@vritti/quantum-ui 0.6.3 → 0.6.5

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 (291) hide show
  1. package/dist/ActivePoints.js +1 -1
  2. package/dist/ActiveShapeUtils.js +1 -1
  3. package/dist/Alert.js +2 -1
  4. package/dist/Alert.js.map +1 -1
  5. package/dist/AreaChart.js +48 -19
  6. package/dist/AreaChart.js.map +1 -1
  7. package/dist/Badge2.js +2 -0
  8. package/dist/Badge2.js.map +1 -1
  9. package/dist/BarChart.js +38 -10
  10. package/dist/BarChart.js.map +1 -1
  11. package/dist/CartesianChart.js +1 -1
  12. package/dist/ChartEmpty.js +8 -0
  13. package/dist/ChartEmpty.js.map +1 -0
  14. package/dist/{Chart.js → ChartFrame.js} +72 -2
  15. package/dist/ChartFrame.js.map +1 -0
  16. package/dist/CurrencyFieldFilter.js +54 -27
  17. package/dist/CurrencyFieldFilter.js.map +1 -1
  18. package/dist/DateRangePicker.js +2 -1
  19. package/dist/DateRangePicker.js.map +1 -1
  20. package/dist/IconSelect.js +1916 -1945
  21. package/dist/IconSelect.js.map +1 -1
  22. package/dist/LineChart.js +116 -107
  23. package/dist/LineChart.js.map +1 -1
  24. package/dist/PieChart.js +37 -15
  25. package/dist/PieChart.js.map +1 -1
  26. package/dist/PolarChart.js +1 -1
  27. package/dist/Progress.js +31 -4
  28. package/dist/Progress.js.map +1 -1
  29. package/dist/RadarChart.js +44 -17
  30. package/dist/RadarChart.js.map +1 -1
  31. package/dist/RadialChart.js +36 -11
  32. package/dist/RadialChart.js.map +1 -1
  33. package/dist/SegmentedProgressKey.js +65 -0
  34. package/dist/SegmentedProgressKey.js.map +1 -0
  35. package/dist/Select.js +95 -20
  36. package/dist/Select.js.map +1 -1
  37. package/dist/SelectFilter.js +79 -8
  38. package/dist/SelectFilter.js.map +1 -1
  39. package/dist/SingleSelect.js +103 -11
  40. package/dist/SingleSelect.js.map +1 -1
  41. package/dist/Sonner.js +2 -1
  42. package/dist/Sonner.js.map +1 -1
  43. package/dist/StepProgressIndicator.js +49 -28
  44. package/dist/StepProgressIndicator.js.map +1 -1
  45. package/dist/ValueFilter.js +3 -2
  46. package/dist/ValueFilter.js.map +1 -1
  47. package/dist/ViewTabs.js.map +1 -1
  48. package/dist/assets/quantum-ui.css +325 -11
  49. package/dist/bindFilters.js +37 -0
  50. package/dist/bindFilters.js.map +1 -0
  51. package/dist/components/Chart.js +125 -0
  52. package/dist/components/Chart.js.map +1 -0
  53. package/dist/components/ContextBar.js +16 -0
  54. package/dist/components/ContextBar.js.map +1 -0
  55. package/dist/components/DataTable.js +1 -1
  56. package/dist/components/DateFilter.js +2 -1
  57. package/dist/components/DateFilter.js.map +1 -1
  58. package/dist/components/SegmentedProgress.js +2 -0
  59. package/dist/components/SegmentedProgress.js.map +1 -0
  60. package/dist/conditions.js +651 -0
  61. package/dist/conditions.js.map +1 -0
  62. package/dist/contextAnchor.js +3 -2
  63. package/dist/contextAnchor.js.map +1 -1
  64. package/dist/getRadiusAndStrokeWidthFromDot.js +1 -1
  65. package/dist/getZIndexFromUnknown.js +1 -1
  66. package/dist/graphicalItemSelectors.js +1 -1
  67. package/dist/hooks/index.js +1 -2
  68. package/dist/hooks/index.js.map +1 -1
  69. package/dist/index.js +3 -3
  70. package/dist/index14.js +1139 -20
  71. package/dist/index14.js.map +1 -1
  72. package/dist/index15.js +20 -1139
  73. package/dist/index15.js.map +1 -1
  74. package/dist/index34.js +2 -2
  75. package/dist/index7.js +2 -1
  76. package/dist/index7.js.map +1 -1
  77. package/dist/info.js +19 -0
  78. package/dist/info.js.map +1 -0
  79. package/dist/lib/components/AreaChart/AreaChart.d.ts +12 -15
  80. package/dist/lib/components/AreaChart/AreaChart.d.ts.map +1 -1
  81. package/dist/lib/components/AreaChart/index.d.ts +0 -1
  82. package/dist/lib/components/AreaChart/index.d.ts.map +1 -1
  83. package/dist/lib/components/BarChart/BarChart.d.ts +11 -14
  84. package/dist/lib/components/BarChart/BarChart.d.ts.map +1 -1
  85. package/dist/lib/components/BarChart/index.d.ts +0 -1
  86. package/dist/lib/components/BarChart/index.d.ts.map +1 -1
  87. package/dist/lib/components/Chart/ChartEmpty.d.ts +3 -0
  88. package/dist/lib/components/Chart/ChartEmpty.d.ts.map +1 -0
  89. package/dist/lib/components/Chart/ChartFrame.d.ts +16 -0
  90. package/dist/lib/components/Chart/ChartFrame.d.ts.map +1 -0
  91. package/dist/lib/components/Chart/ChartKey.d.ts +11 -0
  92. package/dist/lib/components/Chart/ChartKey.d.ts.map +1 -0
  93. package/dist/lib/components/Chart/ChartStates.d.ts +12 -0
  94. package/dist/lib/components/Chart/ChartStates.d.ts.map +1 -0
  95. package/dist/lib/components/Chart/colorSeries.d.ts +6 -0
  96. package/dist/lib/components/Chart/colorSeries.d.ts.map +1 -0
  97. package/dist/lib/components/Chart/index.d.ts +5 -0
  98. package/dist/lib/components/Chart/index.d.ts.map +1 -0
  99. package/dist/lib/components/Chart/types.d.ts +36 -0
  100. package/dist/lib/components/Chart/types.d.ts.map +1 -0
  101. package/dist/lib/components/Chart/useChart.d.ts +23 -0
  102. package/dist/lib/components/Chart/useChart.d.ts.map +1 -0
  103. package/dist/lib/components/Chart/utils.d.ts +7 -0
  104. package/dist/lib/components/Chart/utils.d.ts.map +1 -0
  105. package/dist/lib/components/ContextBar/ContextBar.d.ts +10 -0
  106. package/dist/lib/components/ContextBar/ContextBar.d.ts.map +1 -0
  107. package/dist/lib/components/ContextBar/index.d.ts +3 -0
  108. package/dist/lib/components/ContextBar/index.d.ts.map +1 -0
  109. package/dist/lib/components/ContextBar/useContextSave.d.ts +15 -0
  110. package/dist/lib/components/ContextBar/useContextSave.d.ts.map +1 -0
  111. package/dist/lib/components/ContextBar/useContextState.d.ts +22 -0
  112. package/dist/lib/components/ContextBar/useContextState.d.ts.map +1 -0
  113. package/dist/lib/components/ContextBar/useSettlingFields.d.ts +5 -0
  114. package/dist/lib/components/ContextBar/useSettlingFields.d.ts.map +1 -0
  115. package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts +4 -1
  116. package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts.map +1 -1
  117. package/dist/lib/components/DataTable/DataTable.d.ts +1 -1
  118. package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
  119. package/dist/lib/components/DataTable/DataTableSkeleton.d.ts +11 -0
  120. package/dist/lib/components/DataTable/DataTableSkeleton.d.ts.map +1 -0
  121. package/dist/lib/components/DataTable/cells/cells.d.ts.map +1 -1
  122. package/dist/lib/components/DataTable/components/DataTableColumnHeader.d.ts.map +1 -1
  123. package/dist/lib/components/DataTable/components/DataTableFilters.d.ts.map +1 -1
  124. package/dist/lib/components/DataTable/components/DataTableLoadStates.d.ts +9 -0
  125. package/dist/lib/components/DataTable/components/DataTableLoadStates.d.ts.map +1 -0
  126. package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -1
  127. package/dist/lib/components/DataTable/components/DataTableSearch.d.ts.map +1 -1
  128. package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -1
  129. package/dist/lib/components/DataTable/components/DataTableViewOptions.d.ts.map +1 -1
  130. package/dist/lib/components/DataTable/components/bindFilters.d.ts +3 -1
  131. package/dist/lib/components/DataTable/components/bindFilters.d.ts.map +1 -1
  132. package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts +1 -1
  133. package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts.map +1 -1
  134. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +15 -8
  135. package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
  136. package/dist/lib/components/DataTable/index.d.ts +6 -4
  137. package/dist/lib/components/DataTable/index.d.ts.map +1 -1
  138. package/dist/lib/components/DataTable/modes.d.ts +9 -0
  139. package/dist/lib/components/DataTable/modes.d.ts.map +1 -0
  140. package/dist/lib/components/DataTable/store/store.d.ts +10 -9
  141. package/dist/lib/components/DataTable/store/store.d.ts.map +1 -1
  142. package/dist/lib/components/DataTable/store/useTableSlice.d.ts +5 -4
  143. package/dist/lib/components/DataTable/store/useTableSlice.d.ts.map +1 -1
  144. package/dist/lib/components/DataTable/types.d.ts +30 -8
  145. package/dist/lib/components/DataTable/types.d.ts.map +1 -1
  146. package/dist/lib/components/DataTable/utils.d.ts +1 -1
  147. package/dist/lib/components/DataTable/utils.d.ts.map +1 -1
  148. package/dist/lib/components/DateFilter/DateFilter.d.ts +2 -1
  149. package/dist/lib/components/DateFilter/DateFilter.d.ts.map +1 -1
  150. package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts +2 -1
  151. package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts.map +1 -1
  152. package/dist/lib/components/Editor/editor-ui/button.d.ts +1 -1
  153. package/dist/lib/components/LineChart/LineChart.d.ts +17 -22
  154. package/dist/lib/components/LineChart/LineChart.d.ts.map +1 -1
  155. package/dist/lib/components/LineChart/LineChartEmpty.d.ts +2 -7
  156. package/dist/lib/components/LineChart/LineChartEmpty.d.ts.map +1 -1
  157. package/dist/lib/components/LineChart/index.d.ts +1 -3
  158. package/dist/lib/components/LineChart/index.d.ts.map +1 -1
  159. package/dist/lib/components/PieChart/PieChart.d.ts +9 -8
  160. package/dist/lib/components/PieChart/PieChart.d.ts.map +1 -1
  161. package/dist/lib/components/PieChart/index.d.ts +0 -1
  162. package/dist/lib/components/PieChart/index.d.ts.map +1 -1
  163. package/dist/lib/components/Progress/Progress.d.ts +3 -1
  164. package/dist/lib/components/Progress/Progress.d.ts.map +1 -1
  165. package/dist/lib/components/RadarChart/RadarChart.d.ts +10 -13
  166. package/dist/lib/components/RadarChart/RadarChart.d.ts.map +1 -1
  167. package/dist/lib/components/RadarChart/index.d.ts +0 -1
  168. package/dist/lib/components/RadarChart/index.d.ts.map +1 -1
  169. package/dist/lib/components/RadialChart/RadialChart.d.ts +11 -8
  170. package/dist/lib/components/RadialChart/RadialChart.d.ts.map +1 -1
  171. package/dist/lib/components/RadialChart/index.d.ts +0 -1
  172. package/dist/lib/components/RadialChart/index.d.ts.map +1 -1
  173. package/dist/lib/components/SegmentedProgress/SegmentedProgress.d.ts +16 -0
  174. package/dist/lib/components/SegmentedProgress/SegmentedProgress.d.ts.map +1 -0
  175. package/dist/lib/components/SegmentedProgress/SegmentedProgressKey.d.ts +14 -0
  176. package/dist/lib/components/SegmentedProgress/SegmentedProgressKey.d.ts.map +1 -0
  177. package/dist/lib/components/SegmentedProgress/index.d.ts +5 -0
  178. package/dist/lib/components/SegmentedProgress/index.d.ts.map +1 -0
  179. package/dist/lib/components/SegmentedProgress/steps.d.ts +2 -0
  180. package/dist/lib/components/SegmentedProgress/steps.d.ts.map +1 -0
  181. package/dist/lib/components/Select/Select.d.ts.map +1 -1
  182. package/dist/lib/components/Select/SelectFilter.d.ts +10 -0
  183. package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -1
  184. package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +1 -0
  185. package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
  186. package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts +1 -0
  187. package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -1
  188. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +2 -0
  189. package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
  190. package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts +1 -0
  191. package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
  192. package/dist/lib/components/Select/contextAnchor.d.ts +1 -0
  193. package/dist/lib/components/Select/contextAnchor.d.ts.map +1 -1
  194. package/dist/lib/components/Select/hooks/useSelect.d.ts +4 -0
  195. package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
  196. package/dist/lib/components/Select/types.d.ts +1 -0
  197. package/dist/lib/components/Select/types.d.ts.map +1 -1
  198. package/dist/lib/components/StepProgressIndicator/StepProgressIndicator.d.ts +4 -1
  199. package/dist/lib/components/StepProgressIndicator/StepProgressIndicator.d.ts.map +1 -1
  200. package/dist/lib/components/ValueFilter/ValueFilter.d.ts +7 -1
  201. package/dist/lib/components/ValueFilter/ValueFilter.d.ts.map +1 -1
  202. package/dist/lib/components/ViewTabs/ViewTabs.d.ts +3 -3
  203. package/dist/lib/components/ViewTabs/ViewTabs.d.ts.map +1 -1
  204. package/dist/lib/components/index.d.ts +1 -0
  205. package/dist/lib/components/index.d.ts.map +1 -1
  206. package/dist/lib/config/index.d.ts +1 -0
  207. package/dist/lib/config/index.d.ts.map +1 -1
  208. package/dist/lib/hooks/index.d.ts +1 -0
  209. package/dist/lib/hooks/index.d.ts.map +1 -1
  210. package/dist/lib/hooks/useFormatters.d.ts +3 -0
  211. package/dist/lib/hooks/useFormatters.d.ts.map +1 -1
  212. package/dist/lib/hooks/useOrgCountryCode.d.ts +2 -0
  213. package/dist/lib/hooks/useOrgCountryCode.d.ts.map +1 -0
  214. package/dist/lib/selects/icon/IconSelect.d.ts.map +1 -1
  215. package/dist/lib/services/context-states.service.d.ts +4 -0
  216. package/dist/lib/services/context-states.service.d.ts.map +1 -0
  217. package/dist/lib/services/table-views.service.d.ts +7 -5
  218. package/dist/lib/services/table-views.service.d.ts.map +1 -1
  219. package/dist/lib/types/api-response.d.ts +2 -2
  220. package/dist/lib/types/api-response.d.ts.map +1 -1
  221. package/dist/lib/types/{table-filter.d.ts → conditions.d.ts} +1 -27
  222. package/dist/lib/types/conditions.d.ts.map +1 -0
  223. package/dist/lib/types/table-state.d.ts +28 -0
  224. package/dist/lib/types/table-state.d.ts.map +1 -0
  225. package/dist/lib/utils/axios.d.ts +1 -0
  226. package/dist/lib/utils/axios.d.ts.map +1 -1
  227. package/dist/lib/utils/conditions.d.ts +11 -0
  228. package/dist/lib/utils/conditions.d.ts.map +1 -0
  229. package/dist/lib/utils/country.d.ts +3 -0
  230. package/dist/lib/utils/country.d.ts.map +1 -0
  231. package/dist/lib/utils/filter.d.ts +1 -1
  232. package/dist/lib/utils/filter.d.ts.map +1 -1
  233. package/dist/lib/utils/format.d.ts +5 -0
  234. package/dist/lib/utils/format.d.ts.map +1 -1
  235. package/dist/lib/utils/lodash.d.ts +1 -1
  236. package/dist/lib/utils/lodash.d.ts.map +1 -1
  237. package/dist/lib/utils/timezone.d.ts +1 -0
  238. package/dist/lib/utils/timezone.d.ts.map +1 -1
  239. package/dist/polarScaleSelectors.js +1 -1
  240. package/dist/select2.js +1 -1
  241. package/dist/separator2.js +1 -1
  242. package/dist/shadcn/optionKeys.d.ts +4 -0
  243. package/dist/shadcn/optionKeys.d.ts.map +1 -0
  244. package/dist/shadcn/shadcnBadge/Badge.d.ts +1 -1
  245. package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -1
  246. package/dist/shadcn/shadcnButton/Button.d.ts +2 -2
  247. package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts +3 -2
  248. package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts.map +1 -1
  249. package/dist/shadcn/shadcnProgress/Progress.d.ts +4 -1
  250. package/dist/shadcn/shadcnProgress/Progress.d.ts.map +1 -1
  251. package/dist/shadcn/shadcnSingleSelect/single-select.d.ts +3 -2
  252. package/dist/shadcn/shadcnSingleSelect/single-select.d.ts.map +1 -1
  253. package/dist/table-properties.js +64 -33
  254. package/dist/table-properties.js.map +1 -1
  255. package/dist/timezone.js +4 -1
  256. package/dist/timezone.js.map +1 -1
  257. package/dist/tooltipContext.js +1 -1
  258. package/dist/triangle-alert.js +1 -16
  259. package/dist/triangle-alert.js.map +1 -1
  260. package/dist/types/conditions.js +2 -0
  261. package/dist/types/conditions.js.map +1 -0
  262. package/dist/types/{table-filter.js → table-state.js} +1 -1
  263. package/dist/types/table-state.js.map +1 -0
  264. package/dist/useContextState.js +201 -0
  265. package/dist/useContextState.js.map +1 -0
  266. package/dist/useDataTable.js +572 -924
  267. package/dist/useDataTable.js.map +1 -1
  268. package/dist/useFormatters.js +2 -1
  269. package/dist/useFormatters.js.map +1 -1
  270. package/dist/useWorkspaceCurrency.js +27 -2
  271. package/dist/useWorkspaceCurrency.js.map +1 -1
  272. package/dist/useWorkspaceTimeZone.js +2 -2
  273. package/dist/useWorkspaceTimeZone.js.map +1 -1
  274. package/dist/utils/axios.js +5 -1
  275. package/dist/utils/axios.js.map +1 -1
  276. package/dist/utils/country.js +20 -0
  277. package/dist/utils/country.js.map +1 -0
  278. package/dist/utils/filter.js.map +1 -1
  279. package/dist/utils/format.js +23 -4
  280. package/dist/utils/format.js.map +1 -1
  281. package/dist/utils/lodash.js +3 -1
  282. package/dist/utils/lodash.js.map +1 -1
  283. package/dist/utils/timezone.js +1 -1
  284. package/dist/utils2.js +6 -0
  285. package/dist/utils2.js.map +1 -0
  286. package/package.json +24 -4
  287. package/dist/Chart.js.map +0 -1
  288. package/dist/lib/types/table-filter.d.ts.map +0 -1
  289. package/dist/types/table-filter.js.map +0 -1
  290. package/dist/useCategoricalColors.js +0 -20
  291. package/dist/useCategoricalColors.js.map +0 -1
