@pedidopago/ui 1.16.18 → 1.16.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ export declare const BRAZILIAN_DISTRICTS: {
2
2
  label: string;
3
3
  value: string;
4
4
  }[];
5
- export declare const BRAZILIAN_STATE_OPTIONS: {
5
+ export declare const BRAZILIAN_DISTRICTS_DEFAULT: {
6
6
  label: string;
7
7
  value: string;
8
8
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/components/Combobox/Examples/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;GA4B/B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;GAGjC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/components/Combobox/Examples/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;GA4B/B,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;GAGrC,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BRAZILIAN_STATE_OPTIONS=exports.BRAZILIAN_DISTRICTS=void 0;var BRAZILIAN_DISTRICTS=[{label:"Acre",value:"AC"},{label:"Alagoas",value:"AL"},{label:"Amap\xE1",value:"AP"},{label:"Amazonas",value:"AM"},{label:"Bahia",value:"BA"},{label:"Cear\xE1",value:"CE"},{label:"Distrito Federal",value:"DF"},{label:"Esp\xEDrito Santo",value:"ES"},{label:"Goi\xE1s",value:"GO"},{label:"Maranh\xE3o",value:"MA"},{label:"Mato Grosso",value:"MT"},{label:"Mato Grosso do Sul",value:"MS"},{label:"Minas Gerais",value:"MG"},{label:"Par\xE1",value:"PA"},{label:"Para\xEDba",value:"PB"},{label:"Paran\xE1",value:"PR"},{label:"Pernambuco",value:"PE"},{label:"Piau\xED",value:"PI"},{label:"Rio de Janeiro",value:"RJ"},{label:"Rio Grande do Norte",value:"RN"},{label:"Rio Grande do Sul",value:"RS"},{label:"Rond\xF4nia",value:"RO"},{label:"Roraima",value:"RR"},{label:"Santa Catarina",value:"SC"},{label:"S\xE3o Paulo",value:"SP"},{label:"Sergipe",value:"SE"},{label:"Tocantins",value:"TO"}];exports.BRAZILIAN_DISTRICTS=BRAZILIAN_DISTRICTS;var BRAZILIAN_STATE_OPTIONS=BRAZILIAN_DISTRICTS.map(function(item){return{label:item.label,value:item.value}});exports.BRAZILIAN_STATE_OPTIONS=BRAZILIAN_STATE_OPTIONS;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BRAZILIAN_DISTRICTS_DEFAULT=exports.BRAZILIAN_DISTRICTS=void 0;var BRAZILIAN_DISTRICTS=[{label:"Acre",value:"AC"},{label:"Alagoas",value:"AL"},{label:"Amap\xE1",value:"AP"},{label:"Amazonas",value:"AM"},{label:"Bahia",value:"BA"},{label:"Cear\xE1",value:"CE"},{label:"Distrito Federal",value:"DF"},{label:"Esp\xEDrito Santo",value:"ES"},{label:"Goi\xE1s",value:"GO"},{label:"Maranh\xE3o",value:"MA"},{label:"Mato Grosso",value:"MT"},{label:"Mato Grosso do Sul",value:"MS"},{label:"Minas Gerais",value:"MG"},{label:"Par\xE1",value:"PA"},{label:"Para\xEDba",value:"PB"},{label:"Paran\xE1",value:"PR"},{label:"Pernambuco",value:"PE"},{label:"Piau\xED",value:"PI"},{label:"Rio de Janeiro",value:"RJ"},{label:"Rio Grande do Norte",value:"RN"},{label:"Rio Grande do Sul",value:"RS"},{label:"Rond\xF4nia",value:"RO"},{label:"Roraima",value:"RR"},{label:"Santa Catarina",value:"SC"},{label:"S\xE3o Paulo",value:"SP"},{label:"Sergipe",value:"SE"},{label:"Tocantins",value:"TO"}];exports.BRAZILIAN_DISTRICTS=BRAZILIAN_DISTRICTS;var BRAZILIAN_DISTRICTS_DEFAULT=BRAZILIAN_DISTRICTS.map(function(item){return{label:item.label,value:item.label}});exports.BRAZILIAN_DISTRICTS_DEFAULT=BRAZILIAN_DISTRICTS_DEFAULT;
@@ -1,3 +1,4 @@
1
1
  export declare function ComboboxDefault(): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ComboboxSearchInLabel(): import("react/jsx-runtime").JSX.Element;
2
3
  export declare function ComboboxWithOnFocusShowOptions(): import("react/jsx-runtime").JSX.Element;
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Combobox/Examples/index.tsx"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,4CAuC9B;AAED,wBAAgB,8BAA8B,4CAsB7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Combobox/Examples/index.tsx"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,4CAgD9B;AAED,wBAAgB,qBAAqB,4CAgDpC;AAED,wBAAgB,8BAA8B,4CAsB7C"}
@@ -1,2 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ComboboxDefault=ComboboxDefault,exports.ComboboxWithOnFocusShowOptions=ComboboxWithOnFocusShowOptions;var _react=require("react"),_=require(".."),_Typography=_interopRequireDefault(require("../../../components/Typography")),_Flex=_interopRequireDefault(require("../../Flex")),_constants=require("./constants"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function ComboboxDefault(){function handleChange(){setIsLoading(!0),clearTimeout(null===timer||void 0===timer?void 0:timer.current),timer.current=setTimeout(function(){setIsLoading(!1)},300)}var _useState=(0,_react.useState)(""),_useState2=_slicedToArray(_useState,2),comboboxValue=_useState2[0],setComboboxValue=_useState2[1],_useState3=(0,_react.useState)(!1),_useState4=_slicedToArray(_useState3,2),isLoading=_useState4[0],setIsLoading=_useState4[1],timer=(0,_react.useRef)();// eslint-disable-next-line no-undef
2
- return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"6",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Search for State names. Ex: Acre, Alagoas, Amap\xE1, etc:"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_.Combobox,{label:"Combobox Default",placeholder:"Selecionar",isLoading:isLoading,value:comboboxValue,onChange:function onChange(value){setComboboxValue(value)},onInputChange:function onInputChange(value){setComboboxValue(value),handleChange()},options:_constants.BRAZILIAN_STATE_OPTIONS}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Combobox value: ",comboboxValue]})]})}function ComboboxWithOnFocusShowOptions(){var _useState5=(0,_react.useState)(""),_useState6=_slicedToArray(_useState5,2),comboboxValue=_useState6[0],setComboboxValue=_useState6[1];return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"6",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Search for State names. Ex: Acre, Alagoas, Amap\xE1, etc:"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_.Combobox,{label:"Combobox With onFocusShowOptions",placeholder:"Selecionar",value:comboboxValue,onChange:function onChange(value){setComboboxValue(value)},options:_constants.BRAZILIAN_STATE_OPTIONS,onFocusShowOptions:!0}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Combobox value: ",comboboxValue]})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ComboboxDefault=ComboboxDefault,exports.ComboboxSearchInLabel=ComboboxSearchInLabel,exports.ComboboxWithOnFocusShowOptions=ComboboxWithOnFocusShowOptions;var _react=require("react"),_=require(".."),_Typography=_interopRequireDefault(require("../../../components/Typography")),_Flex=_interopRequireDefault(require("../../Flex")),_constants=require("./constants"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function ComboboxDefault(){function handleChange(){setIsLoading(!0),clearTimeout(null===timer||void 0===timer?void 0:timer.current),timer.current=setTimeout(function(){setIsLoading(!1)},300)}var _useState=(0,_react.useState)(""),_useState2=_slicedToArray(_useState,2),comboboxValue=_useState2[0],setComboboxValue=_useState2[1],_useState3=(0,_react.useState)(!1),_useState4=_slicedToArray(_useState3,2),isLoading=_useState4[0],setIsLoading=_useState4[1],timer=(0,_react.useRef)();// eslint-disable-next-line no-undef
2
+ return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"6",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Search for State names. Ex: Acre, Alagoas, Amap\xE1, etc:"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Best used when options are objects with same label and value properties. Note: If you have different label and value properties, use the `searchIn=label` prop."}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Ex.: ",/*#__PURE__*/(0,_jsxRuntime.jsxs)("code",{children:["[{ label: 'Acre', value: 'Acre' }]"," "]})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_.Combobox,{label:"Combobox Default",placeholder:"Selecionar",isLoading:isLoading,value:comboboxValue,onChange:function onChange(value){setComboboxValue(value)},onInputChange:function onInputChange(value){setComboboxValue(value),handleChange()},options:_constants.BRAZILIAN_DISTRICTS_DEFAULT}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Combobox value: ",comboboxValue]})]})}function ComboboxSearchInLabel(){function handleChange(){setIsLoading(!0),clearTimeout(null===timer||void 0===timer?void 0:timer.current),timer.current=setTimeout(function(){setIsLoading(!1)},300)}var _useState5=(0,_react.useState)(""),_useState6=_slicedToArray(_useState5,2),comboboxValue=_useState6[0],setComboboxValue=_useState6[1],_useState7=(0,_react.useState)(!1),_useState8=_slicedToArray(_useState7,2),isLoading=_useState8[0],setIsLoading=_useState8[1],timer=(0,_react.useRef)();// eslint-disable-next-line no-undef
3
+ return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"6",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Search for State names. Ex: Acre, Alagoas, Amap\xE1, etc:"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Best used when options are objects with different label and value properties. The search will be done in the label property."}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Ex.: ",/*#__PURE__*/(0,_jsxRuntime.jsxs)("code",{children:["[{ label: 'Acre', value: 'AC' }]"," "]})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_.Combobox,{label:"Combobox With search by label",placeholder:"Selecionar",isLoading:isLoading,value:comboboxValue,searchIn:"label",onChange:function onChange(value){setComboboxValue(value)},onInputChange:function onInputChange(value){setComboboxValue(value),handleChange()},options:_constants.BRAZILIAN_DISTRICTS}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Combobox value: ",comboboxValue]})]})}function ComboboxWithOnFocusShowOptions(){var _useState9=(0,_react.useState)(""),_useState10=_slicedToArray(_useState9,2),comboboxValue=_useState10[0],setComboboxValue=_useState10[1];return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",spacing:"6",children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{color:"neutral.neutral6",children:"Search for State names. Ex: Acre, Alagoas, Amap\xE1, etc:"}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_.Combobox,{label:"Combobox With onFocusShowOptions",placeholder:"Selecionar",value:comboboxValue,onChange:function onChange(value){setComboboxValue(value)},options:_constants.BRAZILIAN_DISTRICTS_DEFAULT,onFocusShowOptions:!0}),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Typography.default,{color:"neutral.neutral6",children:["Combobox value: ",comboboxValue]})]})}
@@ -1,3 +1,3 @@
1
1
  import { ComboboxProps } from './types';
2
- export declare function Combobox<T extends string>({ value, onOpen, onChange, onInputChange, onClose, onReset, resetIcon, options, optionsContainerStyles, resultIsLoading, resultNotFound, onFocusShowOptions, isLoading, mode, inFocusAfterSelected, optionsObserver, ...rest }: ComboboxProps<T>): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Combobox<T extends string>({ value, onOpen, onChange, onInputChange, onClose, onReset, resetIcon, options, optionsContainerStyles, resultIsLoading, resultNotFound, onFocusShowOptions, isLoading, mode, inFocusAfterSelected, optionsObserver, searchIn, ...rest }: ComboboxProps<T>): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,EACzC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,EACP,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,IAAe,EACf,oBAA4B,EAC5B,eAAe,EACf,GAAG,IAAI,EACR,EAAE,aAAa,CAAC,CAAC,CAAC,2CAsNlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/index.tsx"],"names":[],"mappings":"AAgCA,OAAO,EAAsB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,EACzC,KAAK,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,EACP,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,IAAe,EACf,oBAA4B,EAC5B,eAAe,EACf,QAAkB,EAClB,GAAG,IAAI,EACR,EAAE,aAAa,CAAC,CAAC,CAAC,2CAiOlB"}
@@ -1 +1,7 @@
1
- "use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Combobox=Combobox;var _react=require("@floating-ui/react"),_react2=require("react"),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_Typography=_interopRequireDefault(require("../Typography")),_ComboboxLoading=require("./ComboboxLoading"),_ComboboxNoResult=require("./ComboboxNoResult"),_ComboboxOption=require("./ComboboxOption"),_utils=require("./utils"),_styles=require("./styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["value","onOpen","onChange","onInputChange","onClose","onReset","resetIcon","options","optionsContainerStyles","resultIsLoading","resultNotFound","onFocusShowOptions","isLoading","mode","inFocusAfterSelected","optionsObserver"];/* eslint-disable no-console */function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function Combobox(_ref){function checkIfHasOption(value){var userSelectedOption=null===options||void 0===options?void 0:options.find(function(option){return option.value.toLowerCase()===value.toLowerCase()});userSelectedOption&&isSuggestionsMode?setIsOpen(!1):(setIsOpen(!0),setActiveIndex(0))}function onChangeSelection(value){(0,_utils.dispatchInputValue)(inputRef,value),setSearchTherm(value),setInputValue(value),null===onChange||void 0===onChange?void 0:onChange(value),setActiveIndex(null),setIsOpen(!1)}var value=_ref.value,onOpen=_ref.onOpen,onChange=_ref.onChange,onInputChange=_ref.onInputChange,onClose=_ref.onClose,onReset=_ref.onReset,resetIcon=_ref.resetIcon,options=_ref.options,optionsContainerStyles=_ref.optionsContainerStyles,resultIsLoading=_ref.resultIsLoading,resultNotFound=_ref.resultNotFound,onFocusShowOptions=_ref.onFocusShowOptions,isLoading=_ref.isLoading,_ref$mode=_ref.mode,mode=void 0===_ref$mode?"select":_ref$mode,_ref$inFocusAfterSele=_ref.inFocusAfterSelected,optionsObserver=_ref.optionsObserver,rest=_objectWithoutProperties(_ref,_excluded),_useState=(0,_react2.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpen=_useState2[0],setIsOpen=_useState2[1],_useState3=(0,_react2.useState)(""),_useState4=_slicedToArray(_useState3,2),searchTherm=_useState4[0],setSearchTherm=_useState4[1],_useState5=(0,_react2.useState)(""),_useState6=_slicedToArray(_useState5,2),inputValue=_useState6[0],setInputValue=_useState6[1],_useState7=(0,_react2.useState)(null),_useState8=_slicedToArray(_useState7,2),activeIndex=_useState8[0],setActiveIndex=_useState8[1],filteredOptions=""!==searchTherm?(0,_utils.filterOptions)({options:options,searchTherm:searchTherm,inputValue:inputValue}):options,hasResults=!!(null!==filteredOptions&&void 0!==filteredOptions&&filteredOptions[0]),isSuggestionsMode="suggestion"===mode,listRef=(0,_react2.useRef)([]),inputRef=(0,_react2.useRef)(null),_useFloating=(0,_react.useFloating)({whileElementsMounted:_react.autoUpdate,open:isOpen,onOpenChange:function onOpenChange(open){open||(null===onClose||void 0===onClose?void 0:onClose(),setActiveIndex(null)),open&&(null===onOpen||void 0===onOpen?void 0:onOpen()),setIsOpen(open)},middleware:[(0,_react.offset)(10),(0,_react.flip)({padding:10}),(0,_react.size)({apply:function apply(_ref2){var rects=_ref2.rects,availableHeight=_ref2.availableHeight,elements=_ref2.elements;Object.assign(elements.floating.style,{width:"".concat(rects.reference.width,"px"),maxHeight:"".concat(availableHeight-60,"px")})},padding:10})]}),refs=_useFloating.refs,floatingStyles=_useFloating.floatingStyles,context=_useFloating.context,role=(0,_react.useRole)(context,{role:"listbox"}),dismiss=(0,_react.useDismiss)(context),listNav=(0,_react.useListNavigation)(context,{listRef:listRef,activeIndex:activeIndex,onNavigate:setActiveIndex,virtual:!0,loop:!0}),_useInteractions=(0,_react.useInteractions)([role,dismiss,listNav]),getReferenceProps=_useInteractions.getReferenceProps,getFloatingProps=_useInteractions.getFloatingProps,getItemProps=_useInteractions.getItemProps;(0,_react2.useEffect)(function(){setInputValue(value),setSearchTherm(value)},[value]);var showRemoveIcon=""!==inputValue&&!(null!==rest&&void 0!==rest&&rest.disabled);return/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Input.default,_objectSpread({ref:inputRef,label:null===rest||void 0===rest?void 0:rest.label,leftIcon:isSuggestionsMode?null:(null===rest||void 0===rest?void 0:rest.leftIcon)||/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"search",color:"neutral.neutral3"}),rightIcon:showRemoveIcon&&(resetIcon||/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"x",color:"neutral.neutral4"})),onRightIconClick:function onRightIconClick(){setIsOpen(!0),onChangeSelection(""),null===onReset||void 0===onReset?void 0:onReset()},ContainerProps:getReferenceProps({ref:refs.setReference}),onChange:function(event){var value=event.target.value;null===onInputChange||void 0===onInputChange?void 0:onInputChange(value),setSearchTherm(value),setInputValue(value),checkIfHasOption(value)},onFocus:function onFocus(e){checkIfHasOption(e.target.value),onFocusShowOptions&&setIsOpen(!0)},onBlur:function onBlur(event){if(!(isSuggestionsMode||null!==activeIndex)){var value=event.target.value,isValidOption=null===options||void 0===options?void 0:options.some(function(option){if("string"==typeof option.label){var _option$label;return(null===(_option$label=option.label)||void 0===_option$label?void 0:_option$label.toLowerCase())===value.toLowerCase()}return!1});isValidOption?onChangeSelection(value):(onChangeSelection(""),null===onReset||void 0===onReset?void 0:onReset())}},value:searchTherm,placeholder:null===rest||void 0===rest?void 0:rest.placeholder,"aria-autocomplete":"list",onKeyDown:function(event){var option=null!==activeIndex&&(null===filteredOptions||void 0===filteredOptions?void 0:filteredOptions[activeIndex]);if("Enter"===event.key&&option){var _value=option.value;event.preventDefault(),onChangeSelection(_value)}}},rest)),isOpen&&!(!hasResults&&isSuggestionsMode)&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.FloatingPortal,{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_react.FloatingFocusManager,{context:context,initialFocus:-1,visuallyHiddenDismiss:!0,returnFocus:void 0!==_ref$inFocusAfterSele&&_ref$inFocusAfterSele,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.ComboboxContainer,_objectSpread(_objectSpread({"data-id":"floating_container"},getFloatingProps({ref:refs.setFloating,style:_objectSpread({},floatingStyles)})),{},{children:[!hasResults&&!isLoading&&(resultNotFound||/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxNoResult.ComboboxNoResult,{therm:searchTherm})),isLoading?resultIsLoading||/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxLoading.ComboboxLoading,{}):hasResults&&(null===filteredOptions||void 0===filteredOptions?void 0:filteredOptions.map(function(item,index){var key="".concat(item.label,"-").concat(item.value);return/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxOption.ComboboxOption,_objectSpread(_objectSpread({},getItemProps({ref:function ref(node){return listRef.current[index]=node},onClick:function onClick(){return onChangeSelection(item.value)},style:_objectSpread({},optionsContainerStyles)})),{},{active:activeIndex===index,children:"string"==typeof item.label?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{children:item.label}):item.label}),key)})),hasResults?optionsObserver:null]}))})})]})}
1
+ "use strict";function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Combobox=Combobox;var _react=require("react"),_react2=require("@floating-ui/react"),_Icon=_interopRequireDefault(require("../Icon")),_Input=_interopRequireDefault(require("../Input")),_Typography=_interopRequireDefault(require("../Typography")),_ComboboxLoading=require("./ComboboxLoading"),_ComboboxNoResult=require("./ComboboxNoResult"),_ComboboxOption=require("./ComboboxOption"),_utils=require("./utils"),_styles=require("./styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["value","onOpen","onChange","onInputChange","onClose","onReset","resetIcon","options","optionsContainerStyles","resultIsLoading","resultNotFound","onFocusShowOptions","isLoading","mode","inFocusAfterSelected","optionsObserver","searchIn"];/* eslint-disable no-console */ // Libs
2
+ // Components
3
+ // Utils
4
+ // Styles
5
+ // Types
6
+ function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function Combobox(_ref){function checkIfHasOption(value){var userSelectedOption=null===options||void 0===options?void 0:options.find(function(option){return option.value.toLowerCase()===value.toLowerCase()});userSelectedOption&&isSuggestionsMode?setIsOpen(!1):(setIsOpen(!0),setActiveIndex(0))}function onChangeSelection(args){var value=(null===args||void 0===args?void 0:args.value)||"",label=(null===args||void 0===args?void 0:args.label)||"";(0,_utils.dispatchInputValue)(inputRef,value),setSearchTerm(label),setInputValue(label),null===onChange||void 0===onChange?void 0:onChange(value),setActiveIndex(null),setIsOpen(!1)}var value=_ref.value,onOpen=_ref.onOpen,onChange=_ref.onChange,onInputChange=_ref.onInputChange,onClose=_ref.onClose,onReset=_ref.onReset,resetIcon=_ref.resetIcon,options=_ref.options,optionsContainerStyles=_ref.optionsContainerStyles,resultIsLoading=_ref.resultIsLoading,resultNotFound=_ref.resultNotFound,onFocusShowOptions=_ref.onFocusShowOptions,isLoading=_ref.isLoading,_ref$mode=_ref.mode,mode=void 0===_ref$mode?"select":_ref$mode,_ref$inFocusAfterSele=_ref.inFocusAfterSelected,optionsObserver=_ref.optionsObserver,_ref$searchIn=_ref.searchIn,searchIn=void 0===_ref$searchIn?"value":_ref$searchIn,rest=_objectWithoutProperties(_ref,_excluded),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpen=_useState2[0],setIsOpen=_useState2[1],_useState3=(0,_react.useState)(""),_useState4=_slicedToArray(_useState3,2),searchTerm=_useState4[0],setSearchTerm=_useState4[1],_useState5=(0,_react.useState)(""),_useState6=_slicedToArray(_useState5,2),inputValue=_useState6[0],setInputValue=_useState6[1],_useState7=(0,_react.useState)(null),_useState8=_slicedToArray(_useState7,2),activeIndex=_useState8[0],setActiveIndex=_useState8[1],shouldLoadDefaultValue=(0,_react.useRef)(!0),showFilteredOptions=""!==searchTerm,filteredOptions=(0,_react.useMemo)(function(){return showFilteredOptions?(0,_utils.filterOptions)({options:options,searchTerm:searchTerm,searchIn:searchIn}):options},[showFilteredOptions,options,searchTerm,searchIn]),hasResults=!!(null!==filteredOptions&&void 0!==filteredOptions&&filteredOptions[0]),isSuggestionsMode="suggestion"===mode,listRef=(0,_react.useRef)([]),inputRef=(0,_react.useRef)(null),_useFloating=(0,_react2.useFloating)({whileElementsMounted:_react2.autoUpdate,open:isOpen,onOpenChange:function onOpenChange(open){open||(null===onClose||void 0===onClose?void 0:onClose(),setActiveIndex(null)),open&&(null===onOpen||void 0===onOpen?void 0:onOpen()),setIsOpen(open)},middleware:[(0,_react2.offset)(10),(0,_react2.flip)({padding:10}),(0,_react2.size)({apply:function apply(_ref2){var rects=_ref2.rects,availableHeight=_ref2.availableHeight,elements=_ref2.elements;Object.assign(elements.floating.style,{width:"".concat(rects.reference.width,"px"),maxHeight:"".concat(availableHeight-60,"px")})},padding:10})]}),refs=_useFloating.refs,floatingStyles=_useFloating.floatingStyles,context=_useFloating.context,role=(0,_react2.useRole)(context,{role:"listbox"}),dismiss=(0,_react2.useDismiss)(context),listNav=(0,_react2.useListNavigation)(context,{listRef:listRef,activeIndex:activeIndex,onNavigate:setActiveIndex,virtual:!0,loop:!0}),_useInteractions=(0,_react2.useInteractions)([role,dismiss,listNav]),getReferenceProps=_useInteractions.getReferenceProps,getFloatingProps=_useInteractions.getFloatingProps,getItemProps=_useInteractions.getItemProps,showRemoveIcon=""!==inputValue&&!(null!==rest&&void 0!==rest&&rest.disabled);// This works only to load the defaultValue once:
7
+ return(0,_react.useEffect)(function(){if(shouldLoadDefaultValue.current&&null!==options&&void 0!==options&&options[0]){var comboboxOption=null===options||void 0===options?void 0:options.find(function(item){return(null===value||void 0===value?void 0:value.toLowerCase())===item.value.toLowerCase()}),optionValue=(0,_utils.getSearchInOption)(comboboxOption,searchIn);setInputValue(optionValue||""),setSearchTerm(optionValue||""),shouldLoadDefaultValue.current=!1}},[value,options]),/*#__PURE__*/(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_Input.default,_objectSpread({ref:inputRef,label:null===rest||void 0===rest?void 0:rest.label,leftIcon:isSuggestionsMode?null:(null===rest||void 0===rest?void 0:rest.leftIcon)||/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"search",color:"neutral.neutral3"}),rightIcon:showRemoveIcon&&(resetIcon||/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"x",color:"neutral.neutral4"})),onRightIconClick:function onRightIconClick(){setIsOpen(!0),onChangeSelection(),null===onReset||void 0===onReset?void 0:onReset()},ContainerProps:getReferenceProps({ref:refs.setReference}),onChange:function(event){var value=event.target.value;null===onInputChange||void 0===onInputChange?void 0:onInputChange(value),setSearchTerm(value),setInputValue(value),checkIfHasOption(value)},onFocus:function onFocus(e){checkIfHasOption(e.target.value),onFocusShowOptions&&setIsOpen(!0)},onBlur:function onBlur(event){if(!(isSuggestionsMode||null!==activeIndex)){var value=event.target.value,comboboxOption=(0,_utils.getComboboxOption)(value,options,searchIn);onChangeSelection(comboboxOption),comboboxOption||(null===onReset||void 0===onReset?void 0:onReset())}},value:searchTerm,placeholder:null===rest||void 0===rest?void 0:rest.placeholder,"aria-autocomplete":"list",onKeyDown:function(event){var option=null!==activeIndex&&(null===filteredOptions||void 0===filteredOptions?void 0:filteredOptions[activeIndex]);if("Enter"===event.key&&option){event.preventDefault();var optionValue=(0,_utils.getSearchInOption)(option,searchIn),comboboxOption=(0,_utils.getComboboxOption)(optionValue,options,searchIn);onChangeSelection(comboboxOption)}}},rest)),isOpen&&!(!hasResults&&isSuggestionsMode)&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_react2.FloatingPortal,{children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_react2.FloatingFocusManager,{context:context,initialFocus:-1,visuallyHiddenDismiss:!0,returnFocus:void 0!==_ref$inFocusAfterSele&&_ref$inFocusAfterSele,children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles.ComboboxContainer,_objectSpread(_objectSpread({"data-id":"floating_container"},getFloatingProps({ref:refs.setFloating,style:_objectSpread({},floatingStyles)})),{},{children:[!hasResults&&!isLoading&&(resultNotFound||/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxNoResult.ComboboxNoResult,{therm:searchTerm})),isLoading?resultIsLoading||/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxLoading.ComboboxLoading,{}):hasResults&&(null===filteredOptions||void 0===filteredOptions?void 0:filteredOptions.map(function(item,index){var key="".concat(item.label,"-").concat(item.value,"-").concat(index);return/*#__PURE__*/(0,_jsxRuntime.jsx)(_ComboboxOption.ComboboxOption,_objectSpread(_objectSpread({},getItemProps({ref:function ref(node){return listRef.current[index]=node},onClick:function onClick(){return onChangeSelection(item)},style:_objectSpread({},optionsContainerStyles)})),{},{active:activeIndex===index,children:"string"==typeof item.label?/*#__PURE__*/(0,_jsxRuntime.jsx)(_Typography.default,{children:item.label}):item.label}),key)})),hasResults?optionsObserver:null]}))})})]})}
@@ -1,5 +1,10 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
2
  import { InputGroupProps } from '../Input/types';
