@mortenbrudvik/waveui 0.15.0 → 0.16.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 (155) hide show
  1. package/README.md +274 -24
  2. package/dist/components/data-display/List.cjs +1 -1
  3. package/dist/components/data-display/List.cjs.map +1 -1
  4. package/dist/components/data-display/List.mjs +405 -219
  5. package/dist/components/data-display/List.mjs.map +1 -1
  6. package/dist/components/data-display/List.registry.cjs +1 -1
  7. package/dist/components/data-display/List.registry.cjs.map +1 -1
  8. package/dist/components/data-display/List.registry.mjs +12 -6
  9. package/dist/components/data-display/List.registry.mjs.map +1 -1
  10. package/dist/components/input/Combobox.cjs +1 -1
  11. package/dist/components/input/Combobox.cjs.map +1 -1
  12. package/dist/components/input/Combobox.mjs +163 -148
  13. package/dist/components/input/Combobox.mjs.map +1 -1
  14. package/dist/components/input/Dropdown.cjs +1 -1
  15. package/dist/components/input/Dropdown.cjs.map +1 -1
  16. package/dist/components/input/Dropdown.mjs +132 -117
  17. package/dist/components/input/Dropdown.mjs.map +1 -1
  18. package/dist/components/input/Listbox.cjs +1 -1
  19. package/dist/components/input/Listbox.cjs.map +1 -1
  20. package/dist/components/input/Listbox.mjs +90 -78
  21. package/dist/components/input/Listbox.mjs.map +1 -1
  22. package/dist/components/input/Option.cjs +1 -1
  23. package/dist/components/input/Option.cjs.map +1 -1
  24. package/dist/components/input/Option.data.cjs +2 -0
  25. package/dist/components/input/Option.data.cjs.map +1 -0
  26. package/dist/components/input/Option.data.mjs +114 -0
  27. package/dist/components/input/Option.data.mjs.map +1 -0
  28. package/dist/components/input/Option.mjs +21 -17
  29. package/dist/components/input/Option.mjs.map +1 -1
  30. package/dist/components/layout/FlatTree.cjs +2 -0
  31. package/dist/components/layout/FlatTree.cjs.map +1 -0
  32. package/dist/components/layout/FlatTree.context.cjs +2 -0
  33. package/dist/components/layout/FlatTree.context.cjs.map +1 -0
  34. package/dist/components/layout/FlatTree.context.mjs +20 -0
  35. package/dist/components/layout/FlatTree.context.mjs.map +1 -0
  36. package/dist/components/layout/FlatTree.item.cjs +2 -0
  37. package/dist/components/layout/FlatTree.item.cjs.map +1 -0
  38. package/dist/components/layout/FlatTree.item.mjs +90 -0
  39. package/dist/components/layout/FlatTree.item.mjs.map +1 -0
  40. package/dist/components/layout/FlatTree.mjs +276 -0
  41. package/dist/components/layout/FlatTree.mjs.map +1 -0
  42. package/dist/components/layout/Tree.core.cjs +1 -1
  43. package/dist/components/layout/Tree.core.cjs.map +1 -1
  44. package/dist/components/layout/Tree.core.mjs +166 -165
  45. package/dist/components/layout/Tree.core.mjs.map +1 -1
  46. package/dist/components/layout/Tree.selection.cjs +1 -1
  47. package/dist/components/layout/Tree.selection.cjs.map +1 -1
  48. package/dist/components/layout/Tree.selection.mjs +11 -57
  49. package/dist/components/layout/Tree.selection.mjs.map +1 -1
  50. package/dist/components/layout/useFlatTree.cjs +2 -0
  51. package/dist/components/layout/useFlatTree.cjs.map +1 -0
  52. package/dist/components/layout/useFlatTree.mjs +83 -0
  53. package/dist/components/layout/useFlatTree.mjs.map +1 -0
  54. package/dist/components/table/DataGrid.cjs +1 -1
  55. package/dist/components/table/DataGrid.cjs.map +1 -1
  56. package/dist/components/table/DataGrid.context.cjs +2 -0
  57. package/dist/components/table/DataGrid.context.cjs.map +1 -0
  58. package/dist/components/table/DataGrid.context.mjs +74 -0
  59. package/dist/components/table/DataGrid.context.mjs.map +1 -0
  60. package/dist/components/table/DataGrid.header.cjs +2 -0
  61. package/dist/components/table/DataGrid.header.cjs.map +1 -0
  62. package/dist/components/table/DataGrid.header.mjs +168 -0
  63. package/dist/components/table/DataGrid.header.mjs.map +1 -0
  64. package/dist/components/table/DataGrid.mjs +488 -591
  65. package/dist/components/table/DataGrid.mjs.map +1 -1
  66. package/dist/components/table/DataGrid.sizing.cjs +2 -0
  67. package/dist/components/table/DataGrid.sizing.cjs.map +1 -0
  68. package/dist/components/table/DataGrid.sizing.mjs +187 -0
  69. package/dist/components/table/DataGrid.sizing.mjs.map +1 -0
  70. package/dist/components/table/DataGrid.store.cjs +2 -0
  71. package/dist/components/table/DataGrid.store.cjs.map +1 -0
  72. package/dist/components/table/DataGrid.store.mjs +108 -0
  73. package/dist/components/table/DataGrid.store.mjs.map +1 -0
  74. package/dist/components/table/DataGrid.window.cjs +2 -0
  75. package/dist/components/table/DataGrid.window.cjs.map +1 -0
  76. package/dist/components/table/DataGrid.window.mjs +165 -0
  77. package/dist/components/table/DataGrid.window.mjs.map +1 -0
  78. package/dist/components/table/Table.cjs +1 -1
  79. package/dist/components/table/Table.cjs.map +1 -1
  80. package/dist/components/table/Table.mjs +74 -72
  81. package/dist/components/table/Table.mjs.map +1 -1
  82. package/dist/components/table/Table.resize.cjs +2 -0
  83. package/dist/components/table/Table.resize.cjs.map +1 -0
  84. package/dist/components/table/Table.resize.mjs +98 -0
  85. package/dist/components/table/Table.resize.mjs.map +1 -0
  86. package/dist/components/table/useGridNavigation.cjs +1 -1
  87. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  88. package/dist/components/table/useGridNavigation.mjs +343 -140
  89. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  90. package/dist/components/table/useTableColumnSizing.cjs +2 -0
  91. package/dist/components/table/useTableColumnSizing.cjs.map +1 -0
  92. package/dist/components/table/useTableColumnSizing.mjs +76 -0
  93. package/dist/components/table/useTableColumnSizing.mjs.map +1 -0
  94. package/dist/components/table/useTableFeatures.cjs +2 -0
  95. package/dist/components/table/useTableFeatures.cjs.map +1 -0
  96. package/dist/components/table/useTableFeatures.mjs +110 -0
  97. package/dist/components/table/useTableFeatures.mjs.map +1 -0
  98. package/dist/components/table/useTableSelection.cjs +2 -0
  99. package/dist/components/table/useTableSelection.cjs.map +1 -0
  100. package/dist/components/table/useTableSelection.mjs +39 -0
  101. package/dist/components/table/useTableSelection.mjs.map +1 -0
  102. package/dist/components/table/useTableSort.cjs +2 -0
  103. package/dist/components/table/useTableSort.cjs.map +1 -0
  104. package/dist/components/table/useTableSort.mjs +58 -0
  105. package/dist/components/table/useTableSort.mjs.map +1 -0
  106. package/dist/hooks/useActiveDescendant.cjs +1 -1
  107. package/dist/hooks/useActiveDescendant.cjs.map +1 -1
  108. package/dist/hooks/useActiveDescendant.mjs +33 -25
  109. package/dist/hooks/useActiveDescendant.mjs.map +1 -1
  110. package/dist/hooks/useListbox.cjs +1 -1
  111. package/dist/hooks/useListbox.cjs.map +1 -1
  112. package/dist/hooks/useListbox.mjs +140 -130
  113. package/dist/hooks/useListbox.mjs.map +1 -1
  114. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  115. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  116. package/dist/hooks/useRovingTabIndex.mjs +1 -1
  117. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  118. package/dist/hooks/useSelection.cjs +2 -0
  119. package/dist/hooks/useSelection.cjs.map +1 -0
  120. package/dist/hooks/useSelection.mjs +57 -0
  121. package/dist/hooks/useSelection.mjs.map +1 -0
  122. package/dist/hooks/useVirtualWindow.cjs +2 -0
  123. package/dist/hooks/useVirtualWindow.cjs.map +1 -0
  124. package/dist/hooks/useVirtualWindow.mjs +102 -0
  125. package/dist/hooks/useVirtualWindow.mjs.map +1 -0
  126. package/dist/index.cjs +1 -1
  127. package/dist/index.d.cts +1542 -53
  128. package/dist/index.d.ts +1542 -53
  129. package/dist/index.mjs +147 -136
  130. package/dist/lib/classNames.cjs +1 -1
  131. package/dist/lib/classNames.cjs.map +1 -1
  132. package/dist/lib/classNames.mjs +68 -49
  133. package/dist/lib/classNames.mjs.map +1 -1
  134. package/dist/lib/columnSizing.cjs +2 -0
  135. package/dist/lib/columnSizing.cjs.map +1 -0
  136. package/dist/lib/columnSizing.mjs +27 -0
  137. package/dist/lib/columnSizing.mjs.map +1 -0
  138. package/dist/lib/flatTree.cjs +2 -0
  139. package/dist/lib/flatTree.cjs.map +1 -0
  140. package/dist/lib/flatTree.mjs +118 -0
  141. package/dist/lib/flatTree.mjs.map +1 -0
  142. package/dist/lib/selection.cjs +2 -0
  143. package/dist/lib/selection.cjs.map +1 -0
  144. package/dist/lib/selection.mjs +28 -0
  145. package/dist/lib/selection.mjs.map +1 -0
  146. package/dist/lib/treeCascade.cjs +2 -0
  147. package/dist/lib/treeCascade.cjs.map +1 -0
  148. package/dist/lib/treeCascade.mjs +52 -0
  149. package/dist/lib/treeCascade.mjs.map +1 -0
  150. package/dist/lib/virtual.cjs +2 -0
  151. package/dist/lib/virtual.cjs.map +1 -0
  152. package/dist/lib/virtual.mjs +54 -0
  153. package/dist/lib/virtual.mjs.map +1 -0
  154. package/dist/styles.css +1 -1
  155. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("./DataGrid.store.cjs");let r=require("react");r=e.__toESM(r,1);var i=`Select all rows`,a=`Selection`;function o(){let e=new Map,t=new Set,n=null,r=()=>{let r=null,i=null;for(let[t,a]of e){let o=a();if(!o){if(n!==null&&e.has(n))return;continue}(!i||o.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_FOLLOWING)&&(r=t,i=o)}if(r===null&&(r=e.keys().next().value??null),r!==n){n=r;for(let e of Array.from(t))e()}};return{subscribe(e){return t.add(e),()=>{t.delete(e)}},register(t,n){return e.set(t,n),r(),()=>{e.delete(t),r()}},getFirst:()=>n,refresh:r}}var s=r.createContext(null),c=r.createContext(null),l=r.createContext(`body`),u=r.createContext(null),d=r.createContext(!0),f=r.createContext(null),p=r.createContext(null),m=r.createContext(void 0),h=r.createContext(null),g={selectionMode:`none`,store:n.createSelectionStore([]),toggleRow:()=>{},toggleAll:()=>{},radioName:``,selectAllLabel:i,selectionHeaderLabel:a,selectOnRowClick:!1,selectionAppearance:`brand`,subtleSelection:!1},_={sort:null,requestSort:()=>{}},v={selectionCellProps:void 0,hasSelectionCell:!0,rowId:void 0,isSelected:!1,disabled:!1,invisible:!1,ariaLabel:void 0,ariaLabelledBy:void 0};function y(e){return r.useContext(s)||(t.reportMissingContext(e,`DataGrid`),g)}function b(e){return r.useContext(h)||(t.reportMissingContext(e,`DataGrid.Row`),v)}function x(e){return r.useContext(c)||(t.reportMissingContext(e,`DataGrid`),_)}exports.DEFAULT_SELECTION_HEADER_LABEL=a,exports.DEFAULT_SELECT_ALL_LABEL=i,exports.DataGridContext=s,exports.DataGridHeaderRowHintContext=d,exports.DataGridHeaderSlotsContext=u,exports.DataGridItemSelectionDisabledContext=m,exports.DataGridItemsContext=f,exports.DataGridRowContext=h,exports.DataGridRowIdContext=p,exports.DataGridSectionContext=l,exports.DataGridSortContext=c,exports.createHeaderSlotRegistry=o,exports.useDataGridContext=y,exports.useDataGridRowContext=b,exports.useDataGridSortContext=x;
