d9438b20c416a8134ca0f4df8cdf5afa.json 10.8 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n/**\n * TODO: 4.0\n * - remove `dataSource`\n * - `size` not work with customizeInput\n * - customizeInput not feedback `ENTER` key since accessibility enhancement\n */\n\nimport * as React from 'react';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport Select from '../select';\nimport { ConfigConsumer } from '../config-provider';\nimport devWarning from '../_util/devWarning';\nimport { isValidElement } from '../_util/reactNode';\nvar Option = Select.Option;\n\nfunction isSelectOptionOrSelectOptGroup(child) {\n  return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup);\n}\n\nvar AutoComplete = function AutoComplete(props, ref) {\n  var customizePrefixCls = props.prefixCls,\n      className = props.className,\n      children = props.children,\n      dataSource = props.dataSource;\n  var childNodes = toArray(children); // ============================= Input =============================\n\n  var customizeInput;\n\n  if (childNodes.length === 1 && isValidElement(childNodes[0]) && !isSelectOptionOrSelectOptGroup(childNodes[0])) {\n    var _childNodes = _slicedToArray(childNodes, 1);\n\n    customizeInput = _childNodes[0];\n  }\n\n  var getInputElement = customizeInput ? function () {\n    return customizeInput;\n  } : undefined; // ============================ Options ============================\n\n  var optionChildren; // [Legacy] convert `children` or `dataSource` into option children\n\n  if (childNodes.length && isSelectOptionOrSelectOptGroup(childNodes[0])) {\n    optionChildren = children;\n  } else {\n    optionChildren = dataSource ? dataSource.map(function (item) {\n      if (isValidElement(item)) {\n        return item;\n      }\n\n      switch (_typeof(item)) {\n        case 'string':\n          return /*#__PURE__*/React.createElement(Option, {\n            key: item,\n            value: item\n          }, item);\n\n        case 'object':\n          {\n            var optionValue = item.value;\n            return /*#__PURE__*/React.createElement(Option, {\n              key: optionValue,\n              value: optionValue\n            }, item.text);\n          }\n\n        default:\n          throw new Error('AutoComplete[dataSource] only supports type `string[] | Object[]`.');\n      }\n    }) : [];\n  } // ============================ Warning ============================\n\n\n  React.useEffect(function () {\n    devWarning(!('dataSource' in props), 'AutoComplete', '`dataSource` is deprecated, please use `options` instead.');\n    devWarning(!customizeInput || !('size' in props), 'AutoComplete', 'You need to control style self instead of setting `size` when using customize input.');\n  }, []);\n  return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {\n    var getPrefixCls = _ref.getPrefixCls;\n    var prefixCls = getPrefixCls('select', customizePrefixCls);\n    return /*#__PURE__*/React.createElement(Select, _extends({\n      ref: ref\n    }, omit(props, ['dataSource']), {\n      prefixCls: prefixCls,\n      className: classNames(\"\".concat(prefixCls, \"-auto-complete\"), className),\n      mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,\n      getInputElement: getInputElement\n    }), optionChildren);\n  });\n};\n\nvar RefAutoComplete = /*#__PURE__*/React.forwardRef(AutoComplete);\nRefAutoComplete.Option = Option;\nexport default RefAutoComplete;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/auto-complete/index.js"],"names":["_extends","_typeof","_slicedToArray","React","toArray","classNames","omit","Select","ConfigConsumer","devWarning","isValidElement","Option","isSelectOptionOrSelectOptGroup","child","type","isSelectOption","isSelectOptGroup","AutoComplete","props","ref","customizePrefixCls","prefixCls","className","children","dataSource","childNodes","customizeInput","length","_childNodes","getInputElement","undefined","optionChildren","map","item","createElement","key","value","optionValue","text","Error","useEffect","_ref","getPrefixCls","concat","mode","SECRET_COMBOBOX_MODE_DO_NOT_USE","RefAutoComplete","forwardRef"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,OAAP,MAAoB,+BAApB;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,OAAOC,UAAP,MAAuB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E,QAAIC,YAAY,GAAGD,IAAI,CAACC,YAAxB;AACA,QAAIrB,SAAS,GAAGqB,YAAY,CAAC,QAAD,EAAWtB,kBAAX,CAA5B;AACA,WAAO,aAAajB,KAAK,CAAC+B,aAAN,CAAoB3B,MAApB,EAA4BP,QAAQ,CAAC;AACvDmB,MAAAA,GAAG,EAAEA;AADkD,KAAD,EAErDb,IAAI,CAACY,KAAD,EAAQ,CAAC,YAAD,CAAR,CAFiD,EAExB;AAC9BG,MAAAA,SAAS,EAAEA,SADmB;AAE9BC,MAAAA,SAAS,EAAEjB,UAAU,CAAC,GAAGsC,MAAH,CAAUtB,SAAV,EAAqB,gBAArB,CAAD,EAAyCC,SAAzC,CAFS;AAG9BsB,MAAAA,IAAI,EAAErC,MAAM,CAACsC,+BAHiB;AAI9BhB,MAAAA,eAAe,EAAEA;AAJa,KAFwB,CAApC,EAOhBE,cAPgB,CAApB;AAQD,GAXmB,CAApB;AAYD,CApED;;AAsEA,IAAIe,eAAe,GAAG,aAAa3C,KAAK,CAAC4C,UAAN,CAAiB9B,YAAjB,CAAnC;AACA6B,eAAe,CAACnC,MAAhB,GAAyBA,MAAzB;AACA,eAAemC,eAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\n/**\n * TODO: 4.0\n * - remove `dataSource`\n * - `size` not work with customizeInput\n * - customizeInput not feedback `ENTER` key since accessibility enhancement\n */\nimport * as React from 'react';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport Select from '../select';\nimport { ConfigConsumer } from '../config-provider';\nimport devWarning from '../_util/devWarning';\nimport { isValidElement } from '../_util/reactNode';\nvar Option = Select.Option;\n\nfunction isSelectOptionOrSelectOptGroup(child) {\n  return child && child.type && (child.type.isSelectOption || child.type.isSelectOptGroup);\n}\n\nvar AutoComplete = function AutoComplete(props, ref) {\n  var customizePrefixCls = props.prefixCls,\n      className = props.className,\n      children = props.children,\n      dataSource = props.dataSource;\n  var childNodes = toArray(children); // ============================= Input =============================\n\n  var customizeInput;\n\n  if (childNodes.length === 1 && isValidElement(childNodes[0]) && !isSelectOptionOrSelectOptGroup(childNodes[0])) {\n    var _childNodes = _slicedToArray(childNodes, 1);\n\n    customizeInput = _childNodes[0];\n  }\n\n  var getInputElement = customizeInput ? function () {\n    return customizeInput;\n  } : undefined; // ============================ Options ============================\n\n  var optionChildren; // [Legacy] convert `children` or `dataSource` into option children\n\n  if (childNodes.length && isSelectOptionOrSelectOptGroup(childNodes[0])) {\n    optionChildren = children;\n  } else {\n    optionChildren = dataSource ? dataSource.map(function (item) {\n      if (isValidElement(item)) {\n        return item;\n      }\n\n      switch (_typeof(item)) {\n        case 'string':\n          return /*#__PURE__*/React.createElement(Option, {\n            key: item,\n            value: item\n          }, item);\n\n        case 'object':\n          {\n            var optionValue = item.value;\n            return /*#__PURE__*/React.createElement(Option, {\n              key: optionValue,\n              value: optionValue\n            }, item.text);\n          }\n\n        default:\n          throw new Error('AutoComplete[dataSource] only supports type `string[] | Object[]`.');\n      }\n    }) : [];\n  } // ============================ Warning ============================\n\n\n  React.useEffect(function () {\n    devWarning(!('dataSource' in props), 'AutoComplete', '`dataSource` is deprecated, please use `options` instead.');\n    devWarning(!customizeInput || !('size' in props), 'AutoComplete', 'You need to control style self instead of setting `size` when using customize input.');\n  }, []);\n  return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {\n    var getPrefixCls = _ref.getPrefixCls;\n    var prefixCls = getPrefixCls('select', customizePrefixCls);\n    return /*#__PURE__*/React.createElement(Select, _extends({\n      ref: ref\n    }, omit(props, ['dataSource']), {\n      prefixCls: prefixCls,\n      className: classNames(\"\".concat(prefixCls, \"-auto-complete\"), className),\n      mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,\n      getInputElement: getInputElement\n    }), optionChildren);\n  });\n};\n\nvar RefAutoComplete = /*#__PURE__*/React.forwardRef(AutoComplete);\nRefAutoComplete.Option = Option;\nexport default RefAutoComplete;"]},"metadata":{},"sourceType":"module"}