@@ -7,13 +7,15 @@ import { B as Button } from './Button.js';
7
7
  import { D as Dialog, a as DialogActions } from './Dialog.js';
8
8
  import { D as DropdownMenu } from './DropdownMenu.js';
9
9
  import { d as usePermissionGate, l as lockedTip, c as usePermission, b as PermissionLockIcon } from './PermissionGate.js';
10
- import { A as ArrowDown, a as ArrowUp, I as Inbox, S as Settings, C as ChevronsLeft, b as ChevronsRight, c as Columns2, P as Pin, E as EllipsisVertical, F as FileUp, d as FilePlusCorner, R as RefreshCw, e as Equal, f as ArrowLeft, B as BookmarkPlus, L as LayoutList, g as Settings2, h as Funnel, i as ArrowUpFromLine, j as ArrowDownToLine, T as TableProperties } from './table-properties.js';
10
+ import { A as ArrowDown, a as ArrowUp, I as Inbox, S as Settings, C as ChevronsLeft, b as ChevronsRight, M as MoveHorizontal, c as ArrowUpDown, d as Columns2, P as Pin, E as EllipsisVertical, F as FileUp, e as FilePlusCorner, R as RefreshCw, f as Equal, g as ArrowLeft, B as BookmarkPlus, L as LayoutList, h as Settings2, i as Funnel, j as ArrowUpFromLine, k as ArrowDownToLine, T as TableProperties } from './table-properties.js';
11
11
  import { useMutation, useQueryClient, useQuery } from '@tanstack/react-query';
12
12
  import * as React from 'react';
13
- import React__default, { Children, isValidElement, cloneElement, useMemo, useState, useRef, useEffect, forwardRef, useCallback, useLayoutEffect } from 'react';
14
- import { EMPTY_TABLE_STATE } from './types/table-filter.js';
15
- import { axios } from './utils/axios.js';
13
+ import React__default, { useMemo, isValidElement, useState, useRef, useEffect, forwardRef, useCallback, useLayoutEffect } from 'react';
14
+ import { EMPTY_TABLE_STATE } from './types/table-state.js';
15
+ import { axios, problemDetail } from './utils/axios.js';
16
+ import { b as bindFilters, f as filterName, a as filterLabel } from './bindFilters.js';
16
17
  import { E as Empty } from './Empty.js';
18
+ import { d as deepEqual, w as withDefaults, r as readValue, h as holdsResetDefaults, c as hasEveryDefault } from './conditions.js';
17
19
  import { b as SortableList, a as SortableItem } from './Sortable.js';
18
20
  import { P as Popover, a as PopoverTrigger, b as PopoverContent } from './popover.js';
19
21
  import { G as GripVertical } from './grip-vertical.js';
@@ -25,6 +27,7 @@ import { U as UploadFile } from './UploadFile.js';
25
27
  import { U as Upload } from './upload.js';
26
28
  import { T as TextAlignJustify, D as Download } from './text-align-justify.js';
27
29
  import { C as CircleCheck } from './circle-check.js';
30
+ import { T as TriangleAlert } from './triangle-alert.js';
28
31
  import { S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem } from './select2.js';
29
32
  import { C as ChevronLeft } from './chevron-left.js';
30
33
  import { I as Input } from './Input.js';
@@ -35,17 +38,49 @@ import { A as AnimatePresence, m as motion } from './proxy.js';
35
38
  import { S as Search } from './search.js';
36
39
  import { C as ChevronDown } from './chevron-down.js';
37
40
  import { X } from './x.js';
41
+ import { pluralize } from './utils/pluralize.js';
38
42
  import { L as Lock } from './lock.js';
39
43
  import { a as Switch } from './Switch.js';
40
44
  import { a, o as object, s as string } from './schemas.js';
41
45
  import { T as TextField } from './TextField.js';
42
46
  import { S as Save, a as Share2 } from './share-2.js';
43
47
  import { P as Pencil, a as Plus, T as Trash2 } from './trash-2.js';
44
- import { T as TriangleAlert } from './triangle-alert.js';
45
48
  import { S as Separator } from './separator2.js';
46
- import { pluralize } from './utils/pluralize.js';
47
49
  import { C as Checkbox } from './Checkbox.js';
48
50
  import { g as getConfig } from './index7.js';
51
+ import { t as toast } from './toast.js';
52
+
53
+ function viewsUrl(path = "") {
54
+ return `${getConfig().views.viewsEndpoint}${path}`;
55
+ }
56
+ const silent = { showSuccessToast: false, showErrorToast: false };
57
+ function fetchViews(tableSlug) {
58
+ return axios.get(viewsUrl(), { params: { tableSlug }, ...silent }).then((r) => r.data);
59
+ }
60
+ function createView(dto) {
61
+ return axios.post(viewsUrl(), dto, silent).then((r) => r.data);
62
+ }
63
+ function updateView(id, state) {
64
+ return axios.patch(viewsUrl(`/${id}`), { state }, silent).then((r) => r.data);
65
+ }
66
+ function toggleShareView(id, isShared) {
67
+ return axios.patch(viewsUrl(`/${id}/share`), { isShared }, silent).then((r) => r.data);
68
+ }
69
+ function renameView(id, name) {
70
+ return axios.patch(viewsUrl(`/${id}/rename`), { name }, silent).then((r) => r.data);
71
+ }
72
+ function deleteView(id) {
73
+ return axios.delete(viewsUrl(`/${id}`), silent).then(() => void 0);
74
+ }
75
+ function statesUrl() {
76
+ return getConfig().views.statesEndpoint;
77
+ }
78
+ function putTableState(tableSlug, state, activeViewId) {
79
+ return axios.put(statesUrl(), { tableSlug, state, activeViewId }, silent).then(() => void 0);
80
+ }
81
+ function setTableContext(tableSlug, context) {
82
+ return axios.patch(statesUrl(), { tableSlug, context }, silent).then(() => void 0);
83
+ }
49
84
 
