@micoblanc/chipster
Version:
A composable and flexible multi-entry input component for React
16 lines (15 loc) • 41.2 kB
JavaScript
import e,{createContext as t,useContext as n,useRef as r,useCallback as o,useEffect as i,useState as a,Children as s,isValidElement as c,cloneElement as l,useMemo as u}from"react";import p from"classnames";import f from"react-dom";function d(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 m={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"};d(".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 h=t(null),g=()=>{const e=n(h);if(!e)throw new Error("Chipster components must be used within a ChipsterProvider");return e},_=({getSuggestions:t,className:n,children:a,onSelect:s,...c})=>{const{theme:l,items:u,addItem:f,showSuggestions:d,inputValue:h,setInputValue:_,allowDuplicates:y,selectedSuggestionIndex:v,setSelectedSuggestionIndex:b,suggestions:x,setSuggestions:E}=g(),k=r(null),S=r([]),w=o((e=>"string"==typeof e?e:e.label),[]);i((()=>{if(t&&h){let e=t(h);y||(e=e.filter((e=>!u.some((t=>t.text===w(e)))))),E(e)}else E([])}),[t,h,u,y,E,w]),i((()=>{if(v>=0&&d){const e=S.current[v];if(e&&k.current){const t=k.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)}}}),[v,d]);const C=o((e=>{const t=w(e);f(t,e),b(-1),_("")}),[f,b,_,w]);if(!d||!x.length)return null;if(a)return a({suggestions:x,onSelect:C,selectedIndex:v});const D={ref:k,role:"listbox",className:p(m.suggestions,"dark"===l?m.suggestionsDark:"",n),...c};return e.createElement("ul",{...D},x.map(((t,n)=>e.createElement("li",{key:n,ref:e=>S.current[n]=e,role:"option","aria-selected":n===v,className:p(m.suggestion,"dark"===l?m.suggestionDark:"",{[m.suggestionSelected]:n===v&&"light"===l,[m.suggestionSelectedDark]:n===v&&"dark"===l}),onClick:()=>C(t)},"string"==typeof t?t:e.createElement("div",{className:m.suggestionWithIcon},t.icon&&e.createElement("span",{className:p(m.suggestionIcon,"dark"===l?m.suggestionIconDark:"")},t.icon),e.createElement("span",null,t.label))))))},y=({item:t,itemClassName:n,highlightedClassName:o,disabledClassName:a,iconClassName:s,removeButtonClassName:c,removeIcon:l,render:u,index:f})=>{const{highlightedIndex:d,disabled:h,theme:_,highlightItem:y,removeItem:v}=g(),b=r(null),x=d===f;i((()=>{x&&b.current&&b.current.focus()}),[x]);return e.createElement("div",{className:m.itemWrapper},e.createElement("span",{ref:b,className:p(m.item,"dark"===_?m.itemDark:"",{[m.itemHighlighted]:x&&"light"===_,[m.itemHighlightedDark]:x&&"dark"===_,[m.itemDisabled]:h},n,{[o||""]:x,[a||""]:h}),"data-highlighted":x||void 0,"data-disabled":h||void 0,tabIndex:x?0:-1,role:"button","aria-selected":x,onFocus:()=>{"number"==typeof f&&y(f)}},t.icon&&e.createElement("span",{className:p(m.itemIcon,"dark"===_?m.itemIconDark:"",s)},t.icon),t.text,e.createElement("button",{onClick:e=>{e.stopPropagation(),"number"==typeof f&&(v(t.id),f===d&&y(null))},className:p(m.itemRemove,"dark"===_?m.itemRemoveDark:"",c,"flex items-center justify-center"),disabled:h,tabIndex:-1,"aria-label":`Remove ${t.text}`},l||"×")))},v=({validationRules:t,maxItems:n,maxItemsMessage:r="Maximum items reached",allowDuplicates:o=!0,transform:a,errorClassName:s,children:c,onError:l})=>{const{error:u,setValidationConfig:f,setError:d}=g();return i((()=>(f({validationRules:t,maxItems:n,maxItemsMessage:r,allowDuplicates:o,transform:a,onError:l}),()=>{f(null),d(null)})),[t,n,r,o,a,l,f,d]),u?c?e.createElement(e.Fragment,null,c(u)):e.createElement("div",{className:p(m.error,"text-red-500 text-sm mt-1",s)},u):null};function b(){return b=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},b.apply(null,arguments)}function x(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 E(e,t){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},E(e,t)}function k(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,E(e,t)}function S(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w,C={exports:{}},D={exports:{}},N={};var O,I,R,j,T,P,V,$,A,M,z,L,F,W,U={};
/** @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 H(){return I||(I=1,"production"===process.env.NODE_ENV?D.exports=function(){if(w)return N;w=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,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: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 b(e){return v(e)===l}return N.AsyncMode=c,N.ConcurrentMode=l,N.ContextConsumer=s,N.ContextProvider=a,N.Element=t,N.ForwardRef=u,N.Fragment=r,N.Lazy=m,N.Memo=d,N.Portal=n,N.Profiler=i,N.StrictMode=o,N.Suspense=p,N.isAsyncMode=function(e){return b(e)||v(e)===c},N.isConcurrentMode=b,N.isContextConsumer=function(e){return v(e)===s},N.isContextProvider=function(e){return v(e)===a},N.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},N.isForwardRef=function(e){return v(e)===u},N.isFragment=function(e){return v(e)===r},N.isLazy=function(e){return v(e)===m},N.isMemo=function(e){return v(e)===d},N.isPortal=function(e){return v(e)===n},N.isProfiler=function(e){return v(e)===i},N.isStrictMode=function(e){return v(e)===o},N.isSuspense=function(e){return v(e)===p},N.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)},N.typeOf=v,N}():D.exports=(O||(O=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,x=l,E=s,k=a,S=t,w=u,C=r,D=m,N=d,O=n,I=i,R=o,j=p,T=!1;function P(e){return v(e)===l}U.AsyncMode=b,U.ConcurrentMode=x,U.ContextConsumer=E,U.ContextProvider=k,U.Element=S,U.ForwardRef=w,U.Fragment=C,U.Lazy=D,U.Memo=N,U.Portal=O,U.Profiler=I,U.StrictMode=R,U.Suspense=j,U.isAsyncMode=function(e){return T||(T=!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},U.isConcurrentMode=P,U.isContextConsumer=function(e){return v(e)===s},U.isContextProvider=function(e){return v(e)===a},U.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},U.isForwardRef=function(e){return v(e)===u},U.isFragment=function(e){return v(e)===r},U.isLazy=function(e){return v(e)===m},U.isMemo=function(e){return v(e)===d},U.isPortal=function(e){return v(e)===n},U.isProfiler=function(e){return v(e)===i},U.isStrictMode=function(e){return v(e)===o},U.isSuspense=function(e){return v(e)===p},U.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)},U.typeOf=v}()),U)),D.exports}
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/function Y(){if(j)return R;j=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return R=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},R}function K(){if(P)return T;P=1;return T="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function q(){return $?V:($=1,V=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var G=H();C.exports=function(){if(L)return z;L=1;var e=H(),t=Y(),n=K(),r=q(),o=function(){if(M)return A;M=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=K(),n={},r=q();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={})},A=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){}}),z=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},z}()(G.isElement,!0)}else C.exports=function(){if(W)return F;W=1;var e=K();function t(){}function n(){}return n.resetWarningCache=t,F=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 X=S(C.exports);function J(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}var B=!1,Z="production"!==process.env.NODE_ENV?X.oneOfType([X.number,X.shape({enter:X.number,exit:X.number,appear:X.number}).isRequired]):null,Q="production"!==process.env.NODE_ENV?X.oneOfType([X.string,X.shape({enter:X.string,exit:X.string,active:X.string}),X.shape({enter:X.string,enterDone:X.string,enterActive:X.string,exit:X.string,exitDone:X.string,exitActive:X.string})]):null,ee=e.createContext(null),te=function(e){return e.scrollTop},ne="unmounted",re="exited",oe="entering",ie="entered",ae="exiting",se=function(t){function n(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=re,r.appearStatus=oe):o=ie:o=e.unmountOnExit||e.mountOnEnter?ne:re,r.state={status:o},r.nextCallback=null,r}k(n,t),n.getDerivedStateFromProps=function(e,t){return e.in&&t.status===ne?{status:re}:null};var r=n.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==oe&&n!==ie&&(t=oe):n!==oe&&n!==ie||(t=ae)}this.updateStatus(!1,t)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.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}},r.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t)if(this.cancelNextCallback(),t===oe){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:f.findDOMNode(this);n&&te(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===re&&this.setState({status:ne})},r.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,o=this.props.nodeRef?[r]:[f.findDOMNode(this),r],i=o[0],a=o[1],s=this.getTimeouts(),c=r?s.appear:s.enter;!e&&!n||B?this.safeSetState({status:ie},(function(){t.props.onEntered(i)})):(this.props.onEnter(i,a),this.safeSetState({status:oe},(function(){t.props.onEntering(i,a),t.onTransitionEnd(c,(function(){t.safeSetState({status:ie},(function(){t.props.onEntered(i,a)}))}))})))},r.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:f.findDOMNode(this);t&&!B?(this.props.onExit(r),this.safeSetState({status:ae},(function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,(function(){e.safeSetState({status:re},(function(){e.props.onExited(r)}))}))}))):this.safeSetState({status:re},(function(){e.props.onExited(r)}))},r.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},r.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},r.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:f.findDOMNode(this),r=null==e&&!this.props.addEndListener;if(n&&!r){if(this.props.addEndListener){var o=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],i=o[0],a=o[1];this.props.addEndListener(i,a)}null!=e&&setTimeout(this.nextCallback,e)}else setTimeout(this.nextCallback,0)},r.render=function(){var t=this.state.status;if(t===ne)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=x(n,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return e.createElement(ee.Provider,{value:null},"function"==typeof r?r(t,o):e.cloneElement(e.Children.only(r),o))},n}(e.Component);function ce(){}se.contextType=ee,se.propTypes="production"!==process.env.NODE_ENV?{nodeRef:X.shape({current:"undefined"==typeof Element?X.any:function(e,t,n,r,o,i){var a=e[t];return X.instanceOf(a&&"ownerDocument"in a?a.ownerDocument.defaultView.Element:Element)(e,t,n,r,o,i)}}),children:X.oneOfType([X.func.isRequired,X.element.isRequired]).isRequired,in:X.bool,mountOnEnter:X.bool,unmountOnExit:X.bool,appear:X.bool,enter:X.bool,exit:X.bool,timeout:function(e){var t=Z;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:X.func,onEnter:X.func,onEntering:X.func,onEntered:X.func,onExit:X.func,onExiting:X.func,onExited:X.func}:{},se.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:ce,onEntering:ce,onEntered:ce,onExit:ce,onExiting:ce,onExited:ce},se.UNMOUNTED=ne,se.EXITED=re,se.ENTERING=oe,se.ENTERED=ie,se.EXITING=ae;var le=se,ue=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}))},pe=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=J(n.className,r):n.setAttribute("class",J(n.className&&n.className.baseVal||"",r)));var n,r}))},fe=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}k(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&&te(e),r&&(this.appliedClasses[t][n]=r,ue(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&&pe(e,r),o&&pe(e,o),i&&pe(e,i)},r.render=function(){var t=this.props;t.classNames;var n=x(t,["classNames"]);return e.createElement(le,b({},n,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},n}(e.Component);fe.defaultProps={classNames:""},fe.propTypes="production"!==process.env.NODE_ENV?b({},le.propTypes,{classNames:Q,onEnter:X.func,onEntering:X.func,onEntered:X.func,onExit:X.func,onExiting:X.func,onExited:X.func}):{};var de=fe;function me(e,t){var n=Object.create(null);return e&&s.map(e,(function(e){return e})).forEach((function(e){n[e.key]=function(e){return t&&c(e)?t(e):e}(e)})),n}function he(e,t,n){return null!=n[t]?n[t]:e.props[t]}function ge(e,t,n){var r=me(e.children),o=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}(t,r);return Object.keys(o).forEach((function(i){var a=o[i];if(c(a)){var s=i in t,u=i in r,p=t[i],f=c(p)&&!p.props.in;!u||s&&!f?u||!s||f?u&&s&&c(p)&&(o[i]=l(a,{onExited:n.bind(null,a),in:p.props.in,exit:he(a,"exit",e),enter:he(a,"enter",e)})):o[i]=l(a,{in:!1}):o[i]=l(a,{onExited:n.bind(null,a),in:!0,exit:he(a,"exit",e),enter:he(a,"enter",e)})}})),o}var _e=Object.values||function(e){return Object.keys(e).map((function(t){return e[t]}))},ye=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}k(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(e,t){var n,r,o=t.children,i=t.handleExited;return{children:t.firstRender?(n=e,r=i,me(n.children,(function(e){return l(e,{onExited:r.bind(null,e),in:!0,appear:he(e,"appear",n),enter:he(e,"enter",n),exit:he(e,"exit",n)})}))):ge(e,o,i),firstRender:!1}},r.handleExited=function(e,t){var n=me(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState((function(t){var n=b({},t.children);return delete n[e.key],{children:n}})))},r.render=function(){var t=this.props,n=t.component,r=t.childFactory,o=x(t,["component","childFactory"]),i=this.state.contextValue,a=_e(this.state.children).map(r);return delete o.appear,delete o.enter,delete o.exit,null===n?e.createElement(ee.Provider,{value:i},a):e.createElement(ee.Provider,{value:i},e.createElement(n,o,a))},n}(e.Component);ye.propTypes="production"!==process.env.NODE_ENV?{component:X.any,children:X.node,appear:X.bool,enter:X.bool,exit:X.bool,childFactory:X.func}:{},ye.defaultProps={component:"div",childFactory:function(e){return e}};var ve=ye,be="chipster__chipEnter__u668U",xe="chipster__chipEnterActive__svvYl",Ee="chipster__chipExit__pJVak",ke="chipster__chipExitActive__jw3I8";d(".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 Se=({children:t,className:n,theme:i="light",font:s,joiner:c,...l})=>{const u=function(e={}){const t=r(null),n=r(null),[i,s]=a(null),{mode:c="free",defaultValue:l,onAdd:u,onRemove:p,disabled:f,theme:d="light"}=e,[m,h]=a((()=>l?l.map((e=>({id:Date.now().toString()+Math.random(),text:e}))):[])),[g,_]=a(null),[y,v]=a(!1),[b,x]=a(""),[E,k]=a([]),[S,w]=a(-1),[C,D]=a(null),N=o((e=>{if(!C)return!0;const{validationRules:t,maxItems:n,maxItemsMessage:r,allowDuplicates:o,transform:i}=C;let a=i?i(e):e.trim();if(n&&m.length>=n)return _(r||`Maximum of ${n} items allowed`),!1;if(!o&&m.some((e=>e.text.toLowerCase()===a.toLowerCase())))return _("Duplicate items are not allowed"),!1;if(t)for(const e of t)if(!e.test(a))return _(e.message||"Invalid input"),!1;return _(null),!0}),[m,C]),O=o(((e,t)=>{if("suggestions-only"===c&&!t)return!1;if(N(e)){const n=(null==C?void 0:C.transform)?C.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 h((e=>[...e,i])),null==u||u(n),!0}return!1}),[c,N,C,u]),I=o((e=>{h((t=>{var r;t.findIndex((t=>t.id===e));const o=t.filter((t=>t.id!==e)),i=t.find((t=>t.id===e));return i&&(null==p||p(i.id)),0===o.length&&(s(null),null===(r=n.current)||void 0===r||r.focus()),o}))}),[p]),R=o((e=>{s(e)}),[]),j=o((t=>{if(e.getSuggestions){const n=e.getSuggestions(t);k(n)}}),[e.getSuggestions]),T=o((()=>{v(!1)}),[]);return{mode:c,items:m,error:g,setError:_,highlightedIndex:i,showSuggestions:y,disabled:f,theme:d,allowDuplicates:null==C?void 0:C.allowDuplicates,addItem:O,removeItem:I,highlightItem:R,updateSuggestions:j,clearSuggestions:T,setShowSuggestions:v,inputValue:b,setInputValue:x,suggestions:E,setSuggestions:k,selectedSuggestionIndex:S,setSelectedSuggestionIndex:w,validationConfig:C,setValidationConfig:D,containerRef:t,inputRef:n,joiner:e.joiner}}({theme:i,joiner:c,...l}),{error:f,containerRef:d}=u,g=(null==s?void 0:s.family)||"var(--font-sans, system-ui, -apple-system, sans-serif)";return e.createElement(h.Provider,{value:u},e.createElement("div",{ref:d,tabIndex:-1,className:p(m.container,"dark"===i?m.containerDark:"",n,{[m.containerError]:f}),style:{"--chipster-font-family":g}},e.createElement("div",{className:p(m.inputContainer,"dark"===i?m.inputContainerDark:"",{[m.inputContainerError]:f})},e.Children.map(t,(t=>{if(e.isValidElement(t)&&t.type!==_&&t.type!==v)return t}))),e.Children.map(t,(t=>{if(e.isValidElement(t)&&(t.type===_||t.type===v))return t}))))};Se.Input=({className:t,placeholder:n="Type and press Enter",onInputChange:i,...a})=>{const{disabled:s,theme:c,addItem:l,items:u,highlightedIndex:f,highlightItem:d,removeItem:h,updateSuggestions:_,showSuggestions:y,setShowSuggestions:v,inputValue:b,setInputValue:x,selectedSuggestionIndex:E,setSelectedSuggestionIndex:k,suggestions:S,setError:w,validationConfig:C,mode:D,joiner:N=[",","Enter"],containerRef:O}=g(),I=r(null),R=Array.isArray(N)?N:[N],j=o((e=>{if(!(null==C?void 0:C.validationRules))return!0;for(const t of C.validationRules)if(!t.test(e))return w(t.message||"Invalid input"),!1;return w(null),!0}),[C,w]),T=o(((e,t)=>!!l(e.trim(),t)&&(x(""),null==i||i(""),k(-1),!0)),[l,x,i,k]),P=o((e=>{const t=e.target.value,n=t.slice(-1);if(R.includes(n)&&t.trim().length>1){const e=t.slice(0,-1).trim();if(e&&T(e))return}x(t),null==i||i(t),t.trim().length>0?(j(t),_(t),v(!0)):(w(null),v(!1))}),[R,T,_,v,i,x,w,j]),V=o((e=>{if(s)return;const t=e.currentTarget.value.trim(),n=e.currentTarget.value;switch(e.key){case"Enter":if(e.preventDefault(),y&&E>=0){const e=S[E];e&&(T("string"==typeof e?e:e.label,e),v(!1),k(-1))}else t&&j(t)&&T(t);break;case"Backspace":""===n&&u.length>0&&(e.preventDefault(),null!==f?f>=0&&f<u.length?h(u[f].id):d(null):h(u[u.length-1].id));break;case"ArrowDown":if(y&&S.length>0){e.preventDefault();const t=E>=S.length-1?0:E+1;k(t)}break;case"ArrowUp":if(y&&S.length>0){e.preventDefault();const t=E<=0?S.length-1:E-1;k(t)}}}),[s,u,f,S,E,y,j,T,h,d,v,k]);return e.createElement("input",{ref:I,type:"text",value:b||"",onChange:P,onKeyDown:V,onFocus:()=>v(!0),onBlur:()=>setTimeout((()=>v(!1)),200),placeholder:"string"==typeof n?n:"",className:p(m.input,"dark"===c?m.inputDark:"",t),disabled:s,...a})},Se.Suggestions=_,Se.Item=y,Se.ItemList=({className:t,itemClassName:n,removeButtonClassName:r,removeIcon:o,iconClassName:i,animationDuration:a=200})=>{const{items:s}=g(),c=u((()=>Array(s.length).fill(null).map((()=>e.createRef()))),[s.length]);return(null==s?void 0:s.length)?e.createElement("div",{className:p(m.itemList,t)},e.createElement(ve,{component:null},s.map(((t,s)=>e.createElement(de,{key:t.id,nodeRef:c[s],timeout:a,classNames:{enter:be,enterActive:xe,exit:Ee,exitActive:ke},appear:!0,unmountOnExit:!0},e.createElement("div",{ref:c[s]},e.createElement(y,{item:t,index:s,itemClassName:n,removeButtonClassName:r,removeIcon:o,iconClassName:i}))))))):null},Se.Validation=v;export{Se as Chipster,m as chipsterStyles};
//# sourceMappingURL=index.esm.js.map