@lifesg/react-design-system 3.5.0-canary.2 → 3.5.0-canary.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/cjs/data-table/data-table.js +1 -1
  2. package/cjs/data-table/data-table.js.map +1 -1
  3. package/cjs/data-table/data-table.styles.js +61 -52
  4. package/cjs/data-table/data-table.styles.js.map +1 -1
  5. package/cjs/external/dompurify/dist/purify.es.js +2 -2
  6. package/cjs/external/dompurify/dist/purify.es.js.map +1 -1
  7. package/cjs/file-upload/file-list-item/file-list-item.styles.js +4 -3
  8. package/cjs/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  9. package/cjs/form/form-textarea.style.js +1 -1
  10. package/cjs/form/form-textarea.style.js.map +1 -1
  11. package/cjs/input-textarea/textarea.style.js +1 -0
  12. package/cjs/input-textarea/textarea.style.js.map +1 -1
  13. package/cjs/predictive-text-input/predictive-text-input.js +1 -1
  14. package/cjs/predictive-text-input/predictive-text-input.js.map +1 -1
  15. package/cjs/shared/dropdown-wrapper/element-with-dropdown.js +1 -1
  16. package/cjs/shared/dropdown-wrapper/element-with-dropdown.js.map +1 -1
  17. package/cjs/table/table.styles.js +4 -6
  18. package/cjs/table/table.styles.js.map +1 -1
  19. package/cjs/util/use-throttle.js +2 -0
  20. package/cjs/util/use-throttle.js.map +1 -0
  21. package/codemods/data.ts +33 -1
  22. package/codemods/index.ts +140 -55
  23. package/data-table/data-table.js +1 -1
  24. package/data-table/data-table.js.map +1 -1
  25. package/data-table/data-table.styles.d.ts +11 -11
  26. package/data-table/data-table.styles.js +73 -64
  27. package/data-table/data-table.styles.js.map +1 -1
  28. package/external/dompurify/dist/purify.es.js +2 -2
  29. package/external/dompurify/dist/purify.es.js.map +1 -1
  30. package/file-upload/file-list-item/file-list-item.styles.js +1 -0
  31. package/file-upload/file-list-item/file-list-item.styles.js.map +1 -1
  32. package/form/form-textarea.style.js +1 -1
  33. package/form/form-textarea.style.js.map +1 -1
  34. package/input-textarea/textarea.style.js +19 -18
  35. package/input-textarea/textarea.style.js.map +1 -1
  36. package/package.json +1 -1
  37. package/predictive-text-input/predictive-text-input.js +1 -1
  38. package/predictive-text-input/predictive-text-input.js.map +1 -1
  39. package/shared/dropdown-wrapper/element-with-dropdown.d.ts +5 -4
  40. package/shared/dropdown-wrapper/element-with-dropdown.js +1 -1
  41. package/shared/dropdown-wrapper/element-with-dropdown.js.map +1 -1
  42. package/table/table.styles.js +10 -12
  43. package/table/table.styles.js.map +1 -1
  44. package/util/index.d.ts +1 -0
  45. package/util/use-throttle.d.ts +1 -0
  46. package/util/use-throttle.js +2 -0
  47. package/util/use-throttle.js.map +1 -0
package/codemods/index.ts CHANGED
@@ -1,23 +1,36 @@
1
- import { API, FileInfo, JSCodeshift } from "jscodeshift";
1
+ import {
2
+ API,
3
+ ASTPath,
4
+ FileInfo,
5
+ JSCodeshift,
6
+ MemberExpression,
7
+ } from "jscodeshift";
2
8
  import { CodemodUtils } from "../codemod-utils";
3
- import { sizePropMapping } from "./data";
9
+ import { textComponentMap, textStyleFontMap, weightMap } from "./data";
4
10
 
5
11
  // ======= Constants ======= //
6
12
 
7
13
  const IMPORT_PATHS = {
8
- TEXT_LIST: "@lifesg/react-design-system/text-list",
9
- V2_TEXT_LIST: "@lifesg/react-design-system/v2_text-list",
14
+ V2_TEXT: "@lifesg/react-design-system/v2_text",
10
15
  DESIGN_SYSTEM: "@lifesg/react-design-system",
16
+ TYPOGRAPHY: "@lifesg/react-design-system/typography",
17
+ THEME: "@lifesg/react-design-system/theme",
11
18
  };
12
19
 
