Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ui-component-library / src / state / typings.ts
Size: Mime:
import {
  EventHandler,
  FocusEventHandler,
  DOMAttributes,
  ReactEventHandler,
  UIEventHandler,
  WheelEventHandler,
  TransitionEventHandler,
} from 'react'
import { IObservable } from 'xmobx/mobx'
import { Observer } from 'xmobx/mobx-react'

export interface UpdatePropNoArgs<PropName> {
  (): CommonState
  (...ignored: any[]): CommonState
}
export interface UpdateProp<PropName, ValueType = boolean> {
  (name: string, value: ValueType): CommonState
  (value: ValueType): CommonState
}

export declare function updateProp(name: string, value: boolean): CommonState
// export declare function updateProp(name, value: boolean) => CommonState<T>;
// export declare function nAry(n: number): <T>(fn: Variadic<T>) => Variadic<T>;

type setActive = UpdateProp<'isActive'>
type handleActive = UpdatePropNoArgs<'isActive'>
type activate = UpdatePropNoArgs<'isActive'>
type handleToggleActive = UpdatePropNoArgs<'isActive'>
type toggleActive = UpdatePropNoArgs<'isActive'>

// ===
type focus = UpdatePropNoArgs<'isFocused'>
type setFocused = UpdateProp<'isFocused'>

type blur = UpdatePropNoArgs<'isFocused'>
type handleFocus = UpdatePropNoArgs<'isFocused'>
type handleBlur = UpdatePropNoArgs<'isFocused'>

// ===

type setClosed = UpdateProp<'isVisible'>
type handleHide = UpdatePropNoArgs<'isVisible'>
type hide = UpdatePropNoArgs<'isVisible'>

type open = UpdatePropNoArgs<'isVisible'>
type setOpen = UpdatePropNoArgs<'isVisible'>
type handleShow = UpdatePropNoArgs<'isVisible'>
type setVisible = UpdateProp<'isVisible'>
type handleOpen = UpdatePropNoArgs<'isVisible'>
type handleToggleVisibility = UpdatePropNoArgs<'isVisible'>
type toggleVisibility = UpdatePropNoArgs<'isVisible'>

type select = UpdatePropNoArgs<'isSelected'>
type setSelected = UpdateProp<'isSelected'>
type handleSelect = UpdatePropNoArgs<'isSelected'>

type unselect = UpdatePropNoArgs<'isSelected'>
type handleUnSelect = UpdatePropNoArgs<'isSelected'>

type toggleSelected = UpdatePropNoArgs<'isSelected'>
type handleToggleSelected = UpdatePropNoArgs<'isSelected'>

type disable = UpdatePropNoArgs<'isDisabled'>
type setDisable = UpdateProp<'isDisabled'>
type handleDisable = UpdatePropNoArgs<'isDisabled'>

type setLabel = UpdateProp<'label', any>
type setValue = UpdateProp<'value', any>

export interface CommonState extends IObservable {
  isVisible: boolean
  isSelected: boolean
  isDisabled: boolean
  isActive: boolean
  isFocused: boolean

  // === active ===
  handleToggleActive: handleToggleActive
  toggleActive: toggleActive
  setActive: setActive
  handleActive: handleActive
  handleInactive: handleActive
  activate: activate

  // === focused ===
  focus: focus
  blur: blur
  setFocused: setFocused
  handleFocus: handleFocus
  handleBlur: handleBlur

  // === visible ===
  setClosed: setClosed
  handleHide: handleHide
  hide: hide
  show: hide

  open: open
  setOpen: setOpen
  handleOpen: handleOpen
  handleShow: handleShow
  setVisible: setVisible
  handleToggleVisibility: handleToggleVisibility
  toggleVisibility: toggleVisibility

  // === select ===
  select: select
  setSelected: setSelected
  handleSelect: handleSelect

  // === disable ===
  disable: disable
  setDisable: setDisable
  handleDisable: handleDisable

  // === isSelected ===
  unselect: unselect
  handleUnSelect: handleUnSelect
  toggleSelected: toggleSelected
  handleToggleSelected: handleToggleSelected

  // === value ===
  label: string | any
  value: string | any
  setLabel: setLabel
  setValue: setValue
}