@lifesg/react-design-system 3.4.0-canary.5 → 3.4.0-canary.7

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 (131) hide show
  1. package/badge/badge.style.d.ts +3 -3
  2. package/badge/badge.style.js +8 -8
  3. package/badge/badge.style.js.map +1 -1
  4. package/badge/types.d.ts +1 -1
  5. package/calendar/calendar.js +1 -1
  6. package/calendar/calendar.js.map +1 -1
  7. package/cjs/badge/badge.style.js +11 -11
  8. package/cjs/badge/badge.style.js.map +1 -1
  9. package/cjs/calendar/calendar.js +7 -7
  10. package/cjs/calendar/calendar.js.map +1 -1
  11. package/cjs/data-table/data-table.js +1 -1
  12. package/cjs/data-table/data-table.js.map +1 -1
  13. package/cjs/date-input/date-input.js +1 -1
  14. package/cjs/date-input/date-input.js.map +1 -1
  15. package/cjs/filter/filter-badge.js +2 -0
  16. package/cjs/filter/filter-badge.js.map +1 -0
  17. package/cjs/filter/filter-modal.js +1 -1
  18. package/cjs/filter/filter-modal.js.map +1 -1
  19. package/cjs/filter/filter-modal.styles.js +24 -15
  20. package/cjs/filter/filter-modal.styles.js.map +1 -1
  21. package/cjs/filter/filter-sidebar.js +1 -1
  22. package/cjs/filter/filter-sidebar.js.map +1 -1
  23. package/cjs/filter/filter-sidebar.styles.js +20 -14
  24. package/cjs/filter/filter-sidebar.styles.js.map +1 -1
  25. package/cjs/filter/filter.styles.js +6 -5
  26. package/cjs/filter/filter.styles.js.map +1 -1
  27. package/cjs/form/form-wrapper.js +1 -1
  28. package/cjs/form/form-wrapper.js.map +1 -1
  29. package/cjs/index.js +1 -1
  30. package/cjs/shared/dropdown-wrapper/dropdown-wrapper.styles.js +6 -5
  31. package/cjs/shared/dropdown-wrapper/dropdown-wrapper.styles.js.map +1 -1
  32. package/cjs/shared/internal-calendar/single/single-cell.js +1 -1
  33. package/cjs/shared/internal-calendar/single/single-cell.js.map +1 -1
  34. package/cjs/shared/standalone-date-input/standalone-date-input.js +1 -1
  35. package/cjs/shared/standalone-date-input/standalone-date-input.js.map +1 -1
  36. package/cjs/shared/standalone-date-input/standalone-date-input.style.js +19 -16
  37. package/cjs/shared/standalone-date-input/standalone-date-input.style.js.map +1 -1
  38. package/cjs/theme/colour-primitive/specs/careercompass-colour-set.js +2 -0
  39. package/cjs/theme/colour-primitive/specs/careercompass-colour-set.js.map +1 -0
  40. package/cjs/theme/colour-primitive/specs/spf-colour-set.js +1 -1
  41. package/cjs/theme/colour-primitive/specs/spf-colour-set.js.map +1 -1
  42. package/cjs/theme/colour-primitive/theme-helper.js +1 -1
  43. package/cjs/theme/colour-primitive/theme-helper.js.map +1 -1
  44. package/cjs/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js +1 -1
  45. package/cjs/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js.map +1 -1
  46. package/cjs/theme/colour-semantic/specs/lifesg-semantic-tokens.js +1 -1
  47. package/cjs/theme/colour-semantic/specs/lifesg-semantic-tokens.js.map +1 -1
  48. package/cjs/theme/colour-semantic/specs/pa-semantic-tokens.js +1 -1
  49. package/cjs/theme/colour-semantic/specs/pa-semantic-tokens.js.map +1 -1
  50. package/cjs/theme/colour-semantic/specs/sgwdigitallobby-tokens.js +1 -1
  51. package/cjs/theme/colour-semantic/specs/sgwdigitallobby-tokens.js.map +1 -1
  52. package/cjs/theme/colour-semantic/specs/spf-semantic-tokens.js +2 -0
  53. package/cjs/theme/colour-semantic/specs/spf-semantic-tokens.js.map +1 -0
  54. package/cjs/theme/colour-semantic/theme-helper.js +1 -1
  55. package/cjs/theme/colour-semantic/theme-helper.js.map +1 -1
  56. package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
  57. package/cjs/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
  58. package/cjs/theme/index.js +1 -1
  59. package/cjs/theme/index.js.map +1 -1
  60. package/cjs/timepicker/timepicker.js +1 -1
  61. package/cjs/timepicker/timepicker.js.map +1 -1
  62. package/cjs/timepicker/timepicker.styles.js +4 -3
  63. package/cjs/timepicker/timepicker.styles.js.map +1 -1
  64. package/data-table/data-table.js +1 -1
  65. package/data-table/data-table.js.map +1 -1
  66. package/date-input/date-input.js +1 -1
  67. package/date-input/date-input.js.map +1 -1
  68. package/filter/filter-badge.d.ts +5 -0
  69. package/filter/filter-badge.js +2 -0
  70. package/filter/filter-badge.js.map +1 -0
  71. package/filter/filter-modal.d.ts +1 -1
  72. package/filter/filter-modal.js +1 -1
  73. package/filter/filter-modal.js.map +1 -1
  74. package/filter/filter-modal.styles.d.ts +2 -0
  75. package/filter/filter-modal.styles.js +25 -16
  76. package/filter/filter-modal.styles.js.map +1 -1
  77. package/filter/filter-sidebar.d.ts +1 -1
  78. package/filter/filter-sidebar.js +1 -1
  79. package/filter/filter-sidebar.js.map +1 -1
  80. package/filter/filter-sidebar.styles.d.ts +1 -0
  81. package/filter/filter-sidebar.styles.js +20 -14
  82. package/filter/filter-sidebar.styles.js.map +1 -1
  83. package/filter/filter.d.ts +2 -2
  84. package/filter/filter.styles.js +10 -9
  85. package/filter/filter.styles.js.map +1 -1
  86. package/filter/types.d.ts +1 -0
  87. package/form/form-wrapper.js +1 -1
  88. package/form/form-wrapper.js.map +1 -1
  89. package/index.js +1 -1
  90. package/package.json +17 -1
  91. package/shared/dropdown-wrapper/dropdown-wrapper.styles.js +8 -7
  92. package/shared/dropdown-wrapper/dropdown-wrapper.styles.js.map +1 -1
  93. package/shared/internal-calendar/single/single-cell.js +1 -1
  94. package/shared/internal-calendar/single/single-cell.js.map +1 -1
  95. package/shared/standalone-date-input/standalone-date-input.js +1 -1
  96. package/shared/standalone-date-input/standalone-date-input.js.map +1 -1
  97. package/shared/standalone-date-input/standalone-date-input.style.d.ts +2 -1
  98. package/shared/standalone-date-input/standalone-date-input.style.js +20 -17
  99. package/shared/standalone-date-input/standalone-date-input.style.js.map +1 -1
  100. package/theme/colour-primitive/specs/careercompass-colour-set.d.ts +3 -0
  101. package/theme/colour-primitive/specs/careercompass-colour-set.js +2 -0
  102. package/theme/colour-primitive/specs/careercompass-colour-set.js.map +1 -0
  103. package/theme/colour-primitive/specs/spf-colour-set.js +1 -1
  104. package/theme/colour-primitive/specs/spf-colour-set.js.map +1 -1
  105. package/theme/colour-primitive/theme-helper.js +1 -1
  106. package/theme/colour-primitive/theme-helper.js.map +1 -1
  107. package/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js +1 -1
  108. package/theme/colour-semantic/specs/a11yplayground-semantic-tokens.js.map +1 -1
  109. package/theme/colour-semantic/specs/lifesg-semantic-tokens.js +1 -1
  110. package/theme/colour-semantic/specs/lifesg-semantic-tokens.js.map +1 -1
  111. package/theme/colour-semantic/specs/pa-semantic-tokens.js +1 -1
  112. package/theme/colour-semantic/specs/pa-semantic-tokens.js.map +1 -1
  113. package/theme/colour-semantic/specs/sgwdigitallobby-tokens.js +1 -1
  114. package/theme/colour-semantic/specs/sgwdigitallobby-tokens.js.map +1 -1
  115. package/theme/colour-semantic/specs/spf-semantic-tokens.d.ts +2 -0
  116. package/theme/colour-semantic/specs/spf-semantic-tokens.js +2 -0
  117. package/theme/colour-semantic/specs/spf-semantic-tokens.js.map +1 -0
  118. package/theme/colour-semantic/theme-helper.js +1 -1
  119. package/theme/colour-semantic/theme-helper.js.map +1 -1
  120. package/theme/colour-semantic/types.d.ts +14 -0
  121. package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js +1 -1
  122. package/theme/font-spec/specs/sgw-digital-lobby-font-spec-set.js.map +1 -1
  123. package/theme/index.d.ts +33 -0
  124. package/theme/index.js +1 -1
  125. package/theme/index.js.map +1 -1
  126. package/theme/types.d.ts +2 -2
  127. package/timepicker/timepicker.js +1 -1
  128. package/timepicker/timepicker.js.map +1 -1
  129. package/timepicker/timepicker.styles.d.ts +6 -2
  130. package/timepicker/timepicker.styles.js +3 -2
  131. package/timepicker/timepicker.styles.js.map +1 -1
