1 line
17 KiB
JSON
1 line
17 KiB
JSON
|
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport toNodeArray from \"rc-util/es/Children/toArray\";\nimport warning, { noteOnce } from \"rc-util/es/warning\";\nimport * as React from 'react';\nimport { isMultiple } from \"../BaseSelect\";\nimport { toArray } from \"./commonUtil\";\nimport { convertChildrenToData } from \"./legacyUtil\";\nfunction warningProps(props) {\n var mode = props.mode,\n options = props.options,\n children = props.children,\n backfill = props.backfill,\n allowClear = props.allowClear,\n placeholder = props.placeholder,\n getInputElement = props.getInputElement,\n showSearch = props.showSearch,\n onSearch = props.onSearch,\n defaultOpen = props.defaultOpen,\n autoFocus = props.autoFocus,\n labelInValue = props.labelInValue,\n value = props.value,\n inputValue = props.inputValue,\n optionLabelProp = props.optionLabelProp;\n var multiple = isMultiple(mode);\n var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';\n var mergedOptions = options || convertChildrenToData(children);\n\n // `tags` should not set option as disabled\n warning(mode !== 'tags' || mergedOptions.every(function (opt) {\n return !opt.disabled;\n }), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.');\n\n // `combobox` & `tags` should option be `string` type\n if (mode === 'tags' || mode === 'combobox') {\n var hasNumberValue = mergedOptions.some(function (item) {\n if (item.options) {\n return item.options.some(function (opt) {\n return typeof ('value' in opt ? opt.value : opt.key) === 'number';\n });\n }\n return typeof ('value' in item ? item.value : item.key) === 'number';\n });\n warning(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');\n }\n\n // `combobox` should not use `optionLabelProp`\n warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');\n\n // Only `combobox` support `backfill`\n warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');\n\n // Only `combobox` support `getInputElement`\n warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');\n\n // Customize `getInputElement` should not use `allowClear` & `placeholder`\n noteOnce(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');\n\n // `onSearch` should use in `combobox` or `showSearch`\n if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {\n warning(false, '`onSearch` should work with `showSearch` instead of use alone.');\n }\n noteOnce(!defaultOpen || autoFocus, '`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed.');\n if (value !== undefined && value !== null) {\n var values = toArray(value);\n warning(!labelInValue || values.every(function (val) {\n return _typeof(val) === 'object' && ('key' in val || 'value' in val);\n }), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');\n warning(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');\n }\n\n // Syntactic sugar should use correct children type\n if (children) {\n var invalidateChildType = null;\n toNodeArray(children).some(function (node) {\n if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {\n return false;\n }\n var _ref = node,\n type = _ref.type;\n if (type.isSelectOption) {\n return false;\n }\n if (type.isSelectOptGroup) {\n var allChildrenValid = toNodeArray(node.props.children).every(function (subNo
|