@stackframe/dashboard-ui-components 2.8.84 → 2.8.86
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/components/analytics-chart/analytics-chart-pie.d.ts +67 -0
- package/dist/components/analytics-chart/analytics-chart-pie.d.ts.map +1 -0
- package/dist/components/analytics-chart/analytics-chart-pie.js +253 -0
- package/dist/components/analytics-chart/analytics-chart-pie.js.map +1 -0
- package/dist/components/analytics-chart/analytics-chart.d.ts +554 -0
- package/dist/components/analytics-chart/analytics-chart.d.ts.map +1 -0
- package/dist/components/analytics-chart/analytics-chart.js +1021 -0
- package/dist/components/analytics-chart/analytics-chart.js.map +1 -0
- package/dist/components/analytics-chart/default-analytics-chart-tooltip.d.ts +66 -0
- package/dist/components/analytics-chart/default-analytics-chart-tooltip.d.ts.map +1 -0
- package/dist/components/analytics-chart/default-analytics-chart-tooltip.js +179 -0
- package/dist/components/analytics-chart/default-analytics-chart-tooltip.js.map +1 -0
- package/dist/components/analytics-chart/format.d.ts +13 -0
- package/dist/components/analytics-chart/format.d.ts.map +1 -0
- package/dist/components/analytics-chart/format.js +138 -0
- package/dist/components/analytics-chart/format.js.map +1 -0
- package/dist/components/analytics-chart/index.d.ts +8 -0
- package/dist/components/analytics-chart/index.js +184 -0
- package/dist/components/analytics-chart/palette.d.ts +15 -0
- package/dist/components/analytics-chart/palette.d.ts.map +1 -0
- package/dist/components/analytics-chart/palette.js +60 -0
- package/dist/components/analytics-chart/palette.js.map +1 -0
- package/dist/components/analytics-chart/render-data-series.d.ts +28 -0
- package/dist/components/analytics-chart/render-data-series.d.ts.map +1 -0
- package/dist/components/analytics-chart/render-data-series.js +109 -0
- package/dist/components/analytics-chart/render-data-series.js.map +1 -0
- package/dist/components/analytics-chart/state.d.ts +54 -0
- package/dist/components/analytics-chart/state.d.ts.map +1 -0
- package/dist/components/analytics-chart/state.js +142 -0
- package/dist/components/analytics-chart/state.js.map +1 -0
- package/dist/components/analytics-chart/strings.d.ts +33 -0
- package/dist/components/analytics-chart/strings.d.ts.map +1 -0
- package/dist/components/analytics-chart/strings.js +37 -0
- package/dist/components/analytics-chart/strings.js.map +1 -0
- package/dist/components/analytics-chart/types.d.ts +157 -0
- package/dist/components/analytics-chart/types.d.ts.map +1 -0
- package/dist/components/analytics-chart/types.js +21 -0
- package/dist/components/analytics-chart/types.js.map +1 -0
- package/dist/components/badge.d.ts +16 -0
- package/dist/components/badge.d.ts.map +1 -1
- package/dist/components/badge.js +16 -0
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.d.ts +15 -1
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +14 -0
- package/dist/components/button.js.map +1 -1
- package/dist/components/card.d.ts +28 -0
- package/dist/components/card.d.ts.map +1 -1
- package/dist/components/card.js +28 -0
- package/dist/components/card.js.map +1 -1
- package/dist/components/chart-card.d.ts +29 -0
- package/dist/components/chart-card.d.ts.map +1 -1
- package/dist/components/chart-card.js +29 -0
- package/dist/components/chart-card.js.map +1 -1
- package/dist/components/chart-legend.d.ts +1 -2
- package/dist/components/chart-legend.d.ts.map +1 -1
- package/dist/components/chart-legend.js +0 -4
- package/dist/components/chart-legend.js.map +1 -1
- package/dist/components/data-grid/data-grid-sizing.d.ts +11 -0
- package/dist/components/data-grid/data-grid-sizing.d.ts.map +1 -0
- package/dist/components/data-grid/data-grid-sizing.js +34 -0
- package/dist/components/data-grid/data-grid-sizing.js.map +1 -0
- package/dist/components/data-grid/data-grid-toolbar.d.ts +31 -0
- package/dist/components/data-grid/data-grid-toolbar.d.ts.map +1 -0
- package/dist/components/data-grid/data-grid-toolbar.js +226 -0
- package/dist/components/data-grid/data-grid-toolbar.js.map +1 -0
- package/dist/components/data-grid/data-grid.d.ts +233 -0
- package/dist/components/data-grid/data-grid.d.ts.map +1 -0
- package/dist/components/data-grid/data-grid.js +871 -0
- package/dist/components/data-grid/data-grid.js.map +1 -0
- package/dist/components/data-grid/index.d.ts +7 -0
- package/dist/components/data-grid/index.js +176 -0
- package/dist/components/data-grid/state.d.ts +91 -0
- package/dist/components/data-grid/state.d.ts.map +1 -0
- package/dist/components/data-grid/state.js +329 -0
- package/dist/components/data-grid/state.js.map +1 -0
- package/dist/components/data-grid/strings.d.ts +8 -0
- package/dist/components/data-grid/strings.d.ts.map +1 -0
- package/dist/components/data-grid/strings.js +42 -0
- package/dist/components/data-grid/strings.js.map +1 -0
- package/dist/components/data-grid/types.d.ts +242 -0
- package/dist/components/data-grid/types.d.ts.map +1 -0
- package/dist/components/data-grid/types.js +0 -0
- package/dist/components/data-grid/use-data-source.d.ts +79 -0
- package/dist/components/data-grid/use-data-source.d.ts.map +1 -0
- package/dist/components/data-grid/use-data-source.js +236 -0
- package/dist/components/data-grid/use-data-source.js.map +1 -0
- package/dist/components/empty-state.d.ts +16 -0
- package/dist/components/empty-state.d.ts.map +1 -1
- package/dist/components/empty-state.js +16 -0
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/metric-card.d.ts +24 -0
- package/dist/components/metric-card.d.ts.map +1 -1
- package/dist/components/metric-card.js +24 -0
- package/dist/components/metric-card.js.map +1 -1
- package/dist/components/progress-bar.d.ts +10 -0
- package/dist/components/progress-bar.d.ts.map +1 -1
- package/dist/components/progress-bar.js +10 -0
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/separator.d.ts +9 -0
- package/dist/components/separator.d.ts.map +1 -1
- package/dist/components/separator.js +9 -0
- package/dist/components/separator.js.map +1 -1
- package/dist/components/skeleton.d.ts +12 -0
- package/dist/components/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton.js +12 -0
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/table.d.ts +25 -0
- package/dist/components/table.d.ts.map +1 -1
- package/dist/components/table.js +25 -0
- package/dist/components/table.js.map +1 -1
- package/dist/dashboard-ui-components.global.js +8562 -2857
- package/dist/dashboard-ui-components.global.js.map +4 -4
- package/dist/esm/components/analytics-chart/analytics-chart-pie.d.ts +67 -0
- package/dist/esm/components/analytics-chart/analytics-chart-pie.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/analytics-chart-pie.js +251 -0
- package/dist/esm/components/analytics-chart/analytics-chart-pie.js.map +1 -0
- package/dist/esm/components/analytics-chart/analytics-chart.d.ts +554 -0
- package/dist/esm/components/analytics-chart/analytics-chart.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/analytics-chart.js +1019 -0
- package/dist/esm/components/analytics-chart/analytics-chart.js.map +1 -0
- package/dist/esm/components/analytics-chart/default-analytics-chart-tooltip.d.ts +66 -0
- package/dist/esm/components/analytics-chart/default-analytics-chart-tooltip.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/default-analytics-chart-tooltip.js +176 -0
- package/dist/esm/components/analytics-chart/default-analytics-chart-tooltip.js.map +1 -0
- package/dist/esm/components/analytics-chart/format.d.ts +13 -0
- package/dist/esm/components/analytics-chart/format.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/format.js +133 -0
- package/dist/esm/components/analytics-chart/format.js.map +1 -0
- package/dist/esm/components/analytics-chart/index.d.ts +8 -0
- package/dist/esm/components/analytics-chart/index.js +9 -0
- package/dist/esm/components/analytics-chart/palette.d.ts +15 -0
- package/dist/esm/components/analytics-chart/palette.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/palette.js +55 -0
- package/dist/esm/components/analytics-chart/palette.js.map +1 -0
- package/dist/esm/components/analytics-chart/render-data-series.d.ts +28 -0
- package/dist/esm/components/analytics-chart/render-data-series.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/render-data-series.js +107 -0
- package/dist/esm/components/analytics-chart/render-data-series.js.map +1 -0
- package/dist/esm/components/analytics-chart/state.d.ts +54 -0
- package/dist/esm/components/analytics-chart/state.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/state.js +126 -0
- package/dist/esm/components/analytics-chart/state.js.map +1 -0
- package/dist/esm/components/analytics-chart/strings.d.ts +33 -0
- package/dist/esm/components/analytics-chart/strings.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/strings.js +34 -0
- package/dist/esm/components/analytics-chart/strings.js.map +1 -0
- package/dist/esm/components/analytics-chart/types.d.ts +157 -0
- package/dist/esm/components/analytics-chart/types.d.ts.map +1 -0
- package/dist/esm/components/analytics-chart/types.js +18 -0
- package/dist/esm/components/analytics-chart/types.js.map +1 -0
- package/dist/esm/components/badge.d.ts +16 -0
- package/dist/esm/components/badge.d.ts.map +1 -1
- package/dist/esm/components/badge.js +16 -0
- package/dist/esm/components/badge.js.map +1 -1
- package/dist/esm/components/button.d.ts +14 -0
- package/dist/esm/components/button.d.ts.map +1 -1
- package/dist/esm/components/button.js +14 -0
- package/dist/esm/components/button.js.map +1 -1
- package/dist/esm/components/card.d.ts +28 -0
- package/dist/esm/components/card.d.ts.map +1 -1
- package/dist/esm/components/card.js +28 -0
- package/dist/esm/components/card.js.map +1 -1
- package/dist/esm/components/chart-card.d.ts +29 -0
- package/dist/esm/components/chart-card.d.ts.map +1 -1
- package/dist/esm/components/chart-card.js +29 -0
- package/dist/esm/components/chart-card.js.map +1 -1
- package/dist/esm/components/chart-legend.d.ts +1 -2
- package/dist/esm/components/chart-legend.d.ts.map +1 -1
- package/dist/esm/components/chart-legend.js +1 -3
- package/dist/esm/components/chart-legend.js.map +1 -1
- package/dist/esm/components/data-grid/data-grid-sizing.d.ts +11 -0
- package/dist/esm/components/data-grid/data-grid-sizing.d.ts.map +1 -0
- package/dist/esm/components/data-grid/data-grid-sizing.js +29 -0
- package/dist/esm/components/data-grid/data-grid-sizing.js.map +1 -0
- package/dist/esm/components/data-grid/data-grid-toolbar.d.ts +31 -0
- package/dist/esm/components/data-grid/data-grid-toolbar.d.ts.map +1 -0
- package/dist/esm/components/data-grid/data-grid-toolbar.js +223 -0
- package/dist/esm/components/data-grid/data-grid-toolbar.js.map +1 -0
- package/dist/esm/components/data-grid/data-grid.d.ts +233 -0
- package/dist/esm/components/data-grid/data-grid.d.ts.map +1 -0
- package/dist/esm/components/data-grid/data-grid.js +868 -0
- package/dist/esm/components/data-grid/data-grid.js.map +1 -0
- package/dist/esm/components/data-grid/index.d.ts +7 -0
- package/dist/esm/components/data-grid/index.js +7 -0
- package/dist/esm/components/data-grid/state.d.ts +91 -0
- package/dist/esm/components/data-grid/state.d.ts.map +1 -0
- package/dist/esm/components/data-grid/state.js +305 -0
- package/dist/esm/components/data-grid/state.js.map +1 -0
- package/dist/esm/components/data-grid/strings.d.ts +8 -0
- package/dist/esm/components/data-grid/strings.d.ts.map +1 -0
- package/dist/esm/components/data-grid/strings.js +39 -0
- package/dist/esm/components/data-grid/strings.js.map +1 -0
- package/dist/esm/components/data-grid/types.d.ts +242 -0
- package/dist/esm/components/data-grid/types.d.ts.map +1 -0
- package/dist/esm/components/data-grid/types.js +1 -0
- package/dist/esm/components/data-grid/use-data-source.d.ts +79 -0
- package/dist/esm/components/data-grid/use-data-source.d.ts.map +1 -0
- package/dist/esm/components/data-grid/use-data-source.js +234 -0
- package/dist/esm/components/data-grid/use-data-source.js.map +1 -0
- package/dist/esm/components/empty-state.d.ts +16 -0
- package/dist/esm/components/empty-state.d.ts.map +1 -1
- package/dist/esm/components/empty-state.js +16 -0
- package/dist/esm/components/empty-state.js.map +1 -1
- package/dist/esm/components/metric-card.d.ts +24 -0
- package/dist/esm/components/metric-card.d.ts.map +1 -1
- package/dist/esm/components/metric-card.js +24 -0
- package/dist/esm/components/metric-card.js.map +1 -1
- package/dist/esm/components/progress-bar.d.ts +10 -0
- package/dist/esm/components/progress-bar.d.ts.map +1 -1
- package/dist/esm/components/progress-bar.js +10 -0
- package/dist/esm/components/progress-bar.js.map +1 -1
- package/dist/esm/components/separator.d.ts +9 -0
- package/dist/esm/components/separator.d.ts.map +1 -1
- package/dist/esm/components/separator.js +9 -0
- package/dist/esm/components/separator.js.map +1 -1
- package/dist/esm/components/skeleton.d.ts +12 -0
- package/dist/esm/components/skeleton.d.ts.map +1 -1
- package/dist/esm/components/skeleton.js +12 -0
- package/dist/esm/components/skeleton.js.map +1 -1
- package/dist/esm/components/table.d.ts +25 -0
- package/dist/esm/components/table.d.ts.map +1 -1
- package/dist/esm/components/table.js +25 -0
- package/dist/esm/components/table.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +6 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +16 -7
- package/package.json +4 -3
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chunk = require('../../chunk-BE-pF4vm.js');
|
|
3
|
+
let _stackframe_stack_shared_dist_utils_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
4
|
+
|
|
5
|
+
//#region src/components/data-grid/state.ts
|
|
6
|
+
const EMPTY_SORT_MODEL = [];
|
|
7
|
+
const EMPTY_SELECTION = {
|
|
8
|
+
selectedIds: /* @__PURE__ */ new Set(),
|
|
9
|
+
anchorId: null
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_PAGINATION = {
|
|
12
|
+
pageIndex: 0,
|
|
13
|
+
pageSize: 50
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Build the initial `DataGridState` for a set of columns. Pass this as the
|
|
17
|
+
* lazy initializer to `useState` — NEVER hand-assemble the state object.
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const [gridState, setGridState] = React.useState(() =>
|
|
21
|
+
* createDefaultDataGridState(columns)
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `columns` must be defined BEFORE this call (obvious, but a common TDZ
|
|
26
|
+
* mistake: if you declare columns after the `useState`, you'll crash on
|
|
27
|
+
* the first render). Keep the columns reference stable across renders
|
|
28
|
+
* (define them outside the component or wrap in `React.useMemo`).
|
|
29
|
+
*/
|
|
30
|
+
function createDefaultDataGridState(columns) {
|
|
31
|
+
const columnWidths = {};
|
|
32
|
+
const columnOrder = [];
|
|
33
|
+
for (const col of columns) {
|
|
34
|
+
columnWidths[col.id] = col.width ?? 150;
|
|
35
|
+
columnOrder.push(col.id);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
sorting: EMPTY_SORT_MODEL,
|
|
39
|
+
columnVisibility: {},
|
|
40
|
+
columnWidths,
|
|
41
|
+
columnPinning: {
|
|
42
|
+
left: [],
|
|
43
|
+
right: []
|
|
44
|
+
},
|
|
45
|
+
columnOrder,
|
|
46
|
+
pagination: DEFAULT_PAGINATION,
|
|
47
|
+
selection: EMPTY_SELECTION,
|
|
48
|
+
dateDisplay: "relative",
|
|
49
|
+
quickSearch: ""
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function resolveColumnValue(col, row) {
|
|
53
|
+
if (typeof col.accessor === "function") return col.accessor(row);
|
|
54
|
+
return row[col.accessor ?? col.id];
|
|
55
|
+
}
|
|
56
|
+
function resolveColumnWidth(col, storedWidth) {
|
|
57
|
+
return storedWidth ?? col.width ?? 150;
|
|
58
|
+
}
|
|
59
|
+
function isColumnVisible(columnId, visibility) {
|
|
60
|
+
return visibility[columnId] !== false;
|
|
61
|
+
}
|
|
62
|
+
function toggleSort(model, columnId, multiSort) {
|
|
63
|
+
const existing = model.find((s) => s.columnId === columnId);
|
|
64
|
+
if (!existing) {
|
|
65
|
+
const item = {
|
|
66
|
+
columnId,
|
|
67
|
+
direction: "asc"
|
|
68
|
+
};
|
|
69
|
+
return multiSort ? [...model, item] : [item];
|
|
70
|
+
}
|
|
71
|
+
if (existing.direction === "asc") {
|
|
72
|
+
const updated = {
|
|
73
|
+
columnId,
|
|
74
|
+
direction: "desc"
|
|
75
|
+
};
|
|
76
|
+
return model.map((s) => s.columnId === columnId ? updated : s);
|
|
77
|
+
}
|
|
78
|
+
return model.filter((s) => s.columnId !== columnId);
|
|
79
|
+
}
|
|
80
|
+
function getSortDirection(model, columnId) {
|
|
81
|
+
const item = model.find((s) => s.columnId === columnId);
|
|
82
|
+
return item ? item.direction : false;
|
|
83
|
+
}
|
|
84
|
+
function getSortIndex(model, columnId) {
|
|
85
|
+
if (model.length <= 1) return null;
|
|
86
|
+
const idx = model.findIndex((s) => s.columnId === columnId);
|
|
87
|
+
return idx >= 0 ? idx + 1 : null;
|
|
88
|
+
}
|
|
89
|
+
function defaultComparator(a, b) {
|
|
90
|
+
if (a == null && b == null) return 0;
|
|
91
|
+
if (a == null) return -1;
|
|
92
|
+
if (b == null) return 1;
|
|
93
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
94
|
+
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
95
|
+
return (0, _stackframe_stack_shared_dist_utils_strings.stringCompare)(String(a), String(b));
|
|
96
|
+
}
|
|
97
|
+
function buildRowComparator(sortModel, columns) {
|
|
98
|
+
if (sortModel.length === 0) return null;
|
|
99
|
+
const colMap = new Map(columns.map((c) => [c.id, c]));
|
|
100
|
+
return (a, b) => {
|
|
101
|
+
for (const { columnId, direction } of sortModel) {
|
|
102
|
+
const col = colMap.get(columnId);
|
|
103
|
+
if (!col) continue;
|
|
104
|
+
const va = resolveColumnValue(col, a);
|
|
105
|
+
const vb = resolveColumnValue(col, b);
|
|
106
|
+
const cmp = col.sortComparator ? col.sortComparator(va, vb) : defaultComparator(va, vb);
|
|
107
|
+
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
108
|
+
}
|
|
109
|
+
return 0;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function paginateRows(rows, pagination) {
|
|
113
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
114
|
+
return rows.slice(start, start + pagination.pageSize);
|
|
115
|
+
}
|
|
116
|
+
function getTotalPages(totalRows, pageSize) {
|
|
117
|
+
return Math.max(1, Math.ceil(totalRows / pageSize));
|
|
118
|
+
}
|
|
119
|
+
function toggleRowSelection(selection, rowId, mode, shiftKey, ctrlKey, allRowIds) {
|
|
120
|
+
if (mode === "single") {
|
|
121
|
+
const isSelected = selection.selectedIds.has(rowId);
|
|
122
|
+
return {
|
|
123
|
+
selectedIds: isSelected ? /* @__PURE__ */ new Set() : new Set([rowId]),
|
|
124
|
+
anchorId: isSelected ? null : rowId
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (shiftKey && selection.anchorId != null) {
|
|
128
|
+
const anchorIdx = allRowIds.indexOf(selection.anchorId);
|
|
129
|
+
const currentIdx = allRowIds.indexOf(rowId);
|
|
130
|
+
if (anchorIdx >= 0 && currentIdx >= 0) {
|
|
131
|
+
const start = Math.min(anchorIdx, currentIdx);
|
|
132
|
+
const end = Math.max(anchorIdx, currentIdx);
|
|
133
|
+
const rangeIds = allRowIds.slice(start, end + 1);
|
|
134
|
+
const next = ctrlKey ? new Set(selection.selectedIds) : /* @__PURE__ */ new Set();
|
|
135
|
+
for (const id of rangeIds) next.add(id);
|
|
136
|
+
return {
|
|
137
|
+
selectedIds: next,
|
|
138
|
+
anchorId: selection.anchorId
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (ctrlKey) {
|
|
143
|
+
const next = new Set(selection.selectedIds);
|
|
144
|
+
if (next.has(rowId)) next.delete(rowId);
|
|
145
|
+
else next.add(rowId);
|
|
146
|
+
return {
|
|
147
|
+
selectedIds: next,
|
|
148
|
+
anchorId: rowId
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
selectedIds: new Set([rowId]),
|
|
153
|
+
anchorId: rowId
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function selectAll(allRowIds) {
|
|
157
|
+
return {
|
|
158
|
+
selectedIds: new Set(allRowIds),
|
|
159
|
+
anchorId: null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function clearSelection() {
|
|
163
|
+
return EMPTY_SELECTION;
|
|
164
|
+
}
|
|
165
|
+
/** Default row matcher used by `applyQuickSearch`. Case-insensitive
|
|
166
|
+
* substring match across every column's resolved cell value. Columns
|
|
167
|
+
* with `null` / `undefined` values are skipped. The query is expected
|
|
168
|
+
* to be pre-trimmed and lowercased by `applyQuickSearch` — this helper
|
|
169
|
+
* does NOT trim or lowercase it again, so if you wire it up yourself,
|
|
170
|
+
* do that first. */
|
|
171
|
+
function defaultMatchRow(row, query, columns) {
|
|
172
|
+
for (const col of columns) {
|
|
173
|
+
const v = resolveColumnValue(col, row);
|
|
174
|
+
if (v == null) continue;
|
|
175
|
+
if (String(v).toLowerCase().includes(query)) return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
/** Client-side quick-search filter. Returns the original array
|
|
180
|
+
* reference when `query` is empty, so calling this in a hot `useMemo`
|
|
181
|
+
* is cheap in the common "no search" case.
|
|
182
|
+
*
|
|
183
|
+
* Used by `useDataSource` in client mode. Exported so consumers driving
|
|
184
|
+
* the grid manually (or doing their own pre-filtering before feeding
|
|
185
|
+
* rows to an async data source) can stay consistent with the built-in
|
|
186
|
+
* search behaviour.
|
|
187
|
+
*
|
|
188
|
+
* Override `matchRow` for custom matching logic — e.g. fuzzy matching,
|
|
189
|
+
* field-specific weighting, or skipping some columns. */
|
|
190
|
+
function applyQuickSearch(rows, query, columns, matchRow = defaultMatchRow) {
|
|
191
|
+
const trimmed = query.trim().toLowerCase();
|
|
192
|
+
if (!trimmed) return rows;
|
|
193
|
+
return rows.filter((r) => matchRow(r, trimmed, columns));
|
|
194
|
+
}
|
|
195
|
+
/** Parse a raw cell value into a `Date`. Returns `null` for nullish,
|
|
196
|
+
* unparseable, or invalid dates. Accepts strings (including ISO and
|
|
197
|
+
* "YYYY-MM-DD HH:MM:SS"-style ClickHouse output), numbers (ms since
|
|
198
|
+
* epoch), and `Date` instances. For truly weird formats, override via
|
|
199
|
+
* `col.parseValue`. */
|
|
200
|
+
function defaultParseDate(value) {
|
|
201
|
+
if (value == null) return null;
|
|
202
|
+
if (value instanceof Date) return isNaN(value.getTime()) ? null : value;
|
|
203
|
+
if (typeof value === "number") {
|
|
204
|
+
const d = new Date(value);
|
|
205
|
+
return isNaN(d.getTime()) ? null : d;
|
|
206
|
+
}
|
|
207
|
+
if (typeof value === "string") {
|
|
208
|
+
const d = new Date(value);
|
|
209
|
+
return isNaN(d.getTime()) ? null : d;
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const DIVISIONS = [
|
|
214
|
+
{
|
|
215
|
+
amount: 60,
|
|
216
|
+
unit: "second"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
amount: 60,
|
|
220
|
+
unit: "minute"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
amount: 24,
|
|
224
|
+
unit: "hour"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
amount: 7,
|
|
228
|
+
unit: "day"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
amount: 4.34524,
|
|
232
|
+
unit: "week"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
amount: 12,
|
|
236
|
+
unit: "month"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
amount: Number.POSITIVE_INFINITY,
|
|
240
|
+
unit: "year"
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
/** Default relative formatter — "1 day ago" / "in 2 hours" via
|
|
244
|
+
* `Intl.RelativeTimeFormat`. Pure function of the date; does NOT
|
|
245
|
+
* re-render as real time passes. */
|
|
246
|
+
function defaultFormatRelative(date) {
|
|
247
|
+
const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
248
|
+
let duration = (date.getTime() - Date.now()) / 1e3;
|
|
249
|
+
for (const div of DIVISIONS) {
|
|
250
|
+
if (Math.abs(duration) < div.amount) return rtf.format(Math.round(duration), div.unit);
|
|
251
|
+
duration /= div.amount;
|
|
252
|
+
}
|
|
253
|
+
return rtf.format(Math.round(duration), "year");
|
|
254
|
+
}
|
|
255
|
+
/** Default absolute formatter — full locale date + time. */
|
|
256
|
+
function defaultFormatAbsolute(date) {
|
|
257
|
+
return date.toLocaleString();
|
|
258
|
+
}
|
|
259
|
+
/** Format a raw cell value for display in a `date` / `dateTime` column.
|
|
260
|
+
* Returns both the inline display string and the tooltip string (which
|
|
261
|
+
* is always the absolute form so users can read the exact datetime).
|
|
262
|
+
*
|
|
263
|
+
* Used internally by the grid's default date cell renderer, and exported
|
|
264
|
+
* so consumers writing a custom `renderCell` for a date column can stay
|
|
265
|
+
* visually consistent with the built-in behaviour.
|
|
266
|
+
*
|
|
267
|
+
* ```tsx
|
|
268
|
+
* renderCell: ({ value, dateDisplay }) => {
|
|
269
|
+
* const { display, tooltip } = formatGridDate(value, dateDisplay);
|
|
270
|
+
* if (!display) return <span className="text-muted-foreground/40">—</span>;
|
|
271
|
+
* return <span title={tooltip ?? undefined}>{display}</span>;
|
|
272
|
+
* }
|
|
273
|
+
* ``` */
|
|
274
|
+
function formatGridDate(value, mode, opts) {
|
|
275
|
+
const date = (opts?.parseValue ?? defaultParseDate)(value);
|
|
276
|
+
if (!date) return {
|
|
277
|
+
display: null,
|
|
278
|
+
tooltip: null
|
|
279
|
+
};
|
|
280
|
+
const relative = opts?.dateFormat?.relative ?? defaultFormatRelative;
|
|
281
|
+
const tooltip = (opts?.dateFormat?.absolute ?? defaultFormatAbsolute)(date);
|
|
282
|
+
return {
|
|
283
|
+
display: mode === "relative" ? relative(date) : tooltip,
|
|
284
|
+
tooltip
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function exportToCsv(rows, columns, filename) {
|
|
288
|
+
const header = columns.map((col) => typeof col.header === "string" ? col.header : col.id);
|
|
289
|
+
const csvRows = rows.map((row) => columns.map((col) => {
|
|
290
|
+
const val = resolveColumnValue(col, row);
|
|
291
|
+
const formatted = col.formatValue ? col.formatValue(val, row) : String(val ?? "");
|
|
292
|
+
if (formatted.includes(",") || formatted.includes("\"") || formatted.includes("\n")) return `"${formatted.replace(/"/g, "\"\"")}"`;
|
|
293
|
+
return formatted;
|
|
294
|
+
}));
|
|
295
|
+
const csvContent = [header.join(","), ...csvRows.map((row) => row.join(","))].join("\n");
|
|
296
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
297
|
+
const url = URL.createObjectURL(blob);
|
|
298
|
+
const link = document.createElement("a");
|
|
299
|
+
link.href = url;
|
|
300
|
+
link.download = `${filename}.csv`;
|
|
301
|
+
link.click();
|
|
302
|
+
URL.revokeObjectURL(url);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
//#endregion
|
|
306
|
+
exports.DEFAULT_PAGINATION = DEFAULT_PAGINATION;
|
|
307
|
+
exports.EMPTY_SELECTION = EMPTY_SELECTION;
|
|
308
|
+
exports.EMPTY_SORT_MODEL = EMPTY_SORT_MODEL;
|
|
309
|
+
exports.applyQuickSearch = applyQuickSearch;
|
|
310
|
+
exports.buildRowComparator = buildRowComparator;
|
|
311
|
+
exports.clearSelection = clearSelection;
|
|
312
|
+
exports.createDefaultDataGridState = createDefaultDataGridState;
|
|
313
|
+
exports.defaultFormatAbsolute = defaultFormatAbsolute;
|
|
314
|
+
exports.defaultFormatRelative = defaultFormatRelative;
|
|
315
|
+
exports.defaultMatchRow = defaultMatchRow;
|
|
316
|
+
exports.defaultParseDate = defaultParseDate;
|
|
317
|
+
exports.exportToCsv = exportToCsv;
|
|
318
|
+
exports.formatGridDate = formatGridDate;
|
|
319
|
+
exports.getSortDirection = getSortDirection;
|
|
320
|
+
exports.getSortIndex = getSortIndex;
|
|
321
|
+
exports.getTotalPages = getTotalPages;
|
|
322
|
+
exports.isColumnVisible = isColumnVisible;
|
|
323
|
+
exports.paginateRows = paginateRows;
|
|
324
|
+
exports.resolveColumnValue = resolveColumnValue;
|
|
325
|
+
exports.resolveColumnWidth = resolveColumnWidth;
|
|
326
|
+
exports.selectAll = selectAll;
|
|
327
|
+
exports.toggleRowSelection = toggleRowSelection;
|
|
328
|
+
exports.toggleSort = toggleSort;
|
|
329
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../../src/components/data-grid/state.ts"],"sourcesContent":["import { stringCompare } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport type {\n DataGridColumnDef,\n DataGridDateDisplay,\n DataGridDateFormat,\n DataGridPaginationModel,\n DataGridSelectionModel,\n DataGridSortModel,\n DataGridState,\n} from \"./types\";\n\n// ─── Default state ───────────────────────────────────────────────────\n\nexport const EMPTY_SORT_MODEL: DataGridSortModel = [];\nexport const EMPTY_SELECTION: DataGridSelectionModel = {\n selectedIds: new Set(),\n anchorId: null,\n};\nexport const DEFAULT_PAGINATION: DataGridPaginationModel = {\n pageIndex: 0,\n pageSize: 50,\n};\n\n/**\n * Build the initial `DataGridState` for a set of columns. Pass this as the\n * lazy initializer to `useState` — NEVER hand-assemble the state object.\n *\n * ```tsx\n * const [gridState, setGridState] = React.useState(() =>\n * createDefaultDataGridState(columns)\n * );\n * ```\n *\n * `columns` must be defined BEFORE this call (obvious, but a common TDZ\n * mistake: if you declare columns after the `useState`, you'll crash on\n * the first render). Keep the columns reference stable across renders\n * (define them outside the component or wrap in `React.useMemo`).\n */\nexport function createDefaultDataGridState(\n columns: readonly DataGridColumnDef<any>[],\n): DataGridState {\n const columnWidths: Record<string, number> = {};\n const columnOrder: string[] = [];\n\n for (const col of columns) {\n columnWidths[col.id] = col.width ?? 150;\n columnOrder.push(col.id);\n }\n\n return {\n sorting: EMPTY_SORT_MODEL,\n columnVisibility: {},\n columnWidths,\n columnPinning: { left: [], right: [] },\n columnOrder,\n pagination: DEFAULT_PAGINATION,\n selection: EMPTY_SELECTION,\n dateDisplay: \"relative\",\n quickSearch: \"\",\n };\n}\n\n// ─── Column helpers ──────────────────────────────────────────────────\n\nexport function resolveColumnValue<TRow>(\n col: DataGridColumnDef<TRow>,\n row: TRow,\n): unknown {\n if (typeof col.accessor === \"function\") return col.accessor(row);\n const key = (col.accessor ?? col.id) as keyof TRow;\n return row[key];\n}\n\nexport function resolveColumnWidth(\n col: DataGridColumnDef<any>,\n storedWidth: number | undefined,\n): number {\n return storedWidth ?? col.width ?? 150;\n}\n\nexport function isColumnVisible(\n columnId: string,\n visibility: Record<string, boolean>,\n): boolean {\n return visibility[columnId] !== false;\n}\n\n// ─── Sort helpers ────────────────────────────────────────────────────\n\nexport function toggleSort(\n model: DataGridSortModel,\n columnId: string,\n multiSort: boolean,\n): DataGridSortModel {\n const existing = model.find((s) => s.columnId === columnId);\n\n if (!existing) {\n const item = { columnId, direction: \"asc\" as const };\n return multiSort ? [...model, item] : [item];\n }\n\n if (existing.direction === \"asc\") {\n const updated = { columnId, direction: \"desc\" as const };\n return model.map((s) => (s.columnId === columnId ? updated : s));\n }\n\n // desc → remove\n return model.filter((s) => s.columnId !== columnId);\n}\n\nexport function getSortDirection(\n model: DataGridSortModel,\n columnId: string,\n): false | \"asc\" | \"desc\" {\n const item = model.find((s) => s.columnId === columnId);\n return item ? item.direction : false;\n}\n\nexport function getSortIndex(\n model: DataGridSortModel,\n columnId: string,\n): number | null {\n if (model.length <= 1) return null;\n const idx = model.findIndex((s) => s.columnId === columnId);\n return idx >= 0 ? idx + 1 : null;\n}\n\n// ─── Default sort comparator ─────────────────────────────────────────\n\nfunction defaultComparator(a: unknown, b: unknown): number {\n if (a == null && b == null) return 0;\n if (a == null) return -1;\n if (b == null) return 1;\n\n if (typeof a === \"number\" && typeof b === \"number\") return a - b;\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();\n return stringCompare(String(a), String(b));\n}\n\nexport function buildRowComparator<TRow>(\n sortModel: DataGridSortModel,\n columns: readonly DataGridColumnDef<TRow>[],\n): ((a: TRow, b: TRow) => number) | null {\n if (sortModel.length === 0) return null;\n\n const colMap = new Map(columns.map((c) => [c.id, c]));\n\n return (a, b) => {\n for (const { columnId, direction } of sortModel) {\n const col = colMap.get(columnId);\n if (!col) continue;\n\n const va = resolveColumnValue(col, a);\n const vb = resolveColumnValue(col, b);\n const cmp = col.sortComparator\n ? col.sortComparator(va, vb)\n : defaultComparator(va, vb);\n if (cmp !== 0) return direction === \"asc\" ? cmp : -cmp;\n }\n return 0;\n };\n}\n\n// ─── Pagination helpers ──────────────────────────────────────────────\n\nexport function paginateRows<TRow>(\n rows: readonly TRow[],\n pagination: DataGridPaginationModel,\n): TRow[] {\n const start = pagination.pageIndex * pagination.pageSize;\n return rows.slice(start, start + pagination.pageSize) as TRow[];\n}\n\nexport function getTotalPages(\n totalRows: number,\n pageSize: number,\n): number {\n return Math.max(1, Math.ceil(totalRows / pageSize));\n}\n\n// ─── Selection helpers ───────────────────────────────────────────────\n\nexport function toggleRowSelection(\n selection: DataGridSelectionModel,\n rowId: string,\n mode: \"single\" | \"multiple\",\n shiftKey: boolean,\n ctrlKey: boolean,\n allRowIds: readonly string[],\n): DataGridSelectionModel {\n if (mode === \"single\") {\n const isSelected = selection.selectedIds.has(rowId);\n return {\n selectedIds: isSelected ? new Set() : new Set([rowId]),\n anchorId: isSelected ? null : rowId,\n };\n }\n\n // Multiple mode\n if (shiftKey && selection.anchorId != null) {\n const anchorIdx = allRowIds.indexOf(selection.anchorId);\n const currentIdx = allRowIds.indexOf(rowId);\n if (anchorIdx >= 0 && currentIdx >= 0) {\n const start = Math.min(anchorIdx, currentIdx);\n const end = Math.max(anchorIdx, currentIdx);\n const rangeIds = allRowIds.slice(start, end + 1);\n\n const next = ctrlKey ? new Set(selection.selectedIds) : new Set<string>();\n for (const id of rangeIds) next.add(id);\n\n return { selectedIds: next, anchorId: selection.anchorId };\n }\n }\n\n if (ctrlKey) {\n // Toggle single in multi mode\n const next = new Set(selection.selectedIds);\n if (next.has(rowId)) {\n next.delete(rowId);\n } else {\n next.add(rowId);\n }\n return { selectedIds: next, anchorId: rowId };\n }\n\n // Plain click in multi mode — select only this row\n return {\n selectedIds: new Set([rowId]),\n anchorId: rowId,\n };\n}\n\nexport function selectAll(\n allRowIds: readonly string[],\n): DataGridSelectionModel {\n return {\n selectedIds: new Set(allRowIds),\n anchorId: null,\n };\n}\n\nexport function clearSelection(): DataGridSelectionModel {\n return EMPTY_SELECTION;\n}\n\n// ─── Quick search ────────────────────────────────────────────────────\n\n/** Default row matcher used by `applyQuickSearch`. Case-insensitive\n * substring match across every column's resolved cell value. Columns\n * with `null` / `undefined` values are skipped. The query is expected\n * to be pre-trimmed and lowercased by `applyQuickSearch` — this helper\n * does NOT trim or lowercase it again, so if you wire it up yourself,\n * do that first. */\nexport function defaultMatchRow<TRow>(\n row: TRow,\n query: string,\n columns: readonly DataGridColumnDef<TRow>[],\n): boolean {\n for (const col of columns) {\n const v = resolveColumnValue(col, row);\n if (v == null) continue;\n if (String(v).toLowerCase().includes(query)) return true;\n }\n return false;\n}\n\n/** Client-side quick-search filter. Returns the original array\n * reference when `query` is empty, so calling this in a hot `useMemo`\n * is cheap in the common \"no search\" case.\n *\n * Used by `useDataSource` in client mode. Exported so consumers driving\n * the grid manually (or doing their own pre-filtering before feeding\n * rows to an async data source) can stay consistent with the built-in\n * search behaviour.\n *\n * Override `matchRow` for custom matching logic — e.g. fuzzy matching,\n * field-specific weighting, or skipping some columns. */\nexport function applyQuickSearch<TRow>(\n rows: readonly TRow[],\n query: string,\n columns: readonly DataGridColumnDef<TRow>[],\n matchRow: (\n row: TRow,\n query: string,\n columns: readonly DataGridColumnDef<TRow>[],\n ) => boolean = defaultMatchRow,\n): readonly TRow[] {\n const trimmed = query.trim().toLowerCase();\n if (!trimmed) return rows;\n return rows.filter((r) => matchRow(r, trimmed, columns));\n}\n\n// ─── Date helpers ────────────────────────────────────────────────────\n\n/** Parse a raw cell value into a `Date`. Returns `null` for nullish,\n * unparseable, or invalid dates. Accepts strings (including ISO and\n * \"YYYY-MM-DD HH:MM:SS\"-style ClickHouse output), numbers (ms since\n * epoch), and `Date` instances. For truly weird formats, override via\n * `col.parseValue`. */\nexport function defaultParseDate(value: unknown): Date | null {\n if (value == null) return null;\n if (value instanceof Date) return isNaN(value.getTime()) ? null : value;\n if (typeof value === \"number\") {\n const d = new Date(value);\n return isNaN(d.getTime()) ? null : d;\n }\n if (typeof value === \"string\") {\n const d = new Date(value);\n return isNaN(d.getTime()) ? null : d;\n }\n return null;\n}\n\nconst DIVISIONS: Array<{ amount: number; unit: Intl.RelativeTimeFormatUnit }> = [\n { amount: 60, unit: \"second\" },\n { amount: 60, unit: \"minute\" },\n { amount: 24, unit: \"hour\" },\n { amount: 7, unit: \"day\" },\n { amount: 4.34524, unit: \"week\" },\n { amount: 12, unit: \"month\" },\n { amount: Number.POSITIVE_INFINITY, unit: \"year\" },\n];\n\n/** Default relative formatter — \"1 day ago\" / \"in 2 hours\" via\n * `Intl.RelativeTimeFormat`. Pure function of the date; does NOT\n * re-render as real time passes. */\nexport function defaultFormatRelative(date: Date): string {\n const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: \"auto\" });\n let duration = (date.getTime() - Date.now()) / 1000;\n for (const div of DIVISIONS) {\n if (Math.abs(duration) < div.amount) {\n return rtf.format(Math.round(duration), div.unit);\n }\n duration /= div.amount;\n }\n return rtf.format(Math.round(duration), \"year\");\n}\n\n/** Default absolute formatter — full locale date + time. */\nexport function defaultFormatAbsolute(date: Date): string {\n return date.toLocaleString();\n}\n\n/** Format a raw cell value for display in a `date` / `dateTime` column.\n * Returns both the inline display string and the tooltip string (which\n * is always the absolute form so users can read the exact datetime).\n *\n * Used internally by the grid's default date cell renderer, and exported\n * so consumers writing a custom `renderCell` for a date column can stay\n * visually consistent with the built-in behaviour.\n *\n * ```tsx\n * renderCell: ({ value, dateDisplay }) => {\n * const { display, tooltip } = formatGridDate(value, dateDisplay);\n * if (!display) return <span className=\"text-muted-foreground/40\">—</span>;\n * return <span title={tooltip ?? undefined}>{display}</span>;\n * }\n * ``` */\nexport function formatGridDate(\n value: unknown,\n mode: DataGridDateDisplay,\n opts?: {\n parseValue?: (value: unknown) => Date | null;\n dateFormat?: DataGridDateFormat;\n },\n): { display: string | null; tooltip: string | null } {\n const parse = opts?.parseValue ?? defaultParseDate;\n const date = parse(value);\n if (!date) return { display: null, tooltip: null };\n\n const relative = opts?.dateFormat?.relative ?? defaultFormatRelative;\n const absolute = opts?.dateFormat?.absolute ?? defaultFormatAbsolute;\n\n const tooltip = absolute(date);\n const display = mode === \"relative\" ? relative(date) : tooltip;\n return { display, tooltip };\n}\n\n// ─── CSV Export ──────────────────────────────────────────────────────\n\nexport function exportToCsv<TRow>(\n rows: readonly TRow[],\n columns: readonly DataGridColumnDef<TRow>[],\n filename: string,\n): void {\n const header = columns.map((col) =>\n typeof col.header === \"string\" ? col.header : col.id,\n );\n\n const csvRows = rows.map((row) =>\n columns.map((col) => {\n const val = resolveColumnValue(col, row);\n const formatted = col.formatValue ? col.formatValue(val, row) : String(val ?? \"\");\n // Escape CSV special characters\n if (formatted.includes(\",\") || formatted.includes('\"') || formatted.includes(\"\\n\")) {\n return `\"${formatted.replace(/\"/g, '\"\"')}\"`;\n }\n return formatted;\n }),\n );\n\n const csvContent = [\n header.join(\",\"),\n ...csvRows.map((row) => row.join(\",\")),\n ].join(\"\\n\");\n\n const blob = new Blob([csvContent], { type: \"text/csv;charset=utf-8;\" });\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n link.download = `${filename}.csv`;\n link.click();\n URL.revokeObjectURL(url);\n}\n"],"mappings":";;;;;AAaA,MAAa,mBAAsC,EAAE;AACrD,MAAa,kBAA0C;CACrD,6BAAa,IAAI,KAAK;CACtB,UAAU;CACX;AACD,MAAa,qBAA8C;CACzD,WAAW;CACX,UAAU;CACX;;;;;;;;;;;;;;;;AAiBD,SAAgB,2BACd,SACe;CACf,MAAM,eAAuC,EAAE;CAC/C,MAAM,cAAwB,EAAE;AAEhC,MAAK,MAAM,OAAO,SAAS;AACzB,eAAa,IAAI,MAAM,IAAI,SAAS;AACpC,cAAY,KAAK,IAAI,GAAG;;AAG1B,QAAO;EACL,SAAS;EACT,kBAAkB,EAAE;EACpB;EACA,eAAe;GAAE,MAAM,EAAE;GAAE,OAAO,EAAE;GAAE;EACtC;EACA,YAAY;EACZ,WAAW;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ACM;CACN,MAAM,SAAS,QAAQ,KAAK,QAC1B,OAAO,IAAI,WAAW,WAAW,IAAI,SAAS,IAAI,GACnD;CAED,MAAM,UAAU,KAAK,KAAK,QACxB,QAAQ,KAAK,QAAQ;EACnB,MAAM,MAAM,mBAAmB,KAAK,IAAI;EACxC,MAAM,YAAY,IAAI,cAAc,IAAI,YAAY,KAAK,IAAI,GAAG,OAAO,OAAO,GAAG;AAEjF,MAAI,UAAU,SAAS,IAAI,IAAI,UAAU,SAAS,KAAI,IAAI,UAAU,SAAS,KAAK,CAChF,QAAO,IAAI,UAAU,QAAQ,MAAM,OAAK,CAAC;AAE3C,SAAO;GACP,CACH;CAED,MAAM,aAAa,CACjB,OAAO,KAAK,IAAI,EAChB,GAAG,QAAQ,KAAK,QAAQ,IAAI,KAAK,IAAI,CAAC,CACvC,CAAC,KAAK,KAAK;CAEZ,MAAM,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,MAAM,2BAA2B,CAAC;CACxE,MAAM,MAAM,IAAI,gBAAgB,KAAK;CACrC,MAAM,OAAO,SAAS,cAAc,IAAI;AACxC,MAAK,OAAO;AACZ,MAAK,WAAW,GAAG,SAAS;AAC5B,MAAK,OAAO;AACZ,KAAI,gBAAgB,IAAI"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataGridStrings } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/data-grid/strings.d.ts
|
|
4
|
+
declare const DATA_GRID_DEFAULT_STRINGS: DataGridStrings;
|
|
5
|
+
declare function resolveDataGridStrings(override: Partial<DataGridStrings> | undefined): DataGridStrings;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { DATA_GRID_DEFAULT_STRINGS, resolveDataGridStrings };
|
|
8
|
+
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","names":[],"sources":["../../../src/components/data-grid/strings.ts"],"mappings":";;;cAEa,yBAAA,EAA2B,eAAA;AAAA,iBAqCxB,sBAAA,CACd,QAAA,EAAU,OAAA,CAAQ,eAAA,gBACjB,eAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/components/data-grid/strings.ts
|
|
4
|
+
const DATA_GRID_DEFAULT_STRINGS = {
|
|
5
|
+
searchPlaceholder: "Search…",
|
|
6
|
+
columns: "Columns",
|
|
7
|
+
export: "Export",
|
|
8
|
+
density: "Density",
|
|
9
|
+
showAll: "Show all",
|
|
10
|
+
hideAll: "Hide all",
|
|
11
|
+
resetColumns: "Reset",
|
|
12
|
+
dateFormat: "Date format",
|
|
13
|
+
dateFormatRelative: "Relative",
|
|
14
|
+
dateFormatAbsolute: "Absolute",
|
|
15
|
+
rowsSelected: (count) => `${count} row${count === 1 ? "" : "s"} selected`,
|
|
16
|
+
rowsPerPage: "Rows per page",
|
|
17
|
+
pageOf: (page, total) => `${page} of ${total}`,
|
|
18
|
+
noData: "No data",
|
|
19
|
+
loading: "Loading…",
|
|
20
|
+
loadingMore: "Loading more…",
|
|
21
|
+
exportCsv: "Export CSV",
|
|
22
|
+
exportCopied: "Copied!",
|
|
23
|
+
sortAsc: "Sort ascending",
|
|
24
|
+
sortDesc: "Sort descending",
|
|
25
|
+
unsort: "Remove sort",
|
|
26
|
+
pinLeft: "Pin left",
|
|
27
|
+
pinRight: "Pin right",
|
|
28
|
+
unpin: "Unpin",
|
|
29
|
+
hideColumn: "Hide column"
|
|
30
|
+
};
|
|
31
|
+
function resolveDataGridStrings(override) {
|
|
32
|
+
if (!override) return DATA_GRID_DEFAULT_STRINGS;
|
|
33
|
+
return {
|
|
34
|
+
...DATA_GRID_DEFAULT_STRINGS,
|
|
35
|
+
...override
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.DATA_GRID_DEFAULT_STRINGS = DATA_GRID_DEFAULT_STRINGS;
|
|
41
|
+
exports.resolveDataGridStrings = resolveDataGridStrings;
|
|
42
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.js","names":[],"sources":["../../../src/components/data-grid/strings.ts"],"sourcesContent":["import type { DataGridStrings } from \"./types\";\n\nexport const DATA_GRID_DEFAULT_STRINGS: DataGridStrings = {\n // toolbar\n searchPlaceholder: \"Search\\u2026\",\n columns: \"Columns\",\n export: \"Export\",\n density: \"Density\",\n // column manager\n showAll: \"Show all\",\n hideAll: \"Hide all\",\n resetColumns: \"Reset\",\n // date display\n dateFormat: \"Date format\",\n dateFormatRelative: \"Relative\",\n dateFormatAbsolute: \"Absolute\",\n // selection\n rowsSelected: (count) => `${count} row${count === 1 ? \"\" : \"s\"} selected`,\n // pagination\n rowsPerPage: \"Rows per page\",\n pageOf: (page, total) => `${page} of ${total}`,\n // empty / loading\n noData: \"No data\",\n loading: \"Loading\\u2026\",\n loadingMore: \"Loading more\\u2026\",\n // export\n exportCsv: \"Export CSV\",\n exportCopied: \"Copied!\",\n // sort\n sortAsc: \"Sort ascending\",\n sortDesc: \"Sort descending\",\n unsort: \"Remove sort\",\n // misc\n pinLeft: \"Pin left\",\n pinRight: \"Pin right\",\n unpin: \"Unpin\",\n hideColumn: \"Hide column\",\n};\n\nexport function resolveDataGridStrings(\n override: Partial<DataGridStrings> | undefined,\n): DataGridStrings {\n if (!override) return DATA_GRID_DEFAULT_STRINGS;\n return { ...DATA_GRID_DEFAULT_STRINGS, ...override };\n}\n"],"mappings":";;;AAEA,MAAa,4BAA6C;CAExD,mBAAmB;CACnB,SAAS;CACT,QAAQ;CACR,SAAS;CAET,SAAS;CACT,SAAS;CACT,cAAc;CAEd,YAAY;CACZ,oBAAoB;CACpB,oBAAoB;CAEpB,eAAe,UAAU,GAAG,MAAM,MAAM,UAAU,IAAI,KAAK,IAAI;CAE/D,aAAa;CACb,SAAS,MAAM,UAAU,GAAG,KAAK,MAAM;CAEvC,QAAQ;CACR,SAAS;CACT,aAAa;CAEb,WAAW;CACX,cAAc;CAEd,SAAS;CACT,UAAU;CACV,QAAQ;CAER,SAAS;CACT,UAAU;CACV,OAAO;CACP,YAAY;CACb;AAED,SAAgB,uBACd,UACiB;AACjB,KAAI,CAAC,SAAU,QAAO;AACtB,QAAO;EAAE,GAAG;EAA2B,GAAG;EAAU"}
|