@@ -1,6 +1,7 @@
1
- "use strict";var e=require("styled-components"),t=require("../shared/input-wrapper/input-wrapper.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e);n.default.div`
1
+ "use strict";var e=require("styled-components"),t=require("../shared/input-wrapper/input-wrapper.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(e);i.default.div`
2
2
  position: relative;
3
- `;const o=n.default(t.BasicInput)`
3
+ `;const n=i.default(t.BasicInput)`
4
4
  height: calc(3rem - 2px); // exclude top and bottom borders
5
- `;exports.InputSelectorElement=o;
5
+ cursor: inherit;
6
+ `;exports.InputSelectorElement=n;
6
7
  //# sourceMappingURL=timepicker.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"timepicker.styles.js","sources":["../../../src/timepicker/timepicker.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { BasicInput } from \"../shared/input-wrapper/input-wrapper\";\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Wrapper = styled.div`\n position: relative;\n`;\n\nexport const InputSelectorElement = styled(BasicInput)`\n height: calc(3rem - 2px); // exclude top and bottom borders\n`;\n"],"names":["styled","div","InputSelectorElement","BasicInput"],"mappings":"yLAMuBA,EAAAA,QAAOC,GAAG;;QAIpBC,EAAuBF,EAAAA,QAAOG,EAAAA,WAAW;;"}
1
+ {"version":3,"file":"timepicker.styles.js","sources":["../../../src/timepicker/timepicker.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { BasicInput } from \"../shared/input-wrapper/input-wrapper\";\n\n// =============================================================================\n// STYLING\n// =============================================================================\nexport const Wrapper = styled.div`\n position: relative;\n`;\n\nexport const InputSelectorElement = styled(BasicInput)<{\n $disabled?: boolean | undefined;\n}>`\n height: calc(3rem - 2px); // exclude top and bottom borders\n cursor: inherit;\n`;\n"],"names":["styled","div","InputSelectorElement","BasicInput"],"mappings":"yLAMuBA,EAAAA,QAAOC,GAAG;;QAIpBC,EAAuBF,EAAAA,QAAOG,EAAAA,WAEzC;;;"}
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as t,jsx as i,Fragment as r}from"react/jsx-runtime";import{ArrowUpIcon as n,ArrowDownIcon as l}from"@lifesg/react-icons";import{useRef as o,useState as d,useCallback as c,useEffect as a}from"react";import{useInView as s}from"../external/react-intersection-observer/index.js";import{useResizeDetector as u}from"../external/react-resize-detector/build/index.esm.js";import"../animations/loading-spinner/loading-spinner.js";import"../animations/loading-dots/loading-dots.js";import{LoadingDotsSpinner as h}from"../animations/loading-dots-spinner/loading-dots-spinner.js";import"styled-components";import{Checkbox as p}from"../checkbox/checkbox.js";import{ErrorDisplay as m}from"../error-display/error-display.js";import"../error-display/helper.js";import{VisuallyHidden as g,concatIds as b}from"../shared/accessibility/index.js";import{Typography as f}from"../typography/typography.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as y}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEventListener as w}from"../util/use-event-listener.js";import{TableWrapper as $,TableContainer as v,Table as C,TableBody as S,HeaderRow as k,EmptyViewCell as j,BodyRow as H,LoaderWrapper as x,ActionBarWrapper as B,ActionBar as R,TextButton as A,HeaderCell as I,CheckBoxWrapper as N,HeaderCellWrapper as V,ErrorDisplayTitle as K,BodyCell as M,BodyCellContent as L}from"./data-table.styles.js";const Y=Y=>{var{id:z,headers:D,rows:E,className:W,sortIndicators:_,alternatingRows:q,loadState:F="success",enableMultiSelect:O,selectedIds:P,disabledIds:T,enableActionBar:G,enableSelectAll:J,enableStickyHeader:Q,emptyView:U,actionBarContent:X,renderCustomEmptyView:Z,onHeaderClick:ee,onSelect:te,onSelectAll:ie,onClearSelectionClick:re}=Y,ne=e(Y,["id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick"]);const le=o(null),oe=o(null),de=o(null),ce=o(null),ae=o(null),se=y(),ue=D.filter((e=>"string"!=typeof e&&!!e.keyColumn)),[he,pe]=d(!1),[me,ge]=d(!1),[be,fe]=d(!1),[ye,we]=d(!1),[$e,ve]=d(!1),{ref:Ce,inView:Se}=s(),ke=c((()=>{if(!ae.current||!ce.current)return;const e=ae.current.scrollHeight>ae.current.clientHeight;pe(e),e?ce.current.style.transform="translateY(0)":Ye()}),[]);a((()=>{ke()}),[]),u({onResize:ke});w("scroll",(()=>{requestAnimationFrame((()=>{he?Le():Ye()})),ae.current&&fe(ae.current.getBoundingClientRect().bottom<=window.innerHeight)}),"window"),a((()=>{ze()}),[E]);const je=()=>(null==P?void 0:P.length)===(null==E?void 0:E.length),He=e=>!!(null==P?void 0:P.includes(e)),xe=e=>!!q&&e%2==1,Be=e=>!!(null==T?void 0:T.includes(e)),Re=e=>{if(ne["data-testid"])return`${ne["data-testid"]}-${e}`},Ae=()=>D.length+(O?1:0),Ie=e=>null==_?void 0:_[e],Ne=e=>{const t=Ie(e);if(t)return"asc"===t?"ascending":"descending"},Ve=e=>` by ${"asc"===Ie(e)?"descending":"ascending"} order`,Ke=(e,t)=>`${se}-row-${e}-${t}-key-column`,Me=e=>{const t=ue.map((t=>Ke(e,t.fieldKey)));return b(...t)},Le=()=>{if(!ae.current)return;const e=ae.current.getBoundingClientRect();we(e.bottom>window.innerHeight+30&&e.top<window.innerHeight-200)},Ye=()=>{if(!(le.current&&oe.current&&ae.current&&ce.current&&de.current))return;const e=oe.current.getBoundingClientRect();if(e.top>window.innerHeight){const t=e.bottom-window.innerHeight,i=le.current.getBoundingClientRect().height-de.current.clientHeight-32,r=Math.min(t,i);ce.current.style.transform=`translateY(-${r}px)`}else ce.current.style.transform="translateY(0)"},ze=()=>{le.current&&ae.current&&ve(le.current.clientHeight+(G?56:0)<ae.current.clientHeight)},De=e=>{const{fieldKey:r,label:n,clickable:l=!1,style:o}="string"==typeof e?{fieldKey:e,label:e,style:void 0}:e,d=!!Ie(r),c=(e=>`${se}-header-${e}`)(r);return t(I,{"data-testid":Re(`header-${r}`),$clickable:l,scope:"col","aria-sort":Ne(r),style:o,$isCheckbox:!1,onClick:()=>(e=>{null==ee||ee(e)})(r),children:[t(V,{id:c,children:["string"==typeof n?i(f.BodyBL,{weight:"bold",children:n}):n,Ee(r)]}),(l||d)&&i(g,{children:t("button",{onClick:e=>((e,t)=>{e.stopPropagation(),null==ee||ee(t)})(e,r),children:[d&&"Sort ",i("span",{"aria-labelledby":c}),d&&Ve(r)]})})]},r)},Ee=e=>{const t=null==_?void 0:_[e];return t?"asc"===t?i(n,{"aria-hidden":!0,"data-testid":Re(`header-${e}-arrowup`)}):i(l,{"aria-hidden":!0,"data-testid":Re(`header-${e}-arrowdown`)}):i(r,{})},We=()=>i(I,{"data-testid":Re("header-selection"),$clickable:!1,$isCheckbox:!0,scope:"col",children:t(N,{children:[i(g,{children:"Row selection"}),J&&i(p,{checked:je(),indeterminate:!!P&&0!==P.length&&!je(),"aria-label":"Select all rows",onClick:()=>{ie&&ie(je())}})]})}),_e=(e,t)=>{const r="string"!=typeof e?e.style:void 0,n="string"==typeof e?e:e.fieldKey,l=t.id.toString(),o=t[n],d=`${l}-${n}`;return i(M,{"data-testid":Re(`row-${d}`),id:Ke(l,n),style:r,$isCheckbox:!1,children:"string"==typeof o||"number"==typeof o?i(L,{children:o}):"function"==typeof o?o(t,{isSelected:He(l)}):o},d)},qe=e=>{const t=e.id.toString();return i(M,{"data-testid":Re(`row-${t}-selection`),$isCheckbox:!0,children:i(N,{children:i(p,{checked:He(t),"aria-labelledby":Me(t),onClick:()=>{te&&te(t,!He(t))},disabled:Be(t),focusableWhenDisabled:Be(t)})})})},Fe=()=>i(m,Object.assign({type:"no-item-found"},U,{title:(null==U?void 0:U.title)?"string"==typeof U.title?i(K,{weight:"bold",children:U.title}):U.title:i(K,{weight:"bold",children:"No <items> found"}),description:(null==U?void 0:U.description)?U.description:"No matching rows"}));return t($,{id:z||"table-wrapper","data-testid":ne["data-testid"]||"table",className:W,ref:ae,onScroll:()=>{he&&ae.current&&ge(ae.current.scrollTop+ae.current.clientHeight>=ae.current.scrollHeight)},tabIndex:0,children:[i(v,{children:t(C,{$end:be,$scrollable:he,ref:le,$stickyHeader:Q,children:[i("thead",{ref:de,children:t(k,{children:[O&&We(),D.map(De)]})}),i(S,{$showLastRowBottomBorder:$e,children:"success"===F?!E||E.length<1?i("tr",{children:i(j,{colSpan:Ae(),children:Z?Z():Fe()})}):i(r,{children:null==E?void 0:E.map(((e,i)=>t(H,{"data-testid":Re(`row-${e.id.toString()}`),$alternating:xe(i),$isSelectable:O,$isSelected:He(e.id.toString()),children:[O&&qe(e),D.map((t=>_e(t,e)))]},e.id.toString())))}):i("tr",{children:i("td",{colSpan:Ae(),children:i(x,{role:"status","aria-live":"polite","aria-label":"Loading table",children:"loading"===F&&i(h,{})})})})})]})}),G&&P&&P.length>0&&(()=>{var e,r,n,l;const o=null!==(e=null==P?void 0:P.length)&&void 0!==e?e:0;return i(B,{ref:ce,$fixed:ye,$left:null===(n=null===(r=null==le?void 0:le.current)||void 0===r?void 0:r.getBoundingClientRect())||void 0===n?void 0:n.left,$width:null===(l=null==le?void 0:le.current)||void 0===l?void 0:l.clientWidth,children:t(R,{$float:(he?!me:!Se)||ye,$scrollable:he,children:[i(f.BodyMD,{weight:"semibold",children:`${o} item${o>1?"s":""} selected`}),i(A,{type:"button","aria-label":`Clear selection of ${o} item${1===o?"":"s"}`,onClick:re,children:"Clear selection"}),X]})})})(),i("div",{ref:e=>{oe.current=e,Ce(e)}})]})};export{Y as DataTable};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as t,jsx as i,Fragment as r}from"react/jsx-runtime";import{ArrowUpIcon as n,ArrowDownIcon as l}from"@lifesg/react-icons";import{useRef as o,useState as d,useCallback as a,useEffect as c}from"react";import{useInView as s}from"../external/react-intersection-observer/index.js";import{useResizeDetector as u}from"../external/react-resize-detector/build/index.esm.js";import"../animations/loading-spinner/loading-spinner.js";import"../animations/loading-dots/loading-dots.js";import{LoadingDotsSpinner as h}from"../animations/loading-dots-spinner/loading-dots-spinner.js";import"styled-components";import{Checkbox as p}from"../checkbox/checkbox.js";import{ErrorDisplay as m}from"../error-display/error-display.js";import"../error-display/helper.js";import{VisuallyHidden as g,concatIds as b}from"../shared/accessibility/index.js";import{Typography as f}from"../typography/typography.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as y}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEventListener as $}from"../util/use-event-listener.js";import{TableWrapper as w,TableContainer as v,Table as C,TableBody as S,HeaderRow as k,BodyRow as j,EmptyViewCell as H,LoaderWrapper as x,ActionBarWrapper as B,ActionBar as R,TextButton as A,HeaderCell as I,CheckBoxWrapper as N,HeaderCellWrapper as V,ErrorDisplayTitle as K,BodyCell as M,BodyCellContent as L}from"./data-table.styles.js";const Y=Y=>{var{id:z,headers:D,rows:E,className:W,sortIndicators:_,alternatingRows:q,loadState:F="success",enableMultiSelect:O,selectedIds:P,disabledIds:T,enableActionBar:G,enableSelectAll:J,enableStickyHeader:Q,emptyView:U,actionBarContent:X,renderCustomEmptyView:Z,onHeaderClick:ee,onSelect:te,onSelectAll:ie,onClearSelectionClick:re}=Y,ne=e(Y,["id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick"]);const le=o(null),oe=o(null),de=o(null),ae=o(null),ce=o(null),se=y(),ue=D.filter((e=>"string"!=typeof e&&!!e.keyColumn)),[he,pe]=d(!1),[me,ge]=d(!1),[be,fe]=d(!1),[ye,$e]=d(!1),[we,ve]=d(!1),{ref:Ce,inView:Se}=s(),ke=a((()=>{if(!ce.current||!ae.current)return;const e=ce.current.scrollHeight>ce.current.clientHeight;pe(e),e?ae.current.style.transform="translateY(0)":Ye()}),[]);c((()=>{ke()}),[]),u({onResize:ke});$("scroll",(()=>{requestAnimationFrame((()=>{he?Le():Ye()})),ce.current&&fe(ce.current.getBoundingClientRect().bottom<=window.innerHeight)}),"window"),c((()=>{ze()}),[E]);const je=()=>!!(E&&E.length&&P)&&P.length===E.length,He=e=>!!(null==P?void 0:P.includes(e)),xe=e=>!!q&&e%2==1,Be=e=>!!(null==T?void 0:T.includes(e)),Re=e=>{if(ne["data-testid"])return`${ne["data-testid"]}-${e}`},Ae=()=>D.length+(O?1:0),Ie=e=>null==_?void 0:_[e],Ne=e=>{const t=Ie(e);if(t)return"asc"===t?"ascending":"descending"},Ve=e=>` by ${"asc"===Ie(e)?"descending":"ascending"} order`,Ke=(e,t)=>`${se}-row-${e}-${t}-key-column`,Me=e=>{const t=ue.map((t=>Ke(e,t.fieldKey)));return b(...t)},Le=()=>{if(!ce.current)return;const e=ce.current.getBoundingClientRect();$e(e.bottom>window.innerHeight+30&&e.top<window.innerHeight-200)},Ye=()=>{if(!(le.current&&oe.current&&ce.current&&ae.current&&de.current))return;const e=oe.current.getBoundingClientRect();if(e.top>window.innerHeight){const t=e.bottom-window.innerHeight,i=le.current.getBoundingClientRect().height-de.current.clientHeight-32,r=Math.min(t,i);ae.current.style.transform=`translateY(-${r}px)`}else ae.current.style.transform="translateY(0)"},ze=()=>{le.current&&ce.current&&ve(le.current.clientHeight+(G?56:0)<ce.current.clientHeight)},De=e=>{const{fieldKey:r,label:n,clickable:l=!1,style:o}="string"==typeof e?{fieldKey:e,label:e,style:void 0}:e,d=!!Ie(r),a=(e=>`${se}-header-${e}`)(r);return t(I,{"data-testid":Re(`header-${r}`),$clickable:l,scope:"col","aria-sort":Ne(r),style:o,$isCheckbox:!1,onClick:()=>(e=>{null==ee||ee(e)})(r),children:[t(V,{id:a,children:["string"==typeof n?i(f.BodyBL,{weight:"bold",children:n}):n,Ee(r)]}),(l||d)&&i(g,{children:t("button",{onClick:e=>((e,t)=>{e.stopPropagation(),null==ee||ee(t)})(e,r),children:[d&&"Sort ",i("span",{"aria-labelledby":a}),d&&Ve(r)]})})]},r)},Ee=e=>{const t=null==_?void 0:_[e];return t?"asc"===t?i(n,{"aria-hidden":!0,"data-testid":Re(`header-${e}-arrowup`)}):i(l,{"aria-hidden":!0,"data-testid":Re(`header-${e}-arrowdown`)}):i(r,{})},We=()=>i(I,{"data-testid":Re("header-selection"),$clickable:!1,$isCheckbox:!0,scope:"col",children:t(N,{children:[i(g,{children:"Row selection"}),J&&i(p,{checked:je(),indeterminate:!!P&&0!==P.length&&!je(),disabled:!E||!E.length||!P,"aria-label":"Select all rows",onClick:()=>{ie&&ie(je())}})]})}),_e=(e,t)=>{const r="string"!=typeof e?e.style:void 0,n="string"==typeof e?e:e.fieldKey,l=t.id.toString(),o=t[n],d=`${l}-${n}`;return i(M,{"data-testid":Re(`row-${d}`),id:Ke(l,n),style:r,$isCheckbox:!1,children:"string"==typeof o||"number"==typeof o?i(L,{children:o}):"function"==typeof o?o(t,{isSelected:He(l)}):o},d)},qe=e=>{const t=e.id.toString();return i(M,{"data-testid":Re(`row-${t}-selection`),$isCheckbox:!0,children:i(N,{children:i(p,{checked:He(t),"aria-labelledby":Me(t),onClick:()=>{te&&te(t,!He(t))},disabled:Be(t),focusableWhenDisabled:Be(t)})})})},Fe=()=>i(m,Object.assign({type:"no-item-found"},U,{title:(null==U?void 0:U.title)?"string"==typeof U.title?i(K,{weight:"bold",children:U.title}):U.title:i(K,{weight:"bold",children:"No <items> found"}),description:(null==U?void 0:U.description)?U.description:"No matching rows"}));return t(w,{id:z||"table-wrapper","data-testid":ne["data-testid"]||"table",className:W,ref:ce,onScroll:()=>{he&&ce.current&&ge(ce.current.scrollTop+ce.current.clientHeight>=ce.current.scrollHeight)},tabIndex:0,children:[i(v,{children:t(C,{$end:be,$scrollable:he,ref:le,$stickyHeader:Q,children:[i("thead",{ref:de,children:t(k,{children:[O&&We(),D.map(De)]})}),i(S,{$showLastRowBottomBorder:we,children:"success"===F?!E||E.length<1?i(j,{$alternating:!1,children:i(H,{colSpan:Ae(),children:Z?Z():Fe()})}):i(r,{children:null==E?void 0:E.map(((e,i)=>t(j,{"data-testid":Re(`row-${e.id.toString()}`),$alternating:xe(i),$isSelectable:O,$isSelected:He(e.id.toString()),children:[O&&qe(e),D.map((t=>_e(t,e)))]},e.id.toString())))}):i(j,{$alternating:!1,children:i("td",{colSpan:Ae(),children:i(x,{role:"status","aria-live":"polite","aria-label":"Loading table",children:"loading"===F&&i(h,{})})})})})]})}),G&&P&&P.length>0&&(()=>{var e,r,n,l;const o=null!==(e=null==P?void 0:P.length)&&void 0!==e?e:0;return i(B,{ref:ae,$fixed:ye,$left:null===(n=null===(r=null==le?void 0:le.current)||void 0===r?void 0:r.getBoundingClientRect())||void 0===n?void 0:n.left,$width:null===(l=null==le?void 0:le.current)||void 0===l?void 0:l.clientWidth,children:t(R,{$float:(he?!me:!Se)||ye,$scrollable:he,children:[i(f.BodyMD,{weight:"semibold",children:`${o} item${o>1?"s":""} selected`}),i(A,{type:"button","aria-label":`Clear selection of ${o} item${1===o?"":"s"}`,onClick:re,children:"Clear selection"}),X]})})})(),i("div",{ref:e=>{oe.current=e,Ce(e)}})]})};export{Y as DataTable};
2
2
  //# sourceMappingURL=data-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.js","sources":["../../src/data-table/data-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from \"@lifesg/react-icons\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\nimport { useResizeDetector } from \"react-resize-detector\";\nimport { LoadingDotsSpinner } from \"../animations\";\nimport { Checkbox } from \"../checkbox\";\nimport { ErrorDisplay } from \"../error-display\";\nimport { VisuallyHidden, concatIds } from \"../shared/accessibility\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport { useEventListener } from \"../util/use-event-listener\";\nimport {\n ActionBar,\n ActionBarWrapper,\n BodyCell,\n BodyCellContent,\n BodyRow,\n CheckBoxWrapper,\n EmptyViewCell,\n ErrorDisplayTitle,\n HeaderCell,\n HeaderCellWrapper,\n HeaderRow,\n LoaderWrapper,\n Table,\n TableBody,\n TableContainer,\n TableWrapper,\n TextButton,\n} from \"./data-table.styles\";\nimport { DataTableProps, HeaderProps, RowProps } from \"./types\";\n\nexport const DataTable = ({\n id,\n headers,\n rows,\n className,\n sortIndicators,\n alternatingRows,\n loadState = \"success\",\n enableMultiSelect,\n selectedIds,\n disabledIds,\n enableActionBar,\n enableSelectAll,\n enableStickyHeader,\n emptyView,\n actionBarContent,\n renderCustomEmptyView,\n onHeaderClick,\n onSelect,\n onSelectAll,\n onClearSelectionClick,\n ...otherProps\n}: DataTableProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const tableRef = useRef<HTMLTableElement>(null);\n const tableEndRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLTableSectionElement>(null);\n const actionBarRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const internalId = useId();\n const keyColumns = headers.filter(\n (header): header is Exclude<HeaderProps, string> => {\n return typeof header !== \"string\" && !!header.keyColumn;\n }\n );\n\n const [scrollable, setScrollable] = useState(false);\n const [scrollEnd, setScrollEnd] = useState(false);\n const [tableEnd, setTableEnd] = useState(false);\n const [isFloatingActionBar, setIsFloatingActionBar] = useState(false);\n const [showLastBorder, setShowLastBorder] = useState(false);\n\n const { ref: endRef, inView: end } = useInView();\n\n // =============================================================================\n // EFFECTS, EVENT LISTENERS\n // ============================================================================\n const onResize = useCallback(() => {\n if (!wrapperRef.current || !actionBarRef.current) {\n return;\n }\n const scrollable =\n wrapperRef.current.scrollHeight > wrapperRef.current.clientHeight;\n setScrollable(scrollable);\n\n if (scrollable) {\n actionBarRef.current.style.transform = `translateY(0)`;\n } else {\n calculateStickyInViewport();\n }\n }, []);\n\n useEffect(() => {\n onResize();\n }, []);\n\n useResizeDetector({ onResize });\n\n const scrollHandler = () => {\n requestAnimationFrame(() => {\n if (scrollable) {\n calculateFixedInViewport();\n } else {\n calculateStickyInViewport();\n }\n });\n\n if (wrapperRef.current) {\n setTableEnd(\n wrapperRef.current.getBoundingClientRect().bottom <=\n window.innerHeight\n );\n }\n };\n\n useEventListener(\"scroll\", scrollHandler, \"window\");\n\n useEffect(() => {\n checkLastBorder();\n }, [rows]);\n\n // ===========================================================================\n // HELPER FUNCTIONS\n // ===========================================================================\n const isAllCheckboxSelected = (): boolean => {\n return selectedIds?.length === rows?.length;\n };\n\n const isIndeterminateCheckbox = (): boolean => {\n return (\n !!selectedIds &&\n selectedIds.length !== 0 &&\n !isAllCheckboxSelected()\n );\n };\n\n const isRowSelected = (rowId: string): boolean => {\n return !!selectedIds?.includes(rowId);\n };\n\n const isAlternatingRow = (index: number): boolean => {\n return !!alternatingRows && index % 2 === 1;\n };\n\n const isDisabledRow = (rowId: string): boolean => {\n return !!disabledIds?.includes(rowId);\n };\n\n const getDataTestId = (subStr: string) => {\n if (!otherProps[\"data-testid\"]) return undefined;\n return `${otherProps[\"data-testid\"]}-${subStr}`;\n };\n\n const getTotalColumns = (): number => {\n return headers.length + (enableMultiSelect ? 1 : 0);\n };\n\n const getSortDirection = (fieldKey: string) => {\n return sortIndicators?.[fieldKey];\n };\n\n const getHeaderAriaSort = (fieldKey: string) => {\n const sortDirection = getSortDirection(fieldKey);\n\n if (!sortDirection) {\n return undefined;\n }\n\n return sortDirection === \"asc\" ? \"ascending\" : \"descending\";\n };\n\n const getSortButtonAriaLabel = (fieldKey: string) => {\n const nextSortDirection =\n getSortDirection(fieldKey) === \"asc\" ? \"descending\" : \"ascending\";\n\n return ` by ${nextSortDirection} order`;\n };\n\n const getHeaderWrapperId = (fieldKey: string) => {\n return `${internalId}-header-${fieldKey}`;\n };\n const getCellId = (rowId: string, fieldKey: string) => {\n return `${internalId}-row-${rowId}-${fieldKey}-key-column`;\n };\n\n const getRowCheckboxAriaLabelledBy = (rowId: string) => {\n const keyColumnIds = keyColumns.map((header) =>\n getCellId(rowId, header.fieldKey)\n );\n\n return concatIds(...keyColumnIds);\n };\n\n const calculateFixedInViewport = () => {\n if (!wrapperRef.current) {\n return;\n }\n const wrapperBounds = wrapperRef.current.getBoundingClientRect();\n setIsFloatingActionBar(\n wrapperBounds.bottom > window.innerHeight + 30 &&\n wrapperBounds.top < window.innerHeight - 200\n );\n };\n\n const calculateStickyInViewport = () => {\n if (\n !tableRef.current ||\n !tableEndRef.current ||\n !wrapperRef.current ||\n !actionBarRef.current ||\n !headerRef.current\n ) {\n return;\n }\n\n const endBounds = tableEndRef.current.getBoundingClientRect();\n\n if (endBounds.top > window.innerHeight) {\n const bottomOffset = endBounds.bottom - window.innerHeight;\n const bottomToHeaderOffset =\n tableRef.current.getBoundingClientRect().height -\n headerRef.current.clientHeight -\n 32;\n const maxBottomOffset = Math.min(\n bottomOffset,\n bottomToHeaderOffset\n );\n\n actionBarRef.current.style.transform = `translateY(-${maxBottomOffset}px)`;\n } else {\n actionBarRef.current.style.transform = `translateY(0)`;\n }\n };\n\n const checkLastBorder = () => {\n if (!tableRef.current || !wrapperRef.current) {\n return;\n }\n // 56 pixels added due to the behavior of action bar\n setShowLastBorder(\n tableRef.current.clientHeight + (enableActionBar ? 56 : 0) <\n wrapperRef.current.clientHeight\n );\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleHeaderClick = (fieldKey: string) => {\n onHeaderClick?.(fieldKey);\n };\n\n const handleHeaderButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>,\n fieldKey: string\n ) => {\n event.stopPropagation();\n onHeaderClick?.(fieldKey);\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderHeaders = () => (\n <thead ref={headerRef}>\n <HeaderRow>\n {enableMultiSelect && renderHeaderCheckBox()}\n {headers.map(renderHeaderCell)}\n </HeaderRow>\n </thead>\n );\n\n const renderHeaderCell = (header: HeaderProps) => {\n const {\n fieldKey,\n label,\n clickable = false,\n style,\n } = typeof header === \"string\"\n ? {\n fieldKey: header,\n label: header,\n style: undefined,\n }\n : header;\n\n const isSortable = !!getSortDirection(fieldKey);\n const headerCellWrapperId = getHeaderWrapperId(fieldKey);\n\n return (\n <HeaderCell\n data-testid={getDataTestId(`header-${fieldKey}`)}\n key={fieldKey}\n $clickable={clickable}\n scope=\"col\"\n aria-sort={getHeaderAriaSort(fieldKey)}\n style={style}\n $isCheckbox={false}\n onClick={() => handleHeaderClick(fieldKey)}\n >\n <HeaderCellWrapper id={headerCellWrapperId}>\n {typeof label === \"string\" ? (\n <Typography.BodyBL weight=\"bold\">\n {label}\n </Typography.BodyBL>\n ) : (\n label\n )}\n {renderSortedArrow(fieldKey)}\n </HeaderCellWrapper>\n {(clickable || isSortable) && (\n <VisuallyHidden>\n <button\n onClick={(event) =>\n handleHeaderButtonClick(event, fieldKey)\n }\n >\n {isSortable && \"Sort \"}\n <span aria-labelledby={headerCellWrapperId} />\n {isSortable && getSortButtonAriaLabel(fieldKey)}\n </button>\n </VisuallyHidden>\n )}\n </HeaderCell>\n );\n };\n\n const renderSortedArrow = (fieldKey: string) => {\n const isSorted = sortIndicators?.[fieldKey];\n\n if (!isSorted) {\n return <></>;\n }\n if (isSorted === \"asc\") {\n return (\n <ArrowUpIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowup`)}\n />\n );\n }\n return (\n <ArrowDownIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowdown`)}\n />\n );\n };\n\n const renderHeaderCheckBox = () => {\n return (\n <HeaderCell\n data-testid={getDataTestId(\"header-selection\")}\n $clickable={false}\n $isCheckbox={true}\n scope=\"col\"\n >\n <CheckBoxWrapper>\n <VisuallyHidden>Row selection</VisuallyHidden>\n {enableSelectAll && (\n <Checkbox\n checked={isAllCheckboxSelected()}\n indeterminate={isIndeterminateCheckbox()}\n aria-label=\"Select all rows\"\n onClick={() => {\n if (onSelectAll) {\n onSelectAll(isAllCheckboxSelected());\n }\n }}\n />\n )}\n </CheckBoxWrapper>\n </HeaderCell>\n );\n };\n\n const renderRows = () => {\n return !rows || rows.length < 1 ? (\n <tr>\n <EmptyViewCell colSpan={getTotalColumns()}>\n {renderCustomEmptyView\n ? renderCustomEmptyView()\n : renderBasicEmptyView()}\n </EmptyViewCell>\n </tr>\n ) : (\n <>\n {rows?.map((row: RowProps, index: number) => (\n <BodyRow\n data-testid={getDataTestId(`row-${row.id.toString()}`)}\n key={row.id.toString()}\n $alternating={isAlternatingRow(index)}\n $isSelectable={enableMultiSelect}\n $isSelected={isRowSelected(row.id.toString())}\n >\n {enableMultiSelect && renderRowCheckBox(row)}\n\n {headers.map((header) => renderRowCell(header, row))}\n </BodyRow>\n ))}\n </>\n );\n };\n\n const renderRowCell = (header: HeaderProps, row: RowProps) => {\n const style = typeof header !== \"string\" ? header.style : undefined;\n const fieldKey = typeof header === \"string\" ? header : header.fieldKey;\n const rowId = row.id.toString();\n const cellData = row[fieldKey];\n const cellId = `${rowId}-${fieldKey}`;\n\n return (\n <BodyCell\n data-testid={getDataTestId(`row-${cellId}`)}\n key={cellId}\n id={getCellId(rowId, fieldKey)}\n style={style}\n $isCheckbox={false}\n >\n {typeof cellData === \"string\" ||\n typeof cellData === \"number\" ? (\n <BodyCellContent>{cellData}</BodyCellContent>\n ) : typeof cellData === \"function\" ? (\n cellData(row, { isSelected: isRowSelected(rowId) })\n ) : (\n cellData\n )}\n </BodyCell>\n );\n };\n\n const renderRowCheckBox = (row: RowProps) => {\n const rowId = row.id.toString();\n\n return (\n <BodyCell\n data-testid={getDataTestId(`row-${rowId}-selection`)}\n $isCheckbox={true}\n >\n <CheckBoxWrapper>\n <Checkbox\n checked={isRowSelected(rowId)}\n aria-labelledby={getRowCheckboxAriaLabelledBy(rowId)}\n onClick={() => {\n if (onSelect) {\n onSelect(rowId, !isRowSelected(rowId));\n }\n }}\n disabled={isDisabledRow(rowId)}\n focusableWhenDisabled={isDisabledRow(rowId)}\n />\n </CheckBoxWrapper>\n </BodyCell>\n );\n };\n\n const renderBasicEmptyView = () => {\n return (\n <ErrorDisplay\n type={\"no-item-found\"}\n {...emptyView}\n title={\n emptyView?.title ? (\n typeof emptyView.title === \"string\" ? (\n <ErrorDisplayTitle weight=\"bold\">\n {emptyView.title}\n </ErrorDisplayTitle>\n ) : (\n emptyView.title\n )\n ) : (\n <ErrorDisplayTitle weight=\"bold\">\n {\"No <items> found\"}\n </ErrorDisplayTitle>\n )\n }\n description={\n emptyView?.description\n ? emptyView.description\n : \"No matching rows\"\n }\n />\n );\n };\n\n const renderLoader = () => {\n return (\n <tr>\n <td colSpan={getTotalColumns()}>\n <LoaderWrapper\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"Loading table\"\n >\n {loadState === \"loading\" && <LoadingDotsSpinner />}\n </LoaderWrapper>\n </td>\n </tr>\n );\n };\n\n const renderSelectionBar = () => {\n const count = selectedIds?.length ?? 0;\n\n return (\n <ActionBarWrapper\n ref={actionBarRef}\n $fixed={isFloatingActionBar}\n $left={tableRef?.current?.getBoundingClientRect()?.left}\n $width={tableRef?.current?.clientWidth}\n >\n <ActionBar\n $float={\n (scrollable ? !scrollEnd : !end) || isFloatingActionBar\n }\n $scrollable={scrollable}\n >\n <Typography.BodyMD weight=\"semibold\">{`${count} item${\n count > 1 ? \"s\" : \"\"\n } selected`}</Typography.BodyMD>\n <TextButton\n type=\"button\"\n aria-label={`Clear selection of ${count} item${\n count === 1 ? \"\" : \"s\"\n }`}\n onClick={onClearSelectionClick}\n >\n Clear selection\n </TextButton>\n {actionBarContent}\n </ActionBar>\n </ActionBarWrapper>\n );\n };\n\n return (\n <TableWrapper\n id={id || \"table-wrapper\"}\n data-testid={otherProps[\"data-testid\"] || \"table\"}\n className={className}\n ref={wrapperRef}\n onScroll={() => {\n if (scrollable && wrapperRef.current) {\n setScrollEnd(\n wrapperRef.current.scrollTop +\n wrapperRef.current.clientHeight >=\n wrapperRef.current.scrollHeight\n );\n }\n }}\n tabIndex={0} // scrollable container must be focusable to support keyboard users\n >\n <TableContainer>\n <Table\n $end={tableEnd}\n $scrollable={scrollable}\n ref={tableRef}\n $stickyHeader={enableStickyHeader}\n >\n {renderHeaders()}\n <TableBody $showLastRowBottomBorder={showLastBorder}>\n {loadState === \"success\"\n ? renderRows()\n : renderLoader()}\n </TableBody>\n </Table>\n </TableContainer>\n {enableActionBar &&\n selectedIds &&\n selectedIds.length > 0 &&\n renderSelectionBar()}\n <div\n ref={(r) => {\n tableEndRef.current = r;\n endRef(r);\n }}\n />\n </TableWrapper>\n );\n};\n"],"names":["DataTable","_a","id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick","otherProps","__rest","tableRef","useRef","tableEndRef","headerRef","actionBarRef","wrapperRef","internalId","useId","keyColumns","filter","header","keyColumn","scrollable","setScrollable","useState","scrollEnd","setScrollEnd","tableEnd","setTableEnd","isFloatingActionBar","setIsFloatingActionBar","showLastBorder","setShowLastBorder","ref","endRef","inView","end","useInView","onResize","useCallback","current","scrollHeight","clientHeight","style","transform","calculateStickyInViewport","useEffect","useResizeDetector","useEventListener","requestAnimationFrame","calculateFixedInViewport","getBoundingClientRect","bottom","window","innerHeight","checkLastBorder","isAllCheckboxSelected","length","isRowSelected","rowId","includes","isAlternatingRow","index","isDisabledRow","getDataTestId","subStr","getTotalColumns","getSortDirection","fieldKey","getHeaderAriaSort","sortDirection","getSortButtonAriaLabel","getCellId","getRowCheckboxAriaLabelledBy","keyColumnIds","map","concatIds","wrapperBounds","top","endBounds","bottomOffset","bottomToHeaderOffset","height","maxBottomOffset","Math","min","renderHeaderCell","label","clickable","undefined","isSortable","headerCellWrapperId","getHeaderWrapperId","_jsxs","HeaderCell","$clickable","scope","$isCheckbox","onClick","handleHeaderClick","children","HeaderCellWrapper","_jsx","Typography","BodyBL","weight","renderSortedArrow","VisuallyHidden","event","stopPropagation","handleHeaderButtonClick","isSorted","ArrowUpIcon","ArrowDownIcon","renderHeaderCheckBox","CheckBoxWrapper","Checkbox","checked","indeterminate","renderRowCell","row","toString","cellData","cellId","BodyCell","BodyCellContent","isSelected","renderRowCheckBox","disabled","focusableWhenDisabled","renderBasicEmptyView","ErrorDisplay","Object","assign","type","title","ErrorDisplayTitle","description","TableWrapper","onScroll","scrollTop","tabIndex","TableContainer","Table","$end","$stickyHeader","HeaderRow","TableBody","$showLastRowBottomBorder","EmptyViewCell","colSpan","BodyRow","$alternating","$isSelectable","$isSelected","LoaderWrapper","role","LoadingDotsSpinner","count","ActionBarWrapper","$fixed","$left","_c","_b","left","$width","_d","clientWidth","ActionBar","$float","$scrollable","BodyMD","TextButton","renderSelectionBar","r"],"mappings":"kiDAgCO,MAAMA,EAAaC,QAAAC,GACtBA,EAAEC,QACFA,EAAOC,KACPA,EAAIC,UACJA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,UACfA,EAAY,UAASC,kBACrBA,EAAiBC,YACjBA,EAAWC,YACXA,EAAWC,gBACXA,EAAeC,gBACfA,EAAeC,mBACfA,EAAkBC,UAClBA,EAASC,iBACTA,EAAgBC,sBAChBA,EAAqBC,cACrBA,GAAaC,SACbA,GAAQC,YACRA,GAAWC,sBACXA,MACGC,GAAUC,EAAAtB,EArBS,CAAA,KAAA,UAAA,OAAA,YAAA,iBAAA,kBAAA,YAAA,oBAAA,cAAA,cAAA,kBAAA,kBAAA,qBAAA,YAAA,mBAAA,wBAAA,gBAAA,WAAA,cAAA,0BA0BtB,MAAMuB,GAAWC,EAAyB,MACpCC,GAAcD,EAA8B,MAC5CE,GAAYF,EAAgC,MAC5CG,GAAeH,EAAuB,MACtCI,GAAaJ,EAAuB,MACpCK,GAAaC,IACbC,GAAa7B,EAAQ8B,QACtBC,GAC4B,iBAAXA,KAAyBA,EAAOC,aAI/CC,GAAYC,IAAiBC,GAAS,IACtCC,GAAW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C,OAC9B,QAAjBC,EAAA5J,cAAQ,EAARA,GAAU8B,eAAO,IAAA8H,OAAA,EAAAA,EAAEC,YAAWnE,SAEtCP,EAAC2E,EAAS,CAAAC,QAEDnJ,IAAcG,IAAaW,KAAQP,GAAmB6I,YAE9CpJ,GAAU8E,SAAA,CAEvBE,EAACC,EAAWoE,OAAM,CAAClE,OAAO,WAAUL,SAAE,GAAG0D,SACrCA,EAAQ,EAAI,IAAM,gBAEtBxD,EAACsE,EAAU,CACPtC,KAAK,SAAQ,aACD,sBAAsBwB,SACpB,IAAVA,EAAc,GAAK,MAEvB5D,QAAS3F,GAAqB6F,SAAA,oBAIjClG,MAEU,EAuCf2K,GACJvE,EAAA,MAAA,CACIrE,IAAM6I,IACFlK,GAAY4B,QAAUsI,EACtB5I,GAAO4I,EAAE,MAGN"}
