@lifesg/react-design-system 1.0.0-alpha.17 → 1.0.0-alpha.18

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 (49) hide show
  1. package/card/types.d.ts +1 -1
  2. package/checkbox/checkbox.d.ts +1 -1
  3. package/checkbox/index.js +6 -6
  4. package/checkbox/index.js.map +1 -1
  5. package/cjs/index.js +101 -29
  6. package/cjs/index.js.map +1 -1
  7. package/color/types.d.ts +1 -1
  8. package/date-input/date-input.d.ts +1 -1
  9. package/date-input/index.js +76 -76
  10. package/date-input/index.js.map +1 -1
  11. package/date-input/types.d.ts +6 -19
  12. package/feedback-rating/feedback-rating-stars-container.styles.d.ts +1 -1
  13. package/feedback-rating/feedback-rating.styles.d.ts +1 -1
  14. package/feedback-rating/index.js.map +1 -1
  15. package/footer/index.js +2 -2
  16. package/footer/index.js.map +1 -1
  17. package/footer/types.d.ts +2 -2
  18. package/form/index.js +455 -442
  19. package/form/index.js.map +1 -1
  20. package/form/types.d.ts +1 -1
  21. package/index.d.ts +1 -0
  22. package/index.js +101 -29
  23. package/index.js.map +1 -1
  24. package/input-group/index.js +14 -2
  25. package/input-group/index.js.map +1 -1
  26. package/input-group/types.d.ts +6 -6
  27. package/input-select/index.js +15 -3
  28. package/input-select/index.js.map +1 -1
  29. package/input-select/input-select-wrapper.d.ts +1 -1
  30. package/input-select/input-select.styles.d.ts +1 -0
  31. package/input-select/types.d.ts +11 -9
  32. package/input-textarea/types.d.ts +1 -1
  33. package/link-list/types.d.ts +1 -1
  34. package/modal/types.d.ts +3 -3
  35. package/navbar/brand.d.ts +1 -1
  36. package/navbar/index.js.map +1 -1
  37. package/navbar/types.d.ts +5 -5
  38. package/notification-banner/types.d.ts +1 -1
  39. package/overlay/types.d.ts +1 -1
  40. package/package.json +1 -1
  41. package/popover/types.d.ts +3 -3
  42. package/progress-indicator/types.d.ts +1 -1
  43. package/shared/dropdown-list/dropdown-list.styles.d.ts +1 -1
  44. package/shared/dropdown-list/types.d.ts +11 -11
  45. package/smart-app-banner/types.d.ts +1 -1
  46. package/timepicker/types.d.ts +3 -3
  47. package/unit-number/types.d.ts +5 -5
  48. package/util/date-helper.d.ts +19 -0
  49. package/util/index.d.ts +2 -0
