UNPKG

k-form-design

Version:

基于vue、ant-design-vue的表单设计器,可视化开发表单

1,561 lines (1,383 loc) 216 kB
((typeof self !== 'undefined' ? self : this)["webpackJsonpk_form_design"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpk_form_design"] || []).push([[6],{ /***/ "133a": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.svgBaseProps = undefined; exports.getThemeFromTypeName = getThemeFromTypeName; exports.removeTypeTheme = removeTypeTheme; exports.withThemeSuffix = withThemeSuffix; exports.alias = alias; var _warning = __webpack_require__("a7e2"); var _warning2 = _interopRequireDefault(_warning); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } // These props make sure that the SVG behaviours like general text. // Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4 var svgBaseProps = exports.svgBaseProps = { width: '1em', height: '1em', fill: 'currentColor', 'aria-hidden': 'true', focusable: 'false' }; var fillTester = /-fill$/; var outlineTester = /-o$/; var twoToneTester = /-twotone$/; function getThemeFromTypeName(type) { var result = null; if (fillTester.test(type)) { result = 'filled'; } else if (outlineTester.test(type)) { result = 'outlined'; } else if (twoToneTester.test(type)) { result = 'twoTone'; } return result; } function removeTypeTheme(type) { return type.replace(fillTester, '').replace(outlineTester, '').replace(twoToneTester, ''); } function withThemeSuffix(type, theme) { var result = type; if (theme === 'filled') { result += '-fill'; } else if (theme === 'outlined') { result += '-o'; } else if (theme === 'twoTone') { result += '-twotone'; } else { (0, _warning2['default'])(false, 'Icon', 'This icon \'' + type + '\' has unknown theme \'' + theme + '\''); } return result; } // For alias or compatibility function alias(type) { var newType = type; switch (type) { case 'cross': newType = 'close'; break; // https://github.com/ant-design/ant-design/issues/13007 case 'interation': newType = 'interaction'; break; // https://github.com/ant-design/ant-design/issues/16810 case 'canlendar': newType = 'calendar'; break; // https://github.com/ant-design/ant-design/issues/17448 case 'colum-height': newType = 'column-height'; break; default: } (0, _warning2['default'])(newType === type, 'Icon', 'Icon \'' + type + '\' was a typo and is now deprecated, please use \'' + newType + '\' instead.'); return newType; } /***/ }), /***/ "148f": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectPropTypes = exports.OptGroup = exports.Option = exports.Select = undefined; var _Select = __webpack_require__("2649"); var _Select2 = _interopRequireDefault(_Select); var _Option = __webpack_require__("b063"); var _Option2 = _interopRequireDefault(_Option); var _PropTypes = __webpack_require__("87fc"); var _OptGroup = __webpack_require__("4913"); var _OptGroup2 = _interopRequireDefault(_OptGroup); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } // based on vc-select 9.2.2 _Select.Select.Option = _Option2['default']; _Select.Select.OptGroup = _OptGroup2['default']; _Select2['default'].Option = _Option2['default']; _Select2['default'].OptGroup = _OptGroup2['default']; exports.Select = _Select.Select; exports.Option = _Option2['default']; exports.OptGroup = _OptGroup2['default']; exports.SelectPropTypes = _PropTypes.SelectPropTypes; exports['default'] = _Select2['default']; /***/ }), /***/ "23f0": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _PropTypes = __webpack_require__("aef2"); exports['default'] = { name: 'StoreProvider', props: { store: _PropTypes.storeShape.isRequired }, provide: function provide() { return { storeContext: this.$props }; }, render: function render() { return this.$slots['default'][0]; } }; /***/ }), /***/ "24ba": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _defineProperty2 = __webpack_require__("6042"); var _defineProperty3 = _interopRequireDefault(_defineProperty2); var _extends2 = __webpack_require__("41b2"); var _extends3 = _interopRequireDefault(_extends2); var _classnames = __webpack_require__("4d26"); var _classnames2 = _interopRequireDefault(_classnames); var _raf = __webpack_require__("c449"); var _raf2 = _interopRequireDefault(_raf); var _vcTrigger = __webpack_require__("2f52"); var _vcTrigger2 = _interopRequireDefault(_vcTrigger); var _vueTypes = __webpack_require__("7b44"); var _vueTypes2 = _interopRequireDefault(_vueTypes); var _DropdownMenu = __webpack_require__("6945"); var _DropdownMenu2 = _interopRequireDefault(_DropdownMenu); var _util = __webpack_require__("d938"); var _BaseMixin = __webpack_require__("48bb"); var _BaseMixin2 = _interopRequireDefault(_BaseMixin); var _propsUtil = __webpack_require__("73c8"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var BUILT_IN_PLACEMENTS = { bottomLeft: { points: ['tl', 'bl'], offset: [0, 4], overflow: { adjustX: 0, adjustY: 1 } }, topLeft: { points: ['bl', 'tl'], offset: [0, -4], overflow: { adjustX: 0, adjustY: 1 } } }; exports['default'] = { name: 'SelectTrigger', mixins: [_BaseMixin2['default']], props: { // onPopupFocus: PropTypes.func, // onPopupScroll: PropTypes.func, dropdownMatchSelectWidth: _vueTypes2['default'].bool, defaultActiveFirstOption: _vueTypes2['default'].bool, dropdownAlign: _vueTypes2['default'].object, visible: _vueTypes2['default'].bool, disabled: _vueTypes2['default'].bool, showSearch: _vueTypes2['default'].bool, dropdownClassName: _vueTypes2['default'].string, dropdownStyle: _vueTypes2['default'].object, dropdownMenuStyle: _vueTypes2['default'].object, multiple: _vueTypes2['default'].bool, inputValue: _vueTypes2['default'].string, filterOption: _vueTypes2['default'].any, empty: _vueTypes2['default'].bool, options: _vueTypes2['default'].any, prefixCls: _vueTypes2['default'].string, popupClassName: _vueTypes2['default'].string, value: _vueTypes2['default'].array, // children: PropTypes.any, showAction: _vueTypes2['default'].arrayOf(_vueTypes2['default'].string), combobox: _vueTypes2['default'].bool, animation: _vueTypes2['default'].string, transitionName: _vueTypes2['default'].string, getPopupContainer: _vueTypes2['default'].func, backfillValue: _vueTypes2['default'].any, menuItemSelectedIcon: _vueTypes2['default'].any, dropdownRender: _vueTypes2['default'].func, ariaId: _vueTypes2['default'].string }, data: function data() { return { dropdownWidth: 0 }; }, created: function created() { this.rafInstance = null; this.saveDropdownMenuRef = (0, _util.saveRef)(this, 'dropdownMenuRef'); this.saveTriggerRef = (0, _util.saveRef)(this, 'triggerRef'); }, mounted: function mounted() { var _this = this; this.$nextTick(function () { _this.setDropdownWidth(); }); }, updated: function updated() { var _this2 = this; this.$nextTick(function () { _this2.setDropdownWidth(); }); }, beforeDestroy: function beforeDestroy() { this.cancelRafInstance(); }, methods: { setDropdownWidth: function setDropdownWidth() { var _this3 = this; this.cancelRafInstance(); this.rafInstance = (0, _raf2['default'])(function () { var width = _this3.$el.offsetWidth; if (width !== _this3.dropdownWidth) { _this3.setState({ dropdownWidth: width }); } }); }, cancelRafInstance: function cancelRafInstance() { if (this.rafInstance) { _raf2['default'].cancel(this.rafInstance); } }, getInnerMenu: function getInnerMenu() { return this.dropdownMenuRef && this.dropdownMenuRef.$refs.menuRef; }, getPopupDOMNode: function getPopupDOMNode() { return this.triggerRef.getPopupDomNode(); }, getDropdownElement: function getDropdownElement(newProps) { var h = this.$createElement; var value = this.value, firstActiveValue = this.firstActiveValue, defaultActiveFirstOption = this.defaultActiveFirstOption, dropdownMenuStyle = this.dropdownMenuStyle, getDropdownPrefixCls = this.getDropdownPrefixCls, backfillValue = this.backfillValue, menuItemSelectedIcon = this.menuItemSelectedIcon; var _getListeners = (0, _propsUtil.getListeners)(this), menuSelect = _getListeners.menuSelect, menuDeselect = _getListeners.menuDeselect, popupScroll = _getListeners.popupScroll; var props = this.$props; var dropdownRender = props.dropdownRender, ariaId = props.ariaId; var dropdownMenuProps = { props: (0, _extends3['default'])({}, newProps.props, { ariaId: ariaId, prefixCls: getDropdownPrefixCls(), value: value, firstActiveValue: firstActiveValue, defaultActiveFirstOption: defaultActiveFirstOption, dropdownMenuStyle: dropdownMenuStyle, backfillValue: backfillValue, menuItemSelectedIcon: menuItemSelectedIcon }), on: (0, _extends3['default'])({}, newProps.on, { menuSelect: menuSelect, menuDeselect: menuDeselect, popupScroll: popupScroll }), directives: [{ name: 'ant-ref', value: this.saveDropdownMenuRef }] }; var menuNode = h(_DropdownMenu2['default'], dropdownMenuProps); if (dropdownRender) { return dropdownRender(menuNode, props); } return null; }, getDropdownTransitionName: function getDropdownTransitionName() { var props = this.$props; var transitionName = props.transitionName; if (!transitionName && props.animation) { transitionName = this.getDropdownPrefixCls() + '-' + props.animation; } return transitionName; }, getDropdownPrefixCls: function getDropdownPrefixCls() { return this.prefixCls + '-dropdown'; } }, render: function render() { var _popupClassName; var h = arguments[0]; var $props = this.$props, $slots = this.$slots; var multiple = $props.multiple, visible = $props.visible, inputValue = $props.inputValue, dropdownAlign = $props.dropdownAlign, disabled = $props.disabled, showSearch = $props.showSearch, dropdownClassName = $props.dropdownClassName, dropdownStyle = $props.dropdownStyle, dropdownMatchSelectWidth = $props.dropdownMatchSelectWidth, options = $props.options, getPopupContainer = $props.getPopupContainer, showAction = $props.showAction, empty = $props.empty; var _getListeners2 = (0, _propsUtil.getListeners)(this), mouseenter = _getListeners2.mouseenter, mouseleave = _getListeners2.mouseleave, popupFocus = _getListeners2.popupFocus, dropdownVisibleChange = _getListeners2.dropdownVisibleChange; var dropdownPrefixCls = this.getDropdownPrefixCls(); var popupClassName = (_popupClassName = {}, (0, _defineProperty3['default'])(_popupClassName, dropdownClassName, !!dropdownClassName), (0, _defineProperty3['default'])(_popupClassName, dropdownPrefixCls + '--' + (multiple ? 'multiple' : 'single'), 1), (0, _defineProperty3['default'])(_popupClassName, dropdownPrefixCls + '--empty', empty), _popupClassName); var popupElement = this.getDropdownElement({ props: { menuItems: options, multiple: multiple, inputValue: inputValue, visible: visible }, on: { popupFocus: popupFocus } }); var hideAction = void 0; if (disabled) { hideAction = []; } else if ((0, _util.isSingleMode)($props) && !showSearch) { hideAction = ['click']; } else { hideAction = ['blur']; } var popupStyle = (0, _extends3['default'])({}, dropdownStyle); var widthProp = dropdownMatchSelectWidth ? 'width' : 'minWidth'; if (this.dropdownWidth) { popupStyle[widthProp] = this.dropdownWidth + 'px'; } var triggerProps = { props: (0, _extends3['default'])({}, $props, { showAction: disabled ? [] : showAction, hideAction: hideAction, ref: 'triggerRef', popupPlacement: 'bottomLeft', builtinPlacements: BUILT_IN_PLACEMENTS, prefixCls: dropdownPrefixCls, popupTransitionName: this.getDropdownTransitionName(), popupAlign: dropdownAlign, popupVisible: visible, getPopupContainer: getPopupContainer, popupClassName: (0, _classnames2['default'])(popupClassName), popupStyle: popupStyle }), on: { popupVisibleChange: dropdownVisibleChange }, directives: [{ name: 'ant-ref', value: this.saveTriggerRef }] }; if (mouseenter) { triggerProps.on.mouseenter = mouseenter; } if (mouseleave) { triggerProps.on.mouseleave = mouseleave; } return h( _vcTrigger2['default'], triggerProps, [$slots['default'], h( 'template', { slot: 'popup' }, [popupElement] )] ); } }; /***/ }), /***/ "2649": /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Select = undefined; var _babelHelperVueJsxMergeProps = __webpack_require__("92fa"); var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps); var _defineProperty2 = __webpack_require__("6042"); var _defineProperty3 = _interopRequireDefault(_defineProperty2); var _extends2 = __webpack_require__("41b2"); var _extends3 = _interopRequireDefault(_extends2); var _KeyCode = __webpack_require__("af09"); var _KeyCode2 = _interopRequireDefault(_KeyCode); var _vueTypes = __webpack_require__("7b44"); var _vueTypes2 = _interopRequireDefault(_vueTypes); var _classnames2 = __webpack_require__("4d26"); var _classnames3 = _interopRequireDefault(_classnames2); var _componentClasses = __webpack_require__("3c55"); var _componentClasses2 = _interopRequireDefault(_componentClasses); var _vcMenu = __webpack_require__("432f"); var _warning = __webpack_require__("d96e"); var _warning2 = _interopRequireDefault(_warning); var _vue = __webpack_require__("8bbf"); var _vue2 = _interopRequireDefault(_vue); var _Option = __webpack_require__("b063"); var _Option2 = _interopRequireDefault(_Option); var _OptGroup = __webpack_require__("4913"); var _OptGroup2 = _interopRequireDefault(_OptGroup); var _propsUtil = __webpack_require__("73c8"); var _getTransitionProps = __webpack_require__("5c25"); var _getTransitionProps2 = _interopRequireDefault(_getTransitionProps); var _vnode = __webpack_require__("d2f9"); var _BaseMixin = __webpack_require__("48bb"); var _BaseMixin2 = _interopRequireDefault(_BaseMixin); var _proxyComponent = __webpack_require__("5c06"); var _proxyComponent2 = _interopRequireDefault(_proxyComponent); var _vueRef = __webpack_require__("46cf"); var _vueRef2 = _interopRequireDefault(_vueRef); var _SelectTrigger = __webpack_require__("24ba"); var _SelectTrigger2 = _interopRequireDefault(_SelectTrigger); var _util = __webpack_require__("d938"); var _PropTypes = __webpack_require__("87fc"); var _contains = __webpack_require__("af8e"); var _contains2 = _interopRequireDefault(_contains); var _env = __webpack_require__("a9eb"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } _vue2['default'].use(_vueRef2['default'], { name: 'ant-ref' }); var SELECT_EMPTY_VALUE_KEY = 'RC_SELECT_EMPTY_VALUE_KEY'; var noop = function noop() { return null; }; // Where el is the DOM element you'd like to test for visibility function isHidden(node) { return !node || node.offsetParent === null; } function chaining() { for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) { fns[_key] = arguments[_key]; } return function () { for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } // eslint-disable-line // eslint-disable-line for (var i = 0; i < fns.length; i++) { if (fns[i] && typeof fns[i] === 'function') { fns[i].apply(chaining, args); } } }; } var Select = { inheritAttrs: false, Option: _Option2['default'], OptGroup: _OptGroup2['default'], name: 'Select', mixins: [_BaseMixin2['default']], props: (0, _extends3['default'])({}, _PropTypes.SelectPropTypes, { prefixCls: _PropTypes.SelectPropTypes.prefixCls.def('rc-select'), defaultOpen: _vueTypes2['default'].bool.def(false), labelInValue: _PropTypes.SelectPropTypes.labelInValue.def(false), defaultActiveFirstOption: _PropTypes.SelectPropTypes.defaultActiveFirstOption.def(true), showSearch: _PropTypes.SelectPropTypes.showSearch.def(true), allowClear: _PropTypes.SelectPropTypes.allowClear.def(false), placeholder: _PropTypes.SelectPropTypes.placeholder.def(''), // showArrow: SelectPropTypes.showArrow.def(true), dropdownMatchSelectWidth: _vueTypes2['default'].bool.def(true), dropdownStyle: _PropTypes.SelectPropTypes.dropdownStyle.def(function () { return {}; }), dropdownMenuStyle: _vueTypes2['default'].object.def(function () { return {}; }), optionFilterProp: _PropTypes.SelectPropTypes.optionFilterProp.def('value'), optionLabelProp: _PropTypes.SelectPropTypes.optionLabelProp.def('value'), notFoundContent: _vueTypes2['default'].any.def('Not Found'), backfill: _vueTypes2['default'].bool.def(false), showAction: _PropTypes.SelectPropTypes.showAction.def(['click']), combobox: _vueTypes2['default'].bool.def(false), tokenSeparators: _vueTypes2['default'].arrayOf(_vueTypes2['default'].string).def([]), autoClearSearchValue: _vueTypes2['default'].bool.def(true), tabIndex: _vueTypes2['default'].any.def(0), dropdownRender: _vueTypes2['default'].func.def(function (menu) { return menu; }) // onChange: noop, // onFocus: noop, // onBlur: noop, // onSelect: noop, // onSearch: noop, // onDeselect: noop, // onInputKeydown: noop, }), model: { prop: 'value', event: 'change' }, created: function created() { this.saveInputRef = (0, _util.saveRef)(this, 'inputRef'); this.saveInputMirrorRef = (0, _util.saveRef)(this, 'inputMirrorRef'); this.saveTopCtrlRef = (0, _util.saveRef)(this, 'topCtrlRef'); this.saveSelectTriggerRef = (0, _util.saveRef)(this, 'selectTriggerRef'); this.saveRootRef = (0, _util.saveRef)(this, 'rootRef'); this.saveSelectionRef = (0, _util.saveRef)(this, 'selectionRef'); this._focused = false; this._mouseDown = false; this._options = []; this._empty = false; }, data: function data() { var props = (0, _propsUtil.getOptionProps)(this); var optionsInfo = this.getOptionsInfoFromProps(props); (0, _warning2['default'])(this.__propsSymbol__, 'Replace slots.default with props.children and pass props.__propsSymbol__'); if (props.tags && typeof props.filterOption !== 'function') { var isDisabledExist = Object.keys(optionsInfo).some(function (key) { return optionsInfo[key].disabled; }); (0, _warning2['default'])(!isDisabledExist, 'Please avoid setting option to disabled in tags mode since user can always type text as tag.'); } var state = { _value: this.getValueFromProps(props, true), // true: use default value _inputValue: props.combobox ? this.getInputValueForCombobox(props, optionsInfo, true // use default value ) : '', _open: props.defaultOpen, _optionsInfo: optionsInfo, _backfillValue: '', // a flag for aviod redundant getOptionsInfoFromProps call _skipBuildOptionsInfo: true, _ariaId: (0, _util.generateUUID)() }; return (0, _extends3['default'])({}, state, { _mirrorInputValue: state._inputValue }, this.getDerivedState(props, state)); }, mounted: function mounted() { var _this = this; this.$nextTick(function () { // when defaultOpen is true, we should auto focus search input // https://github.com/ant-design/ant-design/issues/14254 if (_this.autoFocus || _this._open) { _this.focus(); } // this.setState({ // _ariaId: generateUUID(), // }); }); }, watch: { __propsSymbol__: function __propsSymbol__() { (0, _extends3['default'])(this.$data, this.getDerivedState((0, _propsUtil.getOptionProps)(this), this.$data)); }, '$data._inputValue': function $data_inputValue(val) { this.$data._mirrorInputValue = val; } }, updated: function updated() { var _this2 = this; this.$nextTick(function () { if ((0, _util.isMultipleOrTags)(_this2.$props)) { var inputNode = _this2.getInputDOMNode(); var mirrorNode = _this2.getInputMirrorDOMNode(); if (inputNode && inputNode.value && mirrorNode) { inputNode.style.width = ''; inputNode.style.width = mirrorNode.clientWidth + 10 + 'px'; } else if (inputNode) { inputNode.style.width = ''; } } _this2.forcePopupAlign(); }); }, beforeDestroy: function beforeDestroy() { this.clearFocusTime(); this.clearBlurTime(); this.clearComboboxTime(); if (this.dropdownContainer) { document.body.removeChild(this.dropdownContainer); this.dropdownContainer = null; } }, methods: { getDerivedState: function getDerivedState(nextProps, prevState) { var optionsInfo = prevState._skipBuildOptionsInfo ? prevState._optionsInfo : this.getOptionsInfoFromProps(nextProps, prevState); var newState = { _optionsInfo: optionsInfo, _skipBuildOptionsInfo: false }; if ('open' in nextProps) { newState._open = nextProps.open; } if ('value' in nextProps) { var value = this.getValueFromProps(nextProps); newState._value = value; if (nextProps.combobox) { newState._inputValue = this.getInputValueForCombobox(nextProps, optionsInfo); } } return newState; }, getOptionsFromChildren: function getOptionsFromChildren() { var _this3 = this; var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; children.forEach(function (child) { if (!child.data || child.data.slot !== undefined) { return; } if ((0, _propsUtil.getSlotOptions)(child).isSelectOptGroup) { _this3.getOptionsFromChildren(child.componentOptions.children, options); } else { options.push(child); } }); return options; }, getInputValueForCombobox: function getInputValueForCombobox(props, optionsInfo, useDefaultValue) { var value = []; if ('value' in props && !useDefaultValue) { value = (0, _util.toArray)(props.value); } if ('defaultValue' in props && useDefaultValue) { value = (0, _util.toArray)(props.defaultValue); } if (value.length) { value = value[0]; } else { return ''; } var label = value; if (props.labelInValue) { label = value.label; } else if (optionsInfo[(0, _util.getMapKey)(value)]) { label = optionsInfo[(0, _util.getMapKey)(value)].label; } if (label === undefined) { label = ''; } return label; }, getLabelFromOption: function getLabelFromOption(props, option) { return (0, _util.getPropValue)(option, props.optionLabelProp); }, getOptionsInfoFromProps: function getOptionsInfoFromProps(props, preState) { var _this4 = this; var options = this.getOptionsFromChildren(this.$props.children); var optionsInfo = {}; options.forEach(function (option) { var singleValue = (0, _util.getValuePropValue)(option); optionsInfo[(0, _util.getMapKey)(singleValue)] = { option: option, value: singleValue, label: _this4.getLabelFromOption(props, option), title: (0, _propsUtil.getValueByProp)(option, 'title'), disabled: (0, _propsUtil.getValueByProp)(option, 'disabled') }; }); if (preState) { // keep option info in pre state value. var oldOptionsInfo = preState._optionsInfo; var value = preState._value; if (value) { value.forEach(function (v) { var key = (0, _util.getMapKey)(v); if (!optionsInfo[key] && oldOptionsInfo[key] !== undefined) { optionsInfo[key] = oldOptionsInfo[key]; } }); } } return optionsInfo; }, getValueFromProps: function getValueFromProps(props, useDefaultValue) { var value = []; if ('value' in props && !useDefaultValue) { value = (0, _util.toArray)(props.value); } if ('defaultValue' in props && useDefaultValue) { value = (0, _util.toArray)(props.defaultValue); } if (props.labelInValue) { value = value.map(function (v) { return v.key; }); } return value; }, onInputChange: function onInputChange(e) { var _e$target = e.target, val = _e$target.value, composing = _e$target.composing; var _$data$_inputValue = this.$data._inputValue, _inputValue = _$data$_inputValue === undefined ? '' : _$data$_inputValue; if (e.isComposing || composing || _inputValue === val) { this.setState({ _mirrorInputValue: val }); return; } var tokenSeparators = this.$props.tokenSeparators; if ((0, _util.isMultipleOrTags)(this.$props) && tokenSeparators.length && (0, _util.includesSeparators)(val, tokenSeparators)) { var nextValue = this.getValueByInput(val); if (nextValue !== undefined) { this.fireChange(nextValue); } this.setOpenState(false, { needFocus: true }); this.setInputValue('', false); return; } this.setInputValue(val); this.setState({ _open: true }); if ((0, _util.isCombobox)(this.$props)) { this.fireChange([val]); } }, onDropdownVisibleChange: function onDropdownVisibleChange(open) { if (open && !this._focused) { this.clearBlurTime(); this.timeoutFocus(); this._focused = true; this.updateFocusClassName(); } this.setOpenState(open); }, // combobox ignore onKeyDown: function onKeyDown(event) { var open = this.$data._open; var disabled = this.$props.disabled; if (disabled) { return; } var keyCode = event.keyCode; if (open && !this.getInputDOMNode()) { this.onInputKeydown(event); } else if (keyCode === _KeyCode2['default'].ENTER || keyCode === _KeyCode2['default'].DOWN) { // vue state是同步更新,onKeyDown在onMenuSelect后会再次调用,单选时不在调用setOpenState // https://github.com/vueComponent/ant-design-vue/issues/1142 if (keyCode === _KeyCode2['default'].ENTER && !(0, _util.isMultipleOrTags)(this.$props)) { this.maybeFocus(true); } else if (!open) { this.setOpenState(true); } event.preventDefault(); } else if (keyCode === _KeyCode2['default'].SPACE) { // Not block space if popup is shown if (!open) { this.setOpenState(true); event.preventDefault(); } } }, onInputKeydown: function onInputKeydown(event) { var _this5 = this; var _$props = this.$props, disabled = _$props.disabled, combobox = _$props.combobox, defaultActiveFirstOption = _$props.defaultActiveFirstOption; if (disabled) { return; } var state = this.$data; var isRealOpen = this.getRealOpenState(state); var keyCode = event.keyCode; if ((0, _util.isMultipleOrTags)(this.$props) && !event.target.value && keyCode === _KeyCode2['default'].BACKSPACE) { event.preventDefault(); var value = state._value; if (value.length) { this.removeSelected(value[value.length - 1]); } return; } if (keyCode === _KeyCode2['default'].DOWN) { if (!state._open) { this.openIfHasChildren(); event.preventDefault(); event.stopPropagation(); return; } } else if (keyCode === _KeyCode2['default'].ENTER && state._open) { // Aviod trigger form submit when select item // https://github.com/ant-design/ant-design/issues/10861 // https://github.com/ant-design/ant-design/issues/14544 if (isRealOpen || !combobox) { event.preventDefault(); } // Hard close popup to avoid lock of non option in combobox mode if (isRealOpen && combobox && defaultActiveFirstOption === false) { this.comboboxTimer = setTimeout(function () { _this5.setOpenState(false); }); } } else if (keyCode === _KeyCode2['default'].ESC) { if (state._open) { this.setOpenState(false); event.preventDefault(); event.stopPropagation(); } return; } if (isRealOpen && this.selectTriggerRef) { var menu = this.selectTriggerRef.getInnerMenu(); if (menu && menu.onKeyDown(event, this.handleBackfill)) { event.preventDefault(); event.stopPropagation(); } } }, onMenuSelect: function onMenuSelect(_ref) { var item = _ref.item; if (!item) { return; } var value = this.$data._value; var props = this.$props; var selectedValue = (0, _util.getValuePropValue)(item); var lastValue = value[value.length - 1]; var skipTrigger = false; if ((0, _util.isMultipleOrTags)(props)) { if ((0, _util.findIndexInValueBySingleValue)(value, selectedValue) !== -1) { skipTrigger = true; } else { value = value.concat([selectedValue]); } } else { if (!(0, _util.isCombobox)(props) && lastValue !== undefined && lastValue === selectedValue && selectedValue !== this.$data._backfillValue) { this.setOpenState(false, { needFocus: true, fireSearch: false }); skipTrigger = true; } else { value = [selectedValue]; this.setOpenState(false, { needFocus: true, fireSearch: false }); } } if (!skipTrigger) { this.fireChange(value); } if (!skipTrigger) { this.fireSelect(selectedValue); var inputValue = (0, _util.isCombobox)(props) ? (0, _util.getPropValue)(item, props.optionLabelProp) : ''; if (props.autoClearSearchValue) { this.setInputValue(inputValue, false); } } }, onMenuDeselect: function onMenuDeselect(_ref2) { var item = _ref2.item, domEvent = _ref2.domEvent; if (domEvent.type === 'keydown' && domEvent.keyCode === _KeyCode2['default'].ENTER) { var menuItemDomNode = item.$el; // https://github.com/ant-design/ant-design/issues/20465#issuecomment-569033796 if (!isHidden(menuItemDomNode)) { this.removeSelected((0, _util.getValuePropValue)(item)); } return; } if (domEvent.type === 'click') { this.removeSelected((0, _util.getValuePropValue)(item)); } if (this.autoClearSearchValue) { this.setInputValue(''); } }, onArrowClick: function onArrowClick(e) { e.stopPropagation(); e.preventDefault(); this.clearBlurTime(); if (!this.disabled) { this.setOpenState(!this.$data._open, { needFocus: !this.$data._open }); } }, onPlaceholderClick: function onPlaceholderClick() { if (this.getInputDOMNode() && this.getInputDOMNode()) { this.getInputDOMNode().focus(); } }, onPopupFocus: function onPopupFocus() { // fix ie scrollbar, focus element again this.maybeFocus(true, true); }, onClearSelection: function onClearSelection(event) { var props = this.$props; var state = this.$data; if (props.disabled) { return; } var inputValue = state._inputValue, value = state._value; event.stopPropagation(); if (inputValue || value.length) { if (value.length) { this.fireChange([]); } this.setOpenState(false, { needFocus: true }); if (inputValue) { this.setInputValue(''); } } }, onChoiceAnimationLeave: function onChoiceAnimationLeave() { this.forcePopupAlign(); }, getOptionInfoBySingleValue: function getOptionInfoBySingleValue(value, optionsInfo) { var h = this.$createElement; var info = void 0; optionsInfo = optionsInfo || this.$data._optionsInfo; if (optionsInfo[(0, _util.getMapKey)(value)]) { info = optionsInfo[(0, _util.getMapKey)(value)]; } if (info) { return info; } var defaultLabel = value; if (this.$props.labelInValue) { var valueLabel = (0, _util.getLabelFromPropsValue)(this.$props.value, value); var defaultValueLabel = (0, _util.getLabelFromPropsValue)(this.$props.defaultValue, value); if (valueLabel !== undefined) { defaultLabel = valueLabel; } else if (defaultValueLabel !== undefined) { defaultLabel = defaultValueLabel; } } var defaultInfo = { option: h( _Option2['default'], { attrs: { value: value }, key: value }, [value] ), value: value, label: defaultLabel }; return defaultInfo; }, getOptionBySingleValue: function getOptionBySingleValue(value) { var _getOptionInfoBySingl = this.getOptionInfoBySingleValue(value), option = _getOptionInfoBySingl.option; return option; }, getOptionsBySingleValue: function getOptionsBySingleValue(values) { var _this6 = this; return values.map(function (value) { return _this6.getOptionBySingleValue(value); }); }, getValueByLabel: function getValueByLabel(label) { var _this7 = this; if (label === undefined) { return null; } var value = null; Object.keys(this.$data._optionsInfo).forEach(function (key) { var info = _this7.$data._optionsInfo[key]; var disabled = info.disabled; if (disabled) { return; } var oldLable = (0, _util.toArray)(info.label); if (oldLable && oldLable.join('') === label) { value = info.value; } }); return value; }, getVLBySingleValue: function getVLBySingleValue(value) { if (this.$props.labelInValue) { return { key: value, label: this.getLabelBySingleValue(value) }; } return value; }, getVLForOnChange: function getVLForOnChange(vlsS) { var _this8 = this; var vls = vlsS; if (vls !== undefined) { if (!this.labelInValue) { vls = vls.map(function (v) { return v; }); } else { vls = vls.map(function (vl) { return { key: vl, label: _this8.getLabelBySingleValue(vl) }; }); } return (0, _util.isMultipleOrTags)(this.$props) ? vls : vls[0]; } return vls; }, getLabelBySingleValue: function getLabelBySingleValue(value, optionsInfo) { var _getOptionInfoBySingl2 = this.getOptionInfoBySingleValue(value, optionsInfo), label = _getOptionInfoBySingl2.label; return label; }, getDropdownContainer: function getDropdownContainer() { if (!this.dropdownContainer) { this.dropdownContainer = document.createElement('div'); document.body.appendChild(this.dropdownContainer); } return this.dropdownContainer; }, getPlaceholderElement: function getPlaceholderElement() { var h = this.$createElement; var props = this.$props, state = this.$data; var hidden = false; if (state._mirrorInputValue) { hidden = true; } var value = state._value; if (value.length) { hidden = true; } if (!state._mirrorInputValue && (0, _util.isCombobox)(props) && value.length === 1 && state._value && !state._value[0]) { hidden = false; } var placeholder = props.placeholder; if (placeholder) { var p = { on: { mousedown: _util.preventDefaultEvent, click: this.onPlaceholderClick }, attrs: _util.UNSELECTABLE_ATTRIBUTE, style: (0, _extends3['default'])({ display: hidden ? 'none' : 'block' }, _util.UNSELECTABLE_STYLE), 'class': props.prefixCls + '-selection__placeholder' }; return h( 'div', p, [placeholder] ); } return null; }, inputClick: function inputClick(e) { if (this.$data._open) { this.clearBlurTime(); e.stopPropagation(); } else { this._focused = false; } }, inputBlur: function inputBlur(e) { var _this9 = this; var target = e.relatedTarget || document.activeElement; // https://github.com/vueComponent/ant-design-vue/issues/999 // https://github.com/vueComponent/ant-design-vue/issues/1223 if ((_env.isIE || _env.isEdge) && (e.relatedTarget === this.$refs.arrow || target && this.selectTriggerRef && this.selectTriggerRef.getInnerMenu() && this.selectTriggerRef.getInnerMenu().$el === target || (0, _contains2['default'])(e.target, target))) { e.target.focus(); e.preventDefault(); return; } this.clearBlurTime(); if (this.disabled) { e.preventDefault(); return; } this.blurTimer = setTimeout(function () { _this9._focused = false; _this9.updateFocusClassName(); var props = _this9.$props; var value = _this9.$data._value; var inputValue = _this9.$data._inputValue; if ((0, _util.isSingleMode)(props) && props.showSearch && inputValue && props.defaultActiveFirstOption) { var options = _this9._options || []; if (options.length) { var firstOption = (0, _util.findFirstMenuItem)(options); if (firstOption) { value = [(0, _util.getValuePropValue)(firstOption)]; _this9.fireChange(value); } } } else if ((0, _util.isMultipleOrTags)(props) && inputValue) { if (_this9._mouseDown) { // need update dropmenu when not blur _this9.setInputValue(''); } else { // why not use setState? _this9.$data._inputValue = ''; if (_this9.getInputDOMNode && _this9.getInputDOMNode()) { _this9.getInputDOMNode().value = ''; } } var tmpValue = _this9.getValueByInput(inputValue); if (tmpValue !== undefined) { value = tmpValue; _this9.fireChange(value); } } // if click the rest space of Select in multiple mode if ((0, _util.isMultipleOrTags)(props) && _this9._mouseDown) { _this9.maybeFocus(true, true); _this9._mouseDown = false; return; } _this9.setOpenState(false); _this9.$emit('blur', _this9.getVLForOnChange(value)); }, 200); }, inputFocus: function inputFocus(e) { if (this.$props.disabled) { e.preventDefault(); return; } this.clearBlurTime(); // In IE11, onOuterFocus will be trigger twice when focus input // First one: e.target is div // Second one: e.target is input // other browser only trigger second one // https://github.com/ant-design/ant-design/issues/15942 // Here we ignore the first one when e.target is div var inputNode = this.getInputDOMNode(); if (inputNode && e.target === this.rootRef) { return; } if (!(0, _util.isMultipleOrTagsOrCombobox)(this.$props) && e.target === inputNode) { return; } if (this._focused) { return; } this._focused = true; this.updateFocusClassName(); // only effect multiple or tag mode if (!(0, _util.isMultipleOrTags)(this.$props) || !this._mouseDown) { this.timeoutFocus(); } }, _getInputElement: function _getInputElement() { var h = this.$createElement; var props = this.$props; var _$data = this.$data, inputValue = _$data._inputValue, _mirrorInputValue = _$data._mirrorInputValue; var attrs = (0, _propsUtil.getAttrs)(this); var defaultInput = h('input', { attrs: { id: attrs.id, autoComplete: 'off' } }); var inputElement = props.getInputElement ? props.getInputElement() : defaultInput; var inputCls = (0, _classnames3['default'])((0, _propsUtil.getClass)(inputElement), (0, _defineProperty3['default'])({}, props.prefixCls + '-search__field', true)); var inputEvents = (0, _propsUtil.getEvents)(inputElement); // https://github.com/ant-design/ant-design/issues/4992#issuecomment-281542159 // Add space to the end of the inputValue as the width measurement tolerance inputElement.data = inputElement.data || {}; return h( 'div', { 'class': props.prefixCls + '-search__field__wrap', on: { 'click': this.inputClick } }, [(0, _vnode.cloneElement)(inputElement, { props: { disabled: props.disabled, value: inputValue }, attrs: (0, _extends3['default'])({}, inputElement.data.attrs || {}, { disabled: props.disabled, value: inputValue }), domProps: { value: inputValue }, 'class': inputCls, directives: [{ name: 'ant-ref', value: this.saveInputRef }, { name: 'ant-input' }], on: { input: this.onInputChange, keydown: chaining(this.onInputKeydown, inputEvents.keydown, (0, _propsUtil.getListeners)(this).inputKeydown), focus: chaining(this.inputFocus, inputEvents.focus), blur: chaining(this.inputBlur, inputEvents.blur) } }), h( 'span', (0, _babelHelperVueJsxMergeProps2['default'])([{ directives: [{ name: 'ant-ref', value: this.saveInputMirrorRef }] }, { // ref='inputMirrorRef' 'class': props.prefixCls + '-search__field__mirror' }]), [_mirrorInputValue, '\xA0'] )] ); }, getInputDOMNode: function getInputDOMNode() { return this.topCtrlRef ? this.topCtrlRef.querySelector('input,textarea,div[contentEditable]') : this.inputRef; }, getInputMirrorDOMNode: function getInputMirrorDOMNode() { return this.inputMirrorRef; }, getPopupDOMNode: function getPopupDOMNode() { if (this.selectTriggerRef) { return this.selectTriggerRef.getPopupDOMNode(); } }, getPopupMenuComponent: function getPopupMenuComponent() { if (this.selectTriggerRef) { return this.selectTriggerRef.getInnerMenu(); } }, setOpenState: function setOpenState(open) { var _this10 = this; var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var props = this.$props, state = this.$data; var needFocus = config.needFocus, fireSearch = config.fireSearch; if (state._open === open) { this.maybeFocus(open, !!needFocus); return; } this.__emit('dropdownVisibleChange', open); var nextState = { _open: open, _backfillValue: '' }; // clear search input value when open is false in singleMode. if (!open && (0, _util.isSingleMode)(props) && props.showSearch) { this.setInputValue('', fireSearch); } if (!open) { this.maybeFocus(open, !!needFocus); } this.setState(nextState, function () { if (open) { _this10.maybeFocus(open, !!needFocus); } }); }, setInputValue: function setInputValue(inputValue) { var fireSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (inputValue !== this.$data._inputValue) { this.setState({ _inputValue: inputValue }, this.forcePopupAlign); if (fireSearch) { this.$emit('search', inputValue); } } }, getValueByInput: function getValueByInput(str) { var _this11 = this; var _$props2 = this.$props, multiple = _$props2.multiple, tokenSeparators = _$props2.tokenSeparators; var nextValue = this.$data._value; var hasNewValue = false; (0, _util.splitBySeparators)(str, tokenSeparators).forEach(function (label) { var selectedValue = [label]; if (multiple) { var value = _this11.getValueByLabel(label); if (value && (0, _util.findIndexInValueBySingleValue)(nextValue, value) === -1) { nextValue = nextValue.concat(value); hasNewValue = true; _this11.fireSelect(value); } } else if ((0, _util.findIndexInValueBySingleValue)(nextValue, label) === -1) { nextValue = nextValue.concat(selectedValue); hasNewValue = true; _this11.fireSelect(label); } }); return hasNewValue ? nextValue : undefined; }, getRealOpenState: function getRealOpenState(state) { var _open = this.$props.open; if (typeof _open === 'boolean') { return _open; } var open = (state || this.$data)._open; var options = this._options || []; if ((0, _util.isMultipleOrTagsOrCombobox)(this.$props) || !this.$props.showSearch) { if (open && !options.length) { open = false; } } return open; }, focus: function focus() { if ((0, _util.isSingleMode)(this.$props) && this.selectionRef) { this.selectionRef.focus(); } else if (this.getInputDOMNode()) { this.getInputDOMNode().focus(); } }, blur: function blur() { if ((0, _util.isSingleMode)(this.$props) && this.selectionRef) { this.selectionRef.blur(); } else if (this.getInputDOMNode()) { this.getInputDOMNode().blur(); } }, markMouseDown: function markMouseDown() { this._mouseDown = true; }, markMouseLeave: function markMouseLeave() { this._mouseDown = false; }, handleBackfill: function handleBackfill(item) { if (!this.backfill || !((0, _util.isSingleMode)(this.$props) || (0, _util.isCombobox)(this.$props))) { return; } var key = (0, _util.getValuePropValue)(item); if ((0, _util.isCombobox)(this.$props)) { this.setInputValue(key, false); } this.setState({ _value: [key], _backfillValue: key }); }, _filterOption: function _filterOption(input, child) { var defaultFilter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _util.defaultFilterFn; var _$data2 = this.$data, value = _$data2._value, backfillValue = _$data2._backfillValue; var lastValue = value[value.length - 1]; if (!input || lastValue && lastValue === backfillValue) { return true; } var filterFn = this.$props.filterOption; if ((0, _propsUtil.hasProp)(this, 'filterOption')) { if (filterFn === true) { filterFn = defaultFilter.bind(this); } } else { filterFn = defaultFilter.bind(this); } if (!filterFn) { return true; } else if (typeof filterFn === 'function') { return filterFn.call(this, input, child); } else if ((0, _propsUtil.getValueByProp)(child, 'disabled')) { return false; } return true; }, timeoutFocus: function timeoutFocus() { var _this12 = this; if (this.focusTimer) { this.clearFocusTime(); } this.focusTimer = window.setTimeout(function () { // this._focused = true // this.updateFocusClassName() _this12.$emit('focus'); }, 10); }, clearFocusTime: function clearFocusTime() { if (this.focusTimer) { clearTimeout(this.focusTimer); this.focusTimer = null;