@optimum-intelligence/opti-ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -3
- package/dist/components/card/Card.d.ts +1 -1
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/data-table/DataTable.d.ts +58 -96
- package/dist/components/data-table/DataTable.js +452 -418
- package/dist/components/data-table/DataTable.js.map +1 -1
- package/dist/components/data-table/DataTableContent.d.ts +35 -0
- package/dist/components/data-table/DataTableContent.js +550 -0
- package/dist/components/data-table/DataTableContent.js.map +1 -0
- package/dist/components/data-table/DataTableFilters.d.ts +15 -0
- package/dist/components/data-table/DataTableFilters.js +284 -0
- package/dist/components/data-table/DataTableFilters.js.map +1 -0
- package/dist/components/data-table/DataTableRow.d.ts +33 -0
- package/dist/components/data-table/DataTableRow.js +552 -0
- package/dist/components/data-table/DataTableRow.js.map +1 -0
- package/dist/components/data-table/context.d.ts +5 -0
- package/dist/components/data-table/context.js +14 -0
- package/dist/components/data-table/context.js.map +1 -0
- package/dist/components/data-table/layout.d.ts +60 -0
- package/dist/components/data-table/layout.js +272 -0
- package/dist/components/data-table/layout.js.map +1 -0
- package/dist/components/data-table/types.d.ts +319 -0
- package/dist/components/data-table/useDataTable.d.ts +9 -0
- package/dist/components/data-table/useDataTable.js +666 -0
- package/dist/components/data-table/useDataTable.js.map +1 -0
- package/dist/components/stat-card/StatCard.d.ts +1 -1
- package/dist/components/stat-card/StatCard.js.map +1 -1
- package/dist/icons/index.d.ts +8 -0
- package/dist/icons/index.js +9 -1
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/opti-ui.css +494 -167
- package/package.json +1 -1
|
@@ -1,444 +1,478 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx } from "../../utils/cx.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createPrimitive } from "../../utils/primitive.js";
|
|
4
4
|
import { Spinner } from "../spinner/Spinner.js";
|
|
5
|
-
import { Button } from "../button/Button.js";
|
|
6
|
-
import { Checkbox } from "../choice/Choice.js";
|
|
7
5
|
import { SearchInput } from "../search-input/SearchInput.js";
|
|
8
|
-
import { matchesQuery } from "../../utils/search.js";
|
|
9
6
|
import { Pagination } from "../pagination/Pagination.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { DataTableContext, useDataTableContext } from "./context.js";
|
|
8
|
+
import { useDataTable } from "./useDataTable.js";
|
|
9
|
+
import { DataTableContent } from "./DataTableContent.js";
|
|
10
|
+
import { DataTableFilter, DataTableFilters } from "./DataTableFilters.js";
|
|
12
11
|
import { c } from "react/compiler-runtime";
|
|
13
12
|
import * as React from "react";
|
|
14
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
14
|
//#region src/components/data-table/DataTable.tsx
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
/** Provides a table to the parts inside it. */
|
|
16
|
+
function DataTableRoot(t0) {
|
|
17
|
+
const $ = c(15);
|
|
18
|
+
let className;
|
|
19
|
+
let props;
|
|
20
|
+
let ref;
|
|
21
|
+
let table;
|
|
22
|
+
if ($[0] !== t0) {
|
|
23
|
+
({table, className, ref, ...props} = t0);
|
|
24
|
+
$[0] = t0;
|
|
25
|
+
$[1] = className;
|
|
26
|
+
$[2] = props;
|
|
27
|
+
$[3] = ref;
|
|
28
|
+
$[4] = table;
|
|
29
|
+
} else {
|
|
30
|
+
className = $[1];
|
|
31
|
+
props = $[2];
|
|
32
|
+
ref = $[3];
|
|
33
|
+
table = $[4];
|
|
34
|
+
}
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[5] !== className) {
|
|
37
|
+
t1 = cx("oui-data-table", className);
|
|
38
|
+
$[5] = className;
|
|
39
|
+
$[6] = t1;
|
|
40
|
+
} else t1 = $[6];
|
|
41
|
+
const t2 = table.loading ? table.rows.length ? "refresh" : "initial" : void 0;
|
|
42
|
+
let t3;
|
|
43
|
+
if ($[7] !== props || $[8] !== ref || $[9] !== t1 || $[10] !== t2) {
|
|
44
|
+
t3 = /* @__PURE__ */ jsx("div", {
|
|
45
|
+
ref,
|
|
46
|
+
className: t1,
|
|
47
|
+
"data-loading": t2,
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
$[7] = props;
|
|
51
|
+
$[8] = ref;
|
|
52
|
+
$[9] = t1;
|
|
53
|
+
$[10] = t2;
|
|
54
|
+
$[11] = t3;
|
|
55
|
+
} else t3 = $[11];
|
|
56
|
+
let t4;
|
|
57
|
+
if ($[12] !== t3 || $[13] !== table) {
|
|
58
|
+
t4 = /* @__PURE__ */ jsx(DataTableContext.Provider, {
|
|
59
|
+
value: table,
|
|
60
|
+
children: t3
|
|
61
|
+
});
|
|
62
|
+
$[12] = t3;
|
|
63
|
+
$[13] = table;
|
|
64
|
+
$[14] = t4;
|
|
65
|
+
} else t4 = $[14];
|
|
66
|
+
return t4;
|
|
67
|
+
}
|
|
68
|
+
var DataTableToolbar = createPrimitive("div", "oui-data-table__toolbar", "DataTableToolbar");
|
|
69
|
+
var DataTableActions = createPrimitive("div", "oui-data-table__actions", "DataTableActions");
|
|
70
|
+
/** Search box of the table. Typing applies after the table's `searchDebounce`; clearing applies at once. */
|
|
71
|
+
function DataTableSearch(t0) {
|
|
72
|
+
const $ = c(26);
|
|
73
|
+
let className;
|
|
74
|
+
let props;
|
|
75
|
+
if ($[0] !== t0) {
|
|
76
|
+
({className, ...props} = t0);
|
|
77
|
+
$[0] = t0;
|
|
78
|
+
$[1] = className;
|
|
79
|
+
$[2] = props;
|
|
80
|
+
} else {
|
|
81
|
+
className = $[1];
|
|
82
|
+
props = $[2];
|
|
83
|
+
}
|
|
84
|
+
const table = useDataTableContext();
|
|
85
|
+
const { search, searchDebounce, labels: text } = table;
|
|
86
|
+
const [draft, setDraft] = React.useState(search);
|
|
87
|
+
const [seen, setSeen] = React.useState(search);
|
|
88
|
+
const [sent, setSent] = React.useState(search);
|
|
89
|
+
if (seen !== search) {
|
|
90
|
+
setSeen(search);
|
|
91
|
+
if (search !== sent) {
|
|
92
|
+
setSent(search);
|
|
93
|
+
setDraft(search);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let t1;
|
|
97
|
+
if ($[3] !== table) {
|
|
98
|
+
t1 = (next) => {
|
|
99
|
+
setSent(next);
|
|
100
|
+
table.setSearch(next);
|
|
39
101
|
};
|
|
40
|
-
$[
|
|
41
|
-
$[
|
|
42
|
-
} else
|
|
43
|
-
const
|
|
44
|
-
const t1 = value === void 0 ? inner : value;
|
|
102
|
+
$[3] = table;
|
|
103
|
+
$[4] = t1;
|
|
104
|
+
} else t1 = $[4];
|
|
105
|
+
const commit = t1;
|
|
45
106
|
let t2;
|
|
46
|
-
if ($[
|
|
47
|
-
t2 =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
107
|
+
if ($[5] !== commit || $[6] !== draft || $[7] !== searchDebounce || $[8] !== sent) {
|
|
108
|
+
t2 = () => {
|
|
109
|
+
if (draft === sent) return;
|
|
110
|
+
const timer = window.setTimeout(() => commit(draft), searchDebounce);
|
|
111
|
+
return () => window.clearTimeout(timer);
|
|
112
|
+
};
|
|
113
|
+
$[5] = commit;
|
|
114
|
+
$[6] = draft;
|
|
115
|
+
$[7] = searchDebounce;
|
|
116
|
+
$[8] = sent;
|
|
117
|
+
$[9] = t2;
|
|
118
|
+
} else t2 = $[9];
|
|
119
|
+
let t3;
|
|
120
|
+
if ($[10] !== draft || $[11] !== searchDebounce || $[12] !== sent) {
|
|
121
|
+
t3 = [
|
|
122
|
+
draft,
|
|
123
|
+
sent,
|
|
124
|
+
searchDebounce
|
|
125
|
+
];
|
|
126
|
+
$[10] = draft;
|
|
127
|
+
$[11] = searchDebounce;
|
|
128
|
+
$[12] = sent;
|
|
129
|
+
$[13] = t3;
|
|
130
|
+
} else t3 = $[13];
|
|
131
|
+
React.useEffect(t2, t3);
|
|
132
|
+
let t4;
|
|
133
|
+
if ($[14] !== commit || $[15] !== searchDebounce) {
|
|
134
|
+
t4 = (next_0) => {
|
|
135
|
+
setDraft(next_0);
|
|
136
|
+
if (!searchDebounce || !next_0) commit(next_0);
|
|
137
|
+
};
|
|
138
|
+
$[14] = commit;
|
|
139
|
+
$[15] = searchDebounce;
|
|
140
|
+
$[16] = t4;
|
|
141
|
+
} else t4 = $[16];
|
|
142
|
+
const change = t4;
|
|
143
|
+
let t5;
|
|
144
|
+
if ($[17] !== className) {
|
|
145
|
+
t5 = cx("oui-data-table__search", className);
|
|
146
|
+
$[17] = className;
|
|
147
|
+
$[18] = t5;
|
|
148
|
+
} else t5 = $[18];
|
|
149
|
+
let t6;
|
|
150
|
+
if ($[19] !== change || $[20] !== draft || $[21] !== props || $[22] !== t5 || $[23] !== text.clearSearch || $[24] !== text.search) {
|
|
151
|
+
t6 = /* @__PURE__ */ jsx(SearchInput, {
|
|
152
|
+
className: t5,
|
|
153
|
+
"aria-label": text.search,
|
|
154
|
+
placeholder: text.search,
|
|
155
|
+
clearLabel: text.clearSearch,
|
|
156
|
+
...props,
|
|
157
|
+
value: draft,
|
|
158
|
+
onValueChange: change
|
|
159
|
+
});
|
|
160
|
+
$[19] = change;
|
|
161
|
+
$[20] = draft;
|
|
162
|
+
$[21] = props;
|
|
163
|
+
$[22] = t5;
|
|
164
|
+
$[23] = text.clearSearch;
|
|
165
|
+
$[24] = text.search;
|
|
166
|
+
$[25] = t6;
|
|
167
|
+
} else t6 = $[25];
|
|
168
|
+
return t6;
|
|
68
169
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if ($[0] !== selection) {
|
|
98
|
-
t7 = new Set(selection);
|
|
99
|
-
$[0] = selection;
|
|
100
|
-
$[1] = t7;
|
|
101
|
-
} else t7 = $[1];
|
|
102
|
-
const selected = t7;
|
|
103
|
-
const sortable = _temp;
|
|
104
|
-
let t8;
|
|
105
|
-
if ($[2] !== getRowId) {
|
|
106
|
-
t8 = (row, index) => getRowId?.(row, index) ?? String(row.id ?? index);
|
|
107
|
-
$[2] = getRowId;
|
|
108
|
-
$[3] = t8;
|
|
109
|
-
} else t8 = $[3];
|
|
110
|
-
const idOf = t8;
|
|
111
|
-
let t9;
|
|
112
|
-
if ($[4] !== idOf) {
|
|
113
|
-
t9 = (row_0, index_0) => ({
|
|
114
|
-
row: row_0,
|
|
115
|
-
id: idOf(row_0, index_0)
|
|
170
|
+
/** Row count, or the number of selected rows, with a spinner while loading. */
|
|
171
|
+
function DataTableSummary(t0) {
|
|
172
|
+
const $ = c(24);
|
|
173
|
+
let className;
|
|
174
|
+
let props;
|
|
175
|
+
if ($[0] !== t0) {
|
|
176
|
+
({className, ...props} = t0);
|
|
177
|
+
$[0] = t0;
|
|
178
|
+
$[1] = className;
|
|
179
|
+
$[2] = props;
|
|
180
|
+
} else {
|
|
181
|
+
className = $[1];
|
|
182
|
+
props = $[2];
|
|
183
|
+
}
|
|
184
|
+
const table = useDataTableContext();
|
|
185
|
+
const text = table.labels;
|
|
186
|
+
let t1;
|
|
187
|
+
if ($[3] !== table.selection) {
|
|
188
|
+
t1 = new Set(table.selection);
|
|
189
|
+
$[3] = table.selection;
|
|
190
|
+
$[4] = t1;
|
|
191
|
+
} else t1 = $[4];
|
|
192
|
+
const selected = t1.size;
|
|
193
|
+
let t2;
|
|
194
|
+
if ($[5] !== table.loading || $[6] !== text) {
|
|
195
|
+
t2 = table.loading && /* @__PURE__ */ jsx(Spinner, {
|
|
196
|
+
className: "oui-data-table__spinner",
|
|
197
|
+
label: text.loading
|
|
116
198
|
});
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
199
|
+
$[5] = table.loading;
|
|
200
|
+
$[6] = text;
|
|
201
|
+
$[7] = t2;
|
|
202
|
+
} else t2 = $[7];
|
|
203
|
+
let t3;
|
|
204
|
+
if ($[8] !== className) {
|
|
205
|
+
t3 = cx("oui-data-table__summary", className);
|
|
206
|
+
$[8] = className;
|
|
207
|
+
$[9] = t3;
|
|
208
|
+
} else t3 = $[9];
|
|
209
|
+
let t4;
|
|
210
|
+
if ($[10] !== selected || $[11] !== table.count || $[12] !== table.pending || $[13] !== table.selectable || $[14] !== table.totalCount || $[15] !== text) {
|
|
211
|
+
t4 = table.selectable && selected ? text.selected(selected) : table.pending ? null : table.count !== table.totalCount ? text.filteredCount(table.count, table.totalCount) : text.count(table.count);
|
|
212
|
+
$[10] = selected;
|
|
213
|
+
$[11] = table.count;
|
|
214
|
+
$[12] = table.pending;
|
|
215
|
+
$[13] = table.selectable;
|
|
216
|
+
$[14] = table.totalCount;
|
|
217
|
+
$[15] = text;
|
|
218
|
+
$[16] = t4;
|
|
219
|
+
} else t4 = $[16];
|
|
220
|
+
let t5;
|
|
221
|
+
if ($[17] !== props || $[18] !== t3 || $[19] !== t4) {
|
|
222
|
+
t5 = /* @__PURE__ */ jsx("span", {
|
|
223
|
+
className: t3,
|
|
224
|
+
"aria-live": "polite",
|
|
225
|
+
...props,
|
|
226
|
+
children: t4
|
|
126
227
|
});
|
|
228
|
+
$[17] = props;
|
|
229
|
+
$[18] = t3;
|
|
230
|
+
$[19] = t4;
|
|
231
|
+
$[20] = t5;
|
|
232
|
+
} else t5 = $[20];
|
|
233
|
+
let t6;
|
|
234
|
+
if ($[21] !== t2 || $[22] !== t5) {
|
|
235
|
+
t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t5] });
|
|
236
|
+
$[21] = t2;
|
|
237
|
+
$[22] = t5;
|
|
238
|
+
$[23] = t6;
|
|
239
|
+
} else t6 = $[23];
|
|
240
|
+
return t6;
|
|
241
|
+
}
|
|
242
|
+
/** Page navigation of the table. Renders nothing when there are no rows, or the table is not paginated. */
|
|
243
|
+
function DataTablePagination(t0) {
|
|
244
|
+
const $ = c(14);
|
|
245
|
+
let className;
|
|
246
|
+
let props;
|
|
247
|
+
if ($[0] !== t0) {
|
|
248
|
+
({className, ...props} = t0);
|
|
249
|
+
$[0] = t0;
|
|
250
|
+
$[1] = className;
|
|
251
|
+
$[2] = props;
|
|
252
|
+
} else {
|
|
253
|
+
className = $[1];
|
|
254
|
+
props = $[2];
|
|
127
255
|
}
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
$[
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
256
|
+
const table = useDataTableContext();
|
|
257
|
+
if (!table.paginated || table.count <= 0 || table.error) return null;
|
|
258
|
+
let t1;
|
|
259
|
+
if ($[3] !== className) {
|
|
260
|
+
t1 = cx("oui-data-table__pagination", className);
|
|
261
|
+
$[3] = className;
|
|
262
|
+
$[4] = t1;
|
|
263
|
+
} else t1 = $[4];
|
|
264
|
+
let t2;
|
|
265
|
+
if ($[5] !== props || $[6] !== t1 || $[7] !== table.count || $[8] !== table.labels || $[9] !== table.page || $[10] !== table.pageSize || $[11] !== table.setPage || $[12] !== table.setPageSize) {
|
|
266
|
+
t2 = /* @__PURE__ */ jsx(Pagination, {
|
|
267
|
+
className: t1,
|
|
268
|
+
variant: "simple",
|
|
269
|
+
labels: table.labels,
|
|
270
|
+
...props,
|
|
271
|
+
page: table.page,
|
|
272
|
+
pageSize: table.pageSize,
|
|
273
|
+
total: table.count,
|
|
274
|
+
onPageChange: table.setPage,
|
|
275
|
+
onPageSizeChange: table.setPageSize
|
|
276
|
+
});
|
|
277
|
+
$[5] = props;
|
|
278
|
+
$[6] = t1;
|
|
279
|
+
$[7] = table.count;
|
|
280
|
+
$[8] = table.labels;
|
|
281
|
+
$[9] = table.page;
|
|
282
|
+
$[10] = table.pageSize;
|
|
283
|
+
$[11] = table.setPage;
|
|
284
|
+
$[12] = table.setPageSize;
|
|
285
|
+
$[13] = t2;
|
|
286
|
+
} else t2 = $[13];
|
|
287
|
+
return t2;
|
|
288
|
+
}
|
|
289
|
+
function DataTableComponent(t0) {
|
|
290
|
+
const $ = c(51);
|
|
291
|
+
let className;
|
|
292
|
+
let controlSize;
|
|
293
|
+
let density;
|
|
294
|
+
let empty;
|
|
295
|
+
let layout;
|
|
296
|
+
let maxHeight;
|
|
297
|
+
let onEndReached;
|
|
298
|
+
let options;
|
|
299
|
+
let pageSizeOptions;
|
|
300
|
+
let stickyHeader;
|
|
301
|
+
let striped;
|
|
302
|
+
let tableProps;
|
|
303
|
+
let toolbar;
|
|
304
|
+
let virtualized;
|
|
305
|
+
if ($[0] !== t0) {
|
|
306
|
+
({density, striped, stickyHeader, layout, maxHeight, virtualized, onEndReached, empty, tableProps, pageSizeOptions, controlSize, toolbar, className, ...options} = t0);
|
|
307
|
+
$[0] = t0;
|
|
308
|
+
$[1] = className;
|
|
309
|
+
$[2] = controlSize;
|
|
310
|
+
$[3] = density;
|
|
311
|
+
$[4] = empty;
|
|
312
|
+
$[5] = layout;
|
|
313
|
+
$[6] = maxHeight;
|
|
314
|
+
$[7] = onEndReached;
|
|
315
|
+
$[8] = options;
|
|
316
|
+
$[9] = pageSizeOptions;
|
|
317
|
+
$[10] = stickyHeader;
|
|
318
|
+
$[11] = striped;
|
|
319
|
+
$[12] = tableProps;
|
|
320
|
+
$[13] = toolbar;
|
|
321
|
+
$[14] = virtualized;
|
|
322
|
+
} else {
|
|
323
|
+
className = $[1];
|
|
324
|
+
controlSize = $[2];
|
|
325
|
+
density = $[3];
|
|
326
|
+
empty = $[4];
|
|
327
|
+
layout = $[5];
|
|
328
|
+
maxHeight = $[6];
|
|
329
|
+
onEndReached = $[7];
|
|
330
|
+
options = $[8];
|
|
331
|
+
pageSizeOptions = $[9];
|
|
332
|
+
stickyHeader = $[10];
|
|
333
|
+
striped = $[11];
|
|
334
|
+
tableProps = $[12];
|
|
335
|
+
toolbar = $[13];
|
|
336
|
+
virtualized = $[14];
|
|
151
337
|
}
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
t11 = server ? Boolean(search.trim()) : data.length > 0;
|
|
159
|
-
$[12] = data.length;
|
|
160
|
-
$[13] = search;
|
|
161
|
-
$[14] = server;
|
|
162
|
-
$[15] = t11;
|
|
163
|
-
} else t11 = $[15];
|
|
164
|
-
const filtered = t11;
|
|
165
|
-
const placeholders = loading && !rows.length && !error ? Math.min(paginated ? pageSize : 5, 10) : 0;
|
|
166
|
-
let t12;
|
|
167
|
-
if ($[16] !== selected) {
|
|
168
|
-
t12 = (t13) => {
|
|
169
|
-
const { id } = t13;
|
|
170
|
-
return selected.has(id);
|
|
171
|
-
};
|
|
172
|
-
$[16] = selected;
|
|
173
|
-
$[17] = t12;
|
|
174
|
-
} else t12 = $[17];
|
|
175
|
-
const selectedInView = rows.filter(t12).length;
|
|
176
|
-
const allSelected = rows.length > 0 && selectedInView === rows.length;
|
|
177
|
-
const toggleAll = (checked) => {
|
|
178
|
-
const ids = new Set(rows.map(_temp3));
|
|
179
|
-
const kept = (selection ?? []).filter((id_1) => !ids.has(id_1));
|
|
180
|
-
onSelectionChange?.(checked ? [...kept, ...ids] : kept);
|
|
181
|
-
};
|
|
182
|
-
let t13;
|
|
183
|
-
if ($[18] !== setSort || $[19] !== sort) {
|
|
184
|
-
t13 = (id_2) => setSort(sort?.id !== id_2 ? {
|
|
185
|
-
id: id_2,
|
|
186
|
-
direction: "asc"
|
|
187
|
-
} : sort.direction === "asc" ? {
|
|
188
|
-
id: id_2,
|
|
189
|
-
direction: "desc"
|
|
190
|
-
} : null);
|
|
191
|
-
$[18] = setSort;
|
|
192
|
-
$[19] = sort;
|
|
193
|
-
$[20] = t13;
|
|
194
|
-
} else t13 = $[20];
|
|
195
|
-
const toggleSort = t13;
|
|
196
|
-
let t14;
|
|
197
|
-
if ($[21] !== setPage || $[22] !== setSearch) {
|
|
198
|
-
t14 = (next) => {
|
|
199
|
-
setSearch(next);
|
|
200
|
-
setPage(1);
|
|
338
|
+
const t1 = options.paginated ?? !virtualized;
|
|
339
|
+
let t2;
|
|
340
|
+
if ($[15] !== options || $[16] !== t1) {
|
|
341
|
+
t2 = {
|
|
342
|
+
...options,
|
|
343
|
+
paginated: t1
|
|
201
344
|
};
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
} else
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const T1 = TableBody;
|
|
259
|
-
let t20;
|
|
260
|
-
if ($[36] !== columns || $[37] !== placeholders || $[38] !== selectable) {
|
|
261
|
-
let t21;
|
|
262
|
-
if ($[40] !== columns || $[41] !== selectable) {
|
|
263
|
-
t21 = (_, index_1) => /* @__PURE__ */ jsxs(TableRow, {
|
|
264
|
-
"aria-hidden": true,
|
|
265
|
-
children: [selectable && /* @__PURE__ */ jsx(TableCell, { className: "oui-data-table__check" }), columns.map((column_3, position) => /* @__PURE__ */ jsx(TableCell, {
|
|
266
|
-
align: column_3.align,
|
|
267
|
-
numeric: column_3.numeric,
|
|
268
|
-
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
269
|
-
className: "oui-data-table__skeleton",
|
|
270
|
-
width: `${45 + (index_1 * 3 + position * 5) % 7 * 8}%`
|
|
271
|
-
})
|
|
272
|
-
}, column_3.id))]
|
|
273
|
-
}, index_1);
|
|
274
|
-
$[40] = columns;
|
|
275
|
-
$[41] = selectable;
|
|
276
|
-
$[42] = t21;
|
|
277
|
-
} else t21 = $[42];
|
|
278
|
-
t20 = Array.from({ length: placeholders }, t21);
|
|
279
|
-
$[36] = columns;
|
|
280
|
-
$[37] = placeholders;
|
|
281
|
-
$[38] = selectable;
|
|
282
|
-
$[39] = t20;
|
|
283
|
-
} else t20 = $[39];
|
|
284
|
-
const t21 = !error && visible.map((t22) => {
|
|
285
|
-
const { row: row_3, id: id_3 } = t22;
|
|
286
|
-
const isSelected = selected.has(id_3);
|
|
287
|
-
return /* @__PURE__ */ jsxs(TableRow, {
|
|
288
|
-
"data-selected": isSelected || void 0,
|
|
289
|
-
"data-clickable": onRowClick ? "" : void 0,
|
|
290
|
-
tabIndex: onRowClick ? 0 : void 0,
|
|
291
|
-
"aria-label": onRowClick ? rowLabel?.(row_3) : void 0,
|
|
292
|
-
onClick: (event) => {
|
|
293
|
-
if (!onRowClick || event.ctrlKey || event.metaKey) return;
|
|
294
|
-
if (event.target.closest(INTERACTIVE)) return;
|
|
295
|
-
onRowClick(row_3);
|
|
296
|
-
},
|
|
297
|
-
onKeyDown: (event_0) => {
|
|
298
|
-
if (onRowClick && event_0.target === event_0.currentTarget && event_0.key === "Enter") onRowClick(row_3);
|
|
299
|
-
},
|
|
300
|
-
children: [selectable && /* @__PURE__ */ jsx(TableCell, {
|
|
301
|
-
className: "oui-data-table__check",
|
|
302
|
-
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
303
|
-
size: "sm",
|
|
304
|
-
"aria-label": text.selectRow(rowLabel?.(row_3) ?? id_3),
|
|
305
|
-
checked: isSelected,
|
|
306
|
-
onCheckedChange: (checked_1) => onSelectionChange?.(checked_1 ? [...selection ?? [], id_3] : (selection ?? []).filter((item) => item !== id_3))
|
|
307
|
-
})
|
|
308
|
-
}), columns.map((column_4) => {
|
|
309
|
-
const value = column_4.cell ? column_4.cell(row_3) : valueOf(column_4, row_3);
|
|
310
|
-
return /* @__PURE__ */ jsx(TableCell, {
|
|
311
|
-
align: column_4.align,
|
|
312
|
-
numeric: column_4.numeric,
|
|
313
|
-
children: column_4.cell || React.isValidElement(value) ? value : isEmpty(value) ? "—" : String(value)
|
|
314
|
-
}, column_4.id);
|
|
315
|
-
})]
|
|
316
|
-
}, id_3);
|
|
317
|
-
});
|
|
318
|
-
let t23;
|
|
319
|
-
if ($[43] !== T1 || $[44] !== t20 || $[45] !== t21) {
|
|
320
|
-
t23 = /* @__PURE__ */ jsxs(T1, { children: [t20, t21] });
|
|
321
|
-
$[43] = T1;
|
|
322
|
-
$[44] = t20;
|
|
323
|
-
$[45] = t21;
|
|
324
|
-
$[46] = t23;
|
|
325
|
-
} else t23 = $[46];
|
|
326
|
-
let t24;
|
|
327
|
-
if ($[47] !== T0 || $[48] !== density || $[49] !== stickyHeader || $[50] !== striped || $[51] !== t16 || $[52] !== t19 || $[53] !== t23 || $[54] !== tableProps) {
|
|
328
|
-
t24 = /* @__PURE__ */ jsxs(T0, {
|
|
345
|
+
$[15] = options;
|
|
346
|
+
$[16] = t1;
|
|
347
|
+
$[17] = t2;
|
|
348
|
+
} else t2 = $[17];
|
|
349
|
+
const table = useDataTable(t2);
|
|
350
|
+
let t3;
|
|
351
|
+
if ($[18] !== table || $[19] !== toolbar) {
|
|
352
|
+
t3 = typeof toolbar === "function" ? toolbar({
|
|
353
|
+
rows: table.rows.map(_temp),
|
|
354
|
+
selection: table.selection,
|
|
355
|
+
table
|
|
356
|
+
}) : toolbar;
|
|
357
|
+
$[18] = table;
|
|
358
|
+
$[19] = toolbar;
|
|
359
|
+
$[20] = t3;
|
|
360
|
+
} else t3 = $[20];
|
|
361
|
+
const extra = t3;
|
|
362
|
+
let t4;
|
|
363
|
+
if ($[21] !== controlSize || $[22] !== table.searchable) {
|
|
364
|
+
t4 = table.searchable && /* @__PURE__ */ jsx(DataTableSearch, { size: controlSize });
|
|
365
|
+
$[21] = controlSize;
|
|
366
|
+
$[22] = table.searchable;
|
|
367
|
+
$[23] = t4;
|
|
368
|
+
} else t4 = $[23];
|
|
369
|
+
let t5;
|
|
370
|
+
if ($[24] !== controlSize) {
|
|
371
|
+
t5 = /* @__PURE__ */ jsx(DataTableFilters, { size: controlSize });
|
|
372
|
+
$[24] = controlSize;
|
|
373
|
+
$[25] = t5;
|
|
374
|
+
} else t5 = $[25];
|
|
375
|
+
let t6;
|
|
376
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
377
|
+
t6 = /* @__PURE__ */ jsx(DataTableSummary, {});
|
|
378
|
+
$[26] = t6;
|
|
379
|
+
} else t6 = $[26];
|
|
380
|
+
let t7;
|
|
381
|
+
if ($[27] !== extra) {
|
|
382
|
+
t7 = /* @__PURE__ */ jsxs(DataTableActions, { children: [t6, extra] });
|
|
383
|
+
$[27] = extra;
|
|
384
|
+
$[28] = t7;
|
|
385
|
+
} else t7 = $[28];
|
|
386
|
+
let t8;
|
|
387
|
+
if ($[29] !== t4 || $[30] !== t5 || $[31] !== t7) {
|
|
388
|
+
t8 = /* @__PURE__ */ jsxs(DataTableToolbar, { children: [
|
|
389
|
+
t4,
|
|
390
|
+
t5,
|
|
391
|
+
t7
|
|
392
|
+
] });
|
|
393
|
+
$[29] = t4;
|
|
394
|
+
$[30] = t5;
|
|
395
|
+
$[31] = t7;
|
|
396
|
+
$[32] = t8;
|
|
397
|
+
} else t8 = $[32];
|
|
398
|
+
let t9;
|
|
399
|
+
if ($[33] !== density || $[34] !== empty || $[35] !== layout || $[36] !== maxHeight || $[37] !== onEndReached || $[38] !== stickyHeader || $[39] !== striped || $[40] !== tableProps || $[41] !== virtualized) {
|
|
400
|
+
t9 = /* @__PURE__ */ jsx(DataTableContent, {
|
|
329
401
|
density,
|
|
330
402
|
striped,
|
|
331
403
|
stickyHeader,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
404
|
+
layout,
|
|
405
|
+
maxHeight,
|
|
406
|
+
virtualized,
|
|
407
|
+
onEndReached,
|
|
408
|
+
empty,
|
|
409
|
+
tableProps
|
|
335
410
|
});
|
|
336
|
-
$[
|
|
337
|
-
$[
|
|
338
|
-
$[
|
|
339
|
-
$[
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
$[
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
411
|
+
$[33] = density;
|
|
412
|
+
$[34] = empty;
|
|
413
|
+
$[35] = layout;
|
|
414
|
+
$[36] = maxHeight;
|
|
415
|
+
$[37] = onEndReached;
|
|
416
|
+
$[38] = stickyHeader;
|
|
417
|
+
$[39] = striped;
|
|
418
|
+
$[40] = tableProps;
|
|
419
|
+
$[41] = virtualized;
|
|
420
|
+
$[42] = t9;
|
|
421
|
+
} else t9 = $[42];
|
|
422
|
+
let t10;
|
|
423
|
+
if ($[43] !== pageSizeOptions) {
|
|
424
|
+
t10 = /* @__PURE__ */ jsx(DataTablePagination, { pageSizeOptions });
|
|
425
|
+
$[43] = pageSizeOptions;
|
|
426
|
+
$[44] = t10;
|
|
427
|
+
} else t10 = $[44];
|
|
428
|
+
let t11;
|
|
429
|
+
if ($[45] !== className || $[46] !== t10 || $[47] !== t8 || $[48] !== t9 || $[49] !== table) {
|
|
430
|
+
t11 = /* @__PURE__ */ jsxs(DataTableRoot, {
|
|
431
|
+
table,
|
|
432
|
+
className,
|
|
433
|
+
children: [
|
|
434
|
+
t8,
|
|
435
|
+
t9,
|
|
436
|
+
t10
|
|
437
|
+
]
|
|
361
438
|
});
|
|
362
|
-
$[
|
|
363
|
-
$[
|
|
364
|
-
$[
|
|
365
|
-
$[
|
|
366
|
-
$[
|
|
367
|
-
$[
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
$[64] = setPageSize;
|
|
371
|
-
$[65] = t25;
|
|
372
|
-
} else t25 = $[65];
|
|
373
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
374
|
-
className: t15,
|
|
375
|
-
"data-loading": loading ? rows.length ? "refresh" : "initial" : void 0,
|
|
376
|
-
children: [
|
|
377
|
-
/* @__PURE__ */ jsxs("div", {
|
|
378
|
-
className: "oui-data-table__toolbar",
|
|
379
|
-
children: [searchable && /* @__PURE__ */ jsx(SearchInput, {
|
|
380
|
-
className: "oui-data-table__search",
|
|
381
|
-
"aria-label": text.search,
|
|
382
|
-
placeholder: text.search,
|
|
383
|
-
clearLabel: text.clearSearch,
|
|
384
|
-
value: search,
|
|
385
|
-
onValueChange: changeSearch
|
|
386
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
387
|
-
className: "oui-data-table__actions",
|
|
388
|
-
children: [
|
|
389
|
-
loading && /* @__PURE__ */ jsx(Spinner, {
|
|
390
|
-
className: "oui-data-table__spinner",
|
|
391
|
-
label: text.loading
|
|
392
|
-
}),
|
|
393
|
-
/* @__PURE__ */ jsx("span", {
|
|
394
|
-
className: "oui-data-table__summary",
|
|
395
|
-
"aria-live": "polite",
|
|
396
|
-
children: selectable && selected.size ? text.selected(selected.size) : placeholders ? null : text.count(count)
|
|
397
|
-
}),
|
|
398
|
-
extra
|
|
399
|
-
]
|
|
400
|
-
})]
|
|
401
|
-
}),
|
|
402
|
-
t24,
|
|
403
|
-
error ? /* @__PURE__ */ jsx(EmptyState, {
|
|
404
|
-
role: "alert",
|
|
405
|
-
title: text.errorTitle,
|
|
406
|
-
description: error,
|
|
407
|
-
actions: onRetry ? /* @__PURE__ */ jsx(Button, {
|
|
408
|
-
size: "sm",
|
|
409
|
-
variant: "secondary",
|
|
410
|
-
onClick: onRetry,
|
|
411
|
-
children: text.retry
|
|
412
|
-
}) : void 0
|
|
413
|
-
}) : !rows.length && !loading && (empty ?? /* @__PURE__ */ jsx(EmptyState, {
|
|
414
|
-
title: filtered ? text.noMatchTitle : text.emptyTitle,
|
|
415
|
-
description: filtered ? text.noMatchDescription : text.emptyDescription,
|
|
416
|
-
actions: search ? /* @__PURE__ */ jsx(Button, {
|
|
417
|
-
size: "sm",
|
|
418
|
-
variant: "secondary",
|
|
419
|
-
onClick: () => changeSearch(""),
|
|
420
|
-
children: text.clearSearch
|
|
421
|
-
}) : void 0
|
|
422
|
-
})),
|
|
423
|
-
t25
|
|
424
|
-
]
|
|
425
|
-
});
|
|
439
|
+
$[45] = className;
|
|
440
|
+
$[46] = t10;
|
|
441
|
+
$[47] = t8;
|
|
442
|
+
$[48] = t9;
|
|
443
|
+
$[49] = table;
|
|
444
|
+
$[50] = t11;
|
|
445
|
+
} else t11 = $[50];
|
|
446
|
+
return t11;
|
|
426
447
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
448
|
+
/**
|
|
449
|
+
* `<DataTable data={…} columns={…} />` renders a complete table with search,
|
|
450
|
+
* filters, sorting, pagination, row selection, row actions and inline editing;
|
|
451
|
+
* columns declare what they take part in. Every piece of state works
|
|
452
|
+
* uncontrolled or controlled (`search` / `filterValues` / `sort` / `page` /
|
|
453
|
+
* `selection`), and with `mode="server"` the same state drives an API.
|
|
454
|
+
*
|
|
455
|
+
* For another layout, create the table with `useDataTable` and compose the
|
|
456
|
+
* parts: `DataTable.Root`, `DataTable.Toolbar`, `DataTable.Search`,
|
|
457
|
+
* `DataTable.Filters`, `DataTable.Filter`, `DataTable.Actions`,
|
|
458
|
+
* `DataTable.Summary`, `DataTable.Content`, `DataTable.Pagination`.
|
|
459
|
+
*/
|
|
460
|
+
function _temp(t0) {
|
|
461
|
+
const { row } = t0;
|
|
462
|
+
return row;
|
|
440
463
|
}
|
|
464
|
+
var DataTable = Object.assign(DataTableComponent, {
|
|
465
|
+
Root: DataTableRoot,
|
|
466
|
+
Toolbar: DataTableToolbar,
|
|
467
|
+
Search: DataTableSearch,
|
|
468
|
+
Filters: DataTableFilters,
|
|
469
|
+
Filter: DataTableFilter,
|
|
470
|
+
Actions: DataTableActions,
|
|
471
|
+
Summary: DataTableSummary,
|
|
472
|
+
Content: DataTableContent,
|
|
473
|
+
Pagination: DataTablePagination
|
|
474
|
+
});
|
|
441
475
|
//#endregion
|
|
442
|
-
export { DataTable };
|
|
476
|
+
export { DataTable, useDataTableContext };
|
|
443
477
|
|
|
444
478
|
//# sourceMappingURL=DataTable.js.map
|