@bikdotai/bik-component-library 0.0.763-beta.50 → 0.0.763-beta.56
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("react"),o=require("../../constants/Theme.js"),l=require("../../assets/icons/chevronDown.svg.js"),r=require("../input/Input.js"),i=require("../input/context/InputStyleProvider.js"),s=require("./ChipInput.js"),a=require("./DropdownPopover/index.js"),d=require("./OpenedDropdown/utils/iterationOnOptions.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("react"),o=require("../../constants/Theme.js"),l=require("../../assets/icons/chevronDown.svg.js"),r=require("../input/Input.js"),i=require("../input/context/InputStyleProvider.js"),s=require("./ChipInput.js"),a=require("./DropdownPopover/index.js"),d=require("./OpenedDropdown/utils/iterationOnOptions.js");function c(){}const u=u=>{var p,h,v,x,f,{placeHolder:g,size:j,onSelect:b,defaultOptions:m,disabled:w,noErrorHint:O,placeHolderHeight:S,showPlaceholderWhenSelected:y=!1,inputStyle:I={},inputType:E="default",onDeleteChip:H,truncatedText:C,showLeadingIconInPlaceholder:D=!1,showTrailingIconPlaceholder:P=!1,showLabelsOnMoreHover:T=!1,value:q}=u,M=e.__rest(u,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value"]);const[W,L]=t.useState(!1),[_,z]=t.useState(!1),k=null!=j?j:"default",A=t.useRef(),[F,R]=t.useState(null!=m?m:[]),N=t.useRef(null),[U,V]=t.useState(null);t.useEffect((()=>{var e;const n=[];null===(e=null==M?void 0:M.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&n.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&n.push(e)})),R([...n])}),[M.options]),t.useEffect((()=>{m&&R([...m])}),[m]);const $=d.getSelectedOptionsAsText(F),B=y?g:null!==(p=null!=$?$:g)&&void 0!==p?p:"Select an option";t.useEffect((()=>{if(N.current){const e=N.current.scrollWidth;V(e+("x-small"===k?16:"small"===k?20:24)+2*("x-small"===k?16:12)+8+2)}}),[B,k]);const G=null!==(v=null!==(h=M.buttonWidth)&&void 0!==h?h:M.inputWidth)&&void 0!==v?v:"100%",J=U?`${U}px`:G;return n.jsxs(n.Fragment,{children:[n.jsx("span",Object.assign({ref:N,style:{position:"absolute",visibility:"hidden",whiteSpace:"nowrap",fontSize:"x-small"===k?"12px":"small"===k?"14px":"16px",fontFamily:"Inter"}},{children:B})),n.jsx(i.InputStyleContext.Provider,Object.assign({value:{InputWrapper:Object.assign({height:S||("x-small"===k?24:"small"===k?32:48),width:J,maxWidth:G,zIndex:1,cursor:"pointer",padding:"x-small"===k?"4px 8px":"6px 8px",backgroundColor:void 0!==q?"#C3E4C4":_?"#E0E0E0":"#ffffff",transition:"background-color 0.3s ease"},I),input:{minHeight:"100%",maxWidth:"100%",color:void 0!==q?"#00580E":"inherit"}}},{children:n.jsx("div",Object.assign({onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1)},{children:n.jsxs(a.DropdownPopover,Object.assign({"data-test":M["data-test"],ref:A,onSelect:function(e){Array.isArray(e)?R([...e]):R([e]),null==b||b(e)},disabled:w,onDropdownVisbilityChange:e=>L(e)},M,{children:["default"==E&&n.jsx(r.Input,{version:M.version,noErrorHint:O,state:w?"disabled":"none",value:void 0===q?B:q,errorMessage:M.error,variant:k,placeholder:null!=g?g:"Select an option",onChangeText:c,leftIcon:D&&(null===(x=F[0])||void 0===x?void 0:x.leadingIcon)?{icon:()=>{var e;return n.jsx(n.Fragment,{children:null===(e=F[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return n.jsxs("div",Object.assign({style:{display:"flex"}},{children:[P&&(null===(e=F[0])||void 0===e?void 0:e.trailingIcon),n.jsx(l.default,{style:{transform:W?"rotate(180deg)":"rotate(0deg)"},onClick:c,width:"x-small"===k?16:"small"===k?20:24,height:"x-small"===k?16:"small"===k?20:24,color:o.COLORS.content.primary})]}))}},truncateText:null==C||C}),"chip"==E&&n.jsx(s.default,{placeholder:null!=g?g:"Select options",chips:F,onDeleteChip:e=>{null==H||H(e)},errorMessage:M.error,isDropdownOpened:W,sizeToUse:k,containerStyle:{width:null!==(f=M.width)&&void 0!==f?f:"100%",cursor:"pointer"},showLabelsOnMoreHover:T})]}))}))}))]})};u.displayName="Dropdown",exports.Dropdown=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../OpenedDropdown/utils/iterationOnOptions.js");exports.useDropdown=function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",n=arguments.length>1?arguments[1]:void 0,l=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../OpenedDropdown/utils/iterationOnOptions.js");exports.useDropdown=function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",n=arguments.length>1?arguments[1]:void 0,l=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0,o=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,r=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[],u=arguments.length>8?arguments[8]:void 0;const[d,p]=e.useState(null!=n?n:[]),[v,O]=e.useState([]),[f,b]=e.useState(""),g=e.useRef(d);e.useEffect((()=>{if(g.current=d,v.length&&f&&o){let e=[...v];const t=d.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected})));const t=e;return{value:t.value,selected:t.selected}})).flat();e=e.map((e=>{const s=t.find((t=>e.value===t.value));return s?Object.assign(Object.assign({},e),{selected:s.selected}):e})),a&&(e=e.map((e=>Object.assign(Object.assign({},e),{disabled:!r.includes(e.value)})))),O(c&&!i?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[d]),e.useEffect((()=>{if(n){const e=[...n];p(c&&!i?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[n]);const j=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t},h=e=>{let t=0;return e.forEach((e=>{e.options?t+=e.options.filter((e=>!0===e.selected)).length:e.selected&&t++})),t},m=e=>!(!c||!u&&0!==u)&&h(e)>=u;function S(e,n){if(c){if(e.selected&&u&&m(d))return;if(v.length&&f&&o)if(e.selected){if(u&&m(d))return;let l=!1;const i=t.iterateOnOptions(d,{selected:e.selected},(t=>t.value===e.value&&(l=!0,!0)));if(l||i.push(e),n)return[...i];p([...i]),"2.0"===s&&w(i)}else{let l=!1,i=t.iterateOnOptions(d,{selected:e.selected},(t=>t.value===e.value&&(l=!0,!0)));if(l&&(i=i.filter((t=>t.value!==e.value))),n)return[...i];p([...i]),"2.0"===s&&w(i)}else{const l=t.iterateOnOptions(d,{selected:e.selected},(t=>t.value===e.value));if(n)return[...l];p([...l]),"2.0"===s&&w(l)}}else null==l||l(e)}function w(e){const t=j(null!=e?e:g.current);null==l||l([...t])}return{latestDropdownOptionsRef:g,dropdownOptions:d,search:function(e){if(b(e),O([]),e&&o){const s=[];t.iterateOnOptionsRaw(d,(e=>{e.selected&&!s.includes(e.value)&&s.push(e.value)})),o(e).then((e=>{if(e){const t=e.map((e=>{if(e.options){const t=e;return Object.assign(Object.assign({},t),{options:t.options.map((e=>Object.assign(Object.assign({},e),{selected:s.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:s.includes(e.value)})}));O([...t])}}))}},searchedString:f,searchedOptions:v,onApplyHandler:S,selectAllHandler:function(e){if(v.length&&f&&o)"selectAll"===e?function(e){let t=[...d];if(e&&u&&u>0){const e=h(t),n=u-e;if(n<=0)return;let l=0;v.forEach((e=>{if(l>=n)return;let s=!1;t=t.map((t=>{const n=e;return t.selected||t.disabled?t:void 0!==n.value&&n.value===t.value?(s=!0,l++,Object.assign(Object.assign({},t),{selected:!0})):t})),!s&&l<n&&(e.disabled||(t.push(Object.assign(Object.assign({},e),{selected:!0})),l++))})),p([...t]),"2.0"===s&&w(t)}}(!0):function(e){let t=[...d];e?v.forEach((e=>{let s=!1;t=t.map((t=>{const n=e;return void 0!==n.value&&n.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):v.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),p([...t]),"2.0"===s&&w(t)}(!1);else if("selectAll"===e)if(u&&u>0){const e=h(d),t=u-e;if(t<=0)return;let n=0;const l=d.map((e=>{var s;if(e.options){const s=e;return Object.assign(Object.assign({},s),{options:s.options.map((e=>{var s;return e.disabled||e.selected||f&&!(null===(s=e.label)||void 0===s?void 0:s.toLowerCase().includes(f.toLowerCase()))?e:n<t?(n++,Object.assign(Object.assign({},e),{selected:!0})):e}))})}{const l=e;return l.disabled||(l.selected||f&&!(null===(s=l.label)||void 0===s?void 0:s.toLowerCase().includes(f.toLowerCase())))?e:n<t?(n++,Object.assign(Object.assign({},e),{selected:!0})):e}}));p([...l]),"2.0"===s&&w(l)}else{const e=t.iterateOnOptions(d,{selected:!0},(e=>{var t;return f?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(f.toLowerCase()))&&!e.disabled:!e.disabled}));p([...e]),"2.0"===s&&w(e)}else if("notSelected"===e){const e=t.iterateOnOptions(d,{selected:!1},(e=>!e.disabled));p([...e]),"2.0"===s&&w(e)}},onMultiSelectClear:function(){const e=t.iterateOnOptions(d,{selected:!1});p([...e]),"2.0"===s&&w(e)},onFreeFormSelect:function(e){if(!c)return void S({label:f,value:f,isFreeForm:!0,selected:!0});const t=d.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===f&&t.value===f?e:t.selected})));e&&(t.some((e=>e.label===f&&e.value===f))||t.unshift({label:f,value:f,isFreeForm:!0,selected:!0})),p([...t]),"2.0"===s&&w(t)},onMultiSelectApply:w,getSelectedOptions:j,getCurrentSelectionCount:h,isMaxSelectionsReached:m,maxSelections:u}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../_virtual/_tslib.js";import{jsxs as o,Fragment as n,jsx as l}from"react/jsx-runtime";import{useState as t,useRef as i,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/chevronDown.svg.js";import{Input as d}from"../input/Input.js";import{InputStyleContext as c}from"../input/context/InputStyleProvider.js";import p from"./ChipInput.js";import{DropdownPopover as u}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as h}from"./OpenedDropdown/utils/iterationOnOptions.js";function m(){}const v=v=>{var f,g,x,b,w,{placeHolder:j,size:y,onSelect:I,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:
|
|
1
|
+
import{__rest as e}from"../../_virtual/_tslib.js";import{jsxs as o,Fragment as n,jsx as l}from"react/jsx-runtime";import{useState as t,useRef as i,useEffect as r}from"react";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/chevronDown.svg.js";import{Input as d}from"../input/Input.js";import{InputStyleContext as c}from"../input/context/InputStyleProvider.js";import p from"./ChipInput.js";import{DropdownPopover as u}from"./DropdownPopover/index.js";import{getSelectedOptionsAsText as h}from"./OpenedDropdown/utils/iterationOnOptions.js";function m(){}const v=v=>{var f,g,x,b,w,{placeHolder:j,size:y,onSelect:I,defaultOptions:O,disabled:S,noErrorHint:H,placeHolderHeight:E,showPlaceholderWhenSelected:C=!1,inputStyle:T={},inputType:D="default",onDeleteChip:P,truncatedText:W,showLeadingIconInPlaceholder:M=!1,showTrailingIconPlaceholder:L=!1,showLabelsOnMoreHover:z=!1,value:k}=v,A=e(v,["placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value"]);const[_,F]=t(!1),[N,U]=t(!1),V=null!=y?y:"default",$=i(),[q,B]=t(null!=O?O:[]),G=i(null),[J,K]=t(null);r((()=>{var e;const o=[];null===(e=null==A?void 0:A.options)||void 0===e||e.forEach((e=>{e.options?e.options.forEach((e=>{e.selected&&o.push(Object.assign(Object.assign({},e),{label:e.label}))})):e.selected&&o.push(e)})),B([...o])}),[A.options]),r((()=>{O&&B([...O])}),[O]);const Q=h(q),R=C?j:null!==(f=null!=Q?Q:j)&&void 0!==f?f:"Select an option";r((()=>{if(G.current){const e=G.current.scrollWidth;K(e+("x-small"===V?16:"small"===V?20:24)+2*("x-small"===V?16:12)+8+2)}}),[R,V]);const X=null!==(x=null!==(g=A.buttonWidth)&&void 0!==g?g:A.inputWidth)&&void 0!==x?x:"100%",Y=J?`${J}px`:X;return o(n,{children:[l("span",Object.assign({ref:G,style:{position:"absolute",visibility:"hidden",whiteSpace:"nowrap",fontSize:"x-small"===V?"12px":"small"===V?"14px":"16px",fontFamily:"Inter"}},{children:R})),l(c.Provider,Object.assign({value:{InputWrapper:Object.assign({height:E||("x-small"===V?24:"small"===V?32:48),width:Y,maxWidth:X,zIndex:1,cursor:"pointer",padding:"x-small"===V?"4px 8px":"6px 8px",backgroundColor:void 0!==k?"#C3E4C4":N?"#E0E0E0":"#ffffff",transition:"background-color 0.3s ease"},T),input:{minHeight:"100%",maxWidth:"100%",color:void 0!==k?"#00580E":"inherit"}}},{children:l("div",Object.assign({onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1)},{children:o(u,Object.assign({"data-test":A["data-test"],ref:$,onSelect:function(e){Array.isArray(e)?B([...e]):B([e]),null==I||I(e)},disabled:S,onDropdownVisbilityChange:e=>F(e)},A,{children:["default"==D&&l(d,{version:A.version,noErrorHint:H,state:S?"disabled":"none",value:void 0===k?R:k,errorMessage:A.error,variant:V,placeholder:null!=j?j:"Select an option",onChangeText:m,leftIcon:M&&(null===(b=q[0])||void 0===b?void 0:b.leadingIcon)?{icon:()=>{var e;return l(n,{children:null===(e=q[0])||void 0===e?void 0:e.leadingIcon})}}:void 0,rightIcon:{icon:()=>{var e;return o("div",Object.assign({style:{display:"flex"}},{children:[L&&(null===(e=q[0])||void 0===e?void 0:e.trailingIcon),l(a,{style:{transform:_?"rotate(180deg)":"rotate(0deg)"},onClick:m,width:"x-small"===V?16:"small"===V?20:24,height:"x-small"===V?16:"small"===V?20:24,color:s.content.primary})]}))}},truncateText:null==W||W}),"chip"==D&&l(p,{placeholder:null!=j?j:"Select options",chips:q,onDeleteChip:e=>{null==P||P(e)},errorMessage:A.error,isDropdownOpened:_,sizeToUse:V,containerStyle:{width:null!==(w=A.width)&&void 0!==w?w:"100%",cursor:"pointer"},showLabelsOnMoreHover:z})]}))}))}))]})};v.displayName="Dropdown";export{v as Dropdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useRef as t,useEffect as s}from"react";import{iterateOnOptionsRaw as l,iterateOnOptions as n}from"../OpenedDropdown/utils/iterationOnOptions.js";const c=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",i=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,
|
|
1
|
+
import{useState as e,useRef as t,useEffect as s}from"react";import{iterateOnOptionsRaw as l,iterateOnOptions as n}from"../OpenedDropdown/utils/iterationOnOptions.js";const c=function(){let c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1.0",i=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0,d=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,v=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[],f=arguments.length>8?arguments[8]:void 0;const[p,g]=e(null!=i?i:[]),[b,O]=e([]),[j,h]=e(""),m=t(p);s((()=>{if(m.current=p,b.length&&j&&d){let e=[...b];const t=p.map((e=>{if(e.options)return e.options.map((e=>({value:e.value,selected:e.selected})));const t=e;return{value:t.value,selected:t.selected}})).flat();e=e.map((e=>{const s=t.find((t=>e.value===t.value));return s?Object.assign(Object.assign({},e),{selected:s.selected}):e})),u&&(e=e.map((e=>Object.assign(Object.assign({},e),{disabled:!v.includes(e.value)})))),O(r&&!a?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[p]),s((()=>{if(i){const e=[...i];g(r&&!a?[...e.sort((e=>e.selected?-1:1))]:[...e])}}),[i]);const w=e=>{const t=[];return e.forEach((e=>{if(e.options){const s=e.options.filter((e=>!0===e.selected));t.push(Object.assign(Object.assign({},e),{options:[...s]}))}else e.selected&&t.push(Object.assign({},e))})),t},C=e=>{let t=0;return e.forEach((e=>{e.options?t+=e.options.filter((e=>!0===e.selected)).length:e.selected&&t++})),t},S=e=>!(!r||!f&&0!==f)&&C(e)>=f;function F(e,t){if(r){if(e.selected&&f&&S(p))return;if(b.length&&j&&d)if(e.selected){if(f&&S(p))return;let s=!1;const l=n(p,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s||l.push(e),t)return[...l];g([...l]),"2.0"===c&&L(l)}else{let s=!1,l=n(p,{selected:e.selected},(t=>t.value===e.value&&(s=!0,!0)));if(s&&(l=l.filter((t=>t.value!==e.value))),t)return[...l];g([...l]),"2.0"===c&&L(l)}else{const s=n(p,{selected:e.selected},(t=>t.value===e.value));if(t)return[...s];g([...s]),"2.0"===c&&L(s)}}else null==o||o(e)}function L(e){const t=w(null!=e?e:m.current);null==o||o([...t])}return{latestDropdownOptionsRef:m,dropdownOptions:p,search:function(e){if(h(e),O([]),e&&d){const t=[];l(p,(e=>{e.selected&&!t.includes(e.value)&&t.push(e.value)})),d(e).then((e=>{if(e){const s=e.map((e=>{if(e.options){const s=e;return Object.assign(Object.assign({},s),{options:s.options.map((e=>Object.assign(Object.assign({},e),{selected:t.includes(e.value)})))})}return Object.assign(Object.assign({},e),{selected:t.includes(e.value)})}));O([...s])}}))}},searchedString:j,searchedOptions:b,onApplyHandler:F,selectAllHandler:function(e){if(b.length&&j&&d)"selectAll"===e?function(e){let t=[...p];if(e&&f&&f>0){const e=C(t),s=f-e;if(s<=0)return;let l=0;b.forEach((e=>{if(l>=s)return;let n=!1;t=t.map((t=>{const s=e;return t.selected||t.disabled?t:void 0!==s.value&&s.value===t.value?(n=!0,l++,Object.assign(Object.assign({},t),{selected:!0})):t})),!n&&l<s&&(e.disabled||(t.push(Object.assign(Object.assign({},e),{selected:!0})),l++))})),g([...t]),"2.0"===c&&L(t)}}(!0):function(e){let t=[...p];e?b.forEach((e=>{let s=!1;t=t.map((t=>{const l=e;return void 0!==l.value&&l.value===t.value?(s=!0,Object.assign(Object.assign({},t),{selected:!0})):t})),s||t.push(Object.assign(Object.assign({},e),{selected:!0}))})):b.forEach((e=>{t=t.map((t=>{const s=e;return void 0!==s.value&&s.value===t.value?Object.assign(Object.assign({},t),{selected:!1}):t}))})),g([...t]),"2.0"===c&&L(t)}(!1);else if("selectAll"===e)if(f&&f>0){const e=C(p),t=f-e;if(t<=0)return;let s=0;const l=p.map((e=>{var l;if(e.options){const l=e;return Object.assign(Object.assign({},l),{options:l.options.map((e=>{var l;return e.disabled||e.selected||j&&!(null===(l=e.label)||void 0===l?void 0:l.toLowerCase().includes(j.toLowerCase()))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}))})}{const n=e;return n.disabled||(n.selected||j&&!(null===(l=n.label)||void 0===l?void 0:l.toLowerCase().includes(j.toLowerCase())))?e:s<t?(s++,Object.assign(Object.assign({},e),{selected:!0})):e}}));g([...l]),"2.0"===c&&L(l)}else{const e=n(p,{selected:!0},(e=>{var t;return j?(null===(t=e.label)||void 0===t?void 0:t.toLowerCase().includes(j.toLowerCase()))&&!e.disabled:!e.disabled}));g([...e]),"2.0"===c&&L(e)}else if("notSelected"===e){const e=n(p,{selected:!1},(e=>!e.disabled));g([...e]),"2.0"===c&&L(e)}},onMultiSelectClear:function(){const e=n(p,{selected:!1});g([...e]),"2.0"===c&&L(e)},onFreeFormSelect:function(e){if(!r)return void F({label:j,value:j,isFreeForm:!0,selected:!0});const t=p.map((t=>t.options?t:Object.assign(Object.assign({},t),{selected:t.label===j&&t.value===j?e:t.selected})));e&&(t.some((e=>e.label===j&&e.value===j))||t.unshift({label:j,value:j,isFreeForm:!0,selected:!0})),g([...t]),"2.0"===c&&L(t)},onMultiSelectApply:L,getSelectedOptions:w,getCurrentSelectionCount:C,isMaxSelectionsReached:S,maxSelections:f}};export{c as useDropdown};
|