UNPKG

ll-package

Version:

2 lines (1 loc) 2.3 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../vc-util/warning.js"),C=require("./legacyUtil.js"),P=require("./commonUtil.js"),p=require("../../_util/props-util/index.js"),q=require("../BaseSelect.js");function E(f){const{mode:o,options:h,children:i,backfill:m,allowClear:b,placeholder:g,getInputElement:c,showSearch:u,onSearch:w,defaultOpen:y,autofocus:O,labelInValue:v,value:l,inputValue:S,optionLabelProp:x}=f,d=q.isMultiple(o),V=u!==void 0?u:d||o==="combobox",k=h||C.convertChildrenToData(i);if(e.warningOnce(o!=="tags"||k.every(n=>!n.disabled),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),e.warningOnce(o!=="combobox"||!x,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),e.warningOnce(o==="combobox"||!m,"`backfill` only works with `combobox` mode."),e.warningOnce(o==="combobox"||!c,"`getInputElement` only work with `combobox` mode."),e.noteOnce(o!=="combobox"||!c||!b||!g,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),w&&!V&&o!=="combobox"&&o!=="tags"&&e.warningOnce(!1,"`onSearch` should work with `showSearch` instead of use alone."),e.noteOnce(!y||O,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autofocus` if needed."),l!=null){const n=P.toArray(l);e.warningOnce(!v||n.every(t=>typeof t=="object"&&("key"in t||"value"in t)),"`value` should in shape of `{ value: string | number, label?: any }` when you set `labelInValue` to `true`"),e.warningOnce(!d||Array.isArray(l),"`value` should be array when `mode` is `multiple` or `tags`")}if(i){let n=null;i.some(t=>{var a;if(!p.isValidElement(t)||!t.type)return!1;const{type:r}=t;return r.isSelectOption?!1:r.isSelectOptGroup?!(((a=t.children)===null||a===void 0?void 0:a.default())||[]).every(s=>!p.isValidElement(s)||!t.type||s.type.isSelectOption?!0:(n=s.type,!1)):(n=r,!0)}),n&&e.warningOnce(!1,`\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${n.displayName||n.name||n}\`.`),e.warningOnce(S===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}exports.default=E;