50
85
  const DEFAULT_COLUMNS = [
51
86
  { headerWidth: "w-20", cellWidth: "w-28" },
@@ -105,9 +140,9 @@ const NumberCell = ({ value, fractionDigits, className }) => {
105
140
  const CurrencyCell = ({ value, exchangeRate, className }) => {
106
141
  const fmt = useFormatters();
107
142
  const { primary, secondary } = fmt.currency(value, { exchangeRate });
108
- return /* @__PURE__ */ jsxs("span", { className: ["font-mono", className].filter(Boolean).join(" "), children: [
143
+ return /* @__PURE__ */ jsxs("span", { className: ["inline-flex flex-col font-mono", className].filter(Boolean).join(" "), children: [
109
144
  primary,
110
- secondary && /* @__PURE__ */ jsx("span", { className: "ml-1 text-xs text-muted-foreground", children: secondary })
145
+ secondary && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: secondary })
111
146
  ] });
112
147
  };
113
148
  const DateCell = ({ value, className }) => {
@@ -129,8 +164,8 @@ function DataTableColumnHeader({
129
164
  const isPinned = column.getIsPinned();
130
165
  const pinnedBadge = isPinned ? /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium px-1.5 py-0.5 rounded bg-primary/10 text-primary", children: "Pinned" }) : null;
131
166
  if (!column.getCanSort()) {
132
- return /* @__PURE__ */ jsxs("span", { className: cn("font-medium flex items-center gap-2", className), children: [
133
- title,
167
+ return /* @__PURE__ */ jsxs("span", { className: cn("font-medium flex min-w-0 max-w-full items-center gap-2", className), title, children: [
168
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: title }),
134
169
  pinnedBadge
135
170
  ] });
136
171
  }
@@ -139,14 +174,15 @@ function DataTableColumnHeader({
139
174
  {
140
175
  type: "button",
141
176
  className: cn(
142
- "relative flex items-center cursor-pointer select-none group bg-transparent border-0 p-0 text-inherit",
177
+ "relative flex min-w-0 max-w-full items-center cursor-pointer select-none group bg-transparent border-0 p-0 pr-4 text-inherit",
143
178
  className
144
179
  ),
180
+ title,
145
181
  onClick: (e) => column.getToggleSortingHandler()?.(e),
146
182
  children: [
147
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: title }),
183
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: title }),
148
184
  pinnedBadge,
149
- /* @__PURE__ */ jsx("span", { className: "absolute -right-5 top-1/2 -translate-y-1/2", children: column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" }) : column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5 opacity-0 group-hover:opacity-30 transition-opacity" }) })
185
+ /* @__PURE__ */ jsx("span", { className: "absolute right-0 top-1/2 -translate-y-1/2", children: column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" }) : column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5 opacity-0 group-hover:opacity-30 transition-opacity" }) })
150
186
  ]
151
187
  }
152
188
  );
