forked from sindresorhus/awesome
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
550-b795f20a5042831b.js.download
1 lines (1 loc) · 9.71 KB
/
550-b795f20a5042831b.js.download
1
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[550],{90550:function(e,t,n){n.d(t,{Z:function(){return Z}});var r=n(95235),o=n(82269),l=n(35196),i=n(2784),s=n(42126),c=n(23273),a=n(87593),u=n(52903),p={name:"1qpenwb-ClearSelectionButton--rootStyle",styles:"align-items:center;background:transparent;cursor:pointer;display:flex;height:100%;justify-content:center;width:100%;label:ClearSelectionButton--rootStyle;"},MultiselectDropdown_ClearSelectionButton=function(e){var t=e.clearSelection,n=e.isFocused,r=e.isHovered,o=n||r?"blueJeans":"neutral600";return(0,u.tZ)(a.p,{content:"Clear selection",children:function(e){var n=e.childProps;return(0,u.tZ)("button",{"aria-describedby":n.ariaDescribedBy,css:p,onClick:function(e){return e.stopPropagation(),t(),!1},title:"Clear selection",children:(0,u.tZ)(c.J,{canAcceptPointerEvents:!1,color:o,name:"x",size:20})})}})},d=n(28165),b=n(5045),g=(0,d.iv)(b.ZT.paragraph3Medium," align-items:center;background:",b.wL.neutral800,";border-radius:30px;color:",b.wL.neutral100,";cursor:pointer;display:inline-flex;height:30px;justify-content:center;line-height:20px;padding:0 5px 0 10px;position:relative;transition:",b.fw.transitionValue,";z-index:1;&:hover,&:focus{background:",b.wL.blueJeans,";}&:hover::before,&:focus::before{opacity:1;};label:Badge--root;"),Badge=function(e){return(0,u.tZ)("button",{"aria-current":e.ariaCurrent,css:g,onClick:e.onClick,children:e.children})};function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){(0,r.Z)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var m={name:"5mwy3h-DismissableItem--rootStyle",styles:"align-items:center;display:grid;grid-auto-flow:column;grid-gap:25px;white-space:nowrap;label:DismissableItem--rootStyle;"},MultiselectDropdown_DismissableItem=function(e){return(0,u.tZ)(Badge,{onClick:function(t){return t.stopPropagation(),e.onClick(),!1},children:(0,u.BX)("span",_objectSpread(_objectSpread({css:m},e.getSelectedItemProps()),{},{children:[(0,u.tZ)("span",{children:e.children}),(0,u.tZ)(c.J,{name:"formX",size:24})]}))})},y=n(3e3),f=n(99029),h=n(15504),w=n(53939);function MultiselectMenu_ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function MultiselectMenu_objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?MultiselectMenu_ownKeys(Object(n),!0).forEach(function(t){(0,r.Z)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MultiselectMenu_ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var listStyle=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;return(0,d.iv)("max-height:",(e+.5)*44-10,"px;min-width:240px;overflow:auto;padding:10px;;label:MultiselectMenu--listStyle;")},M=(0,d.iv)(y.ZT.paragraph3," align-items:center;border-radius:5px;color:",f.w.neutral700,";cursor:pointer;display:flex;height:",44,"px;padding:0 10px;;label:MultiselectMenu--menuItem;"),I=(0,d.iv)("color:",f.w.neutral600,";;label:MultiselectMenu--menuItemDisabled;"),v=(0,d.iv)("background-color:",f.w.acidWash,";color:",f.w.blueJeans,";;label:MultiselectMenu--menuItemHighlighted;"),j=(0,d.iv)("color:",f.w.blueJeans,";;label:MultiselectMenu--menuItemSelected;"),O={name:"1guvufo-MultiselectMenu--menuItemIcon",styles:"align-items:center;display:flex;justify-content:center;margin-right:10px;label:MultiselectMenu--menuItemIcon;"},S={name:"yffwap-MultiselectMenu--menuItemText",styles:"flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;label:MultiselectMenu--menuItemText;"},MultiselectDropdown_MultiselectMenu=function(e){var t=e.align,n=e.ariaLabel,r=e.getItemProps,o=e.getKeyForItem,l=e.getLabelForItem,i=e.getMenuProps,s=e.highlightedIndex,a=e.items,p=e.renderIcon,b=e.selectedItems,g=e.isOpen,m=e.visibleItems,y=i({"aria-label":n}),f=g&&a.length>0,D=f?h.f:EmptyList,P=(0,u.tZ)("ul",MultiselectMenu_objectSpread(MultiselectMenu_objectSpread({"aria-hidden":!g,css:listStyle(m)},y),{},{children:(f?a:[]).map(function(e,t){var n=b.includes(e);return(0,d.az)("li",MultiselectMenu_objectSpread(MultiselectMenu_objectSpread({},r({disabled:!!e.disabled,item:e,index:t})),{},{css:[M,e.disabled&&I,n&&j,s===t&&v,";label:MultiselectMenu--list;"],key:o?o(e,t):t}),(0,u.tZ)(c.J,{color:n?"blueJeans":"neutral600",name:n?"formCheckSquare":"formBlank",size:24}),(0,u.tZ)(w.L,{width:10}),p&&(0,u.tZ)("span",{css:O,children:p(e)}),(0,u.tZ)("span",{css:S,children:l(e)}))})}));return(0,u.tZ)(D,{align:void 0===t?"left":t,children:P})},D={name:"1gynx5n-MultiselectMenu--EmptyList",styles:"position:absolute;label:MultiselectMenu--EmptyList;"},EmptyList=function(e){var t=e.children;return(0,u.tZ)("div",{css:D,children:t})},P=["onChange"],x=["ref"];function MultiselectDropdown_ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function MultiselectDropdown_objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?MultiselectDropdown_ownKeys(Object(n),!0).forEach(function(t){(0,r.Z)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MultiselectDropdown_ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var C={name:"83ahzm-MultiselectDropdown--rootStyle",styles:"position:relative;& div:first-of-type div:first-of-type div:first-of-type{height:100%!important;};label:MultiselectDropdown--rootStyle;"},_={name:"qsy8ts-MultiselectDropdown--buttonTextStyle",styles:"align-items:center;display:flex;flex-wrap:wrap;gap:5px;padding:5px 0;label:MultiselectDropdown--buttonTextStyle;"};function MultiselectDropdown(e){var t,n,r,a,p=e.onChange,d=(0,o.Z)(e,P).items,b=(0,i.useState)(""),g=b[0],m=b[1],y=(0,l.M$)({selectedItems:e.selectedItems,itemToString:function(t){return t?e.getLabelForItem(t):""},onStateChange:function(e){var t=e.type,n=e.selectedItems;switch(t){case l.M$.stateChangeTypes.FunctionAddSelectedItem:case l.M$.stateChangeTypes.FunctionSetSelectedItems:case l.M$.stateChangeTypes.FunctionRemoveSelectedItem:p(n||[]);break;case l.M$.stateChangeTypes.FunctionReset:p([])}}}),f=y.addSelectedItem,h=y.getDropdownProps,w=y.getSelectedItemProps,M=y.removeSelectedItem,I=y.reset,v=y.selectedItems,j=g.length>0?d.filter(function(t){return 0>v.indexOf(t)&&e.getLabelForItem(t).toLowerCase().includes(g.toLowerCase())}):d,O=(0,l.Kb)({inputId:e.inputId,items:j,stateReducer:function(e,t){var n=t.type,r=t.changes;switch(n){case l.Kb.stateChangeTypes.ItemClick:return MultiselectDropdown_objectSpread(MultiselectDropdown_objectSpread({},r),{},{isOpen:!0});case l.Kb.stateChangeTypes.InputKeyDownEnter:return MultiselectDropdown_objectSpread(MultiselectDropdown_objectSpread({},r),{},{inputValue:"",isOpen:!0});default:return r}},onStateChange:function(e){var t=e.inputValue,n=e.type,r=e.selectedItem;switch(n){case l.Kb.stateChangeTypes.InputChange:m(t||"");break;case l.Kb.stateChangeTypes.InputKeyDownEnter:case l.Kb.stateChangeTypes.ItemClick:case l.Kb.stateChangeTypes.InputBlur:r&&v.includes(r)?(M(r),B(null)):r&&(f(r),B(null),m(""))}},toggleButtonId:e.inputId}),S=O.getComboboxProps,D=O.getInputProps,Z=O.getItemProps,k=O.getMenuProps,K=O.highlightedIndex,L=O.isOpen,F=O.openMenu,B=O.selectItem,E=v.length>0,T=e.isDisabled||0===e.items.length,A=E&&!T,J=D(MultiselectDropdown_objectSpread(MultiselectDropdown_objectSpread({},h({preventKeyAction:L})),{},{"aria-describedby":e.ariaDescribedBy})),z=(J.ref,(0,o.Z)(J,x));return(0,u.BX)("div",MultiselectDropdown_objectSpread(MultiselectDropdown_objectSpread({css:C},S()),{},{children:[(0,u.tZ)(s.o,MultiselectDropdown_objectSpread(MultiselectDropdown_objectSpread({},z),{},{ariaLabel:(n=(t={label:e.ariaLabel||"",placeholder:e.placeholder,value:v.map(e.getLabelForItem).join(", ")}).label,r=t.value,a=t.placeholder,[r,n,!r&&a].filter(Boolean).join(", ")),autoComplete:"off",canClickIconAfter:A,disabled:T,isErrored:e.isErrored,placeholder:v.length<=0&&e.placeholder,onKeyDown:function(e){"Backspace"===e.key&&""===g&&v.length>0&&p(v.slice(0,v.length-1)),z.onKeyDown(e)},onFocus:F,renderIconAfter:function(e){var t=e.isFocused,n=e.isHovered;return A?(0,u.tZ)(MultiselectDropdown_ClearSelectionButton,{clearSelection:I,isFocused:t,isHovered:n}):(0,u.tZ)(c.J,{name:"upAndDownArrows",size:24})},renderIconBefore:function(){return(0,u.tZ)("div",{css:_,children:v.map(function(t,n){return(0,u.tZ)(MultiselectDropdown_DismissableItem,{onClick:function(){return M(t)},getSelectedItemProps:function(){return w({index:n,selectedItem:t})},children:e.getLabelForItem(t)},e.getKeyForItem(t,n))})})}})),(0,u.tZ)(MultiselectDropdown_MultiselectMenu,{align:e.menuAlign,ariaLabel:e.menuAriaLabel,getItemProps:Z,getKeyForItem:e.getKeyForItem,getLabelForItem:e.getLabelForItem,getMenuProps:k,highlightedIndex:K,isOpen:L,items:j,renderIcon:e.renderIcon,selectedItems:v,visibleItems:e.visibleItems})]}))}MultiselectDropdown.defaultProps={getKeyForItem:function(e){return null==e?void 0:e.id},getLabelForItem:function(e){return null==e?void 0:e.label},isDisabled:!1,selectedItems:[]};var Z=MultiselectDropdown}}]);