@rio-cloud/rio-uikit 2.3.0-beta.3 → 2.4.0

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 (119) hide show
  1. package/MapPreviousViewportButton.d.ts +2 -0
  2. package/MapPreviousViewportButton.js +5 -0
  3. package/MapPreviousViewportButton.js.map +1 -0
  4. package/Table.js +16 -14
  5. package/TableNext.js +16 -14
  6. package/TableRowActionsDropdown.d.ts +2 -0
  7. package/TableRowActionsDropdown.js +5 -0
  8. package/TableRowActionsDropdown.js.map +1 -0
  9. package/components/dropdown/ButtonDropdown.d.ts +4 -0
  10. package/components/dropdown/ButtonDropdown.js +82 -80
  11. package/components/dropdown/ButtonDropdown.js.map +1 -1
  12. package/components/map/components/Map.js +219 -182
  13. package/components/map/components/Map.js.map +1 -1
  14. package/components/map/components/MapContext.d.ts +4 -0
  15. package/components/map/components/MapContext.js +11 -7
  16. package/components/map/components/MapContext.js.map +1 -1
  17. package/components/map/components/MapPosition.d.ts +1 -1
  18. package/components/map/components/MapPosition.js +20 -13
  19. package/components/map/components/MapPosition.js.map +1 -1
  20. package/components/map/components/features/MapZoom.d.ts +0 -1
  21. package/components/map/components/features/MapZoom.js +12 -20
  22. package/components/map/components/features/MapZoom.js.map +1 -1
  23. package/components/map/components/features/settings/MapSettingsTile.d.ts +27 -0
  24. package/components/map/components/features/settings/MapSettingsTile.js +17 -17
  25. package/components/map/components/features/settings/MapSettingsTile.js.map +1 -1
  26. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.d.ts +10 -0
  27. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js +23 -0
  28. package/components/map/components/features/settings/buttons/MapPreviousViewportButton.js.map +1 -0
  29. package/components/map/hooks/useMapViewportHistory.d.ts +19 -0
  30. package/components/map/hooks/useMapViewportHistory.js +116 -0
  31. package/components/map/hooks/useMapViewportHistory.js.map +1 -0
  32. package/components/map/icons/MapIcon.d.ts +1 -0
  33. package/components/map/icons/MapIcon.js +46 -37
  34. package/components/map/icons/MapIcon.js.map +1 -1
  35. package/components/map/utils/mapTypes.d.ts +12 -0
  36. package/components/map/utils/mapTypes.js.map +1 -1
  37. package/components/map/utils/mapUtils.d.ts +2 -0
  38. package/components/map/utils/mapUtils.js +4 -0
  39. package/components/map/utils/mapUtils.js.map +1 -1
  40. package/components/selects/Multiselect.d.ts +6 -0
  41. package/components/selects/Multiselect.js +85 -83
  42. package/components/selects/Multiselect.js.map +1 -1
  43. package/components/selects/Select.d.ts +6 -0
  44. package/components/selects/Select.js +79 -71
  45. package/components/selects/Select.js.map +1 -1
  46. package/components/table/Table.d.ts +5 -1
  47. package/components/table/Table.js +234 -210
  48. package/components/table/Table.js.map +1 -1
  49. package/components/table/Table.types.d.ts +55 -0
  50. package/components/table/TableExpandAllGroupsButton.d.ts +25 -0
  51. package/components/table/TableExpandAllGroupsButton.js +27 -0
  52. package/components/table/TableExpandAllGroupsButton.js.map +1 -0
  53. package/components/table/TableExpandedRow.d.ts +4 -0
  54. package/components/table/TableExpandedRow.js +101 -84
  55. package/components/table/TableExpandedRow.js.map +1 -1
  56. package/components/table/TableExpanderButton.js +11 -11
  57. package/components/table/TableExpanderButton.js.map +1 -1
  58. package/components/table/TableGroupRow.d.ts +16 -2
  59. package/components/table/TableGroupRow.js +57 -22
  60. package/components/table/TableGroupRow.js.map +1 -1
  61. package/components/table/TableHeader.d.ts +1 -9
  62. package/components/table/TableHeader.js +82 -65
  63. package/components/table/TableHeader.js.map +1 -1
  64. package/components/table/TableRow.d.ts +7 -1
  65. package/components/table/TableRow.js +89 -72
  66. package/components/table/TableRow.js.map +1 -1
  67. package/components/table/TableRowActionsDropdown.d.ts +11 -0
  68. package/components/table/TableRowActionsDropdown.js +22 -0
  69. package/components/table/TableRowActionsDropdown.js.map +1 -0
  70. package/components/table/TableStickyRowButton.d.ts +25 -0
  71. package/components/table/TableStickyRowButton.js +32 -0
  72. package/components/table/TableStickyRowButton.js.map +1 -0
  73. package/components/table/TableToolbar.d.ts +24 -3
  74. package/components/table/TableToolbar.js +78 -37
  75. package/components/table/TableToolbar.js.map +1 -1
  76. package/components/table/TableViewToggles.js +5 -5
  77. package/components/table/TableViewToggles.js.map +1 -1
  78. package/components/table/context/TableInteractionContext.d.ts +3 -0
  79. package/components/table/context/TableInteractionContext.js.map +1 -1
  80. package/components/table/context/TableRenderConfigContext.d.ts +2 -1
  81. package/components/table/context/TableRenderConfigContext.js.map +1 -1
  82. package/components/table/context/TableRenderContext.d.ts +1 -0
  83. package/components/table/context/TableRenderContext.js.map +1 -1
  84. package/components/table/layout/useMeasuredColumnMaxWidths.js +52 -54
  85. package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -1
  86. package/components/table/layout/useTableLayout.d.ts +4 -1
  87. package/components/table/layout/useTableLayout.js +54 -48
  88. package/components/table/layout/useTableLayout.js.map +1 -1
  89. package/components/table/layout/useTableVirtualization.js +51 -56
  90. package/components/table/layout/useTableVirtualization.js.map +1 -1
  91. package/components/table/model/resolveResponsiveViewType.d.ts +2 -0
  92. package/components/table/model/resolveResponsiveViewType.js +27 -0
  93. package/components/table/model/resolveResponsiveViewType.js.map +1 -0
  94. package/components/table/render/header/TableHeaderCellContent.js +4 -4
  95. package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
  96. package/components/table/render/header/TableHeaderSelectionCell.d.ts +3 -0
  97. package/components/table/render/header/TableHeaderSelectionCell.js +25 -14
  98. package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
  99. package/components/table/runtime/useRenderDraftState.js +1 -0
  100. package/components/table/runtime/useRenderDraftState.js.map +1 -1
  101. package/components/table/runtime/useResponsiveResolvedViewType.d.ts +23 -0
  102. package/components/table/runtime/useResponsiveResolvedViewType.js +22 -0
  103. package/components/table/runtime/useResponsiveResolvedViewType.js.map +1 -0
  104. package/components/table/selection/useInternalTableSelectionState.d.ts +2 -0
  105. package/components/table/selection/useInternalTableSelectionState.js +29 -17
  106. package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
  107. package/components/table/selection/useTableSelection.d.ts +5 -1
  108. package/components/table/selection/useTableSelection.js +37 -26
  109. package/components/table/selection/useTableSelection.js.map +1 -1
  110. package/components/table/shared/parsePixelSize.d.ts +2 -0
  111. package/components/table/shared/parsePixelSize.js +13 -0
  112. package/components/table/shared/parsePixelSize.js.map +1 -0
  113. package/hooks/useResizeObserver.d.ts +25 -6
  114. package/hooks/useResizeObserver.js +20 -18
  115. package/hooks/useResizeObserver.js.map +1 -1
  116. package/package.json +10 -10
  117. package/version.d.ts +1 -1
  118. package/version.js +2 -2
  119. package/version.js.map +1 -1