1
+ {"version":3,"file":"data-table.js","sources":["../../src/data-table/data-table.tsx"],"sourcesContent":["import { ArrowDownIcon, ArrowUpIcon } from \"@lifesg/react-icons\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useInView } from \"react-intersection-observer\";\nimport { useResizeDetector } from \"react-resize-detector\";\nimport { LoadingDotsSpinner } from \"../animations\";\nimport { Checkbox } from \"../checkbox\";\nimport { ErrorDisplay } from \"../error-display\";\nimport { VisuallyHidden, concatIds } from \"../shared/accessibility\";\nimport { Typography } from \"../typography\";\nimport { useId } from \"../util\";\nimport { useEventListener } from \"../util/use-event-listener\";\nimport {\n ActionBar,\n ActionBarWrapper,\n BodyCell,\n BodyCellContent,\n BodyRow,\n CheckBoxWrapper,\n EmptyViewCell,\n ErrorDisplayTitle,\n HeaderCell,\n HeaderCellWrapper,\n HeaderRow,\n LoaderWrapper,\n Table,\n TableBody,\n TableContainer,\n TableWrapper,\n TextButton,\n} from \"./data-table.styles\";\nimport { DataTableProps, HeaderProps, RowProps } from \"./types\";\n\nexport const DataTable = ({\n id,\n headers,\n rows,\n className,\n sortIndicators,\n alternatingRows,\n loadState = \"success\",\n enableMultiSelect,\n selectedIds,\n disabledIds,\n enableActionBar,\n enableSelectAll,\n enableStickyHeader,\n emptyView,\n actionBarContent,\n renderCustomEmptyView,\n onHeaderClick,\n onSelect,\n onSelectAll,\n onClearSelectionClick,\n ...otherProps\n}: DataTableProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const tableRef = useRef<HTMLTableElement>(null);\n const tableEndRef = useRef<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLTableSectionElement>(null);\n const actionBarRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const internalId = useId();\n const keyColumns = headers.filter(\n (header): header is Exclude<HeaderProps, string> => {\n return typeof header !== \"string\" && !!header.keyColumn;\n }\n );\n\n const [scrollable, setScrollable] = useState(false);\n const [scrollEnd, setScrollEnd] = useState(false);\n const [tableEnd, setTableEnd] = useState(false);\n const [isFloatingActionBar, setIsFloatingActionBar] = useState(false);\n const [showLastBorder, setShowLastBorder] = useState(false);\n\n const { ref: endRef, inView: end } = useInView();\n\n // =============================================================================\n // EFFECTS, EVENT LISTENERS\n // ============================================================================\n const onResize = useCallback(() => {\n if (!wrapperRef.current || !actionBarRef.current) {\n return;\n }\n const scrollable =\n wrapperRef.current.scrollHeight > wrapperRef.current.clientHeight;\n setScrollable(scrollable);\n\n if (scrollable) {\n actionBarRef.current.style.transform = `translateY(0)`;\n } else {\n calculateStickyInViewport();\n }\n }, []);\n\n useEffect(() => {\n onResize();\n }, []);\n\n useResizeDetector({ onResize });\n\n const scrollHandler = () => {\n requestAnimationFrame(() => {\n if (scrollable) {\n calculateFixedInViewport();\n } else {\n calculateStickyInViewport();\n }\n });\n\n if (wrapperRef.current) {\n setTableEnd(\n wrapperRef.current.getBoundingClientRect().bottom <=\n window.innerHeight\n );\n }\n };\n\n useEventListener(\"scroll\", scrollHandler, \"window\");\n\n useEffect(() => {\n checkLastBorder();\n }, [rows]);\n\n // ===========================================================================\n // HELPER FUNCTIONS\n // ===========================================================================\n const isAllCheckboxSelected = (): boolean => {\n if (!rows || !rows.length || !selectedIds) {\n return false;\n }\n\n return selectedIds.length === rows.length;\n };\n\n const isIndeterminateCheckbox = (): boolean => {\n return (\n !!selectedIds &&\n selectedIds.length !== 0 &&\n !isAllCheckboxSelected()\n );\n };\n\n const isHeaderCheckboxDisabled = (): boolean => {\n return !rows || !rows.length || !selectedIds;\n };\n\n const isRowSelected = (rowId: string): boolean => {\n return !!selectedIds?.includes(rowId);\n };\n\n const isAlternatingRow = (index: number): boolean => {\n return !!alternatingRows && index % 2 === 1;\n };\n\n const isDisabledRow = (rowId: string): boolean => {\n return !!disabledIds?.includes(rowId);\n };\n\n const getDataTestId = (subStr: string) => {\n if (!otherProps[\"data-testid\"]) return undefined;\n return `${otherProps[\"data-testid\"]}-${subStr}`;\n };\n\n const getTotalColumns = (): number => {\n return headers.length + (enableMultiSelect ? 1 : 0);\n };\n\n const getSortDirection = (fieldKey: string) => {\n return sortIndicators?.[fieldKey];\n };\n\n const getHeaderAriaSort = (fieldKey: string) => {\n const sortDirection = getSortDirection(fieldKey);\n\n if (!sortDirection) {\n return undefined;\n }\n\n return sortDirection === \"asc\" ? \"ascending\" : \"descending\";\n };\n\n const getSortButtonAriaLabel = (fieldKey: string) => {\n const nextSortDirection =\n getSortDirection(fieldKey) === \"asc\" ? \"descending\" : \"ascending\";\n\n return ` by ${nextSortDirection} order`;\n };\n\n const getHeaderWrapperId = (fieldKey: string) => {\n return `${internalId}-header-${fieldKey}`;\n };\n const getCellId = (rowId: string, fieldKey: string) => {\n return `${internalId}-row-${rowId}-${fieldKey}-key-column`;\n };\n\n const getRowCheckboxAriaLabelledBy = (rowId: string) => {\n const keyColumnIds = keyColumns.map((header) =>\n getCellId(rowId, header.fieldKey)\n );\n\n return concatIds(...keyColumnIds);\n };\n\n const calculateFixedInViewport = () => {\n if (!wrapperRef.current) {\n return;\n }\n const wrapperBounds = wrapperRef.current.getBoundingClientRect();\n setIsFloatingActionBar(\n wrapperBounds.bottom > window.innerHeight + 30 &&\n wrapperBounds.top < window.innerHeight - 200\n );\n };\n\n const calculateStickyInViewport = () => {\n if (\n !tableRef.current ||\n !tableEndRef.current ||\n !wrapperRef.current ||\n !actionBarRef.current ||\n !headerRef.current\n ) {\n return;\n }\n\n const endBounds = tableEndRef.current.getBoundingClientRect();\n\n if (endBounds.top > window.innerHeight) {\n const bottomOffset = endBounds.bottom - window.innerHeight;\n const bottomToHeaderOffset =\n tableRef.current.getBoundingClientRect().height -\n headerRef.current.clientHeight -\n 32;\n const maxBottomOffset = Math.min(\n bottomOffset,\n bottomToHeaderOffset\n );\n\n actionBarRef.current.style.transform = `translateY(-${maxBottomOffset}px)`;\n } else {\n actionBarRef.current.style.transform = `translateY(0)`;\n }\n };\n\n const checkLastBorder = () => {\n if (!tableRef.current || !wrapperRef.current) {\n return;\n }\n // 56 pixels added due to the behavior of action bar\n setShowLastBorder(\n tableRef.current.clientHeight + (enableActionBar ? 56 : 0) <\n wrapperRef.current.clientHeight\n );\n };\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleHeaderClick = (fieldKey: string) => {\n onHeaderClick?.(fieldKey);\n };\n\n const handleHeaderButtonClick = (\n event: React.MouseEvent<HTMLButtonElement>,\n fieldKey: string\n ) => {\n event.stopPropagation();\n onHeaderClick?.(fieldKey);\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderHeaders = () => (\n <thead ref={headerRef}>\n <HeaderRow>\n {enableMultiSelect && renderHeaderCheckBox()}\n {headers.map(renderHeaderCell)}\n </HeaderRow>\n </thead>\n );\n\n const renderHeaderCell = (header: HeaderProps) => {\n const {\n fieldKey,\n label,\n clickable = false,\n style,\n } = typeof header === \"string\"\n ? {\n fieldKey: header,\n label: header,\n style: undefined,\n }\n : header;\n\n const isSortable = !!getSortDirection(fieldKey);\n const headerCellWrapperId = getHeaderWrapperId(fieldKey);\n\n return (\n <HeaderCell\n data-testid={getDataTestId(`header-${fieldKey}`)}\n key={fieldKey}\n $clickable={clickable}\n scope=\"col\"\n aria-sort={getHeaderAriaSort(fieldKey)}\n style={style}\n $isCheckbox={false}\n onClick={() => handleHeaderClick(fieldKey)}\n >\n <HeaderCellWrapper id={headerCellWrapperId}>\n {typeof label === \"string\" ? (\n <Typography.BodyBL weight=\"bold\">\n {label}\n </Typography.BodyBL>\n ) : (\n label\n )}\n {renderSortedArrow(fieldKey)}\n </HeaderCellWrapper>\n {(clickable || isSortable) && (\n <VisuallyHidden>\n <button\n onClick={(event) =>\n handleHeaderButtonClick(event, fieldKey)\n }\n >\n {isSortable && \"Sort \"}\n <span aria-labelledby={headerCellWrapperId} />\n {isSortable && getSortButtonAriaLabel(fieldKey)}\n </button>\n </VisuallyHidden>\n )}\n </HeaderCell>\n );\n };\n\n const renderSortedArrow = (fieldKey: string) => {\n const isSorted = sortIndicators?.[fieldKey];\n\n if (!isSorted) {\n return <></>;\n }\n if (isSorted === \"asc\") {\n return (\n <ArrowUpIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowup`)}\n />\n );\n }\n return (\n <ArrowDownIcon\n aria-hidden\n data-testid={getDataTestId(`header-${fieldKey}-arrowdown`)}\n />\n );\n };\n\n const renderHeaderCheckBox = () => {\n return (\n <HeaderCell\n data-testid={getDataTestId(\"header-selection\")}\n $clickable={false}\n $isCheckbox={true}\n scope=\"col\"\n >\n <CheckBoxWrapper>\n <VisuallyHidden>Row selection</VisuallyHidden>\n {enableSelectAll && (\n <Checkbox\n checked={isAllCheckboxSelected()}\n indeterminate={isIndeterminateCheckbox()}\n disabled={isHeaderCheckboxDisabled()}\n aria-label=\"Select all rows\"\n onClick={() => {\n if (onSelectAll) {\n onSelectAll(isAllCheckboxSelected());\n }\n }}\n />\n )}\n </CheckBoxWrapper>\n </HeaderCell>\n );\n };\n\n const renderRows = () => {\n return !rows || rows.length < 1 ? (\n <BodyRow $alternating={false}>\n <EmptyViewCell colSpan={getTotalColumns()}>\n {renderCustomEmptyView\n ? renderCustomEmptyView()\n : renderBasicEmptyView()}\n </EmptyViewCell>\n </BodyRow>\n ) : (\n <>\n {rows?.map((row: RowProps, index: number) => (\n <BodyRow\n data-testid={getDataTestId(`row-${row.id.toString()}`)}\n key={row.id.toString()}\n $alternating={isAlternatingRow(index)}\n $isSelectable={enableMultiSelect}\n $isSelected={isRowSelected(row.id.toString())}\n >\n {enableMultiSelect && renderRowCheckBox(row)}\n\n {headers.map((header) => renderRowCell(header, row))}\n </BodyRow>\n ))}\n </>\n );\n };\n\n const renderRowCell = (header: HeaderProps, row: RowProps) => {\n const style = typeof header !== \"string\" ? header.style : undefined;\n const fieldKey = typeof header === \"string\" ? header : header.fieldKey;\n const rowId = row.id.toString();\n const cellData = row[fieldKey];\n const cellId = `${rowId}-${fieldKey}`;\n\n return (\n <BodyCell\n data-testid={getDataTestId(`row-${cellId}`)}\n key={cellId}\n id={getCellId(rowId, fieldKey)}\n style={style}\n $isCheckbox={false}\n >\n {typeof cellData === \"string\" ||\n typeof cellData === \"number\" ? (\n <BodyCellContent>{cellData}</BodyCellContent>\n ) : typeof cellData === \"function\" ? (\n cellData(row, { isSelected: isRowSelected(rowId) })\n ) : (\n cellData\n )}\n </BodyCell>\n );\n };\n\n const renderRowCheckBox = (row: RowProps) => {\n const rowId = row.id.toString();\n\n return (\n <BodyCell\n data-testid={getDataTestId(`row-${rowId}-selection`)}\n $isCheckbox={true}\n >\n <CheckBoxWrapper>\n <Checkbox\n checked={isRowSelected(rowId)}\n aria-labelledby={getRowCheckboxAriaLabelledBy(rowId)}\n onClick={() => {\n if (onSelect) {\n onSelect(rowId, !isRowSelected(rowId));\n }\n }}\n disabled={isDisabledRow(rowId)}\n focusableWhenDisabled={isDisabledRow(rowId)}\n />\n </CheckBoxWrapper>\n </BodyCell>\n );\n };\n\n const renderBasicEmptyView = () => {\n return (\n <ErrorDisplay\n type={\"no-item-found\"}\n {...emptyView}\n title={\n emptyView?.title ? (\n typeof emptyView.title === \"string\" ? (\n <ErrorDisplayTitle weight=\"bold\">\n {emptyView.title}\n </ErrorDisplayTitle>\n ) : (\n emptyView.title\n )\n ) : (\n <ErrorDisplayTitle weight=\"bold\">\n {\"No <items> found\"}\n </ErrorDisplayTitle>\n )\n }\n description={\n emptyView?.description\n ? emptyView.description\n : \"No matching rows\"\n }\n />\n );\n };\n\n const renderLoader = () => {\n return (\n <BodyRow $alternating={false}>\n <td colSpan={getTotalColumns()}>\n <LoaderWrapper\n role=\"status\"\n aria-live=\"polite\"\n aria-label=\"Loading table\"\n >\n {loadState === \"loading\" && <LoadingDotsSpinner />}\n </LoaderWrapper>\n </td>\n </BodyRow>\n );\n };\n\n const renderSelectionBar = () => {\n const count = selectedIds?.length ?? 0;\n\n return (\n <ActionBarWrapper\n ref={actionBarRef}\n $fixed={isFloatingActionBar}\n $left={tableRef?.current?.getBoundingClientRect()?.left}\n $width={tableRef?.current?.clientWidth}\n >\n <ActionBar\n $float={\n (scrollable ? !scrollEnd : !end) || isFloatingActionBar\n }\n $scrollable={scrollable}\n >\n <Typography.BodyMD weight=\"semibold\">{`${count} item${\n count > 1 ? \"s\" : \"\"\n } selected`}</Typography.BodyMD>\n <TextButton\n type=\"button\"\n aria-label={`Clear selection of ${count} item${\n count === 1 ? \"\" : \"s\"\n }`}\n onClick={onClearSelectionClick}\n >\n Clear selection\n </TextButton>\n {actionBarContent}\n </ActionBar>\n </ActionBarWrapper>\n );\n };\n\n return (\n <TableWrapper\n id={id || \"table-wrapper\"}\n data-testid={otherProps[\"data-testid\"] || \"table\"}\n className={className}\n ref={wrapperRef}\n onScroll={() => {\n if (scrollable && wrapperRef.current) {\n setScrollEnd(\n wrapperRef.current.scrollTop +\n wrapperRef.current.clientHeight >=\n wrapperRef.current.scrollHeight\n );\n }\n }}\n tabIndex={0} // scrollable container must be focusable to support keyboard users\n >\n <TableContainer>\n <Table\n $end={tableEnd}\n $scrollable={scrollable}\n ref={tableRef}\n $stickyHeader={enableStickyHeader}\n >\n {renderHeaders()}\n <TableBody $showLastRowBottomBorder={showLastBorder}>\n {loadState === \"success\"\n ? renderRows()\n : renderLoader()}\n </TableBody>\n </Table>\n </TableContainer>\n {enableActionBar &&\n selectedIds &&\n selectedIds.length > 0 &&\n renderSelectionBar()}\n <div\n ref={(r) => {\n tableEndRef.current = r;\n endRef(r);\n }}\n />\n </TableWrapper>\n );\n};\n"],"names":["DataTable","_a","id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick","otherProps","__rest","tableRef","useRef","tableEndRef","headerRef","actionBarRef","wrapperRef","internalId","useId","keyColumns","filter","header","keyColumn","scrollable","setScrollable","useState","scrollEnd","setScrollEnd","tableEnd","setTableEnd","isFloatingActionBar","setIsFloatingActionBar","showLastBorder","setShowLastBorder","ref","endRef","inView","end","useInView","onResize","useCallback","current","scrollHeight","clientHeight","style","transform","calculateStickyInViewport","useEffect","useResizeDetector","useEventListener","requestAnimationFrame","calculateFixedInViewport","getBoundingClientRect","bottom","window","innerHeight","checkLastBorder","isAllCheckboxSelected","length","isRowSelected","rowId","includes","isAlternatingRow","index","isDisabledRow","getDataTestId","subStr","getTotalColumns","getSortDirection","fieldKey","getHeaderAriaSort","sortDirection","getSortButtonAriaLabel","getCellId","getRowCheckboxAriaLabelledBy","keyColumnIds","map","concatIds","wrapperBounds","top","endBounds","bottomOffset","bottomToHeaderOffset","height","maxBottomOffset","Math","min","renderHeaderCell","label","clickable","undefined","isSortable","headerCellWrapperId","getHeaderWrapperId","_jsxs","HeaderCell","$clickable","scope","$isCheckbox","onClick","handleHeaderClick","children","HeaderCellWrapper","_jsx","Typography","BodyBL","weight","renderSortedArrow","VisuallyHidden","event","stopPropagation","handleHeaderButtonClick","isSorted","ArrowUpIcon","ArrowDownIcon","renderHeaderCheckBox","CheckBoxWrapper","Checkbox","checked","indeterminate","disabled","renderRowCell","row","toString","cellData","cellId","BodyCell","BodyCellContent","isSelected","renderRowCheckBox","focusableWhenDisabled","renderBasicEmptyView","ErrorDisplay","Object","assign","type","title","ErrorDisplayTitle","description","TableWrapper","onScroll","scrollTop","tabIndex","TableContainer","Table","$end","$stickyHeader","HeaderRow","TableBody","$showLastRowBottomBorder","BodyRow","$alternating","EmptyViewCell","colSpan","$isSelectable","$isSelected","LoaderWrapper","role","LoadingDotsSpinner","count","ActionBarWrapper","$fixed","$left","_c","_b","left","$width","_d","clientWidth","ActionBar","$float","$scrollable","BodyMD","TextButton","renderSelectionBar","r"],"mappings":"kiDAgCO,MAAMA,EAAaC,QAAAC,GACtBA,EAAEC,QACFA,EAAOC,KACPA,EAAIC,UACJA,EAASC,eACTA,EAAcC,gBACdA,EAAeC,UACfA,EAAY,UAASC,kBACrBA,EAAiBC,YACjBA,EAAWC,YACXA,EAAWC,gBACXA,EAAeC,gBACfA,EAAeC,mBACfA,EAAkBC,UAClBA,EAASC,iBACTA,EAAgBC,sBAChBA,EAAqBC,cACrBA,GAAaC,SACbA,GAAQC,YACRA,GAAWC,sBACXA,MACGC,GAAUC,EAAAtB,EArBS,CAAA,KAAA,UAAA,OAAA,YAAA,iBAAA,kBAAA,YAAA,oBAAA,cAAA,cAAA,kBAAA,kBAAA,qBAAA,YAAA,mBAAA,wBAAA,gBAAA,WAAA,cAAA,0BA0BtB,MAAMuB,GAAWC,EAAyB,MACpCC,GAAcD,EAA8B,MAC5CE,GAAYF,EAAgC,MAC5CG,GAAeH,EAAuB,MACtCI,GAAaJ,EAAuB,MACpCK,GAAaC,IACbC,GAAa7B,EAAQ8B,QACtBC,GAC4B,iBAAXA,KAAyBA,EAAOC,aAI/CC,GAAYC,IAAiBC,GAAS,IACtCC,GAAWC,IAAgBF,GAAS,IACpCG,GAAUC,IAAeJ,GAAS,IAClCK,GAAqBC,IAA0BN,GAAS,IACxDO,GAAgBC,IAAqBR,GAAS,IAE7CS,IAAKC,GAAQC,OAAQC,IAAQC,IAK/B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,EAAA5J,cAAQ,EAARA,GAAU8B,eAAO,IAAA8H,OAAA,EAAAA,EAAEC,YAAWnE,SAEtCP,EAAC2E,EAAS,CAAAC,QAEDnJ,IAAcG,IAAaW,KAAQP,GAAmB6I,YAE9CpJ,GAAU8E,SAAA,CAEvBE,EAACC,EAAWoE,OAAM,CAAClE,OAAO,WAAUL,SAAE,GAAG0D,SACrCA,EAAQ,EAAI,IAAM,gBAEtBxD,EAACsE,EAAU,CACPtC,KAAK,SAAQ,aACD,sBAAsBwB,SACpB,IAAVA,EAAc,GAAK,MAEvB5D,QAAS3F,GAAqB6F,SAAA,oBAIjClG,MAEU,EAuCf2K,GACJvE,EAAA,MAAA,CACIrE,IAAM6I,IACFlK,GAAY4B,QAAUsI,EACtB5I,GAAO4I,EAAE,MAGN"}
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../_virtual/_tslib.js";import{jsx as a}from"react/jsx-runtime";import t from"../external/dayjs/dayjs.min.js";import{useState as r,useRef as n,useEffect as o}from"react";import{ElementWithDropdown as i}from"../shared/dropdown-wrapper/element-with-dropdown.js";import{CalendarDropdown as l}from"../shared/internal-calendar/calendar-dropdown.js";import"../shared/internal-calendar/internal-calendar.js";import{StandaloneDateInput as d}from"../shared/standalone-date-input/standalone-date-input.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import{DateInputHelper as s}from"../util/date-input-helper.js";import"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{Container as u}from"./date-input.style.js";const c=c=>{var{minDate:p,maxDate:m,disabled:h,disabledDates:v,error:f,hideInputKeyboard:D,value:b,onChange:j,onFocus:w,onBlur:g,onYearMonthDisplayChange:y,withButton:I=!0,readOnly:x,id:Y,allowDisabledSelection:C,zIndex:B,dropdownRootNode:O}=c,z=e(c,["minDate","maxDate","disabled","disabledDates","error","hideInputKeyboard","value","onChange","onFocus","onBlur","onYearMonthDisplayChange","withButton","readOnly","id","allowDisabledSelection","zIndex","dropdownRootNode"]);const[M,F]=r(s.sanitizeInput(b)),[R,S]=r(s.sanitizeInput(b)),[$,K]=r(void 0),[N,V]=r(!1),[_,k]=r(!1),E=n(null),H=n(null),T=n(null);o((()=>{const e=s.sanitizeInput(b);F(e),S(e)}),[b]);const W=e=>{!C&&s.isDateDisabled(e,{disabledDates:v,minDate:p,maxDate:m})||(S(e),I||(L(e),F(e),e&&V(!1)))},Z=e=>{var a;S(e),I||(L(e),F(e),e&&(null===(a=H.current)||void 0===a||a.focusYearRef(),V(!1)),K(void 0))},q=()=>{x||h||(V(!0),_||(k(!0),w&&w()))},A=e=>{var a,t,r;const n=e.relatedTarget,o=T.current&&T.current.contains(n),i=E.current&&E.current.contains(n),l=(null===(a=null==n?void 0:n.matches)||void 0===a?void 0:a.call(n,"[data-floating-ui-focusable]"))||(null===(t=null==n?void 0:n.matches)||void 0===t?void 0:t.call(n,"[data-floating-ui-focus-guard]"));(_&&!N&&!i&&!l||N&&!i&&!o&&!l)&&(null===(r=H.current)||void 0===r||r.resetInput(),S(M),k(!1),V(!1),P())},G=e=>{K(e)},J=e=>{var a,r;switch(e){case"reset":S(M);break;case"confirmed":F(R),L(R)}t(R,"YYYY-MM-DD",!0).isValid()?null===(a=H.current)||void 0===a||a.focusYearRef():null===(r=E.current)||void 0===r||r.focus(),V(!1)},L=e=>{j&&j(e)},P=()=>{g&&g()};return a(i,{enabled:!x&&!h,isOpen:N,renderElement:()=>a(u,Object.assign({role:"group",tabIndex:0,ref:E,onBlur:A,onFocus:q,$disabled:h,$readOnly:x,$focused:_,$error:f,id:Y,"data-testid":z["data-testid"],"aria-disabled":h},z,{children:a(d,{ref:H,disabled:h,onChange:W,readOnly:x,focused:N,names:["start-day","start-month","start-year"],value:R,hoverValue:$,hideInputKeyboard:D})})),renderDropdown:({elementWidth:e})=>a(l,{variant:"single",ref:T,initialCalendarDate:R,withButton:I,value:R,disabledDates:v,minDate:p,maxDate:m,allowDisabledSelection:C,onHover:G,onSelect:Z,onDismiss:J,onYearMonthDisplayChange:y,width:e,isFocusable:!x&&!h}),onClose:()=>{var e;null===(e=H.current)||void 0===e||e.resetInput(),S(M),V(!1),k(!1),P(),K(void 0)},onDismiss:()=>{var e,a;null===(e=H.current)||void 0===e||e.resetInput(),null===(a=E.current)||void 0===a||a.focus(),S(M),V(!1)},customZIndex:B,offset:16,rootNode:O})};export{c as DateInput};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsx as a}from"react/jsx-runtime";import t from"../external/dayjs/dayjs.min.js";import{useState as r,useRef as n,useEffect as o}from"react";import{ElementWithDropdown as i}from"../shared/dropdown-wrapper/element-with-dropdown.js";import{CalendarDropdown as l}from"../shared/internal-calendar/calendar-dropdown.js";import"../shared/internal-calendar/internal-calendar.js";import{StandaloneDateInput as d}from"../shared/standalone-date-input/standalone-date-input.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import{DateInputHelper as s}from"../util/date-input-helper.js";import"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{Container as u}from"./date-input.style.js";const c=c=>{var{minDate:p,maxDate:m,disabled:h,disabledDates:v,error:f,hideInputKeyboard:D,value:b,onChange:j,onFocus:w,onBlur:g,onYearMonthDisplayChange:y,withButton:I=!0,readOnly:x,id:Y,allowDisabledSelection:C,zIndex:B,dropdownRootNode:O}=c,z=e(c,["minDate","maxDate","disabled","disabledDates","error","hideInputKeyboard","value","onChange","onFocus","onBlur","onYearMonthDisplayChange","withButton","readOnly","id","allowDisabledSelection","zIndex","dropdownRootNode"]);const[M,F]=r(s.sanitizeInput(b)),[R,S]=r(s.sanitizeInput(b)),[$,K]=r(void 0),[N,V]=r(!1),[_,k]=r(!1),E=n(null),H=n(null),T=n(null);o((()=>{const e=s.sanitizeInput(b);F(e),S(e)}),[b]);const W=e=>{!C&&s.isDateDisabled(e,{disabledDates:v,minDate:p,maxDate:m})||(S(e),I||(L(e),F(e),e&&V(!1)))},Z=e=>{var a;S(e),I||(L(e),F(e),e&&(null===(a=H.current)||void 0===a||a.focusYearRef(),V(!1)),K(void 0))},q=()=>{x||h||(V(!0),_||(k(!0),w&&w()))},A=e=>{var a,t,r;const n=e.relatedTarget,o=T.current&&T.current.contains(n),i=E.current&&E.current.contains(n),l=(null===(a=null==n?void 0:n.matches)||void 0===a?void 0:a.call(n,"[data-floating-ui-focusable]"))||(null===(t=null==n?void 0:n.matches)||void 0===t?void 0:t.call(n,"[data-floating-ui-focus-guard]"));(_&&!N&&!i&&!l||N&&!i&&!o&&!l)&&(null===(r=H.current)||void 0===r||r.resetInput(),S(M),k(!1),V(!1),P())},G=e=>{N&&K(e)},J=e=>{var a,r;switch(e){case"reset":S(M);break;case"confirmed":F(R),L(R)}t(R,"YYYY-MM-DD",!0).isValid()?null===(a=H.current)||void 0===a||a.focusYearRef():null===(r=E.current)||void 0===r||r.focus(),V(!1)},L=e=>{j&&j(e)},P=()=>{g&&g()};return a(i,{enabled:!x&&!h,isOpen:N,renderElement:()=>a(u,Object.assign({role:"group",tabIndex:0,ref:E,onBlur:A,onFocus:q,$disabled:h,$readOnly:x,$focused:_,$error:f,id:Y,"data-testid":z["data-testid"],"aria-disabled":h},z,{children:a(d,{ref:H,disabled:h,onChange:W,readOnly:x,focused:N,names:["start-day","start-month","start-year"],value:R,hoverValue:$,hideInputKeyboard:D})})),renderDropdown:({elementWidth:e})=>a(l,{variant:"single",ref:T,initialCalendarDate:R,withButton:I,value:R,disabledDates:v,minDate:p,maxDate:m,allowDisabledSelection:C,onHover:G,onSelect:Z,onDismiss:J,onYearMonthDisplayChange:y,width:e,isFocusable:!x&&!h}),onClose:()=>{var e;null===(e=H.current)||void 0===e||e.resetInput(),S(M),V(!1),k(!1),P(),K(void 0)},onDismiss:()=>{var e,a;null===(e=H.current)||void 0===e||e.resetInput(),null===(a=E.current)||void 0===a||a.focus(),S(M),V(!1)},customZIndex:B,offset:16,rootNode:O})};export{c as DateInput};
2
2
  //# sourceMappingURL=date-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-input.js","sources":["../../src/date-input/date-input.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n DropdownRenderProps,\n ElementWithDropdown,\n} from \"../shared/dropdown-wrapper\";\nimport {\n CalendarAction,\n CalendarDropdown,\n InternalCalendarRef,\n} from \"../shared/internal-calendar\";\nimport {\n StandaloneDateInput,\n StandaloneDateInputRef,\n} from \"../shared/standalone-date-input/standalone-date-input\";\nimport { DateInputHelper } from \"../util\";\nimport { Container } from \"./date-input.style\";\nimport { DateInputProps } from \"./types\";\n\nexport const DateInput = ({\n minDate,\n maxDate,\n disabled,\n disabledDates,\n error,\n hideInputKeyboard,\n value,\n onChange,\n onFocus,\n onBlur,\n onYearMonthDisplayChange,\n withButton = true,\n readOnly,\n id,\n allowDisabledSelection,\n zIndex,\n dropdownRootNode,\n ...otherProps\n}: DateInputProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [initialDate, setInitialDate] = useState<string>(\n DateInputHelper.sanitizeInput(value)\n );\n const [selectedDate, setSelectedDate] = useState<string>(\n DateInputHelper.sanitizeInput(value)\n );\n const [hoveredDate, setHoveredDate] = useState<string | undefined>(\n undefined\n );\n const [calendarOpen, setCalendarOpen] = useState<boolean>(false);\n const [focused, setFocused] = useState<boolean>(false);\n\n const nodeRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<StandaloneDateInputRef>(null);\n const calendarRef = useRef<InternalCalendarRef>(null);\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const newValue = DateInputHelper.sanitizeInput(value);\n setInitialDate(newValue);\n setSelectedDate(newValue);\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleClose = () => {\n inputRef.current?.resetInput();\n setSelectedDate(initialDate);\n setCalendarOpen(false);\n setFocused(false);\n\n performOnBlurHandler();\n\n // clear hover value for mobile scrolling\n setHoveredDate(undefined);\n };\n\n const handleDismiss = () => {\n inputRef.current?.resetInput();\n nodeRef.current?.focus();\n setSelectedDate(initialDate);\n setCalendarOpen(false);\n };\n\n const handleChange = (val: string) => {\n if (\n !allowDisabledSelection &&\n DateInputHelper.isDateDisabled(val, {\n disabledDates,\n minDate,\n maxDate,\n })\n ) {\n return;\n }\n\n setSelectedDate(val);\n\n if (!withButton) {\n performOnChangeHandler(val);\n setInitialDate(val);\n if (val) {\n setCalendarOpen(false);\n }\n }\n };\n\n const handleSelect = (val: string) => {\n setSelectedDate(val);\n\n if (!withButton) {\n performOnChangeHandler(val);\n setInitialDate(val);\n if (val) {\n inputRef.current?.focusYearRef();\n setCalendarOpen(false);\n }\n\n // clear hover value for mobile when onMouseLeave={handleMouseLeaveCell} is not triggered due to touch input\n setHoveredDate(undefined);\n }\n };\n\n const handleFocus = () => {\n if (readOnly || disabled) return;\n\n setCalendarOpen(true);\n\n if (focused) return;\n\n setFocused(true);\n\n if (onFocus) {\n onFocus();\n }\n };\n\n const handleBlur = (e: React.FocusEvent) => {\n const target = e.relatedTarget as HTMLElement;\n\n const isInsideCalendar =\n calendarRef.current && calendarRef.current.contains(target);\n const isInsideNode =\n nodeRef.current && nodeRef.current.contains(target);\n const isFloatingElement =\n target?.matches?.(\"[data-floating-ui-focusable]\") ||\n target?.matches?.(\"[data-floating-ui-focus-guard]\");\n\n // Condition when the calendar is closed and focus moved outside the component\n const shouldBlurWhenClosed =\n focused && !calendarOpen && !isInsideNode && !isFloatingElement;\n\n // Condition when the calendar is open, and focus went outside both input and calendar\n const shouldBlurWhenOpenOutside =\n calendarOpen &&\n !isInsideNode &&\n !isInsideCalendar &&\n !isFloatingElement;\n\n if (shouldBlurWhenClosed || shouldBlurWhenOpenOutside) {\n inputRef.current?.resetInput();\n setSelectedDate(initialDate);\n setFocused(false);\n setCalendarOpen(false);\n performOnBlurHandler();\n }\n };\n\n const handleHoverDayCell = (value: string) => {\n setHoveredDate(value);\n };\n\n const handleCalendarAction = (buttonAction: CalendarAction) => {\n // handle button in day calendar view\n switch (buttonAction) {\n case \"reset\":\n setSelectedDate(initialDate);\n break;\n case \"confirmed\":\n setInitialDate(selectedDate);\n performOnChangeHandler(selectedDate);\n break;\n }\n\n const isValid = dayjs(selectedDate, \"YYYY-MM-DD\", true).isValid();\n\n // Focus on year input if the selected date is valid to avoid restarting entire tab order\n if (isValid) {\n inputRef.current?.focusYearRef();\n } else {\n nodeRef.current?.focus();\n }\n setCalendarOpen(false);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const performOnChangeHandler = (changeValue: string) => {\n if (onChange) {\n onChange(changeValue);\n }\n };\n\n const performOnBlurHandler = () => {\n if (onBlur) {\n onBlur();\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderInput = () => {\n return (\n <Container\n role=\"group\"\n tabIndex={0}\n ref={nodeRef}\n onBlur={handleBlur}\n onFocus={handleFocus}\n $disabled={disabled}\n $readOnly={readOnly}\n $focused={focused}\n $error={error}\n id={id}\n data-testid={otherProps[\"data-testid\"]}\n aria-disabled={disabled}\n {...otherProps}\n >\n <StandaloneDateInput\n ref={inputRef}\n disabled={disabled}\n onChange={handleChange}\n readOnly={readOnly}\n focused={calendarOpen}\n names={[\"start-day\", \"start-month\", \"start-year\"]}\n value={selectedDate}\n hoverValue={hoveredDate}\n hideInputKeyboard={hideInputKeyboard}\n />\n </Container>\n );\n };\n\n const renderCalendar = ({ elementWidth }: DropdownRenderProps) => {\n return (\n <CalendarDropdown\n variant=\"single\"\n ref={calendarRef}\n initialCalendarDate={selectedDate}\n withButton={withButton}\n value={selectedDate}\n disabledDates={disabledDates}\n minDate={minDate}\n maxDate={maxDate}\n allowDisabledSelection={allowDisabledSelection}\n onHover={handleHoverDayCell}\n onSelect={handleSelect}\n onDismiss={handleCalendarAction}\n onYearMonthDisplayChange={onYearMonthDisplayChange}\n width={elementWidth}\n isFocusable={!readOnly && !disabled}\n />\n );\n };\n\n return (\n <ElementWithDropdown\n enabled={!readOnly && !disabled}\n isOpen={calendarOpen}\n renderElement={renderInput}\n renderDropdown={renderCalendar}\n onClose={handleClose}\n onDismiss={handleDismiss}\n customZIndex={zIndex}\n offset={16}\n rootNode={dropdownRootNode}\n />\n );\n};\n"],"names":["DateInput","_a","minDate","maxDate","disabled","disabledDates","error","hideInputKeyboard","value","onChange","onFocus","onBlur","onYearMonthDisplayChange","withButton","readOnly","id","allowDisabledSelection","zIndex","dropdownRootNode","otherProps","__rest","initialDate","setInitialDate","useState","DateInputHelper","sanitizeInput","selectedDate","setSelectedDate","hoveredDate","setHoveredDate","undefined","calendarOpen","setCalendarOpen","focused","setFocused","nodeRef","useRef","inputRef","calendarRef","useEffect","newValue","handleChange","val","isDateDisabled","performOnChangeHandler","handleSelect","current","focusYearRef","handleFocus","handleBlur","e","target","relatedTarget","isInsideCalendar","contains","isInsideNode","isFloatingElement","matches","call","_b","_c","resetInput","performOnBlurHandler","handleHoverDayCell","handleCalendarAction","buttonAction","dayjs","isValid","focus","changeValue","_jsx","ElementWithDropdown","enabled","isOpen","renderElement","Container","Object","assign","role","tabIndex","ref","$disabled","$focused","$error","children","StandaloneDateInput","names","hoverValue","renderDropdown","elementWidth","CalendarDropdown","variant","initialCalendarDate","onHover","onSelect","onDismiss","width","isFocusable","onClose","customZIndex","offset","rootNode"],"mappings":"qyBAmBO,MAAMA,EAAaC,IAAA,IAAAC,QACtBA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,cACRA,EAAaC,MACbA,EAAKC,kBACLA,EAAiBC,MACjBA,EAAKC,SACLA,EAAQC,QACRA,EAAOC,OACPA,EAAMC,yBACNA,EAAwBC,WACxBA,GAAa,EAAIC,SACjBA,EAAQC,GACRA,EAAEC,uBACFA,EAAsBC,OACtBA,EAAMC,iBACNA,GAAgBjB,EACbkB,EAAUC,EAAAnB,EAlBS,iOAuBtB,MAAOoB,EAAaC,GAAkBC,EAClCC,EAAgBC,cAAcjB,KAE3BkB,EAAcC,GAAmBJ,EACpCC,EAAgBC,cAAcjB,KAE3BoB,EAAaC,GAAkB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IAGAjC,OAAeC,EAAU,EAwMrBiE,UArMc,aACF,QAAhB9F,EAAAoC,EAASS,eAAO,IAAA7C,GAAAA,EAAE4D,aACH,QAAfF,EAAAxB,EAAQW,eAAO,IAAAa,GAAAA,EAAES,QACjBzC,EAAgBN,GAChBW,GAAgB,EAAM,EAkMlBmE,aAAclF,EACdmF,OAAQ,GACRC,SAAUnF,GACZ"}
