@gears-frontx/ui-kit 0.4.5 → 0.4.6

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 (146) hide show
  1. package/dist/chunks/actions.iasfkjWq.css +1 -0
  2. package/dist/chunks/create-column-auto-size.js +62 -0
  3. package/dist/chunks/create-column-auto-size.js.map +1 -0
  4. package/dist/chunks/data-grid-record-context.js +13 -0
  5. package/dist/chunks/data-grid-record-context.js.map +1 -0
  6. package/dist/chunks/data-grid.-6P4UQGJ.css +1 -0
  7. package/dist/chunks/hooked.js +27 -35
  8. package/dist/chunks/hooked.js.map +1 -1
  9. package/dist/chunks/ignore-row-click.js +5 -0
  10. package/dist/chunks/ignore-row-click.js.map +1 -0
  11. package/dist/chunks/messages.js +19 -3
  12. package/dist/chunks/messages.js.map +1 -1
  13. package/dist/chunks/resolve-body-cell-props.DGczzk1U.css +1 -0
  14. package/dist/chunks/resolve-body-cell-props.js +140 -0
  15. package/dist/chunks/resolve-body-cell-props.js.map +1 -0
  16. package/dist/chunks/row-actions.BprAXgu2.css +1 -0
  17. package/dist/chunks/row-click.DAYTmSBO.css +1 -0
  18. package/dist/chunks/row-number.C7fNu9Bw.css +1 -0
  19. package/dist/chunks/row-select.BjKdiMf5.css +1 -0
  20. package/dist/chunks/table-configuration.a6C_fp7B.css +1 -0
  21. package/dist/chunks/table-context.js +8 -0
  22. package/dist/chunks/table-context.js.map +1 -0
  23. package/dist/chunks/table-types.js +11 -0
  24. package/dist/chunks/table-types.js.map +1 -0
  25. package/dist/chunks/table.Dmz7LEk7.css +1 -0
  26. package/dist/components/data-grid/messages.d.ts +16 -0
  27. package/dist/components/data-grid/messages.d.ts.map +1 -1
  28. package/dist/components/data-grid/plugins/actions/actions-plugin.d.ts +4 -0
  29. package/dist/components/data-grid/plugins/actions/actions-plugin.d.ts.map +1 -0
  30. package/dist/components/data-grid/plugins/actions/actions-types.d.ts +11 -0
  31. package/dist/components/data-grid/plugins/actions/actions-types.d.ts.map +1 -0
  32. package/dist/components/data-grid/plugins/actions/components/data-grid-actions-wrapper.d.ts +3 -0
  33. package/dist/components/data-grid/plugins/actions/components/data-grid-actions-wrapper.d.ts.map +1 -0
  34. package/dist/components/data-grid/plugins/actions/public.d.ts +3 -0
  35. package/dist/components/data-grid/plugins/actions/public.d.ts.map +1 -0
  36. package/dist/components/data-grid/plugins/actions-menu/actions-menu-plugin.d.ts +3 -0
  37. package/dist/components/data-grid/plugins/actions-menu/actions-menu-plugin.d.ts.map +1 -0
  38. package/dist/components/data-grid/plugins/actions-menu/actions-menu-types.d.ts +25 -0
  39. package/dist/components/data-grid/plugins/actions-menu/actions-menu-types.d.ts.map +1 -0
  40. package/dist/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.d.ts +3 -0
  41. package/dist/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.d.ts.map +1 -0
  42. package/dist/components/data-grid/plugins/actions-menu/public.d.ts +3 -0
  43. package/dist/components/data-grid/plugins/actions-menu/public.d.ts.map +1 -0
  44. package/dist/components/data-grid/plugins/row-actions/components/data-grid-row-actions-cell.d.ts +3 -0
  45. package/dist/components/data-grid/plugins/row-actions/components/data-grid-row-actions-cell.d.ts.map +1 -0
  46. package/dist/components/data-grid/plugins/row-actions/public.d.ts +3 -0
  47. package/dist/components/data-grid/plugins/row-actions/public.d.ts.map +1 -0
  48. package/dist/components/data-grid/plugins/row-actions/row-actions-plugin.d.ts +6 -0
  49. package/dist/components/data-grid/plugins/row-actions/row-actions-plugin.d.ts.map +1 -0
  50. package/dist/components/data-grid/plugins/row-actions/row-actions-types.d.ts +24 -0
  51. package/dist/components/data-grid/plugins/row-actions/row-actions-types.d.ts.map +1 -0
  52. package/dist/components/data-grid/plugins/row-click/components/data-grid-row-click.d.ts +8 -0
  53. package/dist/components/data-grid/plugins/row-click/components/data-grid-row-click.d.ts.map +1 -0
  54. package/dist/components/data-grid/plugins/row-click/public.d.ts +3 -0
  55. package/dist/components/data-grid/plugins/row-click/public.d.ts.map +1 -0
  56. package/dist/components/data-grid/plugins/row-click/row-click-plugin.d.ts +14 -0
  57. package/dist/components/data-grid/plugins/row-click/row-click-plugin.d.ts.map +1 -0
  58. package/dist/components/data-grid/plugins/row-click/row-click-utils.d.ts +9 -0
  59. package/dist/components/data-grid/plugins/row-click/row-click-utils.d.ts.map +1 -0
  60. package/dist/components/data-grid/plugins/row-number/components/data-grid-row-number-cell.d.ts +3 -0
  61. package/dist/components/data-grid/plugins/row-number/components/data-grid-row-number-cell.d.ts.map +1 -0
  62. package/dist/components/data-grid/plugins/row-number/public.d.ts +3 -0
  63. package/dist/components/data-grid/plugins/row-number/public.d.ts.map +1 -0
  64. package/dist/components/data-grid/plugins/row-number/row-number-plugin.d.ts +4 -0
  65. package/dist/components/data-grid/plugins/row-number/row-number-plugin.d.ts.map +1 -0
  66. package/dist/components/data-grid/plugins/row-number/row-number-types.d.ts +6 -0
  67. package/dist/components/data-grid/plugins/row-number/row-number-types.d.ts.map +1 -0
  68. package/dist/components/data-grid/plugins/row-number/services/row-number-formula.d.ts +2 -0
  69. package/dist/components/data-grid/plugins/row-number/services/row-number-formula.d.ts.map +1 -0
  70. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-banner.d.ts +3 -0
  71. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-banner.d.ts.map +1 -0
  72. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-body.d.ts +3 -0
  73. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-body.d.ts.map +1 -0
  74. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-header.d.ts +3 -0
  75. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-header.d.ts.map +1 -0
  76. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-top.d.ts +3 -0
  77. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-top.d.ts.map +1 -0
  78. package/dist/components/data-grid/plugins/row-select/public.d.ts +3 -0
  79. package/dist/components/data-grid/plugins/row-select/public.d.ts.map +1 -0
  80. package/dist/components/data-grid/plugins/row-select/row-select-plugin.d.ts +5 -0
  81. package/dist/components/data-grid/plugins/row-select/row-select-plugin.d.ts.map +1 -0
  82. package/dist/components/data-grid/plugins/row-select/row-select-types.d.ts +113 -0
  83. package/dist/components/data-grid/plugins/row-select/row-select-types.d.ts.map +1 -0
  84. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-group-item.d.ts +10 -0
  85. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-group-item.d.ts.map +1 -0
  86. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-item.d.ts +10 -0
  87. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-item.d.ts.map +1 -0
  88. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-pin-button.d.ts +8 -0
  89. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-pin-button.d.ts.map +1 -0
  90. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-trigger.d.ts +3 -0
  91. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-trigger.d.ts.map +1 -0
  92. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration.d.ts +3 -0
  93. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration.d.ts.map +1 -0
  94. package/dist/components/data-grid/plugins/table-configuration/public.d.ts +3 -0
  95. package/dist/components/data-grid/plugins/table-configuration/public.d.ts.map +1 -0
  96. package/dist/components/data-grid/plugins/table-configuration/table-configuration-plugin.d.ts +5 -0
  97. package/dist/components/data-grid/plugins/table-configuration/table-configuration-plugin.d.ts.map +1 -0
  98. package/dist/components/data-grid/services/layout/components/data-grid-layout-top.d.ts.map +1 -1
  99. package/dist/components/data-grid/services/layout/components/toolbar-lines.d.ts +2 -0
  100. package/dist/components/data-grid/services/layout/components/toolbar-lines.d.ts.map +1 -0
  101. package/dist/components/data-grid/services/table/components/data-grid-cell.d.ts.map +1 -1
  102. package/dist/components/data-grid/services/table/components/data-grid-extra-header-cell.d.ts.map +1 -1
  103. package/dist/components/data-grid/services/table/components/data-grid-header-cell.d.ts.map +1 -1
  104. package/dist/components/data-grid/services/table/components/data-grid-header-group.d.ts.map +1 -1
  105. package/dist/components/data-grid/services/table/table-service.d.ts.map +1 -1
  106. package/dist/components/data-grid/services/table/table-sticky.d.ts +16 -0
  107. package/dist/components/data-grid/services/table/table-sticky.d.ts.map +1 -1
  108. package/dist/components/table/table.d.ts +20 -3
  109. package/dist/components/table/table.d.ts.map +1 -1
  110. package/dist/data-grid/actions-menu.d.ts +1 -0
  111. package/dist/data-grid/actions-menu.js +57 -0
  112. package/dist/data-grid/actions-menu.js.map +1 -0
  113. package/dist/data-grid/actions.d.ts +1 -0
  114. package/dist/data-grid/actions.js +36 -0
  115. package/dist/data-grid/actions.js.map +1 -0
  116. package/dist/data-grid/filters.js +24 -23
  117. package/dist/data-grid/filters.js.map +1 -1
  118. package/dist/data-grid/row-actions.d.ts +1 -0
  119. package/dist/data-grid/row-actions.js +52 -0
  120. package/dist/data-grid/row-actions.js.map +1 -0
  121. package/dist/data-grid/row-click.d.ts +1 -0
  122. package/dist/data-grid/row-click.js +69 -0
  123. package/dist/data-grid/row-click.js.map +1 -0
  124. package/dist/data-grid/row-number.d.ts +1 -0
  125. package/dist/data-grid/row-number.js +38 -0
  126. package/dist/data-grid/row-number.js.map +1 -0
  127. package/dist/data-grid/row-select.d.ts +1 -0
  128. package/dist/data-grid/row-select.js +293 -0
  129. package/dist/data-grid/row-select.js.map +1 -0
  130. package/dist/data-grid/table-configuration.d.ts +1 -0
  131. package/dist/data-grid/table-configuration.js +165 -0
  132. package/dist/data-grid/table-configuration.js.map +1 -0
  133. package/dist/data-grid.js +853 -921
  134. package/dist/data-grid.js.map +1 -1
  135. package/dist/docs/data-grid.md +336 -9
  136. package/dist/docs/table.md +57 -2
  137. package/dist/index.d.ts +7 -0
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +397 -382
  140. package/dist/index.js.map +1 -1
  141. package/dist/table.js +114 -112
  142. package/dist/table.js.map +1 -1
  143. package/llms.txt +9 -7
  144. package/package.json +1 -1
  145. package/dist/chunks/data-grid.DYrZEU-F.css +0 -1
  146. package/dist/chunks/table.CMm41tvy.css +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.js","sources":["../src/components/data-grid/components/data-grid-spinner.tsx","../src/components/data-grid/services/load/use-data-grid-loading.ts","../src/components/data-grid/services/layout/components/data-grid-layout-content.tsx","../src/components/data-grid/components/data-grid-empty-state.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-main.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-slot.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-top-default.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-top.tsx","../src/components/data-grid/components/load-controlled.tsx","../src/components/data-grid/components/data-grid-content.tsx","../src/components/data-grid/utils/load-state.ts","../src/components/data-grid/services/core/core-service.ts","../src/components/data-grid/services/hooked/hooked.ts","../src/components/data-grid/services/layout/layout-slot-ids.ts","../src/components/data-grid/services/layout/components/data-grid-layout-main-slot-selector.tsx","../src/components/data-grid/services/layout/layout-service.ts","../src/components/data-grid/utils/is-record.ts","../src/components/data-grid/services/load/load-instance.ts","../src/components/data-grid/services/load/load-service.ts","../src/components/data-grid/services/persistent-state/persistent-state-service.ts","../src/components/data-grid/services/plugins/plugins-service.ts","../src/components/data-grid/services/storage/storage-helpers.ts","../src/components/data-grid/services/storage/storage-service.ts","../src/components/data-grid/services/table/table-helpers.ts","../src/components/data-grid/services/table/components/data-grid-body-cell-content.tsx","../src/components/data-grid/services/table/components/data-grid-content.tsx","../src/components/data-grid/services/table/components/data-grid-header-cell-label.tsx","../src/components/data-grid/services/table/table-context.ts","../src/components/data-grid/services/table/components/data-grid-header-cell-content.tsx","../src/components/data-grid/services/table/components/data-grid-header-group.tsx","../src/components/data-grid/services/table/data-grid-record-context.ts","../src/components/data-grid/services/table/resolve-column-style.ts","../src/components/data-grid/services/table/resolve-body-cell-props.ts","../src/components/data-grid/services/table/ignore-row-click.ts","../src/components/data-grid/services/table/components/data-grid-cell.tsx","../src/components/data-grid/services/table/components/data-grid-extra-body-columns.tsx","../src/components/data-grid/services/table/components/data-grid-row.tsx","../src/components/data-grid/services/table/components/data-grid-table-record.tsx","../src/components/data-grid/services/table/components/data-grid-table-records.tsx","../src/components/data-grid/services/table/components/data-grid-table-body.tsx","../src/components/data-grid/services/table/components/data-grid-extra-header-cell.tsx","../src/components/data-grid/services/table/components/data-grid-extra-header-columns.tsx","../src/components/data-grid/services/table/table-min-content-width.ts","../src/components/data-grid/services/table/components/data-grid-header-cell.tsx","../src/components/data-grid/services/table/components/data-grid-table-header.tsx","../src/components/data-grid/services/table/components/data-grid-table-slot.tsx","../src/components/data-grid/services/table/components/data-grid-table.tsx","../src/components/data-grid/services/table/table-columns.ts","../src/components/data-grid/services/table/table-columns-persistence.ts","../src/components/data-grid/services/table/table-extra-columns.ts","../src/components/data-grid/services/table/table-header.ts","../src/components/data-grid/services/table/table-slots.ts","../src/components/data-grid/services/table/table-sticky.ts","../src/components/data-grid/services/table/table-store.ts","../src/components/data-grid/services/table/table-service.ts","../src/components/data-grid/create-data-grid.ts","../src/components/data-grid/data-grid.tsx","../src/components/data-grid/services/layout/data-grid-view.ts"],"sourcesContent":["import { cx } from 'class-variance-authority';\n\nimport { Spinner } from '../../spinner/public.js';\nimport styles from './data-grid-spinner.module.css';\n\ninterface DataGridSpinnerProps {\n className?: string;\n}\n\n/**\n * The one loader the grid draws, for the first load, for the `Suspense` fallback and for every\n * refetch overlay: a spinner that changed size between the first load and a refetch would read\n * as two different components, so there is a single size and a single place that sets it.\n *\n * It fades in after a short delay, so a load that finishes quickly never shows it. The fade is\n * on a wrapper rather than on the spinner: the spinner already runs its own rotation animation,\n * and a second `animation` declaration on the same element would replace that one.\n */\nexport function DataGridSpinner({ className }: DataGridSpinnerProps) {\n return (\n <span className={cx(styles.delayed, className)}>\n <Spinner size=\"lg\" />\n </span>\n );\n}\n","import { useDataGridContext } from '../core/data-grid-context';\n\n/**\n * Whether the grid should be showing load feedback.\n *\n * Reads `recordsLoadState` rather than the load service's overall state: that one counts every\n * in-flight instance, so loading the children of a tree row or paging through the whole data set\n * would dim and block the whole grid over rows the user can still work with. The core service's state is no use here\n * either -- it latches at `'loaded'` after the first load and would never report a refetch. The\n * idle value is `'blank'`, not `'loaded'`, so the test is an equality check.\n *\n * OR-ed with the consumer's `loading` prop, which covers work the grid cannot see -- a bulk copy, a\n * mutation elsewhere on the screen.\n *\n * @internal\n */\nexport function useDataGridLoading(): boolean {\n const context = useDataGridContext();\n const recordsLoadState = context.load.useLoadStateStore((s) => s.recordsLoadState);\n const externalLoading = context.core.useExternalLoadingStore((s) => s.loading);\n\n return recordsLoadState === 'loading' || externalLoading;\n}\n","import type { ReactNode } from 'react';\nimport { DataGridSpinner } from '../../../components/data-grid-spinner';\nimport rootStyles from '../../../data-grid.module.css';\nimport { useDataGridContext } from '../../core/data-grid-context';\nimport { useDataGridLoading } from '../../load/use-data-grid-loading';\nimport styles from './data-grid-layout-content.module.css';\n\ninterface DataGridLayoutContentProps {\n children: ReactNode;\n}\n\nexport function DataGridLayoutContent({ children }: DataGridLayoutContentProps) {\n const context = useDataGridContext();\n const initialLoadState = context.core.useLoadStateStore((s) => s.loadState);\n const isLoading = useDataGridLoading();\n\n // The first load already renders a centred loader in place of the grid, so the overlay stays out\n // until there is content to cover. Without this gate the two would run at once.\n const showOverlay = isLoading && initialLoadState === 'loaded';\n // Tracks the feedback that is actually on screen -- the overlay, or the first load's centred\n // loader -- rather than the raw loading flag. `'error'` latches for the lifetime of the grid and\n // swaps the whole region for the error view, so reading the flag directly announced a busy grid\n // to a screen reader while sighted users saw an error and nothing running.\n const isBusy = showOverlay || initialLoadState === 'loading';\n\n return (\n <div className={rootStyles.root} aria-busy={isBusy ? 'true' : undefined}>\n {children}\n {showOverlay && (\n <div className={styles.loaderOverlay}>\n <DataGridSpinner />\n </div>\n )}\n </div>\n );\n}\n","import { SearchXIcon } from 'lucide-react';\n\nimport { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '../../empty/public.js';\nimport { messages } from '../messages';\nimport { useDataGrid } from '../services/core/data-grid-context';\nimport styles from './data-grid-empty-state.module.css';\n\nexport function DataGridEmptyState() {\n const { useStore } = useDataGrid();\n\n const hasActiveFilters = useStore((s) => s.hasActiveFilters);\n\n return (\n <Empty className={styles.emptyState}>\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <SearchXIcon />\n </EmptyMedia>\n <EmptyTitle>{messages.emptyState.noResultsFound}</EmptyTitle>\n {hasActiveFilters && (\n <EmptyDescription>{messages.emptyState.noResultsFoundDescription}</EmptyDescription>\n )}\n </EmptyHeader>\n </Empty>\n );\n}\n","import { DataGridEmptyState } from '../../../components/data-grid-empty-state';\nimport { useDataGrid, useDataGridContext } from '../../core/data-grid-context';\nimport styles from './data-grid-layout-main.module.css';\n\nexport function DataGridLayoutMain() {\n const { useStore } = useDataGrid();\n const context = useDataGridContext();\n const visibleRecords = useStore((s) => s.visibleRecords);\n const hasActiveFilters = useStore((s) => s.hasActiveFilters);\n\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n const mainLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('main'));\n const activeSlot = mainLayoutSlots?.find((s) => s.id === activeSlotId);\n\n // Lives outside the `main` slots, so it renders in exactly the case `showMain` excludes.\n const emptySlots = context.layout.useLayoutStore((state) => state.slots.get('empty'));\n const emptySlot = emptySlots?.[0];\n\n const isEmpty = visibleRecords.length === 0;\n const showMain = activeSlot && (!isEmpty || hasActiveFilters);\n // Not gated on the load state. A load replaces the records in one synchronous step after the\n // fetch resolves, so `visibleRecords` never renders empty mid-flight and there is no \"No results\n // found\" flash to suppress -- and whatever this region holds is behind the scrim for the whole\n // load anyway. Gating it here instead unmounted the region entirely on an unfiltered empty grid,\n // where `showMain` is false too, which collapsed the grid to the toolbar's height and back.\n const showEmptyState = isEmpty;\n\n return (\n <div className={styles.dataGridLayoutMain}>\n {showMain && <activeSlot.component />}\n {showEmptyState && (emptySlot ? <emptySlot.component /> : <DataGridEmptyState />)}\n </div>\n );\n}\n","import { useDataGridContext } from '../../core/data-grid-context';\nimport type { LayoutSlotName } from '../layout-types';\n\ninterface DataGridLayoutSlotProps {\n name: LayoutSlotName;\n}\n\nexport function DataGridLayoutSlot({ name }: DataGridLayoutSlotProps) {\n const context = useDataGridContext();\n const currentSlots = context.layout.useLayoutStore((state) => state.slots.get(name));\n\n if (!currentSlots || currentSlots.length === 0) return null;\n\n return (\n <>\n {currentSlots.map((slot) => (\n <slot.component key={slot.id} />\n ))}\n </>\n );\n}\n","import { useDataGridContext } from '../../core/data-grid-context';\nimport styles from './data-grid-layout-top-default.module.css';\n\nexport function DataGridLayoutTopDefault() {\n const context = useDataGridContext();\n\n const topStartLayoutSlots = context.layout.useLayoutStore((state) =>\n state.slots.get('top-start'),\n );\n const topEndLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('top-end'));\n\n const hasTopStartSlots = (topStartLayoutSlots?.length ?? 0) > 0;\n const hasTopEndSlots = (topEndLayoutSlots?.length ?? 0) > 0;\n\n if (!hasTopStartSlots && !hasTopEndSlots) return null;\n\n return (\n <div className={styles.dataGridTopDefault}>\n {hasTopStartSlots && (\n <div className={styles.topStartSlots}>\n {topStartLayoutSlots?.map((slot) => (\n <div key={slot.id} className={styles.topStartSlot}>\n <slot.component />\n </div>\n ))}\n </div>\n )}\n {hasTopEndSlots && (\n <div className={styles.topEndSlots}>\n {topEndLayoutSlots?.map((slot) => (\n <div key={slot.id} className={styles.topEndSlot}>\n <slot.component />\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n","import { useDataGridContext } from '../../core/data-grid-context';\nimport { DataGridLayoutTopDefault } from './data-grid-layout-top-default';\n\nexport function DataGridLayoutTop() {\n const context = useDataGridContext();\n\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('top'));\n const topLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('top'));\n const topLayoutSlot = topLayoutSlots?.find((s) => s.id === activeSlotId);\n\n if (!topLayoutSlot) return null;\n\n const TopComponent =\n topLayoutSlot.id === 'default' ? DataGridLayoutTopDefault : topLayoutSlot.component;\n\n return <TopComponent />;\n}\n","import { OctagonAlertIcon } from 'lucide-react';\nimport type { ReactNode } from 'react';\n\nimport { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '../../empty/public.js';\nimport { messages } from '../messages';\nimport type { LoadState } from '../utils/load-state';\nimport { DataGridSpinner } from './data-grid-spinner';\nimport styles from './load-controlled.module.css';\n\ninterface LoadControlledProps {\n loadState: LoadState;\n /** Rendered once the state is `loaded`. */\n children: ReactNode;\n}\n\n/**\n * Shows the grid's first load: its content when loaded, an error view when the load failed, and\n * the delayed spinner for everything else. Both stand-ins are centred in the space the grid\n * occupies. The error view has no retry: a failed first load stays failed.\n */\nexport function LoadControlled({ loadState, children }: LoadControlledProps) {\n if (loadState === 'loaded') {\n return <>{children}</>;\n }\n\n if (loadState === 'error') {\n return (\n <Empty className={styles.center}>\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <OctagonAlertIcon />\n </EmptyMedia>\n <EmptyTitle>{messages.loadError.headerDefault}</EmptyTitle>\n <EmptyDescription>{messages.loadError.bodyDefault}</EmptyDescription>\n </EmptyHeader>\n </Empty>\n );\n }\n\n return <DataGridSpinner className={styles.center} />;\n}\n","import { useEffect } from 'react';\nimport { useDataGrid, useDataGridContext } from '../services/core/data-grid-context';\nimport { DataGridLayoutContent } from '../services/layout/components/data-grid-layout-content';\nimport { DataGridLayoutMain } from '../services/layout/components/data-grid-layout-main';\nimport { DataGridLayoutSlot } from '../services/layout/components/data-grid-layout-slot';\nimport { DataGridLayoutTop } from '../services/layout/components/data-grid-layout-top';\nimport { LoadControlled } from './load-controlled';\n\nexport function DataGridContent() {\n const grid = useDataGrid();\n const { useStore } = grid;\n const { core } = useDataGridContext();\n const visibleRecords = useStore((s) => s.visibleRecords);\n\n const loadState = core.useLoadStateStore((s) => s.loadState);\n const isEmpty = visibleRecords.length === 0;\n\n useEffect(() => {\n // A failed first load is already handled for the user: the core load state goes to `'error'`\n // and the region below renders the error view. Letting the rejection escape as well surfaced it\n // as an unhandled rejection, which a host app's global handler reports as a crash it cannot act\n // on. Nothing subscribes to the `load:error` hook, though, so catching it without saying\n // anything would leave a failed load with no trace at all for whoever has to debug it.\n grid.init().catch((error: unknown) => {\n if (process.env.NODE_ENV !== 'production') {\n console.error('[DataGrid] Initial load failed:', error);\n }\n });\n return () => grid.destroy();\n }, [grid]);\n\n return (\n <DataGridLayoutContent>\n <LoadControlled loadState={loadState}>\n <DataGridLayoutTop />\n <DataGridLayoutMain />\n {!isEmpty && <DataGridLayoutSlot name=\"bottom\" />}\n </LoadControlled>\n </DataGridLayoutContent>\n );\n}\n","import type { StoreApi, UseBoundStore } from 'zustand';\nimport { create } from 'zustand';\n\nexport type LoadState = 'blank' | 'loading' | 'error' | 'loaded';\n\nexport interface LoadStateStore {\n loadState: LoadState;\n}\n\nexport type UseLoadStateStore = UseBoundStore<StoreApi<LoadStateStore>>;\n\nexport interface LoadStateManager {\n useLoadState: UseLoadStateStore;\n setLoading: () => void;\n setLoaded: () => void;\n setError: () => void;\n setBlank: () => void;\n /** Back to idle, and detaches the `loadPromise` in flight so its outcome no longer writes. */\n reset: () => void;\n loadPromise: <T>(promise: Promise<T>) => Promise<T>;\n}\n\n/**\n * A zustand store holding a `blank -> loading -> loaded | error` state, plus the helpers that move\n * it. `loadPromise` follows a promise: loading while it is pending, then loaded or error.\n */\nexport function createLoadStateManager(): LoadStateManager {\n const useLoadStateStore = create<LoadStateStore>()(() => ({\n loadState: 'blank',\n }));\n // Which `loadPromise` owns the state. A later one, or a `reset`, takes it over, and the outcome\n // of the one it replaced no longer writes: a load that was cut off must not come back later and\n // mark the state loaded, or failed, over whatever the state has become since.\n let owner = 0;\n\n return {\n useLoadState: useLoadStateStore,\n setLoading,\n setLoaded,\n setError,\n setBlank,\n reset,\n loadPromise,\n };\n\n function setLoading() {\n useLoadStateStore.setState({ loadState: 'loading' });\n }\n\n function setLoaded() {\n useLoadStateStore.setState({ loadState: 'loaded' });\n }\n\n function setError() {\n useLoadStateStore.setState({ loadState: 'error' });\n }\n\n function setBlank() {\n useLoadStateStore.setState({ loadState: 'blank' });\n }\n\n function reset() {\n owner += 1;\n setBlank();\n }\n\n async function loadPromise<T>(promise: Promise<T>): Promise<T> {\n const mine = ++owner;\n setLoading();\n try {\n const result = await promise;\n if (mine === owner) setLoaded();\n return result;\n } catch (error) {\n if (mine === owner) setError();\n throw error;\n }\n }\n}\n","import { create } from 'zustand';\nimport { createLoadStateManager } from '../../utils/load-state';\nimport type { CoreService, ExternalLoadingStore } from './core-types';\n\nexport function createCoreService(): CoreService {\n const { useLoadState, loadPromise, reset } = createLoadStateManager();\n\n const useExternalLoadingStore = create<ExternalLoadingStore>()(() => ({\n loading: false,\n }));\n\n return {\n useLoadStateStore: useLoadState,\n loadPromise,\n resetLoadState: reset,\n useExternalLoadingStore,\n updateLoading,\n };\n\n function updateLoading(loading: boolean) {\n useExternalLoadingStore.setState({ loading });\n }\n}\n","import { createHooked } from '../../utils/hooked';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridHooked, DataGridHooks } from './hooked-types';\n\nexport function createHookedService<TItem extends DataGridItem>(): DataGridHooked<TItem> {\n const hooked = createHooked<DataGridHooks<TItem>>();\n\n return {\n hook: hooked.hook,\n callHook: hooked.callHook,\n callHookParallel: hooked.callHookParallel,\n callHookSync: hooked.callHookSync,\n };\n}\n","/*\n * Ids of the built-in main views, owned by the core rather than by what registers them (the table\n * view is registered by the core itself; a cards view is registered by a plugin). The core reads\n * them (the view selector's labels, `DATA_GRID_VIEW`), and the core's entry must not import a\n * plugin module to do it: that would pull the plugin's code and CSS into every grid that never\n * uses it.\n */\nexport const TABLE_LAYOUT_SLOT_ID = 'table_layout';\nexport const CARDS_LAYOUT_SLOT_ID = 'cards_layout';\n","import { messages } from '../../../messages';\nimport { Segment } from '../../../components/segment';\nimport { ToggleGroupItem } from '../../../../toggle-group/public.js';\nimport { useDataGridContext } from '../../core/data-grid-context';\nimport { CARDS_LAYOUT_SLOT_ID, TABLE_LAYOUT_SLOT_ID } from '../layout-slot-ids';\n\nexport const VIEW_SELECTOR_SLOT_ID = 'view_selector';\n\n// The label of each built-in view. A view the grid does not know (a plugin's own main slot) has\n// none, and is named by its id instead.\nconst slotLabels = new Map<string, string>([\n [TABLE_LAYOUT_SLOT_ID, messages.layoutMainSlotSelector.table],\n [CARDS_LAYOUT_SLOT_ID, messages.layoutMainSlotSelector.cards],\n]);\n\nexport function DataGridLayoutMainSlotSelector() {\n const context = useDataGridContext();\n\n const mainSlots = context.layout.useLayoutStore((state) => state.slots.get('main'));\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n\n if (!mainSlots || mainSlots.length < 2) return null;\n\n return (\n <Segment size=\"sm\" iconOnly value={activeSlotId} onValueChange={handleValueChange}>\n {mainSlots.map((slot) => {\n const Icon = 'icon' in slot ? slot.icon : undefined;\n return (\n <ToggleGroupItem\n key={slot.id}\n value={slot.id}\n aria-label={slotLabels.get(slot.id) ?? slot.id}\n >\n {Icon ? <Icon /> : null}\n </ToggleGroupItem>\n );\n })}\n </Segment>\n );\n\n function handleValueChange(value: string | undefined) {\n if (value) {\n context.layout.setActiveSlotId('main', value);\n }\n }\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport {\n DataGridLayoutMainSlotSelector,\n VIEW_SELECTOR_SLOT_ID,\n} from './components/data-grid-layout-main-slot-selector';\nimport type {\n LayoutPublicApi,\n LayoutService,\n LayoutSlot,\n LayoutSlotName,\n LayoutSlotOptions,\n LayoutStore,\n} from './layout-types';\n\nexport function createLayoutService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): LayoutService {\n const useLayoutStore = create<LayoutStore>()(() => ({\n slots: new Map(),\n activeSlotIds: new Map(),\n }));\n\n const publicApi: LayoutPublicApi = {\n registerSlot,\n setActiveSlotId,\n getActiveSlotId,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n useLayoutStore,\n };\n\n function getSlotById<T extends LayoutSlotName>(name: T, id: string) {\n return getLayoutSlots(name).find((slot) => slot.id === id) as Extract<\n LayoutSlot,\n { name: T }\n >;\n }\n\n function getLayoutSlots<T extends LayoutSlotName>(name: T) {\n return (useLayoutStore.getState().slots.get(name) ?? []) as Extract<\n LayoutSlot,\n { name: T }\n >[];\n }\n\n function registerSlot<T extends LayoutSlotName>(name: T, options: LayoutSlotOptions[T]) {\n if ((name === 'top-start' || name === 'top-end') && !getSlotById('top', 'default')) {\n registerSlot('top', {\n id: 'default',\n active: true,\n component: () => null,\n });\n }\n\n const id = options.id ?? Math.random().toString();\n const existingSlots = getLayoutSlots(name);\n const order = options.order ?? (existingSlots.length + 1) * 10;\n const newSlot: LayoutSlot = { id, name, ...options, order };\n const newSlots = [...existingSlots, newSlot].sort((a, b) => a.order - b.order);\n\n useLayoutStore.setState((state) => {\n const newSlotsMap = new Map(state.slots);\n newSlotsMap.set(name, newSlots);\n return { slots: newSlotsMap };\n });\n\n if ('active' in options && options.active) {\n setActiveSlotId(name, newSlot.id);\n } else if (newSlots.length === 1) {\n setActiveSlotId(name, newSlot.id);\n }\n\n // Auto-mount the main-slot view selector once there are two or more main views to switch\n // between. Guarded so a third main slot does not register a second selector.\n if (name === 'main' && newSlots.length >= 2 && !getSlotById('top-end', VIEW_SELECTOR_SLOT_ID)) {\n registerSlot('top-end', {\n id: VIEW_SELECTOR_SLOT_ID,\n component: DataGridLayoutMainSlotSelector,\n });\n }\n }\n\n function setActiveSlotId(name: LayoutSlotName, id: string) {\n useLayoutStore.setState((state) => {\n const newActiveSlotIds = new Map(state.activeSlotIds);\n newActiveSlotIds.set(name, id);\n return { activeSlotIds: newActiveSlotIds };\n });\n }\n\n function getActiveSlotId(name: LayoutSlotName) {\n return useLayoutStore.getState().activeSlotIds.get(name);\n }\n}\n","/** Any non-null object, arrays included: the shape a value must have to be read by key. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","import { isRecord } from '../../utils/is-record';\nimport { createLoadStateManager } from '../../utils/load-state';\nimport type {\n InternalContext,\n DataGridItem,\n DataGridLoadContext,\n DataGridLoadResult,\n} from '../../data-grid-types';\nimport type { LoadInstance, LoadTriggerConfig } from './load-types';\n\nexport function createLoadInstance<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n config?: LoadTriggerConfig,\n): LoadInstance<TItem> {\n const id = (config?.id ?? Math.random()).toString();\n const controller = new AbortController();\n const loadStateManager = createLoadStateManager();\n const loadContext: DataGridLoadContext = structuredClone(config?.loadContext ?? {});\n let fetchResult: DataGridLoadResult<TItem> | undefined;\n let processResult: DataGridLoadResult<TItem> | undefined;\n let error: Error | undefined;\n // The hooks are handed `instance` while the load is starting, before its promise exists, so the\n // getter below reads a slot that is filled in right after the instance is built.\n const started: { promise?: Promise<void> } = {};\n const instance: LoadInstance<TItem> = {\n id,\n useLoadState: loadStateManager.useLoadState,\n signal: controller.signal,\n abort,\n refresh: config?.refresh ?? null,\n get promise() {\n return started.promise!;\n },\n get loadContext() {\n return loadContext;\n },\n get processResult() {\n return processResult;\n },\n get fetchResult() {\n return fetchResult;\n },\n get error() {\n return error;\n },\n };\n\n started.promise = loadStateManager.loadPromise(executeLoad());\n\n return instance;\n\n function abort() {\n controller.abort();\n }\n\n async function executeLoad() {\n try {\n await context.hooked.callHookParallel('load:prepare', instance);\n // Call the load:context hook first to collect context data from plugins\n const extraContext = await context.hooked.callHookParallel('load:context', instance);\n\n // Merge all returned context data into the main loadContext\n mergeContextData(loadContext, extraContext);\n\n const data = {\n ...instance.loadContext,\n signal: instance.signal,\n };\n\n fetchResult = await context.config.load.current(data);\n\n assertLoadResult(fetchResult);\n\n processResult = (await context.hooked.callHook('load:process', instance))[0] ?? fetchResult;\n\n assertLoadResult(processResult);\n\n // Skip storing if store flag is explicitly false\n if (config?.store !== false) {\n const stored = context.hooked.callHookSync('load:store', instance);\n\n if (!stored.length || stored.every((item) => item !== true)) {\n context.storage.clearSections();\n context.storage.createSection({ loadContext }, processResult.results);\n }\n }\n\n await context.hooked.callHook('load:success', instance);\n } catch (e: unknown) {\n error = e as Error;\n await context.hooked.callHook('load:error', instance);\n throw error;\n }\n }\n\n function assertLoadResult(result: unknown): asserts result is DataGridLoadResult<TItem> {\n if (typeof result !== 'object' || result === null || !('results' in result)) {\n throw new Error(\n `Load result must be an object with \"results\" and \"total?\" properties. Got ${JSON.stringify(result)}`,\n );\n }\n }\n\n function mergeContextData(target: Record<string, unknown>, fromArray: (object | void)[]) {\n for (const result of fromArray ?? []) {\n if (!isRecord(result)) continue;\n\n // key will be filters, pagination, order, ...\n for (const key in result) {\n const value = result[key];\n if (!isRecord(value)) continue;\n\n if (Array.isArray(value)) {\n target[key] = value;\n } else {\n target[key] ??= {};\n const merged = target[key];\n if (isRecord(merged)) {\n Object.assign(merged, value);\n }\n }\n }\n }\n }\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { createLoadInstance } from './load-instance';\nimport type {\n LoadInstance,\n LoadInstanceId,\n LoadPublicApi,\n LoadService,\n LoadTriggerConfig,\n RefreshOptions,\n RefreshOptionsRaw,\n LoadStateStore,\n} from './load-types';\n\nexport function createLoadService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): LoadService<TItem> {\n const instances = new Map<LoadInstanceId, LoadInstance<TItem>>();\n // The subset of `instances` whose result replaces the visible record set. Tracked alongside\n // rather than derived on read, so a child fetch outliving the root load still flips the state\n // back: `instances` alone stays non-empty and would never notify.\n const recordInstanceIds = new Set<LoadInstanceId>();\n // The newest refresh, so a first load that a refresh superseded can wait for the load that\n // replaces it.\n let latestRefresh: Promise<void> | undefined;\n\n const useLoadStateStore = create<LoadStateStore>()(() => ({\n loadState: 'blank',\n recordsLoadState: 'blank',\n }));\n\n const publicApi: LoadPublicApi<TItem> = {\n triggerLoad,\n refresh,\n abort,\n getLoadInstances,\n useLoadStateStore,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n init,\n };\n\n function syncLoadState() {\n useLoadStateStore.setState({\n loadState: instances.size > 0 ? 'loading' : 'blank',\n recordsLoadState: recordInstanceIds.size > 0 ? 'loading' : 'blank',\n });\n }\n\n /**\n * Whether this load ends up replacing what the grid is showing.\n *\n * `store: false` opts out of storage entirely -- a load that pages through the whole data set\n * runs that way -- and a load scoped to a tree parent appends a section beneath that row instead\n * of clearing the rest. Both leave the visible rows usable, so neither should raise the overlay.\n */\n function replacesRecords(triggerConfig?: LoadTriggerConfig): boolean {\n if (triggerConfig?.store === false) {\n return false;\n }\n\n return triggerConfig?.loadContext?.tree?.parentId == null;\n }\n\n function getLoadInstances(): LoadInstance<TItem>[] {\n return [...instances.values()];\n }\n\n function abort() {\n for (const instance of instances.values()) {\n instance.abort();\n }\n }\n\n /**\n * Waits for a load, and says whether this service aborted it itself (`true`) instead of it\n * finishing. An abort counts as settled, not failed.\n *\n * The service aborts what is in flight when a refresh starts its own load, and when the grid is\n * destroyed, so nobody is waiting for the aborted one's result any more. Its rejection (a `load`\n * that honours `signal` rejects with an AbortError) is the abort doing its job: reported from\n * `refresh()` it is an unhandled rejection at every call site that does not catch it (the plugins\n * do not), and reported from the first load it latches the grid into its error view, or logs a\n * failure for a grid that is simply gone.\n *\n * `signal.aborted` means the load was aborted through this service: by a refresh, by `destroy()`,\n * or by the public `abort()`, which a consumer's code can call too, so a consumer's abort settles\n * the same way. An AbortError a consumer's own `load` raises (its own timeout, say) does not set\n * the signal and still rejects, and so does any other failure.\n */\n async function settle(instance: LoadInstance<TItem>): Promise<boolean> {\n try {\n await instance.promise;\n return false;\n } catch (error) {\n if (instance.signal.aborted) return true;\n throw error;\n }\n }\n\n /**\n * The first load is done when the data the grid shows has arrived. A refresh that aborts it\n * carries that data from then on, so it is followed instead of settled: the first load is done\n * when that refresh's load is, through any refreshes that supersede it in turn. If that load\n * fails, so has the first one, since nothing ever loaded. If `destroy()` aborts it, nothing is\n * left to wait for, and the grid has not loaded: `destroy()` puts the core back to idle.\n */\n async function init() {\n await context.hooked.callHook('init');\n const refreshBefore = latestRefresh;\n if (!(await settle(triggerLoad()))) return;\n\n let followed = refreshBefore;\n while (latestRefresh !== followed) {\n followed = latestRefresh;\n await followed;\n }\n }\n\n function refresh(options: RefreshOptionsRaw = {}): Promise<void> {\n latestRefresh = runRefresh(options);\n return latestRefresh;\n }\n\n async function runRefresh(options: RefreshOptionsRaw) {\n abort();\n const refreshOptions: RefreshOptions = { resetFilters: options.resetFilters ?? true };\n await context.hooked.callHook('refresh', refreshOptions);\n await settle(triggerLoad({ refresh: refreshOptions }));\n }\n\n function triggerLoad(triggerConfig?: LoadTriggerConfig): LoadInstance<TItem> {\n const instance = createLoadInstance<TItem>(context, triggerConfig);\n\n instances.set(instance.id, instance);\n if (replacesRecords(triggerConfig)) {\n recordInstanceIds.add(instance.id);\n }\n syncLoadState();\n\n instance.promise\n .finally(() => {\n instances.delete(instance.id);\n recordInstanceIds.delete(instance.id);\n syncLoadState();\n })\n // Bookkeeping only. The rejection itself belongs to whoever awaited the instance's promise;\n // this branch re-raising it would land as an unhandled rejection with no one to catch it.\n .catch(() => undefined);\n\n return instance;\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { isRecord } from '../../utils/is-record';\nimport type {\n PersistOptions,\n UsePersistentState,\n PersistentStateService,\n PersistentStatePublicApi,\n} from './persistent-state-types';\n\nexport function createPersistentStateService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): PersistentStateService {\n const subscribers = new Map<string, Set<() => void>>();\n // Backing for the 'memory' mode, scoped to the grid instance: state survives\n // re-renders within one mount and resets on remount.\n const memoryStore = new Map<string, unknown>();\n const gridName = context.config.name;\n const persistMode = context.config.persistent ?? 'localStorage';\n\n const publicApi: PersistentStatePublicApi = {\n registerPersistentState,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return publicApi;\n\n function getStorageKey(key: string) {\n return `dataGrid:${gridName}:${key}`;\n }\n\n // Browser storage can be unavailable in ways that throw instead of returning `null`: reading the\n // `localStorage` property itself raises a SecurityError where storage is blocked (a sandboxed or\n // third-party iframe, \"block all cookies\"), and a write raises once the quota is used up. Both\n // mean \"this view is not remembered\", never \"the grid cannot render\" -- plugins read storage in\n // render, so a throw here would take the whole grid down -- so each access below falls back to\n // no persistence, the same way a stored value that is not JSON reads as absent.\n function getStorage(area: 'localStorage' | 'sessionStorage'): Storage | null {\n if (typeof window === 'undefined') return null;\n\n try {\n return area === 'localStorage' ? localStorage : sessionStorage;\n } catch {\n return null;\n }\n }\n\n function registerPersistentState<T>(\n key: string,\n options: PersistOptions = {},\n ): UsePersistentState<T> {\n const storageKey = getStorageKey(key);\n // `storage` names the backend for this one state, overriding the grid-wide mode. For\n // state that belongs to the viewer rather than to the view they would share — a column\n // selection, say, next to filters that stay in the URL.\n const mode = options.storage ?? persistMode;\n // A state registered with `router: false` opted out of URL persistence:\n // in router mode it reads and writes nothing, other backends are unaffected.\n const isDisabled = mode === 'router' && options.router === false;\n\n return {\n get value() {\n return getValue();\n },\n setValue,\n buildStorageItem,\n };\n\n function getValue(): T | undefined {\n if (isDisabled) {\n return undefined;\n }\n\n if (mode === 'memory') {\n return memoryStore.get(key) as T | undefined;\n }\n\n if (mode === 'router') {\n // URL-based persistence\n const params = new URLSearchParams(window.location.search);\n return parseStored<T>(params.get(key));\n }\n\n const storage = getStorage(mode);\n if (!storage) return undefined;\n\n return parseStored<T>(readItem(storage, storageKey));\n }\n\n function setValue(value: T | undefined) {\n if (isDisabled) {\n return;\n }\n\n if (mode === 'memory') {\n if (value === undefined) {\n memoryStore.delete(key);\n } else {\n memoryStore.set(key, value);\n }\n } else if (mode === 'router') {\n const params = new URLSearchParams(window.location.search);\n if (value === undefined) {\n params.delete(key);\n } else {\n params.set(key, JSON.stringify(value));\n }\n const newUrl = `${window.location.pathname}?${params.toString()}`;\n window.history.replaceState(null, '', newUrl);\n } else {\n const storage = getStorage(mode);\n if (!storage) return;\n\n try {\n if (value === undefined) {\n storage.removeItem(storageKey);\n } else {\n storage.setItem(storageKey, JSON.stringify(value));\n }\n } catch {\n // Quota or blocked: the plugin keeps the state in its own store, it just is not remembered.\n }\n }\n\n // Notify subscribers\n subscribers.get(key)?.forEach((fn) => fn());\n }\n\n function buildStorageItem(value: T): Record<string, unknown> {\n // Build URL query params based on schema\n if (!options.schema) return { [key]: value };\n\n const result: Record<string, unknown> = {};\n Object.entries(options.schema).forEach(([field]) => {\n const val = isRecord(value) ? value[field] : undefined;\n if (val !== undefined) {\n result[field] = val;\n }\n });\n return result;\n }\n }\n}\n\nfunction readItem(storage: Storage, key: string): string | null {\n try {\n return storage.getItem(key);\n } catch {\n return null;\n }\n}\n\n/**\n * A stored value is a string the user can edit -- through devtools on `localStorage` and\n * `sessionStorage`, through the address bar on the router mode -- so it is not certain to be JSON\n * at all. A value that will not parse reads as an absent one rather than throwing: a `localStorage`\n * entry is read on every mount, so a throw here would leave the grid unable to render until\n * someone cleared site data. Narrowing what did parse is the caller's job.\n */\nfunction parseStored<T>(raw: string | null): T | undefined {\n if (!raw) return undefined;\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return undefined;\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport type {\n DataGridPlugin,\n DataGridPluginContext,\n PluginsPublicApi,\n PluginsService,\n ServicesPublicApiTypes,\n} from './plugins-types';\n\nexport function createPluginsService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): PluginsService<TItem> {\n const pluginApis = new Map<string, unknown>();\n const pluginPublicApi: PluginsPublicApi<TItem> = {\n hook: context.hooked.hook,\n getPlugin,\n };\n\n // Starts with the plugins' own API and grows as every other service registers its public API\n // through `registerPublicApi` while the grid is being created. Plugins only see it afterwards,\n // when it is complete, which a type cannot express for an object filled in over time.\n const pluginContext = { ...pluginPublicApi } as DataGridPluginContext<TItem>;\n\n return {\n ...pluginPublicApi,\n registerPlugin,\n registerPlugins,\n registerPublicApi,\n pluginContext,\n };\n\n function registerPublicApi(methods: ServicesPublicApiTypes<TItem>) {\n Object.assign(pluginContext, methods);\n }\n\n function registerPlugin(plugin: DataGridPlugin<TItem>) {\n if (pluginApis.has(plugin.name)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[DataGrid] Plugin \"${plugin.name}\" is already registered. Skipping duplicate.`,\n );\n }\n return;\n }\n\n const api = plugin.setup(pluginContext);\n if (api !== undefined) {\n pluginApis.set(plugin.name, api);\n }\n }\n\n function registerPlugins(plugins: DataGridPlugin<TItem>[]) {\n plugins.forEach((plugin) => registerPlugin(plugin));\n }\n\n function getPlugin<TApi>(name: string): TApi | undefined {\n return pluginApis.get(name) as TApi | undefined;\n }\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridDataKey, DataGridItemId } from './storage-types';\n\nexport function getItemKeyValue<TItem extends DataGridItem = DataGridItem>(\n item: TItem,\n key: DataGridDataKey<TItem>,\n) {\n if (typeof key === 'string') {\n if (!(key in item)) {\n throw new Error(`Key \"${key}\" not found in item ${JSON.stringify(item)}`);\n }\n return item[key] as DataGridItemId;\n }\n\n return key(item);\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { getItemKeyValue } from './storage-helpers';\nimport type {\n DataGridItemId,\n DataGridParentId,\n DataGridRecord,\n DataGridRecords,\n DataGridSection,\n DataGridSectionConfig,\n DataGridSectionId,\n StoragePublicApi,\n StorageService,\n StorageStoreInternal,\n} from './storage-types';\n\nexport function createStorageService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): StorageService<TItem> {\n const useStore = create<StorageStoreInternal<TItem>>()(() => ({\n sections: new Map(),\n recordSections: new Map(),\n visibleRecords: [],\n rootSections: [],\n visibleSections: [],\n hasActiveFilters: false,\n }));\n\n let implicitFilterKeys: string[] = [];\n\n const publicApi: StoragePublicApi<TItem> = {\n useStore,\n clearSections,\n createSection,\n getSections,\n getRecord,\n getSectionsByParentId,\n getRecordsByParentId,\n getItemId,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return { ...publicApi, updateImplicitFilterKeys };\n\n function createSection(config: DataGridSectionConfig, items: TItem[]) {\n const sectionId = Math.random().toString();\n const parentId = config.parentId ?? null;\n const newSection: DataGridSection<TItem> = {\n id: sectionId,\n visible: true,\n parentId,\n loadContext: config.loadContext,\n records: [],\n };\n\n const itemKey = context.config.itemKey ?? 'id';\n for (const [index, item] of items.entries()) {\n const itemId = getItemKeyValue(item, itemKey);\n newSection.records.push({ id: itemId, item, index, section: newSection });\n }\n\n useStore.setState((state) => {\n const sections = new Map(state.sections);\n const recordSections = new Map(state.recordSections);\n\n sections.set(sectionId, newSection);\n recordSections.set(parentId, [...(recordSections.get(parentId) ?? []), sectionId]);\n const { visibleRecords, rootSections, visibleSections, hasActiveFilters } =\n computeDerivedState(sections, recordSections);\n\n return {\n sections,\n recordSections,\n visibleRecords,\n rootSections,\n visibleSections,\n hasActiveFilters,\n };\n });\n\n return newSection;\n }\n\n function clearSections() {\n useStore.setState({\n sections: new Map(),\n recordSections: new Map(),\n visibleRecords: [],\n rootSections: [],\n visibleSections: [],\n hasActiveFilters: false,\n });\n }\n\n function getSections(): DataGridSection<TItem>[] {\n return [...useStore.getState().sections.values()];\n }\n\n function getRecord(id: DataGridItemId): DataGridRecord<TItem> | undefined {\n for (const section of useStore.getState().sections.values()) {\n const record = section.records.find((r) => r.id === id);\n if (record) {\n return record;\n }\n }\n return undefined;\n }\n\n function getSectionsByParentId(parentId: DataGridParentId): DataGridSection<TItem>[] {\n const state = useStore.getState();\n const sectionIds = state.recordSections.get(parentId) ?? [];\n return sectionIds.map((id) => state.sections.get(id)!).filter(Boolean);\n }\n\n function getRecordsByParentId(parentId: DataGridParentId): DataGridRecords<TItem> {\n return getSectionsByParentId(parentId).flatMap((section) => section.records);\n }\n\n function getItemId(item: TItem): DataGridItemId {\n const itemKey = context.config.itemKey ?? 'id';\n return getItemKeyValue(item, itemKey);\n }\n\n function isFilterValueActive(value: unknown): boolean {\n if (value === undefined || value === null) return false;\n if (typeof value === 'boolean') return true;\n if (Array.isArray(value)) return value.length > 0;\n return Boolean(value);\n }\n\n // hasActiveFilters is computed eagerly into the store, so changing the keys has to\n // recompute it rather than wait for the next section change. Compared by reference, like\n // `columns`: the prop is documented as referentially stable, so a new array means new keys.\n function updateImplicitFilterKeys(keys: string[]) {\n if (implicitFilterKeys === keys) return;\n\n implicitFilterKeys = keys;\n useStore.setState((state) => computeDerivedState(state.sections, state.recordSections));\n }\n\n function computeDerivedState(\n sections: Map<DataGridSectionId, DataGridSection<TItem>>,\n recordSections: Map<DataGridParentId, DataGridSectionId[]>,\n ) {\n const allSections = [...sections.values()];\n const visibleSections = allSections.filter((section) => section.visible);\n const rootSectionIds = recordSections.get(null) ?? [];\n const rootSections = rootSectionIds\n .map((id) => sections.get(id)!)\n .filter((section) => section.visible);\n const visibleRecords = visibleSections.flatMap((section) => section.records);\n const hasActiveFilters = visibleSections.some((section) => {\n const { filters } = section.loadContext;\n if (!filters) return false;\n return Object.entries(filters).some(\n ([key, filter]) => !implicitFilterKeys.includes(key) && isFilterValueActive(filter?.value),\n );\n });\n\n return {\n visibleSections,\n rootSections,\n visibleRecords,\n hasActiveFilters,\n };\n }\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridTableColumn } from './table-types';\n\nexport function resolveLabel(label: string | (() => string)): string {\n return typeof label === 'function' ? label() : label;\n}\n\nexport function getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n return path.split('.').reduce<unknown>((acc, key) => {\n if (acc != null && typeof acc === 'object') {\n return (acc as Record<string, unknown>)[key];\n }\n return undefined;\n }, obj);\n}\n\n/**\n * Resolves a body cell's plain-string display value — the same value the default cell renderer\n * shows — or `undefined` when the column uses `component`/`render` (output the kit cannot safely\n * stringify, e.g. for an auto-set `title` fallback). Shared by `DataGridBodyCellContent` (the\n * renderer) and `resolveBodyCellProps` (the `title` fallback for `cellOverflow: 'nowrap'`) so the\n * two never drift on what counts as \"plain string\" content.\n */\nexport function resolveCellDisplayValue<TItem extends DataGridItem>(\n column: DataGridTableColumn<TItem>,\n item: TItem,\n): string | undefined {\n if (column.render || column.component) return undefined;\n\n const key = column.key ?? column.id;\n const rawValue = key.includes('.') ? getNestedValue(item, key) : item[key];\n\n if (column.formatter) return column.formatter(rawValue);\n\n return rawValue != null ? String(rawValue) : '';\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { getNestedValue, resolveCellDisplayValue } from '../table-helpers';\nimport type { DataGridTableColumn } from '../table-types';\n\ninterface DataGridBodyCellContentProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n item: TItem;\n}\n\nexport function DataGridBodyCellContent<TItem extends DataGridItem>({\n column,\n item,\n}: DataGridBodyCellContentProps<TItem>) {\n // Column-specific render function takes priority\n if (column.render) {\n if (typeof column.render === 'function') {\n return <>{column.render(item)}</>;\n }\n return <>{column.render}</>;\n }\n\n // Column-specific component\n if (column.component) {\n const CellComponent = column.component;\n const key = column.key ?? column.id;\n const value = key.includes('.') ? getNestedValue(item, key) : item[key];\n return <CellComponent item={item} column={column} value={value} />;\n }\n\n // Default: resolve value from key (shared with the `title` fallback in DataGridRow)\n return <>{resolveCellDisplayValue(column, item)}</>;\n}\n","import type { ReactNode } from 'react';\n\ninterface DataGridContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridContent({ children }: DataGridContentProps) {\n return <>{children}</>;\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { resolveLabel } from '../table-helpers';\nimport type { DataGridTableColumn } from '../table-types';\n\ninterface DataGridHeaderCellLabelProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n}\n\nexport function DataGridHeaderCellLabel<TItem extends DataGridItem>({\n column,\n}: DataGridHeaderCellLabelProps<TItem>) {\n return <span>{resolveLabel(column.label)}</span>;\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport { useDataGridContext } from '../core/data-grid-context';\nimport type { TableService } from './table-types';\n\nexport function useTableService<\n TItem extends DataGridItem = DataGridItem,\n>(): TableService<TItem> {\n return useDataGridContext<TItem>().table;\n}\n","import type { ReactNode } from 'react';\nimport styles from './data-grid-header-cell.module.css';\n\ninterface DataGridHeaderCellContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridHeaderCellContent({ children }: DataGridHeaderCellContentProps) {\n return <span className={styles.headerCellContent}>{children}</span>;\n}\n","import { cx } from 'class-variance-authority';\nimport { TableHead } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport { resolveLabel } from '../table-helpers';\nimport type { DataGridTableGroup } from '../table-types';\nimport styles from './data-grid-cell.module.css';\nimport headerStyles from './data-grid-header-cell.module.css';\nimport { DataGridHeaderCellContent } from './data-grid-header-cell-content';\n\ninterface DataGridHeaderGroupProps<TItem extends DataGridItem> {\n group: DataGridTableGroup<TItem>;\n colspan?: number;\n className?: string;\n}\n\nexport function DataGridHeaderGroup<TItem extends DataGridItem>({\n group,\n colspan,\n className,\n}: DataGridHeaderGroupProps<TItem>) {\n const tableService = useTableService<TItem>();\n\n const stickyOffset = tableService.useGroupStickyOffset(group.id);\n const stickyHeader = tableService.useStickyHeader();\n const isSticky = stickyOffset !== undefined;\n\n const GroupContent = group.component;\n\n const content = GroupContent ? (\n <GroupContent group={group} />\n ) : (\n <DataGridHeaderCellContent>{resolveLabel(group.label)}</DataGridHeaderCellContent>\n );\n\n return (\n <TableHead\n className={cx(\n styles.cell,\n headerStyles.headerCell,\n isSticky && styles.stickyCell,\n stickyHeader && styles.stickyHeaderCell,\n className,\n )}\n style={isSticky ? { position: 'sticky', insetInlineStart: `${stickyOffset}px` } : undefined}\n scope=\"col\"\n colSpan={colspan}\n >\n {content}\n </TableHead>\n );\n}\n","import { createContext, useContext } from 'react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridRecord } from '../storage/storage-types';\n\nconst DataGridRecordContext = createContext<DataGridRecord | null>(null);\n\nexport const DataGridRecordProvider = DataGridRecordContext.Provider;\n\nexport function useDataGridRecord<\n TItem extends DataGridItem = DataGridItem,\n>(): DataGridRecord<TItem> {\n const record = useContext(DataGridRecordContext);\n if (!record) {\n throw new Error('useDataGridRecord must be used within a DataGridRow');\n }\n return record as DataGridRecord<TItem>;\n}\n","import type { CSSProperties } from 'react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridTableColumn, DataGridTableLayout } from './table-types';\n\n/**\n * Internal CSS var carrying the `tableLayout=\"auto\"` `maxWidth` cap into the per-row content-cap\n * wrapper (`DataGridCell`'s `.content` span). Not documented as public API.\n */\nexport const DATA_GRID_COLUMN_MAX_WIDTH_VAR = '--_data-grid-col-max';\n\nexport interface ResolvedColumnStyle {\n /**\n * `width`/`minWidth`/`maxWidth` mapped to CSS for the header `<th>`. Body cells intentionally\n * receive no box sizing from this — width lives on the header only, since the table already\n * shares one track per column.\n */\n headerStyle: CSSProperties;\n /**\n * Content-cap CSS var(s) needed by the per-row overflow wrapper. Applied on both header and\n * body cells: a CSS custom property set via inline style on one row's `<td>` does not reach a\n * sibling row's `<td>` for the same column, so each row needs its own copy.\n */\n contentVars: CSSProperties;\n /**\n * Whether `maxWidth` is a real, active cap (`tableLayout=\"auto\"` with `maxWidth` set) that the\n * content wrapper's CSS must enforce regardless of overflow mode — `nowrap` reads the cap var\n * directly (mode-agnostic), `wrap` needs this flag to also force word-breaking, so the column\n * never grows past the cap. Always `false` under `tableLayout=\"fixed\"`, where `maxWidth`\n * aliases into the shared track instead.\n */\n isCapped: boolean;\n}\n\ntype ColumnWidthProps<TItem extends DataGridItem> = Pick<\n DataGridTableColumn<TItem>,\n 'width' | 'minWidth' | 'maxWidth'\n>;\n\nfunction isPercent(value: number | string): value is string {\n return typeof value === 'string' && value.trim().endsWith('%');\n}\n\nfunction toLength(value: number | string): string {\n if (typeof value === 'number') return `${value}px`;\n return /^-?\\d+(\\.\\d+)?$/.test(value.trim()) ? `${value}px` : value;\n}\n\n/**\n * Single source of CSS for column `width`/`minWidth`/`maxWidth`, branching on `tableLayout`.\n *\n * - `fixed`: the three props collapse to one shared track. `width` wins when present; a lone\n * `minWidth`/`maxWidth` aliases to the track. (Detecting the contradictory combination — width\n * set alongside `minWidth`/`maxWidth` — is a DEV-only warning emitted separately at column\n * ingestion; this function stays pure and has no side effects.) `width: 'min-content'` opts the\n * column into the same measurement pipeline as under `auto` (see below) -- once\n * `DataGridHeaderCell`'s ResizeObserver has measured it, the pixel value becomes this column's\n * track, same as a literal numeric `width`.\n * - `auto`: the three are independent constraints — `width` sets a preferred size and, absent an\n * explicit `minWidth`, an implicit floor at that same size; `minWidth` is the floor; `maxWidth`\n * is a real cap. A `maxWidth`-without-`width` column also gets its header `width` set to the\n * cap so it stops absorbing container slack under `inline-size: 100%` fill, and `maxWidth`\n * always drives the content-cap CSS var read by the per-row wrapper. `width: 'min-content'` is\n * special-cased: the literal CSS keyword isn't honored by the browser's auto table-layout\n * algorithm as a hint to hold this column narrow against a widthless sibling, so\n * `minContentWidth` (a measured pixel value from `DataGridHeaderCell`'s ResizeObserver, via\n * `table-min-content-width.ts`) stands in for it once measurement has landed.\n *\n * Before the first measurement lands: under `auto`, the raw `'min-content'` keyword still flows\n * through as an inert one-frame fallback (harmless -- the browser ignores it as a `width`/\n * `min-inline-size` value and the column renders under ordinary layout sizing until the\n * ResizeObserver's first callback fires); under `fixed`, the width is simply unset instead\n * (falls to a lone `minWidth`/`maxWidth` alias, or no track at all).\n *\n * `%` strings map to `inline-size`; any other value maps to `width` + `min-inline-size`.\n */\nexport function resolveColumnStyle<TItem extends DataGridItem>(\n column: ColumnWidthProps<TItem>,\n tableLayout: DataGridTableLayout,\n minContentWidth?: number,\n): ResolvedColumnStyle {\n return tableLayout === 'auto'\n ? resolveAutoStyle(column, minContentWidth)\n : resolveFixedStyle(column, minContentWidth);\n}\n\nfunction resolveFixedStyle<TItem extends DataGridItem>(\n column: ColumnWidthProps<TItem>,\n minContentWidth?: number,\n): ResolvedColumnStyle {\n // `'min-content'` resolves from the measured pixel value once it lands (see the function-level\n // doc above) -- exactly like a literal numeric `width` from here on, including winning over\n // `minWidth`/`maxWidth` in the single-track collapse below. Before measurement, it falls back\n // to the `minWidth`/`maxWidth` alias (or no track at all).\n const width: number | string | undefined =\n column.width === 'min-content' ? minContentWidth : column.width;\n const track = width ?? column.minWidth ?? column.maxWidth;\n if (track === undefined) return { headerStyle: {}, contentVars: {}, isCapped: false };\n\n if (isPercent(track)) {\n return { headerStyle: { inlineSize: track }, contentVars: {}, isCapped: false };\n }\n\n const length = toLength(track);\n return {\n headerStyle: { width: length, minInlineSize: length },\n contentVars: {},\n isCapped: false,\n };\n}\n\nfunction resolveAutoStyle<TItem extends DataGridItem>(\n column: ColumnWidthProps<TItem>,\n minContentWidth?: number,\n): ResolvedColumnStyle {\n const { width, minWidth, maxWidth } = column;\n const headerStyle: CSSProperties = {};\n\n if (width !== undefined) {\n // The literal CSS `min-content` keyword isn't honored by the browser's auto table-layout\n // algorithm as a hint to hold this column narrow against a widthless sibling -- once\n // `DataGridHeaderCell`'s ResizeObserver has measured the header content's natural width, that\n // pixel value stands in for the keyword here, exactly like an ordinary numeric `width` (same\n // width + floor pattern below). Checked ahead of `isPercent` purely so its `value is string`\n // guard doesn't narrow `width` to `number`-only in the `else` branch below (a `'min-content'`\n // check there wouldn't type-check). Before the first measurement lands, the raw keyword still\n // flows through via `toLength` as an inert fallback (harmless -- the browser ignores it and\n // the column renders under ordinary auto-layout sizing for one frame).\n if (width === 'min-content' && minContentWidth !== undefined) {\n // A `maxWidth` cap still applies to a measured min-content column -- without this, the\n // header track could exceed its own cap (the measured value is a natural content size, not\n // itself capped) while the per-row content wrapper below enforces the cap independently,\n // leaving the two out of sync.\n const cappedWidth =\n maxWidth !== undefined ? Math.min(minContentWidth, maxWidth) : minContentWidth;\n const length = `${cappedWidth}px`;\n headerStyle.width = length;\n headerStyle.minInlineSize = length;\n } else if (isPercent(width)) {\n headerStyle.inlineSize = width;\n } else {\n const length = toLength(width);\n headerStyle.width = length;\n headerStyle.minInlineSize = length; // preferred size doubles as the floor by default\n }\n }\n\n if (minWidth !== undefined) {\n headerStyle.minInlineSize = `${minWidth}px`; // explicit floor overrides width's implicit one\n }\n\n const contentVars: CSSProperties = {};\n if (maxWidth !== undefined) {\n if (width === undefined) {\n // A widthless-but-capped column still absorbs container slack under `inline-size: 100%`\n // fill — give the header a width so the cap actually holds instead of leaving dead space.\n headerStyle.width = `${maxWidth}px`;\n }\n (contentVars as Record<string, string>)[DATA_GRID_COLUMN_MAX_WIDTH_VAR] = `${maxWidth}px`;\n }\n\n return { headerStyle, contentVars, isCapped: maxWidth !== undefined };\n}\n","import type { CSSProperties } from 'react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport { resolveColumnStyle } from './resolve-column-style';\nimport { resolveCellDisplayValue } from './table-helpers';\nimport type { DataGridTableColumn, DataGridTableColumnOverflow, DataGridTableLayout } from './table-types';\n\nexport interface ResolvedBodyCellProps {\n /** Content-cap CSS var(s) forwarded to `DataGridCell`'s `style` prop -- see `resolveColumnStyle`. */\n style: CSSProperties;\n /** Drives `DataGridCell`'s `data-overflow` attribute; defaults to `'wrap'` when unset on the column. */\n overflow: DataGridTableColumnOverflow;\n /** Whether a real, active `maxWidth` cap applies -- forwarded to `DataGridCell`'s `capped` prop. */\n capped: boolean;\n /** Stringified cell value for the native `title` tooltip, or `undefined` when there's none to show. */\n title: string | undefined;\n}\n\n/**\n * Single source of the per-cell overflow/width props a body row forwards to `DataGridCell`, kept\n * apart from `DataGridRow` so the derivation is pure and can be tested without rendering a row.\n *\n * Pure: `useTableLayout()` stays a hook call at each call site, its result passed in here.\n */\nexport function resolveBodyCellProps<TItem extends DataGridItem>(\n column: DataGridTableColumn<TItem>,\n item: TItem,\n tableLayout: DataGridTableLayout,\n): ResolvedBodyCellProps {\n const overflow = column.cellOverflow ?? 'wrap';\n // Width lives on the header only -- the column already shares one track from there. Body cells\n // only need the content-cap var (auto mode + maxWidth) for their own per-row overflow wrapper.\n const { contentVars, isCapped } = resolveColumnStyle(column, tableLayout);\n // Custom `component`/`render` output can't be safely stringified -- the kit can't supply a\n // title fallback for it, so resolveCellDisplayValue returns undefined there. `nowrap` is the\n // clipping mode (single line, ellipsis on overflow) -- `wrap` never clips.\n const displayValue = overflow === 'nowrap' ? resolveCellDisplayValue(column, item) : undefined;\n // An empty stringified value (e.g. `null`) must not become an empty `title=\"\"` attribute --\n // only set `title` when there's real content to show.\n const title = displayValue ? displayValue : undefined;\n\n return { style: contentVars, overflow, capped: isCapped, title };\n}\n","/*\n * Marks a cell that a plugin reacting to row clicks must not treat as a row click. It lives in the\n * core because the cell renderer stamps it, and the core's entry must not import a plugin to do\n * that (see `services/layout/layout-slot-ids.ts` for the same split).\n */\nexport const IGNORE_CLICK_ATTRIBUTE = 'data-grid-row-ignore-click';\n","import type { CSSProperties, ReactNode, Ref } from 'react';\nimport { cx } from 'class-variance-authority';\nimport { TableCell, TableHead } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { IGNORE_CLICK_ATTRIBUTE } from '../ignore-row-click';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableColumnOverflow } from '../table-types';\nimport styles from './data-grid-cell.module.css';\n\ninterface DataGridCellProps {\n columnId: string;\n rowspan?: number;\n className?: string;\n style?: CSSProperties;\n width?: string | number;\n children?: ReactNode;\n /** Renders a column header (`<th>`) instead of a body cell (`<td>`). */\n header?: boolean;\n /**\n * Rendered after the overflow-controlled content, outside its clipping contract — used by\n * header cells for the sort-icon / header-cell-end slot, which must stay visible even when the\n * label ellipsizes. Body cells don't pass this.\n */\n endSlot?: ReactNode;\n /** Drives the shared `data-overflow` attribute that both header and body overflow CSS key off. */\n overflow?: DataGridTableColumnOverflow;\n /**\n * Whether `resolveColumnStyle` resolved a real, active `maxWidth` cap for this column (only\n * possible under `tableLayout=\"auto\"`). Drives `data-capped`, which the overflow CSS uses to\n * enforce the cap for `wrap` too -- `nowrap` already reads the cap var directly (mode-agnostic)\n * -- so the column never grows past `maxWidth` regardless of how it wraps.\n */\n capped?: boolean;\n title?: string;\n /**\n * Ref onto the `.contentRow` wrapper -- used by `DataGridHeaderCell` to measure a\n * `width: 'min-content'` column's natural content width, under either `tableLayout` (its own\n * `inline-size: min-content` CSS below makes it shrink-wrap regardless of whatever width the\n * `<th>` itself ends up with, so it's a safe, unstretched measurement target -- see\n * `DataGridHeaderCell` for the ResizeObserver that reads it). Only rendered when `endSlot` is\n * passed, which header cells always do; body cells never pass this ref.\n */\n contentRowRef?: Ref<HTMLSpanElement>;\n /**\n * Whether this header cell's content should fill `.contentRow` instead of shrink-wrapping it,\n * via `data-header-fill` (see data-grid-cell.module.css). Set by `DataGridHeaderCell` only for a\n * custom `headerComponent` (e.g. a select-all checkbox) on a non-min-content column -- that kind\n * of header needs to fill/center like a body cell rather than hug its own min-content width the\n * way a default text label does. Body cells and min-content columns never set this (a min-content\n * column's `.contentRow` doubles as its ResizeObserver measurement target and must keep\n * shrink-wrapping).\n */\n fillContent?: boolean;\n /**\n * When `true`, stamps `data-grid-row-ignore-click` onto the cell element so a plugin that reacts\n * to row clicks can skip clicks anywhere in the cell. Set by extra columns that opt out of row\n * clicks (e.g. a column holding a checkbox).\n */\n ignoreRowClick?: boolean;\n}\n\n// A bare number, or a string holding one, is a pixel width; anything else (`%`, `rem`) is already\n// a CSS length.\nfunction normalizeWidth(width: string | number | undefined): string | undefined {\n if (width == null) return undefined;\n if (typeof width === 'number') return `${width}px`;\n return !isNaN(Number(width)) ? `${width}px` : width;\n}\n\nexport function DataGridCell<TItem extends DataGridItem = DataGridItem>({\n columnId,\n rowspan,\n className,\n style,\n width,\n children,\n header,\n endSlot,\n overflow,\n capped,\n title,\n contentRowRef,\n fillContent,\n ignoreRowClick,\n}: DataGridCellProps) {\n const tableService = useTableService<TItem>();\n\n const stickyOffset = tableService.useColumnStickyOffset(columnId);\n const endStickyOffset = tableService.useColumnEndStickyOffset(columnId);\n\n const isSticky = stickyOffset !== undefined;\n // Extra columns are never in the table's own sticky map, so a pinned `end` column can only ever\n // be one of these two, never both -- it pins to the opposite edge and stays out of the\n // start-side run rather than being parked against it.\n const isStickyEnd = endStickyOffset !== undefined;\n\n const content = <span className={styles.content}>{children}</span>;\n const Cell = header ? TableHead : TableCell;\n const normalizedWidth = normalizeWidth(width);\n\n return (\n <Cell\n data-column-id={columnId}\n data-overflow={overflow}\n data-capped={capped || undefined}\n data-header-fill={fillContent || undefined}\n {...(ignoreRowClick && { [IGNORE_CLICK_ATTRIBUTE]: '' })}\n title={title}\n className={cx(styles.cell, (isSticky || isStickyEnd) && styles.stickyCell, className)}\n style={{\n ...style,\n ...(normalizedWidth ? { width: normalizedWidth } : {}),\n ...(isSticky ? { position: 'sticky', insetInlineStart: `${stickyOffset}px` } : {}),\n ...(isStickyEnd ? { position: 'sticky', insetInlineEnd: `${endStickyOffset}px` } : {}),\n }}\n scope={header ? 'col' : undefined}\n rowSpan={rowspan}\n >\n {endSlot ? (\n <span className={styles.contentRow} ref={contentRowRef}>\n {content}\n <span className={styles.endSlot}>{endSlot}</span>\n </span>\n ) : (\n content\n )}\n </Cell>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { ExtraColumnPosition } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\n\ninterface DataGridExtraBodyColumnsProps {\n position: ExtraColumnPosition;\n}\n\nexport function DataGridExtraBodyColumns<TItem extends DataGridItem = DataGridItem>({\n position,\n}: DataGridExtraBodyColumnsProps) {\n const tableService = useTableService<TItem>();\n const extraColumns = tableService.useExtraColumns(position);\n\n return (\n <>\n {extraColumns.map((extra) => (\n <DataGridCell\n key={extra.id}\n columnId={extra.id}\n width={extra.width}\n ignoreRowClick={extra.ignoreRowClick}\n >\n {extra.body ? <extra.body /> : null}\n </DataGridCell>\n ))}\n </>\n );\n}\n","import { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { DataGridRecordProvider } from '../data-grid-record-context';\nimport { resolveBodyCellProps } from '../resolve-body-cell-props';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableColumn } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport { DataGridExtraBodyColumns } from './data-grid-extra-body-columns';\n\ninterface DataGridRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridRow<TItem extends DataGridItem>({ record }: DataGridRowProps<TItem>) {\n const tableService = useTableService<TItem>();\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n\n const BodyCellContent = tableService.useComponent<{ column: DataGridTableColumn<TItem>; item: TItem }>(\n 'body-cell-content',\n );\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow>\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n </DataGridRecordProvider>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { useTableService } from '../table-context';\n\ninterface DataGridTableRecordProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridTableRecord<TItem extends DataGridItem>({\n record,\n}: DataGridTableRecordProps<TItem>) {\n const tableService = useTableService<TItem>();\n const RowComponent = tableService.useComponent<DataGridTableRecordProps<TItem>>('row');\n\n // eslint-disable-next-line react-hooks/static-components -- RowComponent comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n return <RowComponent record={record} />;\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { DataGridTableRecord } from './data-grid-table-record';\n\ninterface DataGridTableRecordsProps<TItem extends DataGridItem> {\n records: DataGridRecord<TItem>[];\n}\n\nexport function DataGridTableRecords<TItem extends DataGridItem>({\n records,\n}: DataGridTableRecordsProps<TItem>) {\n return (\n <>\n {records.map((record) => (\n <DataGridTableRecord<TItem> key={record.id} record={record} />\n ))}\n </>\n );\n}\n","import { TableBody } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../core/data-grid-context';\nimport { DataGridTableRecords } from './data-grid-table-records';\n\nexport function DataGridTableBody<TItem extends DataGridItem>() {\n const grid = useDataGrid<TItem>();\n const rootSections = grid.useStore((s) => s.rootSections);\n\n return (\n <>\n {rootSections.map((section) => (\n <TableBody key={section.id}>\n <DataGridTableRecords<TItem> records={section.records} />\n </TableBody>\n ))}\n </>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cx } from 'class-variance-authority';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { ExtraColumn } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport cellStyles from './data-grid-cell.module.css';\nimport styles from './data-grid-header-cell.module.css';\nimport { DataGridHeaderCellContent } from './data-grid-header-cell-content';\n\ninterface DataGridExtraHeaderCellProps {\n column: ExtraColumn;\n rowspan?: number;\n className?: string;\n children?: ReactNode;\n}\n\nexport function DataGridExtraHeaderCell<TItem extends DataGridItem>({\n column,\n rowspan,\n className,\n children,\n}: DataGridExtraHeaderCellProps) {\n const tableService = useTableService<TItem>();\n const stickyHeader = tableService.useStickyHeader();\n\n return (\n <DataGridCell<TItem>\n header\n columnId={column.id}\n className={cx(styles.extraHeaderCell, stickyHeader && cellStyles.stickyHeaderCell, className)}\n width={column.width}\n rowspan={rowspan}\n ignoreRowClick={column.ignoreRowClick}\n >\n {children ? <DataGridHeaderCellContent>{children}</DataGridHeaderCellContent> : null}\n </DataGridCell>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { ExtraColumnPosition } from '../table-types';\nimport { DataGridExtraHeaderCell } from './data-grid-extra-header-cell';\n\ninterface DataGridExtraHeaderColumnsProps {\n position: ExtraColumnPosition;\n isGroupRow?: boolean;\n className?: string;\n}\n\nexport function DataGridExtraHeaderColumns<TItem extends DataGridItem>({\n position,\n isGroupRow,\n className,\n}: DataGridExtraHeaderColumnsProps) {\n const tableService = useTableService<TItem>();\n const hasGroups = tableService.useHasGroups();\n const extraColumns = tableService.useExtraColumns(position);\n\n // When groups exist, extra columns should only render on the group row\n const shouldRender = !hasGroups || isGroupRow;\n\n return (\n <>\n {extraColumns.map((extra) => (\n <DataGridExtraHeaderCell<TItem>\n key={extra.id}\n column={extra}\n rowspan={shouldRender && hasGroups ? 2 : undefined}\n className={className}\n >\n {shouldRender && extra.header ? <extra.header /> : null}\n </DataGridExtraHeaderCell>\n ))}\n </>\n );\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStore } from './table-types';\n\n/**\n * Store-backed home for the measured pixel width of columns whose `width` is `'min-content'`,\n * under either `tableLayout`. `DataGridHeaderCell` measures its header content's natural size\n * with a ResizeObserver and calls `setMinContentWidth`; `resolveColumnStyle` reads it back via\n * `useMinContentWidth` to size the column's track -- under `auto`, the literal CSS `min-content`\n * keyword isn't honored by the browser's algorithm as a hint to hold a column narrow against a\n * widthless sibling; under `fixed`, there is no content-driven sizing at all, so the keyword has\n * nothing to act on either way. A measured pixel value stands in for it in both modes.\n *\n * `setMinContentWidth` skips the store write when the measured value hasn't changed. This is the\n * loop guard: the measured value drives the column's own CSS width, so an unconditional write on\n * every ResizeObserver callback would risk apply-width -> relayout -> re-measure -> apply-width\n * spinning forever. (The measurement target itself is also chosen to be size-independent of the\n * column's own width -- see `DataGridHeaderCell` -- so in practice this dedup is a backstop, not\n * the only thing preventing a loop.)\n */\nexport function prepareTableMinContentWidth<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n setMinContentWidth,\n useMinContentWidth,\n };\n\n function setMinContentWidth(columnId: string, width: number) {\n const current = useTableStore.getState().minContentWidths;\n if (current.get(columnId) === width) return;\n\n const next = new Map(current);\n next.set(columnId, width);\n useTableStore.setState({ minContentWidths: next });\n }\n\n function useMinContentWidth(columnId: string): number | undefined {\n return useTableStore((state) => state.minContentWidths.get(columnId));\n }\n}\n\n/**\n * Computes the pixel width to apply to a `width: 'min-content'` column's header `<th>` from a\n * ResizeObserver entry on its `.contentRow` wrapper (see `DataGridHeaderCell`'s measurement\n * effect) -- the wrapper's own `inline-size: min-content` CSS keeps its measured content-box size\n * independent of whatever width the `<th>` itself currently has, so this reads the column's true\n * natural content width regardless of where in the measure -> apply -> re-render cycle it's\n * called (see the loop-safety note on `setMinContentWidth` above). Adds the cell's own\n * padding/border (cells are `border-box`) so the applied width holds the full, unclipped content,\n * and rounds up to guard against sub-pixel drift across repeated measurements of the same content.\n */\nexport function measureMinContentWidth(entry: ResizeObserverEntry, cell: Element | null): number {\n const computedStyle = cell ? window.getComputedStyle(cell) : undefined;\n const paddings = computedStyle\n ? parseFloat(computedStyle.paddingInlineStart || '0') +\n parseFloat(computedStyle.paddingInlineEnd || '0')\n : 0;\n const borders = computedStyle\n ? parseFloat(computedStyle.borderInlineStartWidth || '0') +\n parseFloat(computedStyle.borderInlineEndWidth || '0')\n : 0;\n\n return Math.ceil(entry.contentRect.width + paddings + borders);\n}\n","import { useEffect, useRef } from 'react';\nimport { cx } from 'class-variance-authority';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { resolveColumnStyle } from '../resolve-column-style';\nimport { useTableService } from '../table-context';\nimport { resolveLabel } from '../table-helpers';\nimport { measureMinContentWidth } from '../table-min-content-width';\nimport type { DataGridTableColumn, TableSlot } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport cellStyles from './data-grid-cell.module.css';\nimport styles from './data-grid-header-cell.module.css';\n\ninterface DataGridHeaderCellProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n rowspan?: number;\n headerCellEndSlots: TableSlot[];\n className?: string;\n}\n\nexport function DataGridHeaderCell<TItem extends DataGridItem>({\n column,\n rowspan,\n headerCellEndSlots,\n className,\n}: DataGridHeaderCellProps<TItem>) {\n const tableService = useTableService<TItem>();\n const contentRowRef = useRef<HTMLSpanElement>(null);\n\n const LabelComponent = tableService.useComponent<{ column: DataGridTableColumn<TItem> }>('header-cell-label');\n const tableLayout = tableService.useTableLayout();\n const stickyHeader = tableService.useStickyHeader();\n const minContentWidth = tableService.useMinContentWidth(column.id);\n\n const content = column.headerComponent ? (\n <column.headerComponent column={column} />\n ) : (\n // eslint-disable-next-line react-hooks/static-components -- LabelComponent comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n <LabelComponent column={column} />\n );\n\n const configuredHeaderOverflow = column.headerOverflow ?? 'nowrap';\n // Measured under both `tableLayout` modes -- `resolveColumnStyle` applies the result as this\n // column's `auto` size or its `fixed` track respectively (see its own doc for the branch).\n const isMinContentColumn = column.width === 'min-content';\n // A min-content column is, by definition, exactly as wide as its content needs -- there's\n // nothing to truncate. Disabling the ellipsis/nowrap overflow here also keeps `.contentRow`\n // unconstrained by the `max-inline-size: 100%` the nowrap CSS would otherwise apply (see\n // data-grid-cell.module.css), so the measurement effect below reads its true natural width\n // instead of one clamped to whatever width the column happens to have before the first\n // measurement lands. `title` still follows the column's actual configured overflow (below),\n // independent of this internal measurement-mode override.\n const cellOverflow = isMinContentColumn ? undefined : configuredHeaderOverflow;\n const { headerStyle, contentVars, isCapped } = resolveColumnStyle(\n column,\n tableLayout,\n minContentWidth,\n );\n // A custom headerComponent can render anything -- the kit can't stringify it for a title\n // fallback, so the consumer is responsible for their own (documented on DataGridTableColumn).\n // `nowrap` is the clipping mode (single line, ellipsis on overflow) -- `wrap` never clips.\n const title =\n !column.headerComponent && configuredHeaderOverflow === 'nowrap'\n ? resolveLabel(column.label)\n : undefined;\n // A custom headerComponent (e.g. a select-all checkbox) needs to fill/center like a body cell,\n // not shrink-wrap to its own min-content width the way a default text label does -- see\n // `fillContent`'s doc on `DataGridCell`. `headerCellEndSlots` is table-wide (non-empty for every\n // column once a plugin like order registers a slot, even though `DataGridOrderIcon` only\n // renders for the one actively-sorted column), so it's the wrong signal for this: gating on it\n // would leave a custom header shrink-wrapped on any grid where such a plugin is registered.\n // `column.headerComponent` doesn't depend on which plugins are registered, so it handles both\n // the no-plugin and the with-plugin cases the same way. Excluded for min-content columns, whose\n // `.contentRow` must keep shrink-wrapping to stay an accurate ResizeObserver measurement target.\n // Edge case: a custom header on the actively-sorted column still gets a real end slot (the sort\n // arrow), which then sits at the filled row's far end instead of snug against the label --\n // accepted as a minor cosmetic tradeoff.\n const fillContent = Boolean(column.headerComponent) && !isMinContentColumn;\n\n // Measures `.contentRow`'s own natural (`inline-size: min-content`) width whenever it changes\n // and stores it as this column's resolved width (`resolveColumnStyle` reads it back above --\n // under `auto` as the column's size, under `fixed` as its shared track). This does not loop:\n // `.contentRow` renders at its own min-content size regardless of the `<th>`'s allocated width\n // -- under `auto` because a browser's auto table-layout algorithm doesn't stretch or shrink an\n // ordinary `inline-size: min-content` child to match its ancestor cell, and under `fixed`\n // because the `<th>`'s box (sized by the fixed track algorithm from the *header row*, before\n // any of this observer's writes land) never forces an ordinary content child to match it either\n // -- a `<th>` wider than its content just leaves the child at its own size. So applying the\n // measured width to the `<th>` never changes what this observer sees on a later fire, in either\n // mode; `setMinContentWidth` also skips the store write (and the re-render that would otherwise\n // trigger another observer callback) when the measured value hasn't changed. A genuine\n // ResizeObserver (not a one-off measurement at mount) also means this re-measures correctly if\n // CSS lands after mount (e.g. a consumer's prod bundle injecting a stylesheet `<link>`\n // post-mount), since that changes `.contentRow`'s rendered size and\n // re-fires the observer.\n useEffect(() => {\n if (!isMinContentColumn) return;\n\n const contentRow = contentRowRef.current;\n if (!contentRow) return;\n\n const cell = contentRow.closest('th, td');\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n tableService.setMinContentWidth(column.id, measureMinContentWidth(entry, cell));\n });\n observer.observe(contentRow);\n\n return () => observer.disconnect();\n }, [isMinContentColumn, column.id, tableService]);\n\n return (\n <DataGridCell\n header\n columnId={column.id}\n className={cx(styles.headerCell, stickyHeader && cellStyles.stickyHeaderCell, className)}\n style={{ ...headerStyle, ...contentVars }}\n rowspan={rowspan}\n overflow={cellOverflow}\n // Same measurement rationale as `cellOverflow` above: `[data-capped] .contentRow` also\n // clamps to `max-inline-size: 100%`, which would re-clamp the measurement target to the\n // `<th>`'s current (possibly stale/narrow) width -- suppressing it here keeps the\n // ResizeObserver reading the column's true natural width. Body cells are unaffected: they\n // resolve their own `capped` independently via `resolveBodyCellProps`.\n capped={isMinContentColumn ? undefined : isCapped}\n title={title}\n contentRowRef={isMinContentColumn ? contentRowRef : undefined}\n fillContent={fillContent}\n endSlot={headerCellEndSlots.map((slot) => {\n const SlotComponent = slot.component;\n return <SlotComponent key={slot.id} column={column} />;\n })}\n >\n {content}\n </DataGridCell>\n );\n}\n","import { useEffect, useRef } from 'react';\nimport { cx } from 'class-variance-authority';\nimport { TableHeader, TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableColumn, DataGridTableGroup } from '../table-types';\nimport { DataGridExtraHeaderColumns } from './data-grid-extra-header-columns';\nimport { DataGridHeaderCell } from './data-grid-header-cell';\nimport { DataGridHeaderGroup } from './data-grid-header-group';\nimport styles from './data-grid-table-header.module.css';\n\nexport function DataGridTableHeader<TItem extends DataGridItem>() {\n const tableService = useTableService<TItem>();\n const theadRef = useRef<HTMLTableSectionElement>(null);\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const hasGroups = tableService.useHasGroups();\n const stickyHeader = tableService.useStickyHeader();\n const firstRowCells = tableService.useFirstRowHeaderCells();\n const secondRowColumns = tableService.useSecondRowHeaderColumns();\n const headerCellEndSlots = tableService.useSlots('header-cell-end');\n\n // Set up shared ResizeObserver for all header cells\n useEffect(() => {\n const thead = theadRef.current;\n if (!thead) return;\n\n observerRef.current = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const { columnId } = (entry.target as HTMLElement).dataset;\n if (columnId) {\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n tableService.onResizeColumn(columnId, width);\n }\n }\n });\n\n const cells = thead.querySelectorAll<HTMLElement>('[data-column-id]');\n for (const cell of cells) {\n observerRef.current.observe(cell);\n }\n\n return () => {\n observerRef.current?.disconnect();\n };\n }, [tableService, firstRowCells, secondRowColumns]);\n\n return (\n <TableHeader\n ref={theadRef}\n className={cx(stickyHeader && hasGroups && styles.theadSticky)}\n >\n <TableRow>\n <DataGridExtraHeaderColumns<TItem> position=\"start\" isGroupRow />\n\n {firstRowCells.map((cell) => {\n if (cell.type === 'group') {\n const group = cell.item as DataGridTableGroup<TItem>;\n return (\n <DataGridHeaderGroup<TItem> key={group.id} group={group} colspan={cell.colspan} />\n );\n }\n\n const column = cell.item as DataGridTableColumn<TItem>;\n return (\n <DataGridHeaderCell<TItem>\n key={column.id}\n column={column}\n rowspan={cell.rowspan}\n headerCellEndSlots={headerCellEndSlots}\n />\n );\n })}\n\n <DataGridExtraHeaderColumns<TItem> position=\"end\" isGroupRow />\n </TableRow>\n\n {/* Second row for grouped columns */}\n {hasGroups && secondRowColumns.length > 0 && (\n <TableRow>\n {secondRowColumns.map((column) => (\n <DataGridHeaderCell<TItem>\n key={column.id}\n column={column}\n headerCellEndSlots={headerCellEndSlots}\n />\n ))}\n </TableRow>\n )}\n </TableHeader>\n );\n}\n","import type { TableSlot } from '../table-types';\n\ninterface DataGridTableSlotProps {\n slots: TableSlot[];\n}\n\nexport function DataGridTableSlot({ slots }: DataGridTableSlotProps) {\n if (slots.length === 0) return null;\n\n return (\n <>\n {slots.map((slot) => {\n const SlotComponent = slot.component;\n return <SlotComponent key={slot.id} />;\n })}\n </>\n );\n}\n","import { cx } from 'class-variance-authority';\nimport type { ReactNode } from 'react';\nimport { Table } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableLayout } from '../table-types';\nimport styles from './data-grid-table.module.css';\nimport { DataGridTableBody } from './data-grid-table-body';\nimport { DataGridTableHeader } from './data-grid-table-header';\nimport { DataGridTableSlot } from './data-grid-table-slot';\n\nconst layoutClassMap: Record<DataGridTableLayout, string> = {\n fixed: styles.layoutFixed,\n auto: styles.layoutAuto,\n};\n\nexport function DataGridTable<TItem extends DataGridItem>() {\n const tableService = useTableService<TItem>();\n\n const hasGroups = tableService.useHasGroups();\n const subheaderSlots = tableService.useSlots('subheader');\n const footerSlots = tableService.useSlots('footer');\n const tableLayout = tableService.useTableLayout();\n const stickyHeader = tableService.useStickyHeader();\n\n const ContentWrapper = tableService.useComponent<{ children?: ReactNode }>('content');\n\n return (\n // eslint-disable-next-line react-hooks/static-components -- ContentWrapper comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n <ContentWrapper>\n <Table\n stickyHeader={stickyHeader}\n containerClassName={styles.tableWrapper}\n className={cx(styles.table, layoutClassMap[tableLayout], hasGroups && styles.tableBordered)}\n >\n <DataGridTableHeader />\n <DataGridTableSlot slots={subheaderSlots} />\n <DataGridTableBody />\n <DataGridTableSlot slots={footerSlots} />\n </Table>\n </ContentWrapper>\n );\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableColumnsPersistence } from './table-columns-persistence';\nimport type { TableStickyService } from './table-sticky';\nimport type { DataGridTableColumn, DataGridTableGroup, DataGridTableLayout, TableStore } from './table-types';\nimport { isTableGroup } from './table-types';\n\nconst snakeCaseRe = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;\n\nexport function prepareTableColumns<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n stickyApi: TableStickyService<TItem>,\n persistence?: TableColumnsPersistence,\n) {\n // DEV-only \"warn once per column id\" throttles -- the columns effect re-fires on every new\n // `columns` array identity, and these must not spam on every re-render.\n const widthContradictionWarned = new Set<string>();\n const headerTruncateDeprecationWarned = new Set<string>();\n // Grid-level (not per-column) warn -- fires at most once for this grid instance's lifetime.\n let allColumnsCappedWarned = false;\n\n return {\n initializeColumns,\n useVisibleColumns,\n };\n\n function assertColumnId(id: string): void {\n if (!snakeCaseRe.test(id)) {\n throw new Error(`Column id \"${id}\" must be snake_case (e.g., \"user_name\", \"is_active\").`);\n }\n }\n\n /**\n * `headerTruncate` (deprecated) aliases to `headerOverflow: 'nowrap'` so every downstream\n * reader only ever sees `headerOverflow`. Returns the original column unchanged when no\n * normalization is needed, to avoid mutating/copying caller-owned column objects.\n */\n function normalizeColumn(col: DataGridTableColumn<TItem>): DataGridTableColumn<TItem> {\n if (!col.headerTruncate || col.headerOverflow !== undefined) return col;\n\n if (process.env.NODE_ENV !== 'production' && !headerTruncateDeprecationWarned.has(col.id)) {\n headerTruncateDeprecationWarned.add(col.id);\n console.warn(\n `[DataGrid] Column \"${col.id}\": \\`headerTruncate\\` is deprecated, use ` +\n \"`headerOverflow: 'nowrap'` instead. `headerTruncate` will be removed in a \" +\n 'future release.',\n );\n }\n\n return { ...col, headerOverflow: 'nowrap' };\n }\n\n /**\n * Under `tableLayout=\"fixed\"` the three width props collapse to a single track. Setting\n * `width` alongside `minWidth`/`maxWidth` -- or setting both `minWidth` and `maxWidth` without\n * a `width` to pick between them -- is a contradiction fixed layout cannot honor; a lone prop\n * is a valid track alias and does not warn. `width: 'min-content'` short-circuits this check\n * entirely -- it resolves via measurement rather than a literal author-set value (see\n * `resolveColumnStyle`), so pairing it with `minWidth`/`maxWidth` isn't flagged as the same\n * kind of contradiction.\n */\n function warnOnFixedModeWidthContradiction(\n col: DataGridTableColumn<TItem>,\n tableLayout: DataGridTableLayout,\n ) {\n if (tableLayout !== 'fixed') return;\n if (process.env.NODE_ENV === 'production') return;\n if (col.width === 'min-content') return;\n\n const definedCount = [col.width, col.minWidth, col.maxWidth].filter(\n (value) => value !== undefined,\n ).length;\n if (definedCount <= 1) return;\n if (widthContradictionWarned.has(col.id)) return;\n\n widthContradictionWarned.add(col.id);\n console.warn(\n `[DataGrid] Column \"${col.id}\": width, minWidth, and maxWidth cannot all apply under ` +\n 'tableLayout=\"fixed\" -- they collapse to a single track (width wins when set). Use ' +\n 'tableLayout=\"auto\" for independent min/max constraints, or drop the extra prop(s).',\n );\n }\n\n /**\n * Under `tableLayout=\"auto\"`, a column's `width`/`maxWidth` is a cap honored only when the\n * browser has slack to give it -- when EVERY column is constrained (a `width` or `maxWidth` of\n * its own) and the container is wider than their sum, there is no widthless column left to\n * absorb the extra space, so the browser grows every column past its cap and capped content\n * shows trailing blank space. This is an accepted, documented limitation (see data-grid.md); the\n * warning just points a dev at the fix.\n */\n function warnOnAllColumnsCappedUnderAuto(\n flatCols: DataGridTableColumn<TItem>[],\n tableLayout: DataGridTableLayout,\n ) {\n if (tableLayout !== 'auto') return;\n if (process.env.NODE_ENV === 'production') return;\n if (allColumnsCappedWarned) return;\n if (flatCols.length === 0) return;\n\n const allConstrained = flatCols.every(\n (col) => col.width !== undefined || col.maxWidth !== undefined,\n );\n if (!allConstrained) return;\n\n allColumnsCappedWarned = true;\n console.warn(\n '[DataGrid] Every column has a width or maxWidth under tableLayout=\"auto\" -- if the ' +\n 'container is wider than their sum, the browser will grow columns past their caps and ' +\n 'capped content will show trailing blank space. Leave at least one column without a ' +\n 'width/maxWidth to absorb the extra space.',\n );\n }\n\n function flattenColumns(\n columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[],\n ): DataGridTableColumn<TItem>[] {\n const result: DataGridTableColumn<TItem>[] = [];\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n for (const col of item.columns) {\n result.push(normalizeColumn({ ...col, groupId: item.id }));\n }\n } else {\n result.push(normalizeColumn(item));\n }\n }\n\n return result;\n }\n\n function initializeColumnVisibility(\n columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[],\n ): Map<string, boolean> {\n const map = new Map<string, boolean>();\n const lockedIds = new Set<string>();\n\n function register(col: DataGridTableColumn<TItem>) {\n map.set(col.id, col.visible ?? true);\n if (col.visibleToggleDisabled) {\n lockedIds.add(col.id);\n }\n }\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n for (const col of item.columns) {\n register(col);\n }\n } else {\n register(item);\n }\n }\n\n for (const [columnId, visible] of Object.entries(persistence?.read() ?? {})) {\n // A stored id for a column this grid no longer has is dropped rather than carried: the\n // grid's columns can change between releases, and the store outlives them.\n //\n // A column the grid marks `visibleToggleDisabled` is dropped too. Its visibility is the\n // grid's decision rather than the user's, and a stored `false` from before the grid locked\n // it would hide the column behind a toggle that can no longer bring it back.\n if (map.has(columnId) && !lockedIds.has(columnId)) {\n map.set(columnId, visible);\n }\n }\n\n return map;\n }\n\n function useVisibleColumns(): DataGridTableColumn<TItem>[] {\n return useTableStore(\n useShallow((s) => {\n const visible = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n return stickyApi.getOrderedColumnsWithSticky(visible, s.columnSticky);\n }),\n );\n }\n\n function initializeColumns(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]) {\n const flatCols = flattenColumns(columns);\n const { tableLayout } = useTableStore.getState();\n\n for (const col of flatCols) {\n assertColumnId(col.id);\n warnOnFixedModeWidthContradiction(col, tableLayout);\n }\n warnOnAllColumnsCappedUnderAuto(flatCols, tableLayout);\n\n return {\n columns,\n flatColumns: flatCols,\n columnVisibility: initializeColumnVisibility(columns),\n };\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\n\ninterface StoredColumnVisibility {\n columns?: unknown;\n}\n\nexport interface TableColumnsPersistence {\n /** The columns the user toggled, by id. Columns never toggled are absent. */\n read: () => Record<string, boolean>;\n record: (columnId: string, visible: boolean) => void;\n}\n\n/** Namespaced by the grid's `name`, so two grids on a page keep separate selections. */\nexport const COLUMN_VISIBILITY_KEY = 'columnVisibility';\n\n/**\n * Keeps the columns a user showed or hid, when the grid asked for it with\n * `persistentColumnVisibility`. Returns `undefined` otherwise, so a grid that did not opt in\n * registers no state and reads none.\n *\n * Pinned to `localStorage` whatever the grid's `persistent` setting is: a column selection is\n * how one person likes to read the table, not part of the view they would share by copying the\n * URL, so it sits beside filters that stay in the query string rather than displacing them.\n */\nexport function prepareTableColumnsPersistence<TItem extends DataGridItem = DataGridItem>(\n context: InternalContext<TItem>,\n): TableColumnsPersistence | undefined {\n if (!context.config.persistentColumnVisibility) return undefined;\n\n const state = context.persistentState.registerPersistentState<StoredColumnVisibility>(\n COLUMN_VISIBILITY_KEY,\n { storage: 'localStorage' },\n );\n\n return { read, record };\n\n // The stored value is whatever is in `localStorage`, which the user can edit, so it is\n // narrowed here rather than trusted: anything that is not a boolean under a string key is\n // dropped instead of being carried into the visibility map and written back on the next\n // toggle.\n function read(): Record<string, boolean> {\n const stored = state.value?.columns;\n if (typeof stored !== 'object' || stored === null || Array.isArray(stored)) return {};\n\n return Object.fromEntries(\n Object.entries(stored).filter(([, visible]) => typeof visible === 'boolean'),\n );\n }\n\n // Only the toggled column is written, so a column left alone keeps following whatever default\n // the grid configures for it -- including a later change to that default.\n function record(columnId: string, visible: boolean) {\n state.setValue({ columns: { ...read(), [columnId]: visible } });\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type {\n ExtraColumn,\n ExtraColumnOption,\n ExtraColumnPosition,\n TableStore,\n} from './table-types';\n\nexport function prepareTableExtraColumns<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n // DEV-only \"warn once per column id\" throttle -- `updateExtraColumnSticky` is called from a\n // plugin's `onPropsChange`, which runs on every re-render, so an unthrottled warning would spam.\n const startPinWarned = new Set<string>();\n\n return {\n registerExtraColumn,\n updateExtraColumnWidth,\n updateExtraColumnOrder,\n updateExtraColumnSticky,\n useExtraColumns,\n };\n\n function registerExtraColumn(option: ExtraColumnOption) {\n const store = useTableStore.getState();\n const position = option.position ?? 'end';\n const existing = position === 'start' ? store.extraColumnsStart : store.extraColumnsEnd;\n const order = option.order ?? (existing.length + 1) * 10;\n\n const newColumn: ExtraColumn = {\n id: option.id ?? Math.random().toString(36).slice(2),\n header: option.header,\n body: option.body,\n width: option.width,\n sticky: option.sticky,\n ignoreRowClick: option.ignoreRowClick,\n order,\n position,\n };\n\n const updated = [...existing, newColumn].sort((a, b) => a.order - b.order);\n\n if (position === 'start') {\n warnOnStartColumnPin(newColumn.id, newColumn.sticky);\n useTableStore.setState({ extraColumnsStart: updated });\n } else {\n useTableStore.setState({ extraColumnsEnd: updated });\n }\n }\n\n /**\n * `sticky` sits on `ExtraColumn`, which both positions share, but only `end` columns are ever\n * read for it: `getEndStickyOffset` walks `extraColumnsEnd` alone, and extra columns never enter\n * the table's `columnSticky` map. On a `start` column the flag reads like \"pin this\" and changes\n * nothing -- the field's JSDoc says so, but a caller who sets it does not see the JSDoc, they see\n * nothing happen.\n *\n * A DEV warning rather than a type that refuses the pairing: `position` is optional on\n * `ExtraColumnOption`, so a union discriminated on it would make every caller spell the\n * position out, and it still would not cover `updateExtraColumnSticky` -- that one takes a column\n * id and cannot know the position at the call site, and it is the route a plugin's props take.\n * One runtime check covers both.\n */\n function warnOnStartColumnPin(columnId: string, sticky: boolean | undefined) {\n if (process.env.NODE_ENV === 'production') return;\n if (!sticky) return;\n if (startPinWarned.has(columnId)) return;\n\n startPinWarned.add(columnId);\n console.warn(\n `[DataGrid] Extra column \"${columnId}\": \\`sticky\\` pins to the table's inline-end edge and ` +\n 'is read only for columns at the `end` position -- on a `start` column it does nothing. ' +\n 'Drop the flag, or register the column at the `end` position.',\n );\n }\n\n function updateExtraColumnWidth(columnId: string, width: string) {\n const store = useTableStore.getState();\n\n function updateList(columns: ExtraColumn[]): ExtraColumn[] | undefined {\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return undefined;\n const updated = [...columns];\n updated[index] = { ...updated[index], width };\n return updated;\n }\n\n const updatedStart = updateList(store.extraColumnsStart);\n if (updatedStart) {\n useTableStore.setState({ extraColumnsStart: updatedStart });\n return;\n }\n\n const updatedEnd = updateList(store.extraColumnsEnd);\n if (updatedEnd) {\n useTableStore.setState({ extraColumnsEnd: updatedEnd });\n }\n }\n\n function updateExtraColumnOrder(columnId: string, order: number) {\n const store = useTableStore.getState();\n\n function updateList(columns: ExtraColumn[]): ExtraColumn[] | undefined {\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return undefined;\n const updated = [...columns];\n updated[index] = { ...updated[index], order };\n return updated.sort((a, b) => a.order - b.order);\n }\n\n const updatedStart = updateList(store.extraColumnsStart);\n if (updatedStart) {\n useTableStore.setState({ extraColumnsStart: updatedStart });\n return;\n }\n\n const updatedEnd = updateList(store.extraColumnsEnd);\n if (updatedEnd) {\n useTableStore.setState({ extraColumnsEnd: updatedEnd });\n }\n }\n\n /**\n * Plugins register their extra column once at setup, before their props are available, so the\n * pin arrives here on the first props pass -- same route `updateExtraColumnOrder` takes. Writing\n * only on an actual change keeps that pass from replacing the column list (and re-rendering\n * every cell) on every re-render of a plugin that never opts in.\n *\n * The stored flag is compared through the same `?? false` the callers normalise with, so a\n * column registered with no `sticky` at all is already \"unpinned\" as far as the guard is\n * concerned and the first pass of a grid that never opts in writes nothing. Nothing downstream\n * tells an absent flag from an explicit `false` -- `getEndStickyOffset` reads both as unpinned --\n * so collapsing them here costs no meaning and saves every such grid one re-render of every cell\n * on mount.\n */\n function updateExtraColumnSticky(columnId: string, sticky: boolean) {\n const store = useTableStore.getState();\n\n const isStart = store.extraColumnsStart.some((c) => c.id === columnId);\n const key = isStart ? 'extraColumnsStart' : 'extraColumnsEnd';\n const columns = store[key];\n\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return;\n\n if (isStart) warnOnStartColumnPin(columnId, sticky);\n\n if ((columns[index].sticky ?? false) === sticky) return;\n\n const updated = [...columns];\n updated[index] = { ...updated[index], sticky };\n useTableStore.setState({ [key]: updated });\n }\n\n function useExtraColumns(position: ExtraColumnPosition): ExtraColumn[] {\n return useTableStore((s) => (position === 'start' ? s.extraColumnsStart : s.extraColumnsEnd));\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStickyService } from './table-sticky';\nimport type {\n DataGridTableColumn,\n RegisteredTableComponent,\n TableComponentName,\n TableHeaderCell,\n TableStore,\n} from './table-types';\nimport { isTableGroup } from './table-types';\n\nexport function prepareTableHeader<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n stickyApi: TableStickyService<TItem>,\n defaultComponents: Map<TableComponentName, RegisteredTableComponent>,\n) {\n const emptyTableColumnArray: DataGridTableColumn<TItem>[] = [];\n // Caches for referential stability in reactive hooks\n let headerCellsCache: { state: TableStore<TItem>; result: TableHeaderCell<TItem>[] } | null =\n null;\n let headerColumnsCache: { state: TableStore<TItem>; result: DataGridTableColumn<TItem>[] } | null =\n null;\n\n return {\n useHasGroups,\n useFirstRowHeaderCells,\n useSecondRowHeaderColumns,\n };\n\n function getVisibleColumns(): DataGridTableColumn<TItem>[] {\n const state = useTableStore.getState();\n const visible = state.flatColumns.filter((col) => state.columnVisibility.get(col.id) !== false);\n return stickyApi.getOrderedColumnsWithSticky(visible, state.columnSticky);\n }\n\n function hasGroups(): boolean {\n return useTableStore.getState().columns.some(isTableGroup);\n }\n\n function getFirstRowHeaderCells(): TableHeaderCell<TItem>[] {\n const state = useTableStore.getState();\n const visibleCols = getVisibleColumns();\n\n if (!hasGroups()) {\n const component =\n state.components.get('header-cell') ?? defaultComponents.get('header-cell')!;\n return visibleCols.map((column) => ({\n type: 'column' as const,\n item: column,\n component,\n }));\n }\n\n const columnOrderMap = new Map(visibleCols.map((col, index) => [col.id, index]));\n const orderedItems = [...state.columns].sort((a, b) => {\n const aIndex = isTableGroup(a)\n ? Math.min(...a.columns.map((c) => columnOrderMap.get(c.id) ?? Infinity))\n : (columnOrderMap.get(a.id) ?? Infinity);\n const bIndex = isTableGroup(b)\n ? Math.min(...b.columns.map((c) => columnOrderMap.get(c.id) ?? Infinity))\n : (columnOrderMap.get(b.id) ?? Infinity);\n return aIndex - bIndex;\n });\n\n return orderedItems.flatMap((item) => {\n if (isTableGroup(item)) {\n const visibleCount = item.columns.filter(\n (c) => state.columnVisibility.get(c.id) !== false,\n ).length;\n\n if (visibleCount === 0) return [];\n\n return {\n type: 'group' as const,\n item,\n component: state.components.get('header-group') ?? defaultComponents.get('header-group')!,\n colspan: visibleCount,\n };\n }\n\n if (state.columnVisibility.get(item.id) === false) return [];\n\n return {\n type: 'column' as const,\n item,\n component: state.components.get('header-cell') ?? defaultComponents.get('header-cell')!,\n rowspan: 2,\n };\n });\n }\n\n function getSecondRowHeaderColumns(): DataGridTableColumn<TItem>[] {\n if (!hasGroups()) return emptyTableColumnArray;\n\n const state = useTableStore.getState();\n const visibleCols = getVisibleColumns();\n return visibleCols.filter((col) => col.groupId && state.columnVisibility.get(col.id) !== false);\n }\n\n function useHasGroups() {\n return useTableStore((state) => state.columns.some(isTableGroup));\n }\n\n function useFirstRowHeaderCells(): TableHeaderCell<TItem>[] {\n return useTableStore((state) => {\n if (headerCellsCache !== null && headerCellsCache.state === state) {\n return headerCellsCache.result;\n }\n const result = getFirstRowHeaderCells();\n headerCellsCache = { state, result };\n return result;\n });\n }\n\n function useSecondRowHeaderColumns(): DataGridTableColumn<TItem>[] {\n return useTableStore((state) => {\n if (headerColumnsCache !== null && headerColumnsCache.state === state) {\n return headerColumnsCache.result;\n }\n const result = getSecondRowHeaderColumns();\n headerColumnsCache = { state, result };\n return result;\n });\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableSlot, TableSlotName, TableSlotOptions, TableStore } from './table-types';\n\nconst emptySlots: TableSlot[] = [];\n\nexport function prepareTableSlots<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n registerSlot,\n useSlots,\n };\n\n function registerSlot<T extends TableSlotName>(name: T, options: TableSlotOptions[T]) {\n const store = useTableStore.getState();\n const id = Math.random().toString(36).slice(2);\n const existingSlots = store.slots.get(name) ?? emptySlots;\n const order = options.order ?? (existingSlots.length + 1) * 10;\n\n const newSlot: TableSlot = {\n id,\n name,\n component: options.component,\n order,\n };\n\n const updated = [...existingSlots, newSlot].sort((a, b) => a.order - b.order);\n const newSlots = new Map(store.slots);\n newSlots.set(name, updated);\n useTableStore.setState({ slots: newSlots });\n }\n\n function useSlots<T extends TableSlotName>(name: T): TableSlot[] {\n return useTableStore(useShallow((state) => state.slots.get(name) ?? emptySlots));\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { ExtraColumn, DataGridTableColumn, DataGridTableGroup, TableStore } from './table-types';\nimport { isTableGroup } from './table-types';\n\n/** The slice of the table store the inline-end offsets are derived from. */\ntype EndStickyState = Pick<TableStore, 'extraColumnsEnd' | 'columnWidths'>;\n\n/** A registered `width` the inline-end arithmetic can use: a plain px length, nothing else. */\nconst pxWidthRe = /^\\s*(\\d+(?:\\.\\d+)?)px\\s*$/;\n\nexport type TableStickyService<TItem extends DataGridItem = DataGridItem> = ReturnType<\n typeof prepareTableSticky<TItem>\n>;\n\nexport function prepareTableSticky<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n initializeStickyState,\n getOrderedColumnsWithSticky,\n onResizeColumn,\n isColumnSticky,\n isGroupSticky,\n useColumnStickyOffset,\n useColumnEndStickyOffset,\n useGroupStickyOffset,\n };\n\n function initializeStickyState(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]): {\n columnSticky: Map<string, boolean>;\n groupSticky: Map<string, boolean>;\n } {\n const columnSticky = new Map<string, boolean>();\n const groupSticky = new Map<string, boolean>();\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n groupSticky.set(item.id, item.sticky ?? false);\n for (const col of item.columns) {\n columnSticky.set(col.id, col.sticky ?? item.sticky ?? false);\n }\n } else {\n columnSticky.set(item.id, item.sticky ?? false);\n }\n }\n\n return { columnSticky, groupSticky };\n }\n\n function getOrderedColumnsWithSticky(\n visibleColumns: DataGridTableColumn<TItem>[],\n columnSticky: Map<string, boolean>,\n ): DataGridTableColumn<TItem>[] {\n const sticky: DataGridTableColumn<TItem>[] = [];\n const nonSticky: DataGridTableColumn<TItem>[] = [];\n\n for (const col of visibleColumns) {\n if (columnSticky.get(col.id)) {\n sticky.push(col);\n } else {\n nonSticky.push(col);\n }\n }\n\n return [...sticky, ...nonSticky];\n }\n\n // Skips the write when the width is unchanged. This is what ends the header's observer cycle: a\n // new `columnWidths` Map is a new store state, which gives `useFirstRowHeaderCells` a new array,\n // which re-creates the header's ResizeObserver, and a fresh observer always reports once on\n // `observe()` -- so an unconditional write here would rebuild the observer on every frame.\n function onResizeColumn(columnId: string, width: number) {\n const current = useTableStore.getState().columnWidths;\n if (current.get(columnId) === width) return;\n\n const newWidths = new Map(current);\n newWidths.set(columnId, width);\n useTableStore.setState({ columnWidths: newWidths });\n }\n\n function isColumnSticky(columnId: string) {\n return useTableStore.getState().columnSticky.get(columnId) === true;\n }\n\n function isGroupSticky(groupId: string) {\n return useTableStore.getState().groupSticky.get(groupId) === true;\n }\n\n function useColumnStickyOffset(columnId: string): number | undefined {\n return useTableStore((s) => {\n if (!s.columnSticky.get(columnId)) return undefined;\n\n let offset = getExtraStartOffset(s);\n const visibleCols = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n for (const col of visibleCols) {\n if (col.id === columnId) break;\n if (s.columnSticky.get(col.id)) {\n offset += s.columnWidths.get(col.id) ?? 0;\n }\n }\n return offset;\n });\n }\n\n function useColumnEndStickyOffset(columnId: string): number | undefined {\n return useTableStore((s) => getEndStickyOffset(s, columnId));\n }\n\n function useGroupStickyOffset(groupId: string): number | undefined {\n return useTableStore((s) => {\n if (!s.groupSticky.get(groupId)) return undefined;\n\n let offset = getExtraStartOffset(s);\n const visibleCols = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n for (const col of visibleCols) {\n if (col.groupId === groupId) break;\n if (s.columnSticky.get(col.id)) {\n offset += s.columnWidths.get(col.id) ?? 0;\n }\n }\n return offset;\n });\n }\n\n function getExtraStartOffset(s: TableStore<TItem>) {\n let offset = 0;\n for (const extra of s.extraColumnsStart) {\n if (extra.width) offset += parseInt(extra.width, 10) || 0;\n }\n return offset;\n }\n}\n\n/**\n * Offset from the table's inline-end edge for a pinned `end` extra column, or `undefined` when\n * the column is not an `end` column that pins.\n *\n * Walked right to left so each pinned column sits outside the ones already pinned beyond it,\n * mirroring how the start-edge offsets accumulate left to right. Unpinned columns in between\n * contribute nothing -- they scroll away, so the pinned ones stack against each other.\n *\n * Pure and store-shaped rather than a hook body so the arithmetic is directly testable, and so\n * `useColumnEndStickyOffset` returns a plain number: a `Map` built inside a zustand selector would be a\n * fresh reference on every store read and re-render forever.\n */\nexport function getEndStickyOffset(s: EndStickyState, columnId: string): number | undefined {\n let offset = 0;\n\n for (let index = s.extraColumnsEnd.length - 1; index >= 0; index--) {\n const column = s.extraColumnsEnd[index];\n if (!column.sticky) continue;\n if (column.id === columnId) return offset;\n offset += resolveExtraColumnWidth(s, column);\n }\n\n return undefined;\n}\n\n/**\n * The measured header width wins over the registered one: an auto-sized extra column registers a\n * width computed from its own content, while the header's ResizeObserver reports the track the\n * table actually gave the cell. Stacking on the registered value would drift the outer pinned\n * columns by the difference.\n *\n * The registered value is used only when it is a plain px length. `width` is handed straight to\n * CSS, where `4rem` and `10%` are perfectly good column widths, so the field cannot be narrowed to\n * px without taking those away -- but this arithmetic is pixels, and reading them with `parseInt`\n * would call them `4` and `10` and pin the columns inside them a few pixels from the edge instead\n * of clear of the column. An unreadable width contributes `0` instead: the same as a pinned column\n * with no width at all, and true only until the header's ResizeObserver reports the real track.\n */\nfunction resolveExtraColumnWidth(s: EndStickyState, column: ExtraColumn): number {\n const measured = s.columnWidths.get(column.id);\n if (measured !== undefined) return measured;\n\n const px = pxWidthRe.exec(column.width ?? '');\n return px ? Number(px[1]) : 0;\n}\n","import { create } from 'zustand';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStore } from './table-types';\n\nexport function createTableStore<TItem extends DataGridItem = DataGridItem>() {\n return create<TableStore<TItem>>(() => ({\n columns: [],\n flatColumns: [],\n columnVisibility: new Map(),\n columnSticky: new Map(),\n groupSticky: new Map(),\n columnWidths: new Map(),\n minContentWidths: new Map(),\n extraColumnsStart: [],\n extraColumnsEnd: [],\n slots: new Map(),\n components: new Map(),\n tableLayout: 'fixed',\n stickyHeader: false,\n }));\n}\n","import { TablePropertiesIcon } from 'lucide-react';\nimport type { ComponentType } from 'react';\nimport { useMemo } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { DataGridBodyCellContent } from './components/data-grid-body-cell-content';\nimport { DataGridContent } from './components/data-grid-content';\nimport { DataGridHeaderCellLabel } from './components/data-grid-header-cell-label';\nimport { DataGridHeaderGroup } from './components/data-grid-header-group';\nimport { DataGridRow } from './components/data-grid-row';\nimport { DataGridTable } from './components/data-grid-table';\nimport { TABLE_LAYOUT_SLOT_ID } from '../layout/layout-slot-ids';\nimport { prepareTableColumns } from './table-columns';\nimport { prepareTableColumnsPersistence } from './table-columns-persistence';\nimport { prepareTableExtraColumns } from './table-extra-columns';\nimport { prepareTableHeader } from './table-header';\nimport { prepareTableMinContentWidth } from './table-min-content-width';\nimport { prepareTableSlots } from './table-slots';\nimport { prepareTableSticky } from './table-sticky';\nimport { createTableStore } from './table-store';\nimport type {\n ConfigurationColumn,\n ConfigurationEntry,\n DataGridTableColumn,\n TableComponentName,\n DataGridTableGroup,\n DataGridTableLayout,\n RegisteredTableComponent,\n TablePublicApi,\n TableService,\n} from './table-types';\nimport { isTableGroup } from './table-types';\n\nexport function createTableService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): TableService<TItem> {\n const useTableStore = createTableStore<TItem>();\n const defaultComponents = createDefaultComponents();\n\n // Register table in layout main slot as the default active view, with an icon for the view selector\n context.layout.registerSlot('main', {\n id: TABLE_LAYOUT_SLOT_ID,\n component: DataGridTable,\n active: true,\n icon: TablePropertiesIcon,\n });\n\n // Domain APIs (same composition as before)\n const slotsApi = prepareTableSlots<TItem>(useTableStore);\n const extraColumnsApi = prepareTableExtraColumns<TItem>(useTableStore);\n const stickyApi = prepareTableSticky<TItem>(useTableStore);\n const columnsPersistence = prepareTableColumnsPersistence<TItem>(context);\n const columnsApi = prepareTableColumns<TItem>(useTableStore, stickyApi, columnsPersistence);\n const headerApi = prepareTableHeader<TItem>(useTableStore, stickyApi, defaultComponents);\n const minContentWidthApi = prepareTableMinContentWidth<TItem>(useTableStore);\n\n // Public API — registered into pluginContext for external plugins\n const publicApi: TablePublicApi<TItem> = {\n registerTableSlot: slotsApi.registerSlot,\n registerExtraColumn: extraColumnsApi.registerExtraColumn,\n updateExtraColumnWidth: extraColumnsApi.updateExtraColumnWidth,\n updateExtraColumnOrder: extraColumnsApi.updateExtraColumnOrder,\n updateExtraColumnSticky: extraColumnsApi.updateExtraColumnSticky,\n registerComponent,\n updateColumns,\n updateColumnVisibility,\n updateColumnSticky,\n updateTableLayout,\n updateStickyHeader,\n };\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n updateColumns,\n useComponent,\n useConfigurationColumns,\n useTableLayout,\n useStickyHeader,\n ...slotsApi,\n ...extraColumnsApi,\n ...stickyApi,\n ...columnsApi,\n ...headerApi,\n ...minContentWidthApi,\n };\n\n function updateColumns(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]) {\n const columnState = columnsApi.initializeColumns(columns);\n const { columnSticky, groupSticky } = stickyApi.initializeStickyState(columns);\n const current = useTableStore.getState();\n useTableStore.setState({\n ...columnState,\n columnSticky,\n groupSticky,\n extraColumnsStart: current.extraColumnsStart,\n extraColumnsEnd: current.extraColumnsEnd,\n slots: current.slots,\n components: current.components,\n columnWidths: current.columnWidths,\n minContentWidths: current.minContentWidths,\n });\n }\n\n function updateColumnVisibility(columnId: string, visible: boolean) {\n const state = useTableStore.getState();\n const newVisibility = new Map(state.columnVisibility);\n newVisibility.set(columnId, visible);\n useTableStore.setState({ columnVisibility: newVisibility });\n columnsPersistence?.record(columnId, visible);\n }\n\n function updateTableLayout(tableLayout: DataGridTableLayout) {\n useTableStore.setState({ tableLayout });\n }\n\n function useTableLayout(): DataGridTableLayout {\n return useTableStore((state) => state.tableLayout);\n }\n\n function updateStickyHeader(stickyHeader: boolean) {\n useTableStore.setState({ stickyHeader });\n }\n\n function useStickyHeader(): boolean {\n return useTableStore((state) => state.stickyHeader);\n }\n\n function updateColumnSticky(id: string, sticky: boolean) {\n const state = useTableStore.getState();\n const isGroup = state.columns.some((col) => isTableGroup(col) && col.id === id);\n\n if (isGroup) {\n const newGroupSticky = new Map(state.groupSticky);\n newGroupSticky.set(id, sticky);\n useTableStore.setState({ groupSticky: newGroupSticky });\n } else {\n const newColumnSticky = new Map(state.columnSticky);\n newColumnSticky.set(id, sticky);\n useTableStore.setState({ columnSticky: newColumnSticky });\n }\n }\n\n // The parameter is whatever the public API takes (a `ComponentType<any>`), so a class component\n // is accepted. The registry stores it as a `ComponentType<never>`, which a class component is\n // not assignable to (its instance's `props` are not assignable to `never`), hence the assertion.\n function registerComponent(\n name: TableComponentName,\n component: Parameters<TablePublicApi['registerComponent']>[1],\n ) {\n const state = useTableStore.getState();\n const newComponents = new Map(state.components);\n newComponents.set(name, component as RegisteredTableComponent);\n useTableStore.setState({ components: newComponents });\n }\n\n function useComponent<TProps = unknown>(name: TableComponentName): ComponentType<TProps> {\n return useTableStore(\n (state) => state.components.get(name) ?? defaultComponents.get(name)!,\n ) as ComponentType<TProps>;\n }\n\n function resolveLabel(label: string | (() => string)): string {\n return typeof label === 'function' ? label() : label;\n }\n\n function useConfigurationColumns(): ConfigurationEntry[] {\n const { columns, columnVisibility, columnSticky, groupSticky } = useTableStore(\n useShallow((state) => ({\n columns: state.columns,\n columnVisibility: state.columnVisibility,\n columnSticky: state.columnSticky,\n groupSticky: state.groupSticky,\n })),\n );\n\n return useMemo(() => {\n const visibleCount = Array.from(columnVisibility.values()).filter(Boolean).length;\n\n function toConfigCol(col: DataGridTableColumn<TItem>): ConfigurationColumn {\n const visible = columnVisibility.get(col.id) ?? true;\n return {\n id: col.id,\n label: resolveLabel(col.label),\n visible,\n sticky: columnSticky.get(col.id) ?? false,\n visibleToggleDisabled: col.visibleToggleDisabled ?? (visible && visibleCount === 1),\n };\n }\n\n return columns.map((item): ConfigurationEntry => {\n if (isTableGroup(item)) {\n return {\n id: item.id,\n label: resolveLabel(item.label),\n visible: item.visible ?? true,\n sticky: groupSticky.get(item.id) ?? false,\n columns: item.columns.map(toConfigCol),\n };\n }\n return toConfigCol(item);\n });\n }, [columns, columnVisibility, columnSticky, groupSticky]);\n }\n}\n\nfunction createDefaultComponents(): Map<TableComponentName, RegisteredTableComponent> {\n const defaults = new Map<TableComponentName, RegisteredTableComponent>();\n defaults.set('body-cell-content', DataGridBodyCellContent);\n defaults.set('content', DataGridContent);\n defaults.set('header-cell-label', DataGridHeaderCellLabel);\n defaults.set('header-group', DataGridHeaderGroup);\n defaults.set('row', DataGridRow);\n return defaults;\n}\n","import type {\n DataGridInstance,\n DataGridConfig,\n DataGridItem,\n InternalContext,\n} from './data-grid-types';\nimport { createCoreService } from './services/core/core-service';\nimport { createHookedService } from './services/hooked/hooked';\nimport { internalContextKey } from './services/internal/internal-helpers';\nimport { createLayoutService } from './services/layout/layout-service';\nimport { createLoadService } from './services/load/load-service';\nimport { createPersistentStateService } from './services/persistent-state/persistent-state-service';\nimport { createPluginsService } from './services/plugins/plugins-service';\nimport type { DataGridPlugin } from './services/plugins/plugins-types';\nimport { createStorageService } from './services/storage/storage-service';\nimport { createTableService } from './services/table/table-service';\n\nexport function createDataGrid<\n TItem extends DataGridItem,\n TPlugins extends DataGridPlugin<TItem>[] = DataGridPlugin<TItem>[],\n>(config: DataGridConfig<TItem>): DataGridInstance<TItem, TPlugins> {\n const hooked = createHookedService<TItem>();\n\n // The services are created one after another, and a few read the context while they are being\n // created (the table service registers its layout slot, the load service registers its public\n // API). So the context exposes each service through a getter that fails loudly if it is read\n // before that service exists, instead of handing out a placeholder object.\n const services: Partial<Omit<InternalContext<TItem>, 'hooked' | 'config'>> = {};\n\n const context: InternalContext<TItem> = {\n hooked,\n config,\n get plugins() {\n return created(services.plugins, 'plugins');\n },\n get core() {\n return created(services.core, 'core');\n },\n get load() {\n return created(services.load, 'load');\n },\n get storage() {\n return created(services.storage, 'storage');\n },\n get persistentState() {\n return created(services.persistentState, 'persistentState');\n },\n get layout() {\n return created(services.layout, 'layout');\n },\n get table() {\n return created(services.table, 'table');\n },\n };\n\n services.plugins = createPluginsService<TItem>(context);\n services.core = createCoreService();\n services.load = createLoadService<TItem>(context);\n services.storage = createStorageService<TItem>(context);\n services.persistentState = createPersistentStateService<TItem>(context);\n services.layout = createLayoutService<TItem>(context);\n services.table = createTableService<TItem>(context);\n\n return {\n init,\n destroy,\n ...context.plugins.pluginContext,\n [internalContextKey]: context,\n } as DataGridInstance<TItem, TPlugins>;\n\n function destroy() {\n hooked.callHookSync('destroy');\n\n // A first load that is under way, and so about to be aborted, never delivers: the grid is back\n // to idle, so the next `init()` (an `Activity` showing it again) runs the load once more.\n // Without an instance the first load has not started yet -- React's development remount runs\n // this cleanup between two `init()` calls, and the second must not start another -- so there\n // is nothing to cut off.\n const firstLoadCutOff =\n context.core.useLoadStateStore.getState().loadState === 'loading' &&\n context.load.getLoadInstances().length > 0;\n\n context.load.abort();\n if (firstLoadCutOff) {\n context.core.resetLoadState();\n }\n }\n\n async function init() {\n const { loadState } = context.core.useLoadStateStore.getState();\n if (loadState === 'loaded' || loadState === 'loading') {\n return;\n }\n\n await context.core.loadPromise(context.load.init());\n }\n}\n\nfunction created<T>(service: T | undefined, name: string): T {\n if (service === undefined) {\n throw new Error(`[DataGrid] The ${name} service was used before it was created.`);\n }\n return service;\n}\n","// Load-bearing: DataGrid calls useState/useEffect directly in its own render body, so this\n// can't be dropped. Coupled to CLIENT_COMPONENTS in scripts/verify-consumer.sh and to the\n// client-component sentence in README.md and llms.txt (client-boundaries.test.ts checks all\n// three) - keep them in sync if this ever changes.\n'use client';\n\nimport { Suspense, useEffect, useState } from 'react';\n\nimport { DataGridContent } from './components/data-grid-content';\nimport { DataGridSpinner } from './components/data-grid-spinner';\nimport { createDataGrid } from './create-data-grid';\nimport type { DataGridItem, DataGridProps } from './data-grid-types';\nimport { DataGridProvider } from './services/core/data-grid-context';\nimport { internalContextKey } from './services/internal/internal-helpers';\nimport { useLatest } from './utils/use-latest';\n\nconst noImplicitFilterKeys: string[] = [];\n\nexport function DataGrid<TItem extends DataGridItem = DataGridItem>({\n name,\n load,\n columns,\n children,\n persistent,\n persistentColumnVisibility,\n tableLayout = 'fixed',\n stickyHeader = false,\n loading = false,\n implicitFilterKeys,\n}: DataGridProps<TItem>) {\n const loadRef = useLatest(load);\n const [grid] = useState(() =>\n createDataGrid<TItem>({\n name,\n load: loadRef,\n persistent,\n persistentColumnVisibility,\n }),\n );\n\n // Runs before the columns effect (declaration order) so column ingestion -- which DEV-warns on\n // a width contradiction that only exists under `tableLayout=\"fixed\"` -- reads the current mode.\n useEffect(() => {\n grid.updateTableLayout(tableLayout);\n }, [grid, tableLayout]);\n\n useEffect(() => {\n grid.updateColumns(columns);\n }, [grid, columns]);\n\n useEffect(() => {\n grid.updateStickyHeader(stickyHeader);\n }, [grid, stickyHeader]);\n\n // Reaches the core service directly because the setter is internal: this prop is the only way to\n // raise the overlay for work the grid does not own, so there is exactly one writer of the flag.\n useEffect(() => {\n grid[internalContextKey].core.updateLoading(loading);\n }, [grid, loading]);\n\n // Same idiom as `loading` above: the setter is internal, and this prop is its only writer.\n // Falls back to a shared constant so an omitted prop stays reference-equal across renders.\n useEffect(() => {\n grid[internalContextKey].storage.updateImplicitFilterKeys(\n implicitFilterKeys ?? noImplicitFilterKeys,\n );\n }, [grid, implicitFilterKeys]);\n\n return (\n <DataGridProvider value={grid}>\n {children}\n <Suspense fallback={<DataGridSpinner />}>\n <DataGridContent />\n </Suspense>\n </DataGridProvider>\n );\n}\n","import { CARDS_LAYOUT_SLOT_ID, TABLE_LAYOUT_SLOT_ID } from './layout-slot-ids';\nimport { useDataGridContext } from '../core/data-grid-context';\n\n/**\n * Stable ids of the built-in DataGrid main views. Use these instead of hardcoding the raw slot-id\n * strings when reading or setting the active view (e.g. `grid.setActiveSlotId('main', DATA_GRID_VIEW.cards)`).\n */\nexport const DATA_GRID_VIEW = {\n table: TABLE_LAYOUT_SLOT_ID,\n cards: CARDS_LAYOUT_SLOT_ID,\n} as const;\n\n/** A built-in DataGrid main-view slot id. */\nexport type DataGridViewId = (typeof DATA_GRID_VIEW)[keyof typeof DATA_GRID_VIEW];\n\n/**\n * Reactively read the id of the currently active DataGrid main view (e.g. the table view, or a cards view that a plugin registers).\n * Re-renders when the active view changes. Returns `undefined` before any main view is active.\n */\nexport function useDataGridActiveView(): string | undefined {\n const context = useDataGridContext();\n return context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n}\n"],"names":["DataGridSpinner","className","jsx","cx","styles","Spinner","useDataGridLoading","context","useDataGridContext","recordsLoadState","s","externalLoading","DataGridLayoutContent","children","initialLoadState","showOverlay","isBusy","jsxs","rootStyles","DataGridEmptyState","useStore","useDataGrid","hasActiveFilters","Empty","EmptyHeader","EmptyMedia","SearchXIcon","EmptyTitle","messages","EmptyDescription","DataGridLayoutMain","visibleRecords","activeSlotId","state","mainLayoutSlots","activeSlot","emptySlots","emptySlot","isEmpty","showMain","showEmptyState","DataGridLayoutSlot","name","currentSlots","Fragment","slot","DataGridLayoutTopDefault","topStartLayoutSlots","topEndLayoutSlots","hasTopStartSlots","hasTopEndSlots","DataGridLayoutTop","topLayoutSlots","topLayoutSlot","TopComponent","LoadControlled","loadState","OctagonAlertIcon","DataGridContent","grid","core","useEffect","error","createLoadStateManager","useLoadStateStore","create","owner","setLoading","setLoaded","setError","setBlank","reset","loadPromise","promise","mine","result","createCoreService","useLoadState","useExternalLoadingStore","updateLoading","loading","createHookedService","hooked","createHooked","TABLE_LAYOUT_SLOT_ID","CARDS_LAYOUT_SLOT_ID","VIEW_SELECTOR_SLOT_ID","slotLabels","DataGridLayoutMainSlotSelector","mainSlots","Segment","handleValueChange","Icon","ToggleGroupItem","value","createLayoutService","useLayoutStore","publicApi","registerSlot","setActiveSlotId","getActiveSlotId","getSlotById","id","getLayoutSlots","options","existingSlots","order","newSlot","newSlots","b","newSlotsMap","newActiveSlotIds","isRecord","createLoadInstance","config","controller","loadStateManager","loadContext","fetchResult","processResult","started","instance","abort","executeLoad","extraContext","mergeContextData","data","assertLoadResult","stored","item","e","target","fromArray","key","merged","createLoadService","instances","recordInstanceIds","latestRefresh","triggerLoad","refresh","getLoadInstances","init","syncLoadState","replacesRecords","triggerConfig","_b","_a","settle","refreshBefore","followed","runRefresh","refreshOptions","createPersistentStateService","subscribers","memoryStore","gridName","persistMode","registerPersistentState","getStorageKey","getStorage","area","storageKey","mode","isDisabled","getValue","setValue","buildStorageItem","params","parseStored","storage","readItem","newUrl","fn","field","val","raw","createPluginsService","pluginApis","pluginPublicApi","getPlugin","pluginContext","registerPlugin","registerPlugins","registerPublicApi","methods","plugin","api","plugins","getItemKeyValue","createStorageService","implicitFilterKeys","clearSections","createSection","getSections","getRecord","getSectionsByParentId","getRecordsByParentId","getItemId","updateImplicitFilterKeys","items","sectionId","parentId","newSection","itemKey","index","itemId","sections","recordSections","rootSections","visibleSections","computeDerivedState","section","record","r","isFilterValueActive","keys","filters","filter","resolveLabel","label","getNestedValue","obj","path","acc","resolveCellDisplayValue","column","rawValue","DataGridBodyCellContent","CellComponent","DataGridHeaderCellLabel","useTableService","DataGridHeaderCellContent","DataGridHeaderGroup","group","colspan","tableService","stickyOffset","stickyHeader","isSticky","GroupContent","content","TableHead","headerStyles","DataGridRecordContext","createContext","DataGridRecordProvider","useDataGridRecord","useContext","DATA_GRID_COLUMN_MAX_WIDTH_VAR","isPercent","toLength","resolveColumnStyle","tableLayout","minContentWidth","resolveAutoStyle","resolveFixedStyle","track","length","width","minWidth","maxWidth","headerStyle","contentVars","resolveBodyCellProps","overflow","isCapped","displayValue","IGNORE_CLICK_ATTRIBUTE","normalizeWidth","DataGridCell","columnId","rowspan","style","header","endSlot","capped","title","contentRowRef","fillContent","ignoreRowClick","endStickyOffset","isStickyEnd","Cell","TableCell","normalizedWidth","DataGridExtraBodyColumns","position","extraColumns","extra","DataGridRow","columns","BodyCellContent","TableRow","col","dynamicClassName","bodyCellProps","DataGridTableRecord","RowComponent","DataGridTableRecords","records","DataGridTableBody","TableBody","DataGridExtraHeaderCell","cellStyles","DataGridExtraHeaderColumns","isGroupRow","hasGroups","shouldRender","prepareTableMinContentWidth","useTableStore","setMinContentWidth","useMinContentWidth","current","next","measureMinContentWidth","entry","cell","computedStyle","paddings","borders","DataGridHeaderCell","headerCellEndSlots","useRef","LabelComponent","configuredHeaderOverflow","isMinContentColumn","cellOverflow","contentRow","observer","entries","SlotComponent","DataGridTableHeader","theadRef","observerRef","firstRowCells","secondRowColumns","thead","cells","TableHeader","DataGridTableSlot","slots","layoutClassMap","DataGridTable","subheaderSlots","footerSlots","ContentWrapper","Table","snakeCaseRe","prepareTableColumns","stickyApi","persistence","widthContradictionWarned","headerTruncateDeprecationWarned","allColumnsCappedWarned","initializeColumns","useVisibleColumns","assertColumnId","normalizeColumn","warnOnFixedModeWidthContradiction","warnOnAllColumnsCappedUnderAuto","flatCols","flattenColumns","isTableGroup","initializeColumnVisibility","map","lockedIds","register","visible","useShallow","c","COLUMN_VISIBILITY_KEY","prepareTableColumnsPersistence","read","prepareTableExtraColumns","startPinWarned","registerExtraColumn","updateExtraColumnWidth","updateExtraColumnOrder","updateExtraColumnSticky","useExtraColumns","option","store","existing","newColumn","updated","warnOnStartColumnPin","sticky","updateList","updatedStart","updatedEnd","a","isStart","prepareTableHeader","defaultComponents","emptyTableColumnArray","headerCellsCache","headerColumnsCache","useHasGroups","useFirstRowHeaderCells","useSecondRowHeaderColumns","getVisibleColumns","getFirstRowHeaderCells","visibleCols","component","columnOrderMap","aIndex","bIndex","visibleCount","getSecondRowHeaderColumns","prepareTableSlots","useSlots","pxWidthRe","prepareTableSticky","initializeStickyState","getOrderedColumnsWithSticky","onResizeColumn","isColumnSticky","isGroupSticky","useColumnStickyOffset","useColumnEndStickyOffset","useGroupStickyOffset","columnSticky","groupSticky","visibleColumns","nonSticky","newWidths","groupId","offset","getExtraStartOffset","getEndStickyOffset","resolveExtraColumnWidth","measured","px","createTableStore","createTableService","createDefaultComponents","TablePropertiesIcon","slotsApi","extraColumnsApi","columnsPersistence","columnsApi","headerApi","minContentWidthApi","registerComponent","updateColumns","updateColumnVisibility","updateColumnSticky","updateTableLayout","updateStickyHeader","useComponent","useConfigurationColumns","useTableLayout","useStickyHeader","columnState","newVisibility","newGroupSticky","newColumnSticky","newComponents","columnVisibility","useMemo","toConfigCol","defaults","createDataGrid","services","created","destroy","internalContextKey","firstLoadCutOff","service","noImplicitFilterKeys","DataGrid","load","persistent","persistentColumnVisibility","loadRef","useLatest","useState","DataGridProvider","Suspense","DATA_GRID_VIEW","useDataGridActiveView"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBO,SAASA,EAAgB,EAAE,WAAAC,KAAmC;AACnE,SACE,gBAAAC,EAAC,QAAA,EAAK,WAAWC,EAAGC,GAAO,SAASH,CAAS,GAC3C,UAAA,gBAAAC,EAACG,IAAA,EAAQ,MAAK,KAAA,CAAK,GACrB;AAEJ;;;;ACRO,SAASC,KAA8B;AAC5C,QAAMC,IAAUC,EAAA,GACVC,IAAmBF,EAAQ,KAAK,kBAAkB,CAACG,MAAMA,EAAE,gBAAgB,GAC3EC,IAAkBJ,EAAQ,KAAK,wBAAwB,CAACG,MAAMA,EAAE,OAAO;AAE7E,SAAOD,MAAqB,aAAaE;AAC3C;;;;ACXO,SAASC,GAAsB,EAAE,UAAAC,KAAwC;AAE9E,QAAMC,IADUN,EAAA,EACiB,KAAK,kBAAkB,CAACE,MAAMA,EAAE,SAAS,GAKpEK,IAJYT,GAAA,KAIeQ,MAAqB,UAKhDE,IAASD,KAAeD,MAAqB;AAEnD,SACE,gBAAAG,EAAC,SAAI,WAAWC,GAAW,MAAM,aAAWF,IAAS,SAAS,QAC3D,UAAA;AAAA,IAAAH;AAAA,IACAE,uBACE,OAAA,EAAI,WAAWX,GAAO,eACrB,UAAA,gBAAAF,EAACF,KAAgB,EAAA,CACnB;AAAA,EAAA,GAEJ;AAEJ;;;;AC5BO,SAASmB,KAAqB;AACnC,QAAM,EAAE,UAAAC,EAAA,IAAaC,EAAA,GAEfC,IAAmBF,EAAS,CAACV,MAAMA,EAAE,gBAAgB;AAE3D,2BACGa,IAAA,EAAM,WAAWnB,GAAO,YACvB,4BAACoB,IAAA,EACC,UAAA;AAAA,IAAA,gBAAAtB,EAACuB,IAAA,EAAW,SA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AAS,UAAU,gBAAA7d,EAACF,KAAgB,GACnC,UAAA,gBAAAE,EAACwD,MAAgB,EAAA,CACnB;AAAA,EAAA,GACF;AAEJ;ACrEO,MAAMsa,KAAiB;AAAA,EAC5B,OAAO5Y;AAAA,EACP,OAAOC;AACT;AASO,SAAS4Y,KAA4C;AAE1D,SADgBzd,EAAA,EACD,OAAO,eAAe,CAACyB,MAAUA,EAAM,cAAc,IAAI,MAAM,CAAC;AACjF;"}
1
+ {"version":3,"file":"data-grid.js","sources":["../src/components/data-grid/components/data-grid-spinner.tsx","../src/components/data-grid/services/load/use-data-grid-loading.ts","../src/components/data-grid/services/layout/components/data-grid-layout-content.tsx","../src/components/data-grid/components/data-grid-empty-state.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-main.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-slot.tsx","../src/components/data-grid/services/layout/components/data-grid-layout-top-default.tsx","../src/components/data-grid/services/layout/components/toolbar-lines.ts","../src/components/data-grid/services/layout/components/data-grid-layout-top.tsx","../src/components/data-grid/components/load-controlled.tsx","../src/components/data-grid/components/data-grid-content.tsx","../src/components/data-grid/utils/load-state.ts","../src/components/data-grid/services/core/core-service.ts","../src/components/data-grid/services/hooked/hooked.ts","../src/components/data-grid/services/layout/layout-slot-ids.ts","../src/components/data-grid/services/layout/components/data-grid-layout-main-slot-selector.tsx","../src/components/data-grid/services/layout/layout-service.ts","../src/components/data-grid/utils/is-record.ts","../src/components/data-grid/services/load/load-instance.ts","../src/components/data-grid/services/load/load-service.ts","../src/components/data-grid/services/persistent-state/persistent-state-service.ts","../src/components/data-grid/services/plugins/plugins-service.ts","../src/components/data-grid/services/storage/storage-helpers.ts","../src/components/data-grid/services/storage/storage-service.ts","../src/components/data-grid/services/table/components/data-grid-body-cell-content.tsx","../src/components/data-grid/services/table/components/data-grid-content.tsx","../src/components/data-grid/services/table/components/data-grid-header-cell-label.tsx","../src/components/data-grid/services/table/components/data-grid-header-cell-content.tsx","../src/components/data-grid/services/table/components/data-grid-header-group.tsx","../src/components/data-grid/services/table/components/data-grid-row.tsx","../src/components/data-grid/services/table/components/data-grid-table-record.tsx","../src/components/data-grid/services/table/components/data-grid-table-records.tsx","../src/components/data-grid/services/table/components/data-grid-table-body.tsx","../src/components/data-grid/services/table/components/data-grid-extra-header-cell.tsx","../src/components/data-grid/services/table/components/data-grid-extra-header-columns.tsx","../src/components/data-grid/services/table/table-min-content-width.ts","../src/components/data-grid/services/table/components/data-grid-header-cell.tsx","../src/components/data-grid/services/table/components/data-grid-table-header.tsx","../src/components/data-grid/services/table/components/data-grid-table-slot.tsx","../src/components/data-grid/services/table/components/data-grid-table.tsx","../src/components/data-grid/services/table/table-columns.ts","../src/components/data-grid/services/table/table-columns-persistence.ts","../src/components/data-grid/services/table/table-extra-columns.ts","../src/components/data-grid/services/table/table-header.ts","../src/components/data-grid/services/table/table-slots.ts","../src/components/data-grid/services/table/table-sticky.ts","../src/components/data-grid/services/table/table-store.ts","../src/components/data-grid/services/table/table-service.ts","../src/components/data-grid/create-data-grid.ts","../src/components/data-grid/data-grid.tsx","../src/components/data-grid/services/layout/data-grid-view.ts"],"sourcesContent":["import { cx } from 'class-variance-authority';\n\nimport { Spinner } from '../../spinner/public.js';\nimport styles from './data-grid-spinner.module.css';\n\ninterface DataGridSpinnerProps {\n className?: string;\n}\n\n/**\n * The one loader the grid draws, for the first load, for the `Suspense` fallback and for every\n * refetch overlay: a spinner that changed size between the first load and a refetch would read\n * as two different components, so there is a single size and a single place that sets it.\n *\n * It fades in after a short delay, so a load that finishes quickly never shows it. The fade is\n * on a wrapper rather than on the spinner: the spinner already runs its own rotation animation,\n * and a second `animation` declaration on the same element would replace that one.\n */\nexport function DataGridSpinner({ className }: DataGridSpinnerProps) {\n return (\n <span className={cx(styles.delayed, className)}>\n <Spinner size=\"lg\" />\n </span>\n );\n}\n","import { useDataGridContext } from '../core/data-grid-context';\n\n/**\n * Whether the grid should be showing load feedback.\n *\n * Reads `recordsLoadState` rather than the load service's overall state: that one counts every\n * in-flight instance, so loading the children of a tree row or paging through the whole data set\n * would dim and block the whole grid over rows the user can still work with. The core service's state is no use here\n * either -- it latches at `'loaded'` after the first load and would never report a refetch. The\n * idle value is `'blank'`, not `'loaded'`, so the test is an equality check.\n *\n * OR-ed with the consumer's `loading` prop, which covers work the grid cannot see -- a bulk copy, a\n * mutation elsewhere on the screen.\n *\n * @internal\n */\nexport function useDataGridLoading(): boolean {\n const context = useDataGridContext();\n const recordsLoadState = context.load.useLoadStateStore((s) => s.recordsLoadState);\n const externalLoading = context.core.useExternalLoadingStore((s) => s.loading);\n\n return recordsLoadState === 'loading' || externalLoading;\n}\n","import type { ReactNode } from 'react';\nimport { DataGridSpinner } from '../../../components/data-grid-spinner';\nimport rootStyles from '../../../data-grid.module.css';\nimport { useDataGridContext } from '../../core/data-grid-context';\nimport { useDataGridLoading } from '../../load/use-data-grid-loading';\nimport styles from './data-grid-layout-content.module.css';\n\ninterface DataGridLayoutContentProps {\n children: ReactNode;\n}\n\nexport function DataGridLayoutContent({ children }: DataGridLayoutContentProps) {\n const context = useDataGridContext();\n const initialLoadState = context.core.useLoadStateStore((s) => s.loadState);\n const isLoading = useDataGridLoading();\n\n // The first load already renders a centred loader in place of the grid, so the overlay stays out\n // until there is content to cover. Without this gate the two would run at once.\n const showOverlay = isLoading && initialLoadState === 'loaded';\n // Tracks the feedback that is actually on screen -- the overlay, or the first load's centred\n // loader -- rather than the raw loading flag. `'error'` latches for the lifetime of the grid and\n // swaps the whole region for the error view, so reading the flag directly announced a busy grid\n // to a screen reader while sighted users saw an error and nothing running.\n const isBusy = showOverlay || initialLoadState === 'loading';\n\n return (\n <div className={rootStyles.root} aria-busy={isBusy ? 'true' : undefined}>\n {children}\n {showOverlay && (\n <div className={styles.loaderOverlay}>\n <DataGridSpinner />\n </div>\n )}\n </div>\n );\n}\n","import { SearchXIcon } from 'lucide-react';\n\nimport { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '../../empty/public.js';\nimport { messages } from '../messages';\nimport { useDataGrid } from '../services/core/data-grid-context';\nimport styles from './data-grid-empty-state.module.css';\n\nexport function DataGridEmptyState() {\n const { useStore } = useDataGrid();\n\n const hasActiveFilters = useStore((s) => s.hasActiveFilters);\n\n return (\n <Empty className={styles.emptyState}>\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <SearchXIcon />\n </EmptyMedia>\n <EmptyTitle>{messages.emptyState.noResultsFound}</EmptyTitle>\n {hasActiveFilters && (\n <EmptyDescription>{messages.emptyState.noResultsFoundDescription}</EmptyDescription>\n )}\n </EmptyHeader>\n </Empty>\n );\n}\n","import { DataGridEmptyState } from '../../../components/data-grid-empty-state';\nimport { useDataGrid, useDataGridContext } from '../../core/data-grid-context';\nimport styles from './data-grid-layout-main.module.css';\n\nexport function DataGridLayoutMain() {\n const { useStore } = useDataGrid();\n const context = useDataGridContext();\n const visibleRecords = useStore((s) => s.visibleRecords);\n const hasActiveFilters = useStore((s) => s.hasActiveFilters);\n\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n const mainLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('main'));\n const activeSlot = mainLayoutSlots?.find((s) => s.id === activeSlotId);\n\n // Lives outside the `main` slots, so it renders in exactly the case `showMain` excludes.\n const emptySlots = context.layout.useLayoutStore((state) => state.slots.get('empty'));\n const emptySlot = emptySlots?.[0];\n\n const isEmpty = visibleRecords.length === 0;\n const showMain = activeSlot && (!isEmpty || hasActiveFilters);\n // Not gated on the load state. A load replaces the records in one synchronous step after the\n // fetch resolves, so `visibleRecords` never renders empty mid-flight and there is no \"No results\n // found\" flash to suppress -- and whatever this region holds is behind the scrim for the whole\n // load anyway. Gating it here instead unmounted the region entirely on an unfiltered empty grid,\n // where `showMain` is false too, which collapsed the grid to the toolbar's height and back.\n const showEmptyState = isEmpty;\n\n return (\n <div className={styles.dataGridLayoutMain}>\n {showMain && <activeSlot.component />}\n {showEmptyState && (emptySlot ? <emptySlot.component /> : <DataGridEmptyState />)}\n </div>\n );\n}\n","import { useDataGridContext } from '../../core/data-grid-context';\nimport type { LayoutSlotName } from '../layout-types';\n\ninterface DataGridLayoutSlotProps {\n name: LayoutSlotName;\n}\n\nexport function DataGridLayoutSlot({ name }: DataGridLayoutSlotProps) {\n const context = useDataGridContext();\n const currentSlots = context.layout.useLayoutStore((state) => state.slots.get(name));\n\n if (!currentSlots || currentSlots.length === 0) return null;\n\n return (\n <>\n {currentSlots.map((slot) => (\n <slot.component key={slot.id} />\n ))}\n </>\n );\n}\n","import { useDataGridContext } from '../../core/data-grid-context';\nimport styles from './data-grid-layout-top-default.module.css';\n\nexport function DataGridLayoutTopDefault() {\n const context = useDataGridContext();\n\n const topStartLayoutSlots = context.layout.useLayoutStore((state) =>\n state.slots.get('top-start'),\n );\n const topEndLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('top-end'));\n\n const hasTopStartSlots = (topStartLayoutSlots?.length ?? 0) > 0;\n const hasTopEndSlots = (topEndLayoutSlots?.length ?? 0) > 0;\n\n if (!hasTopStartSlots && !hasTopEndSlots) return null;\n\n return (\n <div className={styles.dataGridTopDefault}>\n {hasTopStartSlots && (\n <div className={styles.topStartSlots}>\n {topStartLayoutSlots?.map((slot) => (\n <div key={slot.id} className={styles.topStartSlot}>\n <slot.component />\n </div>\n ))}\n </div>\n )}\n {hasTopEndSlots && (\n <div className={styles.topEndSlots}>\n {topEndLayoutSlots?.map((slot) => (\n <div key={slot.id} className={styles.topEndSlot}>\n <slot.component />\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n","/*\n * Whether a toolbar is on one line. The toolbar wraps on a narrow screen, at three levels (its two\n * halves, what the start half holds, what a plugin's own bar holds), and every level is a flex\n * container that wraps. So it is on one line when, in every such container, the items sit on one\n * line: all of them share some horizontal line. Items of different heights that are centred on a\n * line still do, and items on two lines do not, because the first line's bottoms are above the\n * second's tops. Only the vertical position is read, so the writing direction does not matter.\n */\n\n// An item that is not in the flow takes no line, and a wrapper with `display: contents` has no box\n// of its own: its children are the container's items.\nfunction flowItems(container: Element): Element[] {\n const items: Element[] = [];\n\n for (const child of Array.from(container.children)) {\n const { display, position } = getComputedStyle(child);\n if (display === 'none' || position === 'absolute' || position === 'fixed') continue;\n\n if (display === 'contents') {\n items.push(...flowItems(child));\n } else {\n items.push(child);\n }\n }\n\n return items;\n}\n\nfunction wraps(element: Element): boolean {\n const { display, flexWrap } = getComputedStyle(element);\n return display.includes('flex') && flexWrap !== '' && flexWrap !== 'nowrap';\n}\n\nfunction itemsShareALine(container: Element): boolean {\n let lowestTop = Number.NEGATIVE_INFINITY;\n let highestBottom = Number.POSITIVE_INFINITY;\n\n for (const item of flowItems(container)) {\n const { top, bottom, width, height } = item.getBoundingClientRect();\n if (width === 0 && height === 0) continue;\n lowestTop = Math.max(lowestTop, top);\n highestBottom = Math.min(highestBottom, bottom);\n }\n\n // Half a pixel of slack for the rounding a layout engine does between lines that touch.\n return lowestTop <= highestBottom + 0.5;\n}\n\nexport function isOnOneLine(root: Element): boolean {\n return [root, ...Array.from(root.querySelectorAll('*'))].every(\n (element) => !wraps(element) || itemsShareALine(element),\n );\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { cx } from 'class-variance-authority';\nimport { useDataGridContext } from '../../core/data-grid-context';\nimport { DataGridLayoutTopDefault } from './data-grid-layout-top-default';\nimport styles from './data-grid-layout-top.module.css';\nimport { isOnOneLine } from './toolbar-lines';\n\nexport function DataGridLayoutTop() {\n const context = useDataGridContext();\n\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('top'));\n const topLayoutSlots = context.layout.useLayoutStore((state) => state.slots.get('top'));\n const topLayoutSlot = topLayoutSlots?.find((s) => s.id === activeSlotId);\n const isDefault = topLayoutSlot?.id === 'default';\n\n // The room the default toolbar takes, read while it is on screen, and only while it is on one\n // line. A slot that replaces it (the row select bar) is given at least that much, so the table\n // under it does not move when one takes the other's place. A toolbar that has wrapped onto\n // several lines (a row of quick filters on a narrow screen) is not a room to keep: the slot takes\n // its own height there, and the table moves up with it. The wrapper is a `flow-root`, its own\n // formatting context whatever it is laid out in, so the toolbar's bottom margin is inside its\n // box: its size is the room, margin included.\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [defaultBlockSize, setDefaultBlockSize] = useState<number>();\n\n useEffect(() => {\n const wrapper = wrapperRef.current;\n if (!isDefault || !wrapper) return;\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n const blockSize = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n setDefaultBlockSize(isOnOneLine(wrapper) ? blockSize : undefined);\n });\n observer.observe(wrapper);\n\n return () => observer.disconnect();\n }, [isDefault]);\n\n if (!topLayoutSlot) return null;\n\n const TopComponent = isDefault ? DataGridLayoutTopDefault : topLayoutSlot.component;\n\n return (\n <div\n ref={wrapperRef}\n className={cx(styles.wrapper, !isDefault && styles.replacement)}\n style={!isDefault && defaultBlockSize ? { minBlockSize: defaultBlockSize } : undefined}\n >\n <TopComponent />\n </div>\n );\n}\n","import { OctagonAlertIcon } from 'lucide-react';\nimport type { ReactNode } from 'react';\n\nimport { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '../../empty/public.js';\nimport { messages } from '../messages';\nimport type { LoadState } from '../utils/load-state';\nimport { DataGridSpinner } from './data-grid-spinner';\nimport styles from './load-controlled.module.css';\n\ninterface LoadControlledProps {\n loadState: LoadState;\n /** Rendered once the state is `loaded`. */\n children: ReactNode;\n}\n\n/**\n * Shows the grid's first load: its content when loaded, an error view when the load failed, and\n * the delayed spinner for everything else. Both stand-ins are centred in the space the grid\n * occupies. The error view has no retry: a failed first load stays failed.\n */\nexport function LoadControlled({ loadState, children }: LoadControlledProps) {\n if (loadState === 'loaded') {\n return <>{children}</>;\n }\n\n if (loadState === 'error') {\n return (\n <Empty className={styles.center}>\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <OctagonAlertIcon />\n </EmptyMedia>\n <EmptyTitle>{messages.loadError.headerDefault}</EmptyTitle>\n <EmptyDescription>{messages.loadError.bodyDefault}</EmptyDescription>\n </EmptyHeader>\n </Empty>\n );\n }\n\n return <DataGridSpinner className={styles.center} />;\n}\n","import { useEffect } from 'react';\nimport { useDataGrid, useDataGridContext } from '../services/core/data-grid-context';\nimport { DataGridLayoutContent } from '../services/layout/components/data-grid-layout-content';\nimport { DataGridLayoutMain } from '../services/layout/components/data-grid-layout-main';\nimport { DataGridLayoutSlot } from '../services/layout/components/data-grid-layout-slot';\nimport { DataGridLayoutTop } from '../services/layout/components/data-grid-layout-top';\nimport { LoadControlled } from './load-controlled';\n\nexport function DataGridContent() {\n const grid = useDataGrid();\n const { useStore } = grid;\n const { core } = useDataGridContext();\n const visibleRecords = useStore((s) => s.visibleRecords);\n\n const loadState = core.useLoadStateStore((s) => s.loadState);\n const isEmpty = visibleRecords.length === 0;\n\n useEffect(() => {\n // A failed first load is already handled for the user: the core load state goes to `'error'`\n // and the region below renders the error view. Letting the rejection escape as well surfaced it\n // as an unhandled rejection, which a host app's global handler reports as a crash it cannot act\n // on. Nothing subscribes to the `load:error` hook, though, so catching it without saying\n // anything would leave a failed load with no trace at all for whoever has to debug it.\n grid.init().catch((error: unknown) => {\n if (process.env.NODE_ENV !== 'production') {\n console.error('[DataGrid] Initial load failed:', error);\n }\n });\n return () => grid.destroy();\n }, [grid]);\n\n return (\n <DataGridLayoutContent>\n <LoadControlled loadState={loadState}>\n <DataGridLayoutTop />\n <DataGridLayoutMain />\n {!isEmpty && <DataGridLayoutSlot name=\"bottom\" />}\n </LoadControlled>\n </DataGridLayoutContent>\n );\n}\n","import type { StoreApi, UseBoundStore } from 'zustand';\nimport { create } from 'zustand';\n\nexport type LoadState = 'blank' | 'loading' | 'error' | 'loaded';\n\nexport interface LoadStateStore {\n loadState: LoadState;\n}\n\nexport type UseLoadStateStore = UseBoundStore<StoreApi<LoadStateStore>>;\n\nexport interface LoadStateManager {\n useLoadState: UseLoadStateStore;\n setLoading: () => void;\n setLoaded: () => void;\n setError: () => void;\n setBlank: () => void;\n /** Back to idle, and detaches the `loadPromise` in flight so its outcome no longer writes. */\n reset: () => void;\n loadPromise: <T>(promise: Promise<T>) => Promise<T>;\n}\n\n/**\n * A zustand store holding a `blank -> loading -> loaded | error` state, plus the helpers that move\n * it. `loadPromise` follows a promise: loading while it is pending, then loaded or error.\n */\nexport function createLoadStateManager(): LoadStateManager {\n const useLoadStateStore = create<LoadStateStore>()(() => ({\n loadState: 'blank',\n }));\n // Which `loadPromise` owns the state. A later one, or a `reset`, takes it over, and the outcome\n // of the one it replaced no longer writes: a load that was cut off must not come back later and\n // mark the state loaded, or failed, over whatever the state has become since.\n let owner = 0;\n\n return {\n useLoadState: useLoadStateStore,\n setLoading,\n setLoaded,\n setError,\n setBlank,\n reset,\n loadPromise,\n };\n\n function setLoading() {\n useLoadStateStore.setState({ loadState: 'loading' });\n }\n\n function setLoaded() {\n useLoadStateStore.setState({ loadState: 'loaded' });\n }\n\n function setError() {\n useLoadStateStore.setState({ loadState: 'error' });\n }\n\n function setBlank() {\n useLoadStateStore.setState({ loadState: 'blank' });\n }\n\n function reset() {\n owner += 1;\n setBlank();\n }\n\n async function loadPromise<T>(promise: Promise<T>): Promise<T> {\n const mine = ++owner;\n setLoading();\n try {\n const result = await promise;\n if (mine === owner) setLoaded();\n return result;\n } catch (error) {\n if (mine === owner) setError();\n throw error;\n }\n }\n}\n","import { create } from 'zustand';\nimport { createLoadStateManager } from '../../utils/load-state';\nimport type { CoreService, ExternalLoadingStore } from './core-types';\n\nexport function createCoreService(): CoreService {\n const { useLoadState, loadPromise, reset } = createLoadStateManager();\n\n const useExternalLoadingStore = create<ExternalLoadingStore>()(() => ({\n loading: false,\n }));\n\n return {\n useLoadStateStore: useLoadState,\n loadPromise,\n resetLoadState: reset,\n useExternalLoadingStore,\n updateLoading,\n };\n\n function updateLoading(loading: boolean) {\n useExternalLoadingStore.setState({ loading });\n }\n}\n","import { createHooked } from '../../utils/hooked';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridHooked, DataGridHooks } from './hooked-types';\n\nexport function createHookedService<TItem extends DataGridItem>(): DataGridHooked<TItem> {\n const hooked = createHooked<DataGridHooks<TItem>>();\n\n return {\n hook: hooked.hook,\n callHook: hooked.callHook,\n callHookParallel: hooked.callHookParallel,\n callHookSync: hooked.callHookSync,\n };\n}\n","/*\n * Ids of the built-in main views, owned by the core rather than by what registers them (the table\n * view is registered by the core itself; a cards view is registered by a plugin). The core reads\n * them (the view selector's labels, `DATA_GRID_VIEW`), and the core's entry must not import a\n * plugin module to do it: that would pull the plugin's code and CSS into every grid that never\n * uses it.\n */\nexport const TABLE_LAYOUT_SLOT_ID = 'table_layout';\nexport const CARDS_LAYOUT_SLOT_ID = 'cards_layout';\n","import { messages } from '../../../messages';\nimport { Segment } from '../../../components/segment';\nimport { ToggleGroupItem } from '../../../../toggle-group/public.js';\nimport { useDataGridContext } from '../../core/data-grid-context';\nimport { CARDS_LAYOUT_SLOT_ID, TABLE_LAYOUT_SLOT_ID } from '../layout-slot-ids';\n\nexport const VIEW_SELECTOR_SLOT_ID = 'view_selector';\n\n// The label of each built-in view. A view the grid does not know (a plugin's own main slot) has\n// none, and is named by its id instead.\nconst slotLabels = new Map<string, string>([\n [TABLE_LAYOUT_SLOT_ID, messages.layoutMainSlotSelector.table],\n [CARDS_LAYOUT_SLOT_ID, messages.layoutMainSlotSelector.cards],\n]);\n\nexport function DataGridLayoutMainSlotSelector() {\n const context = useDataGridContext();\n\n const mainSlots = context.layout.useLayoutStore((state) => state.slots.get('main'));\n const activeSlotId = context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n\n if (!mainSlots || mainSlots.length < 2) return null;\n\n return (\n <Segment size=\"sm\" iconOnly value={activeSlotId} onValueChange={handleValueChange}>\n {mainSlots.map((slot) => {\n const Icon = 'icon' in slot ? slot.icon : undefined;\n return (\n <ToggleGroupItem\n key={slot.id}\n value={slot.id}\n aria-label={slotLabels.get(slot.id) ?? slot.id}\n >\n {Icon ? <Icon /> : null}\n </ToggleGroupItem>\n );\n })}\n </Segment>\n );\n\n function handleValueChange(value: string | undefined) {\n if (value) {\n context.layout.setActiveSlotId('main', value);\n }\n }\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport {\n DataGridLayoutMainSlotSelector,\n VIEW_SELECTOR_SLOT_ID,\n} from './components/data-grid-layout-main-slot-selector';\nimport type {\n LayoutPublicApi,\n LayoutService,\n LayoutSlot,\n LayoutSlotName,\n LayoutSlotOptions,\n LayoutStore,\n} from './layout-types';\n\nexport function createLayoutService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): LayoutService {\n const useLayoutStore = create<LayoutStore>()(() => ({\n slots: new Map(),\n activeSlotIds: new Map(),\n }));\n\n const publicApi: LayoutPublicApi = {\n registerSlot,\n setActiveSlotId,\n getActiveSlotId,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n useLayoutStore,\n };\n\n function getSlotById<T extends LayoutSlotName>(name: T, id: string) {\n return getLayoutSlots(name).find((slot) => slot.id === id) as Extract<\n LayoutSlot,\n { name: T }\n >;\n }\n\n function getLayoutSlots<T extends LayoutSlotName>(name: T) {\n return (useLayoutStore.getState().slots.get(name) ?? []) as Extract<\n LayoutSlot,\n { name: T }\n >[];\n }\n\n function registerSlot<T extends LayoutSlotName>(name: T, options: LayoutSlotOptions[T]) {\n if ((name === 'top-start' || name === 'top-end') && !getSlotById('top', 'default')) {\n registerSlot('top', {\n id: 'default',\n active: true,\n component: () => null,\n });\n }\n\n const id = options.id ?? Math.random().toString();\n const existingSlots = getLayoutSlots(name);\n const order = options.order ?? (existingSlots.length + 1) * 10;\n const newSlot: LayoutSlot = { id, name, ...options, order };\n const newSlots = [...existingSlots, newSlot].sort((a, b) => a.order - b.order);\n\n useLayoutStore.setState((state) => {\n const newSlotsMap = new Map(state.slots);\n newSlotsMap.set(name, newSlots);\n return { slots: newSlotsMap };\n });\n\n if ('active' in options && options.active) {\n setActiveSlotId(name, newSlot.id);\n } else if (newSlots.length === 1) {\n setActiveSlotId(name, newSlot.id);\n }\n\n // Auto-mount the main-slot view selector once there are two or more main views to switch\n // between. Guarded so a third main slot does not register a second selector.\n if (name === 'main' && newSlots.length >= 2 && !getSlotById('top-end', VIEW_SELECTOR_SLOT_ID)) {\n registerSlot('top-end', {\n id: VIEW_SELECTOR_SLOT_ID,\n component: DataGridLayoutMainSlotSelector,\n });\n }\n }\n\n function setActiveSlotId(name: LayoutSlotName, id: string) {\n useLayoutStore.setState((state) => {\n const newActiveSlotIds = new Map(state.activeSlotIds);\n newActiveSlotIds.set(name, id);\n return { activeSlotIds: newActiveSlotIds };\n });\n }\n\n function getActiveSlotId(name: LayoutSlotName) {\n return useLayoutStore.getState().activeSlotIds.get(name);\n }\n}\n","/** Any non-null object, arrays included: the shape a value must have to be read by key. */\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","import { isRecord } from '../../utils/is-record';\nimport { createLoadStateManager } from '../../utils/load-state';\nimport type {\n InternalContext,\n DataGridItem,\n DataGridLoadContext,\n DataGridLoadResult,\n} from '../../data-grid-types';\nimport type { LoadInstance, LoadTriggerConfig } from './load-types';\n\nexport function createLoadInstance<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n config?: LoadTriggerConfig,\n): LoadInstance<TItem> {\n const id = (config?.id ?? Math.random()).toString();\n const controller = new AbortController();\n const loadStateManager = createLoadStateManager();\n const loadContext: DataGridLoadContext = structuredClone(config?.loadContext ?? {});\n let fetchResult: DataGridLoadResult<TItem> | undefined;\n let processResult: DataGridLoadResult<TItem> | undefined;\n let error: Error | undefined;\n // The hooks are handed `instance` while the load is starting, before its promise exists, so the\n // getter below reads a slot that is filled in right after the instance is built.\n const started: { promise?: Promise<void> } = {};\n const instance: LoadInstance<TItem> = {\n id,\n useLoadState: loadStateManager.useLoadState,\n signal: controller.signal,\n abort,\n refresh: config?.refresh ?? null,\n get promise() {\n return started.promise!;\n },\n get loadContext() {\n return loadContext;\n },\n get processResult() {\n return processResult;\n },\n get fetchResult() {\n return fetchResult;\n },\n get error() {\n return error;\n },\n };\n\n started.promise = loadStateManager.loadPromise(executeLoad());\n\n return instance;\n\n function abort() {\n controller.abort();\n }\n\n async function executeLoad() {\n try {\n await context.hooked.callHookParallel('load:prepare', instance);\n // Call the load:context hook first to collect context data from plugins\n const extraContext = await context.hooked.callHookParallel('load:context', instance);\n\n // Merge all returned context data into the main loadContext\n mergeContextData(loadContext, extraContext);\n\n const data = {\n ...instance.loadContext,\n signal: instance.signal,\n };\n\n fetchResult = await context.config.load.current(data);\n\n assertLoadResult(fetchResult);\n\n processResult = (await context.hooked.callHook('load:process', instance))[0] ?? fetchResult;\n\n assertLoadResult(processResult);\n\n // Skip storing if store flag is explicitly false\n if (config?.store !== false) {\n const stored = context.hooked.callHookSync('load:store', instance);\n\n if (!stored.length || stored.every((item) => item !== true)) {\n context.storage.clearSections();\n context.storage.createSection({ loadContext }, processResult.results);\n }\n }\n\n await context.hooked.callHook('load:success', instance);\n } catch (e: unknown) {\n error = e as Error;\n await context.hooked.callHook('load:error', instance);\n throw error;\n }\n }\n\n function assertLoadResult(result: unknown): asserts result is DataGridLoadResult<TItem> {\n if (typeof result !== 'object' || result === null || !('results' in result)) {\n throw new Error(\n `Load result must be an object with \"results\" and \"total?\" properties. Got ${JSON.stringify(result)}`,\n );\n }\n }\n\n function mergeContextData(target: Record<string, unknown>, fromArray: (object | void)[]) {\n for (const result of fromArray ?? []) {\n if (!isRecord(result)) continue;\n\n // key will be filters, pagination, order, ...\n for (const key in result) {\n const value = result[key];\n if (!isRecord(value)) continue;\n\n if (Array.isArray(value)) {\n target[key] = value;\n } else {\n target[key] ??= {};\n const merged = target[key];\n if (isRecord(merged)) {\n Object.assign(merged, value);\n }\n }\n }\n }\n }\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { createLoadInstance } from './load-instance';\nimport type {\n LoadInstance,\n LoadInstanceId,\n LoadPublicApi,\n LoadService,\n LoadTriggerConfig,\n RefreshOptions,\n RefreshOptionsRaw,\n LoadStateStore,\n} from './load-types';\n\nexport function createLoadService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): LoadService<TItem> {\n const instances = new Map<LoadInstanceId, LoadInstance<TItem>>();\n // The subset of `instances` whose result replaces the visible record set. Tracked alongside\n // rather than derived on read, so a child fetch outliving the root load still flips the state\n // back: `instances` alone stays non-empty and would never notify.\n const recordInstanceIds = new Set<LoadInstanceId>();\n // The newest refresh, so a first load that a refresh superseded can wait for the load that\n // replaces it.\n let latestRefresh: Promise<void> | undefined;\n\n const useLoadStateStore = create<LoadStateStore>()(() => ({\n loadState: 'blank',\n recordsLoadState: 'blank',\n }));\n\n const publicApi: LoadPublicApi<TItem> = {\n triggerLoad,\n refresh,\n abort,\n getLoadInstances,\n useLoadStateStore,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n init,\n };\n\n function syncLoadState() {\n useLoadStateStore.setState({\n loadState: instances.size > 0 ? 'loading' : 'blank',\n recordsLoadState: recordInstanceIds.size > 0 ? 'loading' : 'blank',\n });\n }\n\n /**\n * Whether this load ends up replacing what the grid is showing.\n *\n * `store: false` opts out of storage entirely -- a load that pages through the whole data set\n * runs that way -- and a load scoped to a tree parent appends a section beneath that row instead\n * of clearing the rest. Both leave the visible rows usable, so neither should raise the overlay.\n */\n function replacesRecords(triggerConfig?: LoadTriggerConfig): boolean {\n if (triggerConfig?.store === false) {\n return false;\n }\n\n return triggerConfig?.loadContext?.tree?.parentId == null;\n }\n\n function getLoadInstances(): LoadInstance<TItem>[] {\n return [...instances.values()];\n }\n\n function abort() {\n for (const instance of instances.values()) {\n instance.abort();\n }\n }\n\n /**\n * Waits for a load, and says whether this service aborted it itself (`true`) instead of it\n * finishing. An abort counts as settled, not failed.\n *\n * The service aborts what is in flight when a refresh starts its own load, and when the grid is\n * destroyed, so nobody is waiting for the aborted one's result any more. Its rejection (a `load`\n * that honours `signal` rejects with an AbortError) is the abort doing its job: reported from\n * `refresh()` it is an unhandled rejection at every call site that does not catch it (the plugins\n * do not), and reported from the first load it latches the grid into its error view, or logs a\n * failure for a grid that is simply gone.\n *\n * `signal.aborted` means the load was aborted through this service: by a refresh, by `destroy()`,\n * or by the public `abort()`, which a consumer's code can call too, so a consumer's abort settles\n * the same way. An AbortError a consumer's own `load` raises (its own timeout, say) does not set\n * the signal and still rejects, and so does any other failure.\n */\n async function settle(instance: LoadInstance<TItem>): Promise<boolean> {\n try {\n await instance.promise;\n return false;\n } catch (error) {\n if (instance.signal.aborted) return true;\n throw error;\n }\n }\n\n /**\n * The first load is done when the data the grid shows has arrived. A refresh that aborts it\n * carries that data from then on, so it is followed instead of settled: the first load is done\n * when that refresh's load is, through any refreshes that supersede it in turn. If that load\n * fails, so has the first one, since nothing ever loaded. If `destroy()` aborts it, nothing is\n * left to wait for, and the grid has not loaded: `destroy()` puts the core back to idle.\n */\n async function init() {\n await context.hooked.callHook('init');\n const refreshBefore = latestRefresh;\n if (!(await settle(triggerLoad()))) return;\n\n let followed = refreshBefore;\n while (latestRefresh !== followed) {\n followed = latestRefresh;\n await followed;\n }\n }\n\n function refresh(options: RefreshOptionsRaw = {}): Promise<void> {\n latestRefresh = runRefresh(options);\n return latestRefresh;\n }\n\n async function runRefresh(options: RefreshOptionsRaw) {\n abort();\n const refreshOptions: RefreshOptions = { resetFilters: options.resetFilters ?? true };\n await context.hooked.callHook('refresh', refreshOptions);\n await settle(triggerLoad({ refresh: refreshOptions }));\n }\n\n function triggerLoad(triggerConfig?: LoadTriggerConfig): LoadInstance<TItem> {\n const instance = createLoadInstance<TItem>(context, triggerConfig);\n\n instances.set(instance.id, instance);\n if (replacesRecords(triggerConfig)) {\n recordInstanceIds.add(instance.id);\n }\n syncLoadState();\n\n instance.promise\n .finally(() => {\n instances.delete(instance.id);\n recordInstanceIds.delete(instance.id);\n syncLoadState();\n })\n // Bookkeeping only. The rejection itself belongs to whoever awaited the instance's promise;\n // this branch re-raising it would land as an unhandled rejection with no one to catch it.\n .catch(() => undefined);\n\n return instance;\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { isRecord } from '../../utils/is-record';\nimport type {\n PersistOptions,\n UsePersistentState,\n PersistentStateService,\n PersistentStatePublicApi,\n} from './persistent-state-types';\n\nexport function createPersistentStateService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): PersistentStateService {\n const subscribers = new Map<string, Set<() => void>>();\n // Backing for the 'memory' mode, scoped to the grid instance: state survives\n // re-renders within one mount and resets on remount.\n const memoryStore = new Map<string, unknown>();\n const gridName = context.config.name;\n const persistMode = context.config.persistent ?? 'localStorage';\n\n const publicApi: PersistentStatePublicApi = {\n registerPersistentState,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return publicApi;\n\n function getStorageKey(key: string) {\n return `dataGrid:${gridName}:${key}`;\n }\n\n // Browser storage can be unavailable in ways that throw instead of returning `null`: reading the\n // `localStorage` property itself raises a SecurityError where storage is blocked (a sandboxed or\n // third-party iframe, \"block all cookies\"), and a write raises once the quota is used up. Both\n // mean \"this view is not remembered\", never \"the grid cannot render\" -- plugins read storage in\n // render, so a throw here would take the whole grid down -- so each access below falls back to\n // no persistence, the same way a stored value that is not JSON reads as absent.\n function getStorage(area: 'localStorage' | 'sessionStorage'): Storage | null {\n if (typeof window === 'undefined') return null;\n\n try {\n return area === 'localStorage' ? localStorage : sessionStorage;\n } catch {\n return null;\n }\n }\n\n function registerPersistentState<T>(\n key: string,\n options: PersistOptions = {},\n ): UsePersistentState<T> {\n const storageKey = getStorageKey(key);\n // `storage` names the backend for this one state, overriding the grid-wide mode. For\n // state that belongs to the viewer rather than to the view they would share — a column\n // selection, say, next to filters that stay in the URL.\n const mode = options.storage ?? persistMode;\n // A state registered with `router: false` opted out of URL persistence:\n // in router mode it reads and writes nothing, other backends are unaffected.\n const isDisabled = mode === 'router' && options.router === false;\n\n return {\n get value() {\n return getValue();\n },\n setValue,\n buildStorageItem,\n };\n\n function getValue(): T | undefined {\n if (isDisabled) {\n return undefined;\n }\n\n if (mode === 'memory') {\n return memoryStore.get(key) as T | undefined;\n }\n\n if (mode === 'router') {\n // URL-based persistence\n const params = new URLSearchParams(window.location.search);\n return parseStored<T>(params.get(key));\n }\n\n const storage = getStorage(mode);\n if (!storage) return undefined;\n\n return parseStored<T>(readItem(storage, storageKey));\n }\n\n function setValue(value: T | undefined) {\n if (isDisabled) {\n return;\n }\n\n if (mode === 'memory') {\n if (value === undefined) {\n memoryStore.delete(key);\n } else {\n memoryStore.set(key, value);\n }\n } else if (mode === 'router') {\n const params = new URLSearchParams(window.location.search);\n if (value === undefined) {\n params.delete(key);\n } else {\n params.set(key, JSON.stringify(value));\n }\n const newUrl = `${window.location.pathname}?${params.toString()}`;\n window.history.replaceState(null, '', newUrl);\n } else {\n const storage = getStorage(mode);\n if (!storage) return;\n\n try {\n if (value === undefined) {\n storage.removeItem(storageKey);\n } else {\n storage.setItem(storageKey, JSON.stringify(value));\n }\n } catch {\n // Quota or blocked: the plugin keeps the state in its own store, it just is not remembered.\n }\n }\n\n // Notify subscribers\n subscribers.get(key)?.forEach((fn) => fn());\n }\n\n function buildStorageItem(value: T): Record<string, unknown> {\n // Build URL query params based on schema\n if (!options.schema) return { [key]: value };\n\n const result: Record<string, unknown> = {};\n Object.entries(options.schema).forEach(([field]) => {\n const val = isRecord(value) ? value[field] : undefined;\n if (val !== undefined) {\n result[field] = val;\n }\n });\n return result;\n }\n }\n}\n\nfunction readItem(storage: Storage, key: string): string | null {\n try {\n return storage.getItem(key);\n } catch {\n return null;\n }\n}\n\n/**\n * A stored value is a string the user can edit -- through devtools on `localStorage` and\n * `sessionStorage`, through the address bar on the router mode -- so it is not certain to be JSON\n * at all. A value that will not parse reads as an absent one rather than throwing: a `localStorage`\n * entry is read on every mount, so a throw here would leave the grid unable to render until\n * someone cleared site data. Narrowing what did parse is the caller's job.\n */\nfunction parseStored<T>(raw: string | null): T | undefined {\n if (!raw) return undefined;\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return undefined;\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport type {\n DataGridPlugin,\n DataGridPluginContext,\n PluginsPublicApi,\n PluginsService,\n ServicesPublicApiTypes,\n} from './plugins-types';\n\nexport function createPluginsService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): PluginsService<TItem> {\n const pluginApis = new Map<string, unknown>();\n const pluginPublicApi: PluginsPublicApi<TItem> = {\n hook: context.hooked.hook,\n getPlugin,\n };\n\n // Starts with the plugins' own API and grows as every other service registers its public API\n // through `registerPublicApi` while the grid is being created. Plugins only see it afterwards,\n // when it is complete, which a type cannot express for an object filled in over time.\n const pluginContext = { ...pluginPublicApi } as DataGridPluginContext<TItem>;\n\n return {\n ...pluginPublicApi,\n registerPlugin,\n registerPlugins,\n registerPublicApi,\n pluginContext,\n };\n\n function registerPublicApi(methods: ServicesPublicApiTypes<TItem>) {\n Object.assign(pluginContext, methods);\n }\n\n function registerPlugin(plugin: DataGridPlugin<TItem>) {\n if (pluginApis.has(plugin.name)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[DataGrid] Plugin \"${plugin.name}\" is already registered. Skipping duplicate.`,\n );\n }\n return;\n }\n\n const api = plugin.setup(pluginContext);\n if (api !== undefined) {\n pluginApis.set(plugin.name, api);\n }\n }\n\n function registerPlugins(plugins: DataGridPlugin<TItem>[]) {\n plugins.forEach((plugin) => registerPlugin(plugin));\n }\n\n function getPlugin<TApi>(name: string): TApi | undefined {\n return pluginApis.get(name) as TApi | undefined;\n }\n}\n","import type { DataGridItem } from '../../data-grid-types';\nimport type { DataGridDataKey, DataGridItemId } from './storage-types';\n\nexport function getItemKeyValue<TItem extends DataGridItem = DataGridItem>(\n item: TItem,\n key: DataGridDataKey<TItem>,\n) {\n if (typeof key === 'string') {\n if (!(key in item)) {\n throw new Error(`Key \"${key}\" not found in item ${JSON.stringify(item)}`);\n }\n return item[key] as DataGridItemId;\n }\n\n return key(item);\n}\n","import { create } from 'zustand';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { getItemKeyValue } from './storage-helpers';\nimport type {\n DataGridItemId,\n DataGridParentId,\n DataGridRecord,\n DataGridRecords,\n DataGridSection,\n DataGridSectionConfig,\n DataGridSectionId,\n StoragePublicApi,\n StorageService,\n StorageStoreInternal,\n} from './storage-types';\n\nexport function createStorageService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): StorageService<TItem> {\n const useStore = create<StorageStoreInternal<TItem>>()(() => ({\n sections: new Map(),\n recordSections: new Map(),\n visibleRecords: [],\n rootSections: [],\n visibleSections: [],\n hasActiveFilters: false,\n }));\n\n let implicitFilterKeys: string[] = [];\n\n const publicApi: StoragePublicApi<TItem> = {\n useStore,\n clearSections,\n createSection,\n getSections,\n getRecord,\n getSectionsByParentId,\n getRecordsByParentId,\n getItemId,\n };\n\n context.plugins.registerPublicApi(publicApi);\n\n return { ...publicApi, updateImplicitFilterKeys };\n\n function createSection(config: DataGridSectionConfig, items: TItem[]) {\n const sectionId = Math.random().toString();\n const parentId = config.parentId ?? null;\n const newSection: DataGridSection<TItem> = {\n id: sectionId,\n visible: true,\n parentId,\n loadContext: config.loadContext,\n records: [],\n };\n\n const itemKey = context.config.itemKey ?? 'id';\n for (const [index, item] of items.entries()) {\n const itemId = getItemKeyValue(item, itemKey);\n newSection.records.push({ id: itemId, item, index, section: newSection });\n }\n\n useStore.setState((state) => {\n const sections = new Map(state.sections);\n const recordSections = new Map(state.recordSections);\n\n sections.set(sectionId, newSection);\n recordSections.set(parentId, [...(recordSections.get(parentId) ?? []), sectionId]);\n const { visibleRecords, rootSections, visibleSections, hasActiveFilters } =\n computeDerivedState(sections, recordSections);\n\n return {\n sections,\n recordSections,\n visibleRecords,\n rootSections,\n visibleSections,\n hasActiveFilters,\n };\n });\n\n return newSection;\n }\n\n function clearSections() {\n useStore.setState({\n sections: new Map(),\n recordSections: new Map(),\n visibleRecords: [],\n rootSections: [],\n visibleSections: [],\n hasActiveFilters: false,\n });\n }\n\n function getSections(): DataGridSection<TItem>[] {\n return [...useStore.getState().sections.values()];\n }\n\n function getRecord(id: DataGridItemId): DataGridRecord<TItem> | undefined {\n for (const section of useStore.getState().sections.values()) {\n const record = section.records.find((r) => r.id === id);\n if (record) {\n return record;\n }\n }\n return undefined;\n }\n\n function getSectionsByParentId(parentId: DataGridParentId): DataGridSection<TItem>[] {\n const state = useStore.getState();\n const sectionIds = state.recordSections.get(parentId) ?? [];\n return sectionIds.map((id) => state.sections.get(id)!).filter(Boolean);\n }\n\n function getRecordsByParentId(parentId: DataGridParentId): DataGridRecords<TItem> {\n return getSectionsByParentId(parentId).flatMap((section) => section.records);\n }\n\n function getItemId(item: TItem): DataGridItemId {\n const itemKey = context.config.itemKey ?? 'id';\n return getItemKeyValue(item, itemKey);\n }\n\n function isFilterValueActive(value: unknown): boolean {\n if (value === undefined || value === null) return false;\n if (typeof value === 'boolean') return true;\n if (Array.isArray(value)) return value.length > 0;\n return Boolean(value);\n }\n\n // hasActiveFilters is computed eagerly into the store, so changing the keys has to\n // recompute it rather than wait for the next section change. Compared by reference, like\n // `columns`: the prop is documented as referentially stable, so a new array means new keys.\n function updateImplicitFilterKeys(keys: string[]) {\n if (implicitFilterKeys === keys) return;\n\n implicitFilterKeys = keys;\n useStore.setState((state) => computeDerivedState(state.sections, state.recordSections));\n }\n\n function computeDerivedState(\n sections: Map<DataGridSectionId, DataGridSection<TItem>>,\n recordSections: Map<DataGridParentId, DataGridSectionId[]>,\n ) {\n const allSections = [...sections.values()];\n const visibleSections = allSections.filter((section) => section.visible);\n const rootSectionIds = recordSections.get(null) ?? [];\n const rootSections = rootSectionIds\n .map((id) => sections.get(id)!)\n .filter((section) => section.visible);\n const visibleRecords = visibleSections.flatMap((section) => section.records);\n const hasActiveFilters = visibleSections.some((section) => {\n const { filters } = section.loadContext;\n if (!filters) return false;\n return Object.entries(filters).some(\n ([key, filter]) => !implicitFilterKeys.includes(key) && isFilterValueActive(filter?.value),\n );\n });\n\n return {\n visibleSections,\n rootSections,\n visibleRecords,\n hasActiveFilters,\n };\n }\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { getNestedValue, resolveCellDisplayValue } from '../table-helpers';\nimport type { DataGridTableColumn } from '../table-types';\n\ninterface DataGridBodyCellContentProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n item: TItem;\n}\n\nexport function DataGridBodyCellContent<TItem extends DataGridItem>({\n column,\n item,\n}: DataGridBodyCellContentProps<TItem>) {\n // Column-specific render function takes priority\n if (column.render) {\n if (typeof column.render === 'function') {\n return <>{column.render(item)}</>;\n }\n return <>{column.render}</>;\n }\n\n // Column-specific component\n if (column.component) {\n const CellComponent = column.component;\n const key = column.key ?? column.id;\n const value = key.includes('.') ? getNestedValue(item, key) : item[key];\n return <CellComponent item={item} column={column} value={value} />;\n }\n\n // Default: resolve value from key (shared with the `title` fallback in DataGridRow)\n return <>{resolveCellDisplayValue(column, item)}</>;\n}\n","import type { ReactNode } from 'react';\n\ninterface DataGridContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridContent({ children }: DataGridContentProps) {\n return <>{children}</>;\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { resolveLabel } from '../table-helpers';\nimport type { DataGridTableColumn } from '../table-types';\n\ninterface DataGridHeaderCellLabelProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n}\n\nexport function DataGridHeaderCellLabel<TItem extends DataGridItem>({\n column,\n}: DataGridHeaderCellLabelProps<TItem>) {\n return <span>{resolveLabel(column.label)}</span>;\n}\n","import type { ReactNode } from 'react';\nimport styles from './data-grid-header-cell.module.css';\n\ninterface DataGridHeaderCellContentProps {\n children?: ReactNode;\n}\n\nexport function DataGridHeaderCellContent({ children }: DataGridHeaderCellContentProps) {\n return <span className={styles.headerCellContent}>{children}</span>;\n}\n","import { cx } from 'class-variance-authority';\nimport { TableHead } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport { resolveLabel } from '../table-helpers';\nimport type { DataGridTableGroup } from '../table-types';\nimport styles from './data-grid-cell.module.css';\nimport headerStyles from './data-grid-header-cell.module.css';\nimport { DataGridHeaderCellContent } from './data-grid-header-cell-content';\n\ninterface DataGridHeaderGroupProps<TItem extends DataGridItem> {\n group: DataGridTableGroup<TItem>;\n colspan?: number;\n className?: string;\n}\n\nexport function DataGridHeaderGroup<TItem extends DataGridItem>({\n group,\n colspan,\n className,\n}: DataGridHeaderGroupProps<TItem>) {\n const tableService = useTableService<TItem>();\n\n const stickyOffset = tableService.useGroupStickyOffset(group.id);\n const isSticky = stickyOffset !== undefined;\n\n const GroupContent = group.component;\n\n const content = GroupContent ? (\n <GroupContent group={group} />\n ) : (\n <DataGridHeaderCellContent>{resolveLabel(group.label)}</DataGridHeaderCellContent>\n );\n\n return (\n <TableHead\n className={cx(styles.cell, headerStyles.headerCell, className)}\n pinned={isSticky}\n style={isSticky ? { insetInlineStart: `${stickyOffset}px` } : undefined}\n scope=\"col\"\n colSpan={colspan}\n >\n {content}\n </TableHead>\n );\n}\n","import { TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { DataGridRecordProvider } from '../data-grid-record-context';\nimport { resolveBodyCellProps } from '../resolve-body-cell-props';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableColumn } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport { DataGridExtraBodyColumns } from './data-grid-extra-body-columns';\n\ninterface DataGridRowProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridRow<TItem extends DataGridItem>({ record }: DataGridRowProps<TItem>) {\n const tableService = useTableService<TItem>();\n const columns = tableService.useVisibleColumns();\n const tableLayout = tableService.useTableLayout();\n\n const BodyCellContent = tableService.useComponent<{ column: DataGridTableColumn<TItem>; item: TItem }>(\n 'body-cell-content',\n );\n\n return (\n <DataGridRecordProvider value={record}>\n <TableRow>\n <DataGridExtraBodyColumns position=\"start\" />\n {columns.map((col) => {\n const dynamicClassName = col.getClassName?.(record.item);\n const bodyCellProps = resolveBodyCellProps(col, record.item, tableLayout);\n\n return (\n <DataGridCell<TItem>\n key={col.id}\n columnId={col.id}\n className={dynamicClassName}\n {...bodyCellProps}\n >\n <BodyCellContent column={col} item={record.item} />\n </DataGridCell>\n );\n })}\n <DataGridExtraBodyColumns position=\"end\" />\n </TableRow>\n </DataGridRecordProvider>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { useTableService } from '../table-context';\n\ninterface DataGridTableRecordProps<TItem extends DataGridItem> {\n record: DataGridRecord<TItem>;\n}\n\nexport function DataGridTableRecord<TItem extends DataGridItem>({\n record,\n}: DataGridTableRecordProps<TItem>) {\n const tableService = useTableService<TItem>();\n const RowComponent = tableService.useComponent<DataGridTableRecordProps<TItem>>('row');\n\n // eslint-disable-next-line react-hooks/static-components -- RowComponent comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n return <RowComponent record={record} />;\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport type { DataGridRecord } from '../../storage/storage-types';\nimport { DataGridTableRecord } from './data-grid-table-record';\n\ninterface DataGridTableRecordsProps<TItem extends DataGridItem> {\n records: DataGridRecord<TItem>[];\n}\n\nexport function DataGridTableRecords<TItem extends DataGridItem>({\n records,\n}: DataGridTableRecordsProps<TItem>) {\n return (\n <>\n {records.map((record) => (\n <DataGridTableRecord<TItem> key={record.id} record={record} />\n ))}\n </>\n );\n}\n","import { TableBody } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useDataGrid } from '../../core/data-grid-context';\nimport { DataGridTableRecords } from './data-grid-table-records';\n\nexport function DataGridTableBody<TItem extends DataGridItem>() {\n const grid = useDataGrid<TItem>();\n const rootSections = grid.useStore((s) => s.rootSections);\n\n return (\n <>\n {rootSections.map((section) => (\n <TableBody key={section.id}>\n <DataGridTableRecords<TItem> records={section.records} />\n </TableBody>\n ))}\n </>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cx } from 'class-variance-authority';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport type { ExtraColumn } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport styles from './data-grid-header-cell.module.css';\nimport { DataGridHeaderCellContent } from './data-grid-header-cell-content';\n\ninterface DataGridExtraHeaderCellProps {\n column: ExtraColumn;\n rowspan?: number;\n className?: string;\n children?: ReactNode;\n}\n\nexport function DataGridExtraHeaderCell<TItem extends DataGridItem>({\n column,\n rowspan,\n className,\n children,\n}: DataGridExtraHeaderCellProps) {\n return (\n <DataGridCell<TItem>\n header\n columnId={column.id}\n className={cx(styles.extraHeaderCell, className)}\n width={column.width}\n rowspan={rowspan}\n ignoreRowClick={column.ignoreRowClick}\n >\n {children ? <DataGridHeaderCellContent>{children}</DataGridHeaderCellContent> : null}\n </DataGridCell>\n );\n}\n","import type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { ExtraColumnPosition } from '../table-types';\nimport { DataGridExtraHeaderCell } from './data-grid-extra-header-cell';\n\ninterface DataGridExtraHeaderColumnsProps {\n position: ExtraColumnPosition;\n isGroupRow?: boolean;\n className?: string;\n}\n\nexport function DataGridExtraHeaderColumns<TItem extends DataGridItem>({\n position,\n isGroupRow,\n className,\n}: DataGridExtraHeaderColumnsProps) {\n const tableService = useTableService<TItem>();\n const hasGroups = tableService.useHasGroups();\n const extraColumns = tableService.useExtraColumns(position);\n\n // When groups exist, extra columns should only render on the group row\n const shouldRender = !hasGroups || isGroupRow;\n\n return (\n <>\n {extraColumns.map((extra) => (\n <DataGridExtraHeaderCell<TItem>\n key={extra.id}\n column={extra}\n rowspan={shouldRender && hasGroups ? 2 : undefined}\n className={className}\n >\n {shouldRender && extra.header ? <extra.header /> : null}\n </DataGridExtraHeaderCell>\n ))}\n </>\n );\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStore } from './table-types';\n\n/**\n * Store-backed home for the measured pixel width of columns whose `width` is `'min-content'`,\n * under either `tableLayout`. `DataGridHeaderCell` measures its header content's natural size\n * with a ResizeObserver and calls `setMinContentWidth`; `resolveColumnStyle` reads it back via\n * `useMinContentWidth` to size the column's track -- under `auto`, the literal CSS `min-content`\n * keyword isn't honored by the browser's algorithm as a hint to hold a column narrow against a\n * widthless sibling; under `fixed`, there is no content-driven sizing at all, so the keyword has\n * nothing to act on either way. A measured pixel value stands in for it in both modes.\n *\n * `setMinContentWidth` skips the store write when the measured value hasn't changed. This is the\n * loop guard: the measured value drives the column's own CSS width, so an unconditional write on\n * every ResizeObserver callback would risk apply-width -> relayout -> re-measure -> apply-width\n * spinning forever. (The measurement target itself is also chosen to be size-independent of the\n * column's own width -- see `DataGridHeaderCell` -- so in practice this dedup is a backstop, not\n * the only thing preventing a loop.)\n */\nexport function prepareTableMinContentWidth<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n setMinContentWidth,\n useMinContentWidth,\n };\n\n function setMinContentWidth(columnId: string, width: number) {\n const current = useTableStore.getState().minContentWidths;\n if (current.get(columnId) === width) return;\n\n const next = new Map(current);\n next.set(columnId, width);\n useTableStore.setState({ minContentWidths: next });\n }\n\n function useMinContentWidth(columnId: string): number | undefined {\n return useTableStore((state) => state.minContentWidths.get(columnId));\n }\n}\n\n/**\n * Computes the pixel width to apply to a `width: 'min-content'` column's header `<th>` from a\n * ResizeObserver entry on its `.contentRow` wrapper (see `DataGridHeaderCell`'s measurement\n * effect) -- the wrapper's own `inline-size: min-content` CSS keeps its measured content-box size\n * independent of whatever width the `<th>` itself currently has, so this reads the column's true\n * natural content width regardless of where in the measure -> apply -> re-render cycle it's\n * called (see the loop-safety note on `setMinContentWidth` above). Adds the cell's own\n * padding/border (cells are `border-box`) so the applied width holds the full, unclipped content,\n * and rounds up to guard against sub-pixel drift across repeated measurements of the same content.\n */\nexport function measureMinContentWidth(entry: ResizeObserverEntry, cell: Element | null): number {\n const computedStyle = cell ? window.getComputedStyle(cell) : undefined;\n const paddings = computedStyle\n ? parseFloat(computedStyle.paddingInlineStart || '0') +\n parseFloat(computedStyle.paddingInlineEnd || '0')\n : 0;\n const borders = computedStyle\n ? parseFloat(computedStyle.borderInlineStartWidth || '0') +\n parseFloat(computedStyle.borderInlineEndWidth || '0')\n : 0;\n\n return Math.ceil(entry.contentRect.width + paddings + borders);\n}\n","import { useEffect, useRef } from 'react';\nimport { cx } from 'class-variance-authority';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { resolveColumnStyle } from '../resolve-column-style';\nimport { useTableService } from '../table-context';\nimport { resolveLabel } from '../table-helpers';\nimport { measureMinContentWidth } from '../table-min-content-width';\nimport type { DataGridTableColumn, TableSlot } from '../table-types';\nimport { DataGridCell } from './data-grid-cell';\nimport styles from './data-grid-header-cell.module.css';\n\ninterface DataGridHeaderCellProps<TItem extends DataGridItem> {\n column: DataGridTableColumn<TItem>;\n rowspan?: number;\n headerCellEndSlots: TableSlot[];\n className?: string;\n}\n\nexport function DataGridHeaderCell<TItem extends DataGridItem>({\n column,\n rowspan,\n headerCellEndSlots,\n className,\n}: DataGridHeaderCellProps<TItem>) {\n const tableService = useTableService<TItem>();\n const contentRowRef = useRef<HTMLSpanElement>(null);\n\n const LabelComponent = tableService.useComponent<{ column: DataGridTableColumn<TItem> }>('header-cell-label');\n const tableLayout = tableService.useTableLayout();\n const minContentWidth = tableService.useMinContentWidth(column.id);\n\n const content = column.headerComponent ? (\n <column.headerComponent column={column} />\n ) : (\n // eslint-disable-next-line react-hooks/static-components -- LabelComponent comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n <LabelComponent column={column} />\n );\n\n const configuredHeaderOverflow = column.headerOverflow ?? 'nowrap';\n // Measured under both `tableLayout` modes -- `resolveColumnStyle` applies the result as this\n // column's `auto` size or its `fixed` track respectively (see its own doc for the branch).\n const isMinContentColumn = column.width === 'min-content';\n // A min-content column is, by definition, exactly as wide as its content needs -- there's\n // nothing to truncate. Disabling the ellipsis/nowrap overflow here also keeps `.contentRow`\n // unconstrained by the `max-inline-size: 100%` the nowrap CSS would otherwise apply (see\n // data-grid-cell.module.css), so the measurement effect below reads its true natural width\n // instead of one clamped to whatever width the column happens to have before the first\n // measurement lands. `title` still follows the column's actual configured overflow (below),\n // independent of this internal measurement-mode override.\n const cellOverflow = isMinContentColumn ? undefined : configuredHeaderOverflow;\n const { headerStyle, contentVars, isCapped } = resolveColumnStyle(\n column,\n tableLayout,\n minContentWidth,\n );\n // A custom headerComponent can render anything -- the kit can't stringify it for a title\n // fallback, so the consumer is responsible for their own (documented on DataGridTableColumn).\n // `nowrap` is the clipping mode (single line, ellipsis on overflow) -- `wrap` never clips.\n const title =\n !column.headerComponent && configuredHeaderOverflow === 'nowrap'\n ? resolveLabel(column.label)\n : undefined;\n // A custom headerComponent (e.g. a select-all checkbox) needs to fill/center like a body cell,\n // not shrink-wrap to its own min-content width the way a default text label does -- see\n // `fillContent`'s doc on `DataGridCell`. `headerCellEndSlots` is table-wide (non-empty for every\n // column once a plugin like order registers a slot, even though `DataGridOrderIcon` only\n // renders for the one actively-sorted column), so it's the wrong signal for this: gating on it\n // would leave a custom header shrink-wrapped on any grid where such a plugin is registered.\n // `column.headerComponent` doesn't depend on which plugins are registered, so it handles both\n // the no-plugin and the with-plugin cases the same way. Excluded for min-content columns, whose\n // `.contentRow` must keep shrink-wrapping to stay an accurate ResizeObserver measurement target.\n // Edge case: a custom header on the actively-sorted column still gets a real end slot (the sort\n // arrow), which then sits at the filled row's far end instead of snug against the label --\n // accepted as a minor cosmetic tradeoff.\n const fillContent = Boolean(column.headerComponent) && !isMinContentColumn;\n\n // Measures `.contentRow`'s own natural (`inline-size: min-content`) width whenever it changes\n // and stores it as this column's resolved width (`resolveColumnStyle` reads it back above --\n // under `auto` as the column's size, under `fixed` as its shared track). This does not loop:\n // `.contentRow` renders at its own min-content size regardless of the `<th>`'s allocated width\n // -- under `auto` because a browser's auto table-layout algorithm doesn't stretch or shrink an\n // ordinary `inline-size: min-content` child to match its ancestor cell, and under `fixed`\n // because the `<th>`'s box (sized by the fixed track algorithm from the *header row*, before\n // any of this observer's writes land) never forces an ordinary content child to match it either\n // -- a `<th>` wider than its content just leaves the child at its own size. So applying the\n // measured width to the `<th>` never changes what this observer sees on a later fire, in either\n // mode; `setMinContentWidth` also skips the store write (and the re-render that would otherwise\n // trigger another observer callback) when the measured value hasn't changed. A genuine\n // ResizeObserver (not a one-off measurement at mount) also means this re-measures correctly if\n // CSS lands after mount (e.g. a consumer's prod bundle injecting a stylesheet `<link>`\n // post-mount), since that changes `.contentRow`'s rendered size and\n // re-fires the observer.\n useEffect(() => {\n if (!isMinContentColumn) return;\n\n const contentRow = contentRowRef.current;\n if (!contentRow) return;\n\n const cell = contentRow.closest('th, td');\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n tableService.setMinContentWidth(column.id, measureMinContentWidth(entry, cell));\n });\n observer.observe(contentRow);\n\n return () => observer.disconnect();\n }, [isMinContentColumn, column.id, tableService]);\n\n return (\n <DataGridCell\n header\n columnId={column.id}\n className={cx(styles.headerCell, className)}\n style={{ ...headerStyle, ...contentVars }}\n rowspan={rowspan}\n overflow={cellOverflow}\n // Same measurement rationale as `cellOverflow` above: `[data-capped] .contentRow` also\n // clamps to `max-inline-size: 100%`, which would re-clamp the measurement target to the\n // `<th>`'s current (possibly stale/narrow) width -- suppressing it here keeps the\n // ResizeObserver reading the column's true natural width. Body cells are unaffected: they\n // resolve their own `capped` independently via `resolveBodyCellProps`.\n capped={isMinContentColumn ? undefined : isCapped}\n title={title}\n contentRowRef={isMinContentColumn ? contentRowRef : undefined}\n fillContent={fillContent}\n endSlot={headerCellEndSlots.map((slot) => {\n const SlotComponent = slot.component;\n return <SlotComponent key={slot.id} column={column} />;\n })}\n >\n {content}\n </DataGridCell>\n );\n}\n","import { useEffect, useRef } from 'react';\nimport { cx } from 'class-variance-authority';\nimport { TableHeader, TableRow } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableColumn, DataGridTableGroup } from '../table-types';\nimport { DataGridExtraHeaderColumns } from './data-grid-extra-header-columns';\nimport { DataGridHeaderCell } from './data-grid-header-cell';\nimport { DataGridHeaderGroup } from './data-grid-header-group';\nimport styles from './data-grid-table-header.module.css';\n\nexport function DataGridTableHeader<TItem extends DataGridItem>() {\n const tableService = useTableService<TItem>();\n const theadRef = useRef<HTMLTableSectionElement>(null);\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const hasGroups = tableService.useHasGroups();\n const stickyHeader = tableService.useStickyHeader();\n const firstRowCells = tableService.useFirstRowHeaderCells();\n const secondRowColumns = tableService.useSecondRowHeaderColumns();\n const headerCellEndSlots = tableService.useSlots('header-cell-end');\n\n // Set up shared ResizeObserver for all header cells\n useEffect(() => {\n const thead = theadRef.current;\n if (!thead) return;\n\n observerRef.current = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const { columnId } = (entry.target as HTMLElement).dataset;\n if (columnId) {\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n tableService.onResizeColumn(columnId, width);\n }\n }\n });\n\n const cells = thead.querySelectorAll<HTMLElement>('[data-column-id]');\n for (const cell of cells) {\n observerRef.current.observe(cell);\n }\n\n return () => {\n observerRef.current?.disconnect();\n };\n }, [tableService, firstRowCells, secondRowColumns]);\n\n return (\n <TableHeader\n ref={theadRef}\n className={cx(stickyHeader && hasGroups && styles.theadSticky)}\n >\n <TableRow>\n <DataGridExtraHeaderColumns<TItem> position=\"start\" isGroupRow />\n\n {firstRowCells.map((cell) => {\n if (cell.type === 'group') {\n const group = cell.item as DataGridTableGroup<TItem>;\n return (\n <DataGridHeaderGroup<TItem> key={group.id} group={group} colspan={cell.colspan} />\n );\n }\n\n const column = cell.item as DataGridTableColumn<TItem>;\n return (\n <DataGridHeaderCell<TItem>\n key={column.id}\n column={column}\n rowspan={cell.rowspan}\n headerCellEndSlots={headerCellEndSlots}\n />\n );\n })}\n\n <DataGridExtraHeaderColumns<TItem> position=\"end\" isGroupRow />\n </TableRow>\n\n {/* Second row for grouped columns */}\n {hasGroups && secondRowColumns.length > 0 && (\n <TableRow>\n {secondRowColumns.map((column) => (\n <DataGridHeaderCell<TItem>\n key={column.id}\n column={column}\n headerCellEndSlots={headerCellEndSlots}\n />\n ))}\n </TableRow>\n )}\n </TableHeader>\n );\n}\n","import type { TableSlot } from '../table-types';\n\ninterface DataGridTableSlotProps {\n slots: TableSlot[];\n}\n\nexport function DataGridTableSlot({ slots }: DataGridTableSlotProps) {\n if (slots.length === 0) return null;\n\n return (\n <>\n {slots.map((slot) => {\n const SlotComponent = slot.component;\n return <SlotComponent key={slot.id} />;\n })}\n </>\n );\n}\n","import { cx } from 'class-variance-authority';\nimport type { ReactNode } from 'react';\nimport { Table } from '../../../../table/public.js';\nimport type { DataGridItem } from '../../../data-grid-types';\nimport { useTableService } from '../table-context';\nimport type { DataGridTableLayout } from '../table-types';\nimport styles from './data-grid-table.module.css';\nimport { DataGridTableBody } from './data-grid-table-body';\nimport { DataGridTableHeader } from './data-grid-table-header';\nimport { DataGridTableSlot } from './data-grid-table-slot';\n\nconst layoutClassMap: Record<DataGridTableLayout, string> = {\n fixed: styles.layoutFixed,\n auto: styles.layoutAuto,\n};\n\nexport function DataGridTable<TItem extends DataGridItem>() {\n const tableService = useTableService<TItem>();\n\n const hasGroups = tableService.useHasGroups();\n const subheaderSlots = tableService.useSlots('subheader');\n const footerSlots = tableService.useSlots('footer');\n const tableLayout = tableService.useTableLayout();\n const stickyHeader = tableService.useStickyHeader();\n\n const ContentWrapper = tableService.useComponent<{ children?: ReactNode }>('content');\n\n return (\n // eslint-disable-next-line react-hooks/static-components -- ContentWrapper comes from the grid's component registry (a store lookup), so it is the same component on every render; the rule cannot see through the lookup.\n <ContentWrapper>\n <Table\n stickyHeader={stickyHeader}\n containerClassName={styles.tableWrapper}\n className={cx(styles.table, layoutClassMap[tableLayout], hasGroups && styles.tableBordered)}\n >\n <DataGridTableHeader />\n <DataGridTableSlot slots={subheaderSlots} />\n <DataGridTableBody />\n <DataGridTableSlot slots={footerSlots} />\n </Table>\n </ContentWrapper>\n );\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableColumnsPersistence } from './table-columns-persistence';\nimport type { TableStickyService } from './table-sticky';\nimport type { DataGridTableColumn, DataGridTableGroup, DataGridTableLayout, TableStore } from './table-types';\nimport { isTableGroup } from './table-types';\n\nconst snakeCaseRe = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;\n\nexport function prepareTableColumns<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n stickyApi: TableStickyService<TItem>,\n persistence?: TableColumnsPersistence,\n) {\n // DEV-only \"warn once per column id\" throttles -- the columns effect re-fires on every new\n // `columns` array identity, and these must not spam on every re-render.\n const widthContradictionWarned = new Set<string>();\n const headerTruncateDeprecationWarned = new Set<string>();\n // Grid-level (not per-column) warn -- fires at most once for this grid instance's lifetime.\n let allColumnsCappedWarned = false;\n\n return {\n initializeColumns,\n useVisibleColumns,\n };\n\n function assertColumnId(id: string): void {\n if (!snakeCaseRe.test(id)) {\n throw new Error(`Column id \"${id}\" must be snake_case (e.g., \"user_name\", \"is_active\").`);\n }\n }\n\n /**\n * `headerTruncate` (deprecated) aliases to `headerOverflow: 'nowrap'` so every downstream\n * reader only ever sees `headerOverflow`. Returns the original column unchanged when no\n * normalization is needed, to avoid mutating/copying caller-owned column objects.\n */\n function normalizeColumn(col: DataGridTableColumn<TItem>): DataGridTableColumn<TItem> {\n if (!col.headerTruncate || col.headerOverflow !== undefined) return col;\n\n if (process.env.NODE_ENV !== 'production' && !headerTruncateDeprecationWarned.has(col.id)) {\n headerTruncateDeprecationWarned.add(col.id);\n console.warn(\n `[DataGrid] Column \"${col.id}\": \\`headerTruncate\\` is deprecated, use ` +\n \"`headerOverflow: 'nowrap'` instead. `headerTruncate` will be removed in a \" +\n 'future release.',\n );\n }\n\n return { ...col, headerOverflow: 'nowrap' };\n }\n\n /**\n * Under `tableLayout=\"fixed\"` the three width props collapse to a single track. Setting\n * `width` alongside `minWidth`/`maxWidth` -- or setting both `minWidth` and `maxWidth` without\n * a `width` to pick between them -- is a contradiction fixed layout cannot honor; a lone prop\n * is a valid track alias and does not warn. `width: 'min-content'` short-circuits this check\n * entirely -- it resolves via measurement rather than a literal author-set value (see\n * `resolveColumnStyle`), so pairing it with `minWidth`/`maxWidth` isn't flagged as the same\n * kind of contradiction.\n */\n function warnOnFixedModeWidthContradiction(\n col: DataGridTableColumn<TItem>,\n tableLayout: DataGridTableLayout,\n ) {\n if (tableLayout !== 'fixed') return;\n if (process.env.NODE_ENV === 'production') return;\n if (col.width === 'min-content') return;\n\n const definedCount = [col.width, col.minWidth, col.maxWidth].filter(\n (value) => value !== undefined,\n ).length;\n if (definedCount <= 1) return;\n if (widthContradictionWarned.has(col.id)) return;\n\n widthContradictionWarned.add(col.id);\n console.warn(\n `[DataGrid] Column \"${col.id}\": width, minWidth, and maxWidth cannot all apply under ` +\n 'tableLayout=\"fixed\" -- they collapse to a single track (width wins when set). Use ' +\n 'tableLayout=\"auto\" for independent min/max constraints, or drop the extra prop(s).',\n );\n }\n\n /**\n * Under `tableLayout=\"auto\"`, a column's `width`/`maxWidth` is a cap honored only when the\n * browser has slack to give it -- when EVERY column is constrained (a `width` or `maxWidth` of\n * its own) and the container is wider than their sum, there is no widthless column left to\n * absorb the extra space, so the browser grows every column past its cap and capped content\n * shows trailing blank space. This is an accepted, documented limitation (see data-grid.md); the\n * warning just points a dev at the fix.\n */\n function warnOnAllColumnsCappedUnderAuto(\n flatCols: DataGridTableColumn<TItem>[],\n tableLayout: DataGridTableLayout,\n ) {\n if (tableLayout !== 'auto') return;\n if (process.env.NODE_ENV === 'production') return;\n if (allColumnsCappedWarned) return;\n if (flatCols.length === 0) return;\n\n const allConstrained = flatCols.every(\n (col) => col.width !== undefined || col.maxWidth !== undefined,\n );\n if (!allConstrained) return;\n\n allColumnsCappedWarned = true;\n console.warn(\n '[DataGrid] Every column has a width or maxWidth under tableLayout=\"auto\" -- if the ' +\n 'container is wider than their sum, the browser will grow columns past their caps and ' +\n 'capped content will show trailing blank space. Leave at least one column without a ' +\n 'width/maxWidth to absorb the extra space.',\n );\n }\n\n function flattenColumns(\n columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[],\n ): DataGridTableColumn<TItem>[] {\n const result: DataGridTableColumn<TItem>[] = [];\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n for (const col of item.columns) {\n result.push(normalizeColumn({ ...col, groupId: item.id }));\n }\n } else {\n result.push(normalizeColumn(item));\n }\n }\n\n return result;\n }\n\n function initializeColumnVisibility(\n columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[],\n ): Map<string, boolean> {\n const map = new Map<string, boolean>();\n const lockedIds = new Set<string>();\n\n function register(col: DataGridTableColumn<TItem>) {\n map.set(col.id, col.visible ?? true);\n if (col.visibleToggleDisabled) {\n lockedIds.add(col.id);\n }\n }\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n for (const col of item.columns) {\n register(col);\n }\n } else {\n register(item);\n }\n }\n\n for (const [columnId, visible] of Object.entries(persistence?.read() ?? {})) {\n // A stored id for a column this grid no longer has is dropped rather than carried: the\n // grid's columns can change between releases, and the store outlives them.\n //\n // A column the grid marks `visibleToggleDisabled` is dropped too. Its visibility is the\n // grid's decision rather than the user's, and a stored `false` from before the grid locked\n // it would hide the column behind a toggle that can no longer bring it back.\n if (map.has(columnId) && !lockedIds.has(columnId)) {\n map.set(columnId, visible);\n }\n }\n\n return map;\n }\n\n function useVisibleColumns(): DataGridTableColumn<TItem>[] {\n return useTableStore(\n useShallow((s) => {\n const visible = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n return stickyApi.getOrderedColumnsWithSticky(visible, s.columnSticky);\n }),\n );\n }\n\n function initializeColumns(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]) {\n const flatCols = flattenColumns(columns);\n const { tableLayout } = useTableStore.getState();\n\n for (const col of flatCols) {\n assertColumnId(col.id);\n warnOnFixedModeWidthContradiction(col, tableLayout);\n }\n warnOnAllColumnsCappedUnderAuto(flatCols, tableLayout);\n\n return {\n columns,\n flatColumns: flatCols,\n columnVisibility: initializeColumnVisibility(columns),\n };\n }\n}\n","import type { DataGridItem, InternalContext } from '../../data-grid-types';\n\ninterface StoredColumnVisibility {\n columns?: unknown;\n}\n\nexport interface TableColumnsPersistence {\n /** The columns the user toggled, by id. Columns never toggled are absent. */\n read: () => Record<string, boolean>;\n record: (columnId: string, visible: boolean) => void;\n}\n\n/** Namespaced by the grid's `name`, so two grids on a page keep separate selections. */\nexport const COLUMN_VISIBILITY_KEY = 'columnVisibility';\n\n/**\n * Keeps the columns a user showed or hid, when the grid asked for it with\n * `persistentColumnVisibility`. Returns `undefined` otherwise, so a grid that did not opt in\n * registers no state and reads none.\n *\n * Pinned to `localStorage` whatever the grid's `persistent` setting is: a column selection is\n * how one person likes to read the table, not part of the view they would share by copying the\n * URL, so it sits beside filters that stay in the query string rather than displacing them.\n */\nexport function prepareTableColumnsPersistence<TItem extends DataGridItem = DataGridItem>(\n context: InternalContext<TItem>,\n): TableColumnsPersistence | undefined {\n if (!context.config.persistentColumnVisibility) return undefined;\n\n const state = context.persistentState.registerPersistentState<StoredColumnVisibility>(\n COLUMN_VISIBILITY_KEY,\n { storage: 'localStorage' },\n );\n\n return { read, record };\n\n // The stored value is whatever is in `localStorage`, which the user can edit, so it is\n // narrowed here rather than trusted: anything that is not a boolean under a string key is\n // dropped instead of being carried into the visibility map and written back on the next\n // toggle.\n function read(): Record<string, boolean> {\n const stored = state.value?.columns;\n if (typeof stored !== 'object' || stored === null || Array.isArray(stored)) return {};\n\n return Object.fromEntries(\n Object.entries(stored).filter(([, visible]) => typeof visible === 'boolean'),\n );\n }\n\n // Only the toggled column is written, so a column left alone keeps following whatever default\n // the grid configures for it -- including a later change to that default.\n function record(columnId: string, visible: boolean) {\n state.setValue({ columns: { ...read(), [columnId]: visible } });\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type {\n ExtraColumn,\n ExtraColumnOption,\n ExtraColumnPosition,\n TableStore,\n} from './table-types';\n\nexport function prepareTableExtraColumns<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n // DEV-only \"warn once per column id\" throttle -- `updateExtraColumnSticky` is called from a\n // plugin's `onPropsChange`, which runs on every re-render, so an unthrottled warning would spam.\n const startPinWarned = new Set<string>();\n\n return {\n registerExtraColumn,\n updateExtraColumnWidth,\n updateExtraColumnOrder,\n updateExtraColumnSticky,\n useExtraColumns,\n };\n\n function registerExtraColumn(option: ExtraColumnOption) {\n const store = useTableStore.getState();\n const position = option.position ?? 'end';\n const existing = position === 'start' ? store.extraColumnsStart : store.extraColumnsEnd;\n const order = option.order ?? (existing.length + 1) * 10;\n\n const newColumn: ExtraColumn = {\n id: option.id ?? Math.random().toString(36).slice(2),\n header: option.header,\n body: option.body,\n width: option.width,\n sticky: option.sticky,\n ignoreRowClick: option.ignoreRowClick,\n order,\n position,\n };\n\n const updated = [...existing, newColumn].sort((a, b) => a.order - b.order);\n\n if (position === 'start') {\n warnOnStartColumnPin(newColumn.id, newColumn.sticky);\n useTableStore.setState({ extraColumnsStart: updated });\n } else {\n useTableStore.setState({ extraColumnsEnd: updated });\n }\n }\n\n /**\n * `sticky` sits on `ExtraColumn`, which both positions share, but only `end` columns are ever\n * read for it: `getEndStickyOffset` walks `extraColumnsEnd` alone, and extra columns never enter\n * the table's `columnSticky` map. On a `start` column the flag reads like \"pin this\" and changes\n * nothing -- the field's JSDoc says so, but a caller who sets it does not see the JSDoc, they see\n * nothing happen.\n *\n * A DEV warning rather than a type that refuses the pairing: `position` is optional on\n * `ExtraColumnOption`, so a union discriminated on it would make every caller spell the\n * position out, and it still would not cover `updateExtraColumnSticky` -- that one takes a column\n * id and cannot know the position at the call site, and it is the route a plugin's props take.\n * One runtime check covers both.\n */\n function warnOnStartColumnPin(columnId: string, sticky: boolean | undefined) {\n if (process.env.NODE_ENV === 'production') return;\n if (!sticky) return;\n if (startPinWarned.has(columnId)) return;\n\n startPinWarned.add(columnId);\n console.warn(\n `[DataGrid] Extra column \"${columnId}\": \\`sticky\\` pins to the table's inline-end edge and ` +\n 'is read only for columns at the `end` position -- on a `start` column it does nothing. ' +\n 'Drop the flag, or register the column at the `end` position.',\n );\n }\n\n function updateExtraColumnWidth(columnId: string, width: string) {\n const store = useTableStore.getState();\n\n function updateList(columns: ExtraColumn[]): ExtraColumn[] | undefined {\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return undefined;\n const updated = [...columns];\n updated[index] = { ...updated[index], width };\n return updated;\n }\n\n const updatedStart = updateList(store.extraColumnsStart);\n if (updatedStart) {\n useTableStore.setState({ extraColumnsStart: updatedStart });\n return;\n }\n\n const updatedEnd = updateList(store.extraColumnsEnd);\n if (updatedEnd) {\n useTableStore.setState({ extraColumnsEnd: updatedEnd });\n }\n }\n\n function updateExtraColumnOrder(columnId: string, order: number) {\n const store = useTableStore.getState();\n\n function updateList(columns: ExtraColumn[]): ExtraColumn[] | undefined {\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return undefined;\n const updated = [...columns];\n updated[index] = { ...updated[index], order };\n return updated.sort((a, b) => a.order - b.order);\n }\n\n const updatedStart = updateList(store.extraColumnsStart);\n if (updatedStart) {\n useTableStore.setState({ extraColumnsStart: updatedStart });\n return;\n }\n\n const updatedEnd = updateList(store.extraColumnsEnd);\n if (updatedEnd) {\n useTableStore.setState({ extraColumnsEnd: updatedEnd });\n }\n }\n\n /**\n * Plugins register their extra column once at setup, before their props are available, so the\n * pin arrives here on the first props pass -- same route `updateExtraColumnOrder` takes. Writing\n * only on an actual change keeps that pass from replacing the column list (and re-rendering\n * every cell) on every re-render of a plugin that never opts in.\n *\n * The stored flag is compared through the same `?? false` the callers normalise with, so a\n * column registered with no `sticky` at all is already \"unpinned\" as far as the guard is\n * concerned and the first pass of a grid that never opts in writes nothing. Nothing downstream\n * tells an absent flag from an explicit `false` -- `getEndStickyOffset` reads both as unpinned --\n * so collapsing them here costs no meaning and saves every such grid one re-render of every cell\n * on mount.\n */\n function updateExtraColumnSticky(columnId: string, sticky: boolean) {\n const store = useTableStore.getState();\n\n const isStart = store.extraColumnsStart.some((c) => c.id === columnId);\n const key = isStart ? 'extraColumnsStart' : 'extraColumnsEnd';\n const columns = store[key];\n\n const index = columns.findIndex((c) => c.id === columnId);\n if (index === -1) return;\n\n if (isStart) warnOnStartColumnPin(columnId, sticky);\n\n if ((columns[index].sticky ?? false) === sticky) return;\n\n const updated = [...columns];\n updated[index] = { ...updated[index], sticky };\n useTableStore.setState({ [key]: updated });\n }\n\n function useExtraColumns(position: ExtraColumnPosition): ExtraColumn[] {\n return useTableStore((s) => (position === 'start' ? s.extraColumnsStart : s.extraColumnsEnd));\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStickyService } from './table-sticky';\nimport type {\n DataGridTableColumn,\n RegisteredTableComponent,\n TableComponentName,\n TableHeaderCell,\n TableStore,\n} from './table-types';\nimport { isTableGroup } from './table-types';\n\nexport function prepareTableHeader<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n stickyApi: TableStickyService<TItem>,\n defaultComponents: Map<TableComponentName, RegisteredTableComponent>,\n) {\n const emptyTableColumnArray: DataGridTableColumn<TItem>[] = [];\n // Caches for referential stability in reactive hooks\n let headerCellsCache: { state: TableStore<TItem>; result: TableHeaderCell<TItem>[] } | null =\n null;\n let headerColumnsCache: { state: TableStore<TItem>; result: DataGridTableColumn<TItem>[] } | null =\n null;\n\n return {\n useHasGroups,\n useFirstRowHeaderCells,\n useSecondRowHeaderColumns,\n };\n\n function getVisibleColumns(): DataGridTableColumn<TItem>[] {\n const state = useTableStore.getState();\n const visible = state.flatColumns.filter((col) => state.columnVisibility.get(col.id) !== false);\n return stickyApi.getOrderedColumnsWithSticky(visible, state.columnSticky);\n }\n\n function hasGroups(): boolean {\n return useTableStore.getState().columns.some(isTableGroup);\n }\n\n function getFirstRowHeaderCells(): TableHeaderCell<TItem>[] {\n const state = useTableStore.getState();\n const visibleCols = getVisibleColumns();\n\n if (!hasGroups()) {\n const component =\n state.components.get('header-cell') ?? defaultComponents.get('header-cell')!;\n return visibleCols.map((column) => ({\n type: 'column' as const,\n item: column,\n component,\n }));\n }\n\n const columnOrderMap = new Map(visibleCols.map((col, index) => [col.id, index]));\n const orderedItems = [...state.columns].sort((a, b) => {\n const aIndex = isTableGroup(a)\n ? Math.min(...a.columns.map((c) => columnOrderMap.get(c.id) ?? Infinity))\n : (columnOrderMap.get(a.id) ?? Infinity);\n const bIndex = isTableGroup(b)\n ? Math.min(...b.columns.map((c) => columnOrderMap.get(c.id) ?? Infinity))\n : (columnOrderMap.get(b.id) ?? Infinity);\n return aIndex - bIndex;\n });\n\n return orderedItems.flatMap((item) => {\n if (isTableGroup(item)) {\n const visibleCount = item.columns.filter(\n (c) => state.columnVisibility.get(c.id) !== false,\n ).length;\n\n if (visibleCount === 0) return [];\n\n return {\n type: 'group' as const,\n item,\n component: state.components.get('header-group') ?? defaultComponents.get('header-group')!,\n colspan: visibleCount,\n };\n }\n\n if (state.columnVisibility.get(item.id) === false) return [];\n\n return {\n type: 'column' as const,\n item,\n component: state.components.get('header-cell') ?? defaultComponents.get('header-cell')!,\n rowspan: 2,\n };\n });\n }\n\n function getSecondRowHeaderColumns(): DataGridTableColumn<TItem>[] {\n if (!hasGroups()) return emptyTableColumnArray;\n\n const state = useTableStore.getState();\n const visibleCols = getVisibleColumns();\n return visibleCols.filter((col) => col.groupId && state.columnVisibility.get(col.id) !== false);\n }\n\n function useHasGroups() {\n return useTableStore((state) => state.columns.some(isTableGroup));\n }\n\n function useFirstRowHeaderCells(): TableHeaderCell<TItem>[] {\n return useTableStore((state) => {\n if (headerCellsCache !== null && headerCellsCache.state === state) {\n return headerCellsCache.result;\n }\n const result = getFirstRowHeaderCells();\n headerCellsCache = { state, result };\n return result;\n });\n }\n\n function useSecondRowHeaderColumns(): DataGridTableColumn<TItem>[] {\n return useTableStore((state) => {\n if (headerColumnsCache !== null && headerColumnsCache.state === state) {\n return headerColumnsCache.result;\n }\n const result = getSecondRowHeaderColumns();\n headerColumnsCache = { state, result };\n return result;\n });\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableSlot, TableSlotName, TableSlotOptions, TableStore } from './table-types';\n\nconst emptySlots: TableSlot[] = [];\n\nexport function prepareTableSlots<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n registerSlot,\n useSlots,\n };\n\n function registerSlot<T extends TableSlotName>(name: T, options: TableSlotOptions[T]) {\n const store = useTableStore.getState();\n const id = Math.random().toString(36).slice(2);\n const existingSlots = store.slots.get(name) ?? emptySlots;\n const order = options.order ?? (existingSlots.length + 1) * 10;\n\n const newSlot: TableSlot = {\n id,\n name,\n component: options.component,\n order,\n };\n\n const updated = [...existingSlots, newSlot].sort((a, b) => a.order - b.order);\n const newSlots = new Map(store.slots);\n newSlots.set(name, updated);\n useTableStore.setState({ slots: newSlots });\n }\n\n function useSlots<T extends TableSlotName>(name: T): TableSlot[] {\n return useTableStore(useShallow((state) => state.slots.get(name) ?? emptySlots));\n }\n}\n","import type { StoreApi } from 'zustand';\nimport type { UseBoundStore } from 'zustand/react';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { ExtraColumn, DataGridTableColumn, DataGridTableGroup, TableStore } from './table-types';\nimport { isTableGroup } from './table-types';\n\n/** The slice of the table store the inline-end offsets are derived from. */\ntype EndStickyState = Pick<TableStore, 'extraColumnsEnd' | 'columnWidths'>;\n\n/** The slice of the table store that says whether a start extra column pins, and where. */\ntype StartExtraStickyState<TItem extends DataGridItem> = Pick<\n TableStore<TItem>,\n 'extraColumnsStart' | 'columns' | 'flatColumns' | 'columnVisibility' | 'columnSticky' | 'groupSticky'\n>;\n\n/** A registered `width` the inline-end arithmetic can use: a plain px length, nothing else. */\nconst pxWidthRe = /^\\s*(\\d+(?:\\.\\d+)?)px\\s*$/;\n\nexport type TableStickyService<TItem extends DataGridItem = DataGridItem> = ReturnType<\n typeof prepareTableSticky<TItem>\n>;\n\nexport function prepareTableSticky<TItem extends DataGridItem = DataGridItem>(\n useTableStore: UseBoundStore<StoreApi<TableStore<TItem>>>,\n) {\n return {\n initializeStickyState,\n getOrderedColumnsWithSticky,\n onResizeColumn,\n isColumnSticky,\n isGroupSticky,\n useColumnStickyOffset,\n useColumnEndStickyOffset,\n useGroupStickyOffset,\n };\n\n function initializeStickyState(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]): {\n columnSticky: Map<string, boolean>;\n groupSticky: Map<string, boolean>;\n } {\n const columnSticky = new Map<string, boolean>();\n const groupSticky = new Map<string, boolean>();\n\n for (const item of columns) {\n if (isTableGroup(item)) {\n groupSticky.set(item.id, item.sticky ?? false);\n for (const col of item.columns) {\n columnSticky.set(col.id, col.sticky ?? item.sticky ?? false);\n }\n } else {\n columnSticky.set(item.id, item.sticky ?? false);\n }\n }\n\n return { columnSticky, groupSticky };\n }\n\n function getOrderedColumnsWithSticky(\n visibleColumns: DataGridTableColumn<TItem>[],\n columnSticky: Map<string, boolean>,\n ): DataGridTableColumn<TItem>[] {\n const sticky: DataGridTableColumn<TItem>[] = [];\n const nonSticky: DataGridTableColumn<TItem>[] = [];\n\n for (const col of visibleColumns) {\n if (columnSticky.get(col.id)) {\n sticky.push(col);\n } else {\n nonSticky.push(col);\n }\n }\n\n return [...sticky, ...nonSticky];\n }\n\n // Skips the write when the width is unchanged. This is what ends the header's observer cycle: a\n // new `columnWidths` Map is a new store state, which gives `useFirstRowHeaderCells` a new array,\n // which re-creates the header's ResizeObserver, and a fresh observer always reports once on\n // `observe()` -- so an unconditional write here would rebuild the observer on every frame.\n function onResizeColumn(columnId: string, width: number) {\n const current = useTableStore.getState().columnWidths;\n if (current.get(columnId) === width) return;\n\n const newWidths = new Map(current);\n newWidths.set(columnId, width);\n useTableStore.setState({ columnWidths: newWidths });\n }\n\n function isColumnSticky(columnId: string) {\n return useTableStore.getState().columnSticky.get(columnId) === true;\n }\n\n function isGroupSticky(groupId: string) {\n return useTableStore.getState().groupSticky.get(groupId) === true;\n }\n\n function useColumnStickyOffset(columnId: string): number | undefined {\n return useTableStore((s) => {\n if (!s.columnSticky.get(columnId)) return getStartExtraStickyOffset(s, columnId);\n\n let offset = getExtraStartOffset(s);\n const visibleCols = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n for (const col of visibleCols) {\n if (col.id === columnId) break;\n if (s.columnSticky.get(col.id)) {\n offset += s.columnWidths.get(col.id) ?? 0;\n }\n }\n return offset;\n });\n }\n\n function useColumnEndStickyOffset(columnId: string): number | undefined {\n return useTableStore((s) => getEndStickyOffset(s, columnId));\n }\n\n function useGroupStickyOffset(groupId: string): number | undefined {\n return useTableStore((s) => {\n if (!s.groupSticky.get(groupId)) return undefined;\n\n let offset = getExtraStartOffset(s);\n const visibleCols = s.flatColumns.filter((c) => s.columnVisibility.get(c.id) !== false);\n for (const col of visibleCols) {\n if (col.groupId === groupId) break;\n if (s.columnSticky.get(col.id)) {\n offset += s.columnWidths.get(col.id) ?? 0;\n }\n }\n return offset;\n });\n }\n\n function getExtraStartOffset(s: TableStore<TItem>) {\n let offset = 0;\n for (const extra of s.extraColumnsStart) {\n offset += startExtraWidth(extra);\n }\n return offset;\n }\n}\n\nfunction startExtraWidth(extra: ExtraColumn): number {\n return extra.width ? parseInt(extra.width, 10) || 0 : 0;\n}\n\n/**\n * Offset from the table's inline-start edge for an extra `start` column (a row number, a\n * checkbox), or `undefined` when it does not pin.\n *\n * A pinned data column or group is offset by the width of every start extra column, so the extra\n * columns have to be pinned in front of it: left unpinned they scroll away and leave that width\n * empty. They pin together with the first pinned data column and not before it, so a grid that pins\n * nothing scrolls its extra columns away with the rest. A pinned column that is hidden pins nothing.\n * Each one sits behind the extra columns before it, in the order they are drawn.\n *\n * The widths are read the way the data columns' own offset reads them (the registered `width`), so\n * the two sums always agree. Pure and store-shaped, like `getEndStickyOffset`.\n */\nexport function getStartExtraStickyOffset<TItem extends DataGridItem>(\n s: StartExtraStickyState<TItem>,\n columnId: string,\n): number | undefined {\n if (!s.extraColumnsStart.some((extra) => extra.id === columnId) || !hasStartPinnedData(s)) {\n return undefined;\n }\n\n let offset = 0;\n for (const extra of s.extraColumnsStart) {\n if (extra.id === columnId) return offset;\n offset += startExtraWidth(extra);\n }\n\n return undefined;\n}\n\nfunction hasStartPinnedData<TItem extends DataGridItem>(s: StartExtraStickyState<TItem>): boolean {\n const isVisible = (column: DataGridTableColumn<TItem>) => s.columnVisibility.get(column.id) !== false;\n\n return (\n s.flatColumns.some((column) => isVisible(column) && s.columnSticky.get(column.id)) ||\n s.columns.some(\n (item) => isTableGroup(item) && s.groupSticky.get(item.id) && item.columns.some(isVisible),\n )\n );\n}\n\n/**\n * Offset from the table's inline-end edge for a pinned `end` extra column, or `undefined` when\n * the column is not an `end` column that pins.\n *\n * Walked right to left so each pinned column sits outside the ones already pinned beyond it,\n * mirroring how the start-edge offsets accumulate left to right. Unpinned columns in between\n * contribute nothing -- they scroll away, so the pinned ones stack against each other.\n *\n * Pure and store-shaped rather than a hook body so the arithmetic is directly testable, and so\n * `useColumnEndStickyOffset` returns a plain number: a `Map` built inside a zustand selector would be a\n * fresh reference on every store read and re-render forever.\n */\nexport function getEndStickyOffset(s: EndStickyState, columnId: string): number | undefined {\n let offset = 0;\n\n for (let index = s.extraColumnsEnd.length - 1; index >= 0; index--) {\n const column = s.extraColumnsEnd[index];\n if (!column.sticky) continue;\n if (column.id === columnId) return offset;\n offset += resolveExtraColumnWidth(s, column);\n }\n\n return undefined;\n}\n\n/**\n * The measured header width wins over the registered one: an auto-sized extra column registers a\n * width computed from its own content, while the header's ResizeObserver reports the track the\n * table actually gave the cell. Stacking on the registered value would drift the outer pinned\n * columns by the difference.\n *\n * The registered value is used only when it is a plain px length. `width` is handed straight to\n * CSS, where `4rem` and `10%` are perfectly good column widths, so the field cannot be narrowed to\n * px without taking those away -- but this arithmetic is pixels, and reading them with `parseInt`\n * would call them `4` and `10` and pin the columns inside them a few pixels from the edge instead\n * of clear of the column. An unreadable width contributes `0` instead: the same as a pinned column\n * with no width at all, and true only until the header's ResizeObserver reports the real track.\n */\nfunction resolveExtraColumnWidth(s: EndStickyState, column: ExtraColumn): number {\n const measured = s.columnWidths.get(column.id);\n if (measured !== undefined) return measured;\n\n const px = pxWidthRe.exec(column.width ?? '');\n return px ? Number(px[1]) : 0;\n}\n","import { create } from 'zustand';\nimport type { DataGridItem } from '../../data-grid-types';\nimport type { TableStore } from './table-types';\n\nexport function createTableStore<TItem extends DataGridItem = DataGridItem>() {\n return create<TableStore<TItem>>(() => ({\n columns: [],\n flatColumns: [],\n columnVisibility: new Map(),\n columnSticky: new Map(),\n groupSticky: new Map(),\n columnWidths: new Map(),\n minContentWidths: new Map(),\n extraColumnsStart: [],\n extraColumnsEnd: [],\n slots: new Map(),\n components: new Map(),\n tableLayout: 'fixed',\n stickyHeader: false,\n }));\n}\n","import { TablePropertiesIcon } from 'lucide-react';\nimport type { ComponentType } from 'react';\nimport { useMemo } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport type { DataGridItem, InternalContext } from '../../data-grid-types';\nimport { DataGridBodyCellContent } from './components/data-grid-body-cell-content';\nimport { DataGridContent } from './components/data-grid-content';\nimport { DataGridHeaderCellLabel } from './components/data-grid-header-cell-label';\nimport { DataGridHeaderGroup } from './components/data-grid-header-group';\nimport { DataGridRow } from './components/data-grid-row';\nimport { DataGridTable } from './components/data-grid-table';\nimport { TABLE_LAYOUT_SLOT_ID } from '../layout/layout-slot-ids';\nimport { prepareTableColumns } from './table-columns';\nimport { prepareTableColumnsPersistence } from './table-columns-persistence';\nimport { prepareTableExtraColumns } from './table-extra-columns';\nimport { prepareTableHeader } from './table-header';\nimport { prepareTableMinContentWidth } from './table-min-content-width';\nimport { prepareTableSlots } from './table-slots';\nimport { prepareTableSticky } from './table-sticky';\nimport { createTableStore } from './table-store';\nimport type {\n ConfigurationColumn,\n ConfigurationEntry,\n DataGridTableColumn,\n TableComponentName,\n DataGridTableGroup,\n DataGridTableLayout,\n RegisteredTableComponent,\n TablePublicApi,\n TableService,\n} from './table-types';\nimport { isTableGroup } from './table-types';\n\nexport function createTableService<TItem extends DataGridItem>(\n context: InternalContext<TItem>,\n): TableService<TItem> {\n const useTableStore = createTableStore<TItem>();\n const defaultComponents = createDefaultComponents();\n\n // Register table in layout main slot as the default active view, with an icon for the view selector\n context.layout.registerSlot('main', {\n id: TABLE_LAYOUT_SLOT_ID,\n component: DataGridTable,\n active: true,\n icon: TablePropertiesIcon,\n });\n\n // Domain APIs (same composition as before)\n const slotsApi = prepareTableSlots<TItem>(useTableStore);\n const extraColumnsApi = prepareTableExtraColumns<TItem>(useTableStore);\n const stickyApi = prepareTableSticky<TItem>(useTableStore);\n const columnsPersistence = prepareTableColumnsPersistence<TItem>(context);\n const columnsApi = prepareTableColumns<TItem>(useTableStore, stickyApi, columnsPersistence);\n const headerApi = prepareTableHeader<TItem>(useTableStore, stickyApi, defaultComponents);\n const minContentWidthApi = prepareTableMinContentWidth<TItem>(useTableStore);\n\n // Public API — registered into pluginContext for external plugins\n const publicApi: TablePublicApi<TItem> = {\n registerTableSlot: slotsApi.registerSlot,\n registerExtraColumn: extraColumnsApi.registerExtraColumn,\n updateExtraColumnWidth: extraColumnsApi.updateExtraColumnWidth,\n updateExtraColumnOrder: extraColumnsApi.updateExtraColumnOrder,\n updateExtraColumnSticky: extraColumnsApi.updateExtraColumnSticky,\n registerComponent,\n updateColumns,\n updateColumnVisibility,\n updateColumnSticky,\n updateTableLayout,\n updateStickyHeader,\n };\n context.plugins.registerPublicApi(publicApi);\n\n return {\n ...publicApi,\n updateColumns,\n useComponent,\n useConfigurationColumns,\n useTableLayout,\n useStickyHeader,\n ...slotsApi,\n ...extraColumnsApi,\n ...stickyApi,\n ...columnsApi,\n ...headerApi,\n ...minContentWidthApi,\n };\n\n function updateColumns(columns: (DataGridTableColumn<TItem> | DataGridTableGroup<TItem>)[]) {\n const columnState = columnsApi.initializeColumns(columns);\n const { columnSticky, groupSticky } = stickyApi.initializeStickyState(columns);\n const current = useTableStore.getState();\n useTableStore.setState({\n ...columnState,\n columnSticky,\n groupSticky,\n extraColumnsStart: current.extraColumnsStart,\n extraColumnsEnd: current.extraColumnsEnd,\n slots: current.slots,\n components: current.components,\n columnWidths: current.columnWidths,\n minContentWidths: current.minContentWidths,\n });\n }\n\n function updateColumnVisibility(columnId: string, visible: boolean) {\n const state = useTableStore.getState();\n const newVisibility = new Map(state.columnVisibility);\n newVisibility.set(columnId, visible);\n useTableStore.setState({ columnVisibility: newVisibility });\n columnsPersistence?.record(columnId, visible);\n }\n\n function updateTableLayout(tableLayout: DataGridTableLayout) {\n useTableStore.setState({ tableLayout });\n }\n\n function useTableLayout(): DataGridTableLayout {\n return useTableStore((state) => state.tableLayout);\n }\n\n function updateStickyHeader(stickyHeader: boolean) {\n useTableStore.setState({ stickyHeader });\n }\n\n function useStickyHeader(): boolean {\n return useTableStore((state) => state.stickyHeader);\n }\n\n function updateColumnSticky(id: string, sticky: boolean) {\n const state = useTableStore.getState();\n const isGroup = state.columns.some((col) => isTableGroup(col) && col.id === id);\n\n if (isGroup) {\n // A group pins as a whole: its heading and every column under it, or the columns would\n // scroll away from beneath a heading that stays.\n const group = state.columns.find((col) => isTableGroup(col) && col.id === id);\n const newGroupSticky = new Map(state.groupSticky);\n newGroupSticky.set(id, sticky);\n const newColumnSticky = new Map(state.columnSticky);\n if (group && isTableGroup(group)) {\n for (const col of group.columns) newColumnSticky.set(col.id, sticky);\n }\n useTableStore.setState({ groupSticky: newGroupSticky, columnSticky: newColumnSticky });\n } else {\n const newColumnSticky = new Map(state.columnSticky);\n newColumnSticky.set(id, sticky);\n useTableStore.setState({ columnSticky: newColumnSticky });\n }\n }\n\n // The parameter is whatever the public API takes (a `ComponentType<any>`), so a class component\n // is accepted. The registry stores it as a `ComponentType<never>`, which a class component is\n // not assignable to (its instance's `props` are not assignable to `never`), hence the assertion.\n function registerComponent(\n name: TableComponentName,\n component: Parameters<TablePublicApi['registerComponent']>[1],\n ) {\n const state = useTableStore.getState();\n const newComponents = new Map(state.components);\n newComponents.set(name, component as RegisteredTableComponent);\n useTableStore.setState({ components: newComponents });\n }\n\n function useComponent<TProps = unknown>(name: TableComponentName): ComponentType<TProps> {\n return useTableStore(\n (state) => state.components.get(name) ?? defaultComponents.get(name)!,\n ) as ComponentType<TProps>;\n }\n\n function resolveLabel(label: string | (() => string)): string {\n return typeof label === 'function' ? label() : label;\n }\n\n function useConfigurationColumns(): ConfigurationEntry[] {\n const { columns, columnVisibility, columnSticky, groupSticky } = useTableStore(\n useShallow((state) => ({\n columns: state.columns,\n columnVisibility: state.columnVisibility,\n columnSticky: state.columnSticky,\n groupSticky: state.groupSticky,\n })),\n );\n\n return useMemo(() => {\n const visibleCount = Array.from(columnVisibility.values()).filter(Boolean).length;\n\n function toConfigCol(col: DataGridTableColumn<TItem>): ConfigurationColumn {\n const visible = columnVisibility.get(col.id) ?? true;\n return {\n id: col.id,\n label: resolveLabel(col.label),\n visible,\n sticky: columnSticky.get(col.id) ?? false,\n visibleToggleDisabled: col.visibleToggleDisabled ?? (visible && visibleCount === 1),\n };\n }\n\n return columns.map((item): ConfigurationEntry => {\n if (isTableGroup(item)) {\n return {\n id: item.id,\n label: resolveLabel(item.label),\n visible: item.visible ?? true,\n sticky: groupSticky.get(item.id) ?? false,\n columns: item.columns.map(toConfigCol),\n };\n }\n return toConfigCol(item);\n });\n }, [columns, columnVisibility, columnSticky, groupSticky]);\n }\n}\n\nfunction createDefaultComponents(): Map<TableComponentName, RegisteredTableComponent> {\n const defaults = new Map<TableComponentName, RegisteredTableComponent>();\n defaults.set('body-cell-content', DataGridBodyCellContent);\n defaults.set('content', DataGridContent);\n defaults.set('header-cell-label', DataGridHeaderCellLabel);\n defaults.set('header-group', DataGridHeaderGroup);\n defaults.set('row', DataGridRow);\n return defaults;\n}\n","import type {\n DataGridInstance,\n DataGridConfig,\n DataGridItem,\n InternalContext,\n} from './data-grid-types';\nimport { createCoreService } from './services/core/core-service';\nimport { createHookedService } from './services/hooked/hooked';\nimport { internalContextKey } from './services/internal/internal-helpers';\nimport { createLayoutService } from './services/layout/layout-service';\nimport { createLoadService } from './services/load/load-service';\nimport { createPersistentStateService } from './services/persistent-state/persistent-state-service';\nimport { createPluginsService } from './services/plugins/plugins-service';\nimport type { DataGridPlugin } from './services/plugins/plugins-types';\nimport { createStorageService } from './services/storage/storage-service';\nimport { createTableService } from './services/table/table-service';\n\nexport function createDataGrid<\n TItem extends DataGridItem,\n TPlugins extends DataGridPlugin<TItem>[] = DataGridPlugin<TItem>[],\n>(config: DataGridConfig<TItem>): DataGridInstance<TItem, TPlugins> {\n const hooked = createHookedService<TItem>();\n\n // The services are created one after another, and a few read the context while they are being\n // created (the table service registers its layout slot, the load service registers its public\n // API). So the context exposes each service through a getter that fails loudly if it is read\n // before that service exists, instead of handing out a placeholder object.\n const services: Partial<Omit<InternalContext<TItem>, 'hooked' | 'config'>> = {};\n\n const context: InternalContext<TItem> = {\n hooked,\n config,\n get plugins() {\n return created(services.plugins, 'plugins');\n },\n get core() {\n return created(services.core, 'core');\n },\n get load() {\n return created(services.load, 'load');\n },\n get storage() {\n return created(services.storage, 'storage');\n },\n get persistentState() {\n return created(services.persistentState, 'persistentState');\n },\n get layout() {\n return created(services.layout, 'layout');\n },\n get table() {\n return created(services.table, 'table');\n },\n };\n\n services.plugins = createPluginsService<TItem>(context);\n services.core = createCoreService();\n services.load = createLoadService<TItem>(context);\n services.storage = createStorageService<TItem>(context);\n services.persistentState = createPersistentStateService<TItem>(context);\n services.layout = createLayoutService<TItem>(context);\n services.table = createTableService<TItem>(context);\n\n return {\n init,\n destroy,\n ...context.plugins.pluginContext,\n [internalContextKey]: context,\n } as DataGridInstance<TItem, TPlugins>;\n\n function destroy() {\n hooked.callHookSync('destroy');\n\n // A first load that is under way, and so about to be aborted, never delivers: the grid is back\n // to idle, so the next `init()` (an `Activity` showing it again) runs the load once more.\n // Without an instance the first load has not started yet -- React's development remount runs\n // this cleanup between two `init()` calls, and the second must not start another -- so there\n // is nothing to cut off.\n const firstLoadCutOff =\n context.core.useLoadStateStore.getState().loadState === 'loading' &&\n context.load.getLoadInstances().length > 0;\n\n context.load.abort();\n if (firstLoadCutOff) {\n context.core.resetLoadState();\n }\n }\n\n async function init() {\n const { loadState } = context.core.useLoadStateStore.getState();\n if (loadState === 'loaded' || loadState === 'loading') {\n return;\n }\n\n await context.core.loadPromise(context.load.init());\n }\n}\n\nfunction created<T>(service: T | undefined, name: string): T {\n if (service === undefined) {\n throw new Error(`[DataGrid] The ${name} service was used before it was created.`);\n }\n return service;\n}\n","// Load-bearing: DataGrid calls useState/useEffect directly in its own render body, so this\n// can't be dropped. Coupled to CLIENT_COMPONENTS in scripts/verify-consumer.sh and to the\n// client-component sentence in README.md and llms.txt (client-boundaries.test.ts checks all\n// three) - keep them in sync if this ever changes.\n'use client';\n\nimport { Suspense, useEffect, useState } from 'react';\n\nimport { DataGridContent } from './components/data-grid-content';\nimport { DataGridSpinner } from './components/data-grid-spinner';\nimport { createDataGrid } from './create-data-grid';\nimport type { DataGridItem, DataGridProps } from './data-grid-types';\nimport { DataGridProvider } from './services/core/data-grid-context';\nimport { internalContextKey } from './services/internal/internal-helpers';\nimport { useLatest } from './utils/use-latest';\n\nconst noImplicitFilterKeys: string[] = [];\n\nexport function DataGrid<TItem extends DataGridItem = DataGridItem>({\n name,\n load,\n columns,\n children,\n persistent,\n persistentColumnVisibility,\n tableLayout = 'fixed',\n stickyHeader = false,\n loading = false,\n implicitFilterKeys,\n}: DataGridProps<TItem>) {\n const loadRef = useLatest(load);\n const [grid] = useState(() =>\n createDataGrid<TItem>({\n name,\n load: loadRef,\n persistent,\n persistentColumnVisibility,\n }),\n );\n\n // Runs before the columns effect (declaration order) so column ingestion -- which DEV-warns on\n // a width contradiction that only exists under `tableLayout=\"fixed\"` -- reads the current mode.\n useEffect(() => {\n grid.updateTableLayout(tableLayout);\n }, [grid, tableLayout]);\n\n useEffect(() => {\n grid.updateColumns(columns);\n }, [grid, columns]);\n\n useEffect(() => {\n grid.updateStickyHeader(stickyHeader);\n }, [grid, stickyHeader]);\n\n // Reaches the core service directly because the setter is internal: this prop is the only way to\n // raise the overlay for work the grid does not own, so there is exactly one writer of the flag.\n useEffect(() => {\n grid[internalContextKey].core.updateLoading(loading);\n }, [grid, loading]);\n\n // Same idiom as `loading` above: the setter is internal, and this prop is its only writer.\n // Falls back to a shared constant so an omitted prop stays reference-equal across renders.\n useEffect(() => {\n grid[internalContextKey].storage.updateImplicitFilterKeys(\n implicitFilterKeys ?? noImplicitFilterKeys,\n );\n }, [grid, implicitFilterKeys]);\n\n return (\n <DataGridProvider value={grid}>\n {children}\n <Suspense fallback={<DataGridSpinner />}>\n <DataGridContent />\n </Suspense>\n </DataGridProvider>\n );\n}\n","import { CARDS_LAYOUT_SLOT_ID, TABLE_LAYOUT_SLOT_ID } from './layout-slot-ids';\nimport { useDataGridContext } from '../core/data-grid-context';\n\n/**\n * Stable ids of the built-in DataGrid main views. Use these instead of hardcoding the raw slot-id\n * strings when reading or setting the active view (e.g. `grid.setActiveSlotId('main', DATA_GRID_VIEW.cards)`).\n */\nexport const DATA_GRID_VIEW = {\n table: TABLE_LAYOUT_SLOT_ID,\n cards: CARDS_LAYOUT_SLOT_ID,\n} as const;\n\n/** A built-in DataGrid main-view slot id. */\nexport type DataGridViewId = (typeof DATA_GRID_VIEW)[keyof typeof DATA_GRID_VIEW];\n\n/**\n * Reactively read the id of the currently active DataGrid main view (e.g. the table view, or a cards view that a plugin registers).\n * Re-renders when the active view changes. Returns `undefined` before any main view is active.\n */\nexport function useDataGridActiveView(): string | undefined {\n const context = useDataGridContext();\n return context.layout.useLayoutStore((state) => state.activeSlotIds.get('main'));\n}\n"],"names":["DataGridSpinner","className","jsx","cx","styles","Spinner","useDataGridLoading","context","useDataGridContext","recordsLoadState","s","externalLoading","DataGridLayoutContent","children","initialLoadState","showOverlay","isBusy","jsxs","rootStyles","DataGridEmptyState","useStore","useDataGrid","hasActiveFilters","Empty","EmptyHeader","EmptyMedia","SearchXIcon","EmptyTitle","messages","EmptyDescription","DataGridLayoutMain","visibleRecords","activeSlotId","state","mainLayoutSlots","activeSlot","emptySlots","emptySlot","isEmpty","showMain","showEmptyState","DataGridLayoutSlot","name","currentSlots","Fragment","slot","DataGridLayoutTopDefault","topStartLayoutSlots","topEndLayoutSlots","hasTopStartSlots","hasTopEndSlots","flowItems","container","items","child","display","position","wraps","element","flexWrap","itemsShareALine","lowestTop","highestBottom","item","top","bottom","width","height","isOnOneLine","root","DataGridLayoutTop","topLayoutSlots","topLayoutSlot","isDefault","wrapperRef","useRef","defaultBlockSize","setDefaultBlockSize","useState","useEffect","wrapper","observer","entries","entry","blockSize","_b","_a","TopComponent","LoadControlled","loadState","OctagonAlertIcon","DataGridContent","grid","core","error","createLoadStateManager","useLoadStateStore","create","owner","setLoading","setLoaded","setError","setBlank","reset","loadPromise","promise","mine","result","createCoreService","useLoadState","useExternalLoadingStore","updateLoading","loading","createHookedService","hooked","createHooked","TABLE_LAYOUT_SLOT_ID","CARDS_LAYOUT_SLOT_ID","VIEW_SELECTOR_SLOT_ID","slotLabels","DataGridLayoutMainSlotSelector","mainSlots","Segment","handleValueChange","Icon","ToggleGroupItem","value","createLayoutService","useLayoutStore","publicApi","registerSlot","setActiveSlotId","getActiveSlotId","getSlotById","id","getLayoutSlots","options","existingSlots","order","newSlot","newSlots","a","b","newSlotsMap","newActiveSlotIds","isRecord","createLoadInstance","config","controller","loadStateManager","loadContext","fetchResult","processResult","started","instance","abort","executeLoad","extraContext","mergeContextData","data","assertLoadResult","stored","e","target","fromArray","key","merged","createLoadService","instances","recordInstanceIds","latestRefresh","triggerLoad","refresh","getLoadInstances","init","syncLoadState","replacesRecords","triggerConfig","settle","refreshBefore","followed","runRefresh","refreshOptions","createPersistentStateService","subscribers","memoryStore","gridName","persistMode","registerPersistentState","getStorageKey","getStorage","area","storageKey","mode","isDisabled","getValue","setValue","buildStorageItem","params","parseStored","storage","readItem","newUrl","fn","field","val","raw","createPluginsService","pluginApis","pluginPublicApi","getPlugin","pluginContext","registerPlugin","registerPlugins","registerPublicApi","methods","plugin","api","plugins","getItemKeyValue","createStorageService","implicitFilterKeys","clearSections","createSection","getSections","getRecord","getSectionsByParentId","getRecordsByParentId","getItemId","updateImplicitFilterKeys","sectionId","parentId","newSection","itemKey","index","itemId","sections","recordSections","rootSections","visibleSections","computeDerivedState","section","record","r","isFilterValueActive","keys","filters","filter","DataGridBodyCellContent","column","CellComponent","getNestedValue","resolveCellDisplayValue","DataGridHeaderCellLabel","resolveLabel","DataGridHeaderCellContent","DataGridHeaderGroup","group","colspan","stickyOffset","useTableService","isSticky","GroupContent","content","TableHead","headerStyles","DataGridRow","tableService","columns","tableLayout","BodyCellContent","DataGridRecordProvider","TableRow","DataGridExtraBodyColumns","col","dynamicClassName","bodyCellProps","resolveBodyCellProps","DataGridCell","DataGridTableRecord","RowComponent","DataGridTableRecords","records","DataGridTableBody","TableBody","DataGridExtraHeaderCell","rowspan","DataGridExtraHeaderColumns","isGroupRow","hasGroups","extraColumns","shouldRender","extra","prepareTableMinContentWidth","useTableStore","setMinContentWidth","useMinContentWidth","columnId","current","next","measureMinContentWidth","cell","computedStyle","paddings","borders","DataGridHeaderCell","headerCellEndSlots","contentRowRef","LabelComponent","minContentWidth","configuredHeaderOverflow","isMinContentColumn","cellOverflow","headerStyle","contentVars","isCapped","resolveColumnStyle","title","fillContent","contentRow","SlotComponent","DataGridTableHeader","theadRef","observerRef","stickyHeader","firstRowCells","secondRowColumns","thead","cells","TableHeader","DataGridTableSlot","slots","layoutClassMap","DataGridTable","subheaderSlots","footerSlots","ContentWrapper","Table","snakeCaseRe","prepareTableColumns","stickyApi","persistence","widthContradictionWarned","headerTruncateDeprecationWarned","allColumnsCappedWarned","initializeColumns","useVisibleColumns","assertColumnId","normalizeColumn","warnOnFixedModeWidthContradiction","warnOnAllColumnsCappedUnderAuto","flatCols","flattenColumns","isTableGroup","initializeColumnVisibility","map","lockedIds","register","visible","useShallow","c","COLUMN_VISIBILITY_KEY","prepareTableColumnsPersistence","read","prepareTableExtraColumns","startPinWarned","registerExtraColumn","updateExtraColumnWidth","updateExtraColumnOrder","updateExtraColumnSticky","useExtraColumns","option","store","existing","newColumn","updated","warnOnStartColumnPin","sticky","updateList","updatedStart","updatedEnd","isStart","prepareTableHeader","defaultComponents","emptyTableColumnArray","headerCellsCache","headerColumnsCache","useHasGroups","useFirstRowHeaderCells","useSecondRowHeaderColumns","getVisibleColumns","getFirstRowHeaderCells","visibleCols","component","columnOrderMap","aIndex","bIndex","visibleCount","getSecondRowHeaderColumns","prepareTableSlots","useSlots","pxWidthRe","prepareTableSticky","initializeStickyState","getOrderedColumnsWithSticky","onResizeColumn","isColumnSticky","isGroupSticky","useColumnStickyOffset","useColumnEndStickyOffset","useGroupStickyOffset","columnSticky","groupSticky","visibleColumns","nonSticky","newWidths","groupId","getStartExtraStickyOffset","offset","getExtraStartOffset","getEndStickyOffset","startExtraWidth","hasStartPinnedData","isVisible","resolveExtraColumnWidth","measured","px","createTableStore","createTableService","createDefaultComponents","TablePropertiesIcon","slotsApi","extraColumnsApi","columnsPersistence","columnsApi","headerApi","minContentWidthApi","registerComponent","updateColumns","updateColumnVisibility","updateColumnSticky","updateTableLayout","updateStickyHeader","useComponent","useConfigurationColumns","useTableLayout","useStickyHeader","columnState","newVisibility","newGroupSticky","newColumnSticky","newComponents","label","columnVisibility","useMemo","toConfigCol","defaults","createDataGrid","services","created","destroy","internalContextKey","firstLoadCutOff","service","noImplicitFilterKeys","DataGrid","load","persistent","persistentColumnVisibility","loadRef","useLatest","DataGridProvider","Suspense","DATA_GRID_VIEW","useDataGridActiveView"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,SAASA,EAAgB,EAAE,WAAAC,KAAmC;AACnE,SACE,gBAAAC,EAAC,QAAA,EAAK,WAAWC,EAAGC,GAAO,SAASH,CAAS,GAC3C,UAAA,gBAAAC,EAACG,IAAA,EAAQ,MAAK,KAAA,CAAK,GACrB;AAEJ;;;;ACRO,SAASC,KAA8B;AAC5C,QAAMC,IAAUC,EAAA,GACVC,IAAmBF,EAAQ,KAAK,kBAAkB,CAACG,MAAMA,EAAE,gBAAgB,GAC3EC,IAAkBJ,EAAQ,KAAK,wBAAwB,CAACG,MAAMA,EAAE,OAAO;AAE7E,SAAOD,MAAqB,aAAaE;AAC3C;;;;ACXO,SAASC,GAAsB,EAAE,UAAAC,KAAwC;AAE9E,QAAMC,IADUN,EAAA,EACiB,KAAK,kBAAkB,CAACE,MAAMA,EAAE,SAAS,GAKpEK,IAJYT,GAAA,KAIeQ,MAAqB,UAKhDE,IAASD,KAAeD,MAAqB;AAEnD,SACE,gBAAAG,EAAC,SAAI,WAAWC,GAAW,MAAM,aAAWF,IAAS,SAAS,QAC3D,UAAA;AAAA,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