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 (subNode) {\n if (! /*#__PURE__*/React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {\n return true;\n }\n invalidateChildType = subNode.type;\n return false;\n });\n if (allChildrenValid) {\n return false;\n }\n return true;\n }\n invalidateChildType = type;\n return true;\n });\n if (invalidateChildType) {\n warning(false, \"`children` should be `Select.Option` or `Select.OptGroup` instead of `\".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, \"`.\"));\n }\n warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');\n }\n}\n\n// value in Select option should not be null\n// note: OptGroup has options too\nexport function warningNullOptions(options, fieldNames) {\n if (options) {\n var recursiveOptions = function recursiveOptions(optionsList) {\n var inGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n for (var i = 0; i < optionsList.length; i++) {\n var option = optionsList[i];\n if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {\n warning(false, '`value` in Select options should not be `null`.');\n return true;\n }\n if (!inGroup && Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options], true)) {\n break;\n }\n }\n };\n recursiveOptions(options);\n }\n}\nexport default warningProps;","map":{"version":3,"names":["_typeof","toNodeArray","warning","noteOnce","React","isMultiple","toArray","convertChildrenToData","warningProps","props","mode","options","children","backfill","allowClear","placeholder","getInputElement","showSearch","onSearch","defaultOpen","autoFocus","labelInValue","value","inputValue","optionLabelProp","multiple","mergedShowSearch","undefined","mergedOptions","every","opt","disabled","hasNumberValue","some","item","key","values","val","Array","isArray","invalidateChildType","node","isValidElement","type","_ref","isSelectOption","isSelectOptGroup","allChildrenValid","subNode","concat","displayName","name","warningNullOptions","fieldNames","recursiveOptions","optionsList","inGroup","arguments","length","i","option"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-select/es/utils/warningPropsUtil.js"],"sourcesContent":["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 (subNode) {\n if (! /*#__PURE__*/React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {\n return true;\n }\n invalidateChildType = subNode.type;\n return false;\n });\n if (allChildrenValid) {\n return false;\n }\n return true;\n }\n invalidateChildType = type;\n return true;\n });\n if (invalidateChildType) {\n warning(false, \"`children` should be `Select.Option` or `Select.OptGroup` instead of `\".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, \"`.\"));\n }\n warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');\n }\n}\n\n// value in Select option should not be null\n// note: OptGroup has options too\nexport function warningNullOptions(options, fieldNames) {\n if (options) {\n var recursiveOptions = function recursiveOptions(optionsList) {\n var inGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n for (var i = 0; i < optionsList.length; i++) {\n var option = optionsList[i];\n if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {\n warning(false, '`value` in Select options should not be `null`.');\n return true;\n }\n if (!inGroup && Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options], true)) {\n break;\n }\n }\n };\n recursiveOptions(options);\n }\n}\nexport default warningProps;"],"mappings":"AAAA,OAAOA,OAAO,MAAM,mCAAmC;AACvD,OAAOC,WAAW,MAAM,6BAA6B;AACrD,OAAOC,OAAO,IAAIC,QAAQ,QAAQ,oBAAoB;AACtD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,qBAAqB,QAAQ,cAAc;AACpD,SAASC,YAAYA,CAACC,KAAK,EAAE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