@vritti/quantum-ui 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActivePoints.js +1 -1
- package/dist/ActiveShapeUtils.js +1 -1
- package/dist/Alert.js +2 -1
- package/dist/Alert.js.map +1 -1
- package/dist/AreaChart.js +48 -19
- package/dist/AreaChart.js.map +1 -1
- package/dist/BarChart.js +38 -10
- package/dist/BarChart.js.map +1 -1
- package/dist/CartesianChart.js +1 -1
- package/dist/ChartEmpty.js +8 -0
- package/dist/ChartEmpty.js.map +1 -0
- package/dist/{Chart.js → ChartFrame.js} +72 -2
- package/dist/ChartFrame.js.map +1 -0
- package/dist/CurrencyFieldFilter.js +2 -1
- package/dist/CurrencyFieldFilter.js.map +1 -1
- package/dist/DateRangePicker.js +2 -1
- package/dist/DateRangePicker.js.map +1 -1
- package/dist/IconSelect.js +1916 -1945
- package/dist/IconSelect.js.map +1 -1
- package/dist/LineChart.js +116 -107
- package/dist/LineChart.js.map +1 -1
- package/dist/PieChart.js +37 -15
- package/dist/PieChart.js.map +1 -1
- package/dist/PolarChart.js +1 -1
- package/dist/RadarChart.js +44 -17
- package/dist/RadarChart.js.map +1 -1
- package/dist/RadialChart.js +36 -11
- package/dist/RadialChart.js.map +1 -1
- package/dist/Select.js +48 -7
- package/dist/Select.js.map +1 -1
- package/dist/SelectFilter.js +80 -25
- package/dist/SelectFilter.js.map +1 -1
- package/dist/SingleSelect.js +82 -7
- package/dist/SingleSelect.js.map +1 -1
- package/dist/Sonner.js +2 -1
- package/dist/Sonner.js.map +1 -1
- package/dist/ValueFilter.js +22 -6
- package/dist/ValueFilter.js.map +1 -1
- package/dist/ViewTabs.js.map +1 -1
- package/dist/assets/quantum-ui.css +132 -17
- package/dist/bindFilters.js +37 -0
- package/dist/bindFilters.js.map +1 -0
- package/dist/components/Chart.js +125 -0
- package/dist/components/Chart.js.map +1 -0
- package/dist/components/ContextBar.js +16 -0
- package/dist/components/ContextBar.js.map +1 -0
- package/dist/components/DataTable.js +1 -1
- package/dist/components/DateFilter.js +2 -1
- package/dist/components/DateFilter.js.map +1 -1
- package/dist/conditions.js +651 -0
- package/dist/conditions.js.map +1 -0
- package/dist/contextAnchor.js +3 -2
- package/dist/contextAnchor.js.map +1 -1
- package/dist/getRadiusAndStrokeWidthFromDot.js +1 -1
- package/dist/getZIndexFromUnknown.js +1 -1
- package/dist/graphicalItemSelectors.js +1 -1
- package/dist/hooks/index.js +1 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/index7.js +2 -1
- package/dist/index7.js.map +1 -1
- package/dist/info.js +19 -0
- package/dist/info.js.map +1 -0
- package/dist/lib/components/AreaChart/AreaChart.d.ts +12 -15
- package/dist/lib/components/AreaChart/AreaChart.d.ts.map +1 -1
- package/dist/lib/components/AreaChart/index.d.ts +0 -1
- package/dist/lib/components/AreaChart/index.d.ts.map +1 -1
- package/dist/lib/components/BarChart/BarChart.d.ts +11 -14
- package/dist/lib/components/BarChart/BarChart.d.ts.map +1 -1
- package/dist/lib/components/BarChart/index.d.ts +0 -1
- package/dist/lib/components/BarChart/index.d.ts.map +1 -1
- package/dist/lib/components/Chart/ChartEmpty.d.ts +3 -0
- package/dist/lib/components/Chart/ChartEmpty.d.ts.map +1 -0
- package/dist/lib/components/Chart/ChartFrame.d.ts +16 -0
- package/dist/lib/components/Chart/ChartFrame.d.ts.map +1 -0
- package/dist/lib/components/Chart/ChartKey.d.ts +11 -0
- package/dist/lib/components/Chart/ChartKey.d.ts.map +1 -0
- package/dist/lib/components/Chart/ChartStates.d.ts +12 -0
- package/dist/lib/components/Chart/ChartStates.d.ts.map +1 -0
- package/dist/lib/components/Chart/colorSeries.d.ts +6 -0
- package/dist/lib/components/Chart/colorSeries.d.ts.map +1 -0
- package/dist/lib/components/Chart/index.d.ts +5 -0
- package/dist/lib/components/Chart/index.d.ts.map +1 -0
- package/dist/lib/components/Chart/types.d.ts +36 -0
- package/dist/lib/components/Chart/types.d.ts.map +1 -0
- package/dist/lib/components/Chart/useChart.d.ts +23 -0
- package/dist/lib/components/Chart/useChart.d.ts.map +1 -0
- package/dist/lib/components/Chart/utils.d.ts +7 -0
- package/dist/lib/components/Chart/utils.d.ts.map +1 -0
- package/dist/lib/components/ContextBar/ContextBar.d.ts +10 -0
- package/dist/lib/components/ContextBar/ContextBar.d.ts.map +1 -0
- package/dist/lib/components/ContextBar/index.d.ts +3 -0
- package/dist/lib/components/ContextBar/index.d.ts.map +1 -0
- package/dist/lib/components/ContextBar/useContextSave.d.ts +15 -0
- package/dist/lib/components/ContextBar/useContextSave.d.ts.map +1 -0
- package/dist/lib/components/ContextBar/useContextState.d.ts +22 -0
- package/dist/lib/components/ContextBar/useContextState.d.ts.map +1 -0
- package/dist/lib/components/ContextBar/useSettlingFields.d.ts +5 -0
- package/dist/lib/components/ContextBar/useSettlingFields.d.ts.map +1 -0
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts +2 -1
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts.map +1 -1
- package/dist/lib/components/DataTable/DataTable.d.ts +1 -1
- package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/lib/components/DataTable/cells/cells.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableColumnHeader.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableFilters.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableLoadStates.d.ts +9 -0
- package/dist/lib/components/DataTable/components/DataTableLoadStates.d.ts.map +1 -0
- package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableSearch.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableViewOptions.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableViewsMenu.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/bindFilters.d.ts +16 -0
- package/dist/lib/components/DataTable/components/bindFilters.d.ts.map +1 -0
- package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts +1 -2
- package/dist/lib/components/DataTable/hooks/useAutoUpsert.d.ts.map +1 -1
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +17 -7
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
- package/dist/lib/components/DataTable/index.d.ts +3 -4
- package/dist/lib/components/DataTable/index.d.ts.map +1 -1
- package/dist/lib/components/DataTable/store/store.d.ts +13 -11
- package/dist/lib/components/DataTable/store/store.d.ts.map +1 -1
- package/dist/lib/components/DataTable/store/useTableSlice.d.ts +7 -5
- package/dist/lib/components/DataTable/store/useTableSlice.d.ts.map +1 -1
- package/dist/lib/components/DataTable/types.d.ts +31 -6
- package/dist/lib/components/DataTable/types.d.ts.map +1 -1
- package/dist/lib/components/DataTable/utils.d.ts +1 -1
- package/dist/lib/components/DataTable/utils.d.ts.map +1 -1
- package/dist/lib/components/DateFilter/DateFilter.d.ts +2 -1
- package/dist/lib/components/DateFilter/DateFilter.d.ts.map +1 -1
- package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts +2 -1
- package/dist/lib/components/DateRangePicker/DateRangeFilter.d.ts.map +1 -1
- package/dist/lib/components/Editor/editor-ui/button.d.ts +1 -1
- package/dist/lib/components/LineChart/LineChart.d.ts +17 -22
- package/dist/lib/components/LineChart/LineChart.d.ts.map +1 -1
- package/dist/lib/components/LineChart/LineChartEmpty.d.ts +2 -7
- package/dist/lib/components/LineChart/LineChartEmpty.d.ts.map +1 -1
- package/dist/lib/components/LineChart/index.d.ts +1 -3
- package/dist/lib/components/LineChart/index.d.ts.map +1 -1
- package/dist/lib/components/PieChart/PieChart.d.ts +9 -8
- package/dist/lib/components/PieChart/PieChart.d.ts.map +1 -1
- package/dist/lib/components/PieChart/index.d.ts +0 -1
- package/dist/lib/components/PieChart/index.d.ts.map +1 -1
- package/dist/lib/components/RadarChart/RadarChart.d.ts +10 -13
- package/dist/lib/components/RadarChart/RadarChart.d.ts.map +1 -1
- package/dist/lib/components/RadarChart/index.d.ts +0 -1
- package/dist/lib/components/RadarChart/index.d.ts.map +1 -1
- package/dist/lib/components/RadialChart/RadialChart.d.ts +11 -8
- package/dist/lib/components/RadialChart/RadialChart.d.ts.map +1 -1
- package/dist/lib/components/RadialChart/index.d.ts +0 -1
- package/dist/lib/components/RadialChart/index.d.ts.map +1 -1
- package/dist/lib/components/Select/Select.d.ts.map +1 -1
- package/dist/lib/components/Select/SelectFilter.d.ts +10 -0
- package/dist/lib/components/Select/SelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts +1 -0
- package/dist/lib/components/Select/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts +2 -1
- package/dist/lib/components/Select/components/MultiSelect/MultiSelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts +1 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts +1 -0
- package/dist/lib/components/Select/components/SingleSelect/SingleSelectFilter.d.ts.map +1 -1
- package/dist/lib/components/Select/contextAnchor.d.ts +1 -0
- package/dist/lib/components/Select/contextAnchor.d.ts.map +1 -1
- package/dist/lib/components/Select/hooks/useSelect.d.ts +4 -0
- package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
- package/dist/lib/components/Select/types.d.ts +1 -0
- package/dist/lib/components/Select/types.d.ts.map +1 -1
- package/dist/lib/components/ValueFilter/ValueFilter.d.ts +16 -4
- package/dist/lib/components/ValueFilter/ValueFilter.d.ts.map +1 -1
- package/dist/lib/components/ViewTabs/ViewTabs.d.ts +3 -3
- package/dist/lib/components/ViewTabs/ViewTabs.d.ts.map +1 -1
- package/dist/lib/config/index.d.ts +1 -0
- package/dist/lib/config/index.d.ts.map +1 -1
- package/dist/lib/hooks/index.d.ts +1 -0
- package/dist/lib/hooks/index.d.ts.map +1 -1
- package/dist/lib/hooks/useOrgCountryCode.d.ts +2 -0
- package/dist/lib/hooks/useOrgCountryCode.d.ts.map +1 -0
- package/dist/lib/selects/icon/IconSelect.d.ts.map +1 -1
- package/dist/lib/services/context-states.service.d.ts +4 -0
- package/dist/lib/services/context-states.service.d.ts.map +1 -0
- package/dist/lib/services/table-views.service.d.ts +7 -5
- package/dist/lib/services/table-views.service.d.ts.map +1 -1
- package/dist/lib/types/api-response.d.ts +2 -2
- package/dist/lib/types/api-response.d.ts.map +1 -1
- package/dist/lib/types/{table-filter.d.ts → conditions.d.ts} +1 -23
- package/dist/lib/types/conditions.d.ts.map +1 -0
- package/dist/lib/types/table-state.d.ts +28 -0
- package/dist/lib/types/table-state.d.ts.map +1 -0
- package/dist/lib/utils/axios.d.ts +1 -0
- package/dist/lib/utils/axios.d.ts.map +1 -1
- package/dist/lib/utils/conditions.d.ts +11 -0
- package/dist/lib/utils/conditions.d.ts.map +1 -0
- package/dist/lib/utils/country.d.ts +3 -0
- package/dist/lib/utils/country.d.ts.map +1 -0
- package/dist/lib/utils/filter.d.ts +22 -0
- package/dist/lib/utils/filter.d.ts.map +1 -0
- package/dist/lib/utils/timezone.d.ts +1 -0
- package/dist/lib/utils/timezone.d.ts.map +1 -1
- package/dist/polarScaleSelectors.js +1 -1
- package/dist/shadcn/optionKeys.d.ts +4 -0
- package/dist/shadcn/optionKeys.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts +1 -1
- package/dist/shadcn/shadcnButton/Button.d.ts +2 -2
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts +1 -1
- package/dist/shadcn/shadcnMultiSelect/multi-select.d.ts.map +1 -1
- package/dist/shadcn/shadcnSingleSelect/single-select.d.ts +1 -1
- package/dist/shadcn/shadcnSingleSelect/single-select.d.ts.map +1 -1
- package/dist/table-properties.js +64 -33
- package/dist/table-properties.js.map +1 -1
- package/dist/timezone.js +4 -1
- package/dist/timezone.js.map +1 -1
- package/dist/tooltipContext.js +1 -1
- package/dist/triangle-alert.js +1 -16
- package/dist/triangle-alert.js.map +1 -1
- package/dist/types/conditions.js +2 -0
- package/dist/types/conditions.js.map +1 -0
- package/dist/types/{table-filter.js → table-state.js} +2 -2
- package/dist/types/table-state.js.map +1 -0
- package/dist/useContextState.js +201 -0
- package/dist/useContextState.js.map +1 -0
- package/dist/useDataTable.js +627 -966
- package/dist/useDataTable.js.map +1 -1
- package/dist/useWorkspaceCurrency.js +27 -2
- package/dist/useWorkspaceCurrency.js.map +1 -1
- package/dist/useWorkspaceTimeZone.js +2 -2
- package/dist/useWorkspaceTimeZone.js.map +1 -1
- package/dist/utils/axios.js +5 -1
- package/dist/utils/axios.js.map +1 -1
- package/dist/utils/country.js +20 -0
- package/dist/utils/country.js.map +1 -0
- package/dist/utils/filter.js +21 -0
- package/dist/utils/filter.js.map +1 -0
- package/dist/utils/format.js +2 -2
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/timezone.js +1 -1
- package/dist/utils2.js +6 -0
- package/dist/utils2.js.map +1 -0
- package/package.json +26 -4
- package/dist/Chart.js.map +0 -1
- package/dist/lib/components/DataTable/components/FilterWrapper.d.ts +0 -21
- package/dist/lib/components/DataTable/components/FilterWrapper.d.ts.map +0 -1
- package/dist/lib/types/table-filter.d.ts.map +0 -1
- package/dist/types/table-filter.js.map +0 -1
- package/dist/useCategoricalColors.js +0 -20
- package/dist/useCategoricalColors.js.map +0 -1
package/dist/useDataTable.js
CHANGED
|
@@ -7,24 +7,27 @@ 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,
|
|
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, {
|
|
14
|
-
import { EMPTY_TABLE_STATE } from './types/table-
|
|
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
|
-
import { u as useForm, C as Controller } from './index.esm.js';
|
|
19
20
|
import { P as Popover, a as PopoverTrigger, b as PopoverContent } from './popover.js';
|
|
20
21
|
import { G as GripVertical } from './grip-vertical.js';
|
|
21
22
|
import { a as Eye, E as EyeOff } from './eye.js';
|
|
23
|
+
import { u as useForm } from './index.esm.js';
|
|
22
24
|
import { B as Badge } from './Badge.js';
|
|
23
25
|
import { F as Form } from './Form.js';
|
|
24
26
|
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: "
|
|
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
|
|
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();
|
|
@@ -820,12 +245,22 @@ const MAX_TABLES = 20;
|
|
|
820
245
|
function viewStatesEqual(a, b) {
|
|
821
246
|
return deepEqual(a, b);
|
|
822
247
|
}
|
|
823
|
-
|
|
248
|
+
function normalizeViewState(raw) {
|
|
249
|
+
return { ...EMPTY_TABLE_STATE, ...raw };
|
|
250
|
+
}
|
|
251
|
+
function withCondition(conditions, field, condition) {
|
|
252
|
+
const index = conditions.findIndex((c) => c.field === field);
|
|
253
|
+
if (condition === null) return index === -1 ? conditions : conditions.filter((_, i) => i !== index);
|
|
254
|
+
if (index === -1) return [...conditions, condition];
|
|
255
|
+
if (deepEqual(conditions[index], condition)) return conditions;
|
|
256
|
+
return conditions.map((c, i) => i === index ? condition : c);
|
|
257
|
+
}
|
|
258
|
+
const DEFAULT_TABLE_ENTRY = {
|
|
824
259
|
activeState: EMPTY_TABLE_STATE,
|
|
825
260
|
activeViewState: null,
|
|
826
261
|
activeViewId: null,
|
|
827
262
|
lastAccessed: 0,
|
|
828
|
-
|
|
263
|
+
saveRequest: 0
|
|
829
264
|
};
|
|
830
265
|
const useDataTableStore = create((set, get) => ({
|
|
831
266
|
tables: {},
|
|
@@ -843,29 +278,30 @@ const useDataTableStore = create((set, get) => ({
|
|
|
843
278
|
}
|
|
844
279
|
const pinning = options?.pinSelectColumn ? { left: ["select"], right: [] } : { left: [], right: [] };
|
|
845
280
|
tables[slug] = {
|
|
846
|
-
...
|
|
281
|
+
...DEFAULT_TABLE_ENTRY,
|
|
847
282
|
activeState: { ...EMPTY_TABLE_STATE, columnPinning: pinning },
|
|
848
283
|
lastAccessed: Date.now()
|
|
849
284
|
};
|
|
850
285
|
return { tables };
|
|
851
286
|
});
|
|
852
287
|
},
|
|
853
|
-
// Sets activeState/viewId/viewState
|
|
854
|
-
|
|
288
|
+
// Sets activeState/viewId/viewState from a stored state. A page load (the default) only shows it; a view the user
|
|
289
|
+
// switches to is also saved as the table's live state
|
|
290
|
+
loadViewState: (slug, state, viewId, fromUser = false) => {
|
|
855
291
|
set((prev) => {
|
|
856
292
|
const currentTable = prev.tables[slug];
|
|
857
293
|
if (!currentTable) return prev;
|
|
858
|
-
const
|
|
294
|
+
const loaded = normalizeViewState(state);
|
|
859
295
|
return {
|
|
860
296
|
tables: {
|
|
861
297
|
...prev.tables,
|
|
862
298
|
[slug]: {
|
|
863
299
|
...currentTable,
|
|
864
|
-
activeState:
|
|
300
|
+
activeState: loaded,
|
|
865
301
|
activeViewId: viewId,
|
|
866
302
|
// On page-load, activeViewState is set later via setActiveViewState; on user tab activation, set it immediately
|
|
867
|
-
activeViewState:
|
|
868
|
-
|
|
303
|
+
activeViewState: fromUser && viewId !== null ? loaded : null,
|
|
304
|
+
saveRequest: fromUser ? currentTable.saveRequest + 1 : currentTable.saveRequest,
|
|
869
305
|
lastAccessed: Date.now()
|
|
870
306
|
}
|
|
871
307
|
}
|
|
@@ -884,13 +320,14 @@ const useDataTableStore = create((set, get) => ({
|
|
|
884
320
|
[slug]: {
|
|
885
321
|
...currentTable,
|
|
886
322
|
activeState: newActiveState,
|
|
323
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
887
324
|
lastAccessed: Date.now()
|
|
888
325
|
}
|
|
889
326
|
}
|
|
890
327
|
};
|
|
891
328
|
});
|
|
892
329
|
},
|
|
893
|
-
// Sets activeState.filters and returns to the first page, since the old page may be past the new result count
|
|
330
|
+
// Sets activeState.filters.panel and returns to the first page, since the old page may be past the new result count
|
|
894
331
|
setFilters: (slug, filters) => {
|
|
895
332
|
set((prev) => {
|
|
896
333
|
const currentTable = prev.tables[slug];
|
|
@@ -900,9 +337,10 @@ const useDataTableStore = create((set, get) => ({
|
|
|
900
337
|
...prev.tables,
|
|
901
338
|
[slug]: {
|
|
902
339
|
...currentTable,
|
|
340
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
903
341
|
activeState: {
|
|
904
342
|
...currentTable.activeState,
|
|
905
|
-
filters,
|
|
343
|
+
filters: { ...currentTable.activeState.filters, panel: filters },
|
|
906
344
|
pagination: { ...currentTable.activeState.pagination, offset: 0 }
|
|
907
345
|
},
|
|
908
346
|
lastAccessed: Date.now()
|
|
@@ -911,6 +349,56 @@ const useDataTableStore = create((set, get) => ({
|
|
|
911
349
|
};
|
|
912
350
|
});
|
|
913
351
|
},
|
|
352
|
+
// Replaces or removes one condition in filters.panel and returns to the first page
|
|
353
|
+
setFilter: (slug, field, condition) => {
|
|
354
|
+
set((prev) => {
|
|
355
|
+
const currentTable = prev.tables[slug];
|
|
356
|
+
if (!currentTable) return prev;
|
|
357
|
+
const { filters, pagination } = currentTable.activeState;
|
|
358
|
+
const panel = withCondition(filters.panel, field, condition);
|
|
359
|
+
if (panel === filters.panel) return prev;
|
|
360
|
+
return {
|
|
361
|
+
tables: {
|
|
362
|
+
...prev.tables,
|
|
363
|
+
[slug]: {
|
|
364
|
+
...currentTable,
|
|
365
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
366
|
+
activeState: {
|
|
367
|
+
...currentTable.activeState,
|
|
368
|
+
filters: { ...filters, panel },
|
|
369
|
+
pagination: { ...pagination, offset: 0 }
|
|
370
|
+
},
|
|
371
|
+
lastAccessed: Date.now()
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
// Replaces or removes one condition in filters.context and returns to the first page
|
|
378
|
+
setContext: (slug, field, condition) => {
|
|
379
|
+
set((prev) => {
|
|
380
|
+
const currentTable = prev.tables[slug];
|
|
381
|
+
if (!currentTable) return prev;
|
|
382
|
+
const { filters, pagination } = currentTable.activeState;
|
|
383
|
+
const context = withCondition(filters.context, field, condition);
|
|
384
|
+
if (context === filters.context) return prev;
|
|
385
|
+
return {
|
|
386
|
+
tables: {
|
|
387
|
+
...prev.tables,
|
|
388
|
+
[slug]: {
|
|
389
|
+
...currentTable,
|
|
390
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
391
|
+
activeState: {
|
|
392
|
+
...currentTable.activeState,
|
|
393
|
+
filters: { ...filters, context },
|
|
394
|
+
pagination: { ...pagination, offset: 0 }
|
|
395
|
+
},
|
|
396
|
+
lastAccessed: Date.now()
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
});
|
|
401
|
+
},
|
|
914
402
|
// Sets activeState.search and returns to the first page, since the old page may be past the new result count
|
|
915
403
|
setSearch: (slug, search) => {
|
|
916
404
|
set((prev) => {
|
|
@@ -921,6 +409,7 @@ const useDataTableStore = create((set, get) => ({
|
|
|
921
409
|
...prev.tables,
|
|
922
410
|
[slug]: {
|
|
923
411
|
...currentTable,
|
|
412
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
924
413
|
activeState: {
|
|
925
414
|
...currentTable.activeState,
|
|
926
415
|
search,
|
|
@@ -943,6 +432,7 @@ const useDataTableStore = create((set, get) => ({
|
|
|
943
432
|
[slug]: {
|
|
944
433
|
...currentTable,
|
|
945
434
|
activeState: { ...currentTable.activeState, pagination },
|
|
435
|
+
saveRequest: currentTable.saveRequest + 1,
|
|
946
436
|
lastAccessed: Date.now()
|
|
947
437
|
}
|
|
948
438
|
}
|
|
@@ -954,23 +444,18 @@ const useDataTableStore = create((set, get) => ({
|
|
|
954
444
|
set((prev) => {
|
|
955
445
|
const currentTable = prev.tables[slug];
|
|
956
446
|
if (!currentTable) return prev;
|
|
447
|
+
const state = normalizeViewState(viewState);
|
|
957
448
|
return {
|
|
958
449
|
tables: {
|
|
959
450
|
...prev.tables,
|
|
960
|
-
[slug]: {
|
|
451
|
+
[slug]: {
|
|
452
|
+
...currentTable,
|
|
453
|
+
activeViewState: state
|
|
454
|
+
}
|
|
961
455
|
}
|
|
962
456
|
};
|
|
963
457
|
});
|
|
964
458
|
},
|
|
965
|
-
// Reads _skipUpsert, clears it, and returns whether it was set — consumed once per load
|
|
966
|
-
consumeSkipUpsert: (slug) => {
|
|
967
|
-
const table = get().tables[slug];
|
|
968
|
-
if (!table?._skipUpsert) return false;
|
|
969
|
-
set((prev) => ({
|
|
970
|
-
tables: { ...prev.tables, [slug]: { ...prev.tables[slug], _skipUpsert: false } }
|
|
971
|
-
}));
|
|
972
|
-
return true;
|
|
973
|
-
},
|
|
974
459
|
// Syncs activeViewState to current activeState after a view is saved in-place
|
|
975
460
|
syncActiveViewState: (slug) => {
|
|
976
461
|
set((prev) => {
|
|
@@ -989,77 +474,12 @@ const useDataTableStore = create((set, get) => ({
|
|
|
989
474
|
}
|
|
990
475
|
}));
|
|
991
476
|
|
|
992
|
-
function normalizeFormValues(values) {
|
|
993
|
-
return Object.fromEntries(Object.entries(values).filter(([, v]) => v != null));
|
|
994
|
-
}
|
|
995
|
-
function normalizeActiveFilters(filters) {
|
|
996
|
-
return Object.fromEntries(filters.map((f) => [f.field, f]));
|
|
997
|
-
}
|
|
998
|
-
function processChildren(children, control) {
|
|
999
|
-
return Children.map(children, (child) => {
|
|
1000
|
-
if (!isValidElement(child)) return child;
|
|
1001
|
-
const el = child;
|
|
1002
|
-
const props = el.props;
|
|
1003
|
-
const defaultName = typeof el.type === "function" || typeof el.type === "object" ? el.type.defaultName : void 0;
|
|
1004
|
-
const name = typeof props.name === "string" ? props.name : defaultName;
|
|
1005
|
-
if (typeof name === "string") {
|
|
1006
|
-
return /* @__PURE__ */ jsx(
|
|
1007
|
-
Controller,
|
|
1008
|
-
{
|
|
1009
|
-
control,
|
|
1010
|
-
name,
|
|
1011
|
-
render: ({ field }) => cloneElement(el, { ...props, fieldKey: name, value: field.value, onChange: field.onChange })
|
|
1012
|
-
},
|
|
1013
|
-
name
|
|
1014
|
-
);
|
|
1015
|
-
}
|
|
1016
|
-
if (props.children != null) {
|
|
1017
|
-
return cloneElement(el, {
|
|
1018
|
-
...props,
|
|
1019
|
-
children: processChildren(props.children, control)
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
return child;
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
function FilterWrapper({
|
|
1026
|
-
onSubmit,
|
|
1027
|
-
onReset,
|
|
1028
|
-
defaultValues,
|
|
1029
|
-
activeFilters,
|
|
1030
|
-
resetValues,
|
|
1031
|
-
renderActions,
|
|
1032
|
-
children,
|
|
1033
|
-
...props
|
|
1034
|
-
}) {
|
|
1035
|
-
const form = useForm({ defaultValues: defaultValues ?? {} });
|
|
1036
|
-
const isSubmitting = form.formState.isSubmitting;
|
|
1037
|
-
const formValues = form.watch();
|
|
1038
|
-
const isPending = !deepEqual(normalizeFormValues(formValues), normalizeActiveFilters(activeFilters ?? []));
|
|
1039
|
-
const onResetRef = useRef(onReset);
|
|
1040
|
-
onResetRef.current = onReset;
|
|
1041
|
-
function handleReset() {
|
|
1042
|
-
form.reset(resetValues ?? {});
|
|
1043
|
-
onResetRef.current?.();
|
|
1044
|
-
}
|
|
1045
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
1046
|
-
await onSubmit(data);
|
|
1047
|
-
});
|
|
1048
|
-
return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, onReset: handleReset, ...props, children: [
|
|
1049
|
-
processChildren(children, form.control),
|
|
1050
|
-
renderActions?.({ isPending, isSubmitting })
|
|
1051
|
-
] });
|
|
1052
|
-
}
|
|
1053
|
-
FilterWrapper.displayName = "FilterWrapper";
|
|
1054
|
-
|
|
1055
477
|
function getFilterProps(node) {
|
|
1056
478
|
if (!isValidElement(node)) return null;
|
|
1057
|
-
const
|
|
1058
|
-
const
|
|
1059
|
-
const id = typeof props.name === "string" ? props.name : meta.defaultName ?? null;
|
|
1060
|
-
const label = typeof props.label === "string" ? props.label : meta.defaultLabel ?? "";
|
|
479
|
+
const el = node;
|
|
480
|
+
const id = filterName(el);
|
|
1061
481
|
if (!id) return null;
|
|
1062
|
-
return { id, label };
|
|
482
|
+
return { id, label: filterLabel(el) };
|
|
1063
483
|
}
|
|
1064
484
|
function SortableFilterItem({
|
|
1065
485
|
filter,
|
|
@@ -1101,27 +521,13 @@ function SortableFilterItem({
|
|
|
1101
521
|
}
|
|
1102
522
|
) });
|
|
1103
523
|
}
|
|
1104
|
-
const NO_FILTERS = [];
|
|
524
|
+
const NO_FILTERS$1 = [];
|
|
1105
525
|
function DataTableFilters({ filters, table }) {
|
|
1106
526
|
const metaRaw = table.options.meta;
|
|
1107
527
|
const slug = metaRaw?.slug ?? "";
|
|
1108
|
-
const activeFilters = useDataTableStore((s) => s.tables[slug]?.activeState?.filters ?? NO_FILTERS);
|
|
528
|
+
const activeFilters = useDataTableStore((s) => s.tables[slug]?.activeState?.filters.panel ?? NO_FILTERS$1);
|
|
1109
529
|
const activeViewId = useDataTableStore((s) => s.tables[slug]?.activeViewId ?? null);
|
|
1110
|
-
const activeViewStateFilters = useDataTableStore((s) => s.tables[slug]?.activeViewState?.filters ?? NO_FILTERS);
|
|
1111
|
-
const defaultValues = useMemo(
|
|
1112
|
-
() => activeFilters.reduce((acc, f) => {
|
|
1113
|
-
acc[f.field] = f;
|
|
1114
|
-
return acc;
|
|
1115
|
-
}, {}),
|
|
1116
|
-
[activeFilters]
|
|
1117
|
-
);
|
|
1118
|
-
const resetValues = useMemo(
|
|
1119
|
-
() => activeViewId !== null ? activeViewStateFilters.reduce((acc, f) => {
|
|
1120
|
-
acc[f.field] = f;
|
|
1121
|
-
return acc;
|
|
1122
|
-
}, {}) : {},
|
|
1123
|
-
[activeViewId, activeViewStateFilters]
|
|
1124
|
-
);
|
|
530
|
+
const activeViewStateFilters = useDataTableStore((s) => s.tables[slug]?.activeViewState?.filters.panel ?? NO_FILTERS$1);
|
|
1125
531
|
const filterEntries = useMemo(() => {
|
|
1126
532
|
const entries = [];
|
|
1127
533
|
for (const node of filters) {
|
|
@@ -1145,38 +551,22 @@ function DataTableFilters({ filters, table }) {
|
|
|
1145
551
|
function handleReorder(reordered) {
|
|
1146
552
|
meta.setFilterOrder(reordered.map((r) => r.id));
|
|
1147
553
|
}
|
|
1148
|
-
|
|
1149
|
-
const applied = Object.values(data).filter((c) => c != null);
|
|
1150
|
-
meta.setFilters(applied);
|
|
1151
|
-
}
|
|
554
|
+
const resetFilters = activeViewId !== null ? activeViewStateFilters : NO_FILTERS$1;
|
|
1152
555
|
function handleReset() {
|
|
1153
|
-
meta.setFilters(
|
|
556
|
+
meta.setFilters(resetFilters);
|
|
1154
557
|
}
|
|
1155
558
|
const toFilterMap = (filters2) => Object.fromEntries(filters2.map((f) => [f.field, f]));
|
|
1156
|
-
const hasResetChanges =
|
|
559
|
+
const hasResetChanges = !deepEqual(toFilterMap(activeFilters), toFilterMap(resetFilters));
|
|
1157
560
|
const hiddenFilterCount = filterEntries.filter((f) => meta.filterVisibility[f.id] === false).length;
|
|
1158
561
|
const sortableItems = effectiveOrder.map((s) => {
|
|
1159
562
|
const filter = filterMap.get(s);
|
|
1160
563
|
return filter ? { id: s, label: filter.label } : null;
|
|
1161
564
|
}).filter((item) => item !== null);
|
|
1162
565
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-4 py-3 border-b flex-wrap", children: [
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
|
|
1165
|
-
{
|
|
1166
|
-
|
|
1167
|
-
activeFilters,
|
|
1168
|
-
resetValues,
|
|
1169
|
-
onSubmit: handleApply,
|
|
1170
|
-
onReset: handleReset,
|
|
1171
|
-
className: "flex items-center gap-2 flex-1 flex-wrap",
|
|
1172
|
-
renderActions: ({ isPending, isSubmitting }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 ml-auto", children: [
|
|
1173
|
-
hasResetChanges && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", type: "reset", children: "Reset" }),
|
|
1174
|
-
isPending && /* @__PURE__ */ jsx(Button, { size: "sm", type: "submit", isLoading: isSubmitting, children: "Apply" })
|
|
1175
|
-
] }),
|
|
1176
|
-
children: visibleFilters.map((f) => /* @__PURE__ */ jsx("span", { children: f.node }, f.id))
|
|
1177
|
-
},
|
|
1178
|
-
activeViewId + JSON.stringify(defaultValues)
|
|
1179
|
-
),
|
|
566
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1 flex-wrap", children: [
|
|
567
|
+
visibleFilters.map((f) => /* @__PURE__ */ jsx("span", { children: bindFilters(f.node, { conditions: activeFilters, onChange: meta.setFilter }) }, f.id)),
|
|
568
|
+
hasResetChanges && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 ml-auto", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: handleReset, children: "Reset" }) })
|
|
569
|
+
] }),
|
|
1180
570
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1181
571
|
/* @__PURE__ */ jsxs(Popover, { children: [
|
|
1182
572
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
@@ -1191,12 +581,12 @@ function DataTableFilters({ filters, table }) {
|
|
|
1191
581
|
]
|
|
1192
582
|
}
|
|
1193
583
|
) }),
|
|
1194
|
-
/* @__PURE__ */ jsxs(PopoverContent, { align: "end", className: "w-
|
|
584
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "end", className: "w-60 p-0", children: [
|
|
1195
585
|
/* @__PURE__ */ jsxs("div", { className: "px-3 py-3 border-b", children: [
|
|
1196
586
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Filter Settings" }),
|
|
1197
587
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Drag to reorder or hide filters" })
|
|
1198
588
|
] }),
|
|
1199
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-
|
|
589
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-75 overflow-y-auto py-1", children: /* @__PURE__ */ jsx(SortableList, { items: sortableItems, onReorder: handleReorder, children: sortableItems.map(({ id, label }) => /* @__PURE__ */ jsx(
|
|
1200
590
|
SortableFilterItem,
|
|
1201
591
|
{
|
|
1202
592
|
filter: { id, label },
|
|
@@ -1382,8 +772,6 @@ const densityOptions = [
|
|
|
1382
772
|
];
|
|
1383
773
|
function DataTableRowDensity({ table, className }) {
|
|
1384
774
|
const meta = table.options.meta;
|
|
1385
|
-
const density = meta.density;
|
|
1386
|
-
const setDensity = meta.setDensity;
|
|
1387
775
|
return /* @__PURE__ */ jsx(
|
|
1388
776
|
DropdownMenu,
|
|
1389
777
|
{
|
|
@@ -1399,9 +787,14 @@ function DataTableRowDensity({ table, className }) {
|
|
|
1399
787
|
type: "custom",
|
|
1400
788
|
id: option.value,
|
|
1401
789
|
asMenuItem: true,
|
|
1402
|
-
onClick: () => setDensity(option.value),
|
|
790
|
+
onClick: () => meta?.setDensity(option.value),
|
|
1403
791
|
render: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 py-0.5", children: [
|
|
1404
|
-
/* @__PURE__ */ jsx(
|
|
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
|
+
),
|
|
1405
798
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1406
799
|
/* @__PURE__ */ jsx("div", { className: "font-medium text-sm", children: option.label }),
|
|
1407
800
|
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: option.description })
|
|
@@ -1415,8 +808,12 @@ DataTableRowDensity.displayName = "DataTableRowDensity";
|
|
|
1415
808
|
|
|
1416
809
|
const ALL_COLUMNS_ID = "all";
|
|
1417
810
|
function DataTableSearch({ columns, search, onSearchChange, searchAll, className }) {
|
|
1418
|
-
const [isExpanded, setIsExpanded] = useState(
|
|
811
|
+
const [isExpanded, setIsExpanded] = useState(() => !!search?.value);
|
|
812
|
+
const focusOnExpand = useRef(false);
|
|
1419
813
|
const inputRef = useRef(null);
|
|
814
|
+
useEffect(() => {
|
|
815
|
+
if (search?.value) setIsExpanded(true);
|
|
816
|
+
}, [search?.value]);
|
|
1420
817
|
const options = useMemo(() => {
|
|
1421
818
|
const cols = columns.map((c) => ({ value: c.id, label: c.label }));
|
|
1422
819
|
return searchAll ? [{ value: ALL_COLUMNS_ID, label: "All" }, ...cols] : cols;
|
|
@@ -1428,6 +825,9 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
|
|
|
1428
825
|
}
|
|
1429
826
|
return defaultColumnId;
|
|
1430
827
|
});
|
|
828
|
+
useEffect(() => {
|
|
829
|
+
if (search?.columnId && options.some((o) => o.value === search.columnId)) setSelectedColumnId(search.columnId);
|
|
830
|
+
}, [search?.columnId, options]);
|
|
1431
831
|
useEffect(() => {
|
|
1432
832
|
if (!options.some((o) => o.value === selectedColumnId)) {
|
|
1433
833
|
setSelectedColumnId(defaultColumnId);
|
|
@@ -1436,7 +836,9 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
|
|
|
1436
836
|
const selectedLabel = options.find((o) => o.value === selectedColumnId)?.label ?? "";
|
|
1437
837
|
const inputValue = search?.columnId === selectedColumnId ? search?.value ?? "" : "";
|
|
1438
838
|
useEffect(() => {
|
|
1439
|
-
if (isExpanded
|
|
839
|
+
if (!isExpanded || !focusOnExpand.current) return;
|
|
840
|
+
focusOnExpand.current = false;
|
|
841
|
+
inputRef.current?.focus();
|
|
1440
842
|
}, [isExpanded]);
|
|
1441
843
|
function handleCollapse() {
|
|
1442
844
|
onSearchChange(null);
|
|
@@ -1462,7 +864,10 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
|
|
|
1462
864
|
variant: "outline",
|
|
1463
865
|
size: "sm",
|
|
1464
866
|
className: cn("h-9 w-9 p-0", className),
|
|
1465
|
-
onClick: () =>
|
|
867
|
+
onClick: () => {
|
|
868
|
+
focusOnExpand.current = true;
|
|
869
|
+
setIsExpanded(true);
|
|
870
|
+
},
|
|
1466
871
|
children: [
|
|
1467
872
|
/* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }),
|
|
1468
873
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Search" })
|
|
@@ -1519,7 +924,7 @@ function DataTableSearch({ columns, search, onSearchChange, searchAll, className
|
|
|
1519
924
|
if (e.key === "Escape") handleCollapse();
|
|
1520
925
|
},
|
|
1521
926
|
placeholder: `Search ${selectedLabel.toLowerCase()}...`,
|
|
1522
|
-
className: "bg-background text-sm outline-none w-full min-w-
|
|
927
|
+
className: "bg-background text-sm outline-none w-full min-w-35 placeholder:text-muted-foreground text-foreground"
|
|
1523
928
|
}
|
|
1524
929
|
)
|
|
1525
930
|
] }),
|
|
@@ -19952,7 +19357,7 @@ function DataTableSelectionBar({
|
|
|
19952
19357
|
const plural = meta?.plural ?? "rows";
|
|
19953
19358
|
if (count === 0) return null;
|
|
19954
19359
|
const exportConfig = importExport ?? {
|
|
19955
|
-
columns: table.
|
|
19360
|
+
columns: table.getAllLeafColumns().filter((column) => "accessorKey" in column.columnDef && column.getIsVisible()).map((column) => ({
|
|
19956
19361
|
key: column.id,
|
|
19957
19362
|
label: typeof column.columnDef.header === "string" ? column.columnDef.header : column.id
|
|
19958
19363
|
})),
|
|
@@ -20087,6 +19492,10 @@ function DataTableViewOptions({ table, className }) {
|
|
|
20087
19492
|
const columns = table.getAllLeafColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide());
|
|
20088
19493
|
const sortableColumns = columns.map((col) => ({ id: col.id, column: col }));
|
|
20089
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]);
|
|
20090
19499
|
function handleReorder(reordered) {
|
|
20091
19500
|
const currentOrder = table.getState().columnOrder.length > 0 ? table.getState().columnOrder : table.getAllLeafColumns().map((c) => c.id);
|
|
20092
19501
|
const reorderedIds = reordered.map((r) => r.id);
|
|
@@ -20143,7 +19552,49 @@ function DataTableViewOptions({ table, className }) {
|
|
|
20143
19552
|
}
|
|
20144
19553
|
)
|
|
20145
19554
|
] }),
|
|
20146
|
-
/* @__PURE__ */
|
|
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
|
+
] }),
|
|
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)) }) })
|
|
20147
19598
|
] })
|
|
20148
19599
|
}
|
|
20149
19600
|
]
|
|
@@ -23805,34 +23256,33 @@ function DataTableImportDialog({
|
|
|
23805
23256
|
}
|
|
23806
23257
|
DataTableImportDialog.displayName = "DataTableImportDialog";
|
|
23807
23258
|
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
|
|
23813
|
-
|
|
23814
|
-
|
|
23815
|
-
|
|
23816
|
-
|
|
23817
|
-
|
|
23818
|
-
|
|
23819
|
-
|
|
23820
|
-
|
|
23821
|
-
|
|
23822
|
-
|
|
23823
|
-
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
23827
|
-
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
23834
|
-
|
|
23835
|
-
}
|
|
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
|
+
);
|
|
23836
23286
|
|
|
23837
23287
|
const VIEWS_QK$1 = (slug) => ["quantum-ui", "table-views", slug];
|
|
23838
23288
|
const viewNameSchema = object({
|
|
@@ -24040,7 +23490,7 @@ function DataTableViewsMenu({ slug: tableSlug }) {
|
|
|
24040
23490
|
const hasNonEmptyState = useDataTableStore((s) => {
|
|
24041
23491
|
const st = s.tables[tableSlug]?.activeState;
|
|
24042
23492
|
if (!st) return false;
|
|
24043
|
-
return st.filters.length > 0 || st.sort.length > 0 || Object.keys(st.columnVisibility).length > 0 || st.density !== "normal" || st.columnPinning.left.filter((c) => c !== "select").length > 0 || st.columnPinning.right.length > 0;
|
|
23493
|
+
return st.filters.panel.length > 0 || st.filters.context.length > 0 || st.sort.length > 0 || Object.keys(st.columnVisibility).length > 0 || st.density !== "normal" || st.columnPinning.left.filter((c) => c !== "select").length > 0 || st.columnPinning.right.length > 0;
|
|
24044
23494
|
});
|
|
24045
23495
|
const syncActiveViewState = useDataTableStore((s) => s.syncActiveViewState);
|
|
24046
23496
|
const hasView = activeViewId !== null;
|
|
@@ -24170,10 +23620,10 @@ function DataTableViewTabs({ slug }) {
|
|
|
24170
23620
|
});
|
|
24171
23621
|
function doActivate(viewId) {
|
|
24172
23622
|
if (activeViewId === viewId) {
|
|
24173
|
-
loadViewState(tableSlug, EMPTY_TABLE_STATE, null,
|
|
23623
|
+
loadViewState(tableSlug, EMPTY_TABLE_STATE, null, true);
|
|
24174
23624
|
} else {
|
|
24175
23625
|
const view = views.find((v) => v.id === viewId);
|
|
24176
|
-
if (view) loadViewState(tableSlug, view.state, viewId,
|
|
23626
|
+
if (view) loadViewState(tableSlug, view.state, viewId, true);
|
|
24177
23627
|
}
|
|
24178
23628
|
}
|
|
24179
23629
|
function proceedWithSwitch() {
|
|
@@ -24263,11 +23713,27 @@ const densityClasses = {
|
|
|
24263
23713
|
normal: "py-2 px-3 text-sm",
|
|
24264
23714
|
comfortable: "py-4 px-3 text-sm"
|
|
24265
23715
|
};
|
|
23716
|
+
const NO_FILTERS = [];
|
|
24266
23717
|
const MODE_HEIGHTS = {
|
|
24267
23718
|
page: "calc(100vh - 280px)",
|
|
24268
23719
|
tab: "calc(100vh - 320px)",
|
|
24269
23720
|
compact: "calc(100vh - 570px)"
|
|
24270
23721
|
};
|
|
23722
|
+
function grows(column) {
|
|
23723
|
+
return column.getLeafColumns().some((leaf) => leaf.columnDef.meta?.grow === true);
|
|
23724
|
+
}
|
|
23725
|
+
function groupEdges(column) {
|
|
23726
|
+
const leaves = column.parent?.getLeafColumns().filter((leaf) => leaf.getIsVisible()) ?? [];
|
|
23727
|
+
if (leaves.length === 0) return { inGroup: false, isFirst: false, isLast: false };
|
|
23728
|
+
return { inGroup: true, isFirst: leaves[0].id === column.id, isLast: leaves[leaves.length - 1].id === column.id };
|
|
23729
|
+
}
|
|
23730
|
+
function GroupBracket({ children }) {
|
|
23731
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-end gap-2 px-2", children: [
|
|
23732
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-2 min-w-1 flex-1 rounded-tl-sm border-t border-l border-primary/50" }),
|
|
23733
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate pb-0.5 text-xs leading-none font-semibold tracking-wider text-primary uppercase", children }),
|
|
23734
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-2 min-w-1 flex-1 rounded-tr-sm border-t border-r border-primary/50" })
|
|
23735
|
+
] });
|
|
23736
|
+
}
|
|
24271
23737
|
function buildNoResultsDescription(flags) {
|
|
24272
23738
|
const parts = [];
|
|
24273
23739
|
if (flags.hasActiveSearch) parts.push("your search");
|
|
@@ -24277,14 +23743,13 @@ function buildNoResultsDescription(flags) {
|
|
|
24277
23743
|
return `No results match ${joined}.`;
|
|
24278
23744
|
}
|
|
24279
23745
|
function DataTable({
|
|
24280
|
-
table,
|
|
23746
|
+
table: instance,
|
|
24281
23747
|
searchConfig,
|
|
24282
23748
|
selectActions,
|
|
24283
23749
|
emptyStateConfig,
|
|
24284
23750
|
toolbarActions,
|
|
24285
23751
|
filters,
|
|
24286
23752
|
contextBar,
|
|
24287
|
-
isLoading = false,
|
|
24288
23753
|
className,
|
|
24289
23754
|
enableViews = true,
|
|
24290
23755
|
importExport,
|
|
@@ -24293,6 +23758,7 @@ function DataTable({
|
|
|
24293
23758
|
selectedRowId,
|
|
24294
23759
|
permission
|
|
24295
23760
|
}) {
|
|
23761
|
+
const { table, isLoading: isLoadingProp, isFetching, isSyncing, isError, error, refetch } = instance;
|
|
24296
23762
|
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
24297
23763
|
const importDialog = useDialog();
|
|
24298
23764
|
const headerScrollRef = useRef(null);
|
|
@@ -24302,16 +23768,32 @@ function DataTable({
|
|
|
24302
23768
|
headerScrollRef.current.scrollLeft = bodyScrollRef.current.scrollLeft;
|
|
24303
23769
|
}
|
|
24304
23770
|
};
|
|
23771
|
+
const syncBodyScroll = () => {
|
|
23772
|
+
if (headerScrollRef.current && bodyScrollRef.current) {
|
|
23773
|
+
bodyScrollRef.current.scrollLeft = headerScrollRef.current.scrollLeft;
|
|
23774
|
+
}
|
|
23775
|
+
};
|
|
24305
23776
|
const tableGate = usePermission(permission);
|
|
24306
23777
|
const importGate = usePermission(importExport?.importPermission);
|
|
24307
23778
|
const exportGate = usePermission(importExport?.exportPermission);
|
|
24308
23779
|
const meta = table.options.meta;
|
|
24309
23780
|
const slug = meta?.slug;
|
|
24310
|
-
const
|
|
23781
|
+
const panelFilters = useDataTableStore((s) => slug ? s.tables[slug]?.activeState?.filters.panel : void 0);
|
|
23782
|
+
const contextFilters = useDataTableStore((s) => slug ? s.tables[slug]?.activeState?.filters.context : void 0);
|
|
23783
|
+
const appliedFilterCount = panelFilters?.length ?? 0;
|
|
24311
23784
|
const activeViewId = useDataTableStore((s) => slug ? s.tables[slug]?.activeViewId ?? null : null);
|
|
23785
|
+
const hasRows = table.getRowModel().rows.length > 0;
|
|
23786
|
+
const isLoading = isLoadingProp || !!meta?.isAwaitingDefaults || isSyncing && !hasRows && !isError;
|
|
24312
23787
|
const loadViewState = useDataTableStore((s) => s.loadViewState);
|
|
24313
23788
|
const density = meta?.density ?? "normal";
|
|
24314
|
-
const columnCount = table.
|
|
23789
|
+
const columnCount = table.getVisibleLeafColumns().length;
|
|
23790
|
+
const columnWidths = /* @__PURE__ */ jsx("colgroup", { children: table.getVisibleLeafColumns().map((column) => /* @__PURE__ */ jsx(
|
|
23791
|
+
"col",
|
|
23792
|
+
{
|
|
23793
|
+
style: { width: column.id === "actions" ? 70 : grows(column) ? void 0 : column.getSize() }
|
|
23794
|
+
},
|
|
23795
|
+
column.id
|
|
23796
|
+
)) });
|
|
24315
23797
|
const visibilityEnabled = table.options.enableHiding !== false;
|
|
24316
23798
|
const showImport = !!importExport?.importEndpoint && importGate.granted;
|
|
24317
23799
|
const showExport = !!importExport?.exportEndpoint && exportGate.granted;
|
|
@@ -24321,10 +23803,21 @@ function DataTable({
|
|
|
24321
23803
|
const hasActiveFilters = hasActiveView ? !!meta?.isFiltersDirty : appliedFilterCount > 0;
|
|
24322
23804
|
const hasActiveSearch = hasActiveView ? !!meta?.isSearchDirty : !!(search?.value && search.value.trim() !== "");
|
|
24323
23805
|
const isFiltered = hasActiveSearch || hasActiveFilters || hasActiveView;
|
|
24324
|
-
const filtersBaseline = meta?.activeViewState?.filters ??
|
|
23806
|
+
const filtersBaseline = meta?.activeViewState?.filters.panel ?? NO_FILTERS;
|
|
24325
23807
|
const searchBaseline = meta?.activeViewState?.search ?? null;
|
|
24326
23808
|
const onSearchChange = (s) => meta?.setSearch?.(s);
|
|
24327
23809
|
const selectedCount = table.getFilteredSelectedRowModel().rows.length;
|
|
23810
|
+
const setContext = meta?.setContext;
|
|
23811
|
+
const defaultContext = meta?.defaultContext ?? NO_FILTERS;
|
|
23812
|
+
const requiredContext = useMemo(() => new Set(defaultContext.map((c) => c.field)), [defaultContext]);
|
|
23813
|
+
const boundContextBar = contextBar && setContext ? bindFilters(contextBar, {
|
|
23814
|
+
conditions: contextFilters ?? NO_FILTERS,
|
|
23815
|
+
onChange: setContext,
|
|
23816
|
+
keepControlled: true,
|
|
23817
|
+
required: requiredContext,
|
|
23818
|
+
// After a failed first load the controls show what the table holds rather than waiting on a load that ended
|
|
23819
|
+
loading: !meta?.isLoaded && !isError
|
|
23820
|
+
}) : contextBar;
|
|
24328
23821
|
useEffect(() => {
|
|
24329
23822
|
if (selectedCount > 0) setFiltersOpen(false);
|
|
24330
23823
|
}, [selectedCount]);
|
|
@@ -24342,11 +23835,46 @@ function DataTable({
|
|
|
24342
23835
|
return null;
|
|
24343
23836
|
}
|
|
24344
23837
|
const locked = tableGate.locked;
|
|
23838
|
+
function renderNoRows() {
|
|
23839
|
+
if (locked) {
|
|
23840
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-2 text-center", children: [
|
|
23841
|
+
/* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
|
|
23842
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
|
|
23843
|
+
] });
|
|
23844
|
+
}
|
|
23845
|
+
if (isError) {
|
|
23846
|
+
return /* @__PURE__ */ jsx(DataTableLoadFailed, { plural: meta?.plural ?? "rows", error, refetch });
|
|
23847
|
+
}
|
|
23848
|
+
if (isFiltered) {
|
|
23849
|
+
return /* @__PURE__ */ jsx(
|
|
23850
|
+
DataTableEmpty,
|
|
23851
|
+
{
|
|
23852
|
+
icon: emptyStateConfig?.icon,
|
|
23853
|
+
title: "No results found",
|
|
23854
|
+
description: buildNoResultsDescription({ hasActiveSearch, hasActiveFilters, hasActiveView }),
|
|
23855
|
+
action: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
23856
|
+
hasActiveSearch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setSearch?.(searchBaseline), children: "Clear Search" }),
|
|
23857
|
+
hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setFilters?.(filtersBaseline), children: "Clear Filters" }),
|
|
23858
|
+
hasActiveView && slug && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => loadViewState(slug, EMPTY_TABLE_STATE, null, true), children: "Clear View" })
|
|
23859
|
+
] })
|
|
23860
|
+
}
|
|
23861
|
+
);
|
|
23862
|
+
}
|
|
23863
|
+
return /* @__PURE__ */ jsx(
|
|
23864
|
+
DataTableEmpty,
|
|
23865
|
+
{
|
|
23866
|
+
icon: emptyStateConfig?.icon,
|
|
23867
|
+
title: emptyStateConfig?.title,
|
|
23868
|
+
description: emptyStateConfig?.description,
|
|
23869
|
+
action: emptyStateConfig?.action
|
|
23870
|
+
}
|
|
23871
|
+
);
|
|
23872
|
+
}
|
|
24345
23873
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
|
|
24346
23874
|
showToolbar && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
|
|
24347
23875
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
|
|
24348
23876
|
contextBar && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24349
|
-
/* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children:
|
|
23877
|
+
/* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: boundContextBar }),
|
|
24350
23878
|
/* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "data-[orientation=vertical]:h-6" })
|
|
24351
23879
|
] }),
|
|
24352
23880
|
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1", children: enableViews && slug && /* @__PURE__ */ jsx(DataTableViewTabs, { slug }) })
|
|
@@ -24447,7 +23975,25 @@ function DataTable({
|
|
|
24447
23975
|
toolbarActions?.actions
|
|
24448
23976
|
] })
|
|
24449
23977
|
] }),
|
|
24450
|
-
/* @__PURE__ */ jsxs("div", { className: "border rounded-lg overflow-hidden flex flex-col", style: { height: MODE_HEIGHTS[mode] }, children: [
|
|
23978
|
+
/* @__PURE__ */ jsxs("div", { className: "relative border rounded-lg overflow-hidden flex flex-col", style: { height: MODE_HEIGHTS[mode] }, children: [
|
|
23979
|
+
(isFetching || isSyncing) && !isLoading && /* @__PURE__ */ jsx(
|
|
23980
|
+
"div",
|
|
23981
|
+
{
|
|
23982
|
+
role: "progressbar",
|
|
23983
|
+
"aria-label": "Loading",
|
|
23984
|
+
className: "pointer-events-none absolute inset-x-0 top-0 z-30 h-0.5 overflow-hidden bg-primary/15",
|
|
23985
|
+
children: /* @__PURE__ */ jsx(
|
|
23986
|
+
motion.div,
|
|
23987
|
+
{
|
|
23988
|
+
className: "h-full w-1/3 bg-primary",
|
|
23989
|
+
initial: { x: "-100%" },
|
|
23990
|
+
animate: { x: "300%" },
|
|
23991
|
+
transition: { duration: 1.1, ease: "easeInOut", repeat: Number.POSITIVE_INFINITY }
|
|
23992
|
+
}
|
|
23993
|
+
)
|
|
23994
|
+
}
|
|
23995
|
+
),
|
|
23996
|
+
isError && hasRows && !isLoading && /* @__PURE__ */ jsx(DataTableRefreshFailed, { refetch }),
|
|
24451
23997
|
/* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: selectedCount > 0 ? /* @__PURE__ */ jsx(
|
|
24452
23998
|
motion.div,
|
|
24453
23999
|
{
|
|
@@ -24481,52 +24027,83 @@ function DataTable({
|
|
|
24481
24027
|
"filters"
|
|
24482
24028
|
) : null }),
|
|
24483
24029
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col flex-1 min-h-0", children: [
|
|
24484
|
-
/* @__PURE__ */ jsx("div", { ref: headerScrollRef, className: "shrink-0 overflow-hidden", children: /* @__PURE__ */
|
|
24030
|
+
/* @__PURE__ */ jsx("div", { ref: headerScrollRef, onScroll: syncBodyScroll, className: "shrink-0 overflow-hidden", children: /* @__PURE__ */ jsxs(
|
|
24485
24031
|
"table",
|
|
24486
24032
|
{
|
|
24487
24033
|
className: "w-full caption-bottom text-sm table-fixed",
|
|
24488
24034
|
style: { minWidth: table.getCenterTotalSize() },
|
|
24489
|
-
children:
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
TableHead,
|
|
24035
|
+
children: [
|
|
24036
|
+
columnWidths,
|
|
24037
|
+
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup, rowIndex, headerGroups) => /* @__PURE__ */ jsx(
|
|
24038
|
+
TableRow,
|
|
24494
24039
|
{
|
|
24495
|
-
|
|
24496
|
-
|
|
24497
|
-
|
|
24498
|
-
"
|
|
24499
|
-
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
|
|
24504
|
-
children: [
|
|
24505
|
-
isActions && /* @__PURE__ */ jsx(
|
|
24506
|
-
"div",
|
|
24040
|
+
className: cn(rowIndex < headerGroups.length - 1 && "border-b-0!"),
|
|
24041
|
+
children: headerGroup.headers.map((header) => {
|
|
24042
|
+
const isActions = header.column.id === "actions";
|
|
24043
|
+
const headerAlignClass = isActions ? "justify-end" : "justify-center";
|
|
24044
|
+
const isGroup = header.subHeaders.length > 0 && !header.isPlaceholder;
|
|
24045
|
+
const isGroupRow = rowIndex < headerGroups.length - 1;
|
|
24046
|
+
const edges = groupEdges(header.column);
|
|
24047
|
+
return /* @__PURE__ */ jsxs(
|
|
24048
|
+
TableHead,
|
|
24507
24049
|
{
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
}
|
|
24511
|
-
),
|
|
24512
|
-
/* @__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()) }),
|
|
24513
|
-
!meta?.lockedColumnSizing && header.column.getCanResize() && /* @__PURE__ */ jsx(
|
|
24514
|
-
"div",
|
|
24515
|
-
{
|
|
24516
|
-
onPointerDown: header.getResizeHandler(),
|
|
24517
|
-
onTouchStart: header.getResizeHandler(),
|
|
24050
|
+
colSpan: header.colSpan,
|
|
24051
|
+
style: isActions ? { width: "70px" } : grows(header.column) ? { minWidth: header.getSize() } : { width: header.getSize(), minWidth: header.getSize(), maxWidth: header.getSize() },
|
|
24518
24052
|
className: cn(
|
|
24519
|
-
"
|
|
24520
|
-
|
|
24521
|
-
header
|
|
24522
|
-
|
|
24523
|
-
|
|
24524
|
-
|
|
24525
|
-
|
|
24053
|
+
"relative group/resize",
|
|
24054
|
+
// actions header stays pinned on horizontal scroll; z-20 keeps it above the
|
|
24055
|
+
// regular header cells that scroll underneath it.
|
|
24056
|
+
isActions ? "text-right sticky right-0 z-20" : "text-center",
|
|
24057
|
+
// grouped, the two rows together take one ungrouped header row's height
|
|
24058
|
+
isGroupRow && "h-5 px-0 align-bottom",
|
|
24059
|
+
!isGroupRow && headerGroups.length > 1 && "h-7",
|
|
24060
|
+
// a group and the column headers under it share one tint, edged where the group starts and ends
|
|
24061
|
+
(isGroup || edges.inGroup) && "bg-primary/5",
|
|
24062
|
+
isGroup && "border-x border-border",
|
|
24063
|
+
edges.isFirst && "border-l border-border",
|
|
24064
|
+
edges.isLast && "border-r border-border"
|
|
24065
|
+
),
|
|
24066
|
+
"aria-sort": header.column.getCanSort() ? header.column.getIsSorted() === "asc" ? "ascending" : header.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
|
|
24067
|
+
children: [
|
|
24068
|
+
isActions && /* @__PURE__ */ jsx(
|
|
24069
|
+
"div",
|
|
24070
|
+
{
|
|
24071
|
+
"aria-hidden": true,
|
|
24072
|
+
className: "pointer-events-none absolute inset-x-0 top-0 bottom-px bg-muted backdrop-blur-sm"
|
|
24073
|
+
}
|
|
24074
|
+
),
|
|
24075
|
+
/* @__PURE__ */ jsx(
|
|
24076
|
+
"div",
|
|
24077
|
+
{
|
|
24078
|
+
className: cn(
|
|
24079
|
+
isActions ? "relative" : void 0,
|
|
24080
|
+
// an ungrouped column's title rises by half the group row so it centres across both rows
|
|
24081
|
+
!isGroupRow && headerGroups.length > 1 && !edges.inGroup && "-translate-y-2.5"
|
|
24082
|
+
),
|
|
24083
|
+
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())
|
|
24084
|
+
}
|
|
24085
|
+
),
|
|
24086
|
+
!meta?.lockedColumnSizing && header.column.getCanResize() && /* @__PURE__ */ jsx(
|
|
24087
|
+
"div",
|
|
24088
|
+
{
|
|
24089
|
+
onPointerDown: header.getResizeHandler(),
|
|
24090
|
+
onTouchStart: header.getResizeHandler(),
|
|
24091
|
+
className: cn(
|
|
24092
|
+
"absolute top-0 right-0 w-1 h-full cursor-col-resize select-none touch-none z-10",
|
|
24093
|
+
"opacity-0 group-hover/resize:opacity-100 hover:bg-primary/50",
|
|
24094
|
+
header.column.getIsResizing() && "opacity-100 bg-primary"
|
|
24095
|
+
)
|
|
24096
|
+
}
|
|
24097
|
+
)
|
|
24098
|
+
]
|
|
24099
|
+
},
|
|
24100
|
+
header.id
|
|
24101
|
+
);
|
|
24102
|
+
})
|
|
24526
24103
|
},
|
|
24527
|
-
|
|
24528
|
-
)
|
|
24529
|
-
|
|
24104
|
+
headerGroup.id
|
|
24105
|
+
)) })
|
|
24106
|
+
]
|
|
24530
24107
|
}
|
|
24531
24108
|
) }),
|
|
24532
24109
|
/* @__PURE__ */ jsxs(
|
|
@@ -24536,99 +24113,74 @@ function DataTable({
|
|
|
24536
24113
|
onScroll: syncHeaderScroll,
|
|
24537
24114
|
className: "relative flex flex-col flex-1 min-h-0 overflow-auto overscroll-auto",
|
|
24538
24115
|
children: [
|
|
24539
|
-
!locked && (isLoading ||
|
|
24116
|
+
!locked && (isLoading || hasRows) && /* @__PURE__ */ jsxs(
|
|
24540
24117
|
"table",
|
|
24541
24118
|
{
|
|
24542
24119
|
className: "w-full caption-bottom text-sm table-fixed",
|
|
24543
24120
|
style: { minWidth: table.getCenterTotalSize() },
|
|
24544
|
-
children:
|
|
24545
|
-
|
|
24546
|
-
(
|
|
24547
|
-
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24560
|
-
|
|
24561
|
-
|
|
24562
|
-
|
|
24563
|
-
|
|
24564
|
-
|
|
24565
|
-
|
|
24566
|
-
|
|
24567
|
-
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
maxWidth: cell.column.getSize()
|
|
24571
|
-
},
|
|
24572
|
-
children: [
|
|
24573
|
-
isActionsCell && /* @__PURE__ */ jsx(
|
|
24574
|
-
"div",
|
|
24575
|
-
{
|
|
24576
|
-
"aria-hidden": true,
|
|
24577
|
-
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"
|
|
24578
|
-
}
|
|
24121
|
+
children: [
|
|
24122
|
+
columnWidths,
|
|
24123
|
+
/* @__PURE__ */ jsx(TableBody, { className: cn("transition-opacity", isSyncing && !isLoading && "opacity-60"), children: isLoading ? Array.from(
|
|
24124
|
+
{ length: table.getState().pagination?.pageSize ?? 20 },
|
|
24125
|
+
(_, i) => `skeleton-row-${i}`
|
|
24126
|
+
).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) => {
|
|
24127
|
+
const externallySelected = selectedRowId != null && row.id === selectedRowId;
|
|
24128
|
+
const isSelected = row.getIsSelected() || externallySelected;
|
|
24129
|
+
return /* @__PURE__ */ jsx(
|
|
24130
|
+
TableRow,
|
|
24131
|
+
{
|
|
24132
|
+
"data-state": isSelected ? "selected" : void 0,
|
|
24133
|
+
className: "group animate-in fade-in duration-300",
|
|
24134
|
+
style: { animationDelay: `${Math.min(index, 12) * 25}ms`, animationFillMode: "both" },
|
|
24135
|
+
children: row.getVisibleCells().map((cell) => {
|
|
24136
|
+
const isActionsCell = cell.column.id === "actions";
|
|
24137
|
+
const edges = groupEdges(cell.column);
|
|
24138
|
+
return /* @__PURE__ */ jsxs(
|
|
24139
|
+
TableCell,
|
|
24140
|
+
{
|
|
24141
|
+
className: cn(
|
|
24142
|
+
densityClasses[density],
|
|
24143
|
+
edges.isFirst && "border-l border-border/60",
|
|
24144
|
+
edges.isLast && "border-r border-border/60",
|
|
24145
|
+
isActionsCell ? "px-2 sticky right-0 z-10" : void 0,
|
|
24146
|
+
onRowClick && !isActionsCell ? "cursor-pointer" : void 0
|
|
24579
24147
|
),
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24148
|
+
onClick: onRowClick && !isActionsCell ? () => onRowClick(row.original) : void 0,
|
|
24149
|
+
style: isActionsCell ? { width: "70px" } : grows(cell.column) ? { minWidth: cell.column.getSize() } : {
|
|
24150
|
+
width: cell.column.getSize(),
|
|
24151
|
+
minWidth: cell.column.getSize(),
|
|
24152
|
+
maxWidth: cell.column.getSize()
|
|
24153
|
+
},
|
|
24154
|
+
children: [
|
|
24155
|
+
isActionsCell && /* @__PURE__ */ jsx(
|
|
24156
|
+
"div",
|
|
24157
|
+
{
|
|
24158
|
+
"aria-hidden": true,
|
|
24159
|
+
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"
|
|
24160
|
+
}
|
|
24161
|
+
),
|
|
24162
|
+
/* @__PURE__ */ jsx(
|
|
24163
|
+
"div",
|
|
24164
|
+
{
|
|
24165
|
+
className: cn(
|
|
24166
|
+
isActionsCell ? "relative flex items-center justify-end" : "overflow-hidden text-center"
|
|
24167
|
+
),
|
|
24168
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
24169
|
+
}
|
|
24170
|
+
)
|
|
24171
|
+
]
|
|
24172
|
+
},
|
|
24173
|
+
cell.id
|
|
24174
|
+
);
|
|
24175
|
+
})
|
|
24176
|
+
},
|
|
24177
|
+
row.id
|
|
24178
|
+
);
|
|
24179
|
+
}) })
|
|
24180
|
+
]
|
|
24598
24181
|
}
|
|
24599
24182
|
),
|
|
24600
|
-
(locked || !isLoading &&
|
|
24601
|
-
/* @__PURE__ */ jsx(PermissionLockIcon, { reason: tableGate.reason, className: "size-6" }),
|
|
24602
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: lockedTip(tableGate) })
|
|
24603
|
-
] }) : isFiltered ? /* @__PURE__ */ jsx(
|
|
24604
|
-
DataTableEmpty,
|
|
24605
|
-
{
|
|
24606
|
-
icon: emptyStateConfig?.icon,
|
|
24607
|
-
title: "No results found",
|
|
24608
|
-
description: buildNoResultsDescription({ hasActiveSearch, hasActiveFilters, hasActiveView }),
|
|
24609
|
-
action: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
24610
|
-
hasActiveSearch && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setSearch?.(searchBaseline), children: "Clear Search" }),
|
|
24611
|
-
hasActiveFilters && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => meta?.setFilters?.(filtersBaseline), children: "Clear Filters" }),
|
|
24612
|
-
hasActiveView && slug && /* @__PURE__ */ jsx(
|
|
24613
|
-
Button,
|
|
24614
|
-
{
|
|
24615
|
-
variant: "outline",
|
|
24616
|
-
size: "sm",
|
|
24617
|
-
onClick: () => loadViewState(slug, EMPTY_TABLE_STATE, null, false),
|
|
24618
|
-
children: "Clear View"
|
|
24619
|
-
}
|
|
24620
|
-
)
|
|
24621
|
-
] })
|
|
24622
|
-
}
|
|
24623
|
-
) : /* @__PURE__ */ jsx(
|
|
24624
|
-
DataTableEmpty,
|
|
24625
|
-
{
|
|
24626
|
-
icon: emptyStateConfig?.icon,
|
|
24627
|
-
title: emptyStateConfig?.title,
|
|
24628
|
-
description: emptyStateConfig?.description,
|
|
24629
|
-
action: emptyStateConfig?.action
|
|
24630
|
-
}
|
|
24631
|
-
) })
|
|
24183
|
+
(locked || !isLoading && !hasRows) && /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: renderNoRows() })
|
|
24632
24184
|
]
|
|
24633
24185
|
}
|
|
24634
24186
|
)
|
|
@@ -24662,7 +24214,7 @@ function useTableSlice(slug) {
|
|
|
24662
24214
|
const isFiltersDirty = useDataTableStore((s) => {
|
|
24663
24215
|
const t = s.tables[slug];
|
|
24664
24216
|
if (!t?.activeViewState) return false;
|
|
24665
|
-
return !deepEqual(t.activeState.filters, t.activeViewState.filters);
|
|
24217
|
+
return !deepEqual(t.activeState.filters.panel, t.activeViewState.filters.panel);
|
|
24666
24218
|
});
|
|
24667
24219
|
const isSearchDirty = useDataTableStore((s) => {
|
|
24668
24220
|
const t = s.tables[slug];
|
|
@@ -24671,20 +24223,28 @@ function useTableSlice(slug) {
|
|
|
24671
24223
|
});
|
|
24672
24224
|
const _updateActiveState = useDataTableStore((s) => s.updateActiveState);
|
|
24673
24225
|
const _setFilters = useDataTableStore((s) => s.setFilters);
|
|
24226
|
+
const _setFilter = useDataTableStore((s) => s.setFilter);
|
|
24227
|
+
const _setContext = useDataTableStore((s) => s.setContext);
|
|
24674
24228
|
const _setSearch = useDataTableStore((s) => s.setSearch);
|
|
24675
24229
|
const _setPagination = useDataTableStore((s) => s.setPagination);
|
|
24676
|
-
const _consumeSkipUpsert = useDataTableStore((s) => s.consumeSkipUpsert);
|
|
24677
24230
|
const updateActiveState = useCallback(
|
|
24678
24231
|
(updater) => _updateActiveState(slug, updater),
|
|
24679
24232
|
[slug, _updateActiveState]
|
|
24680
24233
|
);
|
|
24681
24234
|
const setFilters = useCallback((filters) => _setFilters(slug, filters), [slug, _setFilters]);
|
|
24235
|
+
const setFilter = useCallback(
|
|
24236
|
+
(field, condition) => _setFilter(slug, field, condition),
|
|
24237
|
+
[slug, _setFilter]
|
|
24238
|
+
);
|
|
24239
|
+
const setContext = useCallback(
|
|
24240
|
+
(field, condition) => _setContext(slug, field, condition),
|
|
24241
|
+
[slug, _setContext]
|
|
24242
|
+
);
|
|
24682
24243
|
const setSearch = useCallback((search) => _setSearch(slug, search), [slug, _setSearch]);
|
|
24683
24244
|
const setPagination = useCallback(
|
|
24684
24245
|
(pagination) => _setPagination(slug, pagination),
|
|
24685
24246
|
[slug, _setPagination]
|
|
24686
24247
|
);
|
|
24687
|
-
const consumeSkipUpsert = useCallback(() => _consumeSkipUpsert(slug), [slug, _consumeSkipUpsert]);
|
|
24688
24248
|
const sorting = useMemo(() => sortConditionsToTanstack(activeState.sort), [activeState.sort]);
|
|
24689
24249
|
const handleSortingChange = useCallback(
|
|
24690
24250
|
(updater) => {
|
|
@@ -24703,50 +24263,94 @@ function useTableSlice(slug) {
|
|
|
24703
24263
|
isSearchDirty,
|
|
24704
24264
|
updateActiveState,
|
|
24705
24265
|
setFilters,
|
|
24266
|
+
setFilter,
|
|
24267
|
+
setContext,
|
|
24706
24268
|
setSearch,
|
|
24707
24269
|
setPagination,
|
|
24708
|
-
handleSortingChange
|
|
24709
|
-
consumeSkipUpsert
|
|
24270
|
+
handleSortingChange
|
|
24710
24271
|
};
|
|
24711
24272
|
}
|
|
24712
24273
|
|
|
24713
|
-
|
|
24274
|
+
const SAVE_DELAY_MS = 150;
|
|
24275
|
+
async function saveTableState(slug, onStatePush) {
|
|
24276
|
+
const table = useDataTableStore.getState().tables[slug];
|
|
24277
|
+
if (!table) return;
|
|
24278
|
+
const saved = await putTableState(slug, table.activeState, table.activeViewId).then(
|
|
24279
|
+
() => true,
|
|
24280
|
+
() => false
|
|
24281
|
+
);
|
|
24282
|
+
if (saved) await onStatePush?.();
|
|
24283
|
+
else toast.error("Couldn't apply the change", { description: "The table still shows the earlier results." });
|
|
24284
|
+
}
|
|
24285
|
+
function useAutoUpsert(slug, isReady, onStatePush) {
|
|
24714
24286
|
const onStatePushRef = useRef(onStatePush);
|
|
24715
24287
|
onStatePushRef.current = onStatePush;
|
|
24716
|
-
const
|
|
24717
|
-
const
|
|
24288
|
+
const saveRequest = useDataTableStore((s) => s.tables[slug]?.saveRequest ?? 0);
|
|
24289
|
+
const lastSeen = useRef({ slug, saveRequest });
|
|
24290
|
+
const [inFlight, setInFlight] = useState(null);
|
|
24718
24291
|
useEffect(() => {
|
|
24719
|
-
|
|
24720
|
-
|
|
24721
|
-
|
|
24722
|
-
|
|
24723
|
-
}
|
|
24724
|
-
|
|
24725
|
-
|
|
24726
|
-
|
|
24727
|
-
|
|
24728
|
-
|
|
24729
|
-
|
|
24730
|
-
|
|
24731
|
-
|
|
24292
|
+
const seen = lastSeen.current;
|
|
24293
|
+
lastSeen.current = { slug, saveRequest };
|
|
24294
|
+
const isNewChange = seen.slug === slug && seen.saveRequest !== saveRequest;
|
|
24295
|
+
if (!isReady || !isNewChange) return;
|
|
24296
|
+
const request = { slug, saveRequest };
|
|
24297
|
+
const finish = () => setInFlight(
|
|
24298
|
+
(current) => current?.slug === request.slug && current.saveRequest === request.saveRequest ? null : current
|
|
24299
|
+
);
|
|
24300
|
+
setInFlight(request);
|
|
24301
|
+
let started = false;
|
|
24302
|
+
const timer = setTimeout(async () => {
|
|
24303
|
+
started = true;
|
|
24304
|
+
await saveTableState(slug, onStatePushRef.current);
|
|
24305
|
+
finish();
|
|
24306
|
+
}, SAVE_DELAY_MS);
|
|
24307
|
+
return () => {
|
|
24308
|
+
clearTimeout(timer);
|
|
24309
|
+
if (!started) finish();
|
|
24310
|
+
};
|
|
24311
|
+
}, [slug, saveRequest, isReady]);
|
|
24312
|
+
return inFlight?.slug === slug;
|
|
24313
|
+
}
|
|
24314
|
+
|
|
24315
|
+
const NO_CONDITIONS = [];
|
|
24316
|
+
const NO_FIELDS = [];
|
|
24317
|
+
function leafColumnIds(columns) {
|
|
24318
|
+
return columns.flatMap((column) => {
|
|
24319
|
+
if ("columns" in column && column.columns) return leafColumnIds(column.columns);
|
|
24320
|
+
if (column.id) return [column.id];
|
|
24321
|
+
if ("accessorKey" in column && typeof column.accessorKey === "string")
|
|
24322
|
+
return [column.accessorKey.replace(/\./g, "_")];
|
|
24323
|
+
return typeof column.header === "string" ? [column.header] : [];
|
|
24324
|
+
});
|
|
24325
|
+
}
|
|
24326
|
+
function withDefinedColumns(savedOrder, definedIds) {
|
|
24327
|
+
if (savedOrder.length === 0) return savedOrder;
|
|
24328
|
+
const order = savedOrder.filter((id) => definedIds.includes(id));
|
|
24329
|
+
definedIds.forEach((id, index) => {
|
|
24330
|
+
if (order.includes(id)) return;
|
|
24331
|
+
const previous = definedIds.slice(0, index).reverse().find((defined) => order.includes(defined));
|
|
24332
|
+
order.splice(previous ? order.indexOf(previous) + 1 : 0, 0, id);
|
|
24333
|
+
});
|
|
24334
|
+
return order;
|
|
24732
24335
|
}
|
|
24733
|
-
|
|
24734
24336
|
function useDataTable({
|
|
24735
24337
|
columns,
|
|
24736
24338
|
slug,
|
|
24737
24339
|
label,
|
|
24738
|
-
|
|
24340
|
+
query,
|
|
24739
24341
|
enableMultiSort = true,
|
|
24740
24342
|
enableRowSelection = true,
|
|
24741
24343
|
enableHiding = true,
|
|
24742
24344
|
enableSorting = true,
|
|
24743
24345
|
enableColumnResizing = true,
|
|
24744
|
-
onStatePush
|
|
24346
|
+
onStatePush,
|
|
24347
|
+
defaultContext,
|
|
24348
|
+
resetOnOpen = NO_FIELDS
|
|
24745
24349
|
}) {
|
|
24350
|
+
const serverState = query?.data;
|
|
24746
24351
|
const {
|
|
24747
24352
|
// State
|
|
24748
24353
|
activeState,
|
|
24749
|
-
activeViewId,
|
|
24750
24354
|
activeViewState,
|
|
24751
24355
|
sorting,
|
|
24752
24356
|
// Dirty flags
|
|
@@ -24756,17 +24360,12 @@ function useDataTable({
|
|
|
24756
24360
|
// Actions
|
|
24757
24361
|
updateActiveState,
|
|
24758
24362
|
setFilters,
|
|
24363
|
+
setFilter,
|
|
24364
|
+
setContext,
|
|
24759
24365
|
setSearch,
|
|
24760
24366
|
setPagination,
|
|
24761
|
-
handleSortingChange
|
|
24762
|
-
consumeSkipUpsert
|
|
24367
|
+
handleSortingChange
|
|
24763
24368
|
} = useTableSlice(slug);
|
|
24764
|
-
const hasInitRef = useRef(false);
|
|
24765
|
-
useEffect(() => {
|
|
24766
|
-
if (!serverState?.state || hasInitRef.current) return;
|
|
24767
|
-
hasInitRef.current = true;
|
|
24768
|
-
useDataTableStore.getState().loadViewState(slug, serverState.state, serverState.activeViewId ?? null);
|
|
24769
|
-
}, [serverState?.state, serverState?.activeViewId, slug]);
|
|
24770
24369
|
const initializedSlug = useRef(null);
|
|
24771
24370
|
useLayoutEffect(() => {
|
|
24772
24371
|
if (initializedSlug.current !== slug) {
|
|
@@ -24774,7 +24373,47 @@ function useDataTable({
|
|
|
24774
24373
|
initializedSlug.current = slug;
|
|
24775
24374
|
}
|
|
24776
24375
|
}, [slug, enableRowSelection]);
|
|
24777
|
-
const
|
|
24376
|
+
const nextDefaults = defaultContext ?? NO_CONDITIONS;
|
|
24377
|
+
const [defaults, setDefaults] = useState(nextDefaults);
|
|
24378
|
+
if (!deepEqual(defaults, nextDefaults)) setDefaults(nextDefaults);
|
|
24379
|
+
const [loadedSlug, setLoadedSlug] = useState(null);
|
|
24380
|
+
useLayoutEffect(() => {
|
|
24381
|
+
if (!serverState?.state || loadedSlug === slug) return;
|
|
24382
|
+
useDataTableStore.getState().loadViewState(slug, serverState.state, serverState.activeViewId ?? null);
|
|
24383
|
+
setLoadedSlug(slug);
|
|
24384
|
+
}, [serverState?.state, serverState?.activeViewId, slug, loadedSlug]);
|
|
24385
|
+
const isReady = loadedSlug === slug || serverState != null && serverState.state == null;
|
|
24386
|
+
const context = activeState.filters.context;
|
|
24387
|
+
const openedSlug = useRef(null);
|
|
24388
|
+
useLayoutEffect(() => {
|
|
24389
|
+
if (loadedSlug !== slug) return;
|
|
24390
|
+
const isOpening = openedSlug.current !== slug;
|
|
24391
|
+
openedSlug.current = slug;
|
|
24392
|
+
const filled = withDefaults(context, defaults, { isOpening, resetOnOpen });
|
|
24393
|
+
const addedOrReplaced = filled.filter((condition) => !context.includes(condition));
|
|
24394
|
+
for (const condition of addedOrReplaced) setContext(condition.field, condition);
|
|
24395
|
+
}, [loadedSlug, slug, defaults, resetOnOpen, context, setContext]);
|
|
24396
|
+
const contextValue = useCallback((field) => readValue(context, field), [context]);
|
|
24397
|
+
const echoedContext = serverState?.state?.filters.context;
|
|
24398
|
+
const [resetDoneSlug, setResetDoneSlug] = useState(null);
|
|
24399
|
+
const isAwaitingReset = resetDoneSlug !== slug && echoedContext != null && !holdsResetDefaults(echoedContext, defaults, resetOnOpen);
|
|
24400
|
+
useLayoutEffect(() => {
|
|
24401
|
+
if (echoedContext != null && !isAwaitingReset && resetDoneSlug !== slug) setResetDoneSlug(slug);
|
|
24402
|
+
}, [echoedContext, isAwaitingReset, resetDoneSlug, slug]);
|
|
24403
|
+
const setUserContext = useCallback(
|
|
24404
|
+
(...args) => {
|
|
24405
|
+
setResetDoneSlug(slug);
|
|
24406
|
+
setContext(...args);
|
|
24407
|
+
},
|
|
24408
|
+
[slug, setContext]
|
|
24409
|
+
);
|
|
24410
|
+
const isAwaitingDefaults = isAwaitingReset || echoedContext != null && !hasEveryDefault(echoedContext, defaults);
|
|
24411
|
+
const { columnVisibility, columnSizing, columnPinning, lockedColumnSizing } = activeState;
|
|
24412
|
+
const definedIds = useMemo(() => leafColumnIds(columns), [columns]);
|
|
24413
|
+
const columnOrder = useMemo(
|
|
24414
|
+
() => withDefinedColumns(activeState.columnOrder, definedIds),
|
|
24415
|
+
[activeState.columnOrder, definedIds]
|
|
24416
|
+
);
|
|
24778
24417
|
const { filterOrder, filterVisibility, density } = activeState;
|
|
24779
24418
|
const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1);
|
|
24780
24419
|
const meta = useMemo(
|
|
@@ -24804,6 +24443,12 @@ function useDataTable({
|
|
|
24804
24443
|
activeViewState,
|
|
24805
24444
|
// Filters
|
|
24806
24445
|
setFilters: (filters) => setFilters(filters),
|
|
24446
|
+
setFilter,
|
|
24447
|
+
setContext: setUserContext,
|
|
24448
|
+
contextValue,
|
|
24449
|
+
defaultContext: defaults,
|
|
24450
|
+
isAwaitingDefaults,
|
|
24451
|
+
isLoaded: isReady,
|
|
24807
24452
|
// Search
|
|
24808
24453
|
search: activeState.search,
|
|
24809
24454
|
setSearch
|
|
@@ -24821,11 +24466,17 @@ function useDataTable({
|
|
|
24821
24466
|
activeViewState,
|
|
24822
24467
|
updateActiveState,
|
|
24823
24468
|
setFilters,
|
|
24469
|
+
setFilter,
|
|
24470
|
+
setUserContext,
|
|
24471
|
+
contextValue,
|
|
24472
|
+
defaults,
|
|
24473
|
+
isAwaitingDefaults,
|
|
24474
|
+
isReady,
|
|
24824
24475
|
activeState.search,
|
|
24825
24476
|
setSearch
|
|
24826
24477
|
]
|
|
24827
24478
|
);
|
|
24828
|
-
useAutoUpsert(slug,
|
|
24479
|
+
const isSyncing = useAutoUpsert(slug, isReady, onStatePush);
|
|
24829
24480
|
const data = serverState?.result ?? [];
|
|
24830
24481
|
const totalRows = serverState?.count;
|
|
24831
24482
|
const table = useReactTable({
|
|
@@ -24863,7 +24514,7 @@ function useDataTable({
|
|
|
24863
24514
|
updateActiveState((prev) => ({ ...prev, columnPinning: newVal }));
|
|
24864
24515
|
},
|
|
24865
24516
|
onColumnOrderChange: (updater) => {
|
|
24866
|
-
const current =
|
|
24517
|
+
const current = columnOrder;
|
|
24867
24518
|
const newVal = typeof updater === "function" ? updater(current) : updater;
|
|
24868
24519
|
updateActiveState((prev) => ({ ...prev, columnOrder: newVal }));
|
|
24869
24520
|
},
|
|
@@ -24887,8 +24538,18 @@ function useDataTable({
|
|
|
24887
24538
|
enableHiding,
|
|
24888
24539
|
meta
|
|
24889
24540
|
});
|
|
24890
|
-
return {
|
|
24541
|
+
return {
|
|
24542
|
+
table,
|
|
24543
|
+
isLoading: query?.isLoading ?? false,
|
|
24544
|
+
isFetching: query?.isFetching ?? false,
|
|
24545
|
+
isSyncing,
|
|
24546
|
+
isError: query?.isError ?? false,
|
|
24547
|
+
error: query?.error,
|
|
24548
|
+
refetch: query?.refetch,
|
|
24549
|
+
contextValue,
|
|
24550
|
+
isLoaded: isReady
|
|
24551
|
+
};
|
|
24891
24552
|
}
|
|
24892
24553
|
|
|
24893
|
-
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,
|
|
24554
|
+
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, setTableContext as s, useDataTable as u };
|
|
24894
24555
|
//# sourceMappingURL=useDataTable.js.map
|