Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@data-driven-forms/carbon-component-mapper

Package Overview
Dependencies
Maintainers
2
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@data-driven-forms/carbon-component-mapper - npm Package Compare versions

Comparing version 2.24.5 to 2.24.6

2

dist/cjs/select.js

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./defineProperty-75110086.js"),n=require("./extends-edb29469.js"),t=require("./objectWithoutProperties-6a6333c3.js"),o=require("react"),i=_interopDefault(o),a=_interopDefault(require("prop-types")),r=require("./toConsumableArray-43caa138.js"),l=require("./typeof-aef86737.js"),s=require("./slicedToArray-bbb33c2c.js");require("./_arrayPush-dee852de.js");var c=_interopDefault(require("@data-driven-forms/react-form-renderer/dist/cjs/use-field-api")),u=require("./isEqual-587c618f.js"),d=_interopDefault(require("carbon-components-react/lib/components/Select/Select.js")),p=_interopDefault(require("carbon-components-react/lib/components/MultiSelect/MultiSelect.js")),b=_interopDefault(require("carbon-components-react/lib/components/SelectItem/SelectItem.js")),f=_interopDefault(require("carbon-components-react/lib/components/ComboBox/ComboBox.js"));require("carbon-components-react/lib/components/Tooltip/Tooltip.js");var g=require("./prepare-props-4fe8d115.js");function toVal(e){var n,t,o="";if(e)if("object"==typeof e)if(e.push)for(n=0;n<e.length;n++)e[n]&&(t=toVal(e[n]))&&(o&&(o+=" "),o+=t);else for(n in e)e[n]&&(t=toVal(n))&&(o&&(o+=" "),o+=t);else"boolean"==typeof e||e.call||(o&&(o+=" "),o+=e);return o}function clsx(){for(var e,n=0,t="";n<arguments.length;)(e=toVal(arguments[n++]))&&(t&&(t+=" "),t+=e);return t}var h=function fnToString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toString().replace(/\s+/g," ")};function ownKeys(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach((function(t){e._defineProperty(n,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}var v=function reducer(e,n){var t=n.type,o=n.payload,i=n.options,a=void 0===i?[]:i;switch(t){case"updateOptions":return _objectSpread(_objectSpread({},e),{},{options:o,isLoading:!1,promises:{}});case"loaded":return _objectSpread(_objectSpread({},e),{},{isLoading:!1});case"startLoading":return _objectSpread(_objectSpread({},e),{},{isLoading:!0});case"setOptions":return _objectSpread(_objectSpread({},e),{},{options:o});case"initialLoaded":return _objectSpread(_objectSpread({},e),{},{isInitialLoaded:!0});case"setPromises":return _objectSpread(_objectSpread({},e),{},{promises:_objectSpread(_objectSpread({},e.promises),o),options:[].concat(r._toConsumableArray(e.options),r._toConsumableArray(a.filter((function(n){var t=n.value;return!e.options.find((function(e){return e.value===t}))}))))});default:return e}},O=function getSelectValue(e,n,t,o){return n?o.filter((function(n){var o=n.value;return t?e.includes(o):u._isEqual(o,e)})):e},m=function Select(a){var r=a.invalid,c=a.classNamePrefix,u=a.simpleValue,d=a.isMulti,p=a.pluckSingleValue,b=a.options,f=a.loadOptions,g=a.loadingMessage,m=a.loadingProps,y=(a.selectVariant,a.updatingMessage),S=a.noOptionsMessage,C=a.value,M=a.onChange,x=a.loadOptionsChangeCounter,j=a.SelectComponent,_=a.noValueUpdates,P=t._objectWithoutProperties(a,["invalid","classNamePrefix","simpleValue","isMulti","pluckSingleValue","options","loadOptions","loadingMessage","loadingProps","selectVariant","updatingMessage","noOptionsMessage","value","onChange","loadOptionsChangeCounter","SelectComponent","noValueUpdates"]),T=o.useReducer(v,{isLoading:!1,options:b,promises:{},isInitialLoaded:!1}),D=s._slicedToArray(T,2),I=D[0],q=D[1],V=function useIsMounted(){var e=o.useRef(!1);return o.useEffect((function(){return e.current=!0,function(){return e.current=!1}}),[]),e}(),L=function updateOptions(){return q({type:"startLoading"}),f().then((function(e){if(V.current){if(!_)if(C&&Array.isArray(C)){var n=C.filter((function(n){return"object"===l._typeof(n)?e.find((function(e){return n.value===e.value})):e.find((function(e){return n===e.value}))}));M(0===n.length?void 0:n)}else C&&!e.find((function(e){return e.value===C}))&&M(void 0);q({type:"updateOptions",payload:e})}}))};o.useEffect((function(){f&&L(),q({type:"initialLoaded"})}),[]);var E=f?h(f):"";o.useEffect((function(){E&&I.isInitialLoaded&&L()}),[E,x]),o.useEffect((function(){I.isInitialLoaded&&(_||!C||b.map((function(e){return e.value})).includes(C)||M(void 0),q({type:"setOptions",payload:b}))}),[b]);var N=function renderNoOptionsMessage(){return Object.values(I.promises).some((function(e){return e}))?function(){return y}:function(){return S}};if(I.isLoading)return i.createElement(j,n._extends({},P,{classNamePrefix:c,isDisabled:!0,isFetching:!0,placeholder:g,options:I.options,onChange:function onChange(){}},m,{noOptionsMessage:N()}));var A=p?d?C:Array.isArray(C)&&C[0]?C[0]:C:C;return i.createElement(j,n._extends({className:clsx(c,{"has-error":r})},P,{isDisabled:P.isDisabled||P.isReadOnly,options:I.options,classNamePrefix:c,isMulti:d,value:O(A,u,d,I.options),onChange:function onChange(e){return function handleSelectChange(e,n,t,o){var i=!e&&t?[]:e;return o(n?t?i.map((function(e){return e.value})):i?i.value:void 0:i)}(e,u,d,M)},onInputChange:function onInputChange(n){n&&f&&void 0===I.promises[n]&&P.isSearchable&&(q({type:"setPromises",payload:e._defineProperty({},n,!0)}),f(n).then((function(t){V.current&&q({type:"setPromises",payload:e._defineProperty({},n,!1),options:t})})).catch((function(t){throw q({type:"setPromises",payload:e._defineProperty({},n,!1)}),t})))},isFetching:Object.values(I.promises).some((function(e){return e})),noOptionsMessage:N(),hideSelectedOptions:!1,closeMenuOnSelect:!d}))};m.propTypes={options:a.array,onChange:a.func,classNamePrefix:a.string,invalid:a.bool,simpleValue:a.bool,isMulti:a.bool,pluckSingleValue:a.bool,value:a.any,placeholder:a.string,loadOptionsChangeCounter:a.number,isDisabled:a.bool,isReadOnly:a.bool,loadOptions:a.func,loadingMessage:a.node,loadingProps:a.object,selectVariant:a.string,updatingMessage:a.node,noOptionsMessage:a.node,isSearchable:a.bool,SelectComponent:a.elementType.isRequired,noValueUpdates:a.bool},m.defaultProps={options:[],invalid:!1,simpleValue:!0,pluckSingleValue:!0,placeholder:"Choose...",isSearchable:!1,isClearable:!1};var y=function multiOnChange(e,n){return function(t){var o=t.selectedItem,i=t.selectedItems;return n?e.onChange((null==i?void 0:i.map((function(e){return e.value})))||o.value):e.onChange(i||o)}},S=function getMultiValue(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return"object"===l._typeof(e)?e:n.find((function(n){return n.value===e}))}))||[]},C=function ClearedMultiSelectFilterable(e){var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),l=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=t._objectWithoutProperties(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(p.Filterable,n._extends({disabled:c},u,{placeholder:l||s,onChange:r,titleText:u.labelText,id:u.name,invalid:Boolean(o),invalidText:o,items:a,initialSelectedItems:S(u.value,a)}))};C.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isRequired:a.bool,isDisabled:a.bool};var M=function ClearedMultiSelect(e){var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),l=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=t._objectWithoutProperties(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(p,n._extends({disabled:c},u,{label:l||s,onChange:r,titleText:u.labelText,id:u.name,invalid:Boolean(o),invalidText:o,items:a,initialSelectedItems:S(u.value,a)}))};M.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isRequired:a.bool,isDisabled:a.bool};var x=function getSelectValue(e,n){return n?e:Array.isArray(e)?e[0]:e},j=function ClearedSelect(e){e.isSearchable,e.isClearable,e.isDisabled;var o=e.isMulti,a=e.invalidText,r=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange,e.placeholder),c=e.value,u=t._objectWithoutProperties(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","value"]);return i.createElement(d,n._extends({value:x(c,o),disabled:l},u,{id:u.name,invalid:Boolean(a),invalidText:a}),l&&i.createElement(b,{text:s,value:""}),r.map((function(e,t){return i.createElement(b,n._extends({key:e.value||t,text:e.label},e))})))};j.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isDisabled:a.bool,isRequired:a.bool,isSearchable:a.bool,isClearable:a.bool,value:a.any};var _=function getComboInitialValue(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=Array.isArray(e)?e[0]:e;return"object"===l._typeof(t)?t:n.find((function(e){return e.value===t}))||t},P=function ClearedSelectSearchable(e){e.isSearchable,e.isClearable,e.isDisabled,e.isMulti;var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=void 0===a?[]:a,l=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange),c=e.placeholder,u=e.labelText,d=t._objectWithoutProperties(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","labelText"]);return i.createElement(f,n._extends({disabled:l},d,{id:d.name,invalid:Boolean(o),invalidText:o,initialSelectedItem:_(d.value,r),items:r,placeholder:c,titleText:u,onChange:s}))};P.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isDisabled:a.bool,isRequired:a.bool,isSearchable:a.bool,isClearable:a.bool,labelText:a.string};var T=function Select$1(e){var a=c(g.prepareProps(e)),r=a.isMulti,l=a.isSearchable,u=a.isClearable,d=a.loadOptions,p=a.input,b=a.meta,f=a.validateOnMount,v=a.helperText,O=t._objectWithoutProperties(a,["isMulti","isSearchable","isClearable","loadOptions","input","meta","validateOnMount","helperText"]),S=o.useState(0),x=s._slicedToArray(S,2),_=x[0],T=x[1],D=h(d);o.useEffect((function(){T(_+1)}),[D]);var I=l||u,q=r&&I?C:r?M:I?P:j,V=(b.touched||f)&&(b.error||b.submitError)||"",L=(b.touched||f)&&b.warning||v;return i.createElement(m,n._extends({SelectComponent:q,simpleValue:!1},O,p,{loadOptions:d,invalidText:V,loadOptionsChangeCounter:_,originalOnChange:y(p,O.simpleValue),helperText:L}))};T.propTypes={isDisabled:a.bool,isRequired:a.bool,options:a.arrayOf(a.shape({value:a.oneOfType([a.string,a.number]),label:a.node}))},T.defaultProps={loadingMessage:"Loading..."},exports.default=T,exports.multiOnChange=y;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./defineProperty-75110086.js"),n=require("./extends-edb29469.js"),t=require("./objectWithoutProperties-6a6333c3.js"),o=require("react"),i=_interopDefault(o),a=_interopDefault(require("prop-types")),r=require("./toConsumableArray-43caa138.js"),l=require("./typeof-aef86737.js"),s=require("./slicedToArray-bbb33c2c.js");require("./_arrayPush-dee852de.js");var c=_interopDefault(require("@data-driven-forms/react-form-renderer/dist/cjs/use-field-api")),u=require("./isEqual-587c618f.js"),d=_interopDefault(require("carbon-components-react/lib/components/Select/Select.js")),p=_interopDefault(require("carbon-components-react/lib/components/MultiSelect/MultiSelect.js")),b=_interopDefault(require("carbon-components-react/lib/components/SelectItem/SelectItem.js")),f=_interopDefault(require("carbon-components-react/lib/components/ComboBox/ComboBox.js"));require("carbon-components-react/lib/components/Tooltip/Tooltip.js");var g=require("./prepare-props-4fe8d115.js");function toVal(e){var n,t,o="";if(e)if("object"==typeof e)if(e.push)for(n=0;n<e.length;n++)e[n]&&(t=toVal(e[n]))&&(o&&(o+=" "),o+=t);else for(n in e)e[n]&&(t=toVal(n))&&(o&&(o+=" "),o+=t);else"boolean"==typeof e||e.call||(o&&(o+=" "),o+=e);return o}function clsx(){for(var e,n=0,t="";n<arguments.length;)(e=toVal(arguments[n++]))&&(t&&(t+=" "),t+=e);return t}var h=function fnToString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toString().replace(/\s+/g," ")};function ownKeys(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach((function(t){e._defineProperty(n,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}var v=function reducer(e,n){var t=n.type,o=n.payload,i=n.options,a=void 0===i?[]:i;switch(t){case"updateOptions":return _objectSpread(_objectSpread({},e),{},{options:o,isLoading:!1,promises:{}});case"loaded":return _objectSpread(_objectSpread({},e),{},{isLoading:!1});case"startLoading":return _objectSpread(_objectSpread({},e),{},{isLoading:!0});case"setOptions":return _objectSpread(_objectSpread({},e),{},{options:o});case"initialLoaded":return _objectSpread(_objectSpread({},e),{},{isInitialLoaded:!0});case"setPromises":return _objectSpread(_objectSpread({},e),{},{promises:_objectSpread(_objectSpread({},e.promises),o),options:[].concat(r._toConsumableArray(e.options),r._toConsumableArray(a.filter((function(n){var t=n.value;return!e.options.find((function(e){return e.value===t}))}))))});default:return e}},O=function getSelectValue(e,n,t,o){return n?o.filter((function(n){var o=n.value;return t?e.includes(o):u._isEqual(o,e)})):e},m=function Select(a){var r=a.invalid,c=a.classNamePrefix,u=a.simpleValue,d=a.isMulti,p=a.pluckSingleValue,b=a.options,f=a.loadOptions,g=a.loadingMessage,m=a.loadingProps,y=(a.selectVariant,a.updatingMessage),S=a.noOptionsMessage,C=a.value,M=a.onChange,x=a.loadOptionsChangeCounter,j=a.SelectComponent,_=a.noValueUpdates,P=t._objectWithoutProperties(a,["invalid","classNamePrefix","simpleValue","isMulti","pluckSingleValue","options","loadOptions","loadingMessage","loadingProps","selectVariant","updatingMessage","noOptionsMessage","value","onChange","loadOptionsChangeCounter","SelectComponent","noValueUpdates"]),T=o.useReducer(v,{isLoading:!1,options:b,promises:{},isInitialLoaded:!1}),D=s._slicedToArray(T,2),I=D[0],q=D[1],V=function useIsMounted(){var e=o.useRef(!1);return o.useEffect((function(){return e.current=!0,function(){return e.current=!1}}),[]),e}(),L=function updateOptions(){return q({type:"startLoading"}),f().then((function(e){if(V.current){if(!_)if(C&&Array.isArray(C)){var n=C.filter((function(n){return"object"===l._typeof(n)?e.find((function(e){return n.value===e.value})):e.find((function(e){return n===e.value}))}));M(0===n.length?void 0:n)}else C&&!e.find((function(e){return e.value===C}))&&M(void 0);q({type:"updateOptions",payload:e})}}))};o.useEffect((function(){f&&L(),q({type:"initialLoaded"})}),[]);var E=f?h(f):"";o.useEffect((function(){E&&I.isInitialLoaded&&L()}),[E,x]),o.useEffect((function(){I.isInitialLoaded&&(_||!C||b.map((function(e){return e.value})).includes(C)||M(void 0),q({type:"setOptions",payload:b}))}),[b]);var N=function renderNoOptionsMessage(){return Object.values(I.promises).some((function(e){return e}))?function(){return y}:function(){return S}};if(I.isLoading)return i.createElement(j,n._extends({},P,{classNamePrefix:c,isDisabled:!0,isFetching:!0,placeholder:g,options:I.options,onChange:function onChange(){}},m,{noOptionsMessage:N()}));var A=p?d?C:Array.isArray(C)&&C[0]?C[0]:C:C;return i.createElement(j,n._extends({className:clsx(c,{"has-error":r})},P,{isDisabled:P.isDisabled||P.isReadOnly,options:I.options,classNamePrefix:c,isMulti:d,value:O(A,u,d,I.options),onChange:function onChange(e){return function handleSelectChange(e,n,t,o){var i=!e&&t?[]:e;return o(n?t?i.map((function(e){return e.value})):i?i.value:void 0:i)}(e,u,d,M)},onInputChange:function onInputChange(n){n&&f&&void 0===I.promises[n]&&P.isSearchable&&(q({type:"setPromises",payload:e._defineProperty({},n,!0)}),f(n).then((function(t){V.current&&q({type:"setPromises",payload:e._defineProperty({},n,!1),options:t})})).catch((function(t){throw q({type:"setPromises",payload:e._defineProperty({},n,!1)}),t})))},isFetching:Object.values(I.promises).some((function(e){return e})),noOptionsMessage:N(),hideSelectedOptions:!1,closeMenuOnSelect:!d}))};m.propTypes={options:a.array,onChange:a.func,classNamePrefix:a.string,invalid:a.bool,simpleValue:a.bool,isMulti:a.bool,pluckSingleValue:a.bool,value:a.any,placeholder:a.string,loadOptionsChangeCounter:a.number,isDisabled:a.bool,isReadOnly:a.bool,loadOptions:a.func,loadingMessage:a.node,loadingProps:a.object,selectVariant:a.string,updatingMessage:a.node,noOptionsMessage:a.node,isSearchable:a.bool,SelectComponent:a.elementType.isRequired,noValueUpdates:a.bool},m.defaultProps={options:[],invalid:!1,simpleValue:!0,pluckSingleValue:!0,placeholder:"Choose...",isSearchable:!1,isClearable:!1};var y=function multiOnChange(e,n){return function(t){var o=t.selectedItem,i=t.selectedItems;return n?e.onChange((null==i?void 0:i.map((function(e){return e.value})))||o.value):e.onChange(i||o)}},S=function getMultiValue(e,n){return(Array.isArray(e)?e:e?[e]:[]).map((function(e){return"object"===l._typeof(e)?e:n.find((function(n){return n.value===e}))}))},C=function ClearedMultiSelectFilterable(e){var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),l=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=t._objectWithoutProperties(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(p.Filterable,n._extends({disabled:c},u,{placeholder:l||s,onChange:r,titleText:u.labelText,id:u.name,invalid:Boolean(o),invalidText:o,items:a,initialSelectedItems:S(u.value,a)}))};C.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isRequired:a.bool,isDisabled:a.bool};var M=function ClearedMultiSelect(e){var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),l=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=t._objectWithoutProperties(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(p,n._extends({disabled:c},u,{label:l||s,onChange:r,titleText:u.labelText,id:u.name,invalid:Boolean(o),invalidText:o,items:a,initialSelectedItems:S(u.value,a)}))};M.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isRequired:a.bool,isDisabled:a.bool};var x=function getSelectValue(e,n){return n?e:Array.isArray(e)?e[0]:e},j=function ClearedSelect(e){e.isSearchable,e.isClearable,e.isDisabled;var o=e.isMulti,a=e.invalidText,r=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange,e.placeholder),c=e.value,u=t._objectWithoutProperties(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","value"]);return i.createElement(d,n._extends({value:x(c,o),disabled:l},u,{id:u.name,invalid:Boolean(a),invalidText:a}),l&&i.createElement(b,{text:s,value:""}),r.map((function(e,t){return i.createElement(b,n._extends({key:e.value||t,text:e.label},e))})))};j.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isDisabled:a.bool,isRequired:a.bool,isSearchable:a.bool,isClearable:a.bool,value:a.any};var _=function getComboInitialValue(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=Array.isArray(e)?e[0]:e;return"object"===l._typeof(t)?t:n.find((function(e){return e.value===t}))||t},P=function ClearedSelectSearchable(e){e.isSearchable,e.isClearable,e.isDisabled,e.isMulti;var o=e.invalidText,a=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=void 0===a?[]:a,l=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange),c=e.placeholder,u=e.labelText,d=t._objectWithoutProperties(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","labelText"]);return i.createElement(f,n._extends({disabled:l},d,{id:d.name,invalid:Boolean(o),invalidText:o,initialSelectedItem:_(d.value,r),items:r,placeholder:c,titleText:u,onChange:s}))};P.propTypes={invalidText:a.node,hideSelectedOptions:a.any,noOptionsMessage:a.any,onInputChange:a.func,options:a.array,isFetching:a.bool,invalid:a.oneOfType([a.bool,a.node]),isMulti:a.bool,classNamePrefix:a.any,closeMenuOnSelect:a.any,onChange:a.func,originalOnChange:a.func,carbonLabel:a.node,placeholder:a.node,isDisabled:a.bool,isRequired:a.bool,isSearchable:a.bool,isClearable:a.bool,labelText:a.string};var T=function Select$1(e){var a=c(g.prepareProps(e)),r=a.isMulti,l=a.isSearchable,u=a.isClearable,d=a.loadOptions,p=a.input,b=a.meta,f=a.validateOnMount,v=a.helperText,O=t._objectWithoutProperties(a,["isMulti","isSearchable","isClearable","loadOptions","input","meta","validateOnMount","helperText"]),S=o.useState(0),x=s._slicedToArray(S,2),_=x[0],T=x[1],D=h(d);o.useEffect((function(){T(_+1)}),[D]);var I=l||u,q=r&&I?C:r?M:I?P:j,V=(b.touched||f)&&(b.error||b.submitError)||"",L=(b.touched||f)&&b.warning||v;return i.createElement(m,n._extends({SelectComponent:q,simpleValue:!1},O,p,{loadOptions:d,invalidText:V,loadOptionsChangeCounter:_,originalOnChange:y(p,O.simpleValue),helperText:L}))};T.propTypes={isDisabled:a.bool,isRequired:a.bool,options:a.arrayOf(a.shape({value:a.oneOfType([a.string,a.number]),label:a.node}))},T.defaultProps={loadingMessage:"Loading..."},exports.default=T,exports.getMultiValue=S,exports.multiOnChange=y;
//# sourceMappingURL=select.js.map