@@ -164,617 +200,6 @@ function DataTableEmpty({
164
200
  }
165
201
  DataTableEmpty.displayName = "DataTableEmpty";
166
202
 
167
- const { getOwnPropertyNames, getOwnPropertySymbols } = Object;
168
- // eslint-disable-next-line @typescript-eslint/unbound-method
169
- const { hasOwnProperty } = Object.prototype;
170
- /**
171
- * Combine two comparators into a single comparators.
172
- */
173
- function combineComparators(comparatorA, comparatorB) {
174
- return function isEqual(a, b, state) {
175
- return comparatorA(a, b, state) && comparatorB(a, b, state);
176
- };
177
- }
178
- /**
179
- * Wrap the provided `areItemsEqual` method to manage the circular state, allowing
180
- * for circular references to be safely included in the comparison without creating
181
- * stack overflows.
182
- */
183
- function createIsCircular(areItemsEqual) {
184
- return function isCircular(a, b, state) {
185
- if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {
186
- return areItemsEqual(a, b, state);
187
- }
188
- const { cache } = state;
189
- const cachedA = cache.get(a);
190
- const cachedB = cache.get(b);
191
- if (cachedA && cachedB) {
192
- return cachedA === b && cachedB === a;
193
- }
194
- cache.set(a, b);
195
- cache.set(b, a);
196
- const result = areItemsEqual(a, b, state);
197
- cache.delete(a);
198
- cache.delete(b);
199
- return result;
200
- };
201
- }
202
- /**
203
- * Get the properties to strictly examine, which include both own properties that are
204
- * not enumerable and symbol properties.
205
- */
206
- function getStrictProperties(object) {
207
- return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
208
- }
209
- /**
210
- * Whether the object contains the property passed as an own property.
211
- */
212
- const hasOwn =
213
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
214
- Object.hasOwn || ((object, property) => hasOwnProperty.call(object, property));
215
-
216
- const PREACT_VNODE = '__v';
217
- const PREACT_OWNER = '__o';
218
- const REACT_OWNER = '_owner';
219
- const { getOwnPropertyDescriptor, keys: keys$1 } = Object;
220
- /**
221
- * Whether the values passed are equal based on a [SameValue](https://262.ecma-international.org/7.0/#sec-samevalue) basis.
222
- * Simplified, this maps to if the two values are referentially equal to one another (`a === b`) or both are `NaN`.
223
- *
224
- * @note
225
- * When available in the environment, this is just a re-export of the global
226
- * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) method.
227
- */
228
- const sameValueEqual =
229
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
230
- Object.is
231
- || function sameValueEqual(a, b) {
232
- return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
233
- };
234
- /**
235
- * Whether the values passed are equal based on a
236
- * [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
237
- * Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
238
- *
239
- * @note
240
- * This is mainly available as a convenience function, such as being a default when a function to determine equality between
241
- * two objects is used.
242
- */
243
- function strictEqual(a, b) {
244
- return a === b;
245
- }
246
- /**
247
- * Whether the array buffers are equal in value.
248
- */
249
- function areArrayBuffersEqual(a, b) {
250
- return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));
251
- }
252
- /**
253
- * Whether the arrays are equal in value.
254
- */
255
- function areArraysEqual(a, b, state) {
256
- let index = a.length;
257
- if (b.length !== index) {
258
- return false;
259
- }
260
- while (index-- > 0) {
261
- if (!state.equals(a[index], b[index], index, index, a, b, state)) {
262
- return false;
263
- }
264
- }
265
- return true;
266
- }
267
- /**
268
- * Whether the dataviews are equal in value.
269
- */
270
- function areDataViewsEqual(a, b) {
271
- return (a.byteLength === b.byteLength
272
- && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)));
273
- }
274
- /**
275
- * Whether the dates passed are equal in value.
276
- */
277
- function areDatesEqual(a, b) {
278
- return sameValueEqual(a.getTime(), b.getTime());
279
- }
280
- /**
281
- * Whether the errors passed are equal in value.
282
- */
283
- function areErrorsEqual(a, b) {
284
- return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
285
- }
286
- /**
287
- * Whether the `Map`s are equal in value.
288
- */
289
- function areMapsEqual(a, b, state) {
290
- const size = a.size;
291
- if (size !== b.size) {
292
- return false;
293
- }
294
- if (!size) {
295
- return true;
296
- }
297
- const matchedIndices = new Array(size);
298
- const aIterable = a.entries();
299
- let aResult;
300
- let bResult;
301
- let index = 0;
302
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
303
- while ((aResult = aIterable.next())) {
304
- if (aResult.done) {
305
- break;
306
- }
307
- const bIterable = b.entries();
308
- let hasMatch = false;
309
- let matchIndex = 0;
310
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
311
- while ((bResult = bIterable.next())) {
312
- if (bResult.done) {
313
- break;
314
- }
315
- if (matchedIndices[matchIndex]) {
316
- matchIndex++;
317
- continue;
318
- }
319
- const aEntry = aResult.value;
320
- const bEntry = bResult.value;
321
- if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state)
322
- && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
323
- hasMatch = matchedIndices[matchIndex] = true;
324
- break;
325
- }
326
- matchIndex++;
327
- }
328
- if (!hasMatch) {
329
- return false;
330
- }
331
- index++;
332
- }
333
- return true;
334
- }
335
- /**
336
- * Whether the objects are equal in value.
337
- */
338
- function areObjectsEqual(a, b, state) {
339
- const properties = keys$1(a);
340
- let index = properties.length;
341
- if (keys$1(b).length !== index) {
342
- return false;
343
- }
344
- // Decrementing `while` showed faster results than either incrementing or
345
- // decrementing `for` loop and than an incrementing `while` loop. Declarative
346
- // methods like `some` / `every` were not used to avoid incurring the garbage
347
- // cost of anonymous callbacks.
348
- while (index-- > 0) {
349
- if (!isPropertyEqual(a, b, state, properties[index])) {
350
- return false;
351
- }
352
- }
353
- return true;
354
- }
355
- /**
356
- * Whether the objects are equal in value with strict property checking.
357
- */
358
- function areObjectsEqualStrict(a, b, state) {
359
- const properties = getStrictProperties(a);
360
- let index = properties.length;
361
- if (getStrictProperties(b).length !== index) {
362
- return false;
363
- }
364
- let property;
365
- let descriptorA;
366
- let descriptorB;
367
- // Decrementing `while` showed faster results than either incrementing or
368
- // decrementing `for` loop and than an incrementing `while` loop. Declarative
369
- // methods like `some` / `every` were not used to avoid incurring the garbage
370
- // cost of anonymous callbacks.
371
- while (index-- > 0) {
372
- property = properties[index];
373
- if (!isPropertyEqual(a, b, state, property)) {
374
- return false;
375
- }
376
- descriptorA = getOwnPropertyDescriptor(a, property);
377
- descriptorB = getOwnPropertyDescriptor(b, property);
378
- if ((descriptorA || descriptorB)
379
- && (!descriptorA
380
- || !descriptorB
381
- || descriptorA.configurable !== descriptorB.configurable
382
- || descriptorA.enumerable !== descriptorB.enumerable
383
- || descriptorA.writable !== descriptorB.writable)) {
384
- return false;
385
- }
386
- }
387
- return true;
388
- }
389
- /**
390
- * Whether the primitive wrappers passed are equal in value.
391
- */
392
- function arePrimitiveWrappersEqual(a, b) {
393
- return sameValueEqual(a.valueOf(), b.valueOf());
394
- }
395
- /**
396
- * Whether the regexps passed are equal in value.
397
- */
398
- function areRegExpsEqual(a, b) {
399
- return a.source === b.source && a.flags === b.flags;
400
- }
401
- /**
402
- * Whether the `Set`s are equal in value.
403
- */
404
- function areSetsEqual(a, b, state) {
405
- const size = a.size;
406
- if (size !== b.size) {
407
- return false;
408
- }
409
- if (!size) {
410
- return true;
411
- }
412
- const matchedIndices = new Array(size);
413
- const aIterable = a.values();
414
- let aResult;
415
- let bResult;
416
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
417
- while ((aResult = aIterable.next())) {
418
- if (aResult.done) {
419
- break;
420
- }
421
- const bIterable = b.values();
422
- let hasMatch = false;
423
- let matchIndex = 0;
424
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
425
- while ((bResult = bIterable.next())) {
426
- if (bResult.done) {
427
- break;
428
- }
429
- if (!matchedIndices[matchIndex]
430
- && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
431
- hasMatch = matchedIndices[matchIndex] = true;
432
- break;
433
- }
434
- matchIndex++;
435
- }
436
- if (!hasMatch) {
437
- return false;
438
- }
439
- }
440
- return true;
441
- }
442
- /**
443
- * Whether the TypedArray instances are equal in value.
444
- */
445
- function areTypedArraysEqual(a, b) {
446
- let index = a.byteLength;
447
- if (b.byteLength !== index || a.byteOffset !== b.byteOffset) {
448
- return false;
449
- }
450
- while (index-- > 0) {
451
- if (a[index] !== b[index]) {
452
- return false;
453
- }
454
- }
455
- return true;
456
- }
457
- /**
458
- * Whether the URL instances are equal in value.
459
- */
460
- function areUrlsEqual(a, b) {
461
- return (a.hostname === b.hostname
462
- && a.pathname === b.pathname
463
- && a.protocol === b.protocol
464
- && a.port === b.port
465
- && a.hash === b.hash
466
- && a.username === b.username
467
- && a.password === b.password);
468
- }
469
- function isPropertyEqual(a, b, state, property) {
470
- if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE)
471
- && (a.$$typeof || b.$$typeof)) {
472
- return true;
473
- }
474
- return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
475
- }
476
-
477
- // eslint-disable-next-line @typescript-eslint/unbound-method
478
- const toString$1 = Object.prototype.toString;
479
- /**
480
- * Create a comparator method based on the type-specific equality comparators passed.
481
- */
482
- function createEqualityComparator(config) {
483
- const supportedComparatorMap = createSupportedComparatorMap(config);
484
- const { areArraysEqual, areDatesEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, areRegExpsEqual, areSetsEqual, getUnsupportedCustomComparator, } = config;
485
- /**
486
- * compare the value of the two objects and return true if they are equivalent in values
487
- */
488
- return function comparator(a, b, state) {
489
- // If the items are strictly equal, no need to do a value comparison.
490
- if (a === b) {
491
- return true;
492
- }
493
- // If either of the items are nullish and fail the strictly equal check
494
- // above, then they must be unequal.
495
- if (a == null || b == null) {
496
- return false;
497
- }
498
- const type = typeof a;
499
- if (type !== typeof b) {
500
- return false;
501
- }
502
- if (type !== 'object') {
503
- if (type === 'number' || type === 'bigint') {
504
- return areNumbersEqual(a, b, state);
505
- }
506
- if (type === 'function') {
507
- return areFunctionsEqual(a, b, state);
508
- }
509
- // If a primitive value that is not strictly equal, it must be unequal.
510
- return false;
511
- }
512
- const constructor = a.constructor;
513
- // Checks are listed in order of commonality of use-case:
514
- // 1. Common complex object types (plain object, array)
515
- // 2. Common data values (date, regexp)
516
- // 3. Less-common complex object types (map, set)
517
- // 4. Less-common data values (promise, primitive wrappers)
518
- // Inherently this is both subjective and assumptive, however
519
- // when reviewing comparable libraries in the wild this order
520
- // appears to be generally consistent.
521
- // Constructors should match, otherwise there is potential for false positives
522
- // between class and subclass or custom object and POJO.
523
- if (constructor !== b.constructor) {
524
- return false;
525
- }
526
- // Try to fast-path equality checks for other complex object types in the
527
- // same realm to avoid capturing the string tag. Strict equality is used
528
- // instead of `instanceof` because it is more performant for the common
529
- // use-case. If someone is creating a subclass from a native class, it will be
530
- // handled with the string tag comparison.
531
- if (constructor === Object) {
532
- return areObjectsEqual(a, b, state);
533
- }
534
- if (constructor === Array) {
535
- return areArraysEqual(a, b, state);
536
- }
537
- if (constructor === Date) {
538
- return areDatesEqual(a, b, state);
539
- }
540
- if (constructor === RegExp) {
541
- return areRegExpsEqual(a, b, state);
542
- }
543
- if (constructor === Map) {
544
- return areMapsEqual(a, b, state);
545
- }
546
- if (constructor === Set) {
547
- return areSetsEqual(a, b, state);
548
- }
549
- if (constructor === Promise) {
550
- // Avoid tag checks for promise values, since we know if they are not referentially equal
551
- // then they are not equal.
552
- return false;
553
- }
554
- // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing
555
- // the string tag or doing an `instanceof` in edge cases.
556
- if (Array.isArray(a)) {
557
- return areArraysEqual(a, b, state);
558
- }
559
- // Since this is a custom object, capture the string tag to determining its type.
560
- // This is reasonably performant in modern environments like v8 and SpiderMonkey.
561
- const tag = toString$1.call(a);
562
- const supportedComparator = supportedComparatorMap[tag];
563
- if (supportedComparator) {
564
- return supportedComparator(a, b, state);
565
- }
566
- const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
567
- if (unsupportedCustomComparator) {
568
- return unsupportedCustomComparator(a, b, state);
569
- }
570
- // If not matching any tags that require a specific type of comparison, then we hard-code false because
571
- // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:
572
- // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only
573
- // comparison that can be made.
574
- // - For types that can be introspected but do not have an objective definition of what
575
- // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.
576
- // In all cases, these decisions should be reevaluated based on changes to the language and
577
- // common development practices.
578
- return false;
579
- };
580
- }
581
- /**
582
- * Create the configuration object used for building comparators.
583
- */
584
- function createEqualityComparatorConfig({ circular, createCustomConfig, strict, }) {
585
- let config = {
586
- areArrayBuffersEqual,
587
- areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
588
- areDataViewsEqual,
589
- areDatesEqual: areDatesEqual,
590
- areErrorsEqual: areErrorsEqual,
591
- areFunctionsEqual: strictEqual,
592
- areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
593
- areNumbersEqual: sameValueEqual,
594
- areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
595
- arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,
596
- areRegExpsEqual: areRegExpsEqual,
597
- areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
598
- areTypedArraysEqual: strict
599
- ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)
600
- : areTypedArraysEqual,
601
- areUrlsEqual: areUrlsEqual,
602
- getUnsupportedCustomComparator: undefined,
603
- };
604
- if (createCustomConfig) {
605
- config = Object.assign({}, config, createCustomConfig(config));
606
- }
607
- if (circular) {
608
- const areArraysEqual = createIsCircular(config.areArraysEqual);
609
- const areMapsEqual = createIsCircular(config.areMapsEqual);
610
- const areObjectsEqual = createIsCircular(config.areObjectsEqual);
611
- const areSetsEqual = createIsCircular(config.areSetsEqual);
612
- config = Object.assign({}, config, {
613
- areArraysEqual,
614
- areMapsEqual,
615
- areObjectsEqual,
616
- areSetsEqual,
617
- });
618
- }
619
- return config;
620
- }
621
- /**
622
- * Default equality comparator pass-through, used as the standard `isEqual` creator for
623
- * use inside the built comparator.
624
- */
625
- function createInternalEqualityComparator(compare) {
626
- return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
627
- return compare(a, b, state);
628
- };
629
- }
630
- /**
631
- * Create the `isEqual` function used by the consuming application.
632
- */
633
- function createIsEqual({ circular, comparator, createState, equals, strict }) {
634
- if (createState) {
635
- return function isEqual(a, b) {
636
- const { cache = circular ? new WeakMap() : undefined, meta } = createState();
637
- return comparator(a, b, {
638
- cache,
639
- equals,
640
- meta,
641
- strict,
642
- });
643
- };
644
- }
645
- if (circular) {
646
- return function isEqual(a, b) {
647
- return comparator(a, b, {
648
- cache: new WeakMap(),
649
- equals,
650
- meta: undefined,
651
- strict,
652
- });
653
- };
654
- }
655
- const state = {
656
- cache: undefined,
657
- equals,
658
- meta: undefined,
659
- strict,
660
- };
661
- return function isEqual(a, b) {
662
- return comparator(a, b, state);
663
- };
664
- }
665
- /**
666
- * Create a map of `toString()` values to their respective handlers for `tag`-based lookups.
667
- */
668
- function createSupportedComparatorMap({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, }) {
669
- return {
670
- '[object Arguments]': areObjectsEqual,
671
- '[object Array]': areArraysEqual,
672
- '[object ArrayBuffer]': areArrayBuffersEqual,
673
- '[object AsyncGeneratorFunction]': areFunctionsEqual,
674
- '[object BigInt]': areNumbersEqual,
675
- '[object BigInt64Array]': areTypedArraysEqual,
676
- '[object BigUint64Array]': areTypedArraysEqual,
677
- '[object Boolean]': arePrimitiveWrappersEqual,
678
- '[object DataView]': areDataViewsEqual,
679
- '[object Date]': areDatesEqual,
680
- // If an error tag, it should be tested explicitly. Like RegExp, the properties are not
681
- // enumerable, and therefore will give false positives if tested like a standard object.
682
- '[object Error]': areErrorsEqual,
683
- '[object Float16Array]': areTypedArraysEqual,
684
- '[object Float32Array]': areTypedArraysEqual,
685
- '[object Float64Array]': areTypedArraysEqual,
686
- '[object Function]': areFunctionsEqual,
687
- '[object GeneratorFunction]': areFunctionsEqual,
688
- '[object Int8Array]': areTypedArraysEqual,
689
- '[object Int16Array]': areTypedArraysEqual,
690
- '[object Int32Array]': areTypedArraysEqual,
691
- '[object Map]': areMapsEqual,
692
- '[object Number]': arePrimitiveWrappersEqual,
693
- '[object Object]': (a, b, state) =>
694
- // The exception for value comparison is custom `Promise`-like class instances. These should
695
- // be treated the same as standard `Promise` objects, which means strict equality, and if
696
- // it reaches this point then that strict equality comparison has already failed.
697
- typeof a.then !== 'function' && typeof b.then !== 'function' && areObjectsEqual(a, b, state),
698
- // For RegExp, the properties are not enumerable, and therefore will give false positives if
699
- // tested like a standard object.
700
- '[object RegExp]': areRegExpsEqual,
701
- '[object Set]': areSetsEqual,
702
- '[object String]': arePrimitiveWrappersEqual,
703
- '[object URL]': areUrlsEqual,
704
- '[object Uint8Array]': areTypedArraysEqual,
705
- '[object Uint8ClampedArray]': areTypedArraysEqual,
706
- '[object Uint16Array]': areTypedArraysEqual,
707
- '[object Uint32Array]': areTypedArraysEqual,
708
- };
709
- }
710
-
711
- /**
712
- * Whether the items passed are deeply-equal in value.
713
- */
714
- const deepEqual = createCustomEqual();
715
- /**
716
- * Whether the items passed are deeply-equal in value based on strict comparison.
717
- */
718
- createCustomEqual({ strict: true });
719
- /**
720
- * Whether the items passed are deeply-equal in value, including circular references.
721
- */
722
- createCustomEqual({ circular: true });
723
- /**
724
- * Whether the items passed are deeply-equal in value, including circular references,
725
- * based on strict comparison.
726
- */
727
- createCustomEqual({
728
- circular: true,
729
- strict: true,
730
- });
731
- /**
732
- * Whether the items passed are shallowly-equal in value.
733
- */
734
- createCustomEqual({
735
- createInternalComparator: () => sameValueEqual,
736
- });
737
- /**
738
- * Whether the items passed are shallowly-equal in value based on strict comparison
739
- */
740
- createCustomEqual({
741
- strict: true,
742
- createInternalComparator: () => sameValueEqual,
743
- });
744
- /**
745
- * Whether the items passed are shallowly-equal in value, including circular references.
746
- */
747
- createCustomEqual({
748
- circular: true,
749
- createInternalComparator: () => sameValueEqual,
750
- });
751
- /**
752
- * Whether the items passed are shallowly-equal in value, including circular references,
753
- * based on strict comparison.
754
- */
755
- createCustomEqual({
756
- circular: true,
757
- createInternalComparator: () => sameValueEqual,
758
- strict: true,
759
- });
760
- /**
761
- * Create a custom equality comparison method.
762
- *
763
- * This can be done to create very targeted comparisons in extreme hot-path scenarios
764
- * where the standard methods are not performant enough, but can also be used to provide
765
- * support for legacy environments that do not support expected features like
766
- * `RegExp.prototype.flags` out of the box.
767
- */
768
- function createCustomEqual(options = {}) {
769
- const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false, } = options;
770
- const config = createEqualityComparatorConfig(options);
771
- const comparator = createEqualityComparator(config);
772
- const equals = createCustomInternalComparator
773
- ? createCustomInternalComparator(comparator)
774
- : createInternalEqualityComparator(comparator);
775
- return createIsEqual({ circular, comparator, createState, equals, strict });
776
- }
777
-
778
203
  const createStoreImpl = (createState) => {
779
204
  let state;
780
205
  const listeners = /* @__PURE__ */ new Set();
@@ -830,7 +255,7 @@ function withCondition(conditions, field, condition) {
830
255
  if (deepEqual(conditions[index], condition)) return conditions;
831
256
  return conditions.map((c, i) => i === index ? condition : c);
832
257
  }
833
- const DEFAULT_TABLE_STATE = {
258
+ const DEFAULT_TABLE_ENTRY = {
834
259
  activeState: EMPTY_TABLE_STATE,
835
260
  activeViewState: null,
836
261
  activeViewId: null,
@@ -853,7 +278,7 @@ const useDataTableStore = create((set, get) => ({
853
278
  }
854
279
  const pinning = options?.pinSelectColumn ? { left: ["select"], right: [] } : { left: [], right: [] };
855
280
  tables[slug] = {
856
- ...DEFAULT_TABLE_STATE,
281
+ ...DEFAULT_TABLE_ENTRY,
857
282
  activeState: { ...EMPTY_TABLE_STATE, columnPinning: pinning },
858
283
  lastAccessed: Date.now()
859
284
  };
@@ -1049,37 +474,6 @@ const useDataTableStore = create((set, get) => ({
1049
474
  }
1050
475
  }));
1051
476
 
1052
- function filterStatics(el) {
1053
- return typeof el.type === "function" || typeof el.type === "object" ? el.type : {};
1054
- }
1055
- function filterName(el) {
1056
- const { name } = el.props;
1057
- return typeof name === "string" ? name : filterStatics(el).defaultName;
1058
- }
1059
- function filterLabel(el) {
1060
- const { label } = el.props;
1061
- return typeof label === "string" ? label : filterStatics(el).defaultLabel ?? "";
1062
- }
1063
- function bindFilters(children, binding) {
1064
- return Children.map(children, (child) => {
1065
- if (!isValidElement(child)) return child;
1066
- const el = child;
1067
- const name = filterName(el);
1068
- if (name !== void 0) {
1069
- if (binding.keepControlled && "value" in el.props) return el;
1070
- return cloneElement(el, {
1071
- value: binding.conditions.find((c) => c.field === name) ?? null,
1072
- onChange: (condition) => binding.onChange(name, condition ?? null),
1073
- ...binding.required?.has(name) ? { clearable: false } : {}
1074
- });
1075
- }
1076
- if (el.props.children != null) {
1077
- return cloneElement(el, { children: bindFilters(el.props.children, binding) });
1078
- }
1079
- return child;
1080
- });
1081
- }
1082
-
1083
477
  function getFilterProps(node) {
1084
478
  if (!isValidElement(node)) return null;
1085
479
  const el = node;
@@ -1378,8 +772,6 @@ const densityOptions = [
1378
772
  ];
1379
773
  function DataTableRowDensity({ table, className }) {
1380
774
  const meta = table.options.meta;
1381
- const density = meta.density;
1382
- const setDensity = meta.setDensity;
1383
775
  return /* @__PURE__ */ jsx(
1384
776
  DropdownMenu,
1385
777
  {
@@ -1395,9 +787,14 @@ function DataTableRowDensity({ table, className }) {
1395
787
  type: "custom",
1396
788
  id: option.value,
1397
789
  asMenuItem: true,
1398
- onClick: () => setDensity(option.value),
790
+ onClick: () => meta?.setDensity(option.value),
1399
791
  render: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 py-0.5", children: [
1400
- /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4 mt-0.5 shrink-0", density === option.value ? "opacity-100" : "opacity-0") }),
792
+ /* @__PURE__ */ jsx(
793
+ Check,
794
+ {
795
+ className: cn("h-4 w-4 mt-0.5 shrink-0", meta?.density === option.value ? "opacity-100" : "opacity-0")
796
+ }
797
+ ),
1401
798
  /* @__PURE__ */ jsxs("div", { children: [
1402
799
  /* @__PURE__ */ jsx("div", { className: "font-medium text-sm", children: option.label }),
1403
800
  /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: option.description })
@@ -1411,8 +808,12 @@ DataTableRowDensity.displayName = "DataTableRowDensity";
1411
808
 
1412
809
  const ALL_COLUMNS_ID = "all";
1413
810
  function DataTableSearch({ columns, search, onSearchChange, searchAll, className }) {
1414
- const [isExpanded, setIsExpanded] = useState(false);
811
+ const [isExpanded, setIsExpanded] = useState(() => !!search?.value);
812
+ const focusOnExpand = useRef(false);
1415
813
  const inputRef = useRef(null);
814
+ useEffect(() => {
815
+ if (search?.value) setIsExpanded(true);
816
+ }, [search?.value]);
1416
817
  const options = useMemo(() => {
1417
818
  const cols = columns.map((c) => ({ value: c.id, label: c.label }));
1418
819
  return searchAll ? [{ value: ALL_COLUMNS_ID, label: "All" }, ...cols] : cols;
@@ -1424,6 +825,9 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
1424
825
  }
1425
826
  return defaultColumnId;
1426
827
  });
828
+ useEffect(() => {
829
+ if (search?.columnId && options.some((o) => o.value === search.columnId)) setSelectedColumnId(search.columnId);
830
+ }, [search?.columnId, options]);
1427
831
  useEffect(() => {
1428
832
  if (!options.some((o) => o.value === selectedColumnId)) {
1429
833
  setSelectedColumnId(defaultColumnId);
@@ -1432,7 +836,9 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
1432
836
  const selectedLabel = options.find((o) => o.value === selectedColumnId)?.label ?? "";
1433
837
  const inputValue = search?.columnId === selectedColumnId ? search?.value ?? "" : "";
1434
838
  useEffect(() => {
1435
- if (isExpanded) inputRef.current?.focus();
839
+ if (!isExpanded || !focusOnExpand.current) return;
840
+ focusOnExpand.current = false;
841
+ inputRef.current?.focus();
1436
842
  }, [isExpanded]);
1437
843
  function handleCollapse() {
1438
844
  onSearchChange(null);
@@ -1458,7 +864,10 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
1458
864
  variant: "outline",
1459
865
  size: "sm",
1460
866
  className: cn("h-9 w-9 p-0", className),
1461
- onClick: () => setIsExpanded(true),
867
+ onClick: () => {
868
+ focusOnExpand.current = true;
869
+ setIsExpanded(true);
870
+ },
1462
871
  children: [
1463
872
  /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }),
1464
873
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Search" })
@@ -19948,9 +19357,9 @@ function DataTableSelectionBar({
19948
19357
  const plural = meta?.plural ?? "rows";
19949
19358
  if (count === 0) return null;
19950
19359
  const exportConfig = importExport ?? {
19951
- columns: table.getAllColumns().filter((column) => "accessorKey" in column.columnDef && column.getIsVisible()).map((column) => ({
19360
+ columns: table.getAllLeafColumns().filter((column) => "accessorKey" in column.columnDef && column.getIsVisible()).map((column) => ({
19952
19361
  key: column.id,
19953
- label: typeof column.columnDef.header === "string" ? column.columnDef.header : column.id
19362
+ label: typeof column.columnDef.header === "string" ? column.columnDef.header : column.columnDef.meta?.label ?? column.id
19954
19363
  })),
19955
19364
  filename: meta?.slug ?? "export"
19956
19365
  };
@@ -20024,7 +19433,7 @@ function SortableColumnItem({ column }) {
20024
19433
  const isPinned = column.getIsPinned();
20025
19434
  const isVisible = column.getIsVisible();
20026
19435
  const header = column.columnDef.header;
20027
- const label = typeof header === "string" ? header : column.id;
19436
+ const label = typeof header === "string" ? header : column.columnDef.meta?.label ?? column.id;
20028
19437
  return /* @__PURE__ */ jsx(SortableItem, { id: column.id, children: ({ isDragging, dragHandleProps }) => /* @__PURE__ */ jsxs(
20029
19438
  "div",
20030
19439
  {
@@ -20083,6 +19492,10 @@ function DataTableViewOptions({ table, className }) {
20083
19492
  const columns = table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide());
20084
19493
  const sortableColumns = columns.map((col) => ({ id: col.id, column: col }));
20085
19494
  const hiddenColumnCount = columns.filter((col) => !col.getIsVisible()).length;
19495
+ const resizedColumnCount = Object.keys(table.getState().columnSizing).length;
19496
+ const definedOrder = table.getAllFlatColumns().filter((column) => column.columns.length === 0).map((column) => column.id);
19497
+ const savedOrder = table.getState().columnOrder;
19498
+ const isReordered = savedOrder.length > 0 && savedOrder.some((id, index) => id !== definedOrder[index]);
20086
19499
  function handleReorder(reordered) {
20087
19500
  const currentOrder = table.getState().columnOrder.length > 0 ? table.getState().columnOrder : table.getAllLeafColumns().map((c) => c.id);
20088
19501
  const reorderedIds = reordered.map((r) => r.id);
@@ -20139,6 +19552,48 @@ function DataTableViewOptions({ table, className }) {
20139
19552
  }
20140
19553
  )
20141
19554
  ] }),
19555
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b", children: [
19556
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
19557
+ /* @__PURE__ */ jsx(MoveHorizontal, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
19558
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
19559
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Column Widths" }),
19560
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: resizedColumnCount > 0 ? `${pluralize("column", resizedColumnCount, true)} resized` : "Default widths" })
19561
+ ] })
19562
+ ] }),
19563
+ /* @__PURE__ */ jsx(
19564
+ Button,
19565
+ {
19566
+ variant: "outline",
19567
+ size: "sm",
19568
+ className: "h-7 shrink-0 px-2.5 text-xs",
19569
+ disabled: resizedColumnCount === 0 || !!meta?.lockedColumnSizing,
19570
+ disabledTip: meta?.lockedColumnSizing ? "Turn off Resize Lock to reset widths" : "No column has been resized",
19571
+ onClick: () => table.resetColumnSizing(true),
19572
+ children: "Reset"
19573
+ }
19574
+ )
19575
+ ] }),
19576
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b", children: [
19577
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
19578
+ /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
19579
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
19580
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Column Order" }),
19581
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: isReordered ? "Reordered" : "Default order" })
19582
+ ] })
19583
+ ] }),
19584
+ /* @__PURE__ */ jsx(
19585
+ Button,
19586
+ {
19587
+ variant: "outline",
19588
+ size: "sm",
19589
+ className: "h-7 shrink-0 px-2.5 text-xs",
19590
+ disabled: !isReordered,
19591
+ disabledTip: "Columns are in their default order",
19592
+ onClick: () => table.resetColumnOrder(true),
19593
+ children: "Reset"
19594
+ }
19595
+ )
19596
+ ] }),
20142
19597
  /* @__PURE__ */ jsx("div", { className: "max-h-75 overflow-y-auto py-1", children: /* @__PURE__ */ jsx(SortableList, { items: sortableColumns, onReorder: handleReorder, children: sortableColumns.map((item) => /* @__PURE__ */ jsx(SortableColumnItem, { column: item.column }, item.id)) }) })