1
+ {"version":3,"file":"date-input.js","sources":["../../src/date-input/date-input.tsx"],"sourcesContent":["import dayjs from \"dayjs\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n DropdownRenderProps,\n ElementWithDropdown,\n} from \"../shared/dropdown-wrapper\";\nimport {\n CalendarAction,\n CalendarDropdown,\n InternalCalendarRef,\n} from \"../shared/internal-calendar\";\nimport {\n StandaloneDateInput,\n StandaloneDateInputRef,\n} from \"../shared/standalone-date-input/standalone-date-input\";\nimport { DateInputHelper } from \"../util\";\nimport { Container } from \"./date-input.style\";\nimport { DateInputProps } from \"./types\";\n\nexport const DateInput = ({\n minDate,\n maxDate,\n disabled,\n disabledDates,\n error,\n hideInputKeyboard,\n value,\n onChange,\n onFocus,\n onBlur,\n onYearMonthDisplayChange,\n withButton = true,\n readOnly,\n id,\n allowDisabledSelection,\n zIndex,\n dropdownRootNode,\n ...otherProps\n}: DateInputProps) => {\n // =============================================================================\n // CONST, STATE, REF\n // =============================================================================\n const [initialDate, setInitialDate] = useState<string>(\n DateInputHelper.sanitizeInput(value)\n );\n const [selectedDate, setSelectedDate] = useState<string>(\n DateInputHelper.sanitizeInput(value)\n );\n const [hoveredDate, setHoveredDate] = useState<string | undefined>(\n undefined\n );\n const [calendarOpen, setCalendarOpen] = useState<boolean>(false);\n const [focused, setFocused] = useState<boolean>(false);\n\n const nodeRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<StandaloneDateInputRef>(null);\n const calendarRef = useRef<InternalCalendarRef>(null);\n\n // =============================================================================\n // EFFECTS\n // =============================================================================\n useEffect(() => {\n const newValue = DateInputHelper.sanitizeInput(value);\n setInitialDate(newValue);\n setSelectedDate(newValue);\n }, [value]);\n\n // =============================================================================\n // EVENT HANDLERS\n // =============================================================================\n const handleClose = () => {\n inputRef.current?.resetInput();\n setSelectedDate(initialDate);\n setCalendarOpen(false);\n setFocused(false);\n\n performOnBlurHandler();\n\n // clear hover value for mobile scrolling\n setHoveredDate(undefined);\n };\n\n const handleDismiss = () => {\n inputRef.current?.resetInput();\n nodeRef.current?.focus();\n setSelectedDate(initialDate);\n setCalendarOpen(false);\n };\n\n const handleChange = (val: string) => {\n if (\n !allowDisabledSelection &&\n DateInputHelper.isDateDisabled(val, {\n disabledDates,\n minDate,\n maxDate,\n })\n ) {\n return;\n }\n\n setSelectedDate(val);\n\n if (!withButton) {\n performOnChangeHandler(val);\n setInitialDate(val);\n if (val) {\n setCalendarOpen(false);\n }\n }\n };\n\n const handleSelect = (val: string) => {\n setSelectedDate(val);\n\n if (!withButton) {\n performOnChangeHandler(val);\n setInitialDate(val);\n if (val) {\n inputRef.current?.focusYearRef();\n setCalendarOpen(false);\n }\n\n // clear hover value for mobile when onMouseLeave={handleMouseLeaveCell} is not triggered due to touch input\n setHoveredDate(undefined);\n }\n };\n\n const handleFocus = () => {\n if (readOnly || disabled) return;\n\n setCalendarOpen(true);\n\n if (focused) return;\n\n setFocused(true);\n\n if (onFocus) {\n onFocus();\n }\n };\n\n const handleBlur = (e: React.FocusEvent) => {\n const target = e.relatedTarget as HTMLElement;\n\n const isInsideCalendar =\n calendarRef.current && calendarRef.current.contains(target);\n const isInsideNode =\n nodeRef.current && nodeRef.current.contains(target);\n const isFloatingElement =\n target?.matches?.(\"[data-floating-ui-focusable]\") ||\n target?.matches?.(\"[data-floating-ui-focus-guard]\");\n\n // Condition when the calendar is closed and focus moved outside the component\n const shouldBlurWhenClosed =\n focused && !calendarOpen && !isInsideNode && !isFloatingElement;\n\n // Condition when the calendar is open, and focus went outside both input and calendar\n const shouldBlurWhenOpenOutside =\n calendarOpen &&\n !isInsideNode &&\n !isInsideCalendar &&\n !isFloatingElement;\n\n if (shouldBlurWhenClosed || shouldBlurWhenOpenOutside) {\n inputRef.current?.resetInput();\n setSelectedDate(initialDate);\n setFocused(false);\n setCalendarOpen(false);\n performOnBlurHandler();\n }\n };\n\n const handleHoverDayCell = (value: string) => {\n if (!calendarOpen) return;\n setHoveredDate(value);\n };\n\n const handleCalendarAction = (buttonAction: CalendarAction) => {\n // handle button in day calendar view\n switch (buttonAction) {\n case \"reset\":\n setSelectedDate(initialDate);\n break;\n case \"confirmed\":\n setInitialDate(selectedDate);\n performOnChangeHandler(selectedDate);\n break;\n }\n\n const isValid = dayjs(selectedDate, \"YYYY-MM-DD\", true).isValid();\n\n // Focus on year input if the selected date is valid to avoid restarting entire tab order\n if (isValid) {\n inputRef.current?.focusYearRef();\n } else {\n nodeRef.current?.focus();\n }\n setCalendarOpen(false);\n };\n\n // =============================================================================\n // HELPER FUNCTIONS\n // =============================================================================\n const performOnChangeHandler = (changeValue: string) => {\n if (onChange) {\n onChange(changeValue);\n }\n };\n\n const performOnBlurHandler = () => {\n if (onBlur) {\n onBlur();\n }\n };\n\n // =============================================================================\n // RENDER FUNCTIONS\n // =============================================================================\n const renderInput = () => {\n return (\n <Container\n role=\"group\"\n tabIndex={0}\n ref={nodeRef}\n onBlur={handleBlur}\n onFocus={handleFocus}\n $disabled={disabled}\n $readOnly={readOnly}\n $focused={focused}\n $error={error}\n id={id}\n data-testid={otherProps[\"data-testid\"]}\n aria-disabled={disabled}\n {...otherProps}\n >\n <StandaloneDateInput\n ref={inputRef}\n disabled={disabled}\n onChange={handleChange}\n readOnly={readOnly}\n focused={calendarOpen}\n names={[\"start-day\", \"start-month\", \"start-year\"]}\n value={selectedDate}\n hoverValue={hoveredDate}\n hideInputKeyboard={hideInputKeyboard}\n />\n </Container>\n );\n };\n\n const renderCalendar = ({ elementWidth }: DropdownRenderProps) => {\n return (\n <CalendarDropdown\n variant=\"single\"\n ref={calendarRef}\n initialCalendarDate={selectedDate}\n withButton={withButton}\n value={selectedDate}\n disabledDates={disabledDates}\n minDate={minDate}\n maxDate={maxDate}\n allowDisabledSelection={allowDisabledSelection}\n onHover={handleHoverDayCell}\n onSelect={handleSelect}\n onDismiss={handleCalendarAction}\n onYearMonthDisplayChange={onYearMonthDisplayChange}\n width={elementWidth}\n isFocusable={!readOnly && !disabled}\n />\n );\n };\n\n return (\n <ElementWithDropdown\n enabled={!readOnly && !disabled}\n isOpen={calendarOpen}\n renderElement={renderInput}\n renderDropdown={renderCalendar}\n onClose={handleClose}\n onDismiss={handleDismiss}\n customZIndex={zIndex}\n offset={16}\n rootNode={dropdownRootNode}\n />\n );\n};\n"],"names":["DateInput","_a","minDate","maxDate","disabled","disabledDates","error","hideInputKeyboard","value","onChange","onFocus","onBlur","onYearMonthDisplayChange","withButton","readOnly","id","allowDisabledSelection","zIndex","dropdownRootNode","otherProps","__rest","initialDate","setInitialDate","useState","DateInputHelper","sanitizeInput","selectedDate","setSelectedDate","hoveredDate","setHoveredDate","undefined","calendarOpen","setCalendarOpen","focused","setFocused","nodeRef","useRef","inputRef","calendarRef","useEffect","newValue","handleChange","val","isDateDisabled","performOnChangeHandler","handleSelect","current","focusYearRef","handleFocus","handleBlur","e","target","relatedTarget","isInsideCalendar","contains","isInsideNode","isFloatingElement","matches","call","_b","_c","resetInput","performOnBlurHandler","handleHoverDayCell","handleCalendarAction","buttonAction","dayjs","isValid","focus","changeValue","_jsx","ElementWithDropdown","enabled","isOpen","renderElement","Container","Object","assign","role","tabIndex","ref","$disabled","$focused","$error","children","StandaloneDateInput","names","hoverValue","renderDropdown","elementWidth","CalendarDropdown","variant","initialCalendarDate","onHover","onSelect","onDismiss","width","isFocusable","onClose","customZIndex","offset","rootNode"],"mappings":"qyBAmBO,MAAMA,EAAaC,IAAA,IAAAC,QACtBA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,cACRA,EAAaC,MACbA,EAAKC,kBACLA,EAAiBC,MACjBA,EAAKC,SACLA,EAAQC,QAC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EACZL,MAAOkB,EACPrB,cAAeA,EACfH,QAASA,EACTC,QAASA,EACTa,uBAAwBA,EACxB6E,QAAS9B,EACT+B,SAAUjD,EACVkD,UAAW/B,EACXpD,yBAA0BA,EAC1BoF,MAAOP,EACPQ,aAAcnF,IAAaV,IAW/B8F,QAjNY,WACA,QAAhBjG,EAAAoC,EAASS,eAAO,IAAA7C,GAAAA,EAAE4D,aAClBlC,EAAgBN,GAChBW,GAAgB,GAChBE,GAAW,GAEX4B,IAGAjC,OAAeC,EAAU,EAyMrBiE,UAtMc,aACF,QAAhB9F,EAAAoC,EAASS,eAAO,IAAA7C,GAAAA,EAAE4D,aACH,QAAfF,EAAAxB,EAAQW,eAAO,IAAAa,GAAAA,EAAES,QACjBzC,EAAgBN,GAChBW,GAAgB,EAAM,EAmMlBmE,aAAclF,EACdmF,OAAQ,GACRC,SAAUnF,GACZ"}
@@ -0,0 +1,5 @@
1
+ interface FilterBadgeProps {
2
+ count?: number;
3
+ }
4
+ export declare const FilterBadge: ({ count }: FilterBadgeProps) => import("react/jsx-runtime").JSX.Element | null;
5
+ export {};
@@ -0,0 +1,2 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{Badge as r}from"../badge/badge.js";const t=({count:t})=>void 0!==t&&t>0?e(r,{count:t,variant:"square-number","aria-label":`${t} selected`}):null;export{t as FilterBadge};
2
+ //# sourceMappingURL=filter-badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-badge.js","sources":["../../src/filter/filter-badge.tsx"],"sourcesContent":["import { Badge } from \"../badge\";\n\ninterface FilterBadgeProps {\n count?: number;\n}\n\nexport const FilterBadge = ({ count }: FilterBadgeProps) =>\n count !== undefined && count > 0 ? (\n <Badge\n count={count}\n variant=\"square-number\"\n aria-label={`${count} selected`}\n />\n ) : null;\n"],"names":["FilterBadge","count","undefined","_jsx","Badge","variant"],"mappings":"kFAMO,MAAMA,EAAc,EAAGC,gBAChBC,IAAVD,GAAuBA,EAAQ,EAC3BE,EAACC,EAAK,CACFH,MAAOA,EACPI,QAAQ,6BACI,GAAGJ,eAEnB"}
@@ -1,5 +1,5 @@
1
1
  import { FilterModalProps } from "./types";