@@ -1,2 +0,2 @@

import{_ as e}from"./defineProperty-984bc41a.js";import{_ as n}from"./extends-4d5fdb5f.js";import{_ as o}from"./objectWithoutProperties-85da668a.js";import i,{useRef as a,useEffect as t,useReducer as l,useState as r}from"react";import s from"prop-types";import{_ as c}from"./toConsumableArray-48c131d8.js";import{_ as u}from"./typeof-9ba06920.js";import{_ as p}from"./slicedToArray-de9f1c8c.js";import"./_arrayPush-0ce29596.js";import d from"@data-driven-forms/react-form-renderer/dist/esm/use-field-api";import{_ as b}from"./isEqual-dfba1eb6.js";import g from"carbon-components-react/es/components/Select/Select.js";import f from"carbon-components-react/es/components/MultiSelect/MultiSelect.js";import h from"carbon-components-react/es/components/SelectItem/SelectItem.js";import m from"carbon-components-react/es/components/ComboBox/ComboBox.js";import"carbon-components-react/es/components/Tooltip/Tooltip.js";import{p as v}from"./prepare-props-c0a0d61e.js";function toVal(e){var n,o,i="";if(e)if("object"==typeof e)if(e.push)for(n=0;n<e.length;n++)e[n]&&(o=toVal(e[n]))&&(i&&(i+=" "),i+=o);else for(n in e)e[n]&&(o=toVal(n))&&(i&&(i+=" "),i+=o);else"boolean"==typeof e||e.call||(i&&(i+=" "),i+=e);return i}function clsx(){for(var e,n=0,o="";n<arguments.length;)(e=toVal(arguments[n++]))&&(o&&(o+=" "),o+=e);return o}var O=function fnToString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toString().replace(/\s+/g," ")};function ownKeys(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,i)}return o}function _objectSpread(n){for(var o=1;o<arguments.length;o++){var i=null!=arguments[o]?arguments[o]:{};o%2?ownKeys(Object(i),!0).forEach((function(o){e(n,o,i[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}var y=function reducer(e,n){var o=n.type,i=n.payload,a=n.options,t=void 0===a?[]:a;switch(o){case"updateOptions":return _objectSpread(_objectSpread({},e),{},{options:i,isLoading:!1,promises:{}});case"loaded":return _objectSpread(_objectSpread({},e),{},{isLoading:!1});case"startLoading":return _objectSpread(_objectSpread({},e),{},{isLoading:!0});case"setOptions":return _objectSpread(_objectSpread({},e),{},{options:i});case"initialLoaded":return _objectSpread(_objectSpread({},e),{},{isInitialLoaded:!0});case"setPromises":return _objectSpread(_objectSpread({},e),{},{promises:_objectSpread(_objectSpread({},e.promises),i),options:[].concat(c(e.options),c(t.filter((function(n){var o=n.value;return!e.options.find((function(e){return e.value===o}))}))))});default:return e}},S=function getSelectValue(e,n,o,i){return n?i.filter((function(n){var i=n.value;return o?e.includes(i):b(i,e)})):e},C=function Select(r){var s=r.invalid,c=r.classNamePrefix,d=r.simpleValue,b=r.isMulti,g=r.pluckSingleValue,f=r.options,h=r.loadOptions,m=r.loadingMessage,v=r.loadingProps,C=(r.selectVariant,r.updatingMessage),M=r.noOptionsMessage,x=r.value,j=r.onChange,T=r.loadOptionsChangeCounter,P=r.SelectComponent,I=r.noValueUpdates,V=o(r,["invalid","classNamePrefix","simpleValue","isMulti","pluckSingleValue","options","loadOptions","loadingMessage","loadingProps","selectVariant","updatingMessage","noOptionsMessage","value","onChange","loadOptionsChangeCounter","SelectComponent","noValueUpdates"]),_=l(y,{isLoading:!1,options:f,promises:{},isInitialLoaded:!1}),L=p(_,2),D=L[0],N=L[1],F=function useIsMounted(){var e=a(!1);return t((function(){return e.current=!0,function(){return e.current=!1}}),[]),e}(),E=function updateOptions(){return N({type:"startLoading"}),h().then((function(e){if(F.current){if(!I)if(x&&Array.isArray(x)){var n=x.filter((function(n){return"object"===u(n)?e.find((function(e){return n.value===e.value})):e.find((function(e){return n===e.value}))}));j(0===n.length?void 0:n)}else x&&!e.find((function(e){return e.value===x}))&&j(void 0);N({type:"updateOptions",payload:e})}}))};t((function(){h&&E(),N({type:"initialLoaded"})}),[]);var w=h?O(h):"";t((function(){w&&D.isInitialLoaded&&E()}),[w,T]),t((function(){D.isInitialLoaded&&(I||!x||f.map((function(e){return e.value})).includes(x)||j(void 0),N({type:"setOptions",payload:f}))}),[f]);var A=function renderNoOptionsMessage(){return Object.values(D.promises).some((function(e){return e}))?function(){return C}:function(){return M}};if(D.isLoading)return i.createElement(P,n({},V,{classNamePrefix:c,isDisabled:!0,isFetching:!0,placeholder:m,options:D.options,onChange:function onChange(){}},v,{noOptionsMessage:A()}));var R=g?b?x:Array.isArray(x)&&x[0]?x[0]:x:x;return i.createElement(P,n({className:clsx(c,{"has-error":s})},V,{isDisabled:V.isDisabled||V.isReadOnly,options:D.options,classNamePrefix:c,isMulti:b,value:S(R,d,b,D.options),onChange:function onChange(e){return function handleSelectChange(e,n,o,i){var a=!e&&o?[]:e;return i(n?o?a.map((function(e){return e.value})):a?a.value:void 0:a)}(e,d,b,j)},onInputChange:function onInputChange(n){n&&h&&void 0===D.promises[n]&&V.isSearchable&&(N({type:"setPromises",payload:e({},n,!0)}),h(n).then((function(o){F.current&&N({type:"setPromises",payload:e({},n,!1),options:o})})).catch((function(o){throw N({type:"setPromises",payload:e({},n,!1)}),o})))},isFetching:Object.values(D.promises).some((function(e){return e})),noOptionsMessage:A(),hideSelectedOptions:!1,closeMenuOnSelect:!b}))};C.propTypes={options:s.array,onChange:s.func,classNamePrefix:s.string,invalid:s.bool,simpleValue:s.bool,isMulti:s.bool,pluckSingleValue:s.bool,value:s.any,placeholder:s.string,loadOptionsChangeCounter:s.number,isDisabled:s.bool,isReadOnly:s.bool,loadOptions:s.func,loadingMessage:s.node,loadingProps:s.object,selectVariant:s.string,updatingMessage:s.node,noOptionsMessage:s.node,isSearchable:s.bool,SelectComponent:s.elementType.isRequired,noValueUpdates:s.bool},C.defaultProps={options:[],invalid:!1,simpleValue:!0,pluckSingleValue:!0,placeholder:"Choose...",isSearchable:!1,isClearable:!1};var M=function multiOnChange(e,n){return function(o){var i=o.selectedItem,a=o.selectedItems;return n?e.onChange((null==a?void 0:a.map((function(e){return e.value})))||i.value):e.onChange(a||i)}},x=function getMultiValue(e,n){return(Array.isArray(e)?e:[e]).map((function(e){return"object"===u(e)?e:n.find((function(n){return n.value===e}))}))||[]},j=function ClearedMultiSelectFilterable(e){var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),r=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=o(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(f.Filterable,n({disabled:c},u,{placeholder:r||s,onChange:l,titleText:u.labelText,id:u.name,invalid:Boolean(a),invalidText:a,items:t,initialSelectedItems:x(u.value,t)}))};j.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isRequired:s.bool,isDisabled:s.bool};var T=function ClearedMultiSelect(e){var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),r=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=o(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(f,n({disabled:c},u,{label:r||s,onChange:l,titleText:u.labelText,id:u.name,invalid:Boolean(a),invalidText:a,items:t,initialSelectedItems:x(u.value,t)}))};T.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isRequired:s.bool,isDisabled:s.bool};var P=function getSelectValue(e,n){return n?e:Array.isArray(e)?e[0]:e},I=function ClearedSelect(e){e.isSearchable,e.isClearable,e.isDisabled;var a=e.isMulti,t=e.invalidText,l=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange,e.placeholder),c=e.value,u=o(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","value"]);return i.createElement(g,n({value:P(c,a),disabled:r},u,{id:u.name,invalid:Boolean(t),invalidText:t}),r&&i.createElement(h,{text:s,value:""}),l.map((function(e,o){return i.createElement(h,n({key:e.value||o,text:e.label},e))})))};I.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isDisabled:s.bool,isRequired:s.bool,isSearchable:s.bool,isClearable:s.bool,value:s.any};var V=function getComboInitialValue(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=Array.isArray(e)?e[0]:e;return"object"===u(o)?o:n.find((function(e){return e.value===o}))||o},_=function ClearedSelectSearchable(e){e.isSearchable,e.isClearable,e.isDisabled,e.isMulti;var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=void 0===t?[]:t,r=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange),c=e.placeholder,u=e.labelText,p=o(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","labelText"]);return i.createElement(m,n({disabled:r},p,{id:p.name,invalid:Boolean(a),invalidText:a,initialSelectedItem:V(p.value,l),items:l,placeholder:c,titleText:u,onChange:s}))};_.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isDisabled:s.bool,isRequired:s.bool,isSearchable:s.bool,isClearable:s.bool,labelText:s.string};var L=function Select$1(e){var a=d(v(e)),l=a.isMulti,s=a.isSearchable,c=a.isClearable,u=a.loadOptions,b=a.input,g=a.meta,f=a.validateOnMount,h=a.helperText,m=o(a,["isMulti","isSearchable","isClearable","loadOptions","input","meta","validateOnMount","helperText"]),y=r(0),S=p(y,2),x=S[0],P=S[1],V=O(u);t((function(){P(x+1)}),[V]);var L=s||c,D=l&&L?j:l?T:L?_:I,N=(g.touched||f)&&(g.error||g.submitError)||"",F=(g.touched||f)&&g.warning||h;return i.createElement(C,n({SelectComponent:D,simpleValue:!1},m,b,{loadOptions:u,invalidText:N,loadOptionsChangeCounter:x,originalOnChange:M(b,m.simpleValue),helperText:F}))};L.propTypes={isDisabled:s.bool,isRequired:s.bool,options:s.arrayOf(s.shape({value:s.oneOfType([s.string,s.number]),label:s.node}))},L.defaultProps={loadingMessage:"Loading..."};export default L;export{M as multiOnChange};
import{_ as e}from"./defineProperty-984bc41a.js";import{_ as n}from"./extends-4d5fdb5f.js";import{_ as o}from"./objectWithoutProperties-85da668a.js";import i,{useRef as a,useEffect as t,useReducer as l,useState as r}from"react";import s from"prop-types";import{_ as c}from"./toConsumableArray-48c131d8.js";import{_ as u}from"./typeof-9ba06920.js";import{_ as p}from"./slicedToArray-de9f1c8c.js";import"./_arrayPush-0ce29596.js";import d from"@data-driven-forms/react-form-renderer/dist/esm/use-field-api";import{_ as b}from"./isEqual-dfba1eb6.js";import g from"carbon-components-react/es/components/Select/Select.js";import f from"carbon-components-react/es/components/MultiSelect/MultiSelect.js";import h from"carbon-components-react/es/components/SelectItem/SelectItem.js";import m from"carbon-components-react/es/components/ComboBox/ComboBox.js";import"carbon-components-react/es/components/Tooltip/Tooltip.js";import{p as v}from"./prepare-props-c0a0d61e.js";function toVal(e){var n,o,i="";if(e)if("object"==typeof e)if(e.push)for(n=0;n<e.length;n++)e[n]&&(o=toVal(e[n]))&&(i&&(i+=" "),i+=o);else for(n in e)e[n]&&(o=toVal(n))&&(i&&(i+=" "),i+=o);else"boolean"==typeof e||e.call||(i&&(i+=" "),i+=e);return i}function clsx(){for(var e,n=0,o="";n<arguments.length;)(e=toVal(arguments[n++]))&&(o&&(o+=" "),o+=e);return o}var O=function fnToString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.toString().replace(/\s+/g," ")};function ownKeys(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,i)}return o}function _objectSpread(n){for(var o=1;o<arguments.length;o++){var i=null!=arguments[o]?arguments[o]:{};o%2?ownKeys(Object(i),!0).forEach((function(o){e(n,o,i[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}var y=function reducer(e,n){var o=n.type,i=n.payload,a=n.options,t=void 0===a?[]:a;switch(o){case"updateOptions":return _objectSpread(_objectSpread({},e),{},{options:i,isLoading:!1,promises:{}});case"loaded":return _objectSpread(_objectSpread({},e),{},{isLoading:!1});case"startLoading":return _objectSpread(_objectSpread({},e),{},{isLoading:!0});case"setOptions":return _objectSpread(_objectSpread({},e),{},{options:i});case"initialLoaded":return _objectSpread(_objectSpread({},e),{},{isInitialLoaded:!0});case"setPromises":return _objectSpread(_objectSpread({},e),{},{promises:_objectSpread(_objectSpread({},e.promises),i),options:[].concat(c(e.options),c(t.filter((function(n){var o=n.value;return!e.options.find((function(e){return e.value===o}))}))))});default:return e}},S=function getSelectValue(e,n,o,i){return n?i.filter((function(n){var i=n.value;return o?e.includes(i):b(i,e)})):e},C=function Select(r){var s=r.invalid,c=r.classNamePrefix,d=r.simpleValue,b=r.isMulti,g=r.pluckSingleValue,f=r.options,h=r.loadOptions,m=r.loadingMessage,v=r.loadingProps,C=(r.selectVariant,r.updatingMessage),M=r.noOptionsMessage,x=r.value,j=r.onChange,T=r.loadOptionsChangeCounter,P=r.SelectComponent,I=r.noValueUpdates,V=o(r,["invalid","classNamePrefix","simpleValue","isMulti","pluckSingleValue","options","loadOptions","loadingMessage","loadingProps","selectVariant","updatingMessage","noOptionsMessage","value","onChange","loadOptionsChangeCounter","SelectComponent","noValueUpdates"]),_=l(y,{isLoading:!1,options:f,promises:{},isInitialLoaded:!1}),L=p(_,2),D=L[0],N=L[1],F=function useIsMounted(){var e=a(!1);return t((function(){return e.current=!0,function(){return e.current=!1}}),[]),e}(),E=function updateOptions(){return N({type:"startLoading"}),h().then((function(e){if(F.current){if(!I)if(x&&Array.isArray(x)){var n=x.filter((function(n){return"object"===u(n)?e.find((function(e){return n.value===e.value})):e.find((function(e){return n===e.value}))}));j(0===n.length?void 0:n)}else x&&!e.find((function(e){return e.value===x}))&&j(void 0);N({type:"updateOptions",payload:e})}}))};t((function(){h&&E(),N({type:"initialLoaded"})}),[]);var w=h?O(h):"";t((function(){w&&D.isInitialLoaded&&E()}),[w,T]),t((function(){D.isInitialLoaded&&(I||!x||f.map((function(e){return e.value})).includes(x)||j(void 0),N({type:"setOptions",payload:f}))}),[f]);var A=function renderNoOptionsMessage(){return Object.values(D.promises).some((function(e){return e}))?function(){return C}:function(){return M}};if(D.isLoading)return i.createElement(P,n({},V,{classNamePrefix:c,isDisabled:!0,isFetching:!0,placeholder:m,options:D.options,onChange:function onChange(){}},v,{noOptionsMessage:A()}));var R=g?b?x:Array.isArray(x)&&x[0]?x[0]:x:x;return i.createElement(P,n({className:clsx(c,{"has-error":s})},V,{isDisabled:V.isDisabled||V.isReadOnly,options:D.options,classNamePrefix:c,isMulti:b,value:S(R,d,b,D.options),onChange:function onChange(e){return function handleSelectChange(e,n,o,i){var a=!e&&o?[]:e;return i(n?o?a.map((function(e){return e.value})):a?a.value:void 0:a)}(e,d,b,j)},onInputChange:function onInputChange(n){n&&h&&void 0===D.promises[n]&&V.isSearchable&&(N({type:"setPromises",payload:e({},n,!0)}),h(n).then((function(o){F.current&&N({type:"setPromises",payload:e({},n,!1),options:o})})).catch((function(o){throw N({type:"setPromises",payload:e({},n,!1)}),o})))},isFetching:Object.values(D.promises).some((function(e){return e})),noOptionsMessage:A(),hideSelectedOptions:!1,closeMenuOnSelect:!b}))};C.propTypes={options:s.array,onChange:s.func,classNamePrefix:s.string,invalid:s.bool,simpleValue:s.bool,isMulti:s.bool,pluckSingleValue:s.bool,value:s.any,placeholder:s.string,loadOptionsChangeCounter:s.number,isDisabled:s.bool,isReadOnly:s.bool,loadOptions:s.func,loadingMessage:s.node,loadingProps:s.object,selectVariant:s.string,updatingMessage:s.node,noOptionsMessage:s.node,isSearchable:s.bool,SelectComponent:s.elementType.isRequired,noValueUpdates:s.bool},C.defaultProps={options:[],invalid:!1,simpleValue:!0,pluckSingleValue:!0,placeholder:"Choose...",isSearchable:!1,isClearable:!1};var M=function multiOnChange(e,n){return function(o){var i=o.selectedItem,a=o.selectedItems;return n?e.onChange((null==a?void 0:a.map((function(e){return e.value})))||i.value):e.onChange(a||i)}},x=function getMultiValue(e,n){return(Array.isArray(e)?e:e?[e]:[]).map((function(e){return"object"===u(e)?e:n.find((function(n){return n.value===e}))}))},j=function ClearedMultiSelectFilterable(e){var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),r=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=o(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(f.Filterable,n({disabled:c},u,{placeholder:r||s,onChange:l,titleText:u.labelText,id:u.name,invalid:Boolean(a),invalidText:a,items:t,initialSelectedItems:x(u.value,t)}))};j.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isRequired:s.bool,isDisabled:s.bool};var T=function ClearedMultiSelect(e){var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=(e.isFetching,e.invalid,e.isMulti,e.classNamePrefix,e.closeMenuOnSelect,e.onChange,e.originalOnChange),r=e.carbonLabel,s=e.placeholder,c=e.isDisabled,u=o(e,["invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","isMulti","classNamePrefix","closeMenuOnSelect","onChange","originalOnChange","carbonLabel","placeholder","isDisabled"]);return i.createElement(f,n({disabled:c},u,{label:r||s,onChange:l,titleText:u.labelText,id:u.name,invalid:Boolean(a),invalidText:a,items:t,initialSelectedItems:x(u.value,t)}))};T.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isRequired:s.bool,isDisabled:s.bool};var P=function getSelectValue(e,n){return n?e:Array.isArray(e)?e[0]:e},I=function ClearedSelect(e){e.isSearchable,e.isClearable,e.isDisabled;var a=e.isMulti,t=e.invalidText,l=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),r=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange,e.placeholder),c=e.value,u=o(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","value"]);return i.createElement(g,n({value:P(c,a),disabled:r},u,{id:u.name,invalid:Boolean(t),invalidText:t}),r&&i.createElement(h,{text:s,value:""}),l.map((function(e,o){return i.createElement(h,n({key:e.value||o,text:e.label},e))})))};I.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isDisabled:s.bool,isRequired:s.bool,isSearchable:s.bool,isClearable:s.bool,value:s.any};var V=function getComboInitialValue(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=Array.isArray(e)?e[0]:e;return"object"===u(o)?o:n.find((function(e){return e.value===o}))||o},_=function ClearedSelectSearchable(e){e.isSearchable,e.isClearable,e.isDisabled,e.isMulti;var a=e.invalidText,t=(e.hideSelectedOptions,e.noOptionsMessage,e.onInputChange,e.options),l=void 0===t?[]:t,r=e.isFetching,s=(e.invalid,e.classNamePrefix,e.closeMenuOnSelect,e.originalOnChange),c=e.placeholder,u=e.labelText,p=o(e,["isSearchable","isClearable","isDisabled","isMulti","invalidText","hideSelectedOptions","noOptionsMessage","onInputChange","options","isFetching","invalid","classNamePrefix","closeMenuOnSelect","originalOnChange","placeholder","labelText"]);return i.createElement(m,n({disabled:r},p,{id:p.name,invalid:Boolean(a),invalidText:a,initialSelectedItem:V(p.value,l),items:l,placeholder:c,titleText:u,onChange:s}))};_.propTypes={invalidText:s.node,hideSelectedOptions:s.any,noOptionsMessage:s.any,onInputChange:s.func,options:s.array,isFetching:s.bool,invalid:s.oneOfType([s.bool,s.node]),isMulti:s.bool,classNamePrefix:s.any,closeMenuOnSelect:s.any,onChange:s.func,originalOnChange:s.func,carbonLabel:s.node,placeholder:s.node,isDisabled:s.bool,isRequired:s.bool,isSearchable:s.bool,isClearable:s.bool,labelText:s.string};var L=function Select$1(e){var a=d(v(e)),l=a.isMulti,s=a.isSearchable,c=a.isClearable,u=a.loadOptions,b=a.input,g=a.meta,f=a.validateOnMount,h=a.helperText,m=o(a,["isMulti","isSearchable","isClearable","loadOptions","input","meta","validateOnMount","helperText"]),y=r(0),S=p(y,2),x=S[0],P=S[1],V=O(u);t((function(){P(x+1)}),[V]);var L=s||c,D=l&&L?j:l?T:L?_:I,N=(g.touched||f)&&(g.error||g.submitError)||"",F=(g.touched||f)&&g.warning||h;return i.createElement(C,n({SelectComponent:D,simpleValue:!1},m,b,{loadOptions:u,invalidText:N,loadOptionsChangeCounter:x,originalOnChange:M(b,m.simpleValue),helperText:F}))};L.propTypes={isDisabled:s.bool,isRequired:s.bool,options:s.arrayOf(s.shape({value:s.oneOfType([s.string,s.number]),label:s.node}))},L.defaultProps={loadingMessage:"Loading..."};export default L;export{x as getMultiValue,M as multiOnChange};
//# sourceMappingURL=select.js.map
{
"name": "@data-driven-forms/carbon-component-mapper",
"version": "2.24.5",
"version": "2.24.6",
"description": "carbon-component-mapper for data-driven-forms.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc