@leafygreen-ui/combobox 1.1.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/Chip.d.ts.map +1 -1
  3. package/dist/Combobox.d.ts +7 -1
  4. package/dist/Combobox.d.ts.map +1 -1
  5. package/dist/Combobox.styles.d.ts +7 -6
  6. package/dist/Combobox.styles.d.ts.map +1 -1
  7. package/dist/Combobox.types.d.ts +27 -1
  8. package/dist/Combobox.types.d.ts.map +1 -1
  9. package/dist/ComboboxContext.d.ts +1 -1
  10. package/dist/ComboboxContext.d.ts.map +1 -1
  11. package/dist/ComboboxOption.d.ts.map +1 -1
  12. package/dist/ComboboxTestUtils.d.ts +1 -2
  13. package/dist/ComboboxTestUtils.d.ts.map +1 -1
  14. package/dist/esm/index.js +1 -1
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/utils/OptionObjectUtils.d.ts +5 -0
  19. package/dist/utils/OptionObjectUtils.d.ts.map +1 -0
  20. package/dist/utils/flattenChildren.d.ts +11 -0
  21. package/dist/utils/flattenChildren.d.ts.map +1 -0
  22. package/dist/utils/getNameAndValue.d.ts +14 -0
  23. package/dist/utils/getNameAndValue.d.ts.map +1 -0
  24. package/dist/utils/index.d.ts +5 -0
  25. package/dist/utils/index.d.ts.map +1 -0
  26. package/dist/utils/wrapJSX.d.ts +14 -0
  27. package/dist/utils/wrapJSX.d.ts.map +1 -0
  28. package/package.json +10 -10
  29. package/src/Chip.tsx +13 -3
  30. package/src/Combobox.spec.tsx +321 -242
  31. package/src/Combobox.story.tsx +98 -3
  32. package/src/Combobox.styles.ts +83 -24
  33. package/src/Combobox.tsx +456 -268
  34. package/src/Combobox.types.ts +36 -1
  35. package/src/ComboboxContext.tsx +2 -2
  36. package/src/ComboboxOption.tsx +34 -8
  37. package/src/ComboboxTestUtils.tsx +20 -3
  38. package/src/utils/ComboboxUtils.spec.tsx +227 -0
  39. package/src/utils/OptionObjectUtils.ts +26 -0
  40. package/src/utils/flattenChildren.tsx +47 -0
  41. package/src/utils/getNameAndValue.ts +23 -0
  42. package/src/utils/index.ts +8 -0
  43. package/src/utils/wrapJSX.tsx +54 -0
  44. package/tsconfig.tsbuildinfo +1 -1
  45. package/dist/util.d.ts +0 -53
  46. package/dist/util.d.ts.map +0 -1
  47. package/src/util.tsx +0 -133
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("lodash"),require("@leafygreen-ui/typography"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/interaction-ring"),require("@leafygreen-ui/icon"),require("@leafygreen-ui/icon-button"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/palette"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/checkbox"),require("lodash/kebabCase"),require("@emotion/react"),require("@leafygreen-ui/inline-definition"),require("@leafygreen-ui/tokens")):"function"==typeof define&&define.amd?define(["exports","react","lodash","@leafygreen-ui/typography","@leafygreen-ui/popover","@leafygreen-ui/hooks","@leafygreen-ui/interaction-ring","@leafygreen-ui/icon","@leafygreen-ui/icon-button","@leafygreen-ui/emotion","@leafygreen-ui/palette","@leafygreen-ui/lib","@leafygreen-ui/checkbox","lodash/kebabCase","@emotion/react","@leafygreen-ui/inline-definition","@leafygreen-ui/tokens"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/combobox"]={},e.React,e._,e["@leafygreen-ui/typography"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/interaction-ring"],e["@leafygreen-ui/icon"],e["@leafygreen-ui/icon-button"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/palette"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/checkbox"],e.kebabCase,e.react,e["@leafygreen-ui/inline-definition"],e["@leafygreen-ui/tokens"])}(this,(function(e,n,o,r,t,i,l,a,c,s,u,d,b,f,g,p,m){"use strict";function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=h(n),x=h(t),y=h(l),w=h(a),C=h(c),k=h(b),j=h(f),N=h(p);function O(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,r)}return o}function M(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?O(Object(o),!0).forEach((function(n){S(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):O(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function S(e,n,o){return n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,e}function I(){return I=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},I.apply(this,arguments)}function A(e,n){if(null==e)return{};var o,r,t=function(e,n){if(null==e)return{};var o,r,t={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],n.indexOf(o)>=0||(t[o]=e[o]);return t}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],n.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(t[o]=e[o])}return t}function z(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}function P(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==o)return;var r,t,i=[],l=!0,a=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(i.push(r.value),!n||i.length!==n);l=!0);}catch(e){a=!0,t=e}finally{try{l||null==o.return||o.return()}finally{if(a)throw t}}return i}(e,n)||F(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||F(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,n){if(e){if("string"==typeof e)return L(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?L(e,n):void 0}}function L(e,n){(null==n||n>e.length)&&(n=e.length);for(var o=0,r=new Array(n);o<n;o++)r[o]=e[o];return r}var T,R,q,G,W,B,K,U,V,H,X,Z,_,Y,$,J,Q,ee,ne,oe,re,te,ie,le,ae,ce,se,ue=n.createContext({multiselect:!1,darkMode:!1,size:"default",withIcons:!1,disabled:!1}),de=M(M({},d.keyMap),{},{Backspace:8,Delete:46}),be=function(e,n,o){if(n&&o){var r=new RegExp(n,"gi"),t=e.matchAll(r);if(t){for(var i=e.split(""),l=0,a=Array.from(t);l<a.length;l++){var c,s=a[l],u=null!==(c=s.index)&&void 0!==c?c:-1,d=s[0],b=d.length,f=u+d+b,p=new Array(b).fill("");p[0]=v.default.createElement(o,{key:f},d),i.splice.apply(i,[u,b].concat(D(p)))}return g.jsx(v.default.Fragment,null,i)}return g.jsx(v.default.Fragment,null,e)}return g.jsx(v.default.Fragment,null,e)},fe=function(e){var n,o=e.value,r=e.displayName;return{value:null!=o?o:j.default(r),displayName:null!==(n=null!=r?r:o)&&void 0!==n?n:""}},ge=function e(n){return v.default.Children.toArray(n).reduce((function(n,o){if(d.isComponentType(o,"ComboboxOption")){var r=fe(o.props),t=r.value,i=r.displayName,l=o.props.glyph;return[].concat(D(n),[{value:t,displayName:i,hasGlyph:!!l}])}if(d.isComponentType(o,"ComboboxGroup")){var a=o.props.children;if(a)return[].concat(D(n),D(e(a)))}}),[])},pe=s.css(R||(R=z(["\n display: inline-flex;\n gap: 8px;\n justify-content: start;\n align-items: inherit;\n"]))),me=s.css(q||(q=z(["\n pointer-events: none;\n"]))),he=function(e){return s.css(G||(G=z(["\n font-weight: ",";\n"])),e?"bold":"normal")},ve=v.default.forwardRef((function(e,o){var r=e.displayName,t=e.glyph,l=e.isSelected,c=e.isFocused,b=e.setSelected,f=e.className,p=n.useContext(ue),m=p.multiselect,h=p.darkMode,x=p.withIcons,y=p.inputValue,C=i.useIdAllocator({prefix:"combobox-option-text"}),j=i.useForwardedRef(o,null),N=n.useCallback((function(e){e.stopPropagation(),e.target!==j.current&&"INPUT"!==e.target.tagName||b()}),[j,b]),O=n.useMemo((function(){if(t){if(a.isComponentGlyph(t)||d.isComponentType(t,"Icon"))return t;console.error("`ComboboxOption` instance did not render icon because it is not a known glyph element.",t)}}),[t]),M=n.useMemo((function(){if(m){var e=g.jsx(k.default,{label:"","aria-labelledby":C,checked:l,tabIndex:-1,animate:!1});return g.jsx(v.default.Fragment,null,g.jsx("span",{className:s.cx(pe,me)},x?O:e,g.jsx("span",{id:C,className:he(l)},be(r,y,"strong"))),x&&e)}return g.jsx(v.default.Fragment,null,g.jsx("span",{className:s.cx(pe,me)},O,g.jsx("span",{className:he(l)},be(r,y,"strong"))),l&&g.jsx(w.default,{glyph:"Checkmark",color:h?u.uiColors.blue.light1:u.uiColors.blue.base}))}),[m,O,l,r,y,h,C,x]);return g.jsx("li",{ref:j,role:"option","aria-selected":c,"aria-label":r,tabIndex:-1,className:s.cx(s.css(T||(T=z(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n list-style: none;\n color: inherit;\n cursor: pointer;\n overflow: hidden;\n font-size: var(--lg-combobox-item-font-size);\n line-height: var(--lg-combobox-item-line-height);\n padding: var(--lg-combobox-item-padding-y) var(--lg-combobox-item-padding-x);\n\n &:before {\n content: '';\n position: absolute;\n left: 0;\n width: 3px;\n height: var(--lg-combobox-item-wedge-height);\n background-color: transparent;\n border-radius: 0 2px 2px 0;\n transform: scaleY(0.3);\n transition: 150ms ease-in-out;\n transition-property: transform, background-color;\n }\n\n &:hover {\n outline: none;\n background-color: var(--lg-combobox-item-hover-color);\n }\n\n &[aria-selected='true'] {\n outline: none;\n background-color: var(--lg-combobox-item-active-color);\n\n &:before {\n background-color: var(--lg-combobox-item-wedge-color);\n transform: scaleY(1);\n }\n }\n"]))),f),onClick:N,onKeyPress:N},M)}));function xe(e){throw Error("`ComboboxOption` must be a child of a `Combobox` instance")}ve.displayName="ComboboxOption",xe.displayName="ComboboxOption";var ye,we,Ce,ke,je,Ne,Oe,Me,Ee=d.createUniqueClassName("combobox-chip"),Se=function(e){var n=e.darkMode,o=e.size,r=e.overflow;return s.cx(function(e){return e?s.css(W||(W=z([""]))):s.css(B||(B=z(["\n --lg-combobox-color-error: ",";\n --lg-combobox-text-color: ",";\n --lg-combobox-text-color-disabled: ",";\n\n --lg-combobox-background-color: ",";\n --lg-combobox-background-color-focus: ",";\n --lg-combobox-background-color-disabled: ",";\n\n --lg-combobox-border-color: ",";\n --lg-combobox-border-color-disabled: ",";\n --lg-combobox-border-color-error: ",";\n\n --lg-combobox-shadow: 0px 1px 2px rgba(6, 22, 33, 0.3);\n --lg-combobox-shadow-focus: 0px 4px 4px rgba(6, 22, 33, 0.3);\n "])),u.uiColors.red.base,u.uiColors.gray.dark3,u.uiColors.gray.dark1,u.uiColors.gray.light3,u.uiColors.white,u.uiColors.gray.light2,u.uiColors.gray.base,u.uiColors.gray.light1,u.uiColors.red.base)}(n),function(e){if("default"===e)return s.css(K||(K=z(["\n --lg-combobox-padding-y: 5px;\n --lg-combobox-padding-x: 7px;\n --lg-combobox-height: 24px;\n --lg-combobox-font-size: 14px;\n --lg-combobox-line-height: 20px;\n --lg-combobox-border-radius: 3px;\n --lg-combobox-icon-height: 16px;\n "])))}(o),s.css(U||(U=z(["\n --lg-combobox-width: ",";\n --lg-combobox-padding: var(--lg-combobox-padding-y)\n var(--lg-combobox-padding-x) var(--lg-combobox-padding-y)\n ",";\n width: var(--lg-combobox-width);\n // TODO: Clean this up 🤮\n min-width: calc(\n ","px + var(--lg-combobox-padding-x) * 2 + 2px +\n var(--lg-combobox-icon-height)\n );\n "])),"expand-x"===r?"unset":"100%","scroll-x"===r?"0":"var(--lg-combobox-padding-x)",24))},Ie=s.css(V||(V=z(["\n display: flex;\n flex-wrap: nowrap;\n align-items: center;\n padding: var(--lg-combobox-padding);\n color: var(--lg-combobox-text-color);\n background-color: var(--lg-combobox-background-color);\n box-shadow: var(--lg-combobox-shadow);\n border: 1px solid var(--lg-combobox-border-color);\n border-radius: var(--lg-combobox-border-radius);\n width: var(--lg-combobox-width);\n cursor: text;\n transition: 150ms ease-in-out;\n transition-property: background-color, box-shadow;\n\n &:focus-within {\n background-color: var(--lg-combobox-background-color-focus);\n box-shadow: var(--lg-combobox-shadow-focus);\n }\n\n &[data-disabled='true'] {\n color: var(--lg-combobox-text-color-disabled);\n background-color: var(--lg-combobox-background-color-disabled);\n border-color: var(--lg-combobox-border-color-disabled);\n box-shadow: unset;\n cursor: not-allowed;\n }\n\n &[data-state='error'] {\n border-color: var(--lg-combobox-border-color-error);\n }\n"]))),Ae=s.css(H||(H=z(["\n width: var(--lg-combobox-width);\n"]))),ze=function(e){var n=e.state;return e.darkMode?{hovered:"error"===n?u.uiColors.red.dark2:void 0}:{hovered:"error"===n?u.uiColors.red.light3:void 0}},Pe=function(e){var n,r=e.overflow,t=e.isOpen,i=e.selection,l=e.value,a=o.isArray(i)&&i.length>0,c=null!==(n=null==l?void 0:l.length)&&void 0!==n?n:0,u=s.css(X||(X=z(["\n flex-grow: 1;\n width: var(--lg-combobox-width);\n\n --lg-combobox-input-width: ",";\n "])),a?"".concat(c,"ch"):"100%");switch(r){case"scroll-x":return s.css(Z||(Z=z(["\n ","\n display: block;\n height: var(--lg-combobox-height);\n white-space: nowrap;\n overflow-x: scroll;\n padding-left: var(--lg-combobox-padding-x);\n scroll-behavior: smooth;\n scrollbar-width: none;\n /*\n * Immediate transition in, slow transition out. \n * '-in' transition is handled by `scroll-behavior` \n */\n --lg-combobox-input-transition: width ease-in-out\n ",";\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n & > ."," {\n margin-inline: 2px;\n\n &:first-child {\n margin-inline-start: 0;\n }\n\n &:last-child {\n margin-inline-end: 0;\n }\n }\n "],["\n ","\n display: block;\n height: var(--lg-combobox-height);\n white-space: nowrap;\n overflow-x: scroll;\n padding-left: var(--lg-combobox-padding-x);\n scroll-behavior: smooth;\n scrollbar-width: none;\n /*\n * Immediate transition in, slow transition out. \n * '-in' transition is handled by \\`scroll-behavior\\` \n */\n --lg-combobox-input-transition: width ease-in-out\n ",";\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n & > ."," {\n margin-inline: 2px;\n\n &:first-child {\n margin-inline-start: 0;\n }\n\n &:last-child {\n margin-inline-end: 0;\n }\n }\n "])),u,t?"0":"100ms",Ee);case"expand-x":return s.css(_||(_=z(["\n ","\n display: flex;\n gap: 4px;\n flex-wrap: nowrap;\n white-space: nowrap;\n height: var(--lg-combobox-height);\n --lg-combobox-input-transition: none;\n "])),u);case"expand-y":return s.css(Y||(Y=z(["\n ","\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n overflow-x: visible;\n min-height: var(--lg-combobox-height);\n "])),u)}},De=s.css($||($=z(["\n border: none;\n cursor: inherit;\n background-color: inherit;\n box-sizing: content-box;\n padding: 0;\n margin: 0;\n text-overflow: ellipsis;\n line-height: var(--lg-combobox-line-height);\n height: var(--lg-combobox-height);\n width: var(--lg-combobox-input-width, 0);\n transition: var(--lg-combobox-input-transition);\n\n &:focus {\n outline: none;\n }\n"]))),Fe=s.css(J||(J=z(["\n // Add a negative margin so the button takes up the same space as the regular icons\n margin-block: calc(var(--lg-combobox-icon-height) / 2 - 100%);\n"]))),Le=s.css(Q||(Q=z(["\n font-size: var(--lg-combobox-font-size);\n line-height: var(--lg-combobox-line-height);\n color: var(--lg-combobox-color-error);\n padding-top: var(--lg-combobox-padding-y);\n"]))),Te=s.css(ee||(ee=z(["\n margin-inline-end: calc(var(--lg-combobox-padding-x) / 2);\n"]))),Re=s.keyframes(ne||(ne=z(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]))),qe=s.css(oe||(oe=z(["\n animation: "," 1.5s linear infinite;\n"])),Re),Ge=function(e){var n,o,r=e.darkMode,t=e.size,i=e.width,l=void 0===i?384:i;if(n=r?s.css(re||(re=z([""]))):s.css(te||(te=z(["\n --lg-combobox-menu-color: ",";\n --lg-combobox-menu-message-color: ",";\n --lg-combobox-menu-background-color: ",";\n --lg-combobox-menu-shadow: 0px 3px 7px rgba(0, 0, 0, 0.25);\n --lg-combobox-item-hover-color: ",";\n --lg-combobox-item-active-color: ",";\n --lg-combobox-item-wedge-color: ",";\n "])),u.uiColors.gray.dark3,u.uiColors.gray.dark1,u.uiColors.white,u.uiColors.gray.light2,u.uiColors.blue.light3,u.uiColors.blue.base),"default"===t)o=s.css(ie||(ie=z(["\n --lg-combobox-menu-border-radius: 4px;\n --lg-combobox-item-height: 36px;\n --lg-combobox-item-padding-y: 8px;\n --lg-combobox-item-padding-x: 12px;\n --lg-combobox-item-font-size: 14px;\n --lg-combobox-item-line-height: 21px;\n --lg-combobox-item-wedge-height: 22px;\n "])));return s.cx(n,o,s.css(le||(le=z(["\n width: ","px;\n border-radius: var(--lg-combobox-menu-border-radius);\n\n & > * {\n border-radius: inherit;\n }\n "])),l))},We=function(e){var n=e.maxHeight;return s.css(ae||(ae=z(["\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n font-family: ",";\n color: var(--lg-combobox-menu-color);\n background-color: var(--lg-combobox-menu-background-color);\n box-shadow: var(--lg-combobox-menu-shadow);\n border-radius: inherit;\n overflow: auto;\n min-height: var(--lg-combobox-item-height);\n max-height: ","px;\n scroll-behavior: smooth;\n"])),m.fontFamilies.default,n)},Be=s.css(ce||(ce=z(["\n position: relative;\n margin: 0;\n padding: 0;\n"]))),Ke=s.css(se||(se=z(["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-size: var(--lg-combobox-item-font-size);\n color: var(--lg-combobox-menu-message-color);\n padding: var(--lg-combobox-item-padding-y) var(--lg-combobox-item-padding-x);\n\n & > svg {\n width: 1em;\n height: 1em;\n }\n"]))),Ue=function(e){var n,o,r=e.darkMode,t=e.size;if(n=r?s.css(ye||(ye=z([""]))):s.css(we||(we=z(["\n --lg-combobox-chip-text-color: ",";\n --lg-combobox-chip-icon-color: ",";\n --lg-combobox-chip-background-color: ",";\n --lg-combobox-chip-hover-color: ",";\n --lg-combobox-chip-focus-color: ",";\n "])),u.uiColors.gray.dark3,u.uiColors.gray.dark2,u.uiColors.gray.light2,u.uiColors.gray.light1,u.uiColors.blue.light2),"default"===t)o=s.css(Ce||(Ce=z(["\n --lg-combobox-chip-height: 24px;\n --lg-combobox-chip-border-radius: 4px;\n --lg-combobox-chip-font-size: 14px;\n --lg-combobox-chip-line-height: 20px;\n --lg-combobox-chip-padding-x: 6px;\n "])));return s.cx(n,o,s.css(ke||(ke=z(["\n display: inline-flex;\n align-items: center;\n overflow: hidden;\n white-space: nowrap;\n height: var(--lg-combobox-chip-height);\n font-size: var(--lg-combobox-chip-font-size);\n line-height: var(--lg-combobox-chip-line-height);\n border-radius: var(--lg-combobox-chip-border-radius);\n color: var(--lg-combobox-chip-text-color);\n background-color: var(--lg-combobox-chip-background-color);\n\n // TODO - refine these styles\n /* &:focus, */\n &:focus-within {\n background-color: var(--lg-combobox-chip-focus-color);\n }\n "]))))},Ve=s.css(je||(je=z(["\n padding-inline: var(--lg-combobox-chip-padding-x);\n"]))),He=s.css(Ne||(Ne=z(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n outline: none;\n border: none;\n background-color: transparent;\n color: var(--lg-combobox-chip-icon-color);\n cursor: pointer;\n transition: background-color 100ms ease-in-out;\n\n &:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 1px;\n background-color: var(--lg-combobox-chip-hover-color);\n }\n\n &:hover {\n background-color: var(--lg-combobox-chip-hover-color);\n }\n"]))),Xe=v.default.forwardRef((function(e,o){var r=e.displayName,t=e.isFocused,i=e.onRemove,l=e.onFocus,a=n.useContext(ue),c=a.darkMode,u=a.size,d=a.disabled,b=a.chipTruncationLocation,f=void 0===b?"end":b,p=a.chipCharacterLimit,m=void 0===p?12:p,h=!!m&&!!f&&"none"!==f&&r.length>m,v=n.useRef(null),x=n.useMemo((function(){if(h){var e=m-3;switch(f){case"start":return"…"+r.substring(r.length-e).trim();case"middle":return r.substring(0,e/2).trim()+"…"+r.substring(r.length-e/2).trim();case"end":return r.substring(0,e).trim()+"…";default:return r}}return!1}),[m,f,r,h]);n.useEffect((function(){var e;t&&!d&&(null==v||null===(e=v.current)||void 0===e||e.focus())}),[d,o,t]);return g.jsx("span",{role:"option","aria-selected":t,"data-testid":"lg-combobox-chip",ref:o,className:s.cx(Ee,Ue({darkMode:c,size:u})),onClick:function(e){var n;null!==(n=v.current)&&void 0!==n&&n.contains(e.target)||l()},tabIndex:-1},g.jsx("span",{className:Ve},x?g.jsx(N.default,{definition:r,align:"bottom"},x):r),g.jsx("button",{"aria-label":"Deselect ".concat(r),"aria-disabled":d,disabled:d,ref:v,className:He,onClick:function(){d||i()},onKeyDown:function(e){d||e.keyCode!==de.Delete&&e.keyCode!==de.Backspace&&e.keyCode!==de.Enter&&e.keyCode!==de.Space||i()}},g.jsx(w.default,{glyph:"X"})))}));Xe.displayName="Chip";var Ze=function(e){return s.css(Oe||(Oe=z(["\n --lg-combobox-group-label-color: ",";\n --lg-combobox-group-border-color: ",";\n padding-top: 8px;\n border-bottom: 1px solid var(--lg-combobox-group-border-color);\n"])),e?u.uiColors.gray.light1:u.uiColors.gray.dark1,e?u.uiColors.gray.dark1:u.uiColors.gray.light1)},_e=s.css(Me||(Me=z(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: bold;\n text-transform: uppercase;\n letter-spacing: 0.4px;\n color: var(--lg-combobox-group-label-color);\n"])));function Ye(e){var o=e.label,r=e.className,t=e.children,l=n.useContext(ue).darkMode,a=i.useIdAllocator({prefix:"combobox-group"});return v.default.Children.count(t)>0?g.jsx("div",{className:s.cx(Ze(l),r)},g.jsx("div",{className:_e,id:a},o),g.jsx("div",{role:"group","aria-labelledby":a},t)):g.jsx(v.default.Fragment,null)}function $e(e){throw Error("`ComboboxGroup` must be a child of a `Combobox` instance")}$e.displayName="ComboboxGroup";var Je=["children","label","description","placeholder","aria-label","disabled","size","darkMode","state","errorMessage","searchState","searchEmptyMessage","searchErrorMessage","searchLoadingMessage","filteredOptions","onFilter","clearable","onClear","overflow","multiselect","initialValue","onChange","value","chipTruncationLocation","chipCharacterLimit","className","usePortal","portalClassName","portalContainer","scrollContainer","popoverZIndex"];e.Combobox=function(e){var t=e.children,l=e.label,a=e.description,c=e.placeholder,b=void 0===c?"Select":c,f=e["aria-label"],p=e.disabled,m=void 0!==p&&p,h=e.size,k=void 0===h?"default":h,j=e.darkMode,N=void 0!==j&&j,O=e.state,S=void 0===O?"none":O,z=e.errorMessage,D=e.searchState,F=void 0===D?"unset":D,L=e.searchEmptyMessage,T=void 0===L?"No results found":L,R=e.searchErrorMessage,q=void 0===R?"Could not get results!":R,G=e.searchLoadingMessage,W=void 0===G?"Loading results...":G,B=e.filteredOptions,K=e.onFilter,U=e.clearable,V=void 0===U||U,H=e.onClear,X=e.overflow,Z=void 0===X?"expand-y":X,_=e.multiselect,Y=void 0!==_&&_,$=e.initialValue,J=e.onChange,Q=e.value,ee=e.chipTruncationLocation,ne=e.chipCharacterLimit,oe=void 0===ne?12:ne,re=e.className,te=e.usePortal,ie=void 0===te||te,le=e.portalClassName,ae=e.portalContainer,ce=e.scrollContainer,se=e.popoverZIndex,be=A(e,Je),pe=i.useDynamicRefs({prefix:"option"}),me=i.useDynamicRefs({prefix:"chip"}),he=i.useIdAllocator({prefix:"combobox-input"}),xe=i.useIdAllocator({prefix:"combobox-label"}),ye=i.useIdAllocator({prefix:"combobox-menu"}),we=n.useRef(null),Ce=n.useRef(null),ke=n.useRef(null),je=n.useRef(null),Ne=n.useRef(null),Oe=P(n.useState(!1),2),Me=Oe[0],Ee=Oe[1],Re=i.usePrevious(Me),Ue=P(n.useState(null),2),Ve=Ue[0],He=Ue[1],Ze=P(n.useState(null),2),_e=Ze[0],$e=Ze[1],Qe=i.usePrevious(_e),en=P(n.useState(""),2),nn=en[0],on=en[1],rn=i.usePrevious(nn),tn=P(n.useState(null),2),ln=tn[0],an=tn[1],cn=!o.isNull(_e)&&(o.isArray(_e)&&_e.length>0||o.isString(_e)),sn=n.useCallback((function(e){return!Y||"string"!=typeof e&&"number"!=typeof e?!Y&&o.isArray(e)&&d.consoleOnce.error("Error in Combobox: multiselect is set to `false`, but recieved an Array value"):d.consoleOnce.error("Error in Combobox: multiselect is set to `true`, but recieved a ".concat(E(e),' value: "').concat(e,'"')),Y&&o.isArray(e)}),[Y]),un=n.useCallback((function(e){!m&&je&&je.current&&(je.current.focus(),o.isUndefined(e)||je.current.setSelectionRange(e,e))}),[m]),dn=n.useCallback((function(e){if(sn(_e)){var n=o.clone(_e);o.isNull(e)?n.length=0:_e.includes(e)?n.splice(n.indexOf(e),1):(n.push(e),on("")),$e(n),null==J||J(n)}else{var r=e;$e(r),null==J||J(r)}}),[sn,J,_e]),bn=function(){ke&&ke.current&&(ke.current.scrollLeft=ke.current.scrollWidth)},fn=Y&&o.isArray(_e)&&_e.length>0?void 0:b,gn=n.useMemo((function(){return ge(t)}),[t]),pn=n.useCallback((function(e){var n,o;return e?null!==(n=null===(o=gn.find((function(n){return n.value===e})))||void 0===o?void 0:o.displayName)&&void 0!==n?n:e:""}),[gn]),mn=n.useCallback((function(e){var n="string"==typeof e?e:e.value;return B&&B.length>0?B.includes(n):("string"==typeof e?pn(n):e.displayName).toLowerCase().includes(nn.toLowerCase())}),[B,pn,nn]),hn=n.useMemo((function(){return gn.filter(mn)}),[gn,mn]),vn=n.useCallback((function(e){return!!e&&!!gn.find((function(n){return n.value===e}))}),[gn]),xn=n.useCallback((function(e){return hn?hn.findIndex((function(n){return n.value===e})):-1}),[hn]),yn=n.useCallback((function(e){if(hn&&hn.length>=e){var n=hn[e];return n?n.value:void 0}}),[hn]),wn=n.useCallback((function(){return sn(_e)?_e.findIndex((function(e){var n,o;return null===(n=me(e))||void 0===n||null===(o=n.current)||void 0===o?void 0:o.contains(document.activeElement)})):-1}),[me,sn,_e]),Cn=n.useCallback((function(){var e,n,o,r=null===(e=je.current)||void 0===e?void 0:e.contains(document.activeElement),t=null===(n=Ce.current)||void 0===n?void 0:n.contains(document.activeElement),i=sn(_e)&&_e.some((function(e){var n,o;return null===(n=me(e))||void 0===n||null===(o=n.current)||void 0===o?void 0:o.contains(document.activeElement)})),l=function(){return sn(_e)?_e.findIndex((function(e){var n,o;return null===(n=me(e))||void 0===n||null===(o=n.current)||void 0===o?void 0:o.contains(document.activeElement)})):-1};return sn(_e)&&i?0===l()?"FirstChip":l()===_e.length-1?"LastChip":"MiddleChip":r?"Input":t?"ClearButton":null!==(o=we.current)&&void 0!==o&&o.contains(document.activeElement)?"Combobox":void 0}),[me,sn,_e]),kn=n.useCallback((function(e){var n,o=null!==(n=null==hn?void 0:hn.length)&&void 0!==n?n:0,r=o-1>0?o-1:0,t=xn(Ve);switch(e&&Me&&(an(null),un()),e){case"next":var i=yn(t+1<o?t+1:0);He(null!=i?i:null);break;case"prev":var l=yn(t-1>=0?t-1:r);He(null!=l?l:null);break;case"last":var a=yn(r);He(null!=a?a:null);break;default:var c=yn(0);He(null!=c?c:null)}}),[Ve,xn,yn,Me,un,null==hn?void 0:hn.length]),jn=n.useCallback((function(e,n){if(sn(_e))switch(e){case"next":var o=null!=n?n:wn(),r=o+1<_e.length?o+1:_e.length-1,t=_e[r];an(t);break;case"prev":var i=null!=n?n:wn(),l=i>0?i-1:i<0?_e.length-1:0,a=_e[l];an(a);break;case"first":var c=_e[0];an(c);break;case"last":var s=_e[_e.length-1];an(s);break;default:an(null)}}),[wn,sn,_e]),Nn=n.useCallback((function(e,n){e&&He(null);var o=Cn();switch(e){case"right":switch(o){case"Input":var r,t,i;if((null===(r=je.current)||void 0===r?void 0:r.selectionEnd)===(null===(t=je.current)||void 0===t?void 0:t.value.length))null===(i=Ce.current)||void 0===i||i.focus();break;case"LastChip":n.preventDefault(),un(0),jn(null);break;case"FirstChip":case"MiddleChip":jn("next")}break;case"left":switch(o){case"ClearButton":var l;n.preventDefault(),un(null==je||null===(l=je.current)||void 0===l?void 0:l.value.length);break;case"Input":case"MiddleChip":case"LastChip":if(sn(_e)){var a;if("Input"===o&&0!==(null===(a=je.current)||void 0===a?void 0:a.selectionStart))break;jn("prev")}}break;default:jn(null)}}),[Cn,sn,_e,un,jn]);n.useEffect((function(){nn!==rn&&kn("first")}),[nn,Me,rn,kn]),n.useEffect((function(){if(Ve){var e=pe(Ve);if(e&&e.current&&Ne.current){var n=e.current.offsetTop,o=Ne.current,r=o.scrollTop;(n>o.offsetHeight||n<r)&&(Ne.current.scrollTop=n)}}}),[Ve,pe]);var On=n.useCallback((function(e){return v.default.Children.map(e,(function(e){if(d.isComponentType(e,"ComboboxOption")){var n=fe(e.props),o=n.value,r=n.displayName;if(mn(o)){var t=e.props,i=t.className,l=t.glyph,a=gn.findIndex((function(e){return e.value===o})),c=Ve===o,s=sn(_e)?_e.includes(o):_e===o,u=pe(o);return g.jsx(ve,{value:o,displayName:r,isFocused:c,isSelected:s,setSelected:function(){He(o),dn(o),un(),o===_e&&Pn()},glyph:l,className:i,index:a,ref:u})}}else if(d.isComponentType(e,"ComboboxGroup")){var b=On(e.props.children);if(b&&(null==b?void 0:b.length)>0)return g.jsx(Ye,{label:e.props.label,className:e.props.className},On(b))}}))}),[gn,Ve,pe,sn,mn,_e,un,dn]),Mn=n.useMemo((function(){return On(t)}),[t,On]),En=n.useMemo((function(){if(sn(_e))return _e.filter(vn).map((function(e,n){var o=pn(e),r=ln===e,t=me(e);return g.jsx(Xe,{key:e,displayName:o,isFocused:r,onRemove:function(){jn("next",n),dn(e)},onFocus:function(){an(e)},ref:t})}))}),[sn,_e,vn,pn,ln,me,jn,dn]),Sn=n.useMemo((function(){return g.jsx(v.default.Fragment,null,V&&cn&&g.jsx(C.default,{"aria-label":"Clear selection","aria-disabled":m,disabled:m,ref:Ce,onClick:function(e){m||(dn(null),null==H||H(e),null==K||K(""),Me||Dn())},onFocus:Wn,className:Fe},g.jsx(w.default,{glyph:"XWithCircle"})),"error"===S?g.jsx(w.default,{glyph:"Warning",color:u.uiColors.red.base,className:Te}):g.jsx(w.default,{glyph:"CaretDown",className:Te}))}),[V,cn,m,S,dn,H,K,Me]),In=n.useMemo((function(){return gn.some((function(e){return e.hasGlyph}))}),[gn]),An=n.useCallback((function(){if(!sn(_e)&&_e===Qe){var e=hn.find((function(e){return e.displayName===nn||e.value===nn}));if(e&&!Q)$e(e.value);else{var n,o=null!==(n=pn(_e))&&void 0!==n?n:"";on(o)}}}),[pn,nn,sn,Qe,_e,Q,hn]),zn=n.useCallback((function(){if(cn){if(sn(_e))bn();else if(!sn(_e)){var e,n=null!==(e=pn(_e))&&void 0!==e?e:"";on(n),Pn()}}else on("")}),[cn,pn,sn,_e]);n.useEffect((function(){if($)if(o.isArray($)){var e,n=null!==(e=$.filter((function(e){return vn(e)})))&&void 0!==e?e:[];$e(n)}else vn($)&&$e($);else $e(function(e){return e?[]:null}(Y))}),[]),n.useEffect((function(){if(!o.isUndefined(Q)&&Q!==rn)if(o.isNull(Q))$e(null);else if(sn(Q)){var e=Q.filter(vn);$e(e)}else $e(vn(Q)?Q:null)}),[sn,vn,rn,Q]),n.useEffect((function(){o.isEqual(_e,Qe)||zn()}),[zn,Qe,_e]),n.useEffect((function(){Me||Re===Me||An()}),[Me,Re,An]);var Pn=function(){return Ee(!1)},Dn=function(){return Ee(!0)},Fn=P(n.useState(0),2),Ln=Fn[0],Tn=Fn[1];n.useEffect((function(){var e,n;Tn(null!==(e=null===(n=we.current)||void 0===n?void 0:n.clientWidth)&&void 0!==e?e:0)}),[we,Me,Ve,_e]);var Rn=n.useMemo((function(){switch(F){case"loading":return g.jsx("span",{className:Ke},g.jsx(w.default,{glyph:"Refresh",color:u.uiColors.blue.base,className:qe}),W);case"error":return g.jsx("span",{className:Ke},g.jsx(w.default,{glyph:"Warning",color:u.uiColors.red.base}),q);default:return Mn&&Mn.length>0?g.jsx("ul",{className:Be},Mn):g.jsx("span",{className:Ke},T)}}),[Mn,T,q,W,F]),qn=i.useViewportSize(),Gn=n.useMemo((function(){if(qn&&we.current&&Ne.current){var e=we.current.getBoundingClientRect(),n=e.top,o=e.bottom,r=Math.max(qn.height-o,n);return Math.min(274,r-8)}return 274}),[qn,we,Ne]);n.useEffect((function(){}),[Ve]);var Wn=function(){He(null)};i.useEventListener("mousedown",(function(e){var n,o,r=e.target;(null===(n=Ne.current)||void 0===n?void 0:n.contains(r))||(null===(o=we.current)||void 0===o?void 0:o.contains(r))||!1||Ee(!1)}));var Bn=M({popoverZIndex:se},ie?{usePortal:ie,portalClassName:le,portalContainer:ae,scrollContainer:ce}:{usePortal:ie});return g.jsx(ue.Provider,{value:{multiselect:Y,darkMode:N,size:k,withIcons:In,disabled:m,chipTruncationLocation:ee,chipCharacterLimit:oe,inputValue:nn}},g.jsx("div",I({className:s.cx(Se({darkMode:N,size:k,overflow:Z}),re)},be),g.jsx("div",null,l&&g.jsx(r.Label,{id:xe,htmlFor:he},l),a&&g.jsx(r.Description,null,a)),g.jsx(y.default,{className:Ae,disabled:m,color:ze({state:S,darkMode:N})},g.jsx("div",{ref:we,role:"combobox","aria-expanded":Me,"aria-controls":ye,"aria-owns":ye,tabIndex:-1,className:Ie,onMouseDown:function(e){m&&e.preventDefault()},onClick:function(e){if(e.target!==je.current){var n=0;if(je.current)n=e.nativeEvent.offsetX>je.current.offsetLeft+je.current.clientWidth?nn.length:0;un(n)}},onFocus:function(){bn(),Dn()},onKeyDown:function(e){var n,r,t=null===(n=Ne.current)||void 0===n?void 0:n.contains(document.activeElement);if((null===(r=we.current)||void 0===r?void 0:r.contains(document.activeElement))||t){if(e.ctrlKey||e.shiftKey||e.altKey)return;var i=Cn();switch(e.keyCode){case de.Tab:switch(i){case"Input":cn||(Pn(),kn("first"),jn(null));break;case"LastChip":jn(null)}break;case de.Escape:Pn(),kn("first");break;case de.Enter:document.activeElement===je.current&&Me&&!o.isNull(Ve)?dn(Ve):document.activeElement===Ce.current&&(dn(null),un());break;case de.Backspace:var l;sn(_e)&&0===(null===(l=je.current)||void 0===l?void 0:l.selectionStart)?jn("last"):Dn();break;case de.ArrowDown:Me&&e.preventDefault(),Dn(),kn("next");break;case de.ArrowUp:Me&&e.preventDefault(),kn("prev");break;case de.ArrowRight:Nn("right",e);break;case de.ArrowLeft:Nn("left",e);break;default:Me||Dn()}}},onTransitionEnd:function(){var e,n;Tn(null!==(e=null===(n=we.current)||void 0===n?void 0:n.clientWidth)&&void 0!==e?e:0)},"data-disabled":m,"data-state":S},g.jsx("div",{ref:ke,className:Pe({overflow:Z,isOpen:Me,selection:_e,value:nn})},En,g.jsx("input",{"aria-label":null!=f?f:l,"aria-autocomplete":"list","aria-controls":ye,"aria-labelledby":xe,ref:je,id:he,className:De,placeholder:fn,disabled:null!=m?m:void 0,onChange:function(e){var n=e.target.value;on(n),null==K||K(n)},value:nn,autoComplete:"off"})),Sn)),"error"===S&&z&&g.jsx("div",{className:Le},z),g.jsx(x.default,I({active:Me&&!m,spacing:4,align:"bottom",justify:"middle",refEl:we,adjustOnMutation:!0,className:Ge({darkMode:N,size:k,width:Ln})},Bn),g.jsx("div",{id:ye,role:"listbox","aria-labelledby":xe,"aria-expanded":Me,ref:Ne,className:We({maxHeight:Gn}),onMouseDownCapture:function(e){return e.preventDefault()}},Rn))))},e.ComboboxGroup=$e,e.ComboboxOption=xe,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("react"),require("lodash"),require("@leafygreen-ui/typography"),require("@leafygreen-ui/popover"),require("@leafygreen-ui/hooks"),require("@leafygreen-ui/icon"),require("@leafygreen-ui/icon-button"),require("@leafygreen-ui/emotion"),require("@leafygreen-ui/palette"),require("@leafygreen-ui/lib"),require("@leafygreen-ui/checkbox"),require("@emotion/react"),require("lodash/kebabCase"),require("@leafygreen-ui/tokens"),require("@leafygreen-ui/inline-definition")):"function"==typeof define&&define.amd?define(["exports","react","lodash","@leafygreen-ui/typography","@leafygreen-ui/popover","@leafygreen-ui/hooks","@leafygreen-ui/icon","@leafygreen-ui/icon-button","@leafygreen-ui/emotion","@leafygreen-ui/palette","@leafygreen-ui/lib","@leafygreen-ui/checkbox","@emotion/react","lodash/kebabCase","@leafygreen-ui/tokens","@leafygreen-ui/inline-definition"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self)["@leafygreen-ui/combobox"]={},e.React,e._,e["@leafygreen-ui/typography"],e["@leafygreen-ui/popover"],e["@leafygreen-ui/hooks"],e["@leafygreen-ui/icon"],e["@leafygreen-ui/icon-button"],e["@leafygreen-ui/emotion"],e["@leafygreen-ui/palette"],e["@leafygreen-ui/lib"],e["@leafygreen-ui/checkbox"],e.react,e.kebabCase,e["@leafygreen-ui/tokens"],e["@leafygreen-ui/inline-definition"])}(this,(function(e,o,n,r,t,i,l,a,c,s,u,d,b,f,p,g){"use strict";function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=m(o),h=m(t),v=m(l),y=m(a),w=m(d),k=m(f),C=m(g);function j(e,o){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),n.push.apply(n,r)}return n}function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function N(e,o,n){return o in e?Object.defineProperty(e,o,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[o]=n,e}function S(){return S=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(this,arguments)}function M(e,o){if(null==e)return{};var n,r,t=function(e,o){if(null==e)return{};var n,r,t={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],o.indexOf(n)>=0||(t[n]=e[n]);return t}(e,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],o.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}function z(e,o){return o||(o=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(o)}}))}function E(e,o){return function(e){if(Array.isArray(e))return e}(e)||function(e,o){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,t,i=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(i.push(r.value),!o||i.length!==o);l=!0);}catch(e){a=!0,t=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw t}}return i}(e,o)||I(e,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(e,o){if(e){if("string"==typeof e)return A(e,o);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(e,o):void 0}}function A(e,o){(null==o||o>e.length)&&(o=e.length);for(var n=0,r=new Array(o);n<o;n++)r[n]=e[n];return r}var T="Input",P="ClearButton",F="FirstChip",L="LastChip",R="MiddleChip",q="Combobox",G="Menu",U="default",W="large";var H,K,V,B,X,Z,_,Y,$,J,Q,ee,oe,ne,re,te,ie,le,ae,ce,se,ue,de,be,fe,pe,ge,me,xe,he,ve,ye,we,ke=o.createContext({multiselect:!1,darkMode:!1,size:U,withIcons:!1,disabled:!1}),Ce=function(e,o,n){if(o&&n){var r=new RegExp(o,"gi"),t=e.matchAll(r);if(t){for(var i=e.split(""),l=0,a=Array.from(t);l<a.length;l++){var c,s=a[l],u=null!==(c=s.index)&&void 0!==c?c:-1,d=s[0],f=d.length,p=u+d+f,g=new Array(f).fill("");g[0]=x.default.createElement(n,{key:p},d),i.splice.apply(i,[u,f].concat(D(g)))}return b.jsx(x.default.Fragment,null,i)}return b.jsx(x.default.Fragment,null,e)}return b.jsx(x.default.Fragment,null,e)},je=function(e){var o,n=e.value,r=e.displayName;return{value:null!=n?n:k.default(r),displayName:null!==(o=null!=r?r:n)&&void 0!==o?o:""}},Oe=function(e,o){if(e)return o.find((function(o){return o.value===e}))},Ne=function(e,o){var n,r;return e?null!==(n=null===(r=Oe(e,o))||void 0===r?void 0:r.displayName)&&void 0!==n?n:e:""},Se=function e(o){return x.default.Children.toArray(o).reduce((function(o,n){if(u.isComponentType(n,"ComboboxOption")){var r=je(n.props),t=r.value,i=r.displayName,l=n.props,a=l.glyph,c=l.disabled;return[].concat(D(o),[{value:t,displayName:i,isDisabled:!!c,hasGlyph:!!a}])}if(u.isComponentType(n,"ComboboxGroup")){var s=n.props.children;if(s)return[].concat(D(o),D(e(s)))}}),[])},Me=c.css(H||(H=z(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n list-style: none;\n color: inherit;\n cursor: pointer;\n overflow: hidden;\n font-family: ",";\n font-size: var(--lg-combobox-item-font-size);\n line-height: var(--lg-combobox-item-line-height);\n padding: var(--lg-combobox-item-padding-y) var(--lg-combobox-item-padding-x);\n\n // Left wedge\n &:before {\n content: '';\n position: absolute;\n left: 0;\n width: 3px;\n height: var(--lg-combobox-item-wedge-height);\n background-color: transparent;\n border-radius: 0 2px 2px 0;\n transform: scaleY(0.3);\n transition: 150ms ease-in-out;\n transition-property: transform, background-color;\n }\n\n &:hover {\n outline: none;\n background-color: var(--lg-combobox-item-hover-color);\n }\n\n &[aria-selected='true'] {\n outline: none;\n background-color: var(--lg-combobox-item-active-color);\n\n &:before {\n background-color: var(--lg-combobox-item-wedge-color);\n transform: scaleY(1);\n }\n }\n"])),p.fontFamilies.legacy),ze=c.css(K||(K=z(["\n cursor: not-allowed;\n color: ",";\n\n &:hover {\n background-color: inherit;\n }\n"])),s.uiColors.gray.base),Ee=c.css(V||(V=z(["\n display: inline-flex;\n gap: 8px;\n justify-content: start;\n align-items: inherit;\n overflow-wrap: anywhere;\n"]))),De=c.css(B||(B=z(["\n pointer-events: none;\n"]))),Ie=function(e){return c.css(X||(X=z(["\n font-weight: ",";\n"])),e?"bold":"normal")},Ae=x.default.forwardRef((function(e,n){var r=e.displayName,t=e.glyph,a=e.isSelected,d=e.isFocused,f=e.disabled,p=e.setSelected,g=e.className,m=o.useContext(ke),h=m.multiselect,y=m.darkMode,k=m.withIcons,C=m.inputValue,j=i.useIdAllocator({prefix:"combobox-option-text"}),O=i.useForwardedRef(n,null),S=o.useCallback((function(e){e.stopPropagation(),f||e.target!==O.current&&"INPUT"!==e.target.tagName||p()}),[f,O,p]),M=o.useMemo((function(){if(t){if(l.isComponentGlyph(t)||u.isComponentType(t,"Icon"))return t;console.error("`ComboboxOption` instance did not render icon because it is not a known glyph element.",t)}}),[t]),z=o.useMemo((function(){if(h){var e=b.jsx(w.default,{label:"","aria-labelledby":j,checked:a,tabIndex:-1,animate:!1,disabled:f});return b.jsx(x.default.Fragment,null,b.jsx("span",{className:c.cx(Ee,De)},k?M:e,b.jsx("span",{id:j,className:Ie(a)},Ce(r,C,"strong"))),k&&e)}return b.jsx(x.default.Fragment,null,b.jsx("span",{className:c.cx(Ee,De)},M,b.jsx("span",{className:Ie(a)},Ce(r,C,"strong"))),a&&b.jsx(v.default,{glyph:"Checkmark",color:y?s.uiColors.blue.light1:s.uiColors.blue.base}))}),[h,M,a,r,C,y,j,f,k]);return b.jsx("li",{ref:O,role:"option","aria-selected":d,"aria-label":r,tabIndex:-1,className:c.cx(Me,N({},ze,f),g),onClick:S,onKeyDown:S},z)}));function Te(e){throw Error("`ComboboxOption` must be a child of a `Combobox` instance")}Ae.displayName="ComboboxOption",Te.displayName="ComboboxOption";var Pe,Fe,Le,Re,qe,Ge,Ue,We,He,Ke=(N(Z={},U,p.typeScales.body1.fontSize),N(Z,W,p.typeScales.body2.fontSize),Z),Ve=u.createUniqueClassName("combobox-chip"),Be=c.css(_||(_=z(["\n font-family: ",";\n font-size: var(--lg-combobox-font-size);\n line-height: var(--lg-combobox-line-height);\n"])),p.fontFamilies.legacy),Xe=function(e){var o=e.darkMode,n=e.size,r=e.overflow;return c.cx(function(e){return e?c.css(Y||(Y=z([""]))):c.css($||($=z(["\n --lg-combobox-color-error: ",";\n --lg-combobox-text-color: ",";\n --lg-combobox-text-color-disabled: ",";\n\n --lg-combobox-background-color: ",";\n --lg-combobox-background-color-focus: ",";\n --lg-combobox-background-color-disabled: ",";\n\n --lg-combobox-border-color: ",";\n --lg-combobox-border-color-disabled: ",";\n --lg-combobox-border-color-error: ",";\n\n --lg-combobox-shadow: 0px 1px 2px rgba(6, 22, 33, 0.3);\n --lg-combobox-shadow-focus: 0px 4px 4px rgba(6, 22, 33, 0.3);\n "])),s.uiColors.red.base,s.uiColors.gray.dark3,s.uiColors.gray.dark1,s.uiColors.gray.light3,s.uiColors.white,s.uiColors.gray.light2,s.uiColors.gray.base,s.uiColors.gray.light1,s.uiColors.red.base)}(o),function(e){switch(e){case U:return c.css(J||(J=z(["\n --lg-combobox-padding-y: 5px;\n --lg-combobox-padding-x: 7px;\n --lg-combobox-height: calc(\n 36px - 2px - 2 * var(--lg-combobox-padding-y)\n );\n --lg-combobox-font-size: ","px; // TODO: update this for redesign\n --lg-combobox-line-height: ","px;\n "])),p.typeScales.body1.fontSize+1,p.typeScales.body1.lineHeight+1);case W:return c.css(Q||(Q=z(["\n --lg-combobox-padding-y: 9px;\n --lg-combobox-padding-x: 11px;\n --lg-combobox-height: calc(\n 48px - 2px - 2 * var(--lg-combobox-padding-y)\n );\n --lg-combobox-font-size: ","px;\n --lg-combobox-line-height: ","px;\n "])),p.typeScales.body2.fontSize,p.typeScales.body2.lineHeight)}}(n),c.css(ee||(ee=z(["\n --lg-combobox-icon-height: 16px;\n --lg-combobox-border-radius: 3px;\n --lg-combobox-width: ",";\n --lg-combobox-padding: var(--lg-combobox-padding-y)\n var(--lg-combobox-padding-x) var(--lg-combobox-padding-y)\n ",";\n width: var(--lg-combobox-width);\n // TODO: Clean this up 🤮\n min-width: calc(\n ","px + var(--lg-combobox-padding-x) * 2 + 2px +\n var(--lg-combobox-icon-height)\n );\n "])),"expand-x"===r?"unset":"100%","scroll-x"===r?"0":"var(--lg-combobox-padding-x)",Ke[n]))},Ze=c.css(oe||(oe=z(["\n display: flex;\n flex-wrap: nowrap;\n align-items: center;\n padding: var(--lg-combobox-padding);\n color: var(--lg-combobox-text-color);\n background-color: var(--lg-combobox-background-color);\n box-shadow: var(--lg-combobox-shadow);\n border: 1px solid var(--lg-combobox-border-color);\n border-radius: var(--lg-combobox-border-radius);\n width: var(--lg-combobox-width);\n cursor: text;\n transition: 150ms ease-in-out;\n transition-property: background-color, box-shadow, border-color;\n\n &[data-disabled='true'] {\n color: var(--lg-combobox-text-color-disabled);\n background-color: var(--lg-combobox-background-color-disabled);\n border-color: var(--lg-combobox-border-color-disabled);\n box-shadow: unset;\n cursor: not-allowed;\n }\n\n &[data-state='error'] {\n border-color: var(--lg-combobox-border-color-error);\n }\n"]))),_e=c.css(ne||(ne=z(["\n &:focus-within {\n border-color: transparent;\n background-color: var(--lg-combobox-background-color-focus);\n // TODO: Remove for UI refresh & Darkmode\n box-shadow: 0 0 0 3px ",", var(--lg-combobox-shadow-focus);\n }\n"])),s.uiColors.focus),Ye=function(e){var o,r=e.overflow,t=e.isOpen,i=e.selection,l=e.size,a=e.value,s=n.isArray(i)&&i.length>0,u=null!==(o=null==a?void 0:a.length)&&void 0!==o?o:0,d=c.css(re||(re=z(["\n flex-grow: 1;\n width: var(--lg-combobox-width);\n\n --lg-combobox-input-width: ",";\n --lg-combobox-input-min-width: ","px;\n "])),s?"".concat(u*Ke[l],"px"):"100%",Ke[l]);switch(r){case"scroll-x":return c.css(te||(te=z(["\n ","\n display: block;\n height: var(--lg-combobox-height);\n white-space: nowrap;\n overflow-x: scroll;\n padding-left: var(--lg-combobox-padding-x);\n scroll-behavior: smooth;\n scrollbar-width: none;\n /*\n * Immediate transition in, slow transition out. \n * '-in' transition is handled by `scroll-behavior` \n */\n --lg-combobox-input-transition: width ease-in-out\n ",";\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n & > ."," {\n margin-inline: 2px;\n\n &:first-child {\n margin-inline-start: 0;\n }\n\n &:last-child {\n margin-inline-end: 0;\n }\n }\n "],["\n ","\n display: block;\n height: var(--lg-combobox-height);\n white-space: nowrap;\n overflow-x: scroll;\n padding-left: var(--lg-combobox-padding-x);\n scroll-behavior: smooth;\n scrollbar-width: none;\n /*\n * Immediate transition in, slow transition out. \n * '-in' transition is handled by \\`scroll-behavior\\` \n */\n --lg-combobox-input-transition: width ease-in-out\n ",";\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n & > ."," {\n margin-inline: 2px;\n\n &:first-child {\n margin-inline-start: 0;\n }\n\n &:last-child {\n margin-inline-end: 0;\n }\n }\n "])),d,t?"0":"100ms",Ve);case"expand-x":return c.css(ie||(ie=z(["\n ","\n display: flex;\n gap: 4px;\n flex-wrap: nowrap;\n white-space: nowrap;\n height: var(--lg-combobox-height);\n --lg-combobox-input-transition: none;\n "])),d);case"expand-y":return c.css(le||(le=z(["\n ","\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n overflow-x: visible;\n min-height: var(--lg-combobox-height);\n "])),d)}},$e=c.css(ae||(ae=z(["\n border: none;\n cursor: inherit;\n background-color: inherit;\n box-sizing: content-box;\n padding: 0;\n margin: 0;\n text-overflow: ellipsis;\n font-size: var(--lg-combobox-font-size);\n line-height: var(--lg-combobox-line-height);\n height: var(--lg-combobox-height);\n width: var(--lg-combobox-input-width, 0);\n min-width: var(--lg-combobox-input-min-width);\n transition: var(--lg-combobox-input-transition);\n\n &:focus {\n outline: none;\n }\n"]))),Je=c.css(ce||(ce=z(["\n // Add a negative margin so the button takes up the same space as the regular icons\n margin-block: calc(var(--lg-combobox-icon-height) / 2 - 100%);\n"]))),Qe=c.css(se||(se=z(["\n &:focus {\n box-shadow: unset;\n &::before {\n background-color: ",";\n }\n }\n"])),s.uiColors.blue.light2),eo=c.css(ue||(ue=z(["\n font-size: var(--lg-combobox-font-size);\n line-height: var(--lg-combobox-line-height);\n color: var(--lg-combobox-color-error);\n padding-top: var(--lg-combobox-padding-y);\n"]))),oo=c.css(de||(de=z(["\n margin-inline-end: calc(var(--lg-combobox-padding-x) / 2);\n"]))),no=c.keyframes(be||(be=z(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"]))),ro=c.css(fe||(fe=z(["\n animation: "," 1.5s linear infinite;\n"])),no),to=function(e){var o,n,r=e.darkMode,t=e.size,i=e.width,l=void 0===i?384:i;switch(o=r?c.css(pe||(pe=z([""]))):c.css(ge||(ge=z(["\n --lg-combobox-menu-color: ",";\n --lg-combobox-menu-message-color: ",";\n --lg-combobox-menu-background-color: ",";\n --lg-combobox-menu-shadow: 0px 3px 7px rgba(0, 0, 0, 0.25);\n --lg-combobox-item-hover-color: ",";\n --lg-combobox-item-active-color: ",";\n --lg-combobox-item-wedge-color: ",";\n "])),s.uiColors.gray.dark3,s.uiColors.gray.dark1,s.uiColors.white,s.uiColors.gray.light2,s.uiColors.blue.light3,s.uiColors.blue.base),t){case U:n=c.css(me||(me=z(["\n --lg-combobox-menu-border-radius: 4px;\n --lg-combobox-item-height: 36px;\n --lg-combobox-item-padding-y: 8px;\n --lg-combobox-item-padding-x: 12px;\n --lg-combobox-item-font-size: ","px; // TODO: update this\n --lg-combobox-item-line-height: ","px; // TODO: update this\n --lg-combobox-item-wedge-height: 22px;\n "])),p.typeScales.body1.fontSize+1,p.typeScales.body1.lineHeight+1);break;case W:n=c.css(xe||(xe=z(["\n --lg-combobox-menu-border-radius: 4px;\n --lg-combobox-item-height: 36px;\n --lg-combobox-item-padding-y: 8px;\n --lg-combobox-item-padding-x: 12px;\n --lg-combobox-item-font-size: ","px; // TODO: update this\n --lg-combobox-item-line-height: ","px; // TODO: update this\n --lg-combobox-item-wedge-height: 22px;\n "])),p.typeScales.body2.fontSize+1,p.typeScales.body2.lineHeight+1)}return c.cx(o,n,c.css(he||(he=z(["\n width: ","px;\n border-radius: var(--lg-combobox-menu-border-radius);\n\n & > * {\n border-radius: inherit;\n }\n "])),l))},io=c.css(ve||(ve=z(["\n position: relative;\n width: 100%;\n margin: 0;\n padding: 0;\n font-family: ",";\n color: var(--lg-combobox-menu-color);\n background-color: var(--lg-combobox-menu-background-color);\n box-shadow: var(--lg-combobox-menu-shadow);\n border-radius: inherit;\n overflow: auto;\n min-height: var(--lg-combobox-item-height);\n scroll-behavior: smooth;\n"])),p.fontFamilies.default),lo=c.css(ye||(ye=z(["\n position: relative;\n margin: 0;\n padding: 0;\n"]))),ao=c.css(we||(we=z(["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-size: var(--lg-combobox-item-font-size);\n color: var(--lg-combobox-menu-message-color);\n padding: var(--lg-combobox-item-padding-y) var(--lg-combobox-item-padding-x);\n\n & > svg {\n width: 1em;\n height: 1em;\n }\n"]))),co=function(e){var o,n,r=e.darkMode,t=e.size;switch(o=r?c.css(Pe||(Pe=z([""]))):c.css(Fe||(Fe=z(["\n --lg-combobox-chip-text-color: ",";\n --lg-combobox-chip-icon-color: ",";\n --lg-combobox-chip-background-color: ",";\n --lg-combobox-chip-hover-color: ",";\n --lg-combobox-chip-focus-color: ",";\n "])),s.uiColors.gray.dark3,s.uiColors.gray.dark2,s.uiColors.gray.light2,s.uiColors.gray.light1,s.uiColors.blue.light2),t){case U:n=c.css(Le||(Le=z(["\n --lg-combobox-chip-height: 24px;\n --lg-combobox-chip-border-radius: 4px;\n --lg-combobox-chip-font-size: 14px;\n --lg-combobox-chip-line-height: 20px;\n --lg-combobox-chip-padding-x: 6px;\n "])));break;case W:n=c.css(Re||(Re=z(["\n --lg-combobox-chip-height: 28px;\n --lg-combobox-chip-border-radius: 4px;\n --lg-combobox-chip-font-size: ","px;\n --lg-combobox-chip-line-height: ","px;\n --lg-combobox-chip-padding-x: 6px;\n "])),p.typeScales.body2.fontSize,p.typeScales.body2.lineHeight)}return c.cx(o,n,c.css(qe||(qe=z(["\n display: inline-flex;\n align-items: center;\n overflow: hidden;\n white-space: nowrap;\n height: var(--lg-combobox-chip-height);\n font-size: var(--lg-combobox-chip-font-size);\n line-height: var(--lg-combobox-chip-line-height);\n border-radius: var(--lg-combobox-chip-border-radius);\n color: var(--lg-combobox-chip-text-color);\n background-color: var(--lg-combobox-chip-background-color);\n\n // TODO - refine these styles\n /* &:focus, */\n &:focus-within {\n background-color: var(--lg-combobox-chip-focus-color);\n }\n "]))))},so=c.css(Ge||(Ge=z(["\n padding-inline: var(--lg-combobox-chip-padding-x);\n"]))),uo=c.css(Ue||(Ue=z(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n outline: none;\n border: none;\n background-color: transparent;\n color: var(--lg-combobox-chip-icon-color);\n cursor: pointer;\n transition: background-color 100ms ease-in-out;\n\n &:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 1px;\n background-color: var(--lg-combobox-chip-hover-color);\n }\n\n &:hover {\n background-color: var(--lg-combobox-chip-hover-color);\n }\n"]))),bo=x.default.forwardRef((function(e,n){var r=e.displayName,t=e.isFocused,i=e.onRemove,l=e.onFocus,a=o.useContext(ke),s=a.darkMode,d=a.size,f=a.disabled,p=a.chipTruncationLocation,g=void 0===p?"end":p,m=a.chipCharacterLimit,x=void 0===m?12:m,h=!!x&&!!g&&"none"!==g&&r.length>x,y=o.useRef(null),w=o.useMemo((function(){if(h){var e=x-3;switch(g){case"start":return"…"+r.substring(r.length-e).trim();case"middle":return r.substring(0,e/2).trim()+"…"+r.substring(r.length-e/2).trim();case"end":return r.substring(0,e).trim()+"…";default:return r}}return!1}),[x,g,r,h]);o.useEffect((function(){var e;t&&!f&&(null==y||null===(e=y.current)||void 0===e||e.focus())}),[f,n,t]);return b.jsx("span",{role:"option","aria-selected":t,"data-testid":"lg-combobox-chip",ref:n,className:c.cx(Ve,co({darkMode:s,size:d})),onClick:function(e){var o;null!==(o=y.current)&&void 0!==o&&o.contains(e.target)||l()},onKeyDown:function(e){f||e.keyCode!==u.keyMap.Delete&&e.keyCode!==u.keyMap.Backspace&&e.keyCode!==u.keyMap.Enter&&e.keyCode!==u.keyMap.Space||i()},tabIndex:-1},b.jsx("span",{className:so},w?b.jsx(C.default,{definition:r,align:"bottom"},w):r),b.jsx("button",{"aria-label":"Deselect ".concat(r),"aria-disabled":f,disabled:f,ref:y,className:uo,onClick:function(){f||i()}},b.jsx(v.default,{glyph:"X"})))}));bo.displayName="Chip";var fo,po=function(e){return c.css(We||(We=z(["\n --lg-combobox-group-label-color: ",";\n --lg-combobox-group-border-color: ",";\n padding-top: 8px;\n border-bottom: 1px solid var(--lg-combobox-group-border-color);\n"])),e?s.uiColors.gray.light1:s.uiColors.gray.dark1,e?s.uiColors.gray.dark1:s.uiColors.gray.light1)},go=c.css(He||(He=z(["\n cursor: default;\n width: 100%;\n padding: 0 12px 2px;\n outline: none;\n overflow-wrap: anywhere;\n font-size: 12px;\n line-height: 16px;\n font-weight: bold;\n text-transform: uppercase;\n letter-spacing: 0.4px;\n color: var(--lg-combobox-group-label-color);\n"])));function mo(e){var n=e.label,r=e.className,t=e.children,l=o.useContext(ke).darkMode,a=i.useIdAllocator({prefix:"combobox-group"});return x.default.Children.count(t)>0?b.jsx("div",{className:c.cx(po(l),r)},b.jsx("div",{className:go,id:a},n),b.jsx("div",{role:"group","aria-labelledby":a},t)):b.jsx(x.default.Fragment,null)}function xo(e){throw Error("`ComboboxGroup` must be a child of a `Combobox` instance")}xo.displayName="ComboboxGroup";var ho=["children","label","description","placeholder","aria-label","disabled","size","darkMode","state","errorMessage","searchState","searchEmptyMessage","searchErrorMessage","searchLoadingMessage","filteredOptions","onFilter","clearable","onClear","overflow","multiselect","initialValue","onChange","value","chipTruncationLocation","chipCharacterLimit","className","usePortal","portalClassName","portalContainer","scrollContainer","popoverZIndex"];e.Combobox=function(e){var t=e.children,l=e.label,a=e.description,d=e.placeholder,f=void 0===d?"Select":d,p=e["aria-label"],g=e.disabled,m=void 0!==g&&g,w=e.size,k=void 0===w?U:w,C=e.darkMode,D=void 0!==C&&C,I=e.state,A=void 0===I?"none":I,W=e.errorMessage,H=e.searchState,K=void 0===H?"unset":H,V=e.searchEmptyMessage,B=void 0===V?"No results found":V,X=e.searchErrorMessage,Z=void 0===X?"Could not get results!":X,_=e.searchLoadingMessage,Y=void 0===_?"Loading results...":_,$=e.filteredOptions,J=e.onFilter,Q=e.clearable,ee=void 0===Q||Q,oe=e.onClear,ne=e.overflow,re=void 0===ne?"expand-y":ne,te=e.multiselect,ie=void 0!==te&&te,le=e.initialValue,ae=e.onChange,ce=e.value,se=e.chipTruncationLocation,ue=e.chipCharacterLimit,de=void 0===ue?12:ue,be=e.className,fe=e.usePortal,pe=void 0===fe||fe,ge=e.portalClassName,me=e.portalContainer,xe=e.scrollContainer,he=e.popoverZIndex,ve=M(e,ho),ye=i.useDynamicRefs({prefix:"option"}),we=i.useDynamicRefs({prefix:"chip"}),Ce=i.useIdAllocator({prefix:"combobox-input"}),Me=i.useIdAllocator({prefix:"combobox-label"}),ze=i.useIdAllocator({prefix:"combobox-menu"}),Ee=o.useRef(null),De=o.useRef(null),Ie=o.useRef(null),Te=o.useRef(null),Pe=o.useRef(null),Fe=E(o.useState(!1),2),Le=Fe[0],Re=Fe[1],qe=i.usePrevious(Le),Ge=E(o.useState(null),2),Ue=Ge[0],We=Ge[1],He=E(o.useState(null),2),Ke=He[0],Ve=He[1],no=i.usePrevious(Ke),co=E(o.useState(""),2),so=co[0],uo=co[1],po=i.usePrevious(so),go=E(o.useState(null),2),xo=go[0],vo=go[1],yo=!n.isNull(Ke)&&(n.isArray(Ke)&&Ke.length>0||n.isString(Ke)),wo=ie&&n.isArray(Ke)&&Ke.length>0?void 0:f,ko=function(){return Re(!1)},Co=function(){return Re(!0)},jo=o.useMemo((function(){return Se(t)}),[t]),Oo=o.useCallback((function(e){return!ie||"string"!=typeof e&&"number"!=typeof e?!ie&&n.isArray(e)&&u.consoleOnce.error("Error in Combobox: multiselect is set to `false`, but recieved an Array value"):u.consoleOnce.error("Error in Combobox: multiselect is set to `true`, but recieved a ".concat(O(e),' value: "').concat(e,'"')),ie&&n.isArray(e)}),[ie]),No=o.useCallback((function(e){!m&&Te&&Te.current&&(Te.current.focus(),n.isUndefined(e)||Te.current.setSelectionRange(e,e))}),[m]),So=o.useCallback((function(e){if(Oo(Ke)){var o=n.clone(Ke);n.isNull(e)?o.length=0:Ke.includes(e)?o.splice(o.indexOf(e),1):(o.push(e),uo("")),Ve(o),null==ae||ae(o)}else{var r=e;Ve(r),null==ae||ae(r)}}),[Oo,ae,Ke]),Mo=o.useCallback((function(e){return Oo(Ke)?Ke.includes(e):e===Ke}),[Oo,Ke]),zo=o.useCallback((function(e){var o,n,r,t,i=(n=jo,(o=e)?null!==(r=null===(t=n.find((function(e){return e.displayName===o})))||void 0===t?void 0:t.value)&&void 0!==r?r:o:"");return Mo(i)}),[jo,Mo]),Eo=o.useCallback((function(e){var o="string"==typeof e?e:e.value;return $&&$.length>0?$.includes(o):!!zo(so)||("string"==typeof e?Ne(o,jo):e.displayName).toLowerCase().includes(so.toLowerCase())}),[$,zo,so,jo]),Do=o.useMemo((function(){return jo.filter(Eo)}),[jo,Eo]),Io=o.useCallback((function(e){return!!e&&!!jo.find((function(o){return o.value===e}))}),[jo]),Ao=o.useCallback((function(e){return Do?Do.findIndex((function(o){return o.value===e})):-1}),[Do]),To=o.useCallback((function(e){if(Do&&Do.length>=e){var o=Do[e];return o?o.value:void 0}}),[Do]),Po=o.useCallback((function(){return Oo(Ke)?Ke.findIndex((function(e){var o,n;return null===(o=we(e))||void 0===o||null===(n=o.current)||void 0===n?void 0:n.contains(document.activeElement)})):-1}),[we,Oo,Ke]),Fo=E(o.useState(),2),Lo=Fo[0],Ro=Fo[1],qo=o.useCallback((function(e){var o,n=null!==(o=null==Do?void 0:Do.length)&&void 0!==o?o:0,r=n-1>0?n-1:0,t=Ao(Ue);switch(e&&Le&&(vo(null),No()),e){case"next":var i=To(t+1<n?t+1:0);We(null!=i?i:null);break;case"prev":var l=To(t-1>=0?t-1:r);We(null!=l?l:null);break;case"last":var a=To(r);We(null!=a?a:null);break;default:var c=To(0);We(null!=c?c:null)}}),[Ue,Ao,To,Le,No,null==Do?void 0:Do.length]),Go=o.useCallback((function(e,o){if(Oo(Ke))switch(e){case"next":var n=null!=o?o:Po(),r=n+1<Ke.length?n+1:Ke.length-1,t=Ke[r];vo(t);break;case"prev":var i=null!=o?o:Po(),l=i>0?i-1:i<0?Ke.length-1:0,a=Ke[l];vo(a);break;case"first":var c=Ke[0];vo(c);break;case"last":var s=Ke[Ke.length-1];vo(s);break;default:vo(null)}}),[Po,Oo,Ke]),Uo=o.useCallback((function(e,o){switch(e&&We(null),e){case"right":switch(Lo){case T:var n,r,t;if((null===(n=Te.current)||void 0===n?void 0:n.selectionEnd)===(null===(r=Te.current)||void 0===r?void 0:r.value.length))null===(t=De.current)||void 0===t||t.focus();break;case F:case R:case L:if(Lo===L||1===(null==Ke?void 0:Ke.length)){No(0),Go(null),o.preventDefault();break}Go("next")}break;case"left":switch(Lo){case P:var i;o.preventDefault(),No(null==Te||null===(i=Te.current)||void 0===i?void 0:i.value.length);break;case T:case R:case L:if(Oo(Ke)){var l;if(Lo===T&&0!==(null===(l=Te.current)||void 0===l?void 0:l.selectionStart))break;Go("prev")}}break;default:Go(null)}}),[Lo,Oo,Ke,No,Go]);o.useEffect((function(){so!==po&&qo("first")}),[so,Le,po,qo]),o.useEffect((function(){if(Ue){var e=ye(Ue);if(e&&e.current&&Pe.current){var o=e.current.offsetTop,n=Pe.current,r=n.scrollTop;(o>n.offsetHeight||o<r)&&(Pe.current.scrollTop=o)}}}),[Ue,ye]);var Wo=o.useCallback((function(e){return x.default.Children.map(e,(function(e){if(u.isComponentType(e,"ComboboxOption")){var o=je(e.props),n=o.value,r=o.displayName;if(Eo(n)){var t=e.props,i=t.className,l=t.glyph,a=t.disabled,c=jo.findIndex((function(e){return e.value===n})),s=Ue===n,d=Oo(Ke)?Ke.includes(n):Ke===n,f=ye(n);return b.jsx(Ae,{value:n,displayName:r,isFocused:s,isSelected:d,disabled:a,setSelected:function(){We(n),So(n),No(),n===Ke&&ko()},glyph:l,className:i,index:c,ref:f})}}else if(u.isComponentType(e,"ComboboxGroup")){var p=Wo(e.props.children);if(p&&(null==p?void 0:p.length)>0)return b.jsx(mo,{label:e.props.label,className:e.props.className},Wo(p))}}))}),[jo,Ue,ye,Oo,Eo,Ke,No,So]),Ho=o.useMemo((function(){return Wo(t)}),[t,Wo]),Ko=o.useMemo((function(){if(Oo(Ke))return Ke.filter(Io).map((function(e,o){var n=Ne(e,jo),r=xo===e,t=we(e),i=o>=Ke.length-1;return b.jsx(bo,{key:e,displayName:n,isFocused:r,onRemove:function(){i?(No(),Go(null)):Go("next",o),So(e)},onFocus:function(){vo(e)},ref:t})}))}),[Oo,Ke,Io,jo,xo,we,So,No,Go]),Vo=o.useMemo((function(){return b.jsx(x.default.Fragment,null,ee&&yo&&b.jsx(y.default,{"aria-label":"Clear selection","aria-disabled":m,disabled:m,ref:De,onClick:function(e){m||(So(null),null==oe||oe(e),null==J||J(""),Le||Co())},onFocus:on,className:c.cx(Je,Qe)},b.jsx(v.default,{glyph:"XWithCircle"})),"error"===A?b.jsx(v.default,{glyph:"Warning",color:s.uiColors.red.base,className:oo}):b.jsx(v.default,{glyph:"CaretDown",className:oo}))}),[ee,yo,m,A,So,oe,J,Le]),Bo=o.useMemo((function(){return jo.some((function(e){return e.hasGlyph}))}),[jo]),Xo=o.useCallback((function(){if(!Oo(Ke)&&Ke===no){var e=Do.find((function(e){return e.displayName===so||e.value===so}));if(e&&!ce)Ve(e.value);else{var o,n=null!==(o=Ne(Ke,jo))&&void 0!==o?o:"";uo(n)}}}),[jo,so,Oo,no,Ke,ce,Do]),Zo=o.useCallback((function(){if(yo){if(Oo(Ke))tn();else if(!Oo(Ke)){var e,o=null!==(e=Ne(Ke,jo))&&void 0!==e?e:"";uo(o),ko()}}else uo("")}),[yo,jo,Oo,Ke]);o.useEffect((function(){if(le)if(n.isArray(le)){var e,o=null!==(e=le.filter((function(e){return Io(e)})))&&void 0!==e?e:[];Ve(o)}else Io(le)&&Ve(le);else Ve(function(e){return e?[]:null}(ie))}),[]),o.useEffect((function(){if(!n.isUndefined(ce)&&ce!==po)if(n.isNull(ce))Ve(null);else if(Oo(ce)){var e=ce.filter(Io);Ve(e)}else Ve(Io(ce)?ce:null)}),[Oo,Io,po,ce]),o.useEffect((function(){n.isEqual(Ke,no)||Zo()}),[Zo,no,Ke]),o.useEffect((function(){!Le&&qe&&Xo()}),[Le,qe,Xo]);var _o=E(o.useState(0),2),Yo=_o[0],$o=_o[1];o.useEffect((function(){var e,o;$o(null!==(e=null===(o=Ee.current)||void 0===o?void 0:o.clientWidth)&&void 0!==e?e:0)}),[Ee,Le,Ue,Ke]);var Jo=o.useMemo((function(){switch(K){case"loading":return b.jsx("span",{className:ao},b.jsx(v.default,{glyph:"Refresh",color:s.uiColors.blue.base,className:ro}),Y);case"error":return b.jsx("span",{className:ao},b.jsx(v.default,{glyph:"Warning",color:s.uiColors.red.base}),Z);default:return Ho&&Ho.length>0?b.jsx("ul",{className:lo},Ho):b.jsx("span",{className:ao},B)}}),[Ho,B,Z,Y,K]),Qo=i.useAvailableSpace(Ee),en=n.isUndefined(Qo)?"unset":"".concat(Math.min(Qo,256),"px"),on=function(){We(null)};i.useEventListener("mousedown",(function(e){rn(e)||(e.preventDefault(),e.stopPropagation())}),{enabled:Le}),i.useEventListener("click",(function(e){rn(e)||(e.stopPropagation(),ko())}),{options:{capture:!0},enabled:Le});var nn=function(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?j(Object(n),!0).forEach((function(o){N(e,o,n[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))}))}return e}({popoverZIndex:he},pe?{usePortal:pe,portalClassName:ge,portalContainer:me,scrollContainer:xe}:{usePortal:pe});return b.jsx(ke.Provider,{value:{multiselect:ie,darkMode:D,size:k,withIcons:Bo,disabled:m,chipTruncationLocation:se,chipCharacterLimit:de,inputValue:so}},b.jsx("div",S({className:c.cx(Xe({darkMode:D,size:k,overflow:re}),be)},ve),b.jsx("div",null,l&&b.jsx(r.Label,{id:Me,htmlFor:Ce,className:Be},l),a&&b.jsx(r.Description,{className:Be},a)),b.jsx("div",{ref:Ee,role:"combobox","aria-expanded":Le,"aria-controls":ze,"aria-owns":ze,tabIndex:-1,className:c.cx(Ze,N({},_e,Lo===T)),onMouseDown:function(e){m&&e.preventDefault()},onClick:function(e){if(e.target!==Te.current){var o=0;if(Te.current)o=e.nativeEvent.offsetX>Te.current.offsetLeft+Te.current.clientWidth?so.length:0;No(o)}},onFocus:function(e){tn(),Co(),Ro(function(e){var o,n,r,t;if(!e)return;if(null!==(o=Te.current)&&void 0!==o&&o.contains(e))return T;if(null!==(n=De.current)&&void 0!==n&&n.contains(e))return P;var i=Oo(Ke)?Ke.findIndex((function(o){var n,r;return null===(n=we(o))||void 0===n||null===(r=n.current)||void 0===r?void 0:r.contains(e)})):-1;if(Oo(Ke)){if(0===i)return F;if(i===Ke.length-1)return L;if(i>0)return R}if(null!==(r=Pe.current)&&void 0!==r&&r.contains(e))return G;if(null!==(t=Ee.current)&&void 0!==t&&t.contains(e))return q}(e.target))},onKeyDown:function(e){var o,r,t=null===(o=Pe.current)||void 0===o?void 0:o.contains(document.activeElement);if((null===(r=Ee.current)||void 0===r?void 0:r.contains(document.activeElement))||t){if(e.ctrlKey||e.shiftKey||e.altKey)return;switch(e.keyCode){case u.keyMap.Tab:switch(Lo){case"Input":yo||(ko(),qo("first"),Go(null));break;case"LastChip":Go(null)}break;case u.keyMap.Escape:ko(),qo("first");break;case u.keyMap.Enter:!Le||Lo!==T||n.isNull(Ue)||function(e){if("string"==typeof e){var o=Oe(e,jo);return!(null==o||!o.isDisabled)}return!!e.isDisabled}(Ue)?Lo===P&&(So(null),No()):So(Ue);break;case u.keyMap.Backspace:var i;if(Oo(Ke))"Input"===Lo&&0===(null===(i=Te.current)||void 0===i?void 0:i.selectionStart)&&Go("last");Co();break;case u.keyMap.ArrowDown:Le?(e.preventDefault(),qo("next")):Co();break;case u.keyMap.ArrowUp:Le?(e.preventDefault(),qo("prev")):Co();break;case u.keyMap.ArrowRight:Uo("right",e);break;case u.keyMap.ArrowLeft:Uo("left",e);break;default:Le||Co()}}},onTransitionEnd:function(){var e,o;$o(null!==(e=null===(o=Ee.current)||void 0===o?void 0:o.clientWidth)&&void 0!==e?e:0)},"data-disabled":m,"data-state":A},b.jsx("div",{ref:Ie,className:Ye({overflow:re,isOpen:Le,selection:Ke,size:k,value:so})},Ko,b.jsx("input",{"aria-label":null!=p?p:l,"aria-autocomplete":"list","aria-controls":ze,"aria-labelledby":Me,ref:Te,id:Ce,className:$e,placeholder:wo,disabled:null!=m?m:void 0,onChange:function(e){var o=e.target.value;uo(o),null==J||J(o)},value:so,autoComplete:"off"})),Vo),"error"===A&&W&&b.jsx("div",{className:eo},W),b.jsx(h.default,S({active:Le&&!m,spacing:4,align:"bottom",justify:"middle",refEl:Ee,adjustOnMutation:!0,className:to({darkMode:D,size:k,width:Yo})},nn),b.jsx("div",{id:ze,role:"listbox","aria-labelledby":Me,"aria-expanded":Le,ref:Pe,className:c.cx(io,c.css(fo||(fo=z(["\n max-height: ",";\n "])),en)),onMouseDownCapture:function(e){return e.preventDefault()}},Jo))));function rn(e){var o,n,r=e.target;return(null===(o=Pe.current)||void 0===o?void 0:o.contains(r))||(null===(n=Ee.current)||void 0===n?void 0:n.contains(r))||!1}function tn(){Ie&&Ie.current&&(Ie.current.scrollLeft=Ie.current.scrollWidth)}},e.ComboboxGroup=xo,e.ComboboxOption=Te,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=index.js.map