20143
19598
  ] })
20144
19599
  }
@@ -23801,34 +23256,33 @@ function DataTableImportDialog({
23801
23256
  }
23802
23257
  DataTableImportDialog.displayName = "DataTableImportDialog";
23803
23258
 
23804
- function viewsUrl(path = "") {
23805
- return `${getConfig().views.viewsEndpoint}${path}`;
23806
- }
23807
- const silent = { showSuccessToast: false, showErrorToast: false };
23808
- function fetchViews(tableSlug) {
23809
- return axios.get(viewsUrl(), { params: { tableSlug }, ...silent }).then((r) => r.data);
23810
- }
23811
- function createView(dto) {
23812
- return axios.post(viewsUrl(), dto, silent).then((r) => r.data);
23813
- }
23814
- function updateView(id, state) {
23815
- return axios.patch(viewsUrl(`/${id}`), { state }, silent).then((r) => r.data);
23816
- }
23817
- function toggleShareView(id, isShared) {
23818
- return axios.patch(viewsUrl(`/${id}/share`), { isShared }, silent).then((r) => r.data);
23819
- }
23820
- function renameView(id, name) {
23821
- return axios.patch(viewsUrl(`/${id}/rename`), { name }, silent).then((r) => r.data);
23822
- }
23823
- function deleteView(id) {
23824
- return axios.delete(viewsUrl(`/${id}`), silent).then(() => void 0);
23825
- }
23826
- function statesUrl() {
23827
- return getConfig().views.statesEndpoint;
23828
- }
23829
- function pushTableState(tableSlug, state, activeViewId) {
23830
- return axios.post(statesUrl(), { tableSlug, state, activeViewId }, silent).then(() => void 0);
23831
- }
23259
+ const DataTableLoadFailed = ({
23260
+ plural,
23261
+ error,
23262
+ refetch
23263
+ }) => /* @__PURE__ */ jsx(
23264
+ DataTableEmpty,
23265
+ {
23266
+ icon: TriangleAlert,
23267
+ title: `Couldn't load ${plural.toLowerCase()}`,
23268
+ description: problemDetail(error) ?? "Something went wrong while loading. Try again.",
23269
+ action: refetch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => refetch(), children: "Retry" })
23270
+ }
23271
+ );
23272
+ const DataTableRefreshFailed = ({ refetch }) => /* @__PURE__ */ jsxs(
23273
+ "div",
23274
+ {
23275
+ role: "alert",
23276
+ className: "flex items-center justify-between gap-2 border-b border-destructive/20 bg-destructive/10 px-3 py-1.5 text-xs text-destructive",
23277
+ children: [
23278
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
23279
+ /* @__PURE__ */ jsx(TriangleAlert, { className: "size-3.5", "aria-hidden": true }),
23280
+ "Couldn't refresh — showing earlier results."
23281
+ ] }),
23282
+ refetch && /* @__PURE__ */ jsx(Button, { variant: "link", size: "sm", className: "h-auto p-0 text-xs text-destructive", onClick: () => refetch(), children: "Retry" })
23283
+ ]
23284
+ }
23285
+ );
23832
23286
 
23833
23287
  const VIEWS_QK$1 = (slug) => ["quantum-ui", "table-views", slug];