2
2
  export declare const FilterModal: {
3
- ({ customLabels, onClear, onDone, onDismiss, onModalOpen, toggleFilterButtonStyle, clearButtonDisabled, insets, children, toggleFilterButtonLabel: _toggleFilterButtonLabel, headerTitle: _headerTitle, doneButtonLabel: _doneButtonLabel, ...otherProps }: FilterModalProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ customLabels, onClear, onDone, onDismiss, onModalOpen, toggleFilterButtonStyle, clearButtonDisabled, insets, count, children, toggleFilterButtonLabel: _toggleFilterButtonLabel, headerTitle: _headerTitle, doneButtonLabel: _doneButtonLabel, ...otherProps }: FilterModalProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as l,jsx as t}from"react/jsx-runtime";import{useFloating as o,FloatingFocusManager as i}from"@floating-ui/react";import{FilterIcon as r,CrossIcon as n}from"@lifesg/react-icons";import{useRef as a,useState as s,useEffect as d}from"react";import{Overlay as c}from"../overlay/overlay.js";import{inertValue as u}from"../shared/accessibility/index.js";import{FilterContext as m}from"./filter-context.js";import{FilterButton as b,FloatingWrapper as h,MobileOverlayContainer as f,MobileContainer as g,FilterHeader as p,FilterTitle as v,FilterClearButton as y}from"./filter-modal.styles.js";import{FilterHeaderButton as B,FilterBody as F,FilterFooter as L,FilterDoneButton as j}from"./filter.styles.js";const x=x=>{var{customLabels:C,onClear:D,onDone:T,onDismiss:k,onModalOpen:O,toggleFilterButtonStyle:$="light",clearButtonDisabled:w=!1,insets:M,children:N,toggleFilterButtonLabel:S,headerTitle:_,doneButtonLabel:H}=x,I=e(x,["customLabels","onClear","onDone","onDismiss","onModalOpen","toggleFilterButtonStyle","clearButtonDisabled","insets","children","toggleFilterButtonLabel","headerTitle","doneButtonLabel"]);const{context:P,refs:q}=o(),z=a(null),[A,E]=s(!1),G={toggle:(null==C?void 0:C.toggleFilterButtonLabel)||S||"Filters",title:(null==C?void 0:C.headerTitle)||_||"Filters",done:(null==C?void 0:C.doneButtonLabel)||H||"Done",clear:(null==C?void 0:C.clearButtonLabel)||"Clear"};return d((()=>{var e;A&&(null===(e=z.current)||void 0===e||e.focus())}),[A]),l(m.Provider,{value:{mode:"mobile",rootNode:z},children:[t("div",Object.assign({},I,{children:t(b,{"data-testid":"filter-show-button",styleType:$,onClick:()=>{E(!0),null==O||O()},type:"button",icon:t(r,{}),children:G.toggle})})),t(c,{show:A,disableTransition:!0,children:t(h,{inert:u(!A),children:t(i,{context:P,disabled:!A,children:t(f,{"data-id":"filter-mobile","data-testid":"filter-mobile",ref:q.setFloating,children:l(g,{ref:z,tabIndex:0,children:[l(p,{$insetTop:null==M?void 0:M.top,children:[t(B,{onClick:()=>{E(!1),null==k||k()},focusOutline:"browser",focusHighlight:!1,"aria-label":`close ${G.title}`,children:t(n,{})}),t(v,{children:G.title}),t(y,{styleType:"link",type:"button",onClick:()=>null==D?void 0:D(),disabled:w,"aria-label":`clear ${G.title}`,children:G.clear})]}),t(F,{children:N}),t(L,{$insetBottom:null==M?void 0:M.bottom,children:t(j,{onClick:()=>{E(!1),null==T||T()},children:G.done})})]})})})})})]})};x.displayName="Filter.Modal";export{x as FilterModal};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as l,jsx as t}from"react/jsx-runtime";import{useFloating as o,FloatingFocusManager as i}from"@floating-ui/react";import{FilterIcon as n,CrossIcon as r}from"@lifesg/react-icons";import{useRef as a,useState as d,useEffect as s}from"react";import{Overlay as c}from"../overlay/overlay.js";import{inertValue as u}from"../shared/accessibility/index.js";import{FilterBadge as m}from"./filter-badge.js";import{FilterContext as b}from"./filter-context.js";import{FilterButton as h,FilterToggleContent as f,FloatingWrapper as g,MobileOverlayContainer as p,MobileContainer as v,FilterHeader as y,FilterTitleGroup as B,FilterTitle as j,FilterClearButton as F}from"./filter-modal.styles.js";import{FilterHeaderButton as L,FilterBody as x,FilterFooter as C,FilterDoneButton as D}from"./filter.styles.js";const T=T=>{var{customLabels:k,onClear:O,onDone:$,onDismiss:w,onModalOpen:M,toggleFilterButtonStyle:N="light",clearButtonDisabled:S=!1,insets:_,count:H,children:I,toggleFilterButtonLabel:P,headerTitle:q,doneButtonLabel:z}=T,A=e(T,["customLabels","onClear","onDone","onDismiss","onModalOpen","toggleFilterButtonStyle","clearButtonDisabled","insets","count","children","toggleFilterButtonLabel","headerTitle","doneButtonLabel"]);const{context:E,refs:G}=o(),J=a(null),[K,Q]=d(!1),R={toggle:(null==k?void 0:k.toggleFilterButtonLabel)||P||"Filters",title:(null==k?void 0:k.headerTitle)||q||"Filters",done:(null==k?void 0:k.doneButtonLabel)||z||"Done",clear:(null==k?void 0:k.clearButtonLabel)||"Clear"};return s((()=>{var e;K&&(null===(e=J.current)||void 0===e||e.focus())}),[K]),l(b.Provider,{value:{mode:"mobile",rootNode:J},children:[t("div",Object.assign({},A,{children:t(h,{"data-testid":"filter-show-button",styleType:N,onClick:()=>{Q(!0),null==M||M()},type:"button",icon:t(n,{}),children:l(f,{children:[t("span",{children:R.toggle}),t(m,{count:H})]})})})),t(c,{show:K,disableTransition:!0,children:t(g,{inert:u(!K),children:t(i,{context:E,disabled:!K,children:t(p,{"data-id":"filter-mobile","data-testid":"filter-mobile",ref:G.setFloating,children:l(v,{ref:J,tabIndex:0,children:[l(y,{$insetTop:null==_?void 0:_.top,children:[t(L,{onClick:()=>{Q(!1),null==w||w()},focusOutline:"browser",focusHighlight:!1,"aria-label":`close ${R.title}`,children:t(r,{})}),l(B,{children:[t(j,{children:R.title}),t(m,{count:H})]}),t(F,{styleType:"link",type:"button",onClick:()=>null==O?void 0:O(),disabled:S,"aria-label":`clear ${R.title}`,children:R.clear})]}),t(x,{children:I}),t(C,{$insetBottom:null==_?void 0:_.bottom,children:t(D,{onClick:()=>{Q(!1),null==$||$()},children:R.done})})]})})})})})]})};T.displayName="Filter.Modal";export{T as FilterModal};
2
2
  //# sourceMappingURL=filter-modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-modal.js","sources":["../../src/filter/filter-modal.tsx"],"sourcesContent":["import { FloatingFocusManager, useFloating } from \"@floating-ui/react\";\nimport { CrossIcon, FilterIcon } from \"@lifesg/react-icons\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Overlay } from \"src/overlay\";\nimport { inertValue } from \"src/shared/accessibility\";\nimport { FilterContext } from \"./filter-context\";\nimport {\n FilterButton,\n FilterClearButton,\n FilterHeader,\n FilterTitle,\n FloatingWrapper,\n MobileContainer,\n MobileOverlayContainer,\n} from \"./filter-modal.styles\";\nimport { FilterModalProps } from \"./types\";\nimport {\n FilterBody,\n FilterDoneButton,\n FilterFooter,\n FilterHeaderButton,\n} from \"./filter.styles\";\n\nexport const FilterModal = ({\n customLabels,\n onClear,\n onDone,\n onDismiss,\n onModalOpen,\n toggleFilterButtonStyle = \"light\",\n clearButtonDisabled = false,\n insets,\n children,\n toggleFilterButtonLabel: _toggleFilterButtonLabel,\n headerTitle: _headerTitle,\n doneButtonLabel: _doneButtonLabel,\n ...otherProps\n}: FilterModalProps) => {\n const { context, refs } = useFloating();\n const nodeRef = useRef<HTMLDivElement>(null);\n\n const [visible, setVisible] = useState(false);\n\n const handleShow = () => setVisible(true);\n const handleDismiss = () => {\n setVisible(false);\n onDismiss?.();\n };\n const handleDone = () => {\n setVisible(false);\n onDone?.();\n };\n\n const handleShowFilter = () => {\n handleShow();\n onModalOpen?.();\n };\n\n const labels = {\n toggle:\n customLabels?.toggleFilterButtonLabel ||\n _toggleFilterButtonLabel ||\n \"Filters\",\n title: customLabels?.headerTitle || _headerTitle || \"Filters\",\n done: customLabels?.doneButtonLabel || _doneButtonLabel || \"Done\",\n clear: customLabels?.clearButtonLabel || \"Clear\",\n };\n\n useEffect(() => {\n if (visible) {\n nodeRef.current?.focus();\n }\n }, [visible]);\n\n return (\n <FilterContext.Provider value={{ mode: \"mobile\", rootNode: nodeRef }}>\n <div {...otherProps}>\n <FilterButton\n data-testid=\"filter-show-button\"\n styleType={toggleFilterButtonStyle}\n onClick={handleShowFilter}\n type=\"button\"\n icon={<FilterIcon />}\n >\n {labels.toggle}\n </FilterButton>\n </div>\n <Overlay show={visible} disableTransition>\n <FloatingWrapper inert={inertValue(!visible)}>\n <FloatingFocusManager context={context} disabled={!visible}>\n <MobileOverlayContainer\n data-id=\"filter-mobile\"\n data-testid=\"filter-mobile\"\n ref={refs.setFloating}\n >\n <MobileContainer ref={nodeRef} tabIndex={0}>\n <FilterHeader $insetTop={insets?.top}>\n <FilterHeaderButton\n onClick={handleDismiss}\n focusOutline=\"browser\"\n focusHighlight={false}\n aria-label={`close ${labels.title}`}\n >\n <CrossIcon />\n </FilterHeaderButton>\n <FilterTitle>{labels.title}</FilterTitle>\n <FilterClearButton\n styleType=\"link\"\n type=\"button\"\n onClick={() => onClear?.()}\n disabled={clearButtonDisabled}\n aria-label={`clear ${labels.title}`}\n >\n {labels.clear}\n </FilterClearButton>\n </FilterHeader>\n <FilterBody>{children}</FilterBody>\n <FilterFooter $insetBottom={insets?.bottom}>\n <FilterDoneButton onClick={handleDone}>\n {labels.done}\n </FilterDoneButton>\n </FilterFooter>\n </MobileContainer>\n </MobileOverlayContainer>\n </FloatingFocusManager>\n </FloatingWrapper>\n </Overlay>\n </FilterContext.Provider>\n );\n};\n\nFilterModal.displayName = \"Filter.Modal\";\n"],"names":["FilterModal","_a","customLabels","onClear","onDone","onDismiss","onModalOpen","toggleFilterButtonStyle","clearButtonDisabled","insets","children","toggleFilterButtonLabel","_toggleFilterButtonLabel","headerTitle","_headerTitle","doneButtonLabel","_doneButtonLabel","otherProps","__rest","context","refs","useFloating","nodeRef","useRef","visible","setVisible","useState","labels","toggle","title","done","clear","clearButtonLabel","useEffect","current","focus","_jsxs","FilterContext","Provider","value","mode","rootNode","_jsx","Object","assign","FilterButton","styleType","onClick","type","icon","FilterIcon","Overlay","show","disableTransition","FloatingWrapper","inert","inertValue","FloatingFocusManager","disabled","MobileOverlayContainer","ref","setFloating","MobileContainer","tabIndex","FilterHeader","$insetTop","top","FilterHeaderButton","focusOutline","focusHighlight","CrossIcon","FilterTitle","FilterClearButton","FilterBody","FilterFooter","$insetBottom","bottom","FilterDoneButton","displayName"],"mappings":"kvBAuBO,MAAMA,EAAeC,IAAA,IAAAC,aACxBA,EAAYC,QACZA,EAAOC,OACPA,EAAMC,UACNA,EAASC,YACTA,EAAWC,wBACXA,EAA0B,QAAOC,oBACjCA,GAAsB,EAAKC,OAC3BA,EAAMC,SACNA,EACAC,wBAAyBC,EACzBC,YAAaC,EACbC,gBAAiBC,GAAgBf,EAC9BgB,EAAUC,EAAAjB,EAbW,6LAexB,MAAMkB,QAAEA,EAAOC,KAAEA,GAASC,IACpBC,EAAUC,EAAuB,OAEhCC,EAASC,GAAcC,GAAS,GAiBjCC,EAAS,CACXC,QACI1B,aAAY,EAAZA,EAAcS,0BACdC,GACA,UACJiB,OAAO3B,aAAY,EAAZA,EAAcW,cAAeC,GAAgB,UACpDgB,MAAM5B,aAAY,EAAZA,EAAca,kBAAmBC,GAAoB,OAC3De,OAAO7B,eAAAA,EAAc8B,mBAAoB,SAS7C,OANAC,GAAU,WACFT,IACe,QAAfvB,EAAAqB,EAAQY,eAAO,IAAAjC,GAAAA,EAAEkC,QACrB,GACD,CAACX,IAGAY,EAACC,EAAcC,UAASC,MAAO,CAAEC,KAAM,SAAUC,SAAUnB,GAASZ,SAAA,CAChEgC,EAAA,MAAAC,OAAAC,OAAA,GAAS3B,EAAU,CAAAP,SACfgC,EAACG,EAAY,CAAA,cACG,qBACZC,UAAWvC,EACXwC,QA3BS,KAVAtB,GAAW,GAYhCnB,SAAAA,GAAe,EA0BH0C,KAAK,SACLC,KAAMP,EAACQ,EAAU,CAAA,GAAGxC,SAEnBiB,EAAOC,YAGhBc,EAACS,EAAO,CAACC,KAAM5B,EAAS6B,mBAAiB,EAAA3C,SACrCgC,EAACY,EAAe,CAACC,MAAOC,GAAYhC,YAChCkB,EAACe,EAAoB,CAACtC,QAASA,EAASuC,UAAWlC,EAAOd,SACtDgC,EAACiB,aACW,gBAAe,cACX,gBACZC,IAAKxC,EAAKyC,YAAWnD,SAErB0B,EAAC0B,EAAe,CAACF,IAAKtC,EAASyC,SAAU,EAACrD,SAAA,CACtC0B,EAAC4B,EAAY,CAAAC,UAAYxD,aAAM,EAANA,EAAQyD,IAAGxD,SAAA,CAChCgC,EAACyB,EAAkB,CACfpB,QAtDd,KAClBtB,GAAW,GACXpB,SAAAA,GAAa,EAqDmB+D,aAAa,UACbC,gBAAgB,EAAK,aACT,SAAS1C,EAAOE,QAAOnB,SAEnCgC,EAAC4B,EAAS,CAAA,KAEd5B,EAAC6B,EAAW,CAAA7D,SAAEiB,EAAOE,QACrBa,EAAC8B,EAAiB,CACd1B,UAAU,OACVE,KAAK,SACLD,QAAS,IAAM5C,eAAAA,IACfuD,SAAUlD,eACE,SAASmB,EAAOE,QAAOnB,SAElCiB,EAAOI,WAGhBW,EAAC+B,EAAU,CAAA/D,SAAEA,IACbgC,EAACgC,EAAY,CAAAC,aAAelE,aAAM,EAANA,EAAQmE,gBAChClC,EAACmC,EAAgB,CAAC9B,QAtE/B,KACftB,GAAW,GACXrB,SAAAA,GAAU,WAqEuBuB,EAAOG,sBAQf,EAIjC9B,EAAY8E,YAAc"}
