@micoblanc/chipster
Version:
A composable and flexible multi-entry input component for React
16 lines (15 loc) • 41.5 kB
JavaScript
"use strict";var e=require("react"),t=require("classnames"),n=require("react-dom");function r(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var o={container:"chipster__container__VjOPZ",inputContainer:"chipster__inputContainer__tjRow",input:"chipster__input__-bovA",error:"chipster__error__YtU82",inputContainerError:"chipster__inputContainerError__Xwoer",suggestions:"chipster__suggestions__dQoKN",suggestion:"chipster__suggestion__YbS4G",suggestionSelected:"chipster__suggestionSelected__RIWOB",placeholder:"chipster__placeholder__wKs2J",item:"chipster__item__EabbH",itemList:"chipster__itemList__K6-EW",itemDisabled:"chipster__itemDisabled__8EHbU",itemIcon:"chipster__itemIcon__mo1mM",itemRemove:"chipster__itemRemove__vGVMk",itemHighlighted:"chipster__itemHighlighted__zDriJ",itemHighlightedDark:"chipster__itemHighlightedDark__yfWWi",containerDark:"chipster__containerDark__YoXag",inputContainerDark:"chipster__inputContainerDark__uZ06K",inputDark:"chipster__inputDark__DEUDF",placeholderDark:"chipster__placeholderDark__H-RUD",errorDark:"chipster__errorDark__GrKO-",suggestionsDark:"chipster__suggestionsDark__igJz7",suggestionDark:"chipster__suggestionDark__Vjk9Y",suggestionSelectedDark:"chipster__suggestionSelectedDark__2-UKq",itemDark:"chipster__itemDark__9muP6",itemIconDark:"chipster__itemIconDark__-LO6g",itemRemoveDark:"chipster__itemRemoveDark__w-F4V",suggestionWithIcon:"chipster__suggestionWithIcon__yy9hD",suggestionIcon:"chipster__suggestionIcon__XGx9z"};r(".chipster__container__VjOPZ{position:relative;width:100%}.chipster__inputContainer__tjRow{align-items:center;background-color:#fff;border:1px solid #c7c7c7;border-radius:.5rem;box-shadow:0 4px 6px -1px rgba(0,0,0,.04);display:flex;flex-wrap:wrap;padding:.25rem}.chipster__inputContainer__tjRow:focus-within{outline:2px solid #000;outline-offset:1px}.chipster__inputContainer__tjRow[data-disabled]{cursor:not-allowed;opacity:.5}.chipster__inputContainer__tjRow[data-error]{border-color:#ef4444;border-width:2px}.chipster__input__-bovA{background-color:transparent;border:none;color:#000;flex-grow:1;font-family:var(--chipster-font-family);font-size:.875rem;min-height:20px;min-width:50px;outline:none;padding:.25rem}.chipster__input__-bovA:focus{box-shadow:none}.chipster__input__-bovA[disabled]{cursor:not-allowed}.chipster__error__YtU82{color:#ef4444;font-family:var(--chipster-font-family);font-size:.875rem;margin-top:.25rem;padding:0 .5rem}.chipster__inputContainerError__Xwoer{border-color:#ef4444;border-width:2px}.chipster__suggestions__dQoKN{background-color:#fff;border:1px solid #c7c7c7;border-radius:.5rem;box-shadow:0 4px 6px -1px rgba(0,0,0,.15);color:#303030;font-family:var(--chipster-font-family);left:0;list-style-type:none;margin-top:4px;max-height:200px;overflow-y:auto;padding-left:0;padding-right:0;position:absolute;top:100%;width:100%;z-index:1000}.chipster__suggestion__YbS4G{cursor:pointer;font-size:.875rem;list-style:none;padding:.5rem 1rem;transition:background-color .2s}.chipster__suggestionSelected__RIWOB,.chipster__suggestion__YbS4G:hover{background-color:#f3f4f6}.chipster__placeholder__wKs2J{color:#4b5563;font-size:.8rem;letter-spacing:-.025em}.chipster__item__EabbH,.chipster__placeholder__wKs2J{font-family:var(--chipster-font-family);font-weight:500}.chipster__item__EabbH{align-items:center;background-color:#f0f0f0;border:1px solid #d3d3d3;border-radius:.375rem;box-sizing:border-box;color:#303030;display:inline-flex;font-size:.75rem;font-style:normal;height:100%;min-height:1.75rem;outline:none;padding:.15rem .3rem;position:relative;transition:all .2s ease}.chipster__itemList__K6-EW{align-items:stretch;display:flex;flex-wrap:wrap;gap:.25rem;height:100%}.chipster__itemDisabled__8EHbU{cursor:not-allowed;opacity:.5}.chipster__itemIcon__mo1mM{align-items:center;display:flex;height:1rem;justify-content:center;margin-right:.25rem;width:1rem}.chipster__itemIcon__mo1mM img,.chipster__itemIcon__mo1mM svg{max-height:100%;max-width:100%;-o-object-fit:contain;object-fit:contain}.chipster__itemRemove__vGVMk{background-color:transparent;border:none;color:#272727;margin-left:.25rem;outline:none;padding-left:.1rem;padding-right:.1rem}.chipster__itemRemove__vGVMk:hover{color:#000}.chipster__itemRemove__vGVMk:focus{outline:none}.chipster__itemRemove__vGVMk[disabled]{cursor:not-allowed}.chipster__itemHighlighted__zDriJ{background-color:#e5e7eb;outline:2px solid #070707!important;outline-offset:0!important;z-index:1}.chipster__itemHighlightedDark__yfWWi{background-color:#374151;color:#fff;outline:2px solid #fff;outline-offset:1px;z-index:1}.chipster__containerDark__YoXag{color:#070707;position:relative}.chipster__inputContainerDark__uZ06K{background-color:#070707;border-color:#5e5e5e}.chipster__inputContainerDark__uZ06K:focus-within{outline:2px solid #fff;outline-offset:1px}.chipster__inputDark__DEUDF{color:#fff}.chipster__placeholderDark__H-RUD{color:#5e5e5e}.chipster__errorDark__GrKO-{color:#f87171}.chipster__suggestionsDark__igJz7{background-color:#000;border-color:#5e5e5e}.chipster__suggestionDark__Vjk9Y{background-color:#070707;border-color:#5e5e5e;color:#fff}.chipster__suggestionDark__Vjk9Y:hover,.chipster__suggestionSelectedDark__2-UKq{background-color:#222}.chipster__itemDark__9muP6{background-color:#222;border-color:#5e5e5e;color:#fff}.chipster__itemIconDark__-LO6g{color:#5e5e5e}.chipster__itemRemoveDark__w-F4V{color:#aaa}.chipster__itemRemoveDark__w-F4V:hover{color:#f3f4f6}.chipster__suggestionWithIcon__yy9hD{align-items:center;display:flex;gap:.5rem}.chipster__suggestionIcon__XGx9z{align-items:center;display:flex;justify-content:center}");const i=e.createContext(null),a=()=>{const t=e.useContext(i);if(!t)throw new Error("Chipster components must be used within a ChipsterProvider");return t},s=({getSuggestions:n,className:r,children:i,onSelect:s,...c})=>{const{theme:l,items:u,addItem:p,showSuggestions:f,inputValue:d,setInputValue:m,allowDuplicates:h,selectedSuggestionIndex:g,setSelectedSuggestionIndex:_,suggestions:y,setSuggestions:v}=a(),b=e.useRef(null),E=e.useRef([]),x=e.useCallback((e=>"string"==typeof e?e:e.label),[]);e.useEffect((()=>{if(n&&d){let e=n(d);h||(e=e.filter((e=>!u.some((t=>t.text===x(e)))))),v(e)}else v([])}),[n,d,u,h,v,x]),e.useEffect((()=>{if(g>=0&&f){const e=E.current[g];if(e&&b.current){const t=b.current,n=e.offsetTop,r=n+e.offsetHeight,o=t.scrollTop,i=o+t.offsetHeight;n<o?t.scrollTop=n:r>i&&(t.scrollTop=r-t.offsetHeight)}}}),[g,f]);const k=e.useCallback((e=>{const t=x(e);p(t,e),_(-1),m("")}),[p,_,m,x]);if(!f||!y.length)return null;if(i)return i({suggestions:y,onSelect:k,selectedIndex:g});const S={ref:b,role:"listbox",className:t(o.suggestions,"dark"===l?o.suggestionsDark:"",r),...c};return e.createElement("ul",{...S},y.map(((n,r)=>e.createElement("li",{key:r,ref:e=>E.current[r]=e,role:"option","aria-selected":r===g,className:t(o.suggestion,"dark"===l?o.suggestionDark:"",{[o.suggestionSelected]:r===g&&"light"===l,[o.suggestionSelectedDark]:r===g&&"dark"===l}),onClick:()=>k(n)},"string"==typeof n?n:e.createElement("div",{className:o.suggestionWithIcon},n.icon&&e.createElement("span",{className:t(o.suggestionIcon,"dark"===l?o.suggestionIconDark:"")},n.icon),e.createElement("span",null,n.label))))))},c=({item:n,itemClassName:r,highlightedClassName:i,disabledClassName:s,iconClassName:c,removeButtonClassName:l,removeIcon:u,render:p,index:f})=>{const{highlightedIndex:d,disabled:m,theme:h,highlightItem:g,removeItem:_}=a(),y=e.useRef(null),v=d===f;e.useEffect((()=>{v&&y.current&&y.current.focus()}),[v]);return e.createElement("div",{className:o.itemWrapper},e.createElement("span",{ref:y,className:t(o.item,"dark"===h?o.itemDark:"",{[o.itemHighlighted]:v&&"light"===h,[o.itemHighlightedDark]:v&&"dark"===h,[o.itemDisabled]:m},r,{[i||""]:v,[s||""]:m}),"data-highlighted":v||void 0,"data-disabled":m||void 0,tabIndex:v?0:-1,role:"button","aria-selected":v,onFocus:()=>{"number"==typeof f&&g(f)}},n.icon&&e.createElement("span",{className:t(o.itemIcon,"dark"===h?o.itemIconDark:"",c)},n.icon),n.text,e.createElement("button",{onClick:e=>{e.stopPropagation(),"number"==typeof f&&(_(n.id),f===d&&g(null))},className:t(o.itemRemove,"dark"===h?o.itemRemoveDark:"",l,"flex items-center justify-center"),disabled:m,tabIndex:-1,"aria-label":`Remove ${n.text}`},u||"×")))},l=({validationRules:n,maxItems:r,maxItemsMessage:i="Maximum items reached",allowDuplicates:s=!0,transform:c,errorClassName:l,children:u,onError:p})=>{const{error:f,setValidationConfig:d,setError:m}=a();return e.useEffect((()=>(d({validationRules:n,maxItems:r,maxItemsMessage:i,allowDuplicates:s,transform:c,onError:p}),()=>{d(null),m(null)})),[n,r,i,s,c,p,d,m]),f?u?e.createElement(e.Fragment,null,u(f)):e.createElement("div",{className:t(o.error,"text-red-500 text-sm mt-1",l)},f):null};function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(null,arguments)}function p(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t)}function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h,g={exports:{}},_={exports:{}},y={};var v,b,E,x,k,S,C,w,D,N,O,I,R,j,T={};
/** @license React v16.13.1
* react-is.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/function V(){return b||(b=1,"production"===process.env.NODE_ENV?_.exports=function(){if(h)return y;h=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,f=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,g=e?Symbol.for("react.block"):60121,_=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,b=e?Symbol.for("react.scope"):60119;function E(e){if("object"==typeof e&&null!==e){var f=e.$$typeof;switch(f){case t:switch(e=e.type){case c:case l:case r:case i:case o:case p:return e;default:switch(e=e&&e.$$typeof){case s:case u:case m:case d:case a:return e;default:return f}}case n:return f}}}function x(e){return E(e)===l}return y.AsyncMode=c,y.ConcurrentMode=l,y.ContextConsumer=s,y.ContextProvider=a,y.Element=t,y.ForwardRef=u,y.Fragment=r,y.Lazy=m,y.Memo=d,y.Portal=n,y.Profiler=i,y.StrictMode=o,y.Suspense=p,y.isAsyncMode=function(e){return x(e)||E(e)===c},y.isConcurrentMode=x,y.isContextConsumer=function(e){return E(e)===s},y.isContextProvider=function(e){return E(e)===a},y.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},y.isForwardRef=function(e){return E(e)===u},y.isFragment=function(e){return E(e)===r},y.isLazy=function(e){return E(e)===m},y.isMemo=function(e){return E(e)===d},y.isPortal=function(e){return E(e)===n},y.isProfiler=function(e){return E(e)===i},y.isStrictMode=function(e){return E(e)===o},y.isSuspense=function(e){return E(e)===p},y.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===i||e===o||e===p||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===a||e.$$typeof===s||e.$$typeof===u||e.$$typeof===_||e.$$typeof===v||e.$$typeof===b||e.$$typeof===g)},y.typeOf=E,y}():_.exports=(v||(v=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,i=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,f=e?Symbol.for("react.suspense_list"):60120,d=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,_=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function v(e){if("object"==typeof e&&null!==e){var f=e.$$typeof;switch(f){case t:var h=e.type;switch(h){case c:case l:case r:case i:case o:case p:return h;default:var g=h&&h.$$typeof;switch(g){case s:case u:case m:case d:case a:return g;default:return f}}case n:return f}}}var b=c,E=l,x=s,k=a,S=t,C=u,w=r,D=m,N=d,O=n,I=i,R=o,j=p,V=!1;function P(e){return v(e)===l}T.AsyncMode=b,T.ConcurrentMode=E,T.ContextConsumer=x,T.ContextProvider=k,T.Element=S,T.ForwardRef=C,T.Fragment=w,T.Lazy=D,T.Memo=N,T.Portal=O,T.Profiler=I,T.StrictMode=R,T.Suspense=j,T.isAsyncMode=function(e){return V||(V=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),P(e)||v(e)===c},T.isConcurrentMode=P,T.isContextConsumer=function(e){return v(e)===s},T.isContextProvider=function(e){return v(e)===a},T.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},T.isForwardRef=function(e){return v(e)===u},T.isFragment=function(e){return v(e)===r},T.isLazy=function(e){return v(e)===m},T.isMemo=function(e){return v(e)===d},T.isPortal=function(e){return v(e)===n},T.isProfiler=function(e){return v(e)===i},T.isStrictMode=function(e){return v(e)===o},T.isSuspense=function(e){return v(e)===p},T.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===i||e===o||e===p||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===d||e.$$typeof===a||e.$$typeof===s||e.$$typeof===u||e.$$typeof===g||e.$$typeof===_||e.$$typeof===y||e.$$typeof===h)},T.typeOf=v}()),T)),_.exports}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/function P(){if(x)return E;x=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return E=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,o){for(var i,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),c=1;c<arguments.length;c++){for(var l in i=Object(arguments[c]))t.call(i,l)&&(s[l]=i[l]);if(e){a=e(i);for(var u=0;u<a.length;u++)n.call(i,a[u])&&(s[a[u]]=i[a[u]])}}return s},E}function $(){if(S)return k;S=1;return k="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function A(){return w?C:(w=1,C=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var M=V();g.exports=function(){if(I)return O;I=1;var e=V(),t=P(),n=$(),r=A(),o=function(){if(N)return D;N=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=$(),n={},r=A();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,i,a,s,c){if("production"!==process.env.NODE_ENV)for(var l in o)if(r(o,l)){var u;try{if("function"!=typeof o[l]){var p=Error((s||"React class")+": "+a+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}u=o[l](i,l,s,a,null,t)}catch(e){u=e}if(!u||u instanceof Error||e((s||"React class")+": type specification of "+a+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),u instanceof Error&&!(u.message in n)){n[u.message]=!0;var f=c?c():"";e("Failed "+a+" type: "+u.message+(null!=f?f:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},D=o}(),i=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(i=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),O=function(s,c){var l="function"==typeof Symbol&&Symbol.iterator,u="<<anonymous>>",p={array:h("array"),bigint:h("bigint"),bool:h("boolean"),func:h("function"),number:h("number"),object:h("object"),string:h("string"),symbol:h("symbol"),any:m(a),arrayOf:function(e){return m((function(t,r,o,i,a){if("function"!=typeof e)return new d("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[r];if(!Array.isArray(s))return new d("Invalid "+i+" `"+a+"` of type `"+y(s)+"` supplied to `"+o+"`, expected an array.");for(var c=0;c<s.length;c++){var l=e(s,c,o,i,a+"["+c+"]",n);if(l instanceof Error)return l}return null}))},element:m((function(e,t,n,r,o){var i=e[t];return s(i)?null:new d("Invalid "+r+" `"+o+"` of type `"+y(i)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:m((function(t,n,r,o,i){var a=t[n];return e.isValidElementType(a)?null:new d("Invalid "+o+" `"+i+"` of type `"+y(a)+"` supplied to `"+r+"`, expected a single ReactElement type.")})),instanceOf:function(e){return m((function(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||u;return new d("Invalid "+o+" `"+i+"` of type `"+((s=t[n]).constructor&&s.constructor.name?s.constructor.name:u)+"` supplied to `"+r+"`, expected instance of `"+a+"`.")}var s;return null}))},node:m((function(e,t,n,r,o){return _(e[t])?null:new d("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return m((function(t,o,i,a,s){if("function"!=typeof e)return new d("Property `"+s+"` of component `"+i+"` has invalid PropType notation inside objectOf.");var c=t[o],l=y(c);if("object"!==l)return new d("Invalid "+a+" `"+s+"` of type `"+l+"` supplied to `"+i+"`, expected an object.");for(var u in c)if(r(c,u)){var p=e(c,u,i,a,s+"."+u,n);if(p instanceof Error)return p}return null}))},oneOf:function(e){return Array.isArray(e)?m((function(t,n,r,o,i){for(var a=t[n],s=0;s<e.length;s++)if(f(a,e[s]))return null;var c=JSON.stringify(e,(function(e,t){return"symbol"===v(t)?String(t):t}));return new d("Invalid "+o+" `"+i+"` of value `"+String(a)+"` supplied to `"+r+"`, expected one of "+c+".")})):("production"!==process.env.NODE_ENV&&i(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&i("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return i("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+b(o)+" at index "+t+"."),a}return m((function(t,o,i,a,s){for(var c=[],l=0;l<e.length;l++){var u=(0,e[l])(t,o,i,a,s,n);if(null==u)return null;u.data&&r(u.data,"expectedType")&&c.push(u.data.expectedType)}return new d("Invalid "+a+" `"+s+"` supplied to `"+i+"`"+(c.length>0?", expected one of type ["+c.join(", ")+"]":"")+".")}))},shape:function(e){return m((function(t,r,o,i,a){var s=t[r],c=y(s);if("object"!==c)return new d("Invalid "+i+" `"+a+"` of type `"+c+"` supplied to `"+o+"`, expected `object`.");for(var l in e){var u=e[l];if("function"!=typeof u)return g(o,i,a,l,v(u));var p=u(s,l,o,i,a+"."+l,n);if(p)return p}return null}))},exact:function(e){return m((function(o,i,a,s,c){var l=o[i],u=y(l);if("object"!==u)return new d("Invalid "+s+" `"+c+"` of type `"+u+"` supplied to `"+a+"`, expected `object`.");var p=t({},o[i],e);for(var f in p){var m=e[f];if(r(e,f)&&"function"!=typeof m)return g(a,s,c,f,v(m));if(!m)return new d("Invalid "+s+" `"+c+"` key `"+f+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[i],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var h=m(l,f,a,s,c+"."+f,n);if(h)return h}return null}))}};function f(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function d(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function m(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,a,s,l,p,f,m){if(l=l||u,f=f||s,m!==n){if(c){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var g=l+":"+s;!t[g]&&r<3&&(i("You are manually calling a React.PropTypes validation function for the `"+f+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[g]=!0,r++)}}return null==a[s]?o?null===a[s]?new d("The "+p+" `"+f+"` is marked as required in `"+l+"`, but its value is `null`."):new d("The "+p+" `"+f+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(a,s,l,p,f)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function h(e){return m((function(t,n,r,o,i,a){var s=t[n];return y(s)!==e?new d("Invalid "+o+" `"+i+"` of type `"+v(s)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null}))}function g(e,t,n,r,o){return new d((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function _(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(_);if(null===e||s(e))return!0;var t=function(e){var t=e&&(l&&e[l]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!_(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!_(o[1]))return!1}return!0;default:return!1}}function y(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function v(e){if(null==e)return""+e;var t=y(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function b(e){var t=v(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return d.prototype=Error.prototype,p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p},O}()(M.isElement,!0)}else g.exports=function(){if(j)return R;j=1;var e=$();function t(){}function n(){}return n.resetWarningCache=t,R=function(){function r(t,n,r,o,i,a){if(a!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return r}r.isRequired=r;var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i}}()();var z=m(g.exports);function L(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}var F=!1,W="production"!==process.env.NODE_ENV?z.oneOfType([z.number,z.shape({enter:z.number,exit:z.number,appear:z.number}).isRequired]):null,U="production"!==process.env.NODE_ENV?z.oneOfType([z.string,z.shape({enter:z.string,exit:z.string,active:z.string}),z.shape({enter:z.string,enterDone:z.string,enterActive:z.string,exit:z.string,exitDone:z.string,exitActive:z.string})]):null,H=e.createContext(null),q=function(e){return e.scrollTop},Y="unmounted",K="exited",G="entering",X="entered",J="exiting",B=function(t){function r(e,n){var r;r=t.call(this,e,n)||this;var o,i=n&&!n.isMounting?e.enter:e.appear;return r.appearStatus=null,e.in?i?(o=K,r.appearStatus=G):o=X:o=e.unmountOnExit||e.mountOnEnter?Y:K,r.state={status:o},r.nextCallback=null,r}d(r,t),r.getDerivedStateFromProps=function(e,t){return e.in&&t.status===Y?{status:K}:null};var o=r.prototype;return o.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},o.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==G&&n!==X&&(t=G):n!==G&&n!==X||(t=J)}this.updateStatus(!1,t)},o.componentWillUnmount=function(){this.cancelNextCallback()},o.getTimeouts=function(){var e,t,n,r=this.props.timeout;return e=t=n=r,null!=r&&"number"!=typeof r&&(e=r.exit,t=r.enter,n=void 0!==r.appear?r.appear:t),{exit:e,enter:t,appear:n}},o.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t)if(this.cancelNextCallback(),t===G){if(this.props.unmountOnExit||this.props.mountOnEnter){var r=this.props.nodeRef?this.props.nodeRef.current:n.findDOMNode(this);r&&q(r)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===K&&this.setState({status:Y})},o.performEnter=function(e){var t=this,r=this.props.enter,o=this.context?this.context.isMounting:e,i=this.props.nodeRef?[o]:[n.findDOMNode(this),o],a=i[0],s=i[1],c=this.getTimeouts(),l=o?c.appear:c.enter;!e&&!r||F?this.safeSetState({status:X},(function(){t.props.onEntered(a)})):(this.props.onEnter(a,s),this.safeSetState({status:G},(function(){t.props.onEntering(a,s),t.onTransitionEnd(l,(function(){t.safeSetState({status:X},(function(){t.props.onEntered(a,s)}))}))})))},o.performExit=function(){var e=this,t=this.props.exit,r=this.getTimeouts(),o=this.props.nodeRef?void 0:n.findDOMNode(this);t&&!F?(this.props.onExit(o),this.safeSetState({status:J},(function(){e.props.onExiting(o),e.onTransitionEnd(r.exit,(function(){e.safeSetState({status:K},(function(){e.props.onExited(o)}))}))}))):this.safeSetState({status:K},(function(){e.props.onExited(o)}))},o.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},o.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},o.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},o.onTransitionEnd=function(e,t){this.setNextCallback(t);var r=this.props.nodeRef?this.props.nodeRef.current:n.findDOMNode(this),o=null==e&&!this.props.addEndListener;if(r&&!o){if(this.props.addEndListener){var i=this.props.nodeRef?[this.nextCallback]:[r,this.nextCallback],a=i[0],s=i[1];this.props.addEndListener(a,s)}null!=e&&setTimeout(this.nextCallback,e)}else setTimeout(this.nextCallback,0)},o.render=function(){var t=this.state.status;if(t===Y)return null;var n=this.props,r=n.children;n.in,n.mountOnEnter,n.unmountOnExit,n.appear,n.enter,n.exit,n.timeout,n.addEndListener,n.onEnter,n.onEntering,n.onEntered,n.onExit,n.onExiting,n.onExited,n.nodeRef;var o=p(n,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return e.createElement(H.Provider,{value:null},"function"==typeof r?r(t,o):e.cloneElement(e.Children.only(r),o))},r}(e.Component);function Z(){}B.contextType=H,B.propTypes="production"!==process.env.NODE_ENV?{nodeRef:z.shape({current:"undefined"==typeof Element?z.any:function(e,t,n,r,o,i){var a=e[t];return z.instanceOf(a&&"ownerDocument"in a?a.ownerDocument.defaultView.Element:Element)(e,t,n,r,o,i)}}),children:z.oneOfType([z.func.isRequired,z.element.isRequired]).isRequired,in:z.bool,mountOnEnter:z.bool,unmountOnExit:z.bool,appear:z.bool,enter:z.bool,exit:z.bool,timeout:function(e){var t=W;e.addEndListener||(t=t.isRequired);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.apply(void 0,[e].concat(r))},addEndListener:z.func,onEnter:z.func,onEntering:z.func,onEntered:z.func,onExit:z.func,onExiting:z.func,onExited:z.func}:{},B.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Z,onEntering:Z,onEntered:Z,onExit:Z,onExiting:Z,onExited:Z},B.UNMOUNTED=Y,B.EXITED=K,B.ENTERING=G,B.ENTERED=X,B.EXITING=J;var Q=B,ee=function(e,t){return e&&t&&t.split(" ").forEach((function(t){return r=t,void((n=e).classList?n.classList.add(r):function(e,t){return e.classList?!!t&&e.classList.contains(t):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")}(n,r)||("string"==typeof n.className?n.className=n.className+" "+r:n.setAttribute("class",(n.className&&n.className.baseVal||"")+" "+r)));var n,r}))},te=function(e,t){return e&&t&&t.split(" ").forEach((function(t){return r=t,void((n=e).classList?n.classList.remove(r):"string"==typeof n.className?n.className=L(n.className,r):n.setAttribute("class",L(n.className&&n.className.baseVal||"",r)));var n,r}))},ne=function(t){function n(){for(var e,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return(e=t.call.apply(t,[this].concat(r))||this).appliedClasses={appear:{},enter:{},exit:{}},e.onEnter=function(t,n){var r=e.resolveArguments(t,n),o=r[0],i=r[1];e.removeClasses(o,"exit"),e.addClass(o,i?"appear":"enter","base"),e.props.onEnter&&e.props.onEnter(t,n)},e.onEntering=function(t,n){var r=e.resolveArguments(t,n),o=r[0],i=r[1]?"appear":"enter";e.addClass(o,i,"active"),e.props.onEntering&&e.props.onEntering(t,n)},e.onEntered=function(t,n){var r=e.resolveArguments(t,n),o=r[0],i=r[1]?"appear":"enter";e.removeClasses(o,i),e.addClass(o,i,"done"),e.props.onEntered&&e.props.onEntered(t,n)},e.onExit=function(t){var n=e.resolveArguments(t)[0];e.removeClasses(n,"appear"),e.removeClasses(n,"enter"),e.addClass(n,"exit","base"),e.props.onExit&&e.props.onExit(t)},e.onExiting=function(t){var n=e.resolveArguments(t)[0];e.addClass(n,"exit","active"),e.props.onExiting&&e.props.onExiting(t)},e.onExited=function(t){var n=e.resolveArguments(t)[0];e.removeClasses(n,"exit"),e.addClass(n,"exit","done"),e.props.onExited&&e.props.onExited(t)},e.resolveArguments=function(t,n){return e.props.nodeRef?[e.props.nodeRef.current,t]:[t,n]},e.getClassNames=function(t){var n=e.props.classNames,r="string"==typeof n,o=r?""+(r&&n?n+"-":"")+t:n[t];return{baseClassName:o,activeClassName:r?o+"-active":n[t+"Active"],doneClassName:r?o+"-done":n[t+"Done"]}},e}d(n,t);var r=n.prototype;return r.addClass=function(e,t,n){var r=this.getClassNames(t)[n+"ClassName"],o=this.getClassNames("enter").doneClassName;"appear"===t&&"done"===n&&o&&(r+=" "+o),"active"===n&&e&&q(e),r&&(this.appliedClasses[t][n]=r,ee(e,r))},r.removeClasses=function(e,t){var n=this.appliedClasses[t],r=n.base,o=n.active,i=n.done;this.appliedClasses[t]={},r&&te(e,r),o&&te(e,o),i&&te(e,i)},r.render=function(){var t=this.props;t.classNames;var n=p(t,["classNames"]);return e.createElement(Q,u({},n,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},n}(e.Component);ne.defaultProps={classNames:""},ne.propTypes="production"!==process.env.NODE_ENV?u({},Q.propTypes,{classNames:U,onEnter:z.func,onEntering:z.func,onEntered:z.func,onExit:z.func,onExiting:z.func,onExited:z.func}):{};var re=ne;function oe(t,n){var r=Object.create(null);return t&&e.Children.map(t,(function(e){return e})).forEach((function(t){r[t.key]=function(t){return n&&e.isValidElement(t)?n(t):t}(t)})),r}function ie(e,t,n){return null!=n[t]?n[t]:e.props[t]}function ae(t,n,r){var o=oe(t.children),i=function(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var r,o=Object.create(null),i=[];for(var a in e)a in t?i.length&&(o[a]=i,i=[]):i.push(a);var s={};for(var c in t){if(o[c])for(r=0;r<o[c].length;r++){var l=o[c][r];s[o[c][r]]=n(l)}s[c]=n(c)}for(r=0;r<i.length;r++)s[i[r]]=n(i[r]);return s}(n,o);return Object.keys(i).forEach((function(a){var s=i[a];if(e.isValidElement(s)){var c=a in n,l=a in o,u=n[a],p=e.isValidElement(u)&&!u.props.in;!l||c&&!p?l||!c||p?l&&c&&e.isValidElement(u)&&(i[a]=e.cloneElement(s,{onExited:r.bind(null,s),in:u.props.in,exit:ie(s,"exit",t),enter:ie(s,"enter",t)})):i[a]=e.cloneElement(s,{in:!1}):i[a]=e.cloneElement(s,{onExited:r.bind(null,s),in:!0,exit:ie(s,"exit",t),enter:ie(s,"enter",t)})}})),i}var se=Object.values||function(e){return Object.keys(e).map((function(t){return e[t]}))},ce=function(t){function n(e,n){var r,o=(r=t.call(this,e,n)||this).handleExited.bind(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r));return r.state={contextValue:{isMounting:!0},handleExited:o,firstRender:!0},r}d(n,t);var r=n.prototype;return r.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},r.componentWillUnmount=function(){this.mounted=!1},n.getDerivedStateFromProps=function(t,n){var r,o,i=n.children,a=n.handleExited;return{children:n.firstRender?(r=t,o=a,oe(r.children,(function(t){return e.cloneElement(t,{onExited:o.bind(null,t),in:!0,appear:ie(t,"appear",r),enter:ie(t,"enter",r),exit:ie(t,"exit",r)})}))):ae(t,i,a),firstRender:!1}},r.handleExited=function(e,t){var n=oe(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState((function(t){var n=u({},t.children);return delete n[e.key],{children:n}})))},r.render=function(){var t=this.props,n=t.component,r=t.childFactory,o=p(t,["component","childFactory"]),i=this.state.contextValue,a=se(this.state.children).map(r);return delete o.appear,delete o.enter,delete o.exit,null===n?e.createElement(H.Provider,{value:i},a):e.createElement(H.Provider,{value:i},e.createElement(n,o,a))},n}(e.Component);ce.propTypes="production"!==process.env.NODE_ENV?{component:z.any,children:z.node,appear:z.bool,enter:z.bool,exit:z.bool,childFactory:z.func}:{},ce.defaultProps={component:"div",childFactory:function(e){return e}};var le=ce,ue="chipster__chipEnter__u668U",pe="chipster__chipEnterActive__svvYl",fe="chipster__chipExit__pJVak",de="chipster__chipExitActive__jw3I8";r(".chipster__chipEnter__u668U{opacity:0!important;transform:scale(.95) translateX(-8px)!important}.chipster__chipEnterActive__svvYl{opacity:1!important;transform:scale(1) translateX(0)!important;transition:opacity 80ms cubic-bezier(.4,0,.2,1),transform 80ms cubic-bezier(.4,0,.2,1)}.chipster__chipAppear__5dbkH{opacity:0!important;transform:scale(.95) translateX(-8px)!important}.chipster__chipAppearActive__CDJNo{opacity:1!important;transform:scale(1) translateX(0)!important;transition:opacity 80ms cubic-bezier(.4,0,.2,1),transform 80ms cubic-bezier(.4,0,.2,1)}.chipster__chipExit__pJVak{opacity:1;transform:translateX(0)}.chipster__chipExitActive__jw3I8{opacity:0;transform:translateX(-16px);transition:opacity .15s cubic-bezier(.4,0,.2,1),transform .15s cubic-bezier(.4,0,.2,1)}");const me=({children:n,className:r,theme:a="light",font:c,joiner:u,...p})=>{const f=function(t={}){const n=e.useRef(null),r=e.useRef(null),[o,i]=e.useState(null),{mode:a="free",defaultValue:s,onAdd:c,onRemove:l,disabled:u,theme:p="light"}=t,[f,d]=e.useState((()=>s?s.map((e=>({id:Date.now().toString()+Math.random(),text:e}))):[])),[m,h]=e.useState(null),[g,_]=e.useState(!1),[y,v]=e.useState(""),[b,E]=e.useState([]),[x,k]=e.useState(-1),[S,C]=e.useState(null),w=e.useCallback((e=>{if(!S)return!0;const{validationRules:t,maxItems:n,maxItemsMessage:r,allowDuplicates:o,transform:i}=S;let a=i?i(e):e.trim();if(n&&f.length>=n)return h(r||`Maximum of ${n} items allowed`),!1;if(!o&&f.some((e=>e.text.toLowerCase()===a.toLowerCase())))return h("Duplicate items are not allowed"),!1;if(t)for(const e of t)if(!e.test(a))return h(e.message||"Invalid input"),!1;return h(null),!0}),[f,S]),D=e.useCallback(((e,t)=>{if("suggestions-only"===a&&!t)return!1;if(w(e)){const n=(null==S?void 0:S.transform)?S.transform(e):e.trim();let r,o;t&&(e=>"object"==typeof e&&"label"in e)(t)&&(r=t.icon,o=t.data);const i={id:Date.now().toString(),text:n,icon:r,data:o};return d((e=>[...e,i])),null==c||c(n),!0}return!1}),[a,w,S,c]),N=e.useCallback((e=>{d((t=>{var n;t.findIndex((t=>t.id===e));const o=t.filter((t=>t.id!==e)),a=t.find((t=>t.id===e));return a&&(null==l||l(a.id)),0===o.length&&(i(null),null===(n=r.current)||void 0===n||n.focus()),o}))}),[l]),O=e.useCallback((e=>{i(e)}),[]),I=e.useCallback((e=>{if(t.getSuggestions){const n=t.getSuggestions(e);E(n)}}),[t.getSuggestions]),R=e.useCallback((()=>{_(!1)}),[]);return{mode:a,items:f,error:m,setError:h,highlightedIndex:o,showSuggestions:g,disabled:u,theme:p,allowDuplicates:null==S?void 0:S.allowDuplicates,addItem:D,removeItem:N,highlightItem:O,updateSuggestions:I,clearSuggestions:R,setShowSuggestions:_,inputValue:y,setInputValue:v,suggestions:b,setSuggestions:E,selectedSuggestionIndex:x,setSelectedSuggestionIndex:k,validationConfig:S,setValidationConfig:C,containerRef:n,inputRef:r,joiner:t.joiner}}({theme:a,joiner:u,...p}),{error:d,containerRef:m}=f,h=(null==c?void 0:c.family)||"var(--font-sans, system-ui, -apple-system, sans-serif)";return e.createElement(i.Provider,{value:f},e.createElement("div",{ref:m,tabIndex:-1,className:t(o.container,"dark"===a?o.containerDark:"",r,{[o.containerError]:d}),style:{"--chipster-font-family":h}},e.createElement("div",{className:t(o.inputContainer,"dark"===a?o.inputContainerDark:"",{[o.inputContainerError]:d})},e.Children.map(n,(t=>{if(e.isValidElement(t)&&t.type!==s&&t.type!==l)return t}))),e.Children.map(n,(t=>{if(e.isValidElement(t)&&(t.type===s||t.type===l))return t}))))};me.Input=({className:n,placeholder:r="Type and press Enter",onInputChange:i,...s})=>{const{disabled:c,theme:l,addItem:u,items:p,highlightedIndex:f,highlightItem:d,removeItem:m,updateSuggestions:h,showSuggestions:g,setShowSuggestions:_,inputValue:y,setInputValue:v,selectedSuggestionIndex:b,setSelectedSuggestionIndex:E,suggestions:x,setError:k,validationConfig:S,mode:C,joiner:w=[",","Enter"],containerRef:D}=a(),N=e.useRef(null),O=Array.isArray(w)?w:[w],I=e.useCallback((e=>{if(!(null==S?void 0:S.validationRules))return!0;for(const t of S.validationRules)if(!t.test(e))return k(t.message||"Invalid input"),!1;return k(null),!0}),[S,k]),R=e.useCallback(((e,t)=>!!u(e.trim(),t)&&(v(""),null==i||i(""),E(-1),!0)),[u,v,i,E]),j=e.useCallback((e=>{const t=e.target.value,n=t.slice(-1);if(O.includes(n)&&t.trim().length>1){const e=t.slice(0,-1).trim();if(e&&R(e))return}v(t),null==i||i(t),t.trim().length>0?(I(t),h(t),_(!0)):(k(null),_(!1))}),[O,R,h,_,i,v,k,I]),T=e.useCallback((e=>{if(c)return;const t=e.currentTarget.value.trim(),n=e.currentTarget.value;switch(e.key){case"Enter":if(e.preventDefault(),g&&b>=0){const e=x[b];e&&(R("string"==typeof e?e:e.label,e),_(!1),E(-1))}else t&&I(t)&&R(t);break;case"Backspace":""===n&&p.length>0&&(e.preventDefault(),null!==f?f>=0&&f<p.length?m(p[f].id):d(null):m(p[p.length-1].id));break;case"ArrowDown":if(g&&x.length>0){e.preventDefault();const t=b>=x.length-1?0:b+1;E(t)}break;case"ArrowUp":if(g&&x.length>0){e.preventDefault();const t=b<=0?x.length-1:b-1;E(t)}}}),[c,p,f,x,b,g,I,R,m,d,_,E]);return e.createElement("input",{ref:N,type:"text",value:y||"",onChange:j,onKeyDown:T,onFocus:()=>_(!0),onBlur:()=>setTimeout((()=>_(!1)),200),placeholder:"string"==typeof r?r:"",className:t(o.input,"dark"===l?o.inputDark:"",n),disabled:c,...s})},me.Suggestions=s,me.Item=c,me.ItemList=({className:n,itemClassName:r,removeButtonClassName:i,removeIcon:s,iconClassName:l,animationDuration:u=200})=>{const{items:p}=a(),f=e.useMemo((()=>Array(p.length).fill(null).map((()=>e.createRef()))),[p.length]);return(null==p?void 0:p.length)?e.createElement("div",{className:t(o.itemList,n)},e.createElement(le,{component:null},p.map(((t,n)=>e.createElement(re,{key:t.id,nodeRef:f[n],timeout:u,classNames:{enter:ue,enterActive:pe,exit:fe,exitActive:de},appear:!0,unmountOnExit:!0},e.createElement("div",{ref:f[n]},e.createElement(c,{item:t,index:n,itemClassName:r,removeButtonClassName:i,removeIcon:s,iconClassName:l}))))))):null},me.Validation=l,exports.Chipster=me,exports.chipsterStyles=o;
//# sourceMappingURL=index.js.map