@@ -1,36 +1,71 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import b from "../../utils/classNames.js";
3
- import { useOptionalTableInteractionContext as w } from "./context/TableInteractionContext.js";
4
- import { useOptionalTableSection as x, useTableBodyContext as g } from "./context/TableStructureContext.js";
5
- import { useOptionalTableRenderContext as f } from "./context/TableRenderContext.js";
6
- const v = (s) => {
7
- const { children: a, className: c, noHover: i, sticky: d, ...u } = s, o = f(), n = w(), m = x(), r = g();
8
- if (!o || !n || o.columns.length === 0 || m !== "body" || !r)
1
+ import { jsx as t, jsxs as k } from "react/jsx-runtime";
2
+ import T from "../checkbox/Checkbox.js";
3
+ import h from "../../utils/classNames.js";
4
+ import { getVerticalAlignClassName as N } from "./shared/getAlignClassName.js";
5
+ import { useOptionalTableInteractionContext as v } from "./context/TableInteractionContext.js";
6
+ import { useOptionalTableSection as I, useTableBodyContext as A } from "./context/TableStructureContext.js";
7
+ import { useOptionalTableRenderContext as O } from "./context/TableRenderContext.js";
8
+ import { useOptionalTableRenderConfigContext as V } from "./context/TableRenderConfigContext.js";
9
+ const B = (r) => {
10
+ const { isSelected: c, onToggleSelection: s, selectionCheckboxVerticalAlignment: i } = r;
11
+ return /* @__PURE__ */ t(
12
+ "div",
13
+ {
14
+ className: h(
15
+ "table-cell table-selection-cell",
16
+ N(i)
17
+ ),
18
+ role: "cell",
19
+ "aria-colindex": 1,
20
+ style: { gridColumn: "1 / span 1", gridRow: "1 / span 1" },
21
+ onClick: (n) => n.stopPropagation(),
22
+ onKeyDown: (n) => n.stopPropagation(),
23
+ children: /* @__PURE__ */ t("div", { className: "table-selection-control", children: /* @__PURE__ */ t(T, { checked: c, onChange: s }) })
24
+ }
25
+ );
26
+ }, q = (r) => {
27
+ const { children: c, className: s, id: i, noHover: n, selectable: m = !1, sticky: b, ...x } = r, g = V(), e = O(), o = v(), f = I(), p = A();
28
+ if (!e || !g || !o || e.columns.length === 0 || f !== "body" || !p)
9
29
  return null;
10
- const e = r.nextRowIndex(), p = o.columns.length + (n.showSelectionColumn ? 1 : 0), l = /* @__PURE__ */ t(
30
+ const a = p.nextRowIndex(), l = i ?? `group-${a}`, u = m && o.selectableRowIdSet.has(l), C = u && o.selectedRowIdSet.has(l), d = o.showSelectionColumn && u, S = e.columns.length + (o.showSelectionColumn && !d ? 1 : 0), y = !!e.renderDraft.bodyMaxHeight, R = d && /* @__PURE__ */ t(
31
+ B,
32
+ {
33
+ isSelected: C,
34
+ onToggleSelection: () => o.onToggleRowSelection?.(l),
35
+ selectionCheckboxVerticalAlignment: g.selectionCheckboxVerticalAlignment
36
+ }
37
+ ), w = /* @__PURE__ */ k(
11
38
  "div",
12
39
  {
13
- ...u,
14
- className: b(
40
+ ...x,
41
+ className: h(
15
42
  "table-row",
16
43
  "table-row-group",
17
- d && "table-row-group-sticky",
18
- i && "table-row-no-hover",
19
- c
44
+ d && "table-row-group-selectable",
45
+ b && "table-row-group-sticky",
46
+ b && y && "table-row-sticky-in-container",
47
+ C && "table-row-selected",
48
+ n && "table-row-no-hover",
49
+ s
20
50
  ),
21
- "data-index": e,
51
+ "data-index": a,
52
+ "data-row-id": String(l),
22
53
  role: "row",
23
- children: /* @__PURE__ */ t("div", { className: "table-cell table-group-cell", role: "cell", "aria-colspan": p, children: /* @__PURE__ */ t("div", { className: "table-cell-content", children: a }) })
54
+ children: [
55
+ R,
56
+ /* @__PURE__ */ t("div", { className: "table-cell table-group-cell", role: "cell", "aria-colspan": S, children: /* @__PURE__ */ t("div", { className: "table-cell-content", children: c }) })
57
+ ]
24
58
  }
25
59
  );
26
- return o.renderDraft.bodyRows.push({
27
- rowId: `group-${e}`,
28
- rowIndex: e,
60
+ return e.renderDraft.bodyRows.push({
61
+ rowId: l,
62
+ rowIndex: a,
29
63
  kind: "group",
30
- render: () => l
31
- }), o.isRegisteringBodyRows ? null : l;
64
+ selectable: m,
65
+ render: () => w
66
+ }), e.isRegisteringBodyRows ? null : w;
32
67
  };
33
68
  export {
34
- v as default
69
+ q as default
35
70
  };
36
71
  //# sourceMappingURL=TableGroupRow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableGroupRow.js","sources":["../../../src/components/table/TableGroupRow.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport classNames from '../../utils/classNames';\nimport type { TableHtmlAttributes } from './Table.types';\nimport { useOptionalTableInteractionContext } from './context/TableInteractionContext';\nimport { useTableBodyContext, useOptionalTableSection } from './context/TableStructureContext';\nimport { useOptionalTableRenderContext } from './context/TableRenderContext';\n\nexport type TableGroupRowProps = TableHtmlAttributes & {\n /**\n * The content of the full-width group row.\n */\n children?: ReactNode;\n\n /**\n * Keeps the group row sticky at the top of a scrollable table body.\n *\n * @default false\n */\n sticky?: boolean;\n\n /**\n * Optional class names only for this group row.\n */\n className?: string;\n\n /**\n * Disable table hover styling for this row.\n */\n noHover?: boolean;\n};\n\nconst TableGroupRow = (props: TableGroupRowProps) => {\n const { children, className, noHover, sticky, ...remainingProps } = props;\n\n const renderContext = useOptionalTableRenderContext();\n const interactionContext = useOptionalTableInteractionContext();\n const section = useOptionalTableSection();\n const bodyContext = useTableBodyContext();\n\n if (\n !renderContext ||\n !interactionContext ||\n renderContext.columns.length === 0 ||\n section !== 'body' ||\n !bodyContext\n ) {\n return null;\n }\n\n const rowIndex = bodyContext.nextRowIndex();\n const columnCount = renderContext.columns.length + (interactionContext.showSelectionColumn ? 1 : 0);\n\n const rowNode = (\n <div\n {...remainingProps}\n className={classNames(\n 'table-row',\n 'table-row-group',\n sticky && 'table-row-group-sticky',\n noHover && 'table-row-no-hover',\n className\n )}\n data-index={rowIndex}\n role='row'\n >\n <div className='table-cell table-group-cell' role='cell' aria-colspan={columnCount}>\n <div className='table-cell-content'>{children}</div>\n </div>\n </div>\n );\n\n renderContext.renderDraft.bodyRows.push({\n rowId: `group-${rowIndex}`,\n rowIndex,\n kind: 'group',\n render: () => rowNode,\n });\n\n return renderContext.isRegisteringBodyRows ? null : rowNode;\n};\n\nexport default TableGroupRow;\n"],"names":["TableGroupRow","props","children","className","noHover","sticky","remainingProps","renderContext","useOptionalTableRenderContext","interactionContext","useOptionalTableInteractionContext","section","useOptionalTableSection","bodyContext","useTableBodyContext","rowIndex","columnCount","rowNode","jsx","classNames"],"mappings":";;;;;AAgCA,MAAMA,IAAgB,CAACC,MAA8B;AACjD,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,SAAAC,GAAS,QAAAC,GAAQ,GAAGC,MAAmBL,GAE9DM,IAAgBC,EAAA,GAChBC,IAAqBC,EAAA,GACrBC,IAAUC,EAAA,GACVC,IAAcC,EAAA;AAEpB,MACI,CAACP,KACD,CAACE,KACDF,EAAc,QAAQ,WAAW,KACjCI,MAAY,UACZ,CAACE;AAED,WAAO;AAGX,QAAME,IAAWF,EAAY,aAAA,GACvBG,IAAcT,EAAc,QAAQ,UAAUE,EAAmB,sBAAsB,IAAI,IAE3FQ,IACF,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACI,GAAGZ;AAAA,MACJ,WAAWa;AAAA,QACP;AAAA,QACA;AAAA,QACAd,KAAU;AAAA,QACVD,KAAW;AAAA,QACXD;AAAA,MAAA;AAAA,MAEJ,cAAYY;AAAA,MACZ,MAAK;AAAA,MAEL,UAAA,gBAAAG,EAAC,OAAA,EAAI,WAAU,+BAA8B,MAAK,QAAO,gBAAcF,GACnE,UAAA,gBAAAE,EAAC,OAAA,EAAI,WAAU,sBAAsB,UAAAhB,GAAS,EAAA,CAClD;AAAA,IAAA;AAAA,EAAA;AAIR,SAAAK,EAAc,YAAY,SAAS,KAAK;AAAA,IACpC,OAAO,SAASQ,CAAQ;AAAA,IACxB,UAAAA;AAAA,IACA,MAAM;AAAA,IACN,QAAQ,MAAME;AAAA,EAAA,CACjB,GAEMV,EAAc,wBAAwB,OAAOU;AACxD;"}
1
+ {"version":3,"file":"TableGroupRow.js","sources":["../../../src/components/table/TableGroupRow.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport Checkbox from '../checkbox/Checkbox';\nimport classNames from '../../utils/classNames';\nimport type { TableHtmlAttributes, TableRowId, TableVerticalAlign } from './Table.types';\nimport { getVerticalAlignClassName } from './shared/getAlignClassName';\nimport { useOptionalTableInteractionContext } from './context/TableInteractionContext';\nimport { useTableBodyContext, useOptionalTableSection } from './context/TableStructureContext';\nimport { useOptionalTableRenderContext } from './context/TableRenderContext';\nimport { useOptionalTableRenderConfigContext } from './context/TableRenderConfigContext';\n\nexport type TableGroupRowProps = TableHtmlAttributes & {\n /**\n * Stable row key for selectable group rows.\n */\n id?: TableRowId;\n\n /**\n * The content of the full-width group row.\n */\n children?: ReactNode;\n\n /**\n * Keeps the group row sticky at the top of the current table scroll context.\n * When a sticky `TableHeader` is present, the row stacks below the measured header height.\n * `TableBody maxHeight` continues to pin the row inside the internal body scroller.\n *\n * @default false\n */\n sticky?: boolean;\n\n /**\n * Optional class names only for this group row.\n */\n className?: string;\n\n /**\n * Includes this group row in table selection.\n *\n * Group rows are not selectable by default so existing grouped tables keep their current full-width layout.\n *\n * @default false\n */\n selectable?: boolean;\n\n /**\n * Disable table hover styling for this row.\n */\n noHover?: boolean;\n};\n\ntype TableGroupRowSelectionCellProps = {\n isSelected: boolean;\n onToggleSelection?: () => void;\n selectionCheckboxVerticalAlignment?: TableVerticalAlign;\n};\n\nconst TableGroupRowSelectionCell = (props: TableGroupRowSelectionCellProps) => {\n const { isSelected, onToggleSelection, selectionCheckboxVerticalAlignment } = props;\n\n return (\n <div\n className={classNames(\n 'table-cell table-selection-cell',\n getVerticalAlignClassName(selectionCheckboxVerticalAlignment)\n )}\n role='cell'\n aria-colindex={1}\n style={{ gridColumn: '1 / span 1', gridRow: '1 / span 1' }}\n onClick={event => event.stopPropagation()}\n onKeyDown={event => event.stopPropagation()}\n >\n <div className='table-selection-control'>\n <Checkbox checked={isSelected} onChange={onToggleSelection} />\n </div>\n </div>\n );\n};\n\nconst TableGroupRow = (props: TableGroupRowProps) => {\n const { children, className, id, noHover, selectable = false, sticky, ...remainingProps } = props;\n\n const renderConfigContext = useOptionalTableRenderConfigContext();\n const renderContext = useOptionalTableRenderContext();\n const interactionContext = useOptionalTableInteractionContext();\n const section = useOptionalTableSection();\n const bodyContext = useTableBodyContext();\n\n if (\n !renderContext ||\n !renderConfigContext ||\n !interactionContext ||\n renderContext.columns.length === 0 ||\n section !== 'body' ||\n !bodyContext\n ) {\n return null;\n }\n\n const rowIndex = bodyContext.nextRowIndex();\n const rowId = id ?? `group-${rowIndex}`;\n const isSelectable = selectable && interactionContext.selectableRowIdSet.has(rowId);\n const isSelected = isSelectable && interactionContext.selectedRowIdSet.has(rowId);\n const hasSelectionCell = interactionContext.showSelectionColumn && isSelectable;\n const columnCount =\n renderContext.columns.length + (interactionContext.showSelectionColumn && !hasSelectionCell ? 1 : 0);\n const stickyInBodyScrollContainer = !!renderContext.renderDraft.bodyMaxHeight;\n const selectionCell = hasSelectionCell && (\n <TableGroupRowSelectionCell\n isSelected={isSelected}\n onToggleSelection={() => interactionContext.onToggleRowSelection?.(rowId)}\n selectionCheckboxVerticalAlignment={renderConfigContext.selectionCheckboxVerticalAlignment}\n />\n );\n\n const rowNode = (\n <div\n {...remainingProps}\n className={classNames(\n 'table-row',\n 'table-row-group',\n hasSelectionCell && 'table-row-group-selectable',\n sticky && 'table-row-group-sticky',\n sticky && stickyInBodyScrollContainer && 'table-row-sticky-in-container',\n isSelected && 'table-row-selected',\n noHover && 'table-row-no-hover',\n className\n )}\n data-index={rowIndex}\n data-row-id={String(rowId)}\n role='row'\n >\n {selectionCell}\n <div className='table-cell table-group-cell' role='cell' aria-colspan={columnCount}>\n <div className='table-cell-content'>{children}</div>\n </div>\n </div>\n );\n\n renderContext.renderDraft.bodyRows.push({\n rowId,\n rowIndex,\n kind: 'group',\n selectable,\n render: () => rowNode,\n });\n\n return renderContext.isRegisteringBodyRows ? null : rowNode;\n};\n\nexport default TableGroupRow;\n"],"names":["TableGroupRowSelectionCell","props","isSelected","onToggleSelection","selectionCheckboxVerticalAlignment","jsx","classNames","getVerticalAlignClassName","event","Checkbox","TableGroupRow","children","className","id","noHover","selectable","sticky","remainingProps","renderConfigContext","useOptionalTableRenderConfigContext","renderContext","useOptionalTableRenderContext","interactionContext","useOptionalTableInteractionContext","section","useOptionalTableSection","bodyContext","useTableBodyContext","rowIndex","rowId","isSelectable","hasSelectionCell","columnCount","stickyInBodyScrollContainer","selectionCell","rowNode","jsxs"],"mappings":";;;;;;;;AAyDA,MAAMA,IAA6B,CAACC,MAA2C;AAC3E,QAAM,EAAE,YAAAC,GAAY,mBAAAC,GAAmB,oCAAAC,EAAA,IAAuCH;AAE9E,SACI,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAWC;AAAA,QACP;AAAA,QACAC,EAA0BH,CAAkC;AAAA,MAAA;AAAA,MAEhE,MAAK;AAAA,MACL,iBAAe;AAAA,MACf,OAAO,EAAE,YAAY,cAAc,SAAS,aAAA;AAAA,MAC5C,SAAS,CAAAI,MAASA,EAAM,gBAAA;AAAA,MACxB,WAAW,CAAAA,MAASA,EAAM,gBAAA;AAAA,MAE1B,UAAA,gBAAAH,EAAC,OAAA,EAAI,WAAU,2BACX,UAAA,gBAAAA,EAACI,KAAS,SAASP,GAAY,UAAUC,EAAA,CAAmB,EAAA,CAChE;AAAA,IAAA;AAAA,EAAA;AAGZ,GAEMO,IAAgB,CAACT,MAA8B;AACjD,QA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Ac2B,GACnE,UAAA,gBAAA3B,EAAC,OAAA,EAAI,WAAU,sBAAsB,UAAAM,GAAS,EAAA,CAClD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,SAAAS,EAAc,YAAY,SAAS,KAAK;AAAA,IACpC,OAAAS;AAAA,IACA,UAAAD;AAAA,IACA,MAAM;AAAA,IACN,YAAAb;AAAA,IACA,QAAQ,MAAMoB;AAAA,EAAA,CACjB,GAEMf,EAAc,wBAAwB,OAAOe;AACxD;"}
@@ -7,21 +7,13 @@ export type TableHeaderProps<RowType extends TableRowData> = TableHtmlAttributes
7
7
  className?: string;
8
8
  /**
9
9
  * Keeps the table header sticky while the page scrolls.
10
+ * The sticky top reference follows `Table.stickyReference`.
10
11
  *
11
12
  * This applies in `TABLE` view only.
12
13
  *
13
14
  * @default false
14
15
  */
15
16
  sticky?: boolean;
16
- /**
17
- * Keeps the sticky header pinned to the top edge of an explicit scroll container.
18
- *
19
- * Use this when the table sits inside a wrapper with an overflow class like `overflow-y-scroll`.
20
- * When omitted, sticky headers compensate the default `ApplicationLayout` body padding.
21
- *
22
- * @default false
23
- */
24
- stickyInContainer?: boolean;
25
17
  /**
26
18
  * Table header content.
27
19
  */
@@ -1,71 +1,86 @@
1
- import { jsxs as v, jsx as o } from "react/jsx-runtime";
2
- import { useSensors as k, useSensor as E, PointerSensor as N, DndContext as j, DragOverlay as z } from "@dnd-kit/core";
3
- import { restrictToHorizontalAxis as L } from "@dnd-kit/modifiers";
4
- import { SortableContext as W, horizontalListSortingStrategy as V } from "@dnd-kit/sortable";
5
- import { useRef as _, useState as f } from "react";
6
- import p from "../../utils/classNames.js";
7
- import $ from "./render/header/TableHeaderDragOverlay.js";
8
- import q from "./render/header/TableHeaderSelectionCell.js";
9
- import { resolveColumnCollisionDetection as B } from "./render/header/resolveColumnCollisionDetection.js";
10
- import { useOptionalTableInteractionContext as F } from "./context/TableInteractionContext.js";
11
- import { useOptionalTableLayoutContext as G } from "./context/TableLayoutContext.js";
12
- import { useOptionalTableRenderConfigContext as J } from "./context/TableRenderConfigContext.js";
13
- import { TableSectionContext as x, TableHeaderContext as S } from "./context/TableStructureContext.js";
14
- import { useOptionalTableRenderContext as M } from "./context/TableRenderContext.js";
15
- const de = (w) => {
16
- const { children: s, className: b, sticky: d = !1, stickyInContainer: D = !1, ...y } = w, l = M(), c = J(), t = F(), n = G();
17
- if (!l || !c || !t || !n)
1
+ import { jsxs as S, jsx as o } from "react/jsx-runtime";
2
+ import { useSensors as N, useSensor as V, PointerSensor as j, DndContext as B, DragOverlay as M } from "@dnd-kit/core";
3
+ import { restrictToHorizontalAxis as W } from "@dnd-kit/modifiers";
4
+ import { SortableContext as $, horizontalListSortingStrategy as G } from "@dnd-kit/sortable";
5
+ import { useRef as Y, useState as b, useLayoutEffect as q } from "react";
6
+ import F from "../../hooks/useMergeRefs.js";
7
+ import J from "../../hooks/useResizeObserver.js";
8
+ import y from "../../utils/classNames.js";
9
+ import Q from "./render/header/TableHeaderDragOverlay.js";
10
+ import U from "./render/header/TableHeaderSelectionCell.js";
11
+ import { resolveColumnCollisionDetection as X } from "./render/header/resolveColumnCollisionDetection.js";
12
+ import { useOptionalTableInteractionContext as Z } from "./context/TableInteractionContext.js";
13
+ import { useOptionalTableLayoutContext as ee } from "./context/TableLayoutContext.js";
14
+ import { useOptionalTableRenderConfigContext as te } from "./context/TableRenderConfigContext.js";
15
+ import { TableSectionContext as R, TableHeaderContext as w } from "./context/TableStructureContext.js";
16
+ import { useOptionalTableRenderContext as oe } from "./context/TableRenderContext.js";
17
+ const m = "--table-sticky-header-height", xe = (D) => {
18
+ const { children: u, className: H, sticky: i = !1, ...T } = D, s = oe(), c = te(), t = Z(), n = ee();
19
+ if (!s || !c || !t || !n)
18
20
  return null;
19
- const R = k(E(N, { activationConstraint: { distance: 6 } })), r = _(0);
21
+ const A = N(V(j, { activationConstraint: { distance: 6 } })), r = Y(0), [g, , { blockSize: C }] = J();
20
22
  r.current = 0;
21
- const [m, u] = f(void 0), [H, g] = f(void 0), T = !!n.onColumnDragEnd && (n.draggableColumnKeys?.length ?? 0) > 1, i = l.header, a = i?.rowCount ?? 1, A = i ?? {
22
- rowCount: a,
23
- totalColumnCount: l.columns.length,
23
+ const [h, f] = b(void 0), [E, v] = b(void 0), P = F(
24
+ n.tableHeadRowRef,
25
+ g
26
+ ), k = !!n.onColumnDragEnd && (n.draggableColumnKeys?.length ?? 0) > 1, d = s.header, l = d?.rowCount ?? 1, I = d ?? {
27
+ rowCount: l,
28
+ totalColumnCount: s.columns.length,
24
29
  columns: []
25
- }, I = m ? i?.columns.find((e) => (e.columnKey ?? String(e.key)) === m) : void 0, C = () => {
26
- u(void 0), g(void 0);
27
- }, K = (e) => {
28
- u(String(e.active.id)), g(e.active.rect.current.initial?.width ?? void 0);
30
+ }, K = h ? d?.columns.find((e) => (e.columnKey ?? String(e.key)) === h) : void 0, p = () => {
31
+ f(void 0), v(void 0);
29
32
  }, O = (e) => {
30
- C();
31
- }, P = (e) => {
32
- C(), n.onColumnDragEnd?.(e);
33
- }, h = T && n.draggableColumnKeys ? /* @__PURE__ */ v(
34
- j,
33
+ f(String(e.active.id)), v(e.active.rect.current.initial?.width ?? void 0);
34
+ }, z = (e) => {
35
+ p();
36
+ }, _ = (e) => {
37
+ p(), n.onColumnDragEnd?.(e);
38
+ };
39
+ q(() => {
40
+ const e = g.current, a = e?.closest(".table");
41
+ if (!a)
42
+ return;
43
+ if (!i || !e) {
44
+ a.style.removeProperty(m);
45
+ return;
46
+ }
47
+ const L = Math.max(C ?? e.getBoundingClientRect().height ?? 0, 0);
48
+ return a.style.setProperty(m, `${L}px`), () => {
49
+ a.style.removeProperty(m);
50
+ };
51
+ }, [C, i]);
52
+ const x = k && n.draggableColumnKeys ? /* @__PURE__ */ S(
53
+ B,
35
54
  {
36
- sensors: R,
37
- collisionDetection: B,
38
- modifiers: [L],
39
- onDragStart: K,
40
- onDragCancel: O,
41
- onDragEnd: P,
55
+ sensors: A,
56
+ collisionDetection: X,
57
+ modifiers: [W],
58
+ onDragStart: O,
59
+ onDragCancel: z,
60
+ onDragEnd: _,
42
61
  children: [
43
- /* @__PURE__ */ o(W, { items: n.draggableColumnKeys, strategy: V, children: s }),
44
- /* @__PURE__ */ o(z, { adjustScale: !1, dropAnimation: null, children: /* @__PURE__ */ o(
45
- $,
62
+ /* @__PURE__ */ o($, { items: n.draggableColumnKeys, strategy: G, children: u }),
63
+ /* @__PURE__ */ o(M, { adjustScale: !1, dropAnimation: null, children: /* @__PURE__ */ o(
64
+ Q,
46
65
  {
47
- column: I,
48
- header: A,
66
+ column: K,
67
+ header: I,
49
68
  showSelectionColumn: t.showSelectionColumn,
50
- width: H
69
+ width: E
51
70
  }
52
71
  ) })
53
72
  ]
54
73
  }
55
- ) : s;
74
+ ) : u;
56
75
  return c.isTableView ? /* @__PURE__ */ o(
57
76
  "div",
58
77
  {
59
- ...y,
60
- className: p(
61
- "table-head",
62
- d && "table-head-sticky",
63
- d && D && "table-head-sticky-in-container"
64
- ),
78
+ ...T,
79
+ className: y("table-head", i && "table-head-sticky"),
65
80
  role: "rowgroup",
66
- ref: n.tableHeadRowRef,
67
- children: /* @__PURE__ */ o(x.Provider, { value: "header", children: /* @__PURE__ */ o(
68
- S.Provider,
81
+ ref: P,
82
+ children: /* @__PURE__ */ o(R.Provider, { value: "header", children: /* @__PURE__ */ o(
83
+ w.Provider,
69
84
  {
70
85
  value: {
71
86
  nextHeaderRowIndex: () => {
@@ -73,36 +88,38 @@ const de = (w) => {
73
88
  return r.current += 1, e;
74
89
  }
75
90
  },
76
- children: /* @__PURE__ */ v(
91
+ children: /* @__PURE__ */ S(
77
92
  "div",
78
93
  {
79
- className: p(
94
+ className: y(
80
95
  "table-head-grid",
81
96
  t.selectionHeaderContent && "table-head-grid-custom-selection",
82
- b
97
+ H
83
98
  ),
84
- role: a === 1 ? "row" : "presentation",
85
- style: { gridTemplateRows: `repeat(${a}, auto)` },
99
+ role: l === 1 ? "row" : "presentation",
100
+ style: { gridTemplateRows: `repeat(${l}, auto)` },
86
101
  children: [
87
102
  t.showSelectionColumn && /* @__PURE__ */ o(
88
- q,
103
+ U,
89
104
  {
90
105
  isAllSelected: t.isAllRowsSelected,
91
106
  isSomeRowsSelected: t.isSomeRowsSelected,
92
107
  onToggleAllSelection: t.onToggleAllSelection,
93
- rowCount: a,
94
- selectionHeaderContent: t.selectionHeaderContent
108
+ disabled: !t.hasSelectableRows,
109
+ rowCount: l,
110
+ selectionHeaderContent: t.selectionHeaderContent,
111
+ selectionCheckboxVerticalAlignment: c.selectionCheckboxVerticalAlignment
95
112
  }
96
113
  ),
97
- h
114
+ x
98
115
  ]
99
116
  }
100
117
  )
101
118
  }
102
119
  ) })
103
120
  }
104
- ) : /* @__PURE__ */ o(x.Provider, { value: "header", children: /* @__PURE__ */ o(
105
- S.Provider,
121
+ ) : /* @__PURE__ */ o(R.Provider, { value: "header", children: /* @__PURE__ */ o(
122
+ w.Provider,
106
123
  {
107
124
  value: {
108
125
  nextHeaderRowIndex: () => {
@@ -110,11 +127,11 @@ const de = (w) => {
110
127
  return r.current += 1, e;
111
128
  }
112
129
  },
113
- children: h
130
+ children: x
114
131
  }
115
132
  ) });
116
133
  };
117
134
  export {
118
- de as default
135
+ xe as default
119
136
  };
120
137
  //# sourceMappingURL=TableHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableHeader.js","sources":["../../../src/components/table/TableHeader.tsx"],"sourcesContent":["import {\n DndContext,\n DragOverlay,\n PointerSensor,\n type DragCancelEvent,\n type DragEndEvent,\n type DragStartEvent,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { restrictToHorizontalAxis } from '@dnd-kit/modifiers';\nimport { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';\nimport { type ReactNode, useRef, useState } from 'react';\n\nimport classNames from '../../utils/classNames';\nimport type { TableHtmlAttributes, TableRowData } from './Table.types';\nimport TableHeaderDragOverlay from './render/header/TableHeaderDragOverlay';\nimport TableHeaderSelectionCell from './render/header/TableHeaderSelectionCell';\nimport { resolveColumnCollisionDetection } from './render/header/resolveColumnCollisionDetection';\nimport { useOptionalTableInteractionContext } from './context/TableInteractionContext';\nimport { useOptionalTableLayoutContext } from './context/TableLayoutContext';\nimport { useOptionalTableRenderConfigContext } from './context/TableRenderConfigContext';\nimport { TableHeaderContext, TableSectionContext } from './context/TableStructureContext';\nimport { useOptionalTableRenderContext } from './context/TableRenderContext';\n\nexport type TableHeaderProps<RowType extends TableRowData> = TableHtmlAttributes & {\n /**\n * Additional class names for the header grid wrapper.\n */\n className?: string;\n\n /**\n * Keeps the table header sticky while the page scrolls.\n *\n * This applies in `TABLE` view only.\n *\n * @default false\n */\n sticky?: boolean;\n\n /**\n * Keeps the sticky header pinned to the top edge of an explicit scroll container.\n *\n * Use this when the table sits inside a wrapper with an overflow class like `overflow-y-scroll`.\n * When omitted, sticky headers compensate the default `ApplicationLayout` body padding.\n *\n * @default false\n */\n stickyInContainer?: boolean;\n\n /**\n * Table header content.\n */\n children?: ReactNode;\n};\n\nconst TableHeader = <RowType extends TableRowData = TableRowData>(props: TableHeaderProps<RowType>) => {\n const { children, className, sticky = false, stickyInContainer = false, ...remainingProps } = props;\n\n const renderContext = useOptionalTableRenderContext<RowType>();\n const renderConfigContext = useOptionalTableRenderConfigContext<RowType>();\n const interactionContext = useOptionalTableInteractionContext<RowType>();\n const layoutContext = useOptionalTableLayoutContext();\n\n if (!renderContext || !renderConfigContext || !interactionContext || !layoutContext) {\n return null;\n }\n\n const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 6 } }));\n\n const headerRowIndexRef = useRef(0);\n headerRowIndexRef.current = 0;\n\n const [activeDraggedColumnKey, setActiveDraggedColumnKey] = useState<string | undefined>(undefined);\n const [activeDraggedColumnWidth, setActiveDraggedColumnWidth] = useState<number | undefined>(undefined);\n\n const canDragColumns = !!layoutContext.onColumnDragEnd && (layoutContext.draggableColumnKeys?.length ?? 0) > 1;\n const header = renderContext.header;\n const headerRowCount = header?.rowCount ?? 1;\n const overlayHeader = header ?? {\n rowCount: headerRowCount,\n totalColumnCount: renderContext.columns.length,\n columns: [],\n };\n\n const activeDraggedColumn = activeDraggedColumnKey\n ? header?.columns.find(column => (column.columnKey ?? String(column.key)) === activeDraggedColumnKey)\n : undefined;\n\n const clearActiveDraggedColumn = () => {\n setActiveDraggedColumnKey(undefined);\n setActiveDraggedColumnWidth(undefined);\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n setActiveDraggedColumnKey(String(event.active.id));\n setActiveDraggedColumnWidth(event.active.rect.current.initial?.width ?? undefined);\n };\n\n const handleDragCancel = (_event: DragCancelEvent) => {\n clearActiveDraggedColumn();\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n clearActiveDraggedColumn();\n layoutContext.onColumnDragEnd?.(event);\n };\n\n const content =\n canDragColumns && layoutContext.draggableColumnKeys ? (\n <DndContext\n sensors={sensors}\n collisionDetection={resolveColumnCollisionDetection}\n modifiers={[restrictToHorizontalAxis]}\n onDragStart={handleDragStart}\n onDragCancel={handleDragCancel}\n onDragEnd={handleDragEnd}\n >\n <SortableContext items={layoutContext.draggableColumnKeys} strategy={horizontalListSortingStrategy}>\n {children}\n </SortableContext>\n <DragOverlay adjustScale={false} dropAnimation={null}>\n <TableHeaderDragOverlay\n column={activeDraggedColumn}\n header={overlayHeader}\n showSelectionColumn={interactionContext.showSelectionColumn}\n width={activeDraggedColumnWidth}\n />\n </DragOverlay>\n </DndContext>\n ) : (\n children\n );\n\n if (!renderConfigContext.isTableView) {\n return (\n <TableSectionContext.Provider value='header'>\n <TableHeaderContext.Provider\n value={{\n nextHeaderRowIndex: () => {\n const nextHeaderRowIndex = headerRowIndexRef.current;\n headerRowIndexRef.current += 1;\n return nextHeaderRowIndex;\n },\n }}\n >\n {content}\n </TableHeaderContext.Provider>\n </TableSectionContext.Provider>\n );\n }\n\n return (\n <div\n {...remainingProps}\n className={classNames(\n 'table-head',\n sticky && 'table-head-sticky',\n sticky && stickyInContainer && 'table-head-sticky-in-container'\n )}\n role='rowgroup'\n ref={layoutContext.tableHeadRowRef}\n >\n <TableSectionContext.Provider value='header'>\n <TableHeaderContext.Provider\n value={{\n nextHeaderRowIndex: () => {\n const nextHeaderRowIndex = headerRowIndexRef.current;\n headerRowIndexRef.current += 1;\n return nextHeaderRowIndex;\n },\n }}\n >\n <div\n className={classNames(\n 'table-head-grid',\n interactionContext.selectionHeaderContent && 'table-head-grid-custom-selection',\n className\n )}\n role={headerRowCount === 1 ? 'row' : 'presentation'}\n style={{ gridTemplateRows: `repeat(${headerRowCount}, auto)` }}\n >\n {interactionContext.showSelectionColumn && (\n <TableHeaderSelectionCell\n isAllSelected={interactionContext.isAllRowsSelected}\n isSomeRowsSelected={interactionContext.isSomeRowsSelected}\n onToggleAllSelection={interactionContext.onToggleAllSelection}\n rowCount={headerRowCount}\n selectionHeaderContent={interactionContext.selectionHeaderContent}\n />\n )}\n {content}\n </div>\n </TableHeaderContext.Provider>\n </TableSectionContext.Provider>\n </div>\n );\n};\n\nexport default TableHeader;\n"],"names":["TableHeader","props","children","className","sticky","stickyInContainer","remainingProps","renderContext","useOptionalTableRenderContext","renderConfigContext","useOptionalTableRenderConfigContext","interactionContext","useOptionalTableInteractionContext","layoutContext","useOptionalTableLayoutContext","sensors","useSensors","useSensor","PointerSensor","headerRowIndexRef","useRef","activeDraggedColumnKey","setActiveDraggedColumnKey","useState","activeDraggedColumnWidth","setActiveDraggedColumnWidth","canDragColumns","header","headerRowCount","overlayHeader","activeDraggedColumn","column","clearActiveDraggedColumn","handleDragStart","event","handleDragCancel","_event","handleDragEnd","content","jsxs","DndContext","resolveColumnCollisionDetection","restrictToHorizontalAxis","jsx","SortableContext","horizontalListSortingStrategy","DragOverlay","TableHeaderDragOverlay","classNames","TableSectionContext","TableHeaderContext","nextHeaderRowIndex","TableHeaderSelectionCell"],"mappings":";;;;;;;;;;;;;;AAwDA,MAAMA,KAAc,CAA8CC,MAAqC;AACnG,QAAM,EAAE,UA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B,UAAUA,CAAc,UAAA;AAAA,cAElD,UAAA;AAAA,gBAAAjB,EAAmB,uBAChB,gBAAAgC;AAAA,kBAACS;AAAA,kBAAA;AAAA,oBACG,eAAezC,EAAmB;AAAA,oBAClC,oBAAoBA,EAAmB;AAAA,oBACvC,sBAAsBA,EAAmB;AAAA,oBACzC,UAAUiB;AAAA,oBACV,wBAAwBjB,EAAmB;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGlD2B;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA,EACJ,CACJ;AAAA,IAAA;AAAA,EAAA,IA1DA,gBAAAK,EAACM,EAAoB,UAApB,EAA6B,OAAM,UAChC,UAAA,gBAAAN;AAAA,IAACO,EAAmB;AAAA,IAAnB;AAAA,MACG,OAAO;AAAA,QACH,oBAAoB,MAAM;AACtB,gBAAMC,IAAqBhC,EAAkB;AAC7C,iBAAAA,EAAkB,WAAW,GACtBgC;AAAA,QACX;AAAA,MAAA;AAAA,MAGH,UAAAb;AAAA,IAAA;AAAA,EAAA,GAET;AAiDZ;"}
1
+ {"version":3,"file":"TableHeader.js","sources":["../../../src/components/table/TableHeader.tsx"],"sourcesContent":["import {\n DndContext,\n DragOverlay,\n PointerSensor,\n type DragCancelEvent,\n type DragEndEvent,\n type DragStartEvent,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { restrictToHorizontalAxis } from '@dnd-kit/modifiers';\nimport { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';\nimport { type MutableRefObject, type ReactNode, useLayoutEffect, useRef, useState } from 'react';\n\nimport useMergeRefs from '../../hooks/useMergeRefs';\nimport useResizeObserver from '../../useResizeObserver';\nimport classNames from '../../utils/classNames';\nimport type { TableHtmlAttributes, TableRowData } from './Table.types';\nimport TableHeaderDragOverlay from './render/header/TableHeaderDragOverlay';\nimport TableHeaderSelectionCell from './render/header/TableHeaderSelectionCell';\nimport { resolveColumnCollisionDetection } from './render/header/resolveColumnCollisionDetection';\nimport { useOptionalTableInteractionContext } from './context/TableInteractionContext';\nimport { useOptionalTableLayoutContext } from './context/TableLayoutContext';\nimport { useOptionalTableRenderConfigContext } from './context/TableRenderConfigContext';\nimport { TableHeaderContext, TableSectionContext } from './context/TableStructureContext';\nimport { useOptionalTableRenderContext } from './context/TableRenderContext';\n\nexport type TableHeaderProps<RowType extends TableRowData> = TableHtmlAttributes & {\n /**\n * Additional class names for the header grid wrapper.\n */\n className?: string;\n\n /**\n * Keeps the table header sticky while the page scrolls.\n * The sticky top reference follows `Table.stickyReference`.\n *\n * This applies in `TABLE` view only.\n *\n * @default false\n */\n sticky?: boolean;\n\n /**\n * Table header content.\n */\n children?: ReactNode;\n};\n\nconst TABLE_STICKY_HEADER_HEIGHT_VAR = '--table-sticky-header-height';\n\nconst TableHeader = <RowType extends TableRowData = TableRowData>(props: TableHeaderProps<RowType>) => {\n const { children, className, sticky = false, ...remainingProps } = props;\n\n const renderContext = useOptionalTableRenderContext<RowType>();\n const renderConfigContext = useOptionalTableRenderConfigContext<RowType>();\n const interactionContext = useOptionalTableInteractionContext<RowType>();\n const layoutContext = useOptionalTableLayoutContext();\n\n if (!renderContext || !renderConfigContext || !interactionContext || !layoutContext) {\n return null;\n }\n\n const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 6 } }));\n\n const headerRowIndexRef = useRef(0);\n const [headerElementRef, , { blockSize: headerBlockSize }] = useResizeObserver<HTMLDivElement>();\n headerRowIndexRef.current = 0;\n\n const [activeDraggedColumnKey, setActiveDraggedColumnKey] = useState<string | undefined>(undefined);\n const [activeDraggedColumnWidth, setActiveDraggedColumnWidth] = useState<number | undefined>(undefined);\n const mergedHeaderRefs = useMergeRefs(\n layoutContext.tableHeadRowRef as MutableRefObject<HTMLDivElement | null>,\n headerElementRef\n );\n\n const canDragColumns = !!layoutContext.onColumnDragEnd && (layoutContext.draggableColumnKeys?.length ?? 0) > 1;\n const header = renderContext.header;\n const headerRowCount = header?.rowCount ?? 1;\n const overlayHeader = header ?? {\n rowCount: headerRowCount,\n totalColumnCount: renderContext.columns.length,\n columns: [],\n };\n\n const activeDraggedColumn = activeDraggedColumnKey\n ? header?.columns.find(column => (column.columnKey ?? String(column.key)) === activeDraggedColumnKey)\n : undefined;\n\n const clearActiveDraggedColumn = () => {\n setActiveDraggedColumnKey(undefined);\n setActiveDraggedColumnWidth(undefined);\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n setActiveDraggedColumnKey(String(event.active.id));\n setActiveDraggedColumnWidth(event.active.rect.current.initial?.width ?? undefined);\n };\n\n const handleDragCancel = (_event: DragCancelEvent) => {\n clearActiveDraggedColumn();\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n clearActiveDraggedColumn();\n layoutContext.onColumnDragEnd?.(event);\n };\n\n useLayoutEffect(() => {\n const headerElement = headerElementRef.current;\n const tableElement = headerElement?.closest<HTMLElement>('.table');\n\n if (!tableElement) {\n return;\n }\n\n if (!sticky || !headerElement) {\n tableElement.style.removeProperty(TABLE_STICKY_HEADER_HEIGHT_VAR);\n return;\n }\n\n const resolvedHeight = Math.max(headerBlockSize ?? headerElement.getBoundingClientRect().height ?? 0, 0);\n\n tableElement.style.setProperty(TABLE_STICKY_HEADER_HEIGHT_VAR, `${resolvedHeight}px`);\n\n return () => {\n tableElement.style.removeProperty(TABLE_STICKY_HEADER_HEIGHT_VAR);\n };\n }, [headerBlockSize, sticky]);\n\n const content =\n canDragColumns && layoutContext.draggableColumnKeys ? (\n <DndContext\n sensors={sensors}\n collisionDetection={resolveColumnCollisionDetection}\n modifiers={[restrictToHorizontalAxis]}\n onDragStart={handleDragStart}\n onDragCancel={handleDragCancel}\n onDragEnd={handleDragEnd}\n >\n <SortableContext items={layoutContext.draggableColumnKeys} strategy={horizontalListSortingStrategy}>\n {children}\n </SortableContext>\n <DragOverlay adjustScale={false} dropAnimation={null}>\n <TableHeaderDragOverlay\n column={activeDraggedColumn}\n header={overlayHeader}\n showSelectionColumn={interactionContext.showSelectionColumn}\n width={activeDraggedColumnWidth}\n />\n </DragOverlay>\n </DndContext>\n ) : (\n children\n );\n\n if (!renderConfigContext.isTableView) {\n return (\n <TableSectionContext.Provider value='header'>\n <TableHeaderContext.Provider\n value={{\n nextHeaderRowIndex: () => {\n const nextHeaderRowIndex = headerRowIndexRef.current;\n headerRowIndexRef.current += 1;\n return nextHeaderRowIndex;\n },\n }}\n >\n {content}\n </TableHeaderContext.Provider>\n </TableSectionContext.Provider>\n );\n }\n\n return (\n <div\n {...remainingProps}\n className={classNames('table-head', sticky && 'table-head-sticky')}\n role='rowgroup'\n ref={mergedHeaderRefs}\n >\n <TableSectionContext.Provider value='header'>\n <TableHeaderContext.Provider\n value={{\n nextHeaderRowIndex: () => {\n const nextHeaderRowIndex = headerRowIndexRef.current;\n headerRowIndexRef.current += 1;\n return nextHeaderRowIndex;\n },\n }}\n >\n <div\n className={classNames(\n 'table-head-grid',\n interactionContext.selectionHeaderContent && 'table-head-grid-custom-selection',\n className\n )}\n role={headerRowCount === 1 ? 'row' : 'presentation'}\n style={{ gridTemplateRows: `repeat(${headerRowCount}, auto)` }}\n >\n {interactionContext.showSelectionColumn && (\n <TableHeaderSelectionCell\n isAllSelected={interactionContext.isAllRowsSelected}\n isSomeRowsSelected={interactionContext.isSomeRowsSelected}\n onToggleAllSelection={interactionContext.onToggleAllSelection}\n disabled={!interactionContext.hasSelectableRows}\n rowCount={headerRowCount}\n selectionHeaderContent={interactionContext.selectionHeaderContent}\n selectionCheckboxVerticalAlignment={\n renderConfigContext.selectionCheckboxVerticalAlignment\n }\n />\n )}\n {content}\n </div>\n </TableHeaderContext.Provider>\n </TableSectionContext.Provider>\n </div>\n );\n};\n\nexport default TableHeader;\n"],"names":["TABLE_STICKY_HEADER_HEIGHT_VAR","TableHeader","props","children","className","sticky","remainingProps","renderContext","useOptionalTableRenderContext","renderConfigContext","useOptionalTableRenderConfigContext","interactionContext","useOptionalTableInteractionContext","layoutContext","useOptionalTableLayoutContext","sensors","useSensors","useSensor","PointerSensor","headerRowIndexRef","useRef","headerElementRef","headerBlockSize","useResizeObserver","activeDraggedColumnKey","setActiveDraggedColumnKey","useState","activeDraggedColumnWidth","setActiveDraggedColumnWidth","mergedHeaderRefs","useMergeRefs","canDragColumns","header","headerRowCount","overlayHeader","activeDraggedColumn","column","clearActiveDraggedColumn","handleDragStart","event","handleDragCancel","_event","handleDragEnd","useLayoutEffect","headerElement","tableElement","resolvedHeight","content","jsxs","DndContext","resolveColumnCollisionDetection","restrictToHorizontalAxis","jsx","SortableContext","horizontalListSortingStrategy","DragOverlay","TableHeaderDragOverlay","classNames","TableSectionContext","TableHeaderContext","nextHeaderRowIndex","TableHeaderSelectionCell"],"mappings":";;;;;;;;;;;;;;;;AAiDA,MAAMA,IAAiC,gCAEjCC,KAAc,CAA8CC,MAAqC;AACnG,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,QAAAC,IAAS,IAAO,GAAGC,MAAmBJ,GAE7DK,IAAgBC,GAAA,GAChBC,IAAsBC,GAAA,GACtBC,IAAqBC,EAAA,GACrBC,IAAgBC,GAAA;AAEtB,MAAI,CAACP,KAAiB,CAACE,KAAuB,CAACE,KAAsB,CAACE;AAClE,WAAO;AAGX,QAAME,IAAUC,EAAWC,EAAUC,GAAe,EAAE,sBAAsB,EAAE,UAAU,EAAA,EAAE,CAAG,CAAC,GAExFC,IAAoBC,EAAO,CAAC,GAC5B,CAACC,KAAoB,EAAE,WAAWC,EAAA,CAAiB,IAAIC,EAAA;AAC7D,EAAAJ,EAAkB,UAAU;AAE5B,QAAM,CAACK,GAAwBC,CAAyB,IAAIC,EAA6B,MAAS,GAC5F,CAACC,GAA0BC,CAA2B,IAAIF,EAA6B,MAAS,GAChGG,IAAmBC;AAAA,IACrBjB,EAAc;AAAA,IACdQ;AAAA,EAAA,GAGEU,IAAiB,CAAC,CAAClB,EAAc,oBAAoBA,EAAc,qBAAqB,UAAU,KAAK,GACvGmB,IAASzB,EAAc,QACvB0B,IAAiBD,GAA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vC,sBAAsBA,EAAmB;AAAA,oBACzC,UAAU,CAACA,EAAmB;AAAA,oBAC9B,UAAUsB;AAAA,oBACV,wBAAwBtB,EAAmB;AAAA,oBAC3C,oCACIF,EAAoB;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAI/BsC;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACL;AAAA,MAAA,EACJ,CACJ;AAAA,IAAA;AAAA,EAAA,IA1DA,gBAAAK,EAACM,EAAoB,UAApB,EAA6B,OAAM,UAChC,UAAA,gBAAAN;AAAA,IAACO,EAAmB;AAAA,IAAnB;AAAA,MACG,OAAO;AAAA,QACH,oBAAoB,MAAM;AACtB,gBAAMC,IAAqBzC,EAAkB;AAC7C,iBAAAA,EAAkB,WAAW,GACtByC;AAAA,QACX;AAAA,MAAA;AAAA,MAGH,UAAAb;AAAA,IAAA;AAAA,EAAA,GAET;AAiDZ;"}
@@ -2,7 +2,9 @@ import { ReactNode } from 'react';
2
2
  import { TableHtmlAttributes, TableRowData } from './Table.types';
3
3
  export type TableRowProps<RowType extends TableRowData> = TableHtmlAttributes & Partial<RowType> & {
4
4
  /**
5
- * Keeps the row sticky at the top of a scrollable table body.
5
+ * Keeps the row sticky at the top of the current table scroll context.
6
+ * When a sticky `TableHeader` is present, the row stacks below the measured header height.
7
+ * `TableBody maxHeight` continues to pin the row inside the internal body scroller.
6
8
  *
7
9
  * @default false
8
10
  */
@@ -17,6 +19,10 @@ export type TableRowProps<RowType extends TableRowData> = TableHtmlAttributes &
17
19
  * Optional class names only for this row.
18
20
  */
19
21
  className?: string;
22
+ /**
23
+ * Excludes this row from table selection while keeping the row interactive.
24
+ */
25
+ selectable?: boolean;
20
26
  /**
21
27
  * Disable table hover styling for this row.
22
28
  */