23834
23288
  const viewNameSchema = object({
@@ -24254,17 +23708,35 @@ function DataTableViewTabs({ slug }) {
24254
23708
  }
24255
23709
  DataTableViewTabs.displayName = "DataTableViewTabs";
24256
23710
 
23711
+ const DATA_TABLE_MODE_HEIGHTS = {
23712
+ page: "calc(100vh - 280px)",
23713
+ tab: "calc(100vh - 320px)",
23714
+ stepper: "calc(100vh - 355px)",
23715
+ stepperTab: "calc(100vh - 395px)",
23716
+ compact: "calc(100vh - 570px)"
23717
+ };
23718
+
24257
23719
  const densityClasses = {
24258
23720
  compact: "py-1 px-2 text-xs",
24259
23721
  normal: "py-2 px-3 text-sm",
24260
23722
  comfortable: "py-4 px-3 text-sm"
24261
23723
  };
24262
23724
  const NO_FILTERS = [];
24263
- const MODE_HEIGHTS = {
24264
- page: "calc(100vh - 280px)",
24265
- tab: "calc(100vh - 320px)",
24266
- compact: "calc(100vh - 570px)"
24267
- };
23725
+ function grows(column) {
23726
+ return column.getLeafColumns().some((leaf) => leaf.columnDef.meta?.grow === true);
23727
+ }
23728
+ function groupEdges(column) {
23729
+ const leaves = column.parent?.getLeafColumns().filter((leaf) => leaf.getIsVisible()) ?? [];
23730
+ if (leaves.length === 0) return { inGroup: false, isFirst: false, isLast: false };
23731
+ return { inGroup: true, isFirst: leaves[0].id === column.id, isLast: leaves[leaves.length - 1].id === column.id };
23732
+ }
23733
+ function GroupBracket({ children }) {
23734
+ return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-end gap-2 px-2", children: [
23735
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-2 min-w-1 flex-1 rounded-tl-sm border-t border-l border-primary/50" }),
23736
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate pb-0.5 text-xs leading-none font-semibold tracking-wider text-primary uppercase", children }),
23737
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-2 min-w-1 flex-1 rounded-tr-sm border-t border-r border-primary/50" })
23738
+ ] });
23739
+ }
24268
23740
  function buildNoResultsDescription(flags) {
24269
23741
  const parts = [];
24270
23742
  if (flags.hasActiveSearch) parts.push("your search");
@@ -24274,15 +23746,13 @@ function buildNoResultsDescription(flags) {
24274
23746
  return `No results match ${joined}.`;
24275
23747
  }
24276
23748
  function DataTable({
24277
- table,
23749
+ table: instance,
24278
23750
  searchConfig,
24279
23751
  selectActions,
24280
23752
  emptyStateConfig,
24281
23753
  toolbarActions,
24282
23754
  filters,
24283
23755
  contextBar,
24284
- isLoading: isLoadingProp = false,
24285
- isFetching = false,
24286
23756
  className,
24287
23757
  enableViews = true,
24288
23758
  importExport,
@@ -24291,6 +23761,7 @@ function DataTable({
24291
23761
  selectedRowId,
24292
23762
  permission
24293
23763
  }) {
23764
+ const { table, isLoading: isLoadingProp, isFetching, isSyncing, isError, error, refetch } = instance;
24294
23765
  const [filtersOpen, setFiltersOpen] = useState(false);
24295
23766
  const importDialog = useDialog();
24296
23767
  const headerScrollRef = useRef(null);
@@ -24300,6 +23771,11 @@ function DataTable({
24300
23771
  headerScrollRef.current.scrollLeft = bodyScrollRef.current.scrollLeft;
24301
23772
  }
24302
23773
  };
23774
+ const syncBodyScroll = () => {
23775
+ if (headerScrollRef.current && bodyScrollRef.current) {
23776
+ bodyScrollRef.current.scrollLeft = headerScrollRef.current.scrollLeft;
23777
+ }
23778
+ };
24303
23779
  const tableGate = usePermission(permission);
24304
23780
  const importGate = usePermission(importExport?.importPermission);
24305
23781
  const exportGate = usePermission(importExport?.exportPermission);
@@ -24309,10 +23785,18 @@ function DataTable({
24309
23785
  const contextFilters = useDataTableStore((s) => slug ? s.tables[slug]?.activeState?.filters.context : void 0);
24310
23786
  const appliedFilterCount = panelFilters?.length ?? 0;
24311
23787
  const activeViewId = useDataTableStore((s) => slug ? s.tables[slug]?.activeViewId ?? null : null);
24312
- const isLoading = isLoadingProp || !!meta?.isAwaitingDefaults;
23788
+ const hasRows = table.getRowModel().rows.length > 0;
23789
+ const isLoading = isLoadingProp || !!meta?.isAwaitingDefaults || isSyncing && !hasRows && !isError;
24313
23790
  const loadViewState = useDataTableStore((s) => s.loadViewState);
24314
23791
  const density = meta?.density ?? "normal";
24315
- const columnCount = table.getAllColumns().length;
23792
+ const columnCount = table.getVisibleLeafColumns().length;
23793
+ const columnWidths = /* @__PURE__ */ jsx("colgroup", { children: table.getVisibleLeafColumns().map((column) => /* @__PURE__ */ jsx(
23794
+ "col",
23795
+ {
23796
+ style: { width: column.id === "actions" ? 70 : grows(column) ? void 0 : column.getSize() }
23797
+ },
23798
+ column.id
23799
+ )) });
24316
23800
  const visibilityEnabled = table.options.enableHiding !== false;
24317
23801
  const showImport = !!importExport?.importEndpoint && importGate.granted;
24318
23802
  const showExport = !!importExport?.exportEndpoint && exportGate.granted;
@@ -24333,7 +23817,9 @@ function DataTable({
24333
23817
  conditions: contextFilters ?? NO_FILTERS,
24334
23818
  onChange: setContext,
24335
23819
  keepControlled: true,
24336
- required: requiredContext
23820
+ required: requiredContext,
23821
+ // After a failed first load the controls show what the table holds rather than waiting on a load that ended
23822
+ loading: !meta?.isLoaded && !isError
24337
23823
  }) : contextBar;
24338
23824
  useEffect(() => {
24339
23825
  if (selectedCount > 0) setFiltersOpen(false);
@@ -24352,6 +23838,41 @@ function DataTable({
24352
23838
  return null;
24353
23839
  }
24354
23840
  const locked = tableGate.locked;
23841
+ function renderNoRows() {
23842
+ if (locked) {
23843
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-2 text-center", children: [
23844
+ /* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
23845
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
23846
+ ] });
23847
+ }
23848
+ if (isError) {
23849
+ return /* @__PURE__ */ jsx(DataTableLoadFailed, { plural: meta?.plural ?? "rows", error, refetch });
23850
+ }
23851
+ if (isFiltered) {
23852
+ return /* @__PURE__ */ jsx(
23853
+ DataTableEmpty,
23854
+ {
23855
+ icon: emptyStateConfig?.icon,
23856
+ title: "No results found",
23857
+ description: buildNoResultsDescription({ hasActiveSearch, hasActiveFilters, hasActiveView }),
23858
+ action: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
23859
+ hasActiveSearch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setSearch?.(searchBaseline), children: "Clear Search" }),
23860
+ hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setFilters?.(filtersBaseline), children: "Clear Filters" }),
23861
+ hasActiveView && slug && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => loadViewState(slug, EMPTY_TABLE_STATE, null, true), children: "Clear View" })
23862
+ ] })
23863
+ }
23864
+ );
23865
+ }
23866
+ return /* @__PURE__ */ jsx(
23867
+ DataTableEmpty,
23868
+ {
23869
+ icon: emptyStateConfig?.icon,
23870
+ title: emptyStateConfig?.title,
23871
+ description: emptyStateConfig?.description,
23872
+ action: emptyStateConfig?.action
23873
+ }
23874
+ );
23875
+ }
24355
23876
  return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
24356
23877
  showToolbar && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
24357
23878
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
@@ -24457,210 +23978,224 @@ function DataTable({
24457
23978
  toolbarActions?.actions
24458
23979
  ] })
24459
23980
  ] }),