3
+ export type ComboboxSearchIn = 'label' | 'value';
4
+ export type ComboboxOptionItem = {
5
+ label: string | ReactNode;
6
+ value: string;
7
+ };
3
8
  export type ComboboxProps<T = unknown> = Omit<InputGroupProps, 'onChange' | 'value'> & {
4
9
  value: T;
5
10
  isLoading?: boolean;
@@ -11,10 +16,7 @@ export type ComboboxProps<T = unknown> = Omit<InputGroupProps, 'onChange' | 'val
11
16
  onChange?: (value: T) => void;
12
17
  onInputChange?: (value: string) => void;
13
18
  onResults?: (results: string) => void;
14
- options?: Array<{
15
- label: string | ReactNode;
16
- value: string;
17
- }>;
19
+ options?: Array<ComboboxOptionItem>;
18
20
  onFocusShowOptions?: boolean;
19
21
  inFocusAfterSelected?: boolean;
20
22
  resultIsLoading?: ReactNode;
@@ -22,16 +24,14 @@ export type ComboboxProps<T = unknown> = Omit<InputGroupProps, 'onChange' | 'val
22
24
  optionsContainerStyles?: CSSProperties;
23
25
  mode?: 'suggestion' | 'select';
24
26
  optionsObserver?: ReactNode;
27
+ searchIn?: ComboboxSearchIn;
25
28
  };
