18e63514e73a88c75d035dceddb68559.json
13.9 KB
{"ast":null,"code":"import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport * as React from 'react';\nimport warning, { noteOnce } from \"rc-util/es/warning\";\nimport toNodeArray from \"rc-util/es/Children/toArray\";\nimport { convertChildrenToData } from './legacyUtil';\nimport { toArray } from './commonUtil';\n\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 = mode === 'multiple' || mode === 'tags';\n var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';\n var mergedOptions = options || convertChildrenToData(children); // `tags` should not set option as disabled\n\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.'); // `combobox` & `tags` should option be `string` type\n\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\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 } // `combobox` should not use `optionLabelProp`\n\n\n warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.'); // Only `combobox` support `backfill`\n\n warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.'); // Only `combobox` support `getInputElement`\n\n warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.'); // Customize `getInputElement` should not use `allowClear` & `placeholder`\n\n noteOnce(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.'); // `onSearch` should use in `combobox` or `showSearch`\n\n if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {\n warning(false, '`onSearch` should work with `showSearch` instead of use alone.');\n }\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\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 } // Syntactic sugar should use correct children type\n\n\n if (children) {\n var invalidateChildType = null;\n toNodeArray(children).some(function (node) {\n if (!React.isValidElement(node) || !node.type) {\n return false;\n }\n\n var type = node.type;\n\n if (type.isSelectOption) {\n return false;\n }\n\n if (type.isSelectOptGroup) {\n var allChildrenValid = toNodeArray(node.props.children).every(function (subNode) {\n if (!React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {\n return true;\n }\n\n invalidateChildType = subNode.type;\n return false;\n });\n\n if (allChildrenValid) {\n return false;\n }\n\n return true;\n }\n\n invalidateChildType = type;\n return true;\n });\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\n warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');\n }\n}\n\nexport default warningProps;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/utils/warningPropsUtil.js"],"names":["_typeof","React","warning","noteOnce","toNodeArray","convertChildrenToData","toArray","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","isSelectOption","isSelectOptGroup","allChildrenValid","subNode","concat","displayName","name"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,mCAApB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,IAAkBC,QAAlB,QAAkC,oBAAlC;AACA,OAAOC,WAAP,MAAwB,6BAAxB;AACA,SAASC,qBAAT,QAAsC,cAAtC;AACA,SAASC,OAAT,QAAwB,cAAxB;;AAEA,SAASC,YAAT,CAAsBC,KAAtB,EAA6B;AAC3B,MAAIC,IAAI,GAAGD,KAAK,CAACC,IAAjB;AAAA,MACIC,OAAO,GAAGF,KAAK,CAACE,OADpB;AAAA,MAEIC,QAAQ,GAAGH,KAAK,CAACG,QAFrB;AAAA,MAGIC,QAAQ,GAAGJ,KAAK,CAACI,QAHrB;AAAA,MAIIC,UAAU,GAAGL,KAAK,CAACK,UAJvB;AAAA,MAKIC,WAAW,GAAGN,KAAK,CAACM,WALxB;AAAA,MAMIC,eAAe,GAAGP,KAAK,CAACO,eAN5B;AAAA,MAOIC,UAAU,GAAGR,KAAK,CAACQ,UAPvB;AAAA,MAQIC,QAAQ,GAAGT,KAAK,CAACS,QARrB;AAAA,MASIC,WAAW,GAAGV,KAAK,CAACU,WATxB;AAAA,MAUIC,SAAS,GAAGX,KAAK,CAACW,SAVtB;AAAA,MAWIC,YAAY,GAAGZ,KAAK,CAACY,YAXzB;AAAA,MAYIC,KAAK,GAAGb,KAAK,CAACa,KAZlB;AAAA,MAaIC,UAAU,GAAGd,KAAK,CAACc,UAbvB;AAAA,MAcIC,eAAe,GAAGf,KAAK,CAACe,eAd5B;AAeA,MAAIC,QAAQ,GAAGf,IAAI,KAAK,UAAT,IAAuBA,IAAI,KAAK,MAA/C;AACA,MAAIgB,gBAAgB,GAAGT,UAAU,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AACC,cAAT,EAAyB;AACvB,eAAO,KAAP;AACD;;AAED,UAAID,IAAI,CAACE,gBAAT,EAA2B;AACzB,YAAIC,gBAAgB,GAAGzC,WAAW,CAACoC,IAAI,CAAChC,KAAL,CAAWG,QAAZ,CAAX,CAAiCiB,KAAjC,CAAuC,UAAUkB,OAAV,EAAmB;AAC/E,cAAI,CAAC7C,KAAK,CAACwC,cAAN,CAAqBK,OAArB,CAAD,IAAkC,CAACN,IAAI,CAACE,IAAxC,IAAgDI,OAAO,CAACJ,IAAR,CAAaC,cAAjE,EAAiF;AAC/E,mBAAO,IAAP;AACD;;AAEDJ,UAAAA,mBAAmB,GAAGO,OAAO,CAACJ,IAA9B;AACA,iBAAO,KAAP;AACD,SAPsB,CAAvB;;AASA,YAAIG,gBAAJ,EAAsB;AACpB,iBAAO,KAAP;AACD;;AAED,eAAO,IAAP;AACD;;AAEDN,MAAAA,mBAAmB,GAAGG,IAAtB;AACA,aAAO,IAAP;AACD,KA9BD;;AAgCA,QAAIH,mBAAJ,EAAyB;AACvBrC,MAAAA,OAAO,CAAC,KAAD,EAAQ,yEAAyE6C,MAAzE,CAAgFR,mBAAmB,CAACS,WAApB,IAAmCT,mBAAmB,CAACU,IAAvD,IAA+DV,mBAA/I,EAAoK,IAApK,CAAR,CAAP;AACD;;AAEDrC,IAAAA,OAAO,CAACoB,UAAU,KAAKI,SAAhB,EAA2B,+DAA3B,CAAP;AACD;AACF;;AAED,eAAenB,YAAf","sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport * as React from 'react';\nimport warning, { noteOnce } from \"rc-util/es/warning\";\nimport toNodeArray from \"rc-util/es/Children/toArray\";\nimport { convertChildrenToData } from './legacyUtil';\nimport { toArray } from './commonUtil';\n\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 = mode === 'multiple' || mode === 'tags';\n var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';\n var mergedOptions = options || convertChildrenToData(children); // `tags` should not set option as disabled\n\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.'); // `combobox` & `tags` should option be `string` type\n\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\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 } // `combobox` should not use `optionLabelProp`\n\n\n warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.'); // Only `combobox` support `backfill`\n\n warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.'); // Only `combobox` support `getInputElement`\n\n warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.'); // Customize `getInputElement` should not use `allowClear` & `placeholder`\n\n noteOnce(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.'); // `onSearch` should use in `combobox` or `showSearch`\n\n if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {\n warning(false, '`onSearch` should work with `showSearch` instead of use alone.');\n }\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\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 } // Syntactic sugar should use correct children type\n\n\n if (children) {\n var invalidateChildType = null;\n toNodeArray(children).some(function (node) {\n if (!React.isValidElement(node) || !node.type) {\n return false;\n }\n\n var type = node.type;\n\n if (type.isSelectOption) {\n return false;\n }\n\n if (type.isSelectOptGroup) {\n var allChildrenValid = toNodeArray(node.props.children).every(function (subNode) {\n if (!React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {\n return true;\n }\n\n invalidateChildType = subNode.type;\n return false;\n });\n\n if (allChildrenValid) {\n return false;\n }\n\n return true;\n }\n\n invalidateChildType = type;\n return true;\n });\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\n warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');\n }\n}\n\nexport default warningProps;"]},"metadata":{},"sourceType":"module"}