24460
- /* @__PURE__ */ jsxs("div", { className: "relative border rounded-lg overflow-hidden flex flex-col", style: { height: MODE_HEIGHTS[mode] }, children: [
24461
- isFetching && !isLoading && /* @__PURE__ */ jsx(
24462
- "div",
24463
- {
24464
- role: "progressbar",
24465
- "aria-label": "Loading",
24466
- className: "pointer-events-none absolute inset-x-0 top-0 z-30 h-0.5 overflow-hidden bg-primary/15",
24467
- children: /* @__PURE__ */ jsx(
24468
- motion.div,
23981
+ /* @__PURE__ */ jsxs(
23982
+ "div",
23983
+ {
23984
+ className: "relative border rounded-lg overflow-hidden flex flex-col",
23985
+ style: { height: DATA_TABLE_MODE_HEIGHTS[mode] },
23986
+ children: [
23987
+ (isFetching || isSyncing) && !isLoading && /* @__PURE__ */ jsx(
23988
+ "div",
24469
23989
  {
24470
- className: "h-full w-1/3 bg-primary",
24471
- initial: { x: "-100%" },
24472
- animate: { x: "300%" },
24473
- transition: { duration: 1.1, ease: "easeInOut", repeat: Number.POSITIVE_INFINITY }
23990
+ role: "progressbar",
23991
+ "aria-label": "Loading",
23992
+ className: "pointer-events-none absolute inset-x-0 top-0 z-30 h-0.5 overflow-hidden bg-primary/15",
23993
+ children: /* @__PURE__ */ jsx(
23994
+ motion.div,
23995
+ {
23996
+ className: "h-full w-1/3 bg-primary",
23997
+ initial: { x: "-100%" },
23998
+ animate: { x: "300%" },
23999
+ transition: { duration: 1.1, ease: "easeInOut", repeat: Number.POSITIVE_INFINITY }
24000
+ }
24001
+ )
24474
24002
  }
24475
- )
24476
- }
24477
- ),
24478
- /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: selectedCount > 0 ? /* @__PURE__ */ jsx(
24479
- motion.div,
24480
- {
24481
- className: "shrink-0 overflow-hidden",
24482
- initial: { height: 0, opacity: 0 },
24483
- animate: { height: "auto", opacity: 1 },
24484
- exit: { height: 0, opacity: 0 },
24485
- transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },
24486
- children: /* @__PURE__ */ jsx(
24487
- DataTableSelectionBar,
24003
+ ),
24004
+ isError && hasRows && !isLoading && /* @__PURE__ */ jsx(DataTableRefreshFailed, { refetch }),
24005
+ /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: selectedCount > 0 ? /* @__PURE__ */ jsx(
24006
+ motion.div,
24488
24007
  {
24489
- table,
24490
- importExport,
24491
- exportHidden: !exportGate.granted,
24492
- exportLockTip: exportGate.locked ? lockedTip(exportGate) : void 0,
24493
- children: selectActions?.(table.getFilteredSelectedRowModel().rows)
24494
- }
24495
- )
24496
- },
24497
- "selection"
24498
- ) : filters && filtersOpen ? /* @__PURE__ */ jsx(
24499
- motion.div,
24500
- {
24501
- className: "shrink-0 overflow-hidden",
24502
- initial: { height: 0, opacity: 0 },
24503
- animate: { height: "auto", opacity: 1 },
24504
- exit: { height: 0, opacity: 0 },
24505
- transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },
24506
- children: /* @__PURE__ */ jsx(DataTableFilters, { filters, table })
24507
- },
24508
- "filters"
24509
- ) : null }),
24510
- /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col flex-1 min-h-0", children: [
24511
- /* @__PURE__ */ jsx("div", { ref: headerScrollRef, className: "shrink-0 overflow-hidden", children: /* @__PURE__ */ jsx(
24512
- "table",
24513
- {
24514
- className: "w-full caption-bottom text-sm table-fixed",
24515
- style: { minWidth: table.getCenterTotalSize() },
24516
- children: /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
24517
- const isActions = header.column.id === "actions";
24518
- const headerAlignClass = isActions ? "justify-end" : "justify-center";
24519
- return /* @__PURE__ */ jsxs(
24520
- TableHead,
24008
+ className: "shrink-0 overflow-hidden",
24009
+ initial: { height: 0, opacity: 0 },
24010
+ animate: { height: "auto", opacity: 1 },
24011
+ exit: { height: 0, opacity: 0 },
24012
+ transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },
24013
+ children: /* @__PURE__ */ jsx(
24014
+ DataTableSelectionBar,
24521
24015
  {
24522
- colSpan: header.colSpan,
24523
- style: isActions ? { width: "70px" } : { width: header.getSize(), minWidth: header.getSize(), maxWidth: header.getSize() },
24524
- className: cn(
24525
- "relative group/resize",
24526
- // actions header stays pinned on horizontal scroll; z-20 keeps it above the
24527
- // regular header cells that scroll underneath it.
24528
- isActions ? "text-right sticky right-0 z-20" : "text-center"
24529
- ),
24530
- "aria-sort": header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
24531
- children: [
24532
- isActions && /* @__PURE__ */ jsx(
24533
- "div",
24534
- {
24535
- "aria-hidden": true,
24536
- className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-muted backdrop-blur-sm"
24537
- }
24538
- ),
24539
- /* @__PURE__ */ jsx("div", { className: cn(isActions ? "relative" : void 0), children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "string" ? /* @__PURE__ */ jsx("div", { className: cn("flex", headerAlignClass), children: /* @__PURE__ */ jsx(DataTableColumnHeader, { column: header.column, title: header.column.columnDef.header }) }) : flexRender(header.column.columnDef.header, header.getContext()) }),
24540
- !meta?.lockedColumnSizing && header.column.getCanResize() && /* @__PURE__ */ jsx(
24541
- "div",
24542
- {
24543
- onPointerDown: header.getResizeHandler(),
24544
- onTouchStart: header.getResizeHandler(),
24545
- className: cn(
24546
- "absolute top-0 right-0 w-1 h-full cursor-col-resize select-none touch-none z-10",
24547
- "opacity-0 group-hover/resize:opacity-100 hover:bg-primary/50",
24548
- header.column.getIsResizing() && "opacity-100 bg-primary"
24549
- )
24550
- }
24551
- )
24552
- ]
24553
- },
24554
- header.id
24555
- );
24556
- }) }, headerGroup.id)) })
24557
- }
24558
- ) }),
24559
- /* @__PURE__ */ jsxs(
24560
- "div",
24561
- {
24562
- ref: bodyScrollRef,
24563
- onScroll: syncHeaderScroll,
24564
- className: "relative flex flex-col flex-1 min-h-0 overflow-auto overscroll-auto",
24565
- children: [
24566
- !locked && (isLoading || table.getRowModel().rows.length > 0) && /* @__PURE__ */ jsx(
24567
- "table",
24568
- {
24569
- className: "w-full caption-bottom text-sm table-fixed",
24570
- style: { minWidth: table.getCenterTotalSize() },
24571
- children: /* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from(
24572
- { length: table.getState().pagination?.pageSize ?? 20 },
24573
- (_, i) => `skeleton-row-${i}`
24574
- ).map((rowKey) => /* @__PURE__ */ jsx(TableRow, { children: Array.from({ length: columnCount }, (_, i) => `${rowKey}-cell-${i}`).map((cellKey) => /* @__PURE__ */ jsx(TableCell, { className: densityClasses[density], children: /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }) }, cellKey)) }, rowKey)) : table.getRowModel().rows.map((row, index) => {
24575
- const externallySelected = selectedRowId != null && row.id === selectedRowId;
24576
- const isSelected = row.getIsSelected() || externallySelected;
24577
- return /* @__PURE__ */ jsx(
24578
- TableRow,
24579
- {
24580
- "data-state": isSelected ? "selected" : void 0,
24581
- className: "group animate-in fade-in duration-300",
24582
- style: { animationDelay: `${Math.min(index, 12) * 25}ms`, animationFillMode: "both" },
24583
- children: row.getVisibleCells().map((cell) => {
24584
- const isActionsCell = cell.column.id === "actions";
24585
- return /* @__PURE__ */ jsxs(
24586
- TableCell,
24587
- {
24588
- className: cn(
24589
- densityClasses[density],
24590
- isActionsCell ? "px-2 sticky right-0 z-10" : void 0,
24591
- onRowClick && !isActionsCell ? "cursor-pointer" : void 0
24016
+ table,
24017
+ importExport,
24018
+ exportHidden: !exportGate.granted,
24019
+ exportLockTip: exportGate.locked ? lockedTip(exportGate) : void 0,
24020
+ children: selectActions?.(table.getFilteredSelectedRowModel().rows)
24021
+ }
24022
+ )
24023
+ },
24024
+ "selection"
24025
+ ) : filters && filtersOpen ? /* @__PURE__ */ jsx(
24026
+ motion.div,
24027
+ {
24028
+ className: "shrink-0 overflow-hidden",
24029
+ initial: { height: 0, opacity: 0 },
24030
+ animate: { height: "auto", opacity: 1 },
24031
+ exit: { height: 0, opacity: 0 },
24032
+ transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },
24033
+ children: /* @__PURE__ */ jsx(DataTableFilters, { filters, table })
24034
+ },
24035
+ "filters"
24036
+ ) : null }),
24037
+ /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col flex-1 min-h-0", children: [
24038
+ /* @__PURE__ */ jsx("div", { ref: headerScrollRef, onScroll: syncBodyScroll, className: "shrink-0 overflow-hidden", children: /* @__PURE__ */ jsxs(
24039
+ "table",
24040
+ {
24041
+ className: "w-full caption-bottom text-sm table-fixed",
24042
+ style: { minWidth: table.getCenterTotalSize() },
24043
+ children: [
24044
+ columnWidths,
24045
+ /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup, rowIndex, headerGroups) => /* @__PURE__ */ jsx(
24046
+ TableRow,
24047
+ {
24048
+ className: cn(rowIndex < headerGroups.length - 1 && "border-b-0!"),
24049
+ children: headerGroup.headers.map((header) => {
24050
+ const isActions = header.column.id === "actions";
24051
+ const headerAlignClass = isActions ? "justify-end" : "justify-center";
24052
+ const isGroup = header.subHeaders.length > 0 && !header.isPlaceholder;
24053
+ const isGroupRow = rowIndex < headerGroups.length - 1;
24054
+ const edges = groupEdges(header.column);
24055
+ return /* @__PURE__ */ jsxs(
24056
+ TableHead,
24057
+ {
24058
+ colSpan: header.colSpan,
24059
+ style: isActions ? { width: "70px" } : grows(header.column) ? { minWidth: header.getSize() } : { width: header.getSize(), minWidth: header.getSize(), maxWidth: header.getSize() },
24060
+ className: cn(
24061
+ "relative group/resize",
24062
+ // actions header stays pinned on horizontal scroll; z-20 keeps it above the
24063
+ // regular header cells that scroll underneath it.
24064
+ isActions ? "text-right sticky right-0 z-20" : "text-center",
24065
+ // grouped, the two rows together take one ungrouped header row's height
24066
+ isGroupRow && "h-5 px-0 align-bottom",
24067
+ !isGroupRow && headerGroups.length > 1 && "h-7",
24068
+ // a group and the column headers under it share one tint, edged where the group starts and ends
24069
+ (isGroup || edges.inGroup) && "bg-primary/5",
24070
+ isGroup && "border-x border-border",
24071
+ edges.isFirst && "border-l border-border",
24072
+ edges.isLast && "border-r border-border"
24073
+ ),
24074
+ "aria-sort": header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
24075
+ children: [
24076
+ isActions && /* @__PURE__ */ jsx(
24077
+ "div",
24078
+ {
24079
+ "aria-hidden": true,
24080
+ className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-muted backdrop-blur-sm"
24081
+ }
24592
24082
  ),
24593
- onClick: onRowClick && !isActionsCell ? () => onRowClick(row.original) : void 0,
24594
- style: isActionsCell ? { width: "70px" } : {
24595
- width: cell.column.getSize(),
24596
- minWidth: cell.column.getSize(),
24597
- maxWidth: cell.column.getSize()
24598
- },
24599
- children: [
24600
- isActionsCell && /* @__PURE__ */ jsx(
24601
- "div",
24602
- {
24603
- "aria-hidden": true,
24604
- className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-background/40 backdrop-blur-sm group-hover:bg-muted/30 group-data-[state=selected]:bg-muted/40"
24605
- }
24606
- ),
24607
- /* @__PURE__ */ jsx(
24608
- "div",
24083
+ /* @__PURE__ */ jsx(
24084
+ "div",
24085
+ {
24086
+ className: cn(
24087
+ isActions ? "relative" : void 0,
24088
+ // an ungrouped column's title rises by half the group row so it centres across both rows
24089
+ !isGroupRow && headerGroups.length > 1 && !edges.inGroup && "-translate-y-2.5"
24090
+ ),
24091
+ children: header.isPlaceholder ? null : isGroup ? /* @__PURE__ */ jsx(GroupBracket, { children: typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : flexRender(header.column.columnDef.header, header.getContext()) }) : typeof header.column.columnDef.header === "string" ? /* @__PURE__ */ jsx("div", { className: cn("flex min-w-0", headerAlignClass), children: /* @__PURE__ */ jsx(DataTableColumnHeader, { column: header.column, title: header.column.columnDef.header }) }) : flexRender(header.column.columnDef.header, header.getContext())
24092
+ }
24093
+ ),
24094
+ !meta?.lockedColumnSizing && header.column.getCanResize() && /* @__PURE__ */ jsx(
24095
+ "div",
24096
+ {
24097
+ onPointerDown: header.getResizeHandler(),
24098
+ onTouchStart: header.getResizeHandler(),
24099
+ className: cn(
24100
+ "absolute top-0 right-0 w-1 h-full cursor-col-resize select-none touch-none z-10",
24101
+ "opacity-0 group-hover/resize:opacity-100 hover:bg-primary/50",
24102
+ header.column.getIsResizing() && "opacity-100 bg-primary"
24103
+ )
24104
+ }
24105
+ )
24106
+ ]
24107
+ },
24108
+ header.id
24109
+ );
24110
+ })
24111
+ },
24112
+ headerGroup.id
24113
+ )) })
24114
+ ]
24115
+ }
24116
+ ) }),
24117
+ /* @__PURE__ */ jsxs(
24118
+ "div",
24119
+ {
24120
+ ref: bodyScrollRef,
24121
+ onScroll: syncHeaderScroll,
24122
+ className: "relative flex flex-col flex-1 min-h-0 overflow-auto overscroll-auto",
24123
+ children: [
24124
+ !locked && (isLoading || hasRows) && /* @__PURE__ */ jsxs(
24125
+ "table",
24126
+ {
24127
+ className: "w-full caption-bottom text-sm table-fixed",
24128
+ style: { minWidth: table.getCenterTotalSize() },
24129
+ children: [
24130
+ columnWidths,
24131
+ /* @__PURE__ */ jsx(TableBody, { className: cn("transition-opacity", isSyncing && !isLoading && "opacity-60"), children: isLoading ? Array.from(
24132
+ { length: table.getState().pagination?.pageSize ?? 20 },
24133
+ (_, i) => `skeleton-row-${i}`
24134
+ ).map((rowKey) => /* @__PURE__ */ jsx(TableRow, { children: Array.from({ length: columnCount }, (_, i) => `${rowKey}-cell-${i}`).map((cellKey) => /* @__PURE__ */ jsx(TableCell, { className: densityClasses[density], children: /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-full" }) }, cellKey)) }, rowKey)) : table.getRowModel().rows.map((row, index) => {
24135
+ const externallySelected = selectedRowId != null && row.id === selectedRowId;
24136
+ const isSelected = row.getIsSelected() || externallySelected;
24137
+ return /* @__PURE__ */ jsx(
24138
+ TableRow,
24139
+ {
24140
+ "data-state": isSelected ? "selected" : void 0,
24141
+ className: "group animate-in fade-in duration-300",
24142
+ style: { animationDelay: `${Math.min(index, 12) * 25}ms`, animationFillMode: "both" },
24143
+ children: row.getVisibleCells().map((cell) => {
24144
+ const isActionsCell = cell.column.id === "actions";
24145
+ const edges = groupEdges(cell.column);
24146
+ return /* @__PURE__ */ jsxs(
24147
+ TableCell,
24609
24148
  {
24610
24149
  className: cn(
24611
- isActionsCell ? "relative flex items-center justify-end" : "overflow-hidden text-center"
24150
+ densityClasses[density],
24151
+ edges.isFirst && "border-l border-border/60",
24152
+ edges.isLast && "border-r border-border/60",
24153
+ isActionsCell ? "px-2 sticky right-0 z-10" : void 0,
24154
+ onRowClick && !isActionsCell ? "cursor-pointer" : void 0
24612
24155
  ),
24613
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
24614
- }
24615
- )
24616
- ]
24156
+ onClick: onRowClick && !isActionsCell ? () => onRowClick(row.original) : void 0,
24157
+ style: isActionsCell ? { width: "70px" } : grows(cell.column) ? { minWidth: cell.column.getSize() } : {
24158
+ width: cell.column.getSize(),
24159
+ minWidth: cell.column.getSize(),
24160
+ maxWidth: cell.column.getSize()
24161
+ },
24162
+ children: [
24163
+ isActionsCell && /* @__PURE__ */ jsx(
24164
+ "div",
24165
+ {
24166
+ "aria-hidden": true,
24167
+ className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-background/40 backdrop-blur-sm group-hover:bg-muted/30 group-data-[state=selected]:bg-muted/40"
24168
+ }
24169
+ ),
24170
+ /* @__PURE__ */ jsx(
24171
+ "div",
24172
+ {
24173
+ className: cn(
24174
+ isActionsCell ? "relative flex items-center justify-end" : "overflow-hidden text-center"
24175
+ ),
24176
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
24177
+ }
24178
+ )
24179
+ ]
24180
+ },
24181
+ cell.id
24182
+ );
24183
+ })
24617
24184
  },
24618
- cell.id
24185
+ row.id
24619
24186
  );
24620
- })
24621
- },
24622
- row.id
24623
- );
24624
- }) })
24625
- }
24626
- ),
24627
- (locked || !isLoading && table.getRowModel().rows.length === 0) && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: locked ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-2 text-center", children: [
24628
- /* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
24629
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
24630
- ] }) : isFiltered ? /* @__PURE__ */ jsx(
24631
- DataTableEmpty,
24632
- {
24633
- icon: emptyStateConfig?.icon,
24634
- title: "No results found",
24635
- description: buildNoResultsDescription({ hasActiveSearch, hasActiveFilters, hasActiveView }),
24636
- action: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
24637
- hasActiveSearch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setSearch?.(searchBaseline), children: "Clear Search" }),
24638
- hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setFilters?.(filtersBaseline), children: "Clear Filters" }),
24639
- hasActiveView && slug && /* @__PURE__ */ jsx(
24640
- Button,
24641
- {
24642
- variant: "outline",
24643
- size: "sm",
24644
- onClick: () => loadViewState(slug, EMPTY_TABLE_STATE, null, true),
24645
- children: "Clear View"
24646
- }
24647
- )
24648
- ] })
24649
- }
24650
- ) : /* @__PURE__ */ jsx(
24651
- DataTableEmpty,
24652
- {
24653
- icon: emptyStateConfig?.icon,
24654
- title: emptyStateConfig?.title,
24655
- description: emptyStateConfig?.description,
24656
- action: emptyStateConfig?.action
24657
- }
24658
- ) })
24659
- ]
24660
- }
24661
- )
24662
- ] })
24663
- ] }),
24187
+ }) })
24188
+ ]
24189
+ }
24190
+ ),
24191
+ (locked || !isLoading && !hasRows) && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: renderNoRows() })
24192
+ ]
24193
+ }
24194
+ )
24195
+ ] })
24196
+ ]
24197
+ }
24198
+ ),
24664
24199
  (mode !== "compact" || table.getRowCount() > (table.getState().pagination?.pageSize ?? 20)) && /* @__PURE__ */ jsx(DataTablePagination, { table }),
