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    
Size: Mime:
// import {
//   number,
//   boolean,
//   string,
//   stringOrFunc,
//   func,
//   node,
//   any,
//   stringOrNumber,
// } from 'uxui-modules/view-container/types'
import { CommonState } from '../../../../state/index.d'

export interface ButtonRenderProp extends Function {
  (
    props: BaseButtonStandardProps,
    state: ButtonState,
    view?: React.ComponentElement<any, any>
  ): any
}

export interface BaseButtonProps {
  class?: string
  className?: string
  classList?: string
  defaultClassName?: string
  styled?: stringOrFunc

  // === aliased
  value?: any
  children?: any
  text?: any

  // might want to just accept aria-label
  // label?: string,
  'aria-label'?: string
  'aria-controls'?: string
  identifier?: string

  // double alias - ONLY FOR COMPATIBILITY - THERE IS A LINT RULE FOR THIS
  handleClick?: any
  onClick?: func
  onSubmit?: func
  // onHover
  // onFocus
  // onPressed

  /**
   * for default square buttons
   */
  isSquare?: boolean
  isLowPriority?: boolean

  // @todo === extend this type for overrides to have combinations of required
  // for url
  to?: string

  // rarely passed in, for isAnimated
  timeout?: number

  // @alias
  shouldAnimate?: boolean
  isAnimated?: boolean
  hasAnimation?: boolean

  isDisabled?: boolean
  isSelected?: boolean
  isFocused?: boolean
  isResting?: boolean
  isPushed?: boolean

  // left | right | number
  iconOrder?: stringOrNumber
  icon?: typeof node | React.Component
  tabIndex?: stringOrNumber

  // added for compat...
  // eslint error here
  isLink?: boolean
  role?: string
  id?: string
  label?: string
  states?: string

  center?: string
  isCenter?: boolean

  isGreen?: boolean
  green?: boolean
  isBlue?: boolean
  blue?: boolean
  isGhost?: boolean
  ghost?: boolean
  isPresentational?: boolean

  snackbarText?: string
  snackbar?: boolean
  onSnackbarClose?: Function
  onSnacbkarUndo?: Function
  snackbarTimeout?: number

  // === for renderProp
  renderProp?: ButtonRenderProp
  renderSnackbar?: ButtonRenderProp
  renderIconAndText?: ButtonRenderProp
  /**
   * @alias renderButtonOrLink
   */
  renderButtonOrLink?: ButtonRenderProp

  // should not be used, use `qa`
  dataQa?: undefined
  qa?: string
}

export const baseButtonPropTypes = {
  // === aliased
  // class: string,
  // className: string,
  // classList: string,
  // defaultClassName: string,
  // styled: stringOrFunc,
  // // === aliased
  // value: any,
  // children: any,
  // text: any,
  // // might want to just accept aria-label
  // // label: string,
  // 'aria-label': string,
  // 'aria-controls': string,
  // identifier: string,
  // // double alias - ONLY FOR COMPATIBILITY - THERE IS A LINT RULE FOR THIS
  // handleClick: any,
  // onClick: func,
  // onSubmit: func,
  // // onHover
  // // onFocus
  // // onPressed
  // // === for renderProp
  // renderProp: node,
  // // element: stringOrFunc,
  // /**
  //  * for default square buttons
  //  */
  // isSquare: boolean,
  // isLowPriority: boolean,
  // // for url
  // to: string,
  // // rarely passed in, for isAnimated
  // timeout: number,
  // // @alias
  // shouldAnimate: boolean,
  // isAnimated: boolean,
  // hasAnimation: boolean,
  // isDisabled: boolean,
  // isSelected: boolean,
  // isFocused: boolean,
  // isResting: boolean,
  // isPushed: boolean,
  // // left | right | number
  // iconOrder: stringOrNumber,
  // icon: node,
  // tabIndex: stringOrNumber,
  // // added for compat...
  // // eslint error here
  // isLink: boolean,
  // role: string,
  // id: string,
  // label: string,
  // states: string,
  // center: string,
  // // isBlue, isGreen, isGhost
  // green: boolean,
  // blue: boolean,
  // ghost: boolean,
  // isPresentational: boolean,
}

export type ButtonRole = 'link' | 'button' | string

export interface BaseButtonStandardProps extends BaseButtonProps {
  isAnimated: boolean
  isDisabled: boolean
  isSelected: boolean
  isFocused: boolean
  isResting: boolean
  isPushed: boolean
  isLowPriority: boolean
  isLink: boolean
  isCenter: boolean
  hasSnackbar: boolean

  isIconLeft: boolean
  isIconRight: boolean

  eventHandlers: ButtonEventHandlers
}

export interface ButtonState extends CommonState {
  // required, but optional on common...
  isActive: boolean
}

export interface ButtonEventHandlers {
  onFocus: React.FocusEventHandler<any>
  onBlur: React.FocusEventHandler<any>
  onKeyDown: React.KeyboardEventHandler<any>
  onClick: React.MouseEventHandler<any>
}

export type StringyBoolean = 'true' | 'false' | true | false | string
export interface AccessibleButtonAttributes {
  id?: string
  'aria-label'?: string
  'aria-pressed'?: string
  'data-qa'?: string
}
export interface PassThroughAttributes {
  className: string
  tabIndex?: number | string
  onSubmit?: React.FormEventHandler<any>
  role?: ButtonRole
}

export { BaseButtonProps as ButtonProps }