13
20
  const IMPORT_SPECIFIERS = {
14
- TEXT_LIST: "TextList",
15
- V2_TEXT_LIST: "V2_TextList",
21
+ V2_TEXT: "V2_Text",
22
+ V2_TEXT_STYLE_HELPER: "V2_TextStyleHelper",
23
+ TYPOGRAPHY: "Typography",
24
+ FONT: "Font",
16
25
  };
17
26
 
18
27
  const JSX_IDENTIFIERS = {
19
- TEXT_LIST: "TextList",
20
- V2_TEXT_LIST: "V2_TextList",
28
+ V2_TEXT: "V2_Text",
29
+ TYPOGRAPHY: "Typography",
30
+ };
31
+
32
+ const IDENTIFIERS = {
33
+ V2_GET_TEXT_STYLE: "getTextStyle",
21
34
  };
22
35
 
23
36
  // ======= Transformer Function ======= //
@@ -26,84 +39,156 @@ export default function transformer(file: FileInfo, api: API) {
26
39
  const j: JSCodeshift = api.jscodeshift;
27
40
  const source = j(file.source);
28
41
 
29
- const isV2TextListImport = CodemodUtils.hasImport(
42
+ const importsText = CodemodUtils.hasImport(
43
+ source,
44
+ api,
45
+ [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
46
+ IMPORT_SPECIFIERS.V2_TEXT
47
+ );
48
+ const importsTextStyleHelper = CodemodUtils.hasImport(
30
49
  source,
31
50
  api,
32
- [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT_LIST],
33
- IMPORT_SPECIFIERS.V2_TEXT_LIST
51
+ [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
52
+ IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER
34
53
  );
35
54
 
36
- if (isV2TextListImport) {
55
+ const replaceWithTypography = (
56
+ path: ASTPath<MemberExpression>,
57
+ newComponentValue: string
58
+ ) => {
59
+ path.replace(
60
+ j.memberExpression(
61
+ j.identifier(JSX_IDENTIFIERS.TYPOGRAPHY),
62
+ j.identifier(newComponentValue)
63
+ )
64
+ );
65
+ };
66
+
67
+ if (importsText) {
37
68
  CodemodUtils.addImport(
38
69
  source,
39
70
  api,
40
- IMPORT_PATHS.TEXT_LIST,
41
- IMPORT_SPECIFIERS.TEXT_LIST
71
+ IMPORT_PATHS.TYPOGRAPHY,
72
+ IMPORT_SPECIFIERS.TYPOGRAPHY
42
73
  );
43
74
 
44
75
  CodemodUtils.removeImport(
45
76
  source,
46
77
  api,
47
- [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT_LIST],
48
- IMPORT_SPECIFIERS.V2_TEXT_LIST
78
+ [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
79
+ IMPORT_SPECIFIERS.V2_TEXT
49
80
  );
50
81
 
51
82
  source
52
- .find(j.Identifier, { name: JSX_IDENTIFIERS.V2_TEXT_LIST })
83
+ .find(j.Identifier, { name: JSX_IDENTIFIERS.V2_TEXT })
53
84
  .forEach((path) => {
54
- path.node.name = JSX_IDENTIFIERS.TEXT_LIST;
85
+ // Replace V2_Text with Typography
86
+ path.node.name = JSX_IDENTIFIERS.TYPOGRAPHY;
55
87
  });
56
88
 
89
+ // Map to respective V3 Typography component usage
57
90
  source.find(j.MemberExpression).forEach((path) => {
58
- if (
59
- j.Identifier.check(path.node.object) &&
60
- path.node.object.name === JSX_IDENTIFIERS.V2_TEXT_LIST
61
- ) {
62
- path.node.object.name = JSX_IDENTIFIERS.TEXT_LIST;
91
+ const propertyNameParts: string[] = [];
92
+ let currentPath = path.node;
93
+ let startsWithTypography = false;
94
+
95
+ while (j.MemberExpression.check(currentPath)) {
96
+ const property = currentPath.property;
97
+ const object = currentPath.object;
98
+
99
+ if (j.Identifier.check(property)) {
100
+ propertyNameParts.unshift(property.name);
101
+ }
102
+
103
+ if (j.MemberExpression.check(object)) {
104
+ currentPath = object;
105
+ } else if (j.Identifier.check(object)) {
106
+ if (object.name === JSX_IDENTIFIERS.TYPOGRAPHY) {
107
+ startsWithTypography = true;
108
+ }
109
+ break;
110
+ } else {
111
+ break;
112
+ }
63
113
  }
64
- });
65
114
 
66
- source.find(j.JSXMemberExpression).forEach((path) => {
67
- if (
68
- j.JSXIdentifier.check(path.node.object) &&
69
- path.node.object.name === JSX_IDENTIFIERS.V2_TEXT_LIST
70
- ) {
71
- path.node.object.name = JSX_IDENTIFIERS.TEXT_LIST;
115
+ if (startsWithTypography) {
116
+ const propertyName = propertyNameParts.join(
117
+ "."
118
+ ) as keyof typeof textComponentMap;
119
+ const newTypographyValue = textComponentMap[propertyName];
120
+ if (newTypographyValue) {
121
+ replaceWithTypography(path, newTypographyValue);
122
+ }
72
123
  }
73
124
  });
125
+ }
74
126
 
75
- source.find(j.JSXOpeningElement).forEach((path) => {
76
- const openingElement = path.node;
77
- let isTextListElement = false;
127
+ if (importsTextStyleHelper) {
128
+ let usesTextStyleHelper = false;
78
129
 
130
+ source.find(j.CallExpression).forEach((path) => {
79
131
  if (
80
- j.JSXMemberExpression.check(openingElement.name) &&
81
- j.JSXIdentifier.check(openingElement.name.object) &&
82
- openingElement.name.object.name === JSX_IDENTIFIERS.TEXT_LIST
132
+ !j.CallExpression.check(path.node) ||
133
+ !j.MemberExpression.check(path.node.callee) ||
134
+ !j.Identifier.check(path.node.callee.object) ||
135
+ path.node.callee.object.name !==
136
+ IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER ||
137
+ !j.Identifier.check(path.node.callee.property) ||
138
+ path.node.callee.property.name !== IDENTIFIERS.V2_GET_TEXT_STYLE
83
139
  ) {
84
- isTextListElement = true;
140
+ return;
85
141
  }
86
142
 
87
- if (isTextListElement) {
88
- const attributes = openingElement.attributes;
89
-
90
- attributes?.forEach((attribute) => {
91
- if (
92
- j.JSXAttribute.check(attribute) &&
93
- attribute.name.name === "size" &&
94
- j.StringLiteral.check(attribute.value)
95
- ) {
96
- const sizeValue = attribute.value
97
- .value as keyof typeof sizePropMapping;
98
- if (sizePropMapping[sizeValue]) {
99
- attribute.value = j.literal(
100
- sizePropMapping[sizeValue]
101
- );
102
- }
103
- }
104
- });
143
+ const style = j.Literal.check(path.node.arguments[0])
144
+ ? path.node.arguments[0].value
145
+ : undefined;
146
+ const weight = j.Literal.check(path.node.arguments[1])
147
+ ? path.node.arguments[1].value
148
+ : "regular";
149
+
150
+ if (!style) {
151
+ return;
105
152
  }
153
+
154
+ const mappedType =
155
+ textStyleFontMap[style as keyof typeof textStyleFontMap];
156
+ const mappedWeight = weightMap[weight as keyof typeof weightMap];
157
+
158
+ j(path).replaceWith(() => {
159
+ return j.memberExpression(
160
+ j.identifier("Font"),
161
+ j.literal(`${mappedType}-${mappedWeight}`)
162
+ );
163
+ });
164
+
165
+ usesTextStyleHelper = true;
106
166
  });
167
+
168
+ if (usesTextStyleHelper) {
169
+ CodemodUtils.addImport(
170
+ source,
171
+ api,
172
+ IMPORT_PATHS.THEME,
173
+ IMPORT_SPECIFIERS.FONT
174
+ );
175
+ }
176
+
177
+ if (
178
+ !CodemodUtils.hasReferences(
179
+ source,
180
+ api,
181
+ [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
182
+ IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER
183
+ )
184
+ ) {
185
+ CodemodUtils.removeImport(
186
+ source,
187
+ api,
188
+ [IMPORT_PATHS.DESIGN_SYSTEM, IMPORT_PATHS.V2_TEXT],
189
+ IMPORT_SPECIFIERS.V2_TEXT_STYLE_HELPER
190
+ );
191
+ }
107
192
  }
108
193
 
109
194
  return source.toSource();
@@ -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 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};
1
+ import{__rest as e}from"../_virtual/_tslib.js";import{jsxs as t,jsx as i,Fragment as n}from"react/jsx-runtime";import{ArrowUpIcon as l,ArrowDownIcon as r}from"@lifesg/react-icons";import{useRef as o,useState as d,useEffect as a}from"react";import{useResizeDetector as s}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 c}from"../animations/loading-dots-spinner/loading-dots-spinner.js";import"styled-components";import{Checkbox as h}from"../checkbox/checkbox.js";import{ErrorDisplay as p}from"../error-display/error-display.js";import"../error-display/helper.js";import{VisuallyHidden as u,concatIds as m}from"../shared/accessibility/index.js";import{Typography as g}from"../typography/typography.js";import"../util/calendar-helper.js";import"../util/date-helper.js";import"../util/date-input-helper.js";import{useId as b}from"../util/simple-id-generator.js";import"../util/string-helper.js";import"@react-aria/live-announcer";import{useEvent as f}from"../util/use-event.js";import{useEventListener as y}from"../util/use-event-listener.js";import{useThrottle as w}from"../util/use-throttle.js";import{TableWrapper as $,TableContainer as k,Table as v,TableBody as S,TableHead as C,HeaderRow as j,BodyRow as H,EmptyViewCell as x,LoaderWrapper as B,ActionBarWrapper as R,ActionBar as I,TextButton as A,ActionBarSpacer as N,HeaderCell as K,CheckBoxWrapper as M,HeaderCellWrapper as V,ErrorDisplayTitle as L,BodyCell as z,BodyCellContent as D}from"./data-table.styles.js";const E=E=>{var{id:W,headers:_,rows:O,className:P,sortIndicators:T,alternatingRows:q,loadState:F="success",enableMultiSelect:G,selectedIds:J,disabledIds:Q,enableActionBar:U,enableSelectAll:X,enableStickyHeader:Y,emptyView:Z,actionBarContent:ee,renderCustomEmptyView:te,onHeaderClick:ie,onSelect:ne,onSelectAll:le,onClearSelectionClick:re}=E,oe=e(E,["id","headers","rows","className","sortIndicators","alternatingRows","loadState","enableMultiSelect","selectedIds","disabledIds","enableActionBar","enableSelectAll","enableStickyHeader","emptyView","actionBarContent","renderCustomEmptyView","onHeaderClick","onSelect","onSelectAll","onClearSelectionClick"]);const de=o(null),ae=o(null),se=o(null),ce=o(null),he=b(),pe=_.filter((e=>"string"!=typeof e&&!!e.keyColumn)),[ue,me]=d("inline"),[ge,be]=d(!1),[fe,ye]=d(!1),we=f((()=>{Ne()}));a((()=>{we()}),[we]);const $e=w((()=>Ne()),100);s({targetRef:ce,onResize:()=>$e()}),y("scroll",$e),y("scroll",$e,ce.current);const ke=()=>!!(O&&O.length&&J)&&J.length===O.length,ve=e=>!!(null==J?void 0:J.includes(e)),Se=e=>!!q&&e%2==1,Ce=e=>!!(null==Q?void 0:Q.includes(e)),je=e=>{if(oe["data-testid"])return`${oe["data-testid"]}-${e}`},He=()=>_.length+(G?1:0),xe=e=>null==T?void 0:T[e],Be=e=>{const t=xe(e);if(t)return"asc"===t?"ascending":"descending"},Re=e=>` by ${"asc"===xe(e)?"descending":"ascending"} order`,Ie=(e,t)=>`${he}-row-${e}-${t}-key-column`,Ae=e=>{const t=pe.map((t=>Ie(e,t.fieldKey)));return m(...t)},Ne=()=>{if(!ce.current||!ae.current||!se.current)return;const e=ce.current.getBoundingClientRect(),t=ae.current.getBoundingClientRect();let i="inline";const n=ce.current.scrollHeight>ce.current.clientHeight;if(e.top>window.innerHeight||e.bottom<0?i="inline":n?e.top>0&&e.top<window.innerHeight&&e.bottom>0&&e.bottom<window.innerHeight||e.top<0&&e.bottom>0&&e.bottom<window.innerHeight?i="sticky":e.bottom>window.innerHeight&&Math.max(e.top,t.bottom)+t.height<window.innerHeight&&(i="fixed"):e.bottom>window.innerHeight&&t.bottom+t.height<window.innerHeight&&(i="fixed"),be(n),me(i),"fixed"===i)ye(!0);else if("sticky"===i){const e=ce.current.scrollTop+ce.current.clientHeight<ce.current.scrollHeight;ye(e)}else ye(!1)},Ke=e=>{const{fieldKey:n,label:l,clickable:r=!1,style:o}="string"==typeof e?{fieldKey:e,label:e,style:void 0}:e,d=!!xe(n),a=(e=>`${he}-header-${e}`)(n);return t(K,{"data-testid":je(`header-${n}`),$clickable:r,scope:"col","aria-sort":Be(n),style:o,$isCheckbox:!1,onClick:()=>(e=>{null==ie||ie(e)})(n),children:[t(V,{id:a,children:["string"==typeof l?i(g.BodyBL,{weight:"bold",children:l}):l,Me(n)]}),(r||d)&&i(u,{children:t("button",{onClick:e=>((e,t)=>{e.stopPropagation(),null==ie||ie(t)})(e,n),children:[d&&"Sort ",i("span",{"aria-labelledby":a}),d&&Re(n)]})})]},n)},Me=e=>{const t=null==T?void 0:T[e];return t?"asc"===t?i(l,{"aria-hidden":!0,"data-testid":je(`header-${e}-arrowup`)}):i(r,{"aria-hidden":!0,"data-testid":je(`header-${e}-arrowdown`)}):i(n,{})},Ve=()=>i(K,{"data-testid":je("header-selection"),$clickable:!1,$isCheckbox:!0,scope:"col",children:t(M,{children:[i(u,{children:"Row selection"}),X&&i(h,{checked:ke(),indeterminate:!!J&&0!==J.length&&!ke(),disabled:!O||!O.length||!J,"aria-label":"Select all rows",onClick:()=>{le&&le(ke())}})]})}),Le=(e,t)=>{const n="string"!=typeof e?e.style:void 0,l="string"==typeof e?e:e.fieldKey,r=t.id.toString(),o=t[l],d=`${r}-${l}`;return i(z,{"data-testid":je(`row-${d}`),id:Ie(r,l),style:n,$isCheckbox:!1,children:"string"==typeof o||"number"==typeof o?i(D,{children:o}):"function"==typeof o?o(t,{isSelected:ve(r)}):o},d)},ze=e=>{const t=e.id.toString();return i(z,{"data-testid":je(`row-${t}-selection`),$isCheckbox:!0,children:i(M,{children:i(h,{checked:ve(t),"aria-labelledby":Ae(t),onClick:()=>{ne&&ne(t,!ve(t))},disabled:Ce(t),focusableWhenDisabled:Ce(t)})})})},De=()=>i(p,Object.assign({type:"no-item-found"},Z,{title:(null==Z?void 0:Z.title)?"string"==typeof Z.title?i(L,{weight:"bold",children:Z.title}):Z.title:i(L,{weight:"bold",children:"No <items> found"}),description:(null==Z?void 0:Z.description)?Z.description:"No matching rows"}));return t($,{id:W||"table-wrapper","data-testid":oe["data-testid"]||"table",className:P,ref:ce,tabIndex:0,$scrollable:ge,children:[i(k,{children:t(v,{ref:de,children:[i(C,{ref:ae,$stickyHeader:Y,children:t(j,{children:[G&&Ve(),_.map(Ke)]})}),i(S,{children:"success"===F?!O||O.length<1?i(H,{$alternating:!1,children:i(x,{colSpan:He(),children:te?te():De()})}):i(n,{children:null==O?void 0:O.map(((e,i)=>t(H,{"data-testid":je(`row-${e.id.toString()}`),$showLastRowBottomBorder:fe,$alternating:Se(i),$isSelectable:G,$isSelected:ve(e.id.toString()),children:[G&&ze(e),_.map((t=>Le(t,e)))]},e.id.toString())))}):i(H,{$alternating:!1,children:i("td",{colSpan:He(),children:i(B,{role:"status","aria-live":"polite","aria-label":"Loading table",children:"loading"===F&&i(c,{})})})})})]})}),U&&J&&J.length>0&&(()=>{var e,l,r,o;const d=null!==(e=null==J?void 0:J.length)&&void 0!==e?e:0,a="item"+(d>1?"s":"");return t(n,{children:[i(R,{ref:se,$strategy:ue,$left:fe?null===(r=null===(l=null==de?void 0:de.current)||void 0===l?void 0:l.getBoundingClientRect())||void 0===r?void 0:r.left:0,$width:null===(o=null==de?void 0:de.current)||void 0===o?void 0:o.clientWidth,children:t(I,{$float:fe,children:[i(g.BodyMD,{weight:"semibold",children:`${d} ${a} selected`}),i(A,{type:"button","aria-label":`Clear selection of ${d} ${a}`,onClick:re,children:"Clear selection"}),ee]})}),"sticky"!==ue&&i(N,{})]})})()]})};export{E 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 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,MAA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AIjClG,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 { useEffect, useRef, useState } from \"react\";\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 { useEvent, useEventListener, useId, useThrottle } from \"../util\";\nimport {\n ActionBar,\n ActionBarSpacer,\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 TableHead,\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 headerRef = useRef<HTMLTableSectionElement>(null);\n const actionBarWrapperRef = 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 [actionBarStrategy, setActionBarStrategy] = useState<\n \"sticky\" | \"fixed\" | \"inline\"\n >(\"inline\");\n const [scrollable, setScrollable] = useState(false);\n const [isFloatingActionBar, setIsFloatingActionBar] = useState(false);\n\n // =============================================================================\n // EFFECTS, EVENT LISTENERS\n // ============================================================================\n const useUpdateActionBarBehaviour = useEvent(() => {\n updateActionBarBehaviour();\n });\n\n useEffect(() => {\n useUpdateActionBarBehaviour();\n }, [useUpdateActionBarBehaviour]);\n\n const updateActionBarBehaviourThrottled = useThrottle(\n () => updateActionBarBehaviour(),\n 100\n );\n\n useResizeDetector({\n targetRef: wrapperRef,\n onResize: () => updateActionBarBehaviourThrottled(),\n });\n\n useEventListener(\"scroll\", updateActionBarBehaviourThrottled);\n useEventListener(\n \"scroll\",\n updateActionBarBehaviourThrottled,\n wrapperRef.current\n );\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 updateActionBarBehaviour = () => {\n if (\n !wrapperRef.current ||\n !headerRef.current ||\n !actionBarWrapperRef.current\n ) {\n return;\n }\n\n const wrapperBounds = wrapperRef.current.getBoundingClientRect();\n const headerBounds = headerRef.current.getBoundingClientRect();\n\n let strategy: typeof actionBarStrategy = \"inline\";\n\n const scrollable =\n wrapperRef.current.scrollHeight > wrapperRef.current.clientHeight;\n\n if (\n wrapperBounds.top > window.innerHeight ||\n wrapperBounds.bottom < 0\n ) {\n // if fully out of the viewport, disable floating\n strategy = \"inline\";\n } else if (scrollable) {\n if (\n wrapperBounds.top > 0 &&\n wrapperBounds.top < window.innerHeight &&\n wrapperBounds.bottom > 0 &&\n wrapperBounds.bottom < window.innerHeight\n ) {\n // if fully in the viewport, use the native sticky behaviour\n strategy = \"sticky\";\n } else if (\n wrapperBounds.top < 0 &&\n wrapperBounds.bottom > 0 &&\n wrapperBounds.bottom < window.innerHeight\n ) {\n // if partially offscreen at the top, use the native sticky behaviour\n strategy = \"sticky\";\n } else if (\n wrapperBounds.bottom > window.innerHeight &&\n Math.max(wrapperBounds.top, headerBounds.bottom) +\n headerBounds.height <\n window.innerHeight\n ) {\n // if offscreen at the bottom, pin to the viewport, up until the table/header\n strategy = \"fixed\";\n }\n } else if (\n wrapperBounds.bottom > window.innerHeight &&\n headerBounds.bottom + headerBounds.height < window.innerHeight\n ) {\n // if offscreen at the bottom, pin to the viewport, up until the header\n strategy = \"fixed\";\n }\n\n setScrollable(scrollable);\n setActionBarStrategy(strategy);\n\n if (strategy === \"fixed\") {\n setIsFloatingActionBar(true);\n } else if (strategy === \"sticky\") {\n const beforeScrollEnd =\n wrapperRef.current.scrollTop + wrapperRef.current.clientHeight <\n wrapperRef.current.scrollHeight;\n setIsFloatingActionBar(beforeScrollEnd);\n } else {\n setIsFloatingActionBar(false);\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 <TableHead ref={headerRef} $stickyHeader={enableStickyHeader}>\n <HeaderRow>\n {enableMultiSelect && renderHeaderCheckBox()}\n {headers.map(renderHeaderCell)}\n </HeaderRow>\n </TableHead>\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 $showLastRowBottomBorder={isFloatingActionBar}\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 const counter = `item${count > 1 ? \"s\" : \"\"}`;\n\n return (\n <>\n <ActionBarWrapper\n ref={actionBarWrapperRef}\n $strategy={actionBarStrategy}\n $left={\n isFloatingActionBar\n ? tableRef?.current?.getBoundingClientRect()?.left\n : 0\n }\n $width={tableRef?.current?.clientWidth}\n >\n <ActionBar $float={isFloatingActionBar}>\n <Typography.BodyMD weight=\"semibold\">{`${count} ${counter} selected`}</Typography.BodyMD>\n <TextButton\n type=\"button\"\n aria-label={`Clear selection of ${count} ${counter}`}\n onClick={onClearSelectionClick}\n >\n Clear selection\n </TextButton>\n {actionBarContent}\n </ActionBar>\n </ActionBarWrapper>\n {/* leave a fixed space when action bar floats to avoid layout shift */}\n {actionBarStrategy !== \"sticky\" && <ActionBarSpacer />}\n </>\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 tabIndex={0} // scrollable container must be focusable to support keyboard users\n $scrollable={scrollable}\n >\n <TableContainer>\n <Table ref={tableRef}>\n {renderHeaders()}\n <TableBody>\n {loadState === \"success\"\n ? renderRows()\n : renderLoader()}\n </TableBody>\n </Table>\n </TableContainer>\n {enableActionBar &&\n selectedIds &&\n selectedIds.length > 0 &&\n renderSelectionBar()}\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","headerRef","actionBarWrapperRef","wrapperRef","internalId","useId","keyColumns","filter","header","keyColumn","actionBarStrategy","setActionBarStrategy","useState","scrollable","setScrollable","isFloatingActionBar","setIsFloatingActionBar","useUpdateActionBarBehaviour","useEvent","updateActionBarBehaviour","useEffect","updateActionBarBehaviourThrottled","useThrottle","useResizeDetector","targetRef","onResize","useEventListener","current","isAllCheckboxSelected","length","isRowSelected","rowId","includes","isAlternatingRow","index","isDisabledRow","getDataTestId","subStr","getTotalColumns","getSortDirection","fieldKey","getHeaderAriaSort","sortDirection","getSortButtonAriaLabel","getCellId","getRowCheckboxAriaLabelledBy","keyColumnIds","map","concatIds","wrapperBounds","getBoundingClientRect","headerBounds","strategy","scrollHeight","clientHeight","top","window","innerHeight","bottom","Math","max","height","beforeScrollEnd","scrollTop","renderHeaderCell","label","clickable","style","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","ref","tabIndex","$scrollable","TableContainer","Table","TableHead","$stickyHeader","HeaderRow","TableBody","BodyRow","$alternating","EmptyViewCell","colSpan","$isSelected","LoaderWrapper","role","LoadingDotsSpinner","count","counter","_Fragment","ActionBarWrapper","$strategy","$left","_c","_b","left","$width","_d","clientWidth","ActionBar","$float","BodyMD","TextButton","ActionBarSpacer","renderSelectionBar"],"mappings":"8kDAgCO,MAAMA,EAAaC,QAAAC,GACtBA,EAAEC,QACFA,EAAOC,KACPA,EAAIC,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,KAAK,SAAQ,YACH,SAAQ,aACP,gBAAetD,SAEX,YAAdhG,GAA2BkG,EAACqD,EAAkB,CAAA,gBA4D1DnJ,GACGF,GACAA,EAAY4C,OAAS,GAvDN,kBACvB,MAAM0G,EAA2B,QAAnB/J,EAAAS,aAAW,EAAXA,EAAa4C,cAAM,IAAArD,EAAAA,EAAI,EAC/BgK,EAAU,QAAOD,EAAQ,EAAI,IAAM,IAEzC,OACI/D,EAAAiE,EAAA,CAAA1D,SAAA,CACIE,EAACyD,EAAgB,CACbpB,IAAKpH,GAAmByI,UACbjI,GAAiBkI,MAExB7H,WACM8H,EAAiB,QAAjBC,EAAA/I,cAAQ,EAARA,GAAU4B,eAAO,IAAAmH,OAAA,EAAAA,EAAE5F,8CAAyB6F,KAC5C,EAACC,OAEc,QAAjBC,EAAAlJ,cAAQ,EAARA,GAAU4B,eAAO,IAAAsH,OAAA,EAAAA,EAAEC,YAAWnE,SAEtCP,EAAC2E,EAAS,CAAAC,OAASrI,GAAmBgE,SAAA,CAClCE,EAACC,EAAWmE,OAAM,CAACjE,OAAO,WAAUL,SAAE,GAAGwD,KAASC,eAClDvD,EAACqE,EAAU,CACPrC,KAAK,SAAQ,aACD,sBAAsBsB,KAASC,IAC3C3D,QAASjF,GAAqBmF,SAAA,oBAIjCxF,QAIc,WAAtBmB,IAAkCuE,EAACsE,EAAe,CAAA,KACpD,EA0BCC,KACO"}
@@ -1,10 +1,8 @@
1
- interface TableProps {
2
- $end: boolean;
1
+ interface TableWrapperProps {
3
2
  $scrollable: boolean;
4
- $stickyHeader: boolean | undefined;
5
3
  }
6
- interface TableBodyProps {
7
- $showLastRowBottomBorder: boolean;
4
+ interface TableHeadProps {
5
+ $stickyHeader: boolean | undefined;
8
6
  }
9
7
  interface HeaderCellProps {
10
8
  $clickable: boolean;
@@ -14,23 +12,24 @@ interface BodyRowProps {
14
12
  $alternating: boolean;
15
13
  $isSelected?: boolean;
16
14
  $isSelectable?: boolean;
15
+ $showLastRowBottomBorder?: boolean;
17
16
  }
18
17
  interface BodyCellProps {
19
18
  $isCheckbox: boolean;
20
19
  }
21
20
  interface ActionBarWrapperProps {
22
- $fixed: boolean;
21
+ $strategy: "fixed" | "sticky" | "inline";
23
22
  $left?: number | undefined;
24
23
  $width?: number | undefined;
25
24
  }
26
25
  interface ActionBarProps {
27
26
  $float: boolean;
28
- $scrollable: boolean;
29
27
  }
30
- export declare const TableWrapper: 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;
28
+ export declare const TableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$scrollable"> & TableWrapperProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$scrollable"> & TableWrapperProps, never>>> & string;
31
29
  export declare const TableContainer: 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;
32
- export declare const Table: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, keyof TableProps> & TableProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, keyof TableProps> & TableProps, never>>> & string;
33
- export declare const TableBody: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "$showLastRowBottomBorder"> & TableBodyProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "$showLastRowBottomBorder"> & TableBodyProps, never>>> & string;
30
+ export declare const Table: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, never>>> & string;
31
+ export declare const TableHead: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "$stickyHeader"> & TableHeadProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "$stickyHeader"> & TableHeadProps, never>>> & string;
32
+ export declare const TableBody: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, never>>> & string;
34
33
  export declare const ActionBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof ActionBarWrapperProps> & ActionBarWrapperProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof ActionBarWrapperProps> & ActionBarWrapperProps, never>>> & string;
35
34
  export declare const TextButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "$variant"> & import("../shared/input-wrapper").InputStyleProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "$variant"> & import("../shared/input-wrapper").InputStyleProps, never>> & {
36
35
  as?: import("styled-components").WebTarget | undefined;
@@ -43,7 +42,8 @@ export declare const TextButton: import("styled-components/dist/types").IStyledC
43
42
  }, "ref"> & {
44
43
  ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
45
44
  }, never>>> & string;
46
- export declare const ActionBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof ActionBarProps> & ActionBarProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof ActionBarProps> & ActionBarProps, never>>> & string;
45
+ export declare const ActionBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$float"> & ActionBarProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "$float"> & ActionBarProps, never>>> & string;
46
+ export declare const ActionBarSpacer: 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;
47
47
  export declare const HeaderRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never> & Partial<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never>>> & string;
48
48
  export declare const HeaderCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, keyof HeaderCellProps> & HeaderCellProps, never> & Partial<Pick<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, keyof HeaderCellProps> & HeaderCellProps, never>>> & string;
49
49
  export declare const HeaderCellWrapper: 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;