UNPKG

semantic-ui-react

Version:
64 lines (45 loc) 2.11 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.partitionHTMLInputProps = exports.htmlInputProps = exports.htmlInputEvents = exports.htmlInputAttrs = undefined; var _includes2 = require('lodash/includes'); var _includes3 = _interopRequireDefault(_includes2); var _forEach2 = require('lodash/forEach'); var _forEach3 = _interopRequireDefault(_forEach2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var htmlInputAttrs = exports.htmlInputAttrs = [ // REACT 'selected', 'defaultValue', 'defaultChecked', // LIMITED HTML PROPS 'autoCapitalize', 'autoComplete', 'autoFocus', 'checked', 'form', 'max', 'maxLength', 'min', 'multiple', 'name', 'pattern', 'placeholder', 'readOnly', 'required', 'step', 'type', 'value']; var htmlInputEvents = exports.htmlInputEvents = [ // EVENTS // keyboard 'onKeyDown', 'onKeyPress', 'onKeyUp', // focus 'onFocus', 'onBlur', // form 'onChange', 'onInput', // mouse 'onClick', 'onContextMenu', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', // selection 'onSelect', // touch 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart']; var htmlInputProps = exports.htmlInputProps = [].concat(htmlInputAttrs, htmlInputEvents); /** * Returns an array of objects consisting of: props of html input element and rest. * @param {object} props A ReactElement props object * @param {array} [htmlProps] An array of html input props * @returns {[{}, {}]} An array of objects */ var partitionHTMLInputProps = exports.partitionHTMLInputProps = function partitionHTMLInputProps(props) { var htmlProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : htmlInputProps; var inputProps = {}; var rest = {}; (0, _forEach3.default)(props, function (val, prop) { return (0, _includes3.default)(htmlProps, prop) ? inputProps[prop] = val : rest[prop] = val; }); return [inputProps, rest]; };