26
29
  export type ResultComponentProps = {
27
30
  therm: string;
28
31
  };
29
32
  export type FilterOptions = {
30
- options: {
31
- label: string | ReactNode;
32
- value: string;
33
- }[] | undefined;
34
- searchTherm: string | undefined;
35
- inputValue: string | undefined;
33
+ searchIn: ComboboxSearchIn;
34
+ options?: ComboboxOptionItem[] | undefined;
35
+ searchTerm?: string | undefined;
36
36
  };
37
37
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG;IACrF,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EACH;QACE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,GACH,SAAS,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG;IAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG;IACrF,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,CAAC,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FilterOptions } from './types';
2
+ import { ComboboxOptionItem, ComboboxSearchIn, FilterOptions } from './types';
3
3
  /**
4
4
  * The function normalizes a search term by removing spaces, dashes, and
5
5
  * underscores.
@@ -7,7 +7,7 @@ import { FilterOptions } from './types';
7
7
  * term.
8
8
  * @returns a normalized version of the search term.
9
9
  */
10
- export declare function normalizeSearchTherm(therm: string): string;
10
+ export declare function normalizeSearchTerm(therm: string): string;
11
11
  /**
12
12
  * The function dispatches an input event with a specified value to a given input
13
13
  * element.
@@ -26,8 +26,22 @@ export declare function dispatchInputValue(ref: React.RefObject<HTMLInputElement
26
26
  * available options.
27
27
  * @returns a filtered array of options.
28
28
  */