1
+ {"version":3,"file":"filter-modal.js","sources":["../../src/filter/filter-modal.tsx"],"sourcesContent":["import { FloatingFocusManager, useFloating } from \"@floating-ui/react\";\nimport { CrossIcon, FilterIcon } from \"@lifesg/react-icons\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Overlay } from \"src/overlay\";\nimport { inertValue } from \"src/shared/accessibility\";\nimport { FilterBadge } from \"./filter-badge\";\nimport { FilterContext } from \"./filter-context\";\nimport {\n FilterButton,\n FilterClearButton,\n FilterHeader,\n FilterTitle,\n FilterTitleGroup,\n FilterToggleContent,\n FloatingWrapper,\n MobileContainer,\n MobileOverlayContainer,\n} from \"./filter-modal.styles\";\nimport { FilterModalProps } from \"./types\";\nimport {\n FilterBody,\n FilterDoneButton,\n FilterFooter,\n FilterHeaderButton,\n} from \"./filter.styles\";\n\nexport const FilterModal = ({\n customLabels,\n onClear,\n onDone,\n onDismiss,\n onModalOpen,\n toggleFilterButtonStyle = \"light\",\n clearButtonDisabled = false,\n insets,\n count,\n children,\n toggleFilterButtonLabel: _toggleFilterButtonLabel,\n headerTitle: _headerTitle,\n doneButtonLabel: _doneButtonLabel,\n ...otherProps\n}: FilterModalProps) => {\n const { context, refs } = useFloating();\n const nodeRef = useRef<HTMLDivElement>(null);\n\n const [visible, setVisible] = useState(false);\n\n const handleShow = () => setVisible(true);\n const handleDismiss = () => {\n setVisible(false);\n onDismiss?.();\n };\n const handleDone = () => {\n setVisible(false);\n onDone?.();\n };\n\n const handleShowFilter = () => {\n handleShow();\n onModalOpen?.();\n };\n\n const labels = {\n toggle:\n customLabels?.toggleFilterButtonLabel ||\n _toggleFilterButtonLabel ||\n \"Filters\",\n title: customLabels?.headerTitle || _headerTitle || \"Filters\",\n done: customLabels?.doneButtonLabel || _doneButtonLabel || \"Done\",\n clear: customLabels?.clearButtonLabel || \"Clear\",\n };\n\n useEffect(() => {\n if (visible) {\n nodeRef.current?.focus();\n }\n }, [visible]);\n\n return (\n <FilterContext.Provider value={{ mode: \"mobile\", rootNode: nodeRef }}>\n <div {...otherProps}>\n <FilterButton\n data-testid=\"filter-show-button\"\n styleType={toggleFilterButtonStyle}\n onClick={handleShowFilter}\n type=\"button\"\n icon={<FilterIcon />}\n >\n <FilterToggleContent>\n <span>{labels.toggle}</span>\n <FilterBadge count={count} />\n </FilterToggleContent>\n </FilterButton>\n </div>\n <Overlay show={visible} disableTransition>\n <FloatingWrapper inert={inertValue(!visible)}>\n <FloatingFocusManager context={context} disabled={!visible}>\n <MobileOverlayContainer\n data-id=\"filter-mobile\"\n data-testid=\"filter-mobile\"\n ref={refs.setFloating}\n >\n <MobileContainer ref={nodeRef} tabIndex={0}>\n <FilterHeader $insetTop={insets?.top}>\n <FilterHeaderButton\n onClick={handleDismiss}\n focusOutline=\"browser\"\n focusHighlight={false}\n aria-label={`close ${labels.title}`}\n >\n <CrossIcon />\n </FilterHeaderButton>\n <FilterTitleGroup>\n <FilterTitle>\n {labels.title}\n </FilterTitle>\n <FilterBadge count={count} />\n </FilterTitleGroup>\n <FilterClearButton\n styleType=\"link\"\n type=\"button\"\n onClick={() => onClear?.()}\n disabled={clearButtonDisabled}\n aria-label={`clear ${labels.title}`}\n >\n {labels.clear}\n </FilterClearButton>\n </FilterHeader>\n <FilterBody>{children}</FilterBody>\n <FilterFooter $insetBottom={insets?.bottom}>\n <FilterDoneButton onClick={handleDone}>\n {labels.done}\n </FilterDoneButton>\n </FilterFooter>\n </MobileContainer>\n </MobileOverlayContainer>\n </FloatingFocusManager>\n </FloatingWrapper>\n </Overlay>\n </FilterContext.Provider>\n );\n};\n\nFilterModal.displayName = \"Filter.Modal\";\n"],"names":["FilterModal","_a","customLabels","onClear","onDone","onDismiss","onModalOpen","toggleFilterButtonStyle","clearButtonDisabled","insets","count","children","toggleFilterButtonLabel","_toggleFilterButtonLabel","headerTitle","_headerTitle","doneButtonLabel","_doneButtonLabel","otherProps","__rest","context","refs","useFloating","nodeRef","useRef","visible","setVisible","useState","labels","toggle","title","done","clear","clearButtonLabel","useEffect","current","focus","_jsxs","FilterContext","Provider","value","mode","rootNode","_jsx","Object","assign","FilterButton","styleType","onClick","type","icon","FilterIcon","FilterToggleContent","FilterBadge","Overlay","show","disableTransition","FloatingWrapper","inert","inertValue","FloatingFocusManager","disabled","MobileOverlayContainer","ref","setFloating","MobileContainer","tabIndex","FilterHeader","$insetTop","top","FilterHeaderButton","focusOutline","focusHighlight","CrossIcon","FilterTitleGroup","FilterTitle","FilterClearButton","FilterBody","FilterFooter","$insetBottom","bottom","FilterDoneButton","displayName"],"mappings":"i1BA0BO,MAAMA,EAAeC,IAAA,IAAAC,aAC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CAAA,UACX,gBAAe,cACX,gBACZC,IAAK1C,EAAK2C,YAAWrD,SAErB0B,EAAC4B,EAAe,CAACF,IAAKxC,EAAS2C,SAAU,EAACvD,SAAA,CACtC0B,EAAC8B,EAAY,CAAAC,UAAY3D,aAAM,EAANA,EAAQ4D,IAAG1D,SAAA,CAChCgC,EAAC2B,EAAkB,CACftB,QAzDd,KAClBtB,GAAW,GACXrB,SAAAA,GAAa,EAwDmBkE,aAAa,UACbC,gBAAgB,EAAK,aACT,SAAS5C,EAAOE,QAAOnB,SAEnCgC,EAAC8B,EAAS,CAAA,KAEdpC,EAACqC,EAAgB,CAAA/D,SAAA,CACbgC,EAACgC,EAAW,CAAAhE,SACPiB,EAAOE,QAEZa,EAACU,EAAW,CAAC3C,MAAOA,OAExBiC,EAACiC,EAAiB,CACd7B,UAAU,OACVE,KAAK,SACLD,QAAS,IAAM7C,aAAO,EAAPA,IACf0D,SAAUrD,EAAmB,aACjB,SAASoB,EAAOE,QAAOnB,SAElCiB,EAAOI,WAGhBW,EAACkC,EAAU,CAAAlE,SAAEA,IACbgC,EAACmC,EAAY,CAAAC,aAAetE,aAAM,EAANA,EAAQuE,OAAMrE,SACtCgC,EAACsC,EAAgB,CAACjC,QA9E/B,KACftB,GAAW,GACXtB,SAAAA,GAAU,EA4EuDO,SAChCiB,EAAOG,sBAQf,EAIjC/B,EAAYkF,YAAc"}
@@ -5,7 +5,9 @@ export declare const MobileContainer: import("styled-components/dist/types").ISt
5
5
  export declare const MobileOverlayContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