24665
24200
  importExport?.importEndpoint && showImport && /* @__PURE__ */ jsx(
24666
24201
  DataTableImportDialog,
@@ -24677,6 +24212,38 @@ function DataTable({
24677
24212
  }
24678
24213
  DataTable.displayName = "DataTable";
24679
24214
 
24215
+ const DataTableSkeleton = ({
24216
+ mode = "page",
24217
+ columns = 4,
24218
+ rows = 6,
24219
+ toolbarAction = true,
24220
+ className
24221
+ }) => /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
24222
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2", children: [
24223
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
24224
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
24225
+ /* @__PURE__ */ jsx(Skeleton, { className: "size-8" }),
24226
+ toolbarAction && /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-28" })
24227
+ ] }),
24228
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden rounded-lg border", style: { height: DATA_TABLE_MODE_HEIGHTS[mode] }, children: [
24229
+ /* @__PURE__ */ jsx("div", { className: "flex gap-6 border-b bg-muted/40 px-4 py-3.5", children: Array.from({ length: columns }).map((_, columnIndex) => (
24230
+ // biome-ignore lint/suspicious/noArrayIndexKey: <static skeleton list>
24231
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" }, `dt-skel-th-${columnIndex}`)
24232
+ )) }),
24233
+ Array.from({ length: rows }).map((_, rowIndex) => (
24234
+ // biome-ignore lint/suspicious/noArrayIndexKey: <static skeleton list>
24235
+ /* @__PURE__ */ jsx("div", { className: "flex gap-6 border-b px-4 py-4", children: Array.from({ length: columns }).map((_2, columnIndex) => (
24236
+ // biome-ignore lint/suspicious/noArrayIndexKey: <static skeleton list>
24237
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" }, `dt-skel-td-${rowIndex}-${columnIndex}`)
24238
+ )) }, `dt-skel-tr-${rowIndex}`)
24239
+ ))
24240
+ ] }),
24241
+ mode !== "compact" && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-1", children: [
24242
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-40" }),
24243
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-64" })
24244
+ ] })
24245
+ ] });
24246
+
24680
24247
  function useTableSlice(slug) {
24681
24248
  const activeState = useDataTableStore((s) => s.tables[slug]?.activeState ?? EMPTY_TABLE_STATE);
24682
24249
  const activeViewId = useDataTableStore((s) => s.tables[slug]?.activeViewId ?? null);
@@ -24746,38 +24313,83 @@ function useTableSlice(slug) {
24746
24313
  };
24747
24314
  }
24748
24315
 
24316
+ const SAVE_DELAY_MS = 150;
24317
+ async function saveTableState(slug, onStatePush) {
24318
+ const table = useDataTableStore.getState().tables[slug];
24319
+ if (!table) return;
24320
+ const saved = await putTableState(slug, table.activeState, table.activeViewId).then(
24321
+ () => true,
24322
+ () => false
24323
+ );
24324
+ if (saved) await onStatePush?.();
24325
+ else toast.error("Couldn't apply the change", { description: "The table still shows the earlier results." });
24326
+ }
24749
24327
  function useAutoUpsert(slug, isReady, onStatePush) {
24750
24328
  const onStatePushRef = useRef(onStatePush);
24751
24329
  onStatePushRef.current = onStatePush;
24752
24330
  const saveRequest = useDataTableStore((s) => s.tables[slug]?.saveRequest ?? 0);
24753
- const handledRef = useRef({ slug, saveRequest });
24331
+ const lastSeen = useRef({ slug, saveRequest });
24332
+ const [inFlight, setInFlight] = useState(null);
24754
24333
  useEffect(() => {
24755
- const handled = handledRef.current;
24756
- handledRef.current = { slug, saveRequest };
24757
- if (!isReady || handled.slug !== slug || handled.saveRequest === saveRequest) return;
24758
- const timer = setTimeout(() => {
24759
- const table = useDataTableStore.getState().tables[slug];
24760
- if (!table) return;
24761
- pushTableState(slug, table.activeState, table.activeViewId).then(() => onStatePushRef.current?.());
24762
- }, 150);
24763
- return () => clearTimeout(timer);
24334
+ const seen = lastSeen.current;
24335
+ lastSeen.current = { slug, saveRequest };
24336
+ const isNewChange = seen.slug === slug && seen.saveRequest !== saveRequest;
24337
+ if (!isReady || !isNewChange) return;
24338
+ const request = { slug, saveRequest };
24339
+ const finish = () => setInFlight(
24340
+ (current) => current?.slug === request.slug && current.saveRequest === request.saveRequest ? null : current
24341
+ );
24342
+ setInFlight(request);
24343
+ let started = false;
24344
+ const timer = setTimeout(async () => {
24345
+ started = true;
24346
+ await saveTableState(slug, onStatePushRef.current);
24347
+ finish();
24348
+ }, SAVE_DELAY_MS);
24349
+ return () => {
24350
+ clearTimeout(timer);
24351
+ if (!started) finish();
24352
+ };
24764
24353
  }, [slug, saveRequest, isReady]);
24354
+ return inFlight?.slug === slug;
24765
24355
  }
24766
24356
 
24767
24357
  const NO_CONDITIONS = [];
24358
+ const NO_FIELDS = [];
24359
+ function leafColumnIds(columns) {
24360
+ return columns.flatMap((column) => {
24361
+ if ("columns" in column && column.columns) return leafColumnIds(column.columns);
24362
+ if (column.id) return [column.id];
24363
+ if ("accessorKey" in column && typeof column.accessorKey === "string")
24364
+ return [column.accessorKey.replace(/\./g, "_")];
24365
+ return typeof column.header === "string" ? [column.header] : [];
24366
+ });
24367
+ }
24368
+ function withDefinedColumns(savedOrder, definedIds) {
24369
+ if (savedOrder.length === 0) return savedOrder;
24370
+ const order = savedOrder.filter((id) => definedIds.includes(id));
24371
+ definedIds.forEach((id, index) => {
24372
+ if (order.includes(id)) return;
24373
+ const previous = definedIds.slice(0, index).reverse().find((defined) => order.includes(defined));
24374
+ order.splice(previous ? order.indexOf(previous) + 1 : 0, 0, id);
24375
+ });
24376
+ return order;
24377
+ }
24768
24378
  function useDataTable({
24769
24379
  columns,
24770
24380
  slug,
24771
24381
  label,
24772
- serverState,
24382
+ query,
24773
24383
  enableMultiSort = true,
24774
24384
  enableRowSelection = true,
24775
24385
  enableHiding = true,
24776
24386
  enableSorting = true,
24777
24387
  enableColumnResizing = true,
24778
24388
  onStatePush,
24779
- defaultContext
24389
+ defaultContext,
24390
+ resetOnOpen = NO_FIELDS
24780
24391
  }) {
24392
+ const serverState = query?.data;
24781
24393
  const {
24782
24394
  // State
24783
24395
  activeState,
@@ -24814,14 +24426,36 @@ function useDataTable({
24814
24426
  }, [serverState?.state, serverState?.activeViewId, slug, loadedSlug]);
24815
24427
  const isReady = loadedSlug === slug || serverState != null && serverState.state == null;
24816
24428
  const context = activeState.filters.context;
24429
+ const openedSlug = useRef(null);
24817
24430
  useLayoutEffect(() => {
24818
24431
  if (loadedSlug !== slug) return;
24819
- for (const condition of defaults) {
24820
- if (!context.some((c) => c.field === condition.field)) setContext(condition.field, condition);
24821
- }
24822
- }, [loadedSlug, slug, defaults, context, setContext]);
24823
- const isAwaitingDefaults = serverState?.state != null && defaults.some((d) => !serverState.state?.filters.context.some((c) => c.field === d.field));
24824
- const { columnVisibility, columnOrder, columnSizing, columnPinning, lockedColumnSizing } = activeState;
24432
+ const isOpening = openedSlug.current !== slug;
24433
+ openedSlug.current = slug;
24434
+ const filled = withDefaults(context, defaults, { isOpening, resetOnOpen });
24435
+ const addedOrReplaced = filled.filter((condition) => !context.includes(condition));
24436
+ for (const condition of addedOrReplaced) setContext(condition.field, condition);
24437
+ }, [loadedSlug, slug, defaults, resetOnOpen, context, setContext]);
24438
+ const contextValue = useCallback((field) => readValue(context, field), [context]);
24439
+ const echoedContext = serverState?.state?.filters.context;
24440
+ const [resetDoneSlug, setResetDoneSlug] = useState(null);
24441
+ const isAwaitingReset = resetDoneSlug !== slug && echoedContext != null && !holdsResetDefaults(echoedContext, defaults, resetOnOpen);
24442
+ useLayoutEffect(() => {
24443
+ if (echoedContext != null && !isAwaitingReset && resetDoneSlug !== slug) setResetDoneSlug(slug);
24444
+ }, [echoedContext, isAwaitingReset, resetDoneSlug, slug]);
24445
+ const setUserContext = useCallback(
24446
+ (...args) => {
24447
+ setResetDoneSlug(slug);
24448
+ setContext(...args);
24449
+ },
24450
+ [slug, setContext]
24451
+ );
24452
+ const isAwaitingDefaults = isAwaitingReset || echoedContext != null && !hasEveryDefault(echoedContext, defaults);
24453
+ const { columnVisibility, columnSizing, columnPinning, lockedColumnSizing } = activeState;
24454
+ const definedIds = useMemo(() => leafColumnIds(columns), [columns]);
24455
+ const columnOrder = useMemo(
24456
+ () => withDefinedColumns(activeState.columnOrder, definedIds),
24457
+ [activeState.columnOrder, definedIds]
24458
+ );
24825
24459
  const { filterOrder, filterVisibility, density } = activeState;
24826
24460
  const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1);
24827
24461
  const meta = useMemo(
@@ -24852,9 +24486,11 @@ function useDataTable({
24852
24486
  // Filters
24853
24487
  setFilters: (filters) => setFilters(filters),
24854
24488
  setFilter,
24855
- setContext,
24489
+ setContext: setUserContext,
24490
+ contextValue,
24856
24491
  defaultContext: defaults,
24857
24492
  isAwaitingDefaults,
24493
+ isLoaded: isReady,
24858
24494
  // Search
24859
24495
  search: activeState.search,
24860
24496
  setSearch
@@ -24873,14 +24509,16 @@ function useDataTable({
24873
24509
  updateActiveState,
24874
24510
  setFilters,
24875
24511
  setFilter,
24876
- setContext,
24512
+ setUserContext,
24513
+ contextValue,
24877
24514
  defaults,
24878
24515
  isAwaitingDefaults,
24516
+ isReady,
24879
24517
  activeState.search,
24880
24518
  setSearch
24881
24519
  ]
24882
24520
  );
24883
- useAutoUpsert(slug, isReady, onStatePush);
24521
+ const isSyncing = useAutoUpsert(slug, isReady, onStatePush);
24884
24522
  const data = serverState?.result ?? [];
24885
24523
  const totalRows = serverState?.count;
24886
24524
  const table = useReactTable({
@@ -24918,7 +24556,7 @@ function useDataTable({
24918
24556
  updateActiveState((prev) => ({ ...prev, columnPinning: newVal }));
24919
24557
  },
24920
24558
  onColumnOrderChange: (updater) => {
24921
- const current = activeState.columnOrder;
24559
+ const current = columnOrder;
24922
24560
  const newVal = typeof updater === "function" ? updater(current) : updater;
24923
24561
  updateActiveState((prev) => ({ ...prev, columnOrder: newVal }));
24924
24562
  },
@@ -24942,8 +24580,18 @@ function useDataTable({
24942
24580
  enableHiding,
24943
24581
  meta
24944
24582
  });
24945
- return { table, context, isLoaded: isReady };
24583
+ return {
24584
+ table,
24585
+ isLoading: query?.isLoading ?? false,
24586
+ isFetching: query?.isFetching ?? false,
24587
+ isSyncing,
24588
+ isError: query?.isError ?? false,
24589
+ error: query?.error,
24590
+ refetch: query?.refetch,
24591
+ contextValue,
24592
+ isLoaded: isReady
24593
+ };
24946
24594
  }
24947
24595
 
24948
- export { CompactTableSkeleton as C, DataTable as D, NumberCell as N, RowActions as R, StringCell as S, CurrencyCell as a, DataTableColumnHeader as b, DataTableEmpty as c, DataTableFilters as d, DataTablePagination as e, DataTableRowDensity as f, DataTableSearch as g, DataTableSelectionBar as h, DataTableViewOptions as i, DateCell as j, DateTimeCell as k, getSelectionColumn as l, useDataTableStore as m, useDataTable as u };
24596
+ export { CompactTableSkeleton as C, DataTable as D, NumberCell as N, RowActions as R, StringCell as S, CurrencyCell as a, DataTableColumnHeader as b, DataTableEmpty as c, DataTableFilters as d, DataTablePagination as e, DataTableRowDensity as f, DataTableSearch as g, DataTableSelectionBar as h, DataTableSkeleton as i, DataTableViewOptions as j, DateCell as k, DateTimeCell as l, getSelectionColumn as m, setTableContext as s, useDataTable as u };
24949
24597
  //# sourceMappingURL=useDataTable.js.map