29
- export declare function filterOptions({ options, searchTherm }: FilterOptions): {
30
- label: import("react").ReactNode;
31
- value: string;
32
- }[] | undefined;
29
+ export declare function filterOptions({ options, searchTerm, searchIn }: FilterOptions): ComboboxOptionItem[] | undefined;
30
+ /**
31
+ * The function `getSearchInOption` returns the value or label of a
32
+ * ComboboxOptionItem based on the specified valueAs parameter.
33
+ * @returns either the value of the option if the valueAs parameter is set to
34
+ * 'value', or the label of the option as a string if the valueAs parameter is not
35
+ * 'value'.
36
+ */
37
+ export declare function getSearchInOption(option?: ComboboxOptionItem, searchIn?: ComboboxSearchIn): string | undefined;
38
+ /**
39
+ * The function `getComboboxOption` retrieves a specific option from a list based
40
+ * on a provided value and search criteria.
41
+ * @returns The function `getComboboxOption` returns a `ComboboxOptionItem` object
42
+ * from the `options` array that matches the `value` based on the specified
43
+ * `valueAs` criteria. If a matching option is found, it is returned by the
44
+ * function. If no matching option is found, `undefined` is returned.
45
+ */
46
+ export declare function getComboboxOption(value?: string, options?: ComboboxOptionItem[], searchIn?: ComboboxSearchIn): ComboboxOptionItem | undefined;
33
47
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,UAEjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,QAS9F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,aAAa;;;gBAOpE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Combobox/utils.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,UAEhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,QAS9F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,aAAa,oCAU7E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,gBAAgB,sBAEzF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,kBAAkB,EAAE,EAC9B,QAAQ,CAAC,EAAE,gBAAgB,kCAM5B"}
@@ -1,10 +1,12 @@
1
- "use strict";var _strings=require("../../utils/formatters/strings");Object.defineProperty(exports,"__esModule",{value:!0}),exports.dispatchInputValue=dispatchInputValue,exports.filterOptions=filterOptions,exports.normalizeSearchTherm=normalizeSearchTherm;/**
1
+ "use strict";var _strings=require("../../utils/formatters/strings");Object.defineProperty(exports,"__esModule",{value:!0}),exports.dispatchInputValue=dispatchInputValue,exports.filterOptions=filterOptions,exports.getComboboxOption=getComboboxOption,exports.getSearchInOption=getSearchInOption,exports.normalizeSearchTerm=normalizeSearchTerm;/* eslint-disable no-console */ // Utils
2
+ // Types
3
+ /**
2
4
  * The function normalizes a search term by removing spaces, dashes, and
3
5
  * underscores.
4
6
  * @param {string} therm - The `therm` parameter is a string representing a search
5
7
  * term.
6
8
  * @returns a normalized version of the search term.
7
- */function normalizeSearchTherm(therm){return(0,_strings.normalizeString)(therm).replace(/[ -_]/g,"")}/**
9
+ */function normalizeSearchTerm(therm){return(0,_strings.normalizeString)(therm).replace(/[ -_]/g,"")}/**
8
10
  * The function dispatches an input event with a specified value to a given input
9
11
  * element.
10
12
  * @param ref - A mutable ref object that references an HTMLInputElement or null.
@@ -19,4 +21,17 @@
19
21
  * @param {FilterOptions} - - `options`: An array of objects representing the
20
22
  * available options.
21
23
  * @returns a filtered array of options.
22
- */function filterOptions(_ref){var options=_ref.options,searchTherm=_ref.searchTherm;return null===options||void 0===options?void 0:options.filter(function(item){var itemValueNormalized=normalizeSearchTherm(item.value),searchThermNormalized=normalizeSearchTherm(searchTherm||"");return null===itemValueNormalized||void 0===itemValueNormalized?void 0:itemValueNormalized.includes(searchThermNormalized)})}
24
+ */function filterOptions(_ref){var options=_ref.options,searchTerm=_ref.searchTerm,searchIn=_ref.searchIn;return null===options||void 0===options?void 0:options.filter(function(item){var label=item.label,value=item.value,itemValue="value"===searchIn?value:label,itemValueNormalized=normalizeSearchTerm(itemValue),searchTermNormalized=normalizeSearchTerm(searchTerm||"");return null===itemValueNormalized||void 0===itemValueNormalized?void 0:itemValueNormalized.includes(searchTermNormalized)})}/**
25
+ * The function `getSearchInOption` returns the value or label of a
26
+ * ComboboxOptionItem based on the specified valueAs parameter.
27
+ * @returns either the value of the option if the valueAs parameter is set to
28
+ * 'value', or the label of the option as a string if the valueAs parameter is not
29
+ * 'value'.
30
+ */function getSearchInOption(option,searchIn){return"value"===searchIn?null===option||void 0===option?void 0:option.value:null===option||void 0===option?void 0:option.label}/**
31
+ * The function `getComboboxOption` retrieves a specific option from a list based
32
+ * on a provided value and search criteria.
33
+ * @returns The function `getComboboxOption` returns a `ComboboxOptionItem` object
34
+ * from the `options` array that matches the `value` based on the specified
35
+ * `valueAs` criteria. If a matching option is found, it is returned by the
36
+ * function. If no matching option is found, `undefined` is returned.
37
+ */function getComboboxOption(value,options,searchIn){return null===options||void 0===options?void 0:options.find(function(item){var itemValue="value"===searchIn?item.value:item.label;return(null===itemValue||void 0===itemValue?void 0:itemValue.toLowerCase())===(null===value||void 0===value?void 0:value.toLowerCase())})}
@@ -1 +1 @@
1
- {"version":3,"file":"dash.d.ts","sourceRoot":"","sources":["../../../../src/components/Icon/data/dash.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS;;;;;;;GAy3HrB,CAAC"}
1
+ {"version":3,"file":"dash.d.ts","sourceRoot":"","sources":["../../../../src/components/Icon/data/dash.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS;;;;;;;GAy7HrB,CAAC"}