6
6
  export declare const FloatingWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
7
7
  export declare const FilterHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$insetTop"> & FilterHeaderProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$insetTop"> & FilterHeaderProps, never>>> & string;
8
+ export declare const FilterTitleGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
8
9
  export declare const FilterTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>>> & string;
10
+ export declare const FilterToggleContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
9
11
  export declare const FilterClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>, never> & Partial<Pick<import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>, never>>> & string & Omit<(props: import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null, keyof import("react").Component<any, {}, any>>;
10
12
  export declare const FilterButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("..").ButtonWithIconProps & import("react").RefAttributes<HTMLButtonElement>, never> & Partial<Pick<import("..").ButtonWithIconProps & import("react").RefAttributes<HTMLButtonElement>, never>>> & string & Omit<(props: import("..").ButtonWithIconProps & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null, keyof import("react").Component<any, {}, any>>;
11
13
  export {};
@@ -1,30 +1,39 @@
1
- import t from"styled-components";import{Button as i}from"../button/button.js";import{ButtonWithIcon as o}from"../button-with-icon/button-with-icon.js";import{Colour as n,Font as e,Spacing as r}from"../theme/index.js";const d=t.div`
2
- background-color: ${n["bg-strong"]};
1
+ import i from"styled-components";import{Button as t}from"../button/button.js";import{ButtonWithIcon as n}from"../button-with-icon/button-with-icon.js";import{Colour as o,Spacing as e,Font as a}from"../theme/index.js";const r=i.div`
2
+ background-color: ${o["bg-strong"]};
3
3
  height: 100%;
4
4
  width: 100%;
5
5
  display: flex;
6
6
  flex-direction: column;
7
- `,g=t.div`
8
- background-color: ${n.bg};
7
+ `,g=i.div`
8
+ background-color: ${o.bg};
9
9
  height: 100%;
10
10
  width: 100%;
11
- `,a=t.div`
11
+ `,s=i.div`
12
12
  height: 100%;
13
- `,c=t.div`
13
+ `,c=i.div`
14
14
  display: flex;
15
15
  align-items: center;
16
- background-color: ${n.bg};
17
- ${t=>t.$insetTop&&`padding-top: ${t.$insetTop}px;`}
18
- `,l=t.h2`
19
- ${e["heading-xs-semibold"]}
16
+ background-color: ${o.bg};
17
+ ${i=>i.$insetTop&&`padding-top: ${i.$insetTop}px;`}
18
+ `,d=i.div`
20
19
  flex: 1;
21
- text-align: center;
22
- margin: ${r["spacing-24"]} 0;
23
- `,p=t(i.Small)`
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: center;
23
+ gap: ${e["spacing-8"]};
24
+ margin: ${e["spacing-24"]} 0;
25
+ `,l=i.h2`
26
+ ${a["heading-xs-semibold"]}
27
+ color: ${o.text};
28
+ `,p=i.span`
29
+ display: inline-flex;
30
+ align-items: center;
31
+ gap: ${e["spacing-8"]};
32
+ `,m=i(t.Small)`
24
33
  background-color: transparent;
25
34
  height: 100%;
26
- padding: ${r["spacing-24"]} ${r["spacing-20"]};
27
- `,s=t(o.Default)`
35
+ padding: ${e["spacing-24"]} ${e["spacing-20"]};
36
+ `,h=i(n.Default)`
28
37
  width: 100%;
29
- `;export{s as FilterButton,p as FilterClearButton,c as FilterHeader,l as FilterTitle,a as FloatingWrapper,d as MobileContainer,g as MobileOverlayContainer};
38
+ `;export{h as FilterButton,m as FilterClearButton,c as FilterHeader,l as FilterTitle,d as FilterTitleGroup,p as FilterToggleContent,s as FloatingWrapper,r as MobileContainer,g as MobileOverlayContainer};
30
39
  //# sourceMappingURL=filter-modal.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-modal.styles.js","sources":["../../src/filter/filter-modal.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { ButtonWithIcon } from \"../button-with-icon\";\nimport { Colour, Font, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\ntype FilterHeaderProps = {\n $insetTop?: number | undefined;\n};\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const MobileContainer = styled.div`\n background-color: ${Colour[\"bg-strong\"]};\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: column;\n`;\n\nexport const MobileOverlayContainer = styled.div`\n background-color: ${Colour[\"bg\"]};\n height: 100%;\n width: 100%;\n`;\n\nexport const FloatingWrapper = styled.div`\n height: 100%;\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeader = styled.div<FilterHeaderProps>`\n display: flex;\n align-items: center;\n background-color: ${Colour[\"bg\"]};\n ${(props) => props.$insetTop && `padding-top: ${props.$insetTop}px;`}\n`;\n\nexport const FilterTitle = styled.h2`\n ${Font[\"heading-xs-semibold\"]}\n flex: 1;\n text-align: center;\n margin: ${Spacing[\"spacing-24\"]} 0;\n`;\n\nexport const FilterClearButton = styled(Button.Small)`\n background-color: transparent;\n height: 100%;\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n`;\n\n// =============================================================================\n// COMPONENT STYLES\n// =============================================================================\n\nexport const FilterButton = styled(ButtonWithIcon.Default)`\n width: 100%;\n`;\n"],"names":["MobileContainer","styled","div","Colour","MobileOverlayContainer","FloatingWrapper","FilterHeader","props","$insetTop","FilterTitle","h2","Font","Spacing","FilterClearButton","Button","Small","FilterButton","ButtonWithIcon","Default"],"mappings":"yNAgBO,MAAMA,EAAkBC,EAAOC,GAAG;wBACjBC,EAAO;;;;;EAOlBC,EAAyBH,EAAOC,GAAG;wBACxBC,EAAW;;;EAKtBE,EAAkBJ,EAAOC,GAAG;;EAQ5BI,EAAeL,EAAOC,GAAsB;;;wBAGjCC,EAAW;MAC5BI,GAAUA,EAAMC,WAAa,gBAAgBD,EAAMC;EAG7CC,EAAcR,EAAOS,EAAE;MAC9BC,EAAK;;;cAGGC,EAAQ;EAGTC,EAAoBZ,EAAOa,EAAOC,MAAM;;;eAGtCH,EAAQ,iBAAiBA,EAAQ;EAOnCI,EAAef,EAAOgB,EAAeC,QAAQ;;"}
1
+ {"version":3,"file":"filter-modal.styles.js","sources":["../../src/filter/filter-modal.styles.tsx"],"sourcesContent":["import styled from \"styled-components\";\nimport { Button } from \"../button\";\nimport { ButtonWithIcon } from \"../button-with-icon\";\nimport { Colour, Font, Spacing } from \"../theme\";\n\n// =============================================================================\n// STYLE INTERFACES\n// =============================================================================\ntype FilterHeaderProps = {\n $insetTop?: number | undefined;\n};\n\n// =============================================================================\n// CONTAINER STYLES\n// =============================================================================\n\nexport const MobileContainer = styled.div`\n background-color: ${Colour[\"bg-strong\"]};\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: column;\n`;\n\nexport const MobileOverlayContainer = styled.div`\n background-color: ${Colour[\"bg\"]};\n height: 100%;\n width: 100%;\n`;\n\nexport const FloatingWrapper = styled.div`\n height: 100%;\n`;\n\n// =============================================================================\n// HEADER STYLES\n// =============================================================================\n\nexport const FilterHeader = styled.div<FilterHeaderProps>`\n display: flex;\n align-items: center;\n background-color: ${Colour[\"bg\"]};\n ${(props) => props.$insetTop && `padding-top: ${props.$insetTop}px;`}\n`;\n\nexport const FilterTitleGroup = styled.div`\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: ${Spacing[\"spacing-8\"]};\n margin: ${Spacing[\"spacing-24\"]} 0;\n`;\n\nexport const FilterTitle = styled.h2`\n ${Font[\"heading-xs-semibold\"]}\n color: ${Colour[\"text\"]};\n`;\n\nexport const FilterToggleContent = styled.span`\n display: inline-flex;\n align-items: center;\n gap: ${Spacing[\"spacing-8\"]};\n`;\n\nexport const FilterClearButton = styled(Button.Small)`\n background-color: transparent;\n height: 100%;\n padding: ${Spacing[\"spacing-24\"]} ${Spacing[\"spacing-20\"]};\n`;\n\n// =============================================================================\n// COMPONENT STYLES\n// =============================================================================\n\nexport const FilterButton = styled(ButtonWithIcon.Default)`\n width: 100%;\n`;\n"],"names":["MobileContainer","styled","div","Colour","MobileOverlayContainer","FloatingWrapper","FilterHeader","props","$insetTop","FilterTitleGroup","Spacing","FilterTitle","h2","Font","FilterToggleContent","span","FilterClearButton","Button","Small","FilterButton","ButtonWithIcon","Default"],"mappings":"yNAgBO,MAAMA,EAAkBC,EAAOC,GAAG;wBACjBC,EAAO;;;;;EAOlBC,EAAyBH,EAAOC,GAAG;wBACxBC,EAAW;;;EAKtBE,EAAkBJ,EAAOC,GAAG;;EAQ5BI,EAAeL,EAAOC,GAAsB;;;wBAGjCC,EAAW;MAC5BI,GAAUA,EAAMC,WAAa,gBAAgBD,EAAMC;EAG7CC,EAAmBR,EAAOC,GAAG;;;;;WAK/BQ,EAAQ;cACLA,EAAQ;EAGTC,EAAcV,EAAOW,EAAE;MAC9BC,EAAK;aACEV,EAAa;EAGbW,EAAsBb,EAAOc,IAAI;;;WAGnCL,EAAQ;EAGNM,EAAoBf,EAAOgB,EAAOC,MAAM;;;eAGtCR,EAAQ,iBAAiBA,EAAQ;EAOnCS,EAAelB,EAAOmB,EAAeC,QAAQ;;"}
@@ -1,5 +1,5 @@
1
1
  import { FilterSidebarProps } from "./types";
2
2
  export declare const FilterSidebar: {
3
- ({ customLabels, onClear, clearButtonDisabled, children, headerTitle: _headerTitle, ...otherProps }: FilterSidebarProps): import("react/jsx-runtime").JSX.Element;
3
+ ({ customLabels, onClear, clearButtonDisabled, count, children, headerTitle: _headerTitle, ...otherProps }: FilterSidebarProps): import("react/jsx-runtime").JSX.Element;
4
4
  displayName: string;
5
5
  };
@@ -1,2 +1,2 @@
1
- import{__rest as e}from"../_virtual/_tslib.js";import{jsx as l,jsxs as t}from"react/jsx-runtime";import{useRef as r}from"react";import{FilterContext as i}from"./filter-context.js";import{DesktopContainer as a,FilterHeader as o,FilterTitle as d,FilterClearButton as s}from"./filter-sidebar.styles.js";import{FilterBody as n}from"./filter.styles.js";const c=c=>{var{customLabels:m,onClear:u,clearButtonDisabled:f=!1,children:b,headerTitle:p}=c,h=e(c,["customLabels","onClear","clearButtonDisabled","children","headerTitle"]);const v=r(null),j={title:(null==m?void 0:m.headerTitle)||p||"Filters",clear:(null==m?void 0:m.clearButtonLabel)||"Clear"};return l(i.Provider,{value:{mode:"default",rootNode:v},children:t(a,Object.assign({"data-id":"filter-desktop","data-testid":"filter-desktop",ref:v},h,{children:[t(o,{children:[l(d,{children:j.title}),l(s,{styleType:"link",type:"button",onClick:()=>null==u?void 0:u(),disabled:f,"aria-label":`clear ${j.title}`,children:j.clear})]}),l(n,{children:b})]}))})};c.displayName="Filter.Sidebar";export{c as FilterSidebar};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsx as t,jsxs as l}from"react/jsx-runtime";import{useRef as r}from"react";import{FilterBadge as i}from"./filter-badge.js";import{FilterContext as o}from"./filter-context.js";import{DesktopContainer as a,FilterHeader as d,FilterTitleGroup as n,FilterTitle as s,FilterClearButton as c}from"./filter-sidebar.styles.js";import{FilterBody as m}from"./filter.styles.js";const u=u=>{var{customLabels:f,onClear:b,clearButtonDisabled:p=!1,count:h,children:j,headerTitle:v}=u,y=e(u,["customLabels","onClear","clearButtonDisabled","count","children","headerTitle"]);const k=r(null),C={title:(null==f?void 0:f.headerTitle)||v||"Filters",clear:(null==f?void 0:f.clearButtonLabel)||"Clear"};return t(o.Provider,{value:{mode:"default",rootNode:k},children:l(a,Object.assign({"data-id":"filter-desktop","data-testid":"filter-desktop",ref:k},y,{children:[l(d,{children:[l(n,{children:[t(s,{children:C.title}),t(i,{count:h})]}),t(c,{styleType:"link",type:"button",onClick:()=>null==b?void 0:b(),disabled:p,"aria-label":`clear ${C.title}`,children:C.clear})]}),t(m,{children:j})]}))})};u.displayName="Filter.Sidebar";export{u as FilterSidebar};
2
2
  //# sourceMappingURL=filter-sidebar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-sidebar.js","sources":["../../src/filter/filter-sidebar.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { FilterContext } from \"./filter-context\";\nimport {\n DesktopContainer,\n FilterClearButton,\n FilterHeader,\n FilterTitle,\n} from \"./filter-sidebar.styles\";\nimport { FilterSidebarProps } from \"./types\";\nimport { FilterBody } from \"./filter.styles\";\n\nexport const FilterSidebar = ({\n customLabels,\n onClear,\n clearButtonDisabled = false,\n children,\n headerTitle: _headerTitle,\n ...otherProps\n}: FilterSidebarProps) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n\n const labels = {\n title: customLabels?.headerTitle || _headerTitle || \"Filters\",\n clear: customLabels?.clearButtonLabel || \"Clear\",\n };\n\n return (\n <FilterContext.Provider value={{ mode: \"default\", rootNode: nodeRef }}>\n <DesktopContainer\n data-id=\"filter-desktop\"\n data-testid=\"filter-desktop\"\n ref={nodeRef}\n {...otherProps}\n >\n <FilterHeader>\n <FilterTitle>{labels.title}</FilterTitle>\n <FilterClearButton\n styleType=\"link\"\n type=\"button\"\n onClick={() => onClear?.()}\n disabled={clearButtonDisabled}\n aria-label={`clear ${labels.title}`}\n >\n {labels.clear}\n </FilterClearButton>\n </FilterHeader>\n <FilterBody>{children}</FilterBody>\n </DesktopContainer>\n </FilterContext.Provider>\n );\n};\n\nFilterSidebar.displayName = \"Filter.Sidebar\";\n"],"names":["FilterSidebar","_a","customLabels","onClear","clearButtonDisabled","children","headerTitle","_headerTitle","otherProps","__rest","nodeRef","useRef","labels","title","clear","clearButtonLabel","_jsx","FilterContext","Provider","value","mode","rootNode","_jsxs","DesktopContainer","Object","assign","ref","FilterHeader","FilterTitle","FilterClearButton","styleType","type","onClick","disabled","FilterBody","displayName"],"mappings":"4VAWO,MAAMA,EAAiBC,IAAA,IAAAC,aAC1BA,EAAYC,QACZA,EAAOC,oBACPA,GAAsB,EAAKC,SAC3BA,EACAC,YAAaC,GAAYN,EACtBO,EAAUC,EAAAR,EANa,2EAQ1B,MAAMS,EAAUC,EAAuB,MAEjCC,EAAS,CACXC,OAAOX,aAAY,EAAZA,EAAcI,cAAeC,GAAgB,UACpDO,OAAOZ,eAAAA,EAAca,mBAAoB,SAG7C,OACIC,EAACC,EAAcC,SAAQ,CAACC,MAAO,CAAEC,KAAM,UAAWC,SAAUX,GAASL,SACjEiB,EAACC,EAAgBC,OAAAC,OAAA,CAAA,UACL,iBAAgB,cACZ,iBACZC,IAAKhB,GACDF,EAAU,CAAAH,SAAA,CAEdiB,EAACK,EAAY,CAAAtB,SAAA,CACTW,EAACY,EAAW,CAAAvB,SAAEO,EAAOC,QACrBG,EAACa,EAAiB,CACdC,UAAU,OACVC,KAAK,SACLC,QAAS,IAAM7B,eAAAA,IACf8B,SAAU7B,EAAmB,aACjB,SAASQ,EAAOC,QAAOR,SAElCO,EAAOE,WAGhBE,EAACkB,EAAU,CAAA7B,SAAEA,SAEI,EAIjCL,EAAcmC,YAAc"}
1
+ {"version":3,"file":"filter-sidebar.js","sources":["../../src/filter/filter-sidebar.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport { FilterBadge } from \"./filter-badge\";\nimport { FilterContext } from \"./filter-context\";\nimport {\n DesktopContainer,\n FilterClearButton,\n FilterHeader,\n FilterTitle,\n FilterTitleGroup,\n} from \"./filter-sidebar.styles\";\nimport { FilterSidebarProps } from \"./types\";\nimport { FilterBody } from \"./filter.styles\";\n\nexport const FilterSidebar = ({\n customLabels,\n onClear,\n clearButtonDisabled = false,\n count,\n children,\n headerTitle: _headerTitle,\n ...otherProps\n}: FilterSidebarProps) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n\n const labels = {\n title: customLabels?.headerTitle || _headerTitle || \"Filters\",\n clear: customLabels?.clearButtonLabel || \"Clear\",\n };\n\n return (\n <FilterContext.Provider value={{ mode: \"default\", rootNode: nodeRef }}>\n <DesktopContainer\n data-id=\"filter-desktop\"\n data-testid=\"filter-desktop\"\n ref={nodeRef}\n {...otherProps}\n >\n <FilterHeader>\n <FilterTitleGroup>\n <FilterTitle>{labels.title}</FilterTitle>\n <FilterBadge count={count} />\n </FilterTitleGroup>\n <FilterClearButton\n styleType=\"link\"\n type=\"button\"\n onClick={() => onClear?.()}\n disabled={clearButtonDisabled}\n aria-label={`clear ${labels.title}`}\n >\n {labels.clear}\n </FilterClearButton>\n </FilterHeader>\n <FilterBody>{children}</FilterBody>\n </DesktopContainer>\n </FilterContext.Provider>\n );\n};\n\nFilterSidebar.displayName = \"Filter.Sidebar\";\n"],"names":["FilterSidebar","_a","customLabels","onClear","clearButtonDisabled","count","children","headerTitle","_headerTitle","otherProps","__rest","nodeRef","useRef","labels","title","clear","clearButtonLabel","_jsx","FilterContext","Provider","value","mode","rootNode","_jsxs","DesktopContainer","Object","assign","ref","FilterHeader","FilterTitleGroup","FilterTitle","FilterBadge","FilterClearButton","styleType","type","onClick","disabled","FilterBody","displayName"],"mappings":"kaAaO,MAAMA,EAAiBC,QAAAC,aAC1BA,EAAYC,QACZA,EAAOC,oBACPA,GAAsB,EAAKC,MAC3BA,EAAKC,SACLA,EACAC,YAAaC,GAAYP,EACtBQ,EAAUC,EAAAT,EAPa,mFAS1B,MAAMU,EAAUC,EAAuB,MAEjCC,EAAS,CACXC,OAAOZ,aAAY,EAAZA,EAAcK,cAAeC,GAAgB,UACpDO,OAAOb,eAAAA,EAAcc,mBAAoB,SAG7C,OACIC,EAACC,EAAcC,SAAQ,CAACC,MAAO,CAAEC,KAAM,UAAWC,SAAUX,YACxDY,EAACC,EAAgBC,OAAAC,OAAA,CAAA,UACL,iBAAgB,cACZ,iBACZC,IAAKhB,GACDF,aAEJc,EAACK,EAAY,CAAAtB,SAAA,CACTiB,EAACM,EAAgB,CAAAvB,SAAA,CACbW,EAACa,EAAW,CAAAxB,SAAEO,EAAOC,QACrBG,EAACc,EAAW,CAAC1B,MAAOA,OAExBY,EAACe,GACGC,UAAU,OACVC,KAAK,SACLC,QAAS,IAAMhC,aAAO,EAAPA,IACfiC,SAAUhC,EAAmB,aACjB,SAASS,EAAOC,QAAOR,SAElCO,EAAOE,WAGhBE,EAACoB,EAAU,CAAA/B,SAAEA,SAEI,EAIjCN,EAAcsC,YAAc"}
@@ -1,4 +1,5 @@
1
1
  export declare const DesktopContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
2
2
  export declare const FilterHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
3
+ export declare const FilterTitleGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
3
4
  export declare const FilterTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>>> & string;
4
5
  export declare const FilterClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>, never> & Partial<Pick<import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>, never>>> & string & Omit<(props: import("..").ButtonProps & import("react").RefAttributes<HTMLButtonElement>) => React.ReactElement | null, keyof import("react").Component<any, {}, any>>;