@@ -11,11 +11,11 @@ export interface LabelAddon {
11
11
  export interface ListAddon<T, V> extends DropdownDisplayProps<T, V>, DropdownSearchProps<T> {
12
12
  value?: T | undefined;
13
13
  placeholder?: string | undefined;
14
- displayValueExtractor?: (item: T) => string | undefined;
14
+ displayValueExtractor?: ((item: T) => string) | undefined;
15
15
  "data-selector-testid"?: string | undefined;
16
16
  options?: T[] | undefined;
17
17
  selectedOption?: T | undefined;
18
- onSelectOption?: (option: T, extractedValue: T | V) => void | undefined;
18
+ onSelectOption?: ((option: T, extractedValue: T | V) => void) | undefined;
19
19
  /**
20
20
  * Used when items are loaded from an api call.
21
21
  * Values: "loading" | "fail" | "success"
@@ -23,9 +23,9 @@ export interface ListAddon<T, V> extends DropdownDisplayProps<T, V>, DropdownSea
23
23
  optionsLoadState?: ItemsLoadStateType | undefined;
24
24
  /** Specifies the truncation type. Truncated text will be replaced with ellipsis. Values: "middle" | "end" */
25
25
  optionTruncationType?: TruncateType | undefined;
26
- onRetry?: () => void | undefined;
27
- onHideOptions?: () => void | undefined;
28
- onShowOptions?: () => void | undefined;
26
+ onRetry?: (() => void) | undefined;
27
+ onHideOptions?: (() => void) | undefined;
28
+ onShowOptions?: (() => void) | undefined;
29
29
  }
30
30
  export interface AddonProps<T, V> {
31
31
  type?: InputGroupAddonType | undefined;
@@ -33,7 +33,7 @@ export interface AddonProps<T, V> {
33
33
  position?: "left" | "right" | undefined;
34
34
  }
35
35
  export interface InputGroupProps<T, V> extends InputProps {
36
- addon?: AddonProps<T, V>;
36
+ addon?: AddonProps<T, V> | undefined;
37
37
  }
38
38
  /** To be exposed for Form component inheritance */
39
39
  export declare type InputGroupPartialProps<T, V> = Omit<InputGroupProps<T, V>, "error">;
@@ -403,7 +403,7 @@ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import*as r from
403
403
  outline-color: ${Tl.Accent.Light[3]};
404
404
  color: ${Tl.Neutral[1]};
405
405
  }
406
- `;const Rc=p((({className:n,checked:r,disabled:i,onClick:a,onKeyPress:l,displaySize:c="default",...u})=>{const[d,h]=s(r);o((()=>{h(r)}),[r]);const C=e=>{i||(a&&a(e),l&&l(e))};return e(wc,{selected:d,disabled:i,className:n,"data-testid":"checkbox",onKeyPress:C,tabIndex:i?-1:0,role:"checkbox",$displaySize:c,children:[t(Vc,{type:"checkbox","data-testid":"checkbox-input",onClick:C,disabled:i,tabIndex:-1,...u}),d&&t(_c,{type:"tick",id:"checkmark","data-testid":"checkmark",disabled:i,$displaySize:c})]})}))`
406
+ `;const Rc=p((({className:n,checked:r,disabled:i,onChange:a,onKeyPress:l,displaySize:c="default",...u})=>{const[d,h]=s(r);o((()=>{h(r)}),[r]);const C=e=>{if(!i){const t=e;if(!(" "===t.key||"change"===e.type))return;a&&a(e),l&&l(t)}};return e(wc,{selected:d,disabled:i,className:n,"data-testid":"checkbox",$displaySize:c,role:"checkbox","aria-checked":d,"aria-labelledby":"checkbox-input",tabIndex:i?-1:0,onKeyDown:C,children:[t(Vc,{id:"checkbox-input","data-testid":"checkbox-input","aria-hidden":"true",type:"checkbox",tabIndex:-1,onChange:C,disabled:i,checked:d,...u}),d&&t(_c,{type:"tick",id:"checkmark","data-testid":"checkmark",disabled:i,$displaySize:c})]})}))`
407
407
  flex: 0 0 1.5rem;
408
408
  margin-right: 1rem;
409
409
  `,jc=p.div`
@@ -466,7 +466,7 @@ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import*as r from
466
466
  width: 1.5rem;
467
467
  margin: 0 0.5rem;
468
468
  color: ${Tl.Neutral[3]};
469
- `,Nc=c(((n,r)=>e(Ic,{children:[t(Ec,{type:"search"}),t(Dc,{ref:r,...n})]},"search"))),Tc=({listItems:n,listExtractor:r,valueExtractor:i,onSelectItem:a,listStyleWidth:c,visible:u,enableSearch:d,searchPlaceholder:h="Search",onSearch:C,searchFunction:p,onDismiss:f,multiSelect:g,selectedItems:m,onSelectAll:v,onRetry:y,itemsLoadState:L="success",itemTruncationType:b="end",renderListItem:H,...w})=>{const[V,_]=s(0),[S,M]=s(""),[x,$]=s(n),[k,Z]=s(0),F=function(e,t){const n=yo.fun(e),[[r],i]=fl(1,n?e:[e],n?t||[]:t);return n||2==arguments.length?[r,i]:r}({height:k}),O=l(),R=l(),j=l([]),B=l(),A=l(V),P=l(x),z=e=>{A.current=e,_(e)},I=e=>{P.current=e,$(e)};o((()=>(document.addEventListener("keydown",q),()=>{document.removeEventListener("keydown",q)})),[]),o((()=>{T(S)}),[S]),o((()=>{M(""),u?(Z(W()),B&&B.current?(B.current.focus(),z(-1)):j.current[V]&&j.current[V].focus()):Z(0)}),[u]),o((()=>{if(u){const e=W();Z(e)}}),[x]),o((()=>{I(n),M(""),z(0)}),[n]);const D=e=>r?r(e):e.toString(),E=e=>{const t=r?r(e):e.toString();let n=0;return R&&R.current&&(n=R.current.getBoundingClientRect().width-100),Hc.shouldTruncateToTwoLines(t,n)},N=e=>Ti(m,e)>-1,T=e=>{if(""===e)I(n);else if(p){const t=p(e);I(t)}else{const t=n.filter((t=>D(t).toLowerCase().includes(e.trim().toLowerCase())));I(t)}},W=()=>R&&R.current?R.current.getBoundingClientRect().height:0,q=e=>{if(O&&O.current.contains(e.target))switch(e.code){case"ArrowDown":if(A.current<P.current.length-1){const e=A.current+1;j.current[e].focus(),z(e)}break;case"ArrowUp":if(A.current>0){const e=A.current-1;j.current[e].focus(),z(A.current-1)}break;case"Escape":f&&f()}},U=(e,t)=>{e.preventDefault(),a&&a(t,(e=>i?i(e):e)(t))},Q=()=>{y&&y()},G=n=>{const i=r?r(n):n.toString();return e(Zc,{"data-testid":"truncate-middle-container",children:[t(Fc,{children:i}),e(Oc,{children:[" ",i]})]})};return t(Sc,{style:F,"data-testid":u?"dropdown-container":"dropdown-container-hidden",ref:O,children:e(Mc,{ref:R,"data-testid":"dropdown-list",width:c,role:"list",...w,children:[(d||p)&&"success"===L?t(Nc,{ref:B,onChange:e=>{const t=e.target.value;M(t),C&&C()},value:S,placeholder:h,"data-testid":"search-input","aria-label":"search-input",tabIndex:u?0:-1}):null,(()=>{if(g&&x.length>0&&!S&&"success"===L)return t(jc,{children:t(Bc,{onClick:v,children:0===m.length?"Select all":"Unselect all"})},"selectAll")})(),(()=>{if(S&&0===x.length)return e(Ac,{"data-testid":"list-no-results",children:[t(zc,{"data-testid":"no-result-icon",children:t(Yi,{})}),t(Pc,{children:"No results found."})]},"noResults")})(),(()=>{if(y&&"loading"===L)return e(Ac,{"data-testid":"list-loading",children:[t(bc,{$buttonStyle:"secondary",size:24}),t(Pc,{children:"Loading..."})]},"loading")})(),(()=>{if(y&&"fail"===L)return e(Ac,{"data-testid":"list-fail",children:[t(zc,{"data-testid":"load-error-icon",children:t(Yi,{})}),t(Pc,{children:"Failed to load."}),t(Bc,{onClick:Q,children:"Try again."})]},"noResults")})(),(()=>{if(!y||y&&"success"===L)return x.map(((n,r)=>t(xc,{checked:N(n)&&!g,children:e($c,{onClick:e=>{U(e,n)},ref:e=>j.current[r]=e,"data-testid":"list-item",type:"button",tabIndex:u?0:-1,multiSelect:g,children:[g&&t(Rc,{checked:N(n),displaySize:"small"}),H?H(n,{selected:N(n)}):t(kc,{truncateType:b,children:"middle"===b&&E(n)?G(n):D(n)})]})},((e,t)=>`item_${t}__${i?i(e):e}`)(n,r))))})()]})})},Wc="all 300ms cubic-bezier(0.21, 0.79, 0.53, 1)",qc=p.div`
469
+ `,Nc=c(((n,r)=>e(Ic,{children:[t(Ec,{type:"search"}),t(Dc,{ref:r,...n})]},"search"))),Tc=({listItems:n,listExtractor:r,valueExtractor:i,onSelectItem:a,listStyleWidth:c,visible:u,enableSearch:d,searchPlaceholder:h="Search",onSearch:C,searchFunction:p,onDismiss:f,multiSelect:g,selectedItems:m,onSelectAll:v,onRetry:y,itemsLoadState:L="success",itemTruncationType:b="end",renderListItem:H,...w})=>{const[V,_]=s(0),[S,M]=s(""),[x,$]=s(n),[k,Z]=s(0),F=function(e,t){const n=yo.fun(e),[[r],i]=fl(1,n?e:[e],n?t||[]:t);return n||2==arguments.length?[r,i]:r}({height:k}),O=l(),R=l(),j=l([]),B=l(),A=l(V),P=l(x),z=e=>{A.current=e,_(e)},I=e=>{P.current=e,$(e)};o((()=>(document.addEventListener("keydown",q),()=>{document.removeEventListener("keydown",q)})),[]),o((()=>{T(S)}),[S]),o((()=>{M(""),u?(Z(W()),B&&B.current?(B.current.focus(),z(-1)):j.current[V]&&j.current[V].focus()):Z(0)}),[u]),o((()=>{if(u){const e=W();Z(e)}}),[x]),o((()=>{I(n),M(""),z(0)}),[n]);const D=e=>r?r(e):e.toString(),E=e=>{const t=r?r(e):e.toString();let n=0;return R&&R.current&&(n=R.current.getBoundingClientRect().width-100),Hc.shouldTruncateToTwoLines(t,n)},N=e=>Ti(m,e)>-1,T=e=>{if(""===e)I(n);else if(p){const t=p(e);I(t)}else{const t=n.filter((t=>D(t).toLowerCase().includes(e.trim().toLowerCase())));I(t)}},W=()=>R&&R.current?R.current.getBoundingClientRect().height:0,q=e=>{if(O&&O.current.contains(e.target))switch(e.code){case"ArrowDown":if(A.current<P.current.length-1){const e=A.current+1;j.current[e].focus(),z(e)}break;case"ArrowUp":if(A.current>0){const e=A.current-1;j.current[e].focus(),z(A.current-1)}break;case"Escape":f&&f()}},U=(e,t)=>{e.preventDefault(),a&&a(t,(e=>i?i(e):e)(t))},Q=e=>{const t=e.target.value;M(t),C&&C()},G=()=>{y&&y()},X=n=>{const i=r?r(n):n.toString();return e(Zc,{"data-testid":"truncate-middle-container",children:[t(Fc,{children:i}),e(Oc,{children:[" ",i]})]})},K=()=>{if(!y||y&&"success"===L)return x.map(((n,r)=>t(xc,{checked:N(n)&&!g,children:e($c,{onClick:e=>{U(e,n)},ref:e=>j.current[r]=e,"data-testid":"list-item",type:"button",tabIndex:u?0:-1,multiSelect:g,children:[g&&t(Rc,{checked:N(n),displaySize:"small"}),H?H(n,{selected:N(n)}):t(kc,{truncateType:b,children:"middle"===b&&E(n)?X(n):D(n)})]})},((e,t)=>`item_${t}__${i?i(e):e}`)(n,r))))},Y=()=>{if(g&&x.length>0&&!S&&"success"===L)return t(jc,{children:t(Bc,{onClick:v,children:0===m.length?"Select all":"Unselect all"})},"selectAll")},J=()=>{if(S&&0===x.length)return e(Ac,{"data-testid":"list-no-results",children:[t(zc,{"data-testid":"no-result-icon",children:t(Yi,{})}),t(Pc,{children:"No results found."})]},"noResults")},ee=()=>{if(y&&"loading"===L)return e(Ac,{"data-testid":"list-loading",children:[t(bc,{$buttonStyle:"secondary",size:24}),t(Pc,{children:"Loading..."})]},"loading")},te=()=>{if(y&&"fail"===L)return e(Ac,{"data-testid":"list-fail",children:[t(zc,{"data-testid":"load-error-icon",children:t(Yi,{})}),t(Pc,{children:"Failed to load."}),t(Bc,{onClick:G,children:"Try again."})]},"noResults")};return t(Sc,{style:F,"data-testid":u?"dropdown-container":"dropdown-container-hidden",ref:O,children:(()=>{if(u)return e(Mc,{ref:R,"data-testid":"dropdown-list",width:c,role:"list",...w,children:[(d||p)&&"success"===L?t(Nc,{ref:B,onChange:Q,value:S,placeholder:h,"data-testid":"search-input","aria-label":"search-input",tabIndex:u?0:-1}):null,Y(),J(),ee(),te(),K()]})})()})},Wc="all 300ms cubic-bezier(0.21, 0.79, 0.53, 1)",qc=p.div`
470
470
  position: relative;
471
471
  min-height: 3rem;
472
472
  height: 3rem;
@@ -535,6 +535,18 @@ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import*as r from
535
535
  border: 1px solid ${Tl.Neutral[5](e)};
536
536
  box-shadow: none;
537
537
  }
