How to use the @instructure/ui-utils.createChainedFunction function in @instructure/ui-utils

To help you get started, we’ve selected a few @instructure/ui-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-selectable / src / Selectable / index.js View on Github external
getRootProps: ({
          onMouseDown,
          onClick,
          ...rest
        } = {}) => {
          return {
            onClick: createChainedFunction(this.handleOpenClose, onClick),
            onMouseDown: createChainedFunction((event) => {
              if (event.target !== this._trigger) {
                event.preventDefault() // prevent trigger from losing focus
              }
            }, onMouseDown),
            ...rest
          }
        },
github instructure / instructure-ui / packages / ui-react-utils / src / safeCloneElement.js View on Github external
Object.keys(props).forEach((prop) => {
    // If prop looks like an event handler "on*" and either
    // props[props] or element.props[prop] is a function create a chained function.
    // If only one is a function it will just use that function with no extra overhead.
    // This is necessary in cases where props[prop] is `null` or `undefined` which would
    // otherwise unwantedly override element.props[prop].
    if (prop.indexOf('on') === 0 && (
        typeof props[prop] === 'function' ||
        typeof element.props[prop] === 'function'
    )) {
      mergedProps[prop] = createChainedFunction(element.props[prop], props[prop])
    }
  })
github instructure / instructure-ui / packages / ui-popover / src / Popover / index.js View on Github external
}

      if (shouldContainFocus) {
        // only set aria-expanded if popover can contain focus
        expanded = this.shown ? 'true' : 'false'
      } else {
        expanded = null
      }

      trigger = safeCloneElement(trigger, {
        ref: el => this._trigger = el,
        'aria-expanded': expanded,
        'data-popover-trigger': true,
        onKeyDown: createChainedFunction(this.handleTriggerKeyDown, this.props.onKeyDown),
        onClick: createChainedFunction(onClick, this.props.onClick),
        onBlur: createChainedFunction(this.handleTriggerBlur, this.props.onBlur),
        onFocus: createChainedFunction(onFocus, this.props.onFocus),
        onMouseOut: createChainedFunction(onMouseOut, this.props.onMouseOut),
        onMouseOver: createChainedFunction(onMouseOver, this.props.onMouseOver)
      })
    }

    return trigger
  }
github instructure / instructure-ui / packages / ui-popover / src / Popover / index.js View on Github external
// only set aria-expanded if popover can contain focus
        expanded = this.shown ? 'true' : 'false'
      } else {
        expanded = null
      }

      trigger = safeCloneElement(trigger, {
        ref: el => this._trigger = el,
        'aria-expanded': expanded,
        'data-popover-trigger': true,
        onKeyDown: createChainedFunction(this.handleTriggerKeyDown, this.props.onKeyDown),
        onClick: createChainedFunction(onClick, this.props.onClick),
        onBlur: createChainedFunction(this.handleTriggerBlur, this.props.onBlur),
        onFocus: createChainedFunction(onFocus, this.props.onFocus),
        onMouseOut: createChainedFunction(onMouseOut, this.props.onMouseOut),
        onMouseOver: createChainedFunction(onMouseOver, this.props.onMouseOver)
      })
    }

    return trigger
  }
github instructure / instructure-ui / packages / ui-editable / src / InPlaceEdit / index.js View on Github external
renderEditButton ({ buttonRef, ...rest }) {
    return this.props.renderEditButton({
      buttonRef: createChainedFunction(this.handleEditButtonRef, buttonRef),
      ...rest
    })
  }
github instructure / instructure-ui / packages / ui-overlays / src / Overlay / index.js View on Github external
defaultFocusElement={this.props.defaultFocusElement}
        open={this.state.open}
      >
        {this.props.children}
      
    )

    if (this.props.transition) {
      content = this.renderTransition(content)
    }

    return (
      
        {content}
      
    )
  }
}
github instructure / instructure-ui / packages / ui-selectable / src / Selectable / index.js View on Github external
ref,
          onKeyDown,
          onKeyUp,
          ...rest
        } = {}) => {
          return {
            id: this._id,
            ref: createChainedFunction(ref, (el) => this._trigger = el),
            'aria-haspopup': 'listbox',
            'aria-expanded': isShowingOptions,
            'aria-owns': isShowingOptions ? this._listId : null,
            'aria-controls': isShowingOptions ? this._listId : null,
            'aria-describedby': this._descriptionId,
            'aria-activedescendant': isShowingOptions ? highlightedOptionId : null,
            onKeyDown: createChainedFunction(this.handleKeyDown, onKeyDown),
            onKeyUp: createChainedFunction(this.handleKeyUp, onKeyUp),
            ...rest
          }
        },
github instructure / instructure-ui / packages / ui-calendar / src / Calendar / index.js View on Github external
const cloneButton = (button, onClick) => safeCloneElement(button, {
      onClick: createChainedFunction(button.props.onClick, onClick)
    })
github instructure / instructure-ui / packages / ui-selectable / src / Selectable / index.js View on Github external
getTriggerProps: ({
          ref,
          onKeyDown,
          onKeyUp,
          ...rest
        } = {}) => {
          return {
            id: this._id,
            ref: createChainedFunction(ref, (el) => this._trigger = el),
            'aria-haspopup': 'listbox',
            'aria-expanded': isShowingOptions,
            'aria-owns': isShowingOptions ? this._listId : null,
            'aria-controls': isShowingOptions ? this._listId : null,
            'aria-describedby': this._descriptionId,
            'aria-activedescendant': isShowingOptions ? highlightedOptionId : null,
            onKeyDown: createChainedFunction(this.handleKeyDown, onKeyDown),
            onKeyUp: createChainedFunction(this.handleKeyUp, onKeyUp),
            ...rest
          }
        },