2
+ //# sourceMappingURL=DataGrid.context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.context.cjs","names":["React","createSelectionStore","require_runtime","require_dev","require_DataGrid_store","react","DEFAULT_SELECT_ALL_LABEL","DEFAULT_SELECTION_HEADER_LABEL","createHeaderSlotRegistry","slots","listeners","first","update","next","nextCell","slot","getCell","cell","listener","DataGridContext","DataGridSortContext","DataGridSectionContext","DataGridHeaderSlotsContext","DataGridHeaderRowHintContext","DataGridItemsContext","DataGridRowIdContext","DataGridItemSelectionDisabledContext","DataGridRowContext","INERT_CONTEXT","INERT_SORT_CONTEXT","INERT_ROW_CONTEXT","useDataGridContext","component","useDataGridRowContext","useDataGridSortContext"],"sources":["../../../src/components/table/DataGrid.context.ts"],"sourcesContent":["import * as React from 'react';\nimport { reportMissingContext } from '../../lib/dev';\nimport type { SelectionMode } from '../../lib/types';\nimport { createSelectionStore, type SelectionStore } from './DataGrid.store';\nimport type {\n DataGridRowSelectionCellProps,\n DataGridSelectionAppearance,\n DataGridSort,\n} from './DataGrid';\n\nexport const DEFAULT_SELECT_ALL_LABEL = 'Select all rows';\nexport const DEFAULT_SELECTION_HEADER_LABEL = 'Selection';\n\n// ---------------------------------------------------------------------------\n// Header selection slots\n// ---------------------------------------------------------------------------\n\n/**\n * The selection column's header slots of one `DataGrid.Header`, one per header row. Only the first\n * slot in document order renders the \"Select all rows\" control (the \"Selection\" text in single\n * mode); the others render an empty cell, so a grouped header (several header rows) has one control\n * and every header row keeps the selection column.\n */\nexport interface HeaderSlotRegistry {\n subscribe(listener: () => void): () => void;\n /** Registers a slot and a getter for its current cell; returns the unregister function. */\n register(slot: object, getCell: () => Element | null): () => void;\n /** The first slot in document order, or `null` while no slot is registered. */\n getFirst(): object | null;\n /** Re-checks the order: header rows can move without a slot mounting or unmounting. */\n refresh(): void;\n}\n\nexport function createHeaderSlotRegistry(): HeaderSlotRegistry {\n const slots = new Map<object, () => Element | null>();\n const listeners = new Set<() => void>();\n let first: object | null = null;\n\n const update = () => {\n let next: object | null = null;\n let nextCell: Element | null = null;\n for (const [slot, getCell] of slots) {\n const cell = getCell();\n if (!cell) {\n // A slot whose cell is being replaced (control <-> empty cell): keep the current order\n // until the next registration or header commit sees every cell again.\n if (first !== null && slots.has(first)) return;\n continue;\n }\n if (!nextCell || cell.compareDocumentPosition(nextCell) & Node.DOCUMENT_POSITION_FOLLOWING) {\n next = slot;\n nextCell = cell;\n }\n }\n if (next === null) next = slots.keys().next().value ?? null;\n if (next === first) return;\n first = next;\n for (const listener of Array.from(listeners)) listener();\n };\n\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n register(slot, getCell) {\n slots.set(slot, getCell);\n update();\n return () => {\n slots.delete(slot);\n update();\n };\n },\n getFirst: () => first,\n refresh: update,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\nexport interface DataGridContextValue {\n selectionMode: 'none' | SelectionMode;\n store: SelectionStore;\n /** Toggles one row (single mode: selects it alone, or clears it); `event` goes to `details`. */\n toggleRow: (rowId: string, event: Event) => void;\n /**\n * Selects every row select-all changes (with `items`, every selectable item, rendered or not),\n * or clears them when all are selected.\n */\n toggleAll: (event: Event) => void;\n /** Shared `name` of the single-mode radios (they are kept out of any form with `form=\"\"`). */\n radioName: string;\n /** Name of the select-all checkbox (multiple mode). */\n selectAllLabel: string;\n /** Hidden header text of the selection column (single mode). */\n selectionHeaderLabel: string;\n /** `selectOnRowClick` of the grid. */\n selectOnRowClick: boolean;\n /** `selectionAppearance` of the grid. */\n selectionAppearance: DataGridSelectionAppearance;\n /** `subtleSelection` of the grid. */\n subtleSelection: boolean;\n}\n\n/** What a row tells its selection cell, the automatic one or a `DataGrid.SelectionCell` child. */\nexport interface DataGridRowContextValue {\n /** The row's `selectionCellProps`. */\n selectionCellProps: DataGridRowSelectionCellProps | undefined;\n /** Whether a `DataGrid.SelectionCell` child was seen (then the row adds no cell of its own). */\n hasSelectionCell: boolean;\n /** The row's id; `undefined` for a header row, or a body row without one (no control). */\n rowId: string | undefined;\n isSelected: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n disabled: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n invisible: boolean;\n /** The control's `aria-label`. */\n ariaLabel: string | undefined;\n /** The control's `aria-labelledby`. */\n ariaLabelledBy: string | undefined;\n}\n\nexport interface DataGridSortContextValue {\n sort: DataGridSort | null;\n /** Sorts by the column (toggling its direction); `event` goes to `details`. */\n requestSort: (columnId: string, event: Event) => void;\n}\n\nexport type DataGridSection = 'header' | 'body';\n\nexport const DataGridContext = React.createContext<DataGridContextValue | null>(null);\nexport const DataGridSortContext = React.createContext<DataGridSortContextValue | null>(null);\n/** Whether a row is rendered in the header or the body (rows in a header get a header cell). */\nexport const DataGridSectionContext = React.createContext<DataGridSection>('body');\n/** The header's selection slots (see {@link HeaderSlotRegistry}). */\nexport const DataGridHeaderSlotsContext = React.createContext<HeaderSlotRegistry | null>(null);\n/**\n * Whether the header row below is the header's first row, as far as the header can tell from its\n * children. Only the initial (and server) render uses it; the slots then follow the DOM order.\n */\nexport const DataGridHeaderRowHintContext = React.createContext(true);\n\n/** Renders the row of one item of `items` (a `DataGrid.Body` render function, or from `columns`). */\nexport type DataGridRenderRow = (item: unknown, index: number) => React.ReactNode;\n\n/** One row of the grid's `items`. */\nexport interface DataGridItemRowData {\n item: unknown;\n /** The item's index in `items`. */\n index: number;\n rowId: string;\n /** The row's React key: its row id, made unique when the id repeats. */\n key: string;\n}\n\nexport interface DataGridItemsContextValue {\n /** The rows of `items`, in the order they are rendered; `null` without `items`. */\n rows: readonly DataGridItemRowData[] | null;\n /** Renders a row from `columns`; `null` without `items` and `columns`. */\n renderColumnsRow: DataGridRenderRow | null;\n /**\n * `isSelectionDisabled` of each item, by its index in `items`; `null` without `items` or\n * without `isSelectionDisabled`.\n */\n selectionDisabled: readonly boolean[] | null;\n}\n\n/** The grid's `items`, for `DataGrid.Body` (optional: a body of JSX rows needs none). */\nexport const DataGridItemsContext = React.createContext<DataGridItemsContextValue | null>(null);\n/**\n * The row id of the item a body row is rendered for, the default `rowId` of `DataGrid.Row`. The\n * grid resets it, so the rows of a grid nested in a cell do not take the outer row's id.\n */\nexport const DataGridRowIdContext = React.createContext<string | null>(null);\n/**\n * `isSelectionDisabled` of the item a body row is rendered for, the default `disabled` of the\n * row's selection cell; `undefined` without it. The grid resets it, as {@link DataGridRowIdContext}.\n */\nexport const DataGridItemSelectionDisabledContext = React.createContext<boolean | undefined>(\n undefined,\n);\n/** The row around a selection cell (see {@link DataGridRowContextValue}). */\nexport const DataGridRowContext = React.createContext<DataGridRowContextValue | null>(null);\n\nconst INERT_STORE = createSelectionStore([]);\nconst INERT_CONTEXT: DataGridContextValue = {\n selectionMode: 'none',\n store: INERT_STORE,\n toggleRow: () => {},\n toggleAll: () => {},\n radioName: '',\n selectAllLabel: DEFAULT_SELECT_ALL_LABEL,\n selectionHeaderLabel: DEFAULT_SELECTION_HEADER_LABEL,\n selectOnRowClick: false,\n selectionAppearance: 'brand',\n subtleSelection: false,\n};\nconst INERT_SORT_CONTEXT: DataGridSortContextValue = { sort: null, requestSort: () => {} };\nconst INERT_ROW_CONTEXT: DataGridRowContextValue = {\n selectionCellProps: undefined,\n hasSelectionCell: true,\n rowId: undefined,\n isSelected: false,\n disabled: false,\n invisible: false,\n ariaLabel: undefined,\n ariaLabelledBy: undefined,\n};\n\nexport function useDataGridContext(component: string): DataGridContextValue {\n const ctx = React.useContext(DataGridContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_CONTEXT;\n}\n\nexport function useDataGridRowContext(component: string): DataGridRowContextValue {\n const ctx = React.useContext(DataGridRowContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid.Row');\n return INERT_ROW_CONTEXT;\n}\n\nexport function useDataGridSortContext(component: string): DataGridSortContextValue {\n const ctx = React.useContext(DataGridSortContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_SORT_CONTEXT;\n}\n"],"mappings":"8KAUA,IAAaM,EAA2B,kBAC3BC,EAAiC,YAsB9C,SAAgBC,GAA+C,CAC7D,IAAMC,EAAQ,IAAI,IACZC,EAAY,IAAI,IAClBC,EAAuB,KAErBC,MAAe,CACnB,IAAIC,EAAsB,KACtBC,EAA2B,KAC/B,IAAK,GAAM,CAACC,EAAMC,KAAYP,EAAO,CACnC,IAAMQ,EAAOD,EAAQ,EACrB,GAAI,CAACC,EAAM,CAGT,GAAIN,IAAU,MAAQF,EAAM,IAAIE,CAAK,EAAG,OACxC,QACF,EACI,CAACG,GAAYG,EAAK,wBAAwBH,CAAQ,EAAI,KAAK,+BAC7D,EAAOC,EACP,EAAWE,EAEf,CAEA,GADIJ,IAAS,OAAM,EAAOJ,EAAM,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,OAAS,MACnDI,IAASF,EACb,GAAQE,EACR,IAAK,IAAMK,KAAY,MAAM,KAAKR,CAAS,EAAGQ,EAAS,CAD/C,CAEV,EAEA,MAAO,CACL,UAAU,EAAU,CAElB,OADAR,EAAU,IAAIQ,CAAQ,MACT,CACXR,EAAU,OAAOQ,CAAQ,CA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AAqB6B,EAAW,UAAU,EACnCH,EACT"}
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import { reportMissingContext as e } from "../../lib/dev.mjs";
3
+ import { createSelectionStore as t } from "./DataGrid.store.mjs";
4
+ import * as n from "react";
5
+ //#region src/components/table/DataGrid.context.ts
6
+ var r = "Select all rows", i = "Selection";
7
+ function a() {
8
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = null, r = () => {
9
+ let r = null, i = null;
10
+ for (let [t, a] of e) {
11
+ let o = a();
12
+ if (!o) {
13
+ if (n !== null && e.has(n)) return;
14
+ continue;
15
+ }
16
+ (!i || o.compareDocumentPosition(i) & Node.DOCUMENT_POSITION_FOLLOWING) && (r = t, i = o);
17
+ }
18
+ if (r === null && (r = e.keys().next().value ?? null), r !== n) {
19
+ n = r;
20
+ for (let e of Array.from(t)) e();
21
+ }
22
+ };
23
+ return {
24
+ subscribe(e) {
25
+ return t.add(e), () => {
26
+ t.delete(e);
27
+ };
28
+ },
29
+ register(t, n) {
30
+ return e.set(t, n), r(), () => {
31
+ e.delete(t), r();
32
+ };
33
+ },
34
+ getFirst: () => n,
35
+ refresh: r
36
+ };
37
+ }
38
+ var o = n.createContext(null), s = n.createContext(null), c = n.createContext("body"), l = n.createContext(null), u = n.createContext(!0), d = n.createContext(null), f = n.createContext(null), p = n.createContext(void 0), m = n.createContext(null), h = {
39
+ selectionMode: "none",
40
+ store: t([]),
41
+ toggleRow: () => {},
42
+ toggleAll: () => {},
43
+ radioName: "",
44
+ selectAllLabel: r,
45
+ selectionHeaderLabel: i,
46
+ selectOnRowClick: !1,
47
+ selectionAppearance: "brand",
48
+ subtleSelection: !1
49
+ }, g = {
50
+ sort: null,
51
+ requestSort: () => {}
52
+ }, _ = {
53
+ selectionCellProps: void 0,
54
+ hasSelectionCell: !0,
55
+ rowId: void 0,
56
+ isSelected: !1,
57
+ disabled: !1,
58
+ invisible: !1,
59
+ ariaLabel: void 0,
60
+ ariaLabelledBy: void 0
61
+ };
62
+ function v(t) {
63
+ return n.useContext(o) || (e(t, "DataGrid"), h);
64
+ }
65
+ function y(t) {
66
+ return n.useContext(m) || (e(t, "DataGrid.Row"), _);
67
+ }
68
+ function b(t) {
69
+ return n.useContext(s) || (e(t, "DataGrid"), g);
70
+ }
71
+ //#endregion
72
+ export { i as DEFAULT_SELECTION_HEADER_LABEL, r as DEFAULT_SELECT_ALL_LABEL, o as DataGridContext, u as DataGridHeaderRowHintContext, l as DataGridHeaderSlotsContext, p as DataGridItemSelectionDisabledContext, d as DataGridItemsContext, m as DataGridRowContext, f as DataGridRowIdContext, c as DataGridSectionContext, s as DataGridSortContext, a as createHeaderSlotRegistry, v as useDataGridContext, y as useDataGridRowContext, b as useDataGridSortContext };
73
+
74
+ //# sourceMappingURL=DataGrid.context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.context.mjs","names":["React","DEFAULT_SELECT_ALL_LABEL","DEFAULT_SELECTION_HEADER_LABEL","createHeaderSlotRegistry","slots","listeners","first","update","next","nextCell","slot","getCell","cell","listener","DataGridContext","DataGridSortContext","DataGridSectionContext","DataGridHeaderSlotsContext","DataGridHeaderRowHintContext","DataGridItemsContext","DataGridRowIdContext","DataGridItemSelectionDisabledContext","DataGridRowContext","INERT_CONTEXT","createSelectionStore","INERT_SORT_CONTEXT","INERT_ROW_CONTEXT","useDataGridContext","reportMissingContext","component","useDataGridRowContext","useDataGridSortContext"],"sources":["../../../src/components/table/DataGrid.context.ts"],"sourcesContent":["import * as React from 'react';\nimport { reportMissingContext } from '../../lib/dev';\nimport type { SelectionMode } from '../../lib/types';\nimport { createSelectionStore, type SelectionStore } from './DataGrid.store';\nimport type {\n DataGridRowSelectionCellProps,\n DataGridSelectionAppearance,\n DataGridSort,\n} from './DataGrid';\n\nexport const DEFAULT_SELECT_ALL_LABEL = 'Select all rows';\nexport const DEFAULT_SELECTION_HEADER_LABEL = 'Selection';\n\n// ---------------------------------------------------------------------------\n// Header selection slots\n// ---------------------------------------------------------------------------\n\n/**\n * The selection column's header slots of one `DataGrid.Header`, one per header row. Only the first\n * slot in document order renders the \"Select all rows\" control (the \"Selection\" text in single\n * mode); the others render an empty cell, so a grouped header (several header rows) has one control\n * and every header row keeps the selection column.\n */\nexport interface HeaderSlotRegistry {\n subscribe(listener: () => void): () => void;\n /** Registers a slot and a getter for its current cell; returns the unregister function. */\n register(slot: object, getCell: () => Element | null): () => void;\n /** The first slot in document order, or `null` while no slot is registered. */\n getFirst(): object | null;\n /** Re-checks the order: header rows can move without a slot mounting or unmounting. */\n refresh(): void;\n}\n\nexport function createHeaderSlotRegistry(): HeaderSlotRegistry {\n const slots = new Map<object, () => Element | null>();\n const listeners = new Set<() => void>();\n let first: object | null = null;\n\n const update = () => {\n let next: object | null = null;\n let nextCell: Element | null = null;\n for (const [slot, getCell] of slots) {\n const cell = getCell();\n if (!cell) {\n // A slot whose cell is being replaced (control <-> empty cell): keep the current order\n // until the next registration or header commit sees every cell again.\n if (first !== null && slots.has(first)) return;\n continue;\n }\n if (!nextCell || cell.compareDocumentPosition(nextCell) & Node.DOCUMENT_POSITION_FOLLOWING) {\n next = slot;\n nextCell = cell;\n }\n }\n if (next === null) next = slots.keys().next().value ?? null;\n if (next === first) return;\n first = next;\n for (const listener of Array.from(listeners)) listener();\n };\n\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n register(slot, getCell) {\n slots.set(slot, getCell);\n update();\n return () => {\n slots.delete(slot);\n update();\n };\n },\n getFirst: () => first,\n refresh: update,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\nexport interface DataGridContextValue {\n selectionMode: 'none' | SelectionMode;\n store: SelectionStore;\n /** Toggles one row (single mode: selects it alone, or clears it); `event` goes to `details`. */\n toggleRow: (rowId: string, event: Event) => void;\n /**\n * Selects every row select-all changes (with `items`, every selectable item, rendered or not),\n * or clears them when all are selected.\n */\n toggleAll: (event: Event) => void;\n /** Shared `name` of the single-mode radios (they are kept out of any form with `form=\"\"`). */\n radioName: string;\n /** Name of the select-all checkbox (multiple mode). */\n selectAllLabel: string;\n /** Hidden header text of the selection column (single mode). */\n selectionHeaderLabel: string;\n /** `selectOnRowClick` of the grid. */\n selectOnRowClick: boolean;\n /** `selectionAppearance` of the grid. */\n selectionAppearance: DataGridSelectionAppearance;\n /** `subtleSelection` of the grid. */\n subtleSelection: boolean;\n}\n\n/** What a row tells its selection cell, the automatic one or a `DataGrid.SelectionCell` child. */\nexport interface DataGridRowContextValue {\n /** The row's `selectionCellProps`. */\n selectionCellProps: DataGridRowSelectionCellProps | undefined;\n /** Whether a `DataGrid.SelectionCell` child was seen (then the row adds no cell of its own). */\n hasSelectionCell: boolean;\n /** The row's id; `undefined` for a header row, or a body row without one (no control). */\n rowId: string | undefined;\n isSelected: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n disabled: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n invisible: boolean;\n /** The control's `aria-label`. */\n ariaLabel: string | undefined;\n /** The control's `aria-labelledby`. */\n ariaLabelledBy: string | undefined;\n}\n\nexport interface DataGridSortContextValue {\n sort: DataGridSort | null;\n /** Sorts by the column (toggling its direction); `event` goes to `details`. */\n requestSort: (columnId: string, event: Event) => void;\n}\n\nexport type DataGridSection = 'header' | 'body';\n\nexport const DataGridContext = React.createContext<DataGridContextValue | null>(null);\nexport const DataGridSortContext = React.createContext<DataGridSortContextValue | null>(null);\n/** Whether a row is rendered in the header or the body (rows in a header get a header cell). */\nexport const DataGridSectionContext = React.createContext<DataGridSection>('body');\n/** The header's selection slots (see {@link HeaderSlotRegistry}). */\nexport const DataGridHeaderSlotsContext = React.createContext<HeaderSlotRegistry | null>(null);\n/**\n * Whether the header row below is the header's first row, as far as the header can tell from its\n * children. Only the initial (and server) render uses it; the slots then follow the DOM order.\n */\nexport const DataGridHeaderRowHintContext = React.createContext(true);\n\n/** Renders the row of one item of `items` (a `DataGrid.Body` render function, or from `columns`). */\nexport type DataGridRenderRow = (item: unknown, index: number) => React.ReactNode;\n\n/** One row of the grid's `items`. */\nexport interface DataGridItemRowData {\n item: unknown;\n /** The item's index in `items`. */\n index: number;\n rowId: string;\n /** The row's React key: its row id, made unique when the id repeats. */\n key: string;\n}\n\nexport interface DataGridItemsContextValue {\n /** The rows of `items`, in the order they are rendered; `null` without `items`. */\n rows: readonly DataGridItemRowData[] | null;\n /** Renders a row from `columns`; `null` without `items` and `columns`. */\n renderColumnsRow: DataGridRenderRow | null;\n /**\n * `isSelectionDisabled` of each item, by its index in `items`; `null` without `items` or\n * without `isSelectionDisabled`.\n */\n selectionDisabled: readonly boolean[] | null;\n}\n\n/** The grid's `items`, for `DataGrid.Body` (optional: a body of JSX rows needs none). */\nexport const DataGridItemsContext = React.createContext<DataGridItemsContextValue | null>(null);\n/**\n * The row id of the item a body row is rendered for, the default `rowId` of `DataGrid.Row`. The\n * grid resets it, so the rows of a grid nested in a cell do not take the outer row's id.\n */\nexport const DataGridRowIdContext = React.createContext<string | null>(null);\n/**\n * `isSelectionDisabled` of the item a body row is rendered for, the default `disabled` of the\n * row's selection cell; `undefined` without it. The grid resets it, as {@link DataGridRowIdContext}.\n */\nexport const DataGridItemSelectionDisabledContext = React.createContext<boolean | undefined>(\n undefined,\n);\n/** The row around a selection cell (see {@link DataGridRowContextValue}). */\nexport const DataGridRowContext = React.createContext<DataGridRowContextValue | null>(null);\n\nconst INERT_STORE = createSelectionStore([]);\nconst INERT_CONTEXT: DataGridContextValue = {\n selectionMode: 'none',\n store: INERT_STORE,\n toggleRow: () => {},\n toggleAll: () => {},\n radioName: '',\n selectAllLabel: DEFAULT_SELECT_ALL_LABEL,\n selectionHeaderLabel: DEFAULT_SELECTION_HEADER_LABEL,\n selectOnRowClick: false,\n selectionAppearance: 'brand',\n subtleSelection: false,\n};\nconst INERT_SORT_CONTEXT: DataGridSortContextValue = { sort: null, requestSort: () => {} };\nconst INERT_ROW_CONTEXT: DataGridRowContextValue = {\n selectionCellProps: undefined,\n hasSelectionCell: true,\n rowId: undefined,\n isSelected: false,\n disabled: false,\n invisible: false,\n ariaLabel: undefined,\n ariaLabelledBy: undefined,\n};\n\nexport function useDataGridContext(component: string): DataGridContextValue {\n const ctx = React.useContext(DataGridContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_CONTEXT;\n}\n\nexport function useDataGridRowContext(component: string): DataGridRowContextValue {\n const ctx = React.useContext(DataGridRowContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid.Row');\n return INERT_ROW_CONTEXT;\n}\n\nexport function useDataGridSortContext(component: string): DataGridSortContextValue {\n const ctx = React.useContext(DataGridSortContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_SORT_CONTEXT;\n}\n"],"mappings":";;;;;AAUA,IAAaC,IAA2B,mBAC3BC,IAAiC;AAsB9C,SAAgBC,IAA+C;CAC7D,IAAMC,oBAAQ,IAAI,IAAkC,GAC9CC,oBAAY,IAAI,IAAgB,GAClCC,IAAuB,MAErBC,UAAe;EACnB,IAAIC,IAAsB,MACtBC,IAA2B;EAC/B,KAAK,IAAM,CAACC,GAAMC,MAAYP,GAAO;GACnC,IAAMQ,IAAOD,EAAQ;GACrB,IAAI,CAACC,GAAM;IAGT,IAAIN,MAAU,QAAQF,EAAM,IAAIE,CAAK,GAAG;IACxC;GACF;GACA,CAAI,CAACG,KAAYG,EAAK,wBAAwBH,CAAQ,IAAI,KAAK,iCAC7D,IAAOC,GACP,IAAWE;EAEf;EAEA,IADIJ,MAAS,SAAM,IAAOJ,EAAM,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,OACnDI,MAASF,GACb;OAAQE;GACR,KAAK,IAAMK,KAAY,MAAM,KAAKR,CAAS,GAAG,EAAS;EAD/C;CAEV;CAEA,OAAO;EACL,UAAU,GAAU;GAElB,OADAA,EAAU,IAAIQ,CAAQ,SACT;IACX,EAAU,OAAOA,CAAQ;GA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}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../lib/styles.cjs"),l=require("./Table.shared.cjs"),u=require("../../lib/columnSizing.cjs"),d=require("./DataGrid.sizing.cjs"),f=require("./DataGrid.window.cjs"),p=require("./DataGrid.context.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g=`px-4 py-3 border-b border-border`;function _(e){return l.getTablePartKind(e)===`dataGridSelectionCell`}function v({selectionMode:e,stableClassName:n,cellProps:r,ref:i}){let{store:o,toggleAll:s,selectAllLabel:u,selectionHeaderLabel:d,subtleSelection:f}=p.useDataGridContext(`DataGrid.Header`),g=m.useSyncExternalStore(o.subscribeSelectAll,o.getSelectAllState,o.getSelectAllState),{className:_,disabled:v,invisible:y,controlRef:b,"aria-label":x,"aria-labelledby":S,"aria-describedby":C,...w}=r??{},T=!1;return g===`all`?T=!0:g===`some`&&(T=`mixed`),(0,h.jsx)(`th`,{scope:`col`,...w,ref:i,"data-selection-cell":``,className:t.cn(n,a.dataGridHeaderClassNames.selectionCell,l.SELECTION_CELL_CLASSES,`text-start`,c.focusRingInset,_),children:e===`multiple`?(0,h.jsx)(l.TableSelectionControl,{ref:b,type:`checkbox`,"aria-label":x??(S===void 0?u:void 0),"aria-labelledby":S,"aria-describedby":C,checked:T,disabled:v,invisible:y,subtle:f,reveal:`grid`,onChange:e=>s(e.nativeEvent),className:a.dataGridHeaderClassNames.selectAllCheckbox}):(0,h.jsx)(`span`,{className:`sr-only`,children:d})})}var y={subscribe:()=>()=>{},register:()=>()=>{},getFirst:()=>null,refresh:()=>{}};function b({selectionMode:e,initialFirst:n,stableClassName:r,cellProps:i,ref:o}){let u=m.useContext(p.DataGridHeaderSlotsContext)??y,[d]=m.useState(()=>({})),f=m.useRef(null),g=s.useMergedRefs(f,o),_=m.useCallback(()=>{let e=u.getFirst();return e===null?n:e===d},[u,d,n]),b=m.useCallback(()=>n,[n]),x=m.useSyncExternalStore(u.subscribe,_,b);if(m.useLayoutEffect(()=>u.register(d,()=>f.current),[u,d]),x)return(0,h.jsx)(v,{ref:g,selectionMode:e,stableClassName:r,cellProps:i});let{className:S,disabled:C,invisible:w,controlRef:T,"aria-label":E,"aria-labelledby":D,"aria-describedby":O,...k}=i??{};return(0,h.jsx)(`td`,{...k,ref:g,"data-selection-cell":``,className:t.cn(r,a.dataGridHeaderClassNames.selectionCell,l.SELECTION_CELL_CLASSES,c.focusRingInset,S)})}function x(e,t,r){let i=0,a=e=>m.Children.map(e,e=>{if(n.isElementOfType(e,m.Fragment))return m.cloneElement(e,void 0,a(e.props.children));if(!m.isValidElement(e))return e;let o=i===0;if(i+=1,n.isElementOfType(e,`tr`)){let a=e.props.children,s=t===`none`||n.flattenChildren(a).some(({node:e})=>_(e))?null:(0,h.jsx)(b,{selectionMode:t,initialFirst:o});return m.cloneElement(e,r?{"aria-rowindex":i}:void 0,s,(0,h.jsx)(p.DataGridHeaderRowHintContext.Provider,{value:o,children:a}))}let s=r?{index:void 0,ariaRowIndex:i,height:void 0}:null;return(0,h.jsx)(p.DataGridHeaderRowHintContext.Provider,{value:o,children:(0,h.jsx)(f.DataGridWindowRowContext.Provider,{value:s,children:e})})});return a(e)}var S=({children:e,className:n,ref:i,...o})=>{let{selectionMode:c}=p.useDataGridContext(`DataGrid.Header`),l=m.useContext(f.DataGridWindowContext)!==null,[u,d]=m.useState(null),g=s.useMergedRefs(i,d),[_]=m.useState(p.createHeaderSlotRegistry),v=x(e,c,l);return m.useLayoutEffect(()=>{_.refresh()}),m.useEffect(()=>{if(!r.isDev||!u||c===`none`)return;let e=Array.from(u.rows,e=>Array.from(e.cells).filter(e=>e.hasAttribute(`data-selection-cell`)));e.some((e,t)=>e.length===0&&u.rows[t].cells.length>0)&&r.warnOnce(`DataGrid.Header:missing-selection-cell`,"DataGrid.Header: a header row has no selection column header cell, so the header has one column fewer than the selectable rows. Render header rows as `<tr>` children of DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that another component renders."),e.some(e=>e.length>1)&&r.warnOnce(`DataGrid.Header:several-selection-cells`,`DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell rendered by another component is not seen, so the row also gets the automatic cell: render DataGrid.SelectionCell as a child of the row (a Fragment is fine).`)}),(0,h.jsx)(p.DataGridSectionContext.Provider,{value:`header`,children:(0,h.jsx)(p.DataGridHeaderSlotsContext.Provider,{value:_,children:(0,h.jsx)(`thead`,{ref:g,className:t.cn(a.dataGridHeaderClassNames.root,`bg-card`,`in-data-[resizing]:pointer-events-none`,l&&`sticky top-0 z-1`,n),...o,children:v})})})};S.displayName=`DataGridHeader`;var C=({columnId:e,sortable:n=!1,sortIcon:s,children:f,className:_,onClick:v,"aria-label":y,"aria-labelledby":b,ref:x,...S})=>{let{sort:C,requestSort:w}=p.useDataGridSortContext(`DataGrid.HeaderCell`),T=m.useContext(d.DataGridResizeContext),E=m.useContext(d.DataGridFixedLayoutContext),D=o.useId(`wave-datagrid-header-label`),O=n&&e?e:void 0,k=O!==void 0&&C?.columnId===O?C.direction:null,A=T!==null&&e!==void 0&&u.getColumnEntry(T.widths,e)!==void 0?e:void 0,j=A!==void 0&&y===void 0&&b===void 0?D:void 0,M=e=>{let t=e.currentTarget.firstElementChild;O!==void 0&&t?.localName===`button`&&t.contains(e.target)&&w(O,e.nativeEvent)};return m.useEffect(()=>{n&&!e&&r.warnOnce(`DataGrid.HeaderCell:sortable-without-columnId`,"DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.")},[n,e]),(0,h.jsxs)(`th`,{ref:x,scope:`col`,"aria-sort":O===void 0?void 0:k??`none`,"aria-label":y,"aria-labelledby":b??j,className:t.cn(a.dataGridHeaderCellClassNames.root,g,`text-start align-middle font-semibold text-caption-1 uppercase tracking-wider`,c.focusRingInset,O!==void 0&&`p-0 hover:bg-subtle-hover`,E&&`overflow-hidden`,A!==void 0&&`relative`,_),...S,onClick:O===void 0?v:i.composeEventHandlers(v,M),children:[O===void 0?(0,h.jsx)(`span`,{id:j,className:`inline-flex items-center gap-1`,children:f}):(0,h.jsx)(l.TableSortButton,{id:j,component:`DataGrid.HeaderCell`,direction:k,sortIcon:s,className:a.dataGridHeaderCellClassNames.button,iconClassName:a.dataGridHeaderCellClassNames.sortIcon,children:f}),A!==void 0&&T!==null&&(0,h.jsx)(d.DataGridColumnResizeHandle,{columnId:A,context:T})]})};C.displayName=`DataGridHeaderCell`,exports.DataGridHeader=S,exports.DataGridHeaderCell=C,exports.DataGridSelectionHeaderSlot=b,exports.cellBase=g,exports.isSelectionCellElement=_;
2
+ //# sourceMappingURL=DataGrid.header.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.header.cjs","names":["getTablePartKind","useDataGridContext","React","cn","dataGridHeaderClassNames","SELECTION_CELL_CLASSES","focusRingInset","TableSelectionControl","DataGridHeaderSlotsContext","useMergedRefs","isElementOfType","flattenChildren","DataGridHeaderRowHintContext","DataGridWindowRowContext","DataGridWindowContext","createHeaderSlotRegistry","isDev","DataGridSectionContext","useDataGridSortContext","DataGridResizeContext","DataGridFixedLayoutContext","useId","getColumnEntry","dataGridHeaderCellClassNames","composeEventHandlers","TableSortButton","DataGridColumnResizeHandle","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_classNames","require_useId","require_useMergedRefs","require_styles","require_Table_shared","require_columnSizing","require_DataGrid_sizing","require_DataGrid_window","require_DataGrid_context","react","react_jsx_runtime","cellBase","isSelectionCellElement","node","DataGridSelectionHeaderCell","state","store","ariaLabel","ariaLabelledBy","ariaDescribedBy","rest","cellProps","checked","stableClassName","className","selectionMode","controlRef","selectAllLabel","subtleSelection","toggleAll","event","selectionHeaderLabel","INERT_HEADER_SLOTS","DataGridSelectionHeaderSlot","slots","slot","cellRef","mergedRef","ref","getIsFirst","first","initialFirst","getServerIsFirst","isFirst","_disabled","_invisible","_controlRef","_ariaLabel","_ariaLabelledBy","_ariaDescribedBy","withSelectionHeaderSlots","position","visit","nodes","child","cells","windowed","windowRow","children","DataGridHeader","thead","setThead","content","selectionCells","row","cell","index","DataGridHeaderCell","resize","fixedLayout","labelId","sortColumnId","sortable","columnId","sortedDirection","sort","resizeColumnId","contentId","sortOnButtonClick","button","requestSort","onClick"],"sources":["../../../src/components/table/DataGrid.header.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { dataGridHeaderCellClassNames, dataGridHeaderClassNames } from '../../lib/classNames';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { getColumnEntry } from '../../lib/columnSizing';\nimport { focusRingInset } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport {\n DataGridHeaderRowHintContext,\n DataGridHeaderSlotsContext,\n DataGridSectionContext,\n createHeaderSlotRegistry,\n useDataGridContext,\n useDataGridSortContext,\n type HeaderSlotRegistry,\n} from './DataGrid.context';\nimport {\n DataGridColumnResizeHandle,\n DataGridFixedLayoutContext,\n DataGridResizeContext,\n} from './DataGrid.sizing';\nimport {\n DataGridWindowContext,\n DataGridWindowRowContext,\n type DataGridWindowRow,\n} from './DataGrid.window';\nimport {\n SELECTION_CELL_CLASSES,\n TableSelectionControl,\n TableSortButton,\n getTablePartKind,\n} from './Table.shared';\nimport type {\n DataGridHeaderCellProps,\n DataGridHeaderProps,\n DataGridSelectionCellProps,\n} from './DataGrid';\n\nexport const cellBase = 'px-4 py-3 border-b border-border';\n\n/** Whether `node` is an element of `DataGrid.SelectionCell` (lazy client references too). */\nexport function isSelectionCellElement(\n node: React.ReactNode,\n): node is React.ReactElement<DataGridSelectionCellProps> {\n return getTablePartKind(node) === 'dataGridSelectionCell';\n}\n\n// ---------------------------------------------------------------------------\n// Selection header cell (internal)\n// ---------------------------------------------------------------------------\n\n/**\n * The props of a header row's selection cell: the row's `selectionCellProps`, merged with a\n * `DataGrid.SelectionCell`'s own (whose `ref` is passed as `cellRef`).\n */\ntype HeaderSelectionCellProps = Omit<DataGridSelectionCellProps, 'ref'>;\n\ninterface DataGridSelectionHeaderCellProps {\n selectionMode: SelectionMode;\n /** The root class of `DataGrid.SelectionCell`, when the cell is one. */\n stableClassName?: string;\n cellProps?: HeaderSelectionCellProps;\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\nfunction DataGridSelectionHeaderCell({\n selectionMode,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps) {\n const { store, toggleAll, selectAllLabel, selectionHeaderLabel, subtleSelection } =\n useDataGridContext('DataGrid.Header');\n const state = React.useSyncExternalStore(\n store.subscribeSelectAll,\n store.getSelectAllState,\n store.getSelectAllState,\n );\n const {\n className,\n disabled,\n invisible,\n controlRef,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n\n let checked: boolean | 'mixed' = false;\n if (state === 'all') checked = true;\n else if (state === 'some') checked = 'mixed';\n\n return (\n <th\n scope=\"col\"\n {...rest}\n ref={ref}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n 'text-start',\n focusRingInset,\n className,\n )}\n >\n {selectionMode === 'multiple' ? (\n <TableSelectionControl\n ref={controlRef}\n type=\"checkbox\"\n aria-label={ariaLabel ?? (ariaLabelledBy === undefined ? selectAllLabel : undefined)}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n checked={checked}\n disabled={disabled}\n invisible={invisible}\n subtle={subtleSelection}\n reveal=\"grid\"\n onChange={(event) => toggleAll(event.nativeEvent)}\n className={dataGridHeaderClassNames.selectAllCheckbox}\n />\n ) : (\n <span className=\"sr-only\">{selectionHeaderLabel}</span>\n )}\n </th>\n );\n}\n\nconst INERT_HEADER_SLOTS: HeaderSlotRegistry = {\n subscribe: () => () => {},\n register: () => () => {},\n getFirst: () => null,\n refresh: () => {},\n};\n\n/**\n * The selection column's cell of one header row: the select-all header cell in the header's first\n * row (document order), an empty cell in every later row. `initialFirst` is the header's guess from\n * its children, used until the slots are registered (the initial and the server render).\n */\nexport function DataGridSelectionHeaderSlot({\n selectionMode,\n initialFirst,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps & { initialFirst: boolean }) {\n const slots = React.useContext(DataGridHeaderSlotsContext) ?? INERT_HEADER_SLOTS;\n const [slot] = React.useState(() => ({}));\n const cellRef = React.useRef<HTMLTableCellElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableCellElement>(cellRef, ref);\n\n const getIsFirst = React.useCallback(() => {\n const first = slots.getFirst();\n return first === null ? initialFirst : first === slot;\n }, [slots, slot, initialFirst]);\n const getServerIsFirst = React.useCallback(() => initialFirst, [initialFirst]);\n const isFirst = React.useSyncExternalStore(slots.subscribe, getIsFirst, getServerIsFirst);\n\n React.useLayoutEffect(() => slots.register(slot, () => cellRef.current), [slots, slot]);\n\n if (isFirst) {\n return (\n <DataGridSelectionHeaderCell\n ref={mergedRef}\n selectionMode={selectionMode}\n stableClassName={stableClassName}\n cellProps={cellProps}\n />\n );\n }\n // A later header row's cell: none of the control's props apply.\n const {\n className,\n disabled: _disabled,\n invisible: _invisible,\n controlRef: _controlRef,\n 'aria-label': _ariaLabel,\n 'aria-labelledby': _ariaLabelledBy,\n 'aria-describedby': _ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n return (\n <td\n {...rest}\n ref={mergedRef}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n focusRingInset,\n className,\n )}\n />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sub-components\n// ---------------------------------------------------------------------------\n\n/**\n * Prepends the selection column's header slot (or `null`) to every `<tr>` in `children`, looking\n * inside Fragments, unless the row holds a `DataGrid.SelectionCell` (that cell is the slot), and\n * tells every row whether it is the header's first row: the cells of a `<tr>` and every other\n * element child (a `DataGrid.Row`, or a component that renders one). Every row gets the same child\n * shape in every selection mode, so switching `selectionMode` does not remount the header cells.\n * In a windowed grid each row also gets its `aria-rowindex` (1-based, in order).\n */\nfunction withSelectionHeaderSlots(\n children: React.ReactNode,\n selectionMode: 'none' | SelectionMode,\n windowed: boolean,\n): React.ReactNode {\n let position = 0;\n const visit = (nodes: React.ReactNode): React.ReactNode =>\n React.Children.map(nodes, (child) => {\n if (isElementOfType<{ children?: React.ReactNode }>(child, React.Fragment)) {\n return React.cloneElement(child, undefined, visit(child.props.children));\n }\n if (!React.isValidElement(child)) return child;\n const isFirst = position === 0;\n position += 1;\n if (isElementOfType<React.HTMLAttributes<HTMLTableRowElement>>(child, 'tr')) {\n const cells = child.props.children;\n const slot =\n selectionMode === 'none' ||\n flattenChildren(cells).some(({ node }) => isSelectionCellElement(node)) ? null : (\n <DataGridSelectionHeaderSlot selectionMode={selectionMode} initialFirst={isFirst} />\n );\n return React.cloneElement(\n child,\n windowed ? { 'aria-rowindex': position } : undefined,\n slot,\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {cells}\n </DataGridHeaderRowHintContext.Provider>,\n );\n }\n // A `DataGrid.Row` takes its `aria-rowindex` from the row context.\n const windowRow: DataGridWindowRow | null = windowed\n ? { index: undefined, ariaRowIndex: position, height: undefined }\n : null;\n return (\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n <DataGridWindowRowContext.Provider value={windowRow}>\n {child}\n </DataGridWindowRowContext.Provider>\n </DataGridHeaderRowHintContext.Provider>\n );\n });\n return visit(children);\n}\n\n/**\n * The grid's `<thead>`. When the grid is selectable, it prepends the selection column's header\n * cell to each `<tr>` child, also inside a Fragment, unless the row holds a\n * `DataGrid.SelectionCell`: the first header row gets the \"Select all rows\" checkbox (multiple\n * mode) or the \"Selection\" header (single mode; DataGrid's `labels` localizes both), later rows of\n * a grouped header an empty cell. A header row rendered by another component cannot get it (a\n * development warning says so): use `DataGrid.Row` for such a row, which adds the cell itself.\n * In a grid with a `virtualWindow` the header stays at the top of the grid's scroll wrapper while\n * the rows scroll under it, and each header row carries its `aria-rowindex`.\n */\nexport const DataGridHeader = ({ children, className, ref, ...rest }: DataGridHeaderProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.Header');\n const windowed = React.useContext(DataGridWindowContext) !== null;\n const [thead, setThead] = React.useState<HTMLTableSectionElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableSectionElement>(ref, setThead);\n const [slots] = React.useState(createHeaderSlotRegistry);\n const content = withSelectionHeaderSlots(children, selectionMode, windowed);\n\n // Every commit, after the rows' slots registered: header rows can move without a slot mounting.\n React.useLayoutEffect(() => {\n slots.refresh();\n });\n\n // Every commit: header rows can come from components the header cannot see into.\n React.useEffect(() => {\n if (!isDev || !thead || selectionMode === 'none') return;\n const selectionCells = Array.from(thead.rows, (row) =>\n Array.from(row.cells).filter((cell) => cell.hasAttribute('data-selection-cell')),\n );\n if (\n selectionCells.some(\n (cells, index) => cells.length === 0 && thead.rows[index].cells.length > 0,\n )\n ) {\n warnOnce(\n 'DataGrid.Header:missing-selection-cell',\n 'DataGrid.Header: a header row has no selection column header cell, so the header has one ' +\n 'column fewer than the selectable rows. Render header rows as `<tr>` children of ' +\n 'DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that ' +\n 'another component renders.',\n );\n }\n if (selectionCells.some((cells) => cells.length > 1)) {\n warnOnce(\n 'DataGrid.Header:several-selection-cells',\n 'DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell ' +\n 'rendered by another component is not seen, so the row also gets the automatic cell: ' +\n 'render DataGrid.SelectionCell as a child of the row (a Fragment is fine).',\n );\n }\n });\n\n return (\n <DataGridSectionContext.Provider value=\"header\">\n <DataGridHeaderSlotsContext.Provider value={slots}>\n <thead\n ref={mergedRef}\n className={cn(\n dataGridHeaderClassNames.root,\n 'bg-card',\n // While a column resize handle drags, the header cells ignore the pointer.\n 'in-data-[resizing]:pointer-events-none',\n // A windowed grid scrolls in its wrapper: the header stays at its top, over the rows\n // (on the section: a header cell is positioned for its resize handle).\n windowed && 'sticky top-0 z-1',\n className,\n )}\n {...rest}\n >\n {content}\n </thead>\n </DataGridHeaderSlotsContext.Provider>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridHeader.displayName = 'DataGridHeader';\n\n/**\n * A column header cell. A `sortable` header (with a `columnId`) renders its content inside a\n * `<button type=\"button\">` that toggles the sort, followed by the direction glyph (`sortIcon`)\n * while its column is sorted; the `<th>` carries `aria-sort`. A consumer `onClick` (on the `<th>`)\n * runs before the sort, and calling `preventDefault()` in it cancels the sort (also for\n * Enter/Space on the button, which click it). In a grid with `resizableColumns`, the header cell\n * of a column of `columns` (by `columnId`) also holds the column's resize handle, after its\n * content, along its end edge (the cell is positioned for it); the cell is then named by its\n * content alone (`aria-labelledby`, unless it has a name of its own), not by the handle's label.\n * The handle is no target of the grid's navigation: a sortable cell's target stays its sort\n * button, and F2 on the cell or the button moves focus to the handle.\n */\nexport const DataGridHeaderCell = ({\n columnId,\n sortable = false,\n sortIcon,\n children,\n className,\n onClick,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ref,\n ...rest\n}: DataGridHeaderCellProps) => {\n const { sort, requestSort } = useDataGridSortContext('DataGrid.HeaderCell');\n const resize = React.useContext(DataGridResizeContext);\n const fixedLayout = React.useContext(DataGridFixedLayoutContext);\n const labelId = useId('wave-datagrid-header-label');\n /** The column this header sorts, or `undefined` when it is not sortable. */\n const sortColumnId = sortable && columnId ? columnId : undefined;\n const sortedDirection =\n sortColumnId !== undefined && sort?.columnId === sortColumnId ? sort.direction : null;\n /** The column whose resize handle this cell holds. */\n const resizeColumnId =\n resize !== null &&\n columnId !== undefined &&\n getColumnEntry(resize.widths, columnId) !== undefined\n ? columnId\n : undefined;\n // The handle is content of the cell: without this, its label would join the cell's name. A\n // name prop given as `undefined` (forwarded by a wrapper) counts as none.\n const labelledByContent =\n resizeColumnId !== undefined && ariaLabel === undefined && ariaLabelledBy === undefined;\n const contentId = labelledByContent ? labelId : undefined;\n\n // The sort runs from the `<th>` once the button's click bubbled up to it, composed after the\n // consumer's `onClick` (C-COMPOSE): the consumer runs first and can cancel with preventDefault().\n // The sort button is the `<th>`'s first child (a resize handle may follow it); clicks elsewhere\n // in the cell, the handle included, do not sort.\n const sortOnButtonClick = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const button = event.currentTarget.firstElementChild;\n if (\n sortColumnId !== undefined &&\n button?.localName === 'button' &&\n button.contains(event.target as Node)\n ) {\n requestSort(sortColumnId, event.nativeEvent);\n }\n };\n\n React.useEffect(() => {\n if (sortable && !columnId) {\n warnOnce(\n 'DataGrid.HeaderCell:sortable-without-columnId',\n 'DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.',\n );\n }\n }, [sortable, columnId]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={sortColumnId !== undefined ? (sortedDirection ?? 'none') : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy ?? contentId}\n className={cn(\n dataGridHeaderCellClassNames.root,\n cellBase,\n 'text-start align-middle font-semibold text-caption-1 uppercase tracking-wider',\n focusRingInset,\n sortColumnId !== undefined && 'p-0 hover:bg-subtle-hover',\n // Columns laid out from widths: what does not fit is clipped, not drawn over the next.\n fixedLayout && 'overflow-hidden',\n // The box the resize handle is drawn in, along the end edge.\n resizeColumnId !== undefined && 'relative',\n className,\n )}\n {...rest}\n onClick={\n sortColumnId !== undefined ? composeEventHandlers(onClick, sortOnButtonClick) : onClick\n }\n >\n {sortColumnId !== undefined ? (\n <TableSortButton\n id={contentId}\n component=\"DataGrid.HeaderCell\"\n direction={sortedDirection}\n sortIcon={sortIcon}\n className={dataGridHeaderCellClassNames.button}\n iconClassName={dataGridHeaderCellClassNames.sortIcon}\n >\n {children}\n </TableSortButton>\n ) : (\n <span id={contentId} className=\"inline-flex items-center gap-1\">\n {children}\n </span>\n )}\n {resizeColumnId !== undefined && resize !== null && (\n <DataGridColumnResizeHandle columnId={resizeColumnId} context={resize} />\n )}\n </th>\n );\n};\nDataGridHeaderCell.displayName = 'DataGridHeaderCell';\n"],"mappings":"ymBA0CA,IAAa2C,EAAW,mCAGxB,SAAgBC,EACd,EACwD,CACxD,OAAO5C,EAAAA,iBAAiB6C,CAAI,IAAM,uBACpC,CAoBA,SAASC,EAA4B,CACnC,gBACA,kBACA,YACA,OACmC,CACnC,GAAM,CAAE,QAAO,YAAW,iBAAgB,uBAAsB,mBAC9D7C,EAAAA,mBAAmB,iBAAiB,EAChC8C,EAAQ7C,EAAM,qBAClB8C,EAAM,mBACNA,EAAM,kBACNA,EAAM,iBACR,EACM,CACJ,YACA,WACA,YACA,aACA,aAAcC,EACd,kBAAmBC,EACnB,mBAAoBC,EACpB,GAAGC,GACDC,GAAa,CAAC,EAEdC,EAA6B,GAIjC,OAHIP,IAAU,MAAO,EAAU,GACtBA,IAAU,SAAQ,EAAU,UAGnC,EAAAL,EAAA,IAAA,CAAC,KAAD,CACE,MAAM,MACN,GAAIU,EACC,MACL,sBAAoB,GACpB,UAAWjD,EAAAA,GACToD,EACAnD,EAAAA,yBAAyB,cACzBC,EAAAA,uBACA,aACAC,EAAAA,eACAkD,CACF,EAEC,SAAAC,IAAkB,YACjB,EAAAf,EAAA,IAAA,CAACnC,EAAAA,sBAAD,CACE,IAAKmD,EACL,KAAK,WACL,aAAYT,IAAcC,IAAmB,IAAA,GAAYS,EAAiB,IAAA,IAC1E,kBAAiBT,EACjB,mBAAkBC,EACT,UACC,WACC,YACX,OAAQS,EACR,OAAO,OACP,SAAW,GAAUC,EAAUC,EA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ByF,EAASH,CAAiB,EApBhF,SAAA,CAuBGP,IAAiB,IAAA,IAYhB,EAAA7D,EAAA,IAAA,CAAC,OAAD,CAAM,GAAImE,EAAW,UAAU,iCAC5B,UACG,CAAA,GAbN,EAAAnE,EAAA,IAAA,CAACjB,EAAAA,gBAAD,CACE,GAAIoF,EACJ,UAAU,sBACV,UAAWH,EACD,WACV,UAAWnF,EAAAA,6BAA6B,OACxC,cAAeA,EAAAA,6BAA6B,SAE3C,UACc,CAAA,EAMlBqF,IAAmB,IAAA,IAAaR,IAAW,OAC1C,EAAA1D,EAAA,IAAA,CAAChB,EAAAA,2BAAD,CAA4B,SAAUkF,EAAgB,QAASR,CAAS,CAAA,CAExE,GAER,EACA,EAAmB,YAAc"}
@@ -0,0 +1,168 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
4
+ import { isDev as r, warnOnce as i } from "../../lib/dev.mjs";
5
+ import { composeEventHandlers as a } from "../../lib/composeEventHandlers.mjs";
6
+ import { dataGridHeaderCellClassNames as o, dataGridHeaderClassNames as s } from "../../lib/classNames.mjs";
7
+ import { useId as c } from "../../hooks/useId.mjs";
8
+ import { useMergedRefs as l } from "../../hooks/useMergedRefs.mjs";
9
+ import { focusRingInset as u } from "../../lib/styles.mjs";
10
+ import { SELECTION_CELL_CLASSES as d, TableSelectionControl as f, TableSortButton as p, getTablePartKind as m } from "./Table.shared.mjs";
11
+ import { getColumnEntry as h } from "../../lib/columnSizing.mjs";
12
+ import { DataGridColumnResizeHandle as g, DataGridFixedLayoutContext as _, DataGridResizeContext as v } from "./DataGrid.sizing.mjs";
13
+ import { DataGridWindowContext as y, DataGridWindowRowContext as b } from "./DataGrid.window.mjs";
14
+ import { DataGridHeaderRowHintContext as x, DataGridHeaderSlotsContext as S, DataGridSectionContext as C, createHeaderSlotRegistry as w, useDataGridContext as T, useDataGridSortContext as E } from "./DataGrid.context.mjs";
15
+ import * as D from "react";
16
+ import { jsx as O, jsxs as k } from "react/jsx-runtime";
17
+ //#region src/components/table/DataGrid.header.tsx
18
+ var A = "px-4 py-3 border-b border-border";
19
+ function j(e) {
20
+ return m(e) === "dataGridSelectionCell";
21
+ }
22
+ function M({ selectionMode: t, stableClassName: n, cellProps: r, ref: i }) {
23
+ let { store: a, toggleAll: o, selectAllLabel: c, selectionHeaderLabel: l, subtleSelection: p } = T("DataGrid.Header"), m = D.useSyncExternalStore(a.subscribeSelectAll, a.getSelectAllState, a.getSelectAllState), { className: h, disabled: g, invisible: _, controlRef: v, "aria-label": y, "aria-labelledby": b, "aria-describedby": x, ...S } = r ?? {}, C = !1;
24
+ return m === "all" ? C = !0 : m === "some" && (C = "mixed"), /* @__PURE__ */ O("th", {
25
+ scope: "col",
26
+ ...S,
27
+ ref: i,
28
+ "data-selection-cell": "",
29
+ className: e(n, s.selectionCell, d, "text-start", u, h),
30
+ children: t === "multiple" ? /* @__PURE__ */ O(f, {
31
+ ref: v,
32
+ type: "checkbox",
33
+ "aria-label": y ?? (b === void 0 ? c : void 0),
34
+ "aria-labelledby": b,
35
+ "aria-describedby": x,
36
+ checked: C,
37
+ disabled: g,
38
+ invisible: _,
39
+ subtle: p,
40
+ reveal: "grid",
41
+ onChange: (e) => o(e.nativeEvent),
42
+ className: s.selectAllCheckbox
43
+ }) : /* @__PURE__ */ O("span", {
44
+ className: "sr-only",
45
+ children: l
46
+ })
47
+ });
48
+ }
49
+ var N = {
50
+ subscribe: () => () => {},
51
+ register: () => () => {},
52
+ getFirst: () => null,
53
+ refresh: () => {}
54
+ };
55
+ function P({ selectionMode: t, initialFirst: n, stableClassName: r, cellProps: i, ref: a }) {
56
+ let o = D.useContext(S) ?? N, [c] = D.useState(() => ({})), f = D.useRef(null), p = l(f, a), m = D.useCallback(() => {
57
+ let e = o.getFirst();
58
+ return e === null ? n : e === c;
59
+ }, [
60
+ o,
61
+ c,
62
+ n
63
+ ]), h = D.useCallback(() => n, [n]), g = D.useSyncExternalStore(o.subscribe, m, h);
64
+ if (D.useLayoutEffect(() => o.register(c, () => f.current), [o, c]), g) return /* @__PURE__ */ O(M, {
65
+ ref: p,
66
+ selectionMode: t,
67
+ stableClassName: r,
68
+ cellProps: i
69
+ });
70
+ let { className: _, disabled: v, invisible: y, controlRef: b, "aria-label": x, "aria-labelledby": C, "aria-describedby": w, ...T } = i ?? {};
71
+ return /* @__PURE__ */ O("td", {
72
+ ...T,
73
+ ref: p,
74
+ "data-selection-cell": "",
75
+ className: e(r, s.selectionCell, d, u, _)
76
+ });
77
+ }
78
+ function F(e, r, i) {
79
+ let a = 0, o = (e) => D.Children.map(e, (e) => {
80
+ if (n(e, D.Fragment)) return D.cloneElement(e, void 0, o(e.props.children));
81
+ if (!D.isValidElement(e)) return e;
82
+ let s = a === 0;
83
+ if (a += 1, n(e, "tr")) {
84
+ let n = e.props.children, o = r === "none" || t(n).some(({ node: e }) => j(e)) ? null : /* @__PURE__ */ O(P, {
85
+ selectionMode: r,
86
+ initialFirst: s
87
+ });
88
+ return D.cloneElement(e, i ? { "aria-rowindex": a } : void 0, o, /* @__PURE__ */ O(x.Provider, {
89
+ value: s,
90
+ children: n
91
+ }));
92
+ }
93
+ let c = i ? {
94
+ index: void 0,
95
+ ariaRowIndex: a,
96
+ height: void 0
97
+ } : null;
98
+ return /* @__PURE__ */ O(x.Provider, {
99
+ value: s,
100
+ children: /* @__PURE__ */ O(b.Provider, {
101
+ value: c,
102
+ children: e
103
+ })
104
+ });
105
+ });
106
+ return o(e);
107
+ }
108
+ var I = ({ children: t, className: n, ref: a, ...o }) => {
109
+ let { selectionMode: c } = T("DataGrid.Header"), u = D.useContext(y) !== null, [d, f] = D.useState(null), p = l(a, f), [m] = D.useState(w), h = F(t, c, u);
110
+ return D.useLayoutEffect(() => {
111
+ m.refresh();
112
+ }), D.useEffect(() => {
113
+ if (!r || !d || c === "none") return;
114
+ let e = Array.from(d.rows, (e) => Array.from(e.cells).filter((e) => e.hasAttribute("data-selection-cell")));
115
+ e.some((e, t) => e.length === 0 && d.rows[t].cells.length > 0) && i("DataGrid.Header:missing-selection-cell", "DataGrid.Header: a header row has no selection column header cell, so the header has one column fewer than the selectable rows. Render header rows as `<tr>` children of DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that another component renders."), e.some((e) => e.length > 1) && i("DataGrid.Header:several-selection-cells", "DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell rendered by another component is not seen, so the row also gets the automatic cell: render DataGrid.SelectionCell as a child of the row (a Fragment is fine).");
116
+ }), /* @__PURE__ */ O(C.Provider, {
117
+ value: "header",
118
+ children: /* @__PURE__ */ O(S.Provider, {
119
+ value: m,
120
+ children: /* @__PURE__ */ O("thead", {
121
+ ref: p,
122
+ className: e(s.root, "bg-card", "in-data-[resizing]:pointer-events-none", u && "sticky top-0 z-1", n),
123
+ ...o,
124
+ children: h
125
+ })
126
+ })
127
+ });
128
+ };
129
+ I.displayName = "DataGridHeader";
130
+ var L = ({ columnId: t, sortable: n = !1, sortIcon: r, children: s, className: l, onClick: d, "aria-label": f, "aria-labelledby": m, ref: y, ...b }) => {
131
+ let { sort: x, requestSort: S } = E("DataGrid.HeaderCell"), C = D.useContext(v), w = D.useContext(_), T = c("wave-datagrid-header-label"), j = n && t ? t : void 0, M = j !== void 0 && x?.columnId === j ? x.direction : null, N = C !== null && t !== void 0 && h(C.widths, t) !== void 0 ? t : void 0, P = N !== void 0 && f === void 0 && m === void 0 ? T : void 0, F = (e) => {
132
+ let t = e.currentTarget.firstElementChild;
133
+ j !== void 0 && t?.localName === "button" && t.contains(e.target) && S(j, e.nativeEvent);
134
+ };
135
+ return D.useEffect(() => {
136
+ n && !t && i("DataGrid.HeaderCell:sortable-without-columnId", "DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.");
137
+ }, [n, t]), /* @__PURE__ */ k("th", {
138
+ ref: y,
139
+ scope: "col",
140
+ "aria-sort": j === void 0 ? void 0 : M ?? "none",
141
+ "aria-label": f,
142
+ "aria-labelledby": m ?? P,
143
+ className: e(o.root, A, "text-start align-middle font-semibold text-caption-1 uppercase tracking-wider", u, j !== void 0 && "p-0 hover:bg-subtle-hover", w && "overflow-hidden", N !== void 0 && "relative", l),
144
+ ...b,
145
+ onClick: j === void 0 ? d : a(d, F),
146
+ children: [j === void 0 ? /* @__PURE__ */ O("span", {
147
+ id: P,
148
+ className: "inline-flex items-center gap-1",
149
+ children: s
150
+ }) : /* @__PURE__ */ O(p, {
151
+ id: P,
152
+ component: "DataGrid.HeaderCell",
153
+ direction: M,
154
+ sortIcon: r,
155
+ className: o.button,
156
+ iconClassName: o.sortIcon,
157
+ children: s
158
+ }), N !== void 0 && C !== null && /* @__PURE__ */ O(g, {
159
+ columnId: N,
160
+ context: C
161
+ })]
162
+ });
163
+ };
164
+ L.displayName = "DataGridHeaderCell";
165
+ //#endregion
166
+ export { I as DataGridHeader, L as DataGridHeaderCell, P as DataGridSelectionHeaderSlot, A as cellBase, j as isSelectionCellElement };
167
+
168
+ //# sourceMappingURL=DataGrid.header.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.header.mjs","names":["useId","useId$1","React","cellBase","isSelectionCellElement","getTablePartKind","node","DataGridSelectionHeaderCell","useDataGridContext","state","store","ariaLabel","ariaLabelledBy","ariaDescribedBy","rest","cellProps","checked","cn","stableClassName","dataGridHeaderClassNames","SELECTION_CELL_CLASSES","focusRingInset","className","selectionMode","TableSelectionControl","controlRef","selectAllLabel","subtleSelection","toggleAll","event","selectionHeaderLabel","INERT_HEADER_SLOTS","DataGridSelectionHeaderSlot","slots","DataGridHeaderSlotsContext","slot","cellRef","mergedRef","useMergedRefs","ref","getIsFirst","first","initialFirst","getServerIsFirst","isFirst","_disabled","_invisible","_controlRef","_ariaLabel","_ariaLabelledBy","_ariaDescribedBy","withSelectionHeaderSlots","position","visit","nodes","isElementOfType","child","cells","flattenChildren","windowed","DataGridHeaderRowHintContext","windowRow","DataGridWindowRowContext","children","DataGridHeader","DataGridWindowContext","thead","setThead","createHeaderSlotRegistry","content","isDev","selectionCells","row","cell","index","warnOnce","DataGridSectionContext","DataGridHeaderCell","useDataGridSortContext","resize","DataGridResizeContext","fixedLayout","DataGridFixedLayoutContext","labelId","sortColumnId","sortable","columnId","sortedDirection","sort","resizeColumnId","getColumnEntry","contentId","sortOnButtonClick","button","requestSort","dataGridHeaderCellClassNames","onClick","composeEventHandlers","TableSortButton","DataGridColumnResizeHandle"],"sources":["../../../src/components/table/DataGrid.header.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { dataGridHeaderCellClassNames, dataGridHeaderClassNames } from '../../lib/classNames';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { getColumnEntry } from '../../lib/columnSizing';\nimport { focusRingInset } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport {\n DataGridHeaderRowHintContext,\n DataGridHeaderSlotsContext,\n DataGridSectionContext,\n createHeaderSlotRegistry,\n useDataGridContext,\n useDataGridSortContext,\n type HeaderSlotRegistry,\n} from './DataGrid.context';\nimport {\n DataGridColumnResizeHandle,\n DataGridFixedLayoutContext,\n DataGridResizeContext,\n} from './DataGrid.sizing';\nimport {\n DataGridWindowContext,\n DataGridWindowRowContext,\n type DataGridWindowRow,\n} from './DataGrid.window';\nimport {\n SELECTION_CELL_CLASSES,\n TableSelectionControl,\n TableSortButton,\n getTablePartKind,\n} from './Table.shared';\nimport type {\n DataGridHeaderCellProps,\n DataGridHeaderProps,\n DataGridSelectionCellProps,\n} from './DataGrid';\n\nexport const cellBase = 'px-4 py-3 border-b border-border';\n\n/** Whether `node` is an element of `DataGrid.SelectionCell` (lazy client references too). */\nexport function isSelectionCellElement(\n node: React.ReactNode,\n): node is React.ReactElement<DataGridSelectionCellProps> {\n return getTablePartKind(node) === 'dataGridSelectionCell';\n}\n\n// ---------------------------------------------------------------------------\n// Selection header cell (internal)\n// ---------------------------------------------------------------------------\n\n/**\n * The props of a header row's selection cell: the row's `selectionCellProps`, merged with a\n * `DataGrid.SelectionCell`'s own (whose `ref` is passed as `cellRef`).\n */\ntype HeaderSelectionCellProps = Omit<DataGridSelectionCellProps, 'ref'>;\n\ninterface DataGridSelectionHeaderCellProps {\n selectionMode: SelectionMode;\n /** The root class of `DataGrid.SelectionCell`, when the cell is one. */\n stableClassName?: string;\n cellProps?: HeaderSelectionCellProps;\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\nfunction DataGridSelectionHeaderCell({\n selectionMode,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps) {\n const { store, toggleAll, selectAllLabel, selectionHeaderLabel, subtleSelection } =\n useDataGridContext('DataGrid.Header');\n const state = React.useSyncExternalStore(\n store.subscribeSelectAll,\n store.getSelectAllState,\n store.getSelectAllState,\n );\n const {\n className,\n disabled,\n invisible,\n controlRef,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n\n let checked: boolean | 'mixed' = false;\n if (state === 'all') checked = true;\n else if (state === 'some') checked = 'mixed';\n\n return (\n <th\n scope=\"col\"\n {...rest}\n ref={ref}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n 'text-start',\n focusRingInset,\n className,\n )}\n >\n {selectionMode === 'multiple' ? (\n <TableSelectionControl\n ref={controlRef}\n type=\"checkbox\"\n aria-label={ariaLabel ?? (ariaLabelledBy === undefined ? selectAllLabel : undefined)}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n checked={checked}\n disabled={disabled}\n invisible={invisible}\n subtle={subtleSelection}\n reveal=\"grid\"\n onChange={(event) => toggleAll(event.nativeEvent)}\n className={dataGridHeaderClassNames.selectAllCheckbox}\n />\n ) : (\n <span className=\"sr-only\">{selectionHeaderLabel}</span>\n )}\n </th>\n );\n}\n\nconst INERT_HEADER_SLOTS: HeaderSlotRegistry = {\n subscribe: () => () => {},\n register: () => () => {},\n getFirst: () => null,\n refresh: () => {},\n};\n\n/**\n * The selection column's cell of one header row: the select-all header cell in the header's first\n * row (document order), an empty cell in every later row. `initialFirst` is the header's guess from\n * its children, used until the slots are registered (the initial and the server render).\n */\nexport function DataGridSelectionHeaderSlot({\n selectionMode,\n initialFirst,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps & { initialFirst: boolean }) {\n const slots = React.useContext(DataGridHeaderSlotsContext) ?? INERT_HEADER_SLOTS;\n const [slot] = React.useState(() => ({}));\n const cellRef = React.useRef<HTMLTableCellElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableCellElement>(cellRef, ref);\n\n const getIsFirst = React.useCallback(() => {\n const first = slots.getFirst();\n return first === null ? initialFirst : first === slot;\n }, [slots, slot, initialFirst]);\n const getServerIsFirst = React.useCallback(() => initialFirst, [initialFirst]);\n const isFirst = React.useSyncExternalStore(slots.subscribe, getIsFirst, getServerIsFirst);\n\n React.useLayoutEffect(() => slots.register(slot, () => cellRef.current), [slots, slot]);\n\n if (isFirst) {\n return (\n <DataGridSelectionHeaderCell\n ref={mergedRef}\n selectionMode={selectionMode}\n stableClassName={stableClassName}\n cellProps={cellProps}\n />\n );\n }\n // A later header row's cell: none of the control's props apply.\n const {\n className,\n disabled: _disabled,\n invisible: _invisible,\n controlRef: _controlRef,\n 'aria-label': _ariaLabel,\n 'aria-labelledby': _ariaLabelledBy,\n 'aria-describedby': _ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n return (\n <td\n {...rest}\n ref={mergedRef}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n focusRingInset,\n className,\n )}\n />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sub-components\n// ---------------------------------------------------------------------------\n\n/**\n * Prepends the selection column's header slot (or `null`) to every `<tr>` in `children`, looking\n * inside Fragments, unless the row holds a `DataGrid.SelectionCell` (that cell is the slot), and\n * tells every row whether it is the header's first row: the cells of a `<tr>` and every other\n * element child (a `DataGrid.Row`, or a component that renders one). Every row gets the same child\n * shape in every selection mode, so switching `selectionMode` does not remount the header cells.\n * In a windowed grid each row also gets its `aria-rowindex` (1-based, in order).\n */\nfunction withSelectionHeaderSlots(\n children: React.ReactNode,\n selectionMode: 'none' | SelectionMode,\n windowed: boolean,\n): React.ReactNode {\n let position = 0;\n const visit = (nodes: React.ReactNode): React.ReactNode =>\n React.Children.map(nodes, (child) => {\n if (isElementOfType<{ children?: React.ReactNode }>(child, React.Fragment)) {\n return React.cloneElement(child, undefined, visit(child.props.children));\n }\n if (!React.isValidElement(child)) return child;\n const isFirst = position === 0;\n position += 1;\n if (isElementOfType<React.HTMLAttributes<HTMLTableRowElement>>(child, 'tr')) {\n const cells = child.props.children;\n const slot =\n selectionMode === 'none' ||\n flattenChildren(cells).some(({ node }) => isSelectionCellElement(node)) ? null : (\n <DataGridSelectionHeaderSlot selectionMode={selectionMode} initialFirst={isFirst} />\n );\n return React.cloneElement(\n child,\n windowed ? { 'aria-rowindex': position } : undefined,\n slot,\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {cells}\n </DataGridHeaderRowHintContext.Provider>,\n );\n }\n // A `DataGrid.Row` takes its `aria-rowindex` from the row context.\n const windowRow: DataGridWindowRow | null = windowed\n ? { index: undefined, ariaRowIndex: position, height: undefined }\n : null;\n return (\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n <DataGridWindowRowContext.Provider value={windowRow}>\n {child}\n </DataGridWindowRowContext.Provider>\n </DataGridHeaderRowHintContext.Provider>\n );\n });\n return visit(children);\n}\n\n/**\n * The grid's `<thead>`. When the grid is selectable, it prepends the selection column's header\n * cell to each `<tr>` child, also inside a Fragment, unless the row holds a\n * `DataGrid.SelectionCell`: the first header row gets the \"Select all rows\" checkbox (multiple\n * mode) or the \"Selection\" header (single mode; DataGrid's `labels` localizes both), later rows of\n * a grouped header an empty cell. A header row rendered by another component cannot get it (a\n * development warning says so): use `DataGrid.Row` for such a row, which adds the cell itself.\n * In a grid with a `virtualWindow` the header stays at the top of the grid's scroll wrapper while\n * the rows scroll under it, and each header row carries its `aria-rowindex`.\n */\nexport const DataGridHeader = ({ children, className, ref, ...rest }: DataGridHeaderProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.Header');\n const windowed = React.useContext(DataGridWindowContext) !== null;\n const [thead, setThead] = React.useState<HTMLTableSectionElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableSectionElement>(ref, setThead);\n const [slots] = React.useState(createHeaderSlotRegistry);\n const content = withSelectionHeaderSlots(children, selectionMode, windowed);\n\n // Every commit, after the rows' slots registered: header rows can move without a slot mounting.\n React.useLayoutEffect(() => {\n slots.refresh();\n });\n\n // Every commit: header rows can come from components the header cannot see into.\n React.useEffect(() => {\n if (!isDev || !thead || selectionMode === 'none') return;\n const selectionCells = Array.from(thead.rows, (row) =>\n Array.from(row.cells).filter((cell) => cell.hasAttribute('data-selection-cell')),\n );\n if (\n selectionCells.some(\n (cells, index) => cells.length === 0 && thead.rows[index].cells.length > 0,\n )\n ) {\n warnOnce(\n 'DataGrid.Header:missing-selection-cell',\n 'DataGrid.Header: a header row has no selection column header cell, so the header has one ' +\n 'column fewer than the selectable rows. Render header rows as `<tr>` children of ' +\n 'DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that ' +\n 'another component renders.',\n );\n }\n if (selectionCells.some((cells) => cells.length > 1)) {\n warnOnce(\n 'DataGrid.Header:several-selection-cells',\n 'DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell ' +\n 'rendered by another component is not seen, so the row also gets the automatic cell: ' +\n 'render DataGrid.SelectionCell as a child of the row (a Fragment is fine).',\n );\n }\n });\n\n return (\n <DataGridSectionContext.Provider value=\"header\">\n <DataGridHeaderSlotsContext.Provider value={slots}>\n <thead\n ref={mergedRef}\n className={cn(\n dataGridHeaderClassNames.root,\n 'bg-card',\n // While a column resize handle drags, the header cells ignore the pointer.\n 'in-data-[resizing]:pointer-events-none',\n // A windowed grid scrolls in its wrapper: the header stays at its top, over the rows\n // (on the section: a header cell is positioned for its resize handle).\n windowed && 'sticky top-0 z-1',\n className,\n )}\n {...rest}\n >\n {content}\n </thead>\n </DataGridHeaderSlotsContext.Provider>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridHeader.displayName = 'DataGridHeader';\n\n/**\n * A column header cell. A `sortable` header (with a `columnId`) renders its content inside a\n * `<button type=\"button\">` that toggles the sort, followed by the direction glyph (`sortIcon`)\n * while its column is sorted; the `<th>` carries `aria-sort`. A consumer `onClick` (on the `<th>`)\n * runs before the sort, and calling `preventDefault()` in it cancels the sort (also for\n * Enter/Space on the button, which click it). In a grid with `resizableColumns`, the header cell\n * of a column of `columns` (by `columnId`) also holds the column's resize handle, after its\n * content, along its end edge (the cell is positioned for it); the cell is then named by its\n * content alone (`aria-labelledby`, unless it has a name of its own), not by the handle's label.\n * The handle is no target of the grid's navigation: a sortable cell's target stays its sort\n * button, and F2 on the cell or the button moves focus to the handle.\n */\nexport const DataGridHeaderCell = ({\n columnId,\n sortable = false,\n sortIcon,\n children,\n className,\n onClick,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ref,\n ...rest\n}: DataGridHeaderCellProps) => {\n const { sort, requestSort } = useDataGridSortContext('DataGrid.HeaderCell');\n const resize = React.useContext(DataGridResizeContext);\n const fixedLayout = React.useContext(DataGridFixedLayoutContext);\n const labelId = useId('wave-datagrid-header-label');\n /** The column this header sorts, or `undefined` when it is not sortable. */\n const sortColumnId = sortable && columnId ? columnId : undefined;\n const sortedDirection =\n sortColumnId !== undefined && sort?.columnId === sortColumnId ? sort.direction : null;\n /** The column whose resize handle this cell holds. */\n const resizeColumnId =\n resize !== null &&\n columnId !== undefined &&\n getColumnEntry(resize.widths, columnId) !== undefined\n ? columnId\n : undefined;\n // The handle is content of the cell: without this, its label would join the cell's name. A\n // name prop given as `undefined` (forwarded by a wrapper) counts as none.\n const labelledByContent =\n resizeColumnId !== undefined && ariaLabel === undefined && ariaLabelledBy === undefined;\n const contentId = labelledByContent ? labelId : undefined;\n\n // The sort runs from the `<th>` once the button's click bubbled up to it, composed after the\n // consumer's `onClick` (C-COMPOSE): the consumer runs first and can cancel with preventDefault().\n // The sort button is the `<th>`'s first child (a resize handle may follow it); clicks elsewhere\n // in the cell, the handle included, do not sort.\n const sortOnButtonClick = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const button = event.currentTarget.firstElementChild;\n if (\n sortColumnId !== undefined &&\n button?.localName === 'button' &&\n button.contains(event.target as Node)\n ) {\n requestSort(sortColumnId, event.nativeEvent);\n }\n };\n\n React.useEffect(() => {\n if (sortable && !columnId) {\n warnOnce(\n 'DataGrid.HeaderCell:sortable-without-columnId',\n 'DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.',\n );\n }\n }, [sortable, columnId]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={sortColumnId !== undefined ? (sortedDirection ?? 'none') : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy ?? contentId}\n className={cn(\n dataGridHeaderCellClassNames.root,\n cellBase,\n 'text-start align-middle font-semibold text-caption-1 uppercase tracking-wider',\n focusRingInset,\n sortColumnId !== undefined && 'p-0 hover:bg-subtle-hover',\n // Columns laid out from widths: what does not fit is clipped, not drawn over the next.\n fixedLayout && 'overflow-hidden',\n // The box the resize handle is drawn in, along the end edge.\n resizeColumnId !== undefined && 'relative',\n className,\n )}\n {...rest}\n onClick={\n sortColumnId !== undefined ? composeEventHandlers(onClick, sortOnButtonClick) : onClick\n }\n >\n {sortColumnId !== undefined ? (\n <TableSortButton\n id={contentId}\n component=\"DataGrid.HeaderCell\"\n direction={sortedDirection}\n sortIcon={sortIcon}\n className={dataGridHeaderCellClassNames.button}\n iconClassName={dataGridHeaderCellClassNames.sortIcon}\n >\n {children}\n </TableSortButton>\n ) : (\n <span id={contentId} className=\"inline-flex items-center gap-1\">\n {children}\n </span>\n )}\n {resizeColumnId !== undefined && resize !== null && (\n <DataGridColumnResizeHandle columnId={resizeColumnId} context={resize} />\n )}\n </th>\n );\n};\nDataGridHeaderCell.displayName = 'DataGridHeaderCell';\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,IAAaG,IAAW;AAGxB,SAAgBC,EACd,GACwD;CACxD,OAAOC,EAAiBC,CAAI,MAAM;AACpC;AAoBA,SAASC,EAA4B,EACnC,kBACA,oBACA,cACA,UACmC;CACnC,IAAM,EAAE,UAAO,cAAW,mBAAgB,yBAAsB,uBAC9DC,EAAmB,iBAAiB,GAChCC,IAAQP,EAAM,qBAClBQ,EAAM,oBACNA,EAAM,mBACNA,EAAM,iBACR,GACM,EACJ,cACA,aACA,cACA,eACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,GAAGC,MACDC,KAAa,CAAC,GAEdC,IAA6B;CAIjC,OAHIP,MAAU,QAAO,IAAU,KACtBA,MAAU,WAAQ,IAAU,UAGnC,kBAAC,MAAD;EACE,OAAM;EACN,GAAIK;EACC;EACL,uBAAoB;EACpB,WAAWG,EACTC,GACAC,EAAyB,eACzBC,GACA,cACAC,GACAC,CACF;EAEC,UAAAC,MAAkB,aACjB,kBAACC,GAAD;GACE,KAAKC;GACL,MAAK;GACL,cAAYd,MAAcC,MAAmB,KAAA,IAAYc,IAAiB,KAAA;GAC1E,mBAAiBd;GACjB,oBAAkBC;GACT;GACC;GACC;GACX,QAAQc;GACR,QAAO;GACP,WAAW,MAAUC,EAAUC,EAAM,WAAW;GAChD,WAAWV,EAAyB;EACrC,CAAA,IAED,kBAAC,QAAD;GAAM,WAAU;GAAW,UAAAW;EAA2B,CAAA;CAEtD,CAAA;A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