538
+ `:e.$readOnly?g`
539
+ border: none;
540
+ background: transparent !important;
541
+
542
+ ${Uc} {
543
+ padding-left: 0rem;
544
+ }
545
+
546
+ :focus-within {
547
+ border: none;
548
+ box-shadow: none;
549
+ }
538
550
  `:e.error?g`
539
551
  border: 1px solid ${Tl.Validation.Red.Border(e)};
540
552
 
@@ -570,5 +582,5 @@ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import*as r from
570
582
  overflow: hidden;
571
583
  `,tu=p(eu)`
572
584
  color: ${Tl.Neutral[3]};
573
- `,nu=({children:e,show:n,error:r,disabled:i,testId:a,onBlur:s})=>{const c=l(),u=l(n);o((()=>(document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)})),[]),o((()=>{u.current=n}),[n]);const d=e=>{if(!i){if(c&&c.current.contains(e.target))return;u.current&&s()}};return t(qc,{children:t(Gc,{ref:c,error:r&&!n,disabled:i,expanded:n,"data-testid":a,children:e})})},ru=({selectedOption:r,placeholder:i="Select",options:a,disabled:c,error:u,"data-testid":d,id:h,enableSearch:C=!1,searchFunction:p,searchPlaceholder:f,valueExtractor:g,valueToStringFunction:m,listExtractor:v,displayValueExtractor:y,onSelectOption:L,listStyleWidth:b,onShowOptions:H,onHideOptions:w,onRetry:V,optionsLoadState:_="success",optionTruncationType:S="end",renderCustomSelectedOption:M,renderListItem:x,...$})=>{const[k,Z]=s(r),[F,O]=s(!1),R=l(),j=l();o((()=>{Z(r)}),[r]);const B=(e,t)=>{Z(e),O(!1),z(!1),R&&R.current.focus(),L&&L(e,t)},A=()=>{F&&(O(!1),z(!1)),R&&R.current.focus()},P=e=>{if("middle"===S){let t=0;return j&&j.current&&(t=j.current.getBoundingClientRect().width),Hc.truncateOneLine((e=>"string"==typeof e?e:m(e)||e.toString())(e),t,120,8)}return e},z=e=>{!e&&w&&w(),e&&H&&H()};return e(nu,{show:F,error:u&&!F,disabled:c,testId:d,onBlur:()=>{O(!1),z(!1)},children:[t(Uc,{ref:R,type:"button","data-testid":h||"selector",onClick:e=>{e.preventDefault(),c||(O(!F),z(!F))},...$,children:e(n,{children:[t(Jc,{ref:j,children:k?M?M(k):t(eu,{truncateType:S,children:P(y?y(k):g?g(k):k.toString())}):t(tu,{truncateType:S,children:i})}),t(Xc,{expanded:F,children:t(Kc,{type:"chevron-down"})})]})}),F&&t(Yc,{}),a&&a.length>0?t(Tc,{listItems:a,onSelectItem:B,onDismiss:A,valueExtractor:g,listExtractor:v,listStyleWidth:b,visible:F,enableSearch:C,searchPlaceholder:f,searchFunction:p,"data-testid":"dropdown-list",selectedItems:k?[k]:[],onRetry:V,itemsLoadState:_,itemTruncationType:S,renderListItem:x}):null]})},iu=({selectedOptions:r,placeholder:i="Select",options:a,disabled:c,error:u,"data-testid":d,enableSearch:h=!1,searchFunction:C,searchPlaceholder:p,valueExtractor:f,listExtractor:g,onSelectOptions:m,listStyleWidth:v,onShowOptions:y,onHideOptions:L,onRetry:b,optionsLoadState:H="success",optionTruncationType:w="end",...V})=>{const[_,S]=s(r||[]),[M,x]=s(!1),$=l();o((()=>{S(r||[])}),[r]);const k=(e,t)=>{const n=[..._],r=Ti(_,(e=>(f?f(e):e)===t));r>-1?n.splice(r,1):n.push(e),S(n),O(!1),$&&$.current.focus(),m&&m(n)},Z=()=>{M&&(x(!1),O(!1)),$&&$.current.focus()},F=()=>{_&&_.length>0?(S([]),m([])):(S(a),m(a))},O=e=>{!e&&L&&L(),e&&y&&y()};return e(nu,{show:M,error:u&&!M,disabled:c,testId:d,onBlur:()=>{x(!1),O(!1)},children:[t(Uc,{ref:$,type:"button","data-testid":"selector",onClick:e=>{e.preventDefault(),c||(x(!M),O(!M))},...V,children:e(n,{children:[t(Jc,{children:_&&0!==_.length?t(eu,{children:_&&0!=_.length?`${_.length} selected`:i}):t(tu,{truncateType:w,children:i})}),t(Xc,{expanded:M,children:t(Kc,{type:"chevron-down"})})]})}),M&&t(Yc,{}),a&&a.length>0||b?t(Tc,{listItems:a,onSelectItem:k,onDismiss:Z,valueExtractor:f,listExtractor:g,listStyleWidth:v,visible:M,enableSearch:h,searchFunction:C,searchPlaceholder:p,"data-testid":"dropdown-list",multiSelect:!0,selectedItems:_,onSelectAll:F,onRetry:b,itemsLoadState:H,itemTruncationType:w}):null]})};export{iu as InputMultiSelect,ru as InputSelect};
585
+ `,nu=({children:e,show:n,error:r,disabled:i,testId:a,onBlur:s,readOnly:c})=>{const u=l(),d=l(n);o((()=>(document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)})),[]),o((()=>{d.current=n}),[n]);const h=e=>{if(!i){if(u&&u.current.contains(e.target))return;d.current&&s()}};return t(qc,{children:t(Gc,{ref:u,error:r&&!n,disabled:i,$readOnly:c,expanded:n,"data-testid":a,children:e})})},ru=({selectedOption:r,placeholder:i="Select",options:a,disabled:c,error:u,"data-testid":d,id:h,enableSearch:C=!1,searchFunction:p,searchPlaceholder:f,valueExtractor:g,valueToStringFunction:m,listExtractor:v,displayValueExtractor:y,onSelectOption:L,listStyleWidth:b,onShowOptions:H,onHideOptions:w,onRetry:V,optionsLoadState:_="success",optionTruncationType:S="end",renderCustomSelectedOption:M,renderListItem:x,...$})=>{const[k,Z]=s(r),[F,O]=s(!1),R=l(),j=l();o((()=>{Z(r)}),[r]);const B=(e,t)=>{Z(e),O(!1),z(!1),R&&R.current.focus(),L&&L(e,t)},A=()=>{F&&(O(!1),z(!1)),R&&R.current.focus()},P=e=>{if("middle"===S){let t=0;return j&&j.current&&(t=j.current.getBoundingClientRect().width),Hc.truncateOneLine((e=>"string"==typeof e?e:m(e)||e.toString())(e),t,120,8)}return e},z=e=>{!e&&w&&w(),e&&H&&H()};return e(nu,{show:F,error:u&&!F,disabled:c,readOnly:$.readOnly,testId:d,onBlur:()=>{O(!1),z(!1)},children:[t(Uc,{ref:R,type:"button","data-testid":h||"selector",onClick:e=>{e.preventDefault(),c||$.readOnly||(O(!F),z(!F))},...$,children:e(n,{children:[t(Jc,{ref:j,children:k?M?M(k):t(eu,{truncateType:S,children:P(y?y(k):g?g(k):k.toString())}):t(tu,{truncateType:S,children:i})}),!$.readOnly&&t(Xc,{expanded:F,children:t(Kc,{type:"chevron-down"})})]})}),F&&t(Yc,{}),a&&a.length>0?t(Tc,{listItems:a,onSelectItem:B,onDismiss:A,valueExtractor:g,listExtractor:v,listStyleWidth:b,visible:F,enableSearch:C,searchPlaceholder:f,searchFunction:p,"data-testid":"dropdown-list",selectedItems:k?[k]:[],onRetry:V,itemsLoadState:_,itemTruncationType:S,renderListItem:x}):null]})},iu=({selectedOptions:r,placeholder:i="Select",options:a,disabled:c,error:u,"data-testid":d,enableSearch:h=!1,searchFunction:C,searchPlaceholder:p,valueExtractor:f,listExtractor:g,onSelectOptions:m,listStyleWidth:v,onShowOptions:y,onHideOptions:L,onRetry:b,optionsLoadState:H="success",optionTruncationType:w="end",...V})=>{const[_,S]=s(r||[]),[M,x]=s(!1),$=l();o((()=>{S(r||[])}),[r]);const k=(e,t)=>{const n=[..._],r=Ti(_,(e=>(f?f(e):e)===t));r>-1?n.splice(r,1):n.push(e),S(n),O(!1),$&&$.current.focus(),m&&m(n)},Z=()=>{M&&(x(!1),O(!1)),$&&$.current.focus()},F=()=>{_&&_.length>0?(S([]),m([])):(S(a),m(a))},O=e=>{!e&&L&&L(),e&&y&&y()};return e(nu,{show:M,error:u&&!M,disabled:c,testId:d,onBlur:()=>{x(!1),O(!1)},children:[t(Uc,{ref:$,type:"button","data-testid":"selector",onClick:e=>{e.preventDefault(),c||(x(!M),O(!M))},...V,children:e(n,{children:[t(Jc,{children:_&&0!==_.length?t(eu,{children:_&&0!=_.length?`${_.length} selected`:i}):t(tu,{truncateType:w,children:i})}),t(Xc,{expanded:M,children:t(Kc,{type:"chevron-down"})})]})}),M&&t(Yc,{}),a&&a.length>0||b?t(Tc,{listItems:a,onSelectItem:k,onDismiss:Z,valueExtractor:f,listExtractor:g,listStyleWidth:v,visible:M,enableSearch:h,searchFunction:C,searchPlaceholder:p,"data-testid":"dropdown-list",multiSelect:!0,selectedItems:_,onSelectAll:F,onRetry:b,itemsLoadState:H,itemTruncationType:w}):null]})};export{iu as InputMultiSelect,ru as InputSelect};
574
586
  //# sourceMappingURL=index.js.map