@stealthscale/component-tables 0.2.2 → 0.2.3
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/cyclonedx/bom.json +1 -1
- package/dist/index.js +1 -6000
- package/dist/pages/data-table/data-table.js +4299 -0
- package/dist/pages/data-table/data-table.props.js +3 -0
- package/dist/pages/pages.json +21 -0
- package/dist/shared-DJAOX1dY.js +6001 -0
- package/dist/theme.js +1 -1
- package/locales/en/specimen/data-table.json +276 -0
- package/package.json +16 -15
- /package/dist/{recipe-E5qwAx85.js → recipes-E5qwAx85.js} +0 -0
|
@@ -0,0 +1,4299 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { a as Search, c as pinColumn, d as expandColumn, f as ColumnMenu, h as ColumnFilter, i as selectColumn, l as TablePagination, m as createColumnHelper, n as useDataTable, o as Root, p as ColumnManager, r as Table$1, s as pivot$1, u as PageSize } from "../../shared-DJAOX1dY.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { Button, ButtonPropsProvider } from "@stealthscale/component-actions";
|
|
5
|
+
import { Popover } from "@stealthscale/component-disclosure";
|
|
6
|
+
import { Portal } from "@stealthscale/component-primitives";
|
|
7
|
+
import { DataList } from "@stealthscale/component-collections";
|
|
8
|
+
import { Field, NativeSelect } from "@stealthscale/component-forms";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useEffect, useRef, useState } from "react";
|
|
11
|
+
import { Pagination } from "@stealthscale/component-navigation";
|
|
12
|
+
import { Format } from "@stealthscale/component-data";
|
|
13
|
+
import { Room, specimen, useWords } from "@stealthscale/specimen";
|
|
14
|
+
import { ArrowDownIcon, ArrowUpIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, Columns3Icon, EllipsisVerticalIcon, EyeOffIcon, GripVerticalIcon, GroupIcon, ListFilterIcon, MinusIcon, PinIcon, PinOffIcon, SearchIcon, UngroupIcon, XIcon } from "lucide-react";
|
|
15
|
+
import { Grid, Stack } from "@stealthscale/component-layout";
|
|
16
|
+
import { Code, Text } from "@stealthscale/component-typography";
|
|
17
|
+
//#region src/data-table/examples/sales.ts
|
|
18
|
+
/**
|
|
19
|
+
* Lists the quarters in their order.
|
|
20
|
+
*/
|
|
21
|
+
const QUARTERS$1 = [
|
|
22
|
+
"q1",
|
|
23
|
+
"q2",
|
|
24
|
+
"q3",
|
|
25
|
+
"q4"
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Lists the products in the order the orders list them.
|
|
29
|
+
*/
|
|
30
|
+
const PRODUCTS = [
|
|
31
|
+
"laptops",
|
|
32
|
+
"monitors",
|
|
33
|
+
"docks"
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Lists the regions in the order the orders list them.
|
|
37
|
+
*/
|
|
38
|
+
const REGIONS = [
|
|
39
|
+
"north",
|
|
40
|
+
"south",
|
|
41
|
+
"west"
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Lists each product's price in euros.
|
|
45
|
+
*/
|
|
46
|
+
const PRICES = {
|
|
47
|
+
docks: 240,
|
|
48
|
+
laptops: 1450,
|
|
49
|
+
monitors: 380
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Returns whether a region sold a product in a quarter.
|
|
53
|
+
*/
|
|
54
|
+
function sold(region, product, quarter) {
|
|
55
|
+
if (region === "west" && product === "docks") return false;
|
|
56
|
+
return !(region === "south" && product === "monitors" && quarter === "q2");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Lists the year's orders: one to three for each region, product and quarter that sold, each of
|
|
60
|
+
* one to four units.
|
|
61
|
+
*/
|
|
62
|
+
const SALES = QUARTERS$1.flatMap((quarter, q) => PRODUCTS.flatMap((product, p) => REGIONS.flatMap((region, r) => sold(region, product, quarter) ? Array.from({ length: 1 + (q + p + r) % 3 }, (_, n) => ({
|
|
63
|
+
product,
|
|
64
|
+
quarter,
|
|
65
|
+
region,
|
|
66
|
+
value: PRICES[product] * (1 + (q + p + r + n) % 4)
|
|
67
|
+
})) : [])));
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/data-table/examples/aggregates.example.tsx
|
|
70
|
+
var aggregates_example_exports = /* @__PURE__ */ __exportAll({
|
|
71
|
+
Aggregates: () => Aggregates,
|
|
72
|
+
source: () => source$21
|
|
73
|
+
});
|
|
74
|
+
const AGGREGATES = [
|
|
75
|
+
"sum",
|
|
76
|
+
"average",
|
|
77
|
+
"min",
|
|
78
|
+
"max",
|
|
79
|
+
"count"
|
|
80
|
+
];
|
|
81
|
+
const EURO$20 = {
|
|
82
|
+
currency: "EUR",
|
|
83
|
+
maximumFractionDigits: 0,
|
|
84
|
+
style: "currency"
|
|
85
|
+
};
|
|
86
|
+
function Aggregates() {
|
|
87
|
+
const $ = c(31);
|
|
88
|
+
const { t } = useWords("data-table");
|
|
89
|
+
const [aggregate, setAggregate] = useState("average");
|
|
90
|
+
let t0;
|
|
91
|
+
if ($[0] !== aggregate || $[1] !== t) {
|
|
92
|
+
let t1;
|
|
93
|
+
if ($[3] !== t) {
|
|
94
|
+
t1 = (sale) => ({
|
|
95
|
+
quarter: t(`pivot.${sale.quarter}`),
|
|
96
|
+
region: t(`pivot.${sale.region}`),
|
|
97
|
+
value: sale.value
|
|
98
|
+
});
|
|
99
|
+
$[3] = t;
|
|
100
|
+
$[4] = t1;
|
|
101
|
+
} else t1 = $[4];
|
|
102
|
+
t0 = pivot$1(SALES.map(t1), {
|
|
103
|
+
aggregate,
|
|
104
|
+
column: "quarter",
|
|
105
|
+
format: aggregate === "count" ? void 0 : EURO$20,
|
|
106
|
+
headers: { region: t("pivot.region") },
|
|
107
|
+
missingLabel: t("pivot.missing"),
|
|
108
|
+
rows: ["region"],
|
|
109
|
+
totalLabel: t("pivot.total"),
|
|
110
|
+
value: "value"
|
|
111
|
+
});
|
|
112
|
+
$[0] = aggregate;
|
|
113
|
+
$[1] = t;
|
|
114
|
+
$[2] = t0;
|
|
115
|
+
} else t0 = $[2];
|
|
116
|
+
const table = useDataTable(t0);
|
|
117
|
+
let t1;
|
|
118
|
+
if ($[5] !== t) {
|
|
119
|
+
t1 = t("aggregates.label");
|
|
120
|
+
$[5] = t;
|
|
121
|
+
$[6] = t1;
|
|
122
|
+
} else t1 = $[6];
|
|
123
|
+
let t2;
|
|
124
|
+
if ($[7] !== t1) {
|
|
125
|
+
t2 = /* @__PURE__ */ jsx(Field.Label, { children: t1 });
|
|
126
|
+
$[7] = t1;
|
|
127
|
+
$[8] = t2;
|
|
128
|
+
} else t2 = $[8];
|
|
129
|
+
let t3;
|
|
130
|
+
if ($[9] !== aggregate) {
|
|
131
|
+
t3 = (event) => {
|
|
132
|
+
const { value } = event.currentTarget;
|
|
133
|
+
setAggregate(AGGREGATES.find((each) => each === value) ?? aggregate);
|
|
134
|
+
};
|
|
135
|
+
$[9] = aggregate;
|
|
136
|
+
$[10] = t3;
|
|
137
|
+
} else t3 = $[10];
|
|
138
|
+
let t4;
|
|
139
|
+
if ($[11] !== t) {
|
|
140
|
+
t4 = AGGREGATES.map((each_0) => /* @__PURE__ */ jsx("option", {
|
|
141
|
+
value: each_0,
|
|
142
|
+
children: t(`aggregates.${each_0}`)
|
|
143
|
+
}, each_0));
|
|
144
|
+
$[11] = t;
|
|
145
|
+
$[12] = t4;
|
|
146
|
+
} else t4 = $[12];
|
|
147
|
+
let t5;
|
|
148
|
+
if ($[13] !== aggregate || $[14] !== t3 || $[15] !== t4) {
|
|
149
|
+
t5 = /* @__PURE__ */ jsx(NativeSelect.Field, {
|
|
150
|
+
onChange: t3,
|
|
151
|
+
value: aggregate,
|
|
152
|
+
children: t4
|
|
153
|
+
});
|
|
154
|
+
$[13] = aggregate;
|
|
155
|
+
$[14] = t3;
|
|
156
|
+
$[15] = t4;
|
|
157
|
+
$[16] = t5;
|
|
158
|
+
} else t5 = $[16];
|
|
159
|
+
let t6;
|
|
160
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
161
|
+
t6 = /* @__PURE__ */ jsx(NativeSelect.Indicator, { children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) });
|
|
162
|
+
$[17] = t6;
|
|
163
|
+
} else t6 = $[17];
|
|
164
|
+
let t7;
|
|
165
|
+
if ($[18] !== t5) {
|
|
166
|
+
t7 = /* @__PURE__ */ jsxs(NativeSelect.Root, { children: [t5, t6] });
|
|
167
|
+
$[18] = t5;
|
|
168
|
+
$[19] = t7;
|
|
169
|
+
} else t7 = $[19];
|
|
170
|
+
let t8;
|
|
171
|
+
if ($[20] !== t2 || $[21] !== t7) {
|
|
172
|
+
t8 = /* @__PURE__ */ jsx(Grid.Root, {
|
|
173
|
+
columns: "fill-xs",
|
|
174
|
+
children: /* @__PURE__ */ jsxs(Field.Root, {
|
|
175
|
+
orientation: "horizontal",
|
|
176
|
+
size: "sm",
|
|
177
|
+
children: [t2, t7]
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
$[20] = t2;
|
|
181
|
+
$[21] = t7;
|
|
182
|
+
$[22] = t8;
|
|
183
|
+
} else t8 = $[22];
|
|
184
|
+
let t9;
|
|
185
|
+
if ($[23] !== t) {
|
|
186
|
+
t9 = t("aggregates.caption");
|
|
187
|
+
$[23] = t;
|
|
188
|
+
$[24] = t9;
|
|
189
|
+
} else t9 = $[24];
|
|
190
|
+
let t10;
|
|
191
|
+
if ($[25] !== t9) {
|
|
192
|
+
t10 = /* @__PURE__ */ jsx(Table$1, {
|
|
193
|
+
caption: t9,
|
|
194
|
+
variant: "surface"
|
|
195
|
+
});
|
|
196
|
+
$[25] = t9;
|
|
197
|
+
$[26] = t10;
|
|
198
|
+
} else t10 = $[26];
|
|
199
|
+
let t11;
|
|
200
|
+
if ($[27] !== t10 || $[28] !== t8 || $[29] !== table) {
|
|
201
|
+
t11 = /* @__PURE__ */ jsxs(Root, {
|
|
202
|
+
table,
|
|
203
|
+
children: [t8, t10]
|
|
204
|
+
});
|
|
205
|
+
$[27] = t10;
|
|
206
|
+
$[28] = t8;
|
|
207
|
+
$[29] = table;
|
|
208
|
+
$[30] = t11;
|
|
209
|
+
} else t11 = $[30];
|
|
210
|
+
return t11;
|
|
211
|
+
}
|
|
212
|
+
const source$21 = "import { type ReactElement, useState } from \"react\";\n\nimport { ChevronDownIcon } from \"lucide-react\";\n\nimport { Field, NativeSelect } from \"@stealthscale/component-forms\";\nimport { Grid } from \"@stealthscale/component-layout\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { SALES } from \"./sales.ts\";\n\nconst AGGREGATES = [\"sum\", \"average\", \"min\", \"max\", \"count\"] as const;\n\nconst EURO = { currency: \"EUR\", maximumFractionDigits: 0, style: \"currency\" } as const;\n\nexport function Aggregates(): ReactElement {\n const { t } = useWords(\"data-table\");\n const [aggregate, setAggregate] = useState<DataTable.PivotAggregate>(\"average\");\n const table = DataTable.useDataTable(\n DataTable.pivot(\n SALES.map((sale) => ({\n quarter: t(`pivot.${sale.quarter}`),\n region: t(`pivot.${sale.region}`),\n value: sale.value,\n })),\n {\n aggregate,\n column: \"quarter\",\n format: aggregate === \"count\" ? undefined : EURO,\n headers: { region: t(\"pivot.region\") },\n missingLabel: t(\"pivot.missing\"),\n rows: [\"region\"],\n totalLabel: t(\"pivot.total\"),\n value: \"value\",\n },\n ),\n );\n\n return (\n <DataTable.Root table={table}>\n <Grid.Root columns=\"fill-xs\">\n <Field.Root orientation=\"horizontal\" size=\"sm\">\n <Field.Label>{t(\"aggregates.label\")}</Field.Label>\n <NativeSelect.Root>\n <NativeSelect.Field\n onChange={(event) => {\n const { value } = event.currentTarget;\n\n setAggregate(AGGREGATES.find((each) => each === value) ?? aggregate);\n }}\n value={aggregate}\n >\n {AGGREGATES.map((each) => (\n <option key={each} value={each}>\n {t(`aggregates.${each}`)}\n </option>\n ))}\n </NativeSelect.Field>\n <NativeSelect.Indicator>\n <ChevronDownIcon />\n </NativeSelect.Indicator>\n </NativeSelect.Root>\n </Field.Root>\n </Grid.Root>\n <DataTable.Table caption={t(\"aggregates.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/data-table/examples/claims.ts
|
|
215
|
+
/**
|
|
216
|
+
* Lists the categories in the order a picker offers them.
|
|
217
|
+
*/
|
|
218
|
+
const CATEGORIES = [
|
|
219
|
+
"travel",
|
|
220
|
+
"meals",
|
|
221
|
+
"software",
|
|
222
|
+
"office"
|
|
223
|
+
];
|
|
224
|
+
/**
|
|
225
|
+
* Lists the claims to review, in the order they were filed.
|
|
226
|
+
*/
|
|
227
|
+
const FILED = [
|
|
228
|
+
{
|
|
229
|
+
amount: 412.5,
|
|
230
|
+
category: "travel",
|
|
231
|
+
id: "EX-1041",
|
|
232
|
+
topic: "flight"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
amount: 186,
|
|
236
|
+
category: "travel",
|
|
237
|
+
id: "EX-1042",
|
|
238
|
+
topic: "hotel"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
amount: 64.8,
|
|
242
|
+
category: "meals",
|
|
243
|
+
id: "EX-1043",
|
|
244
|
+
topic: "dinner"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
amount: 38.2,
|
|
248
|
+
category: "travel",
|
|
249
|
+
id: "EX-1044",
|
|
250
|
+
topic: "taxi"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
amount: 129,
|
|
254
|
+
category: "software",
|
|
255
|
+
id: "EX-1045",
|
|
256
|
+
topic: "licence"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
amount: 249,
|
|
260
|
+
category: "office",
|
|
261
|
+
id: "EX-1046",
|
|
262
|
+
topic: "monitor"
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
/**
|
|
266
|
+
* Returns a claim with an edit written into it: an amount as a number, a category among the
|
|
267
|
+
* categories, and a description as typed.
|
|
268
|
+
*
|
|
269
|
+
* @param claim - The claim as it was before the edit.
|
|
270
|
+
* @param field - The claim's field the edit changes, its column's id.
|
|
271
|
+
* @param text - The text saved.
|
|
272
|
+
* @returns The claim with the field changed.
|
|
273
|
+
*/
|
|
274
|
+
function writtenTo(claim, field, text) {
|
|
275
|
+
return {
|
|
276
|
+
amount: field === "amount" ? Number(text) : claim.amount,
|
|
277
|
+
category: CATEGORIES.find((each) => field === "category" && each === text) ?? claim.category,
|
|
278
|
+
description: field === "description" ? text : claim.description,
|
|
279
|
+
id: claim.id
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Lists the fields of a claim a person edits.
|
|
284
|
+
*/
|
|
285
|
+
const FIELDS = [
|
|
286
|
+
"amount",
|
|
287
|
+
"category",
|
|
288
|
+
"description"
|
|
289
|
+
];
|
|
290
|
+
/**
|
|
291
|
+
* Returns the number of fields in which two lists of the same claims differ, claim by claim.
|
|
292
|
+
*
|
|
293
|
+
* @param rows - The claims as edited.
|
|
294
|
+
* @param saved - The claims as last saved, in the same order.
|
|
295
|
+
* @returns The number of changed fields.
|
|
296
|
+
*/
|
|
297
|
+
function changesOf(rows, saved) {
|
|
298
|
+
return rows.reduce((count, row, at) => count + FIELDS.filter((field) => row[field] !== saved[at]?.[field]).length, 0);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Returns whether a claim's field differs from its last saved value.
|
|
302
|
+
*
|
|
303
|
+
* @param rows - The claims as edited.
|
|
304
|
+
* @param saved - The claims as last saved, in the same order.
|
|
305
|
+
* @param id - Reference of the claim.
|
|
306
|
+
* @param field - The field, its column's id.
|
|
307
|
+
* @returns Whether the field changed, false for a field no person edits.
|
|
308
|
+
*/
|
|
309
|
+
function differs(rows, saved, id, field) {
|
|
310
|
+
const at = rows.findIndex((row) => row.id === id);
|
|
311
|
+
return FIELDS.some((each) => each === field && rows[at]?.[each] !== saved[at]?.[each]);
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/data-table/examples/claims.example.tsx
|
|
315
|
+
var claims_example_exports = /* @__PURE__ */ __exportAll({
|
|
316
|
+
Claims: () => Claims,
|
|
317
|
+
source: () => source$20
|
|
318
|
+
});
|
|
319
|
+
const column$19 = createColumnHelper();
|
|
320
|
+
const EURO$19 = {
|
|
321
|
+
currency: "EUR",
|
|
322
|
+
style: "currency"
|
|
323
|
+
};
|
|
324
|
+
function amountOf$18(value) {
|
|
325
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
326
|
+
options: EURO$19,
|
|
327
|
+
value
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function claimOf(id) {
|
|
331
|
+
return /* @__PURE__ */ jsx(Code, {
|
|
332
|
+
size: "sm",
|
|
333
|
+
children: id
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function picker(editor, names) {
|
|
337
|
+
return /* @__PURE__ */ jsx(NativeSelect.Root, {
|
|
338
|
+
size: editor.size,
|
|
339
|
+
children: /* @__PURE__ */ jsx(NativeSelect.Field, {
|
|
340
|
+
"aria-label": editor["aria-label"],
|
|
341
|
+
id: editor.id,
|
|
342
|
+
onChange: (event) => {
|
|
343
|
+
editor.commit(event.currentTarget.value);
|
|
344
|
+
},
|
|
345
|
+
value: editor.value,
|
|
346
|
+
children: CATEGORIES.map((category) => /* @__PURE__ */ jsx("option", {
|
|
347
|
+
value: category,
|
|
348
|
+
children: names[category]
|
|
349
|
+
}, category))
|
|
350
|
+
})
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function Claims() {
|
|
354
|
+
const $ = c(58);
|
|
355
|
+
const { t } = useWords("data-table");
|
|
356
|
+
let t0;
|
|
357
|
+
if ($[0] !== t) {
|
|
358
|
+
t0 = (each) => [each, t(`claims.${each}`)];
|
|
359
|
+
$[0] = t;
|
|
360
|
+
$[1] = t0;
|
|
361
|
+
} else t0 = $[1];
|
|
362
|
+
const names = Object.fromEntries(CATEGORIES.map(t0));
|
|
363
|
+
let t1;
|
|
364
|
+
if ($[2] !== t) {
|
|
365
|
+
t1 = () => FILED.map((filed) => ({
|
|
366
|
+
amount: filed.amount,
|
|
367
|
+
category: filed.category,
|
|
368
|
+
description: t(`claims.${filed.topic}`),
|
|
369
|
+
id: filed.id
|
|
370
|
+
}));
|
|
371
|
+
$[2] = t;
|
|
372
|
+
$[3] = t1;
|
|
373
|
+
} else t1 = $[3];
|
|
374
|
+
const [saved, setSaved] = useState(t1);
|
|
375
|
+
let t2;
|
|
376
|
+
if ($[4] !== saved) {
|
|
377
|
+
t2 = () => saved.map(_temp$19);
|
|
378
|
+
$[4] = saved;
|
|
379
|
+
$[5] = t2;
|
|
380
|
+
} else t2 = $[5];
|
|
381
|
+
const [rows, setRows] = useState(t2);
|
|
382
|
+
let t3;
|
|
383
|
+
if ($[6] !== t) {
|
|
384
|
+
t3 = (text) => text.trim() === "" ? t("claims.required") : void 0;
|
|
385
|
+
$[6] = t;
|
|
386
|
+
$[7] = t3;
|
|
387
|
+
} else t3 = $[7];
|
|
388
|
+
let t4;
|
|
389
|
+
if ($[8] !== t) {
|
|
390
|
+
t4 = (text_0) => /^\d+(\.\d{1,2})?$/u.test(text_0) ? void 0 : t("claims.invalid");
|
|
391
|
+
$[8] = t;
|
|
392
|
+
$[9] = t4;
|
|
393
|
+
} else t4 = $[9];
|
|
394
|
+
const t5 = column$19.columns([
|
|
395
|
+
column$19.accessor("id", {
|
|
396
|
+
cell: _temp2$19,
|
|
397
|
+
header: t("claims.claim"),
|
|
398
|
+
meta: { rowHeader: true }
|
|
399
|
+
}),
|
|
400
|
+
column$19.accessor("description", {
|
|
401
|
+
header: t("claims.description"),
|
|
402
|
+
meta: { edit: { validate: t3 } }
|
|
403
|
+
}),
|
|
404
|
+
column$19.accessor("category", {
|
|
405
|
+
cell: (cell_0) => names[cell_0.getValue()],
|
|
406
|
+
header: t("claims.category"),
|
|
407
|
+
meta: { edit: { editor: (editor) => picker(editor, names) } }
|
|
408
|
+
}),
|
|
409
|
+
column$19.accessor("amount", {
|
|
410
|
+
cell: _temp3$8,
|
|
411
|
+
header: t("claims.amount"),
|
|
412
|
+
meta: {
|
|
413
|
+
edit: { validate: t4 },
|
|
414
|
+
numeric: true
|
|
415
|
+
}
|
|
416
|
+
})
|
|
417
|
+
]);
|
|
418
|
+
let t6;
|
|
419
|
+
if ($[10] !== rows || $[11] !== t5) {
|
|
420
|
+
t6 = {
|
|
421
|
+
columns: t5,
|
|
422
|
+
data: rows,
|
|
423
|
+
getRowId: _temp4$4
|
|
424
|
+
};
|
|
425
|
+
$[10] = rows;
|
|
426
|
+
$[11] = t5;
|
|
427
|
+
$[12] = t6;
|
|
428
|
+
} else t6 = $[12];
|
|
429
|
+
const table = useDataTable(t6);
|
|
430
|
+
let t7;
|
|
431
|
+
if ($[13] !== t) {
|
|
432
|
+
t7 = t("claims.caption");
|
|
433
|
+
$[13] = t;
|
|
434
|
+
$[14] = t7;
|
|
435
|
+
} else t7 = $[14];
|
|
436
|
+
let t8;
|
|
437
|
+
if ($[15] !== rows || $[16] !== setRows) {
|
|
438
|
+
t8 = (edit) => {
|
|
439
|
+
setRows(rows.map((row_0) => row_0.id === edit.rowId ? writtenTo(row_0, edit.columnId, edit.value) : row_0));
|
|
440
|
+
};
|
|
441
|
+
$[15] = rows;
|
|
442
|
+
$[16] = setRows;
|
|
443
|
+
$[17] = t8;
|
|
444
|
+
} else t8 = $[17];
|
|
445
|
+
let t9;
|
|
446
|
+
if ($[18] !== rows || $[19] !== saved) {
|
|
447
|
+
t9 = (id, field) => differs(rows, saved, id, field);
|
|
448
|
+
$[18] = rows;
|
|
449
|
+
$[19] = saved;
|
|
450
|
+
$[20] = t9;
|
|
451
|
+
} else t9 = $[20];
|
|
452
|
+
let t10;
|
|
453
|
+
if ($[21] !== t) {
|
|
454
|
+
t10 = t("claims.unsaved");
|
|
455
|
+
$[21] = t;
|
|
456
|
+
$[22] = t10;
|
|
457
|
+
} else t10 = $[22];
|
|
458
|
+
let t11;
|
|
459
|
+
if ($[23] !== t10 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9) {
|
|
460
|
+
t11 = /* @__PURE__ */ jsx(Table$1, {
|
|
461
|
+
caption: t7,
|
|
462
|
+
grid: true,
|
|
463
|
+
onCellEdit: t8,
|
|
464
|
+
unsaved: t9,
|
|
465
|
+
unsavedLabel: t10,
|
|
466
|
+
variant: "surface"
|
|
467
|
+
});
|
|
468
|
+
$[23] = t10;
|
|
469
|
+
$[24] = t7;
|
|
470
|
+
$[25] = t8;
|
|
471
|
+
$[26] = t9;
|
|
472
|
+
$[27] = t11;
|
|
473
|
+
} else t11 = $[27];
|
|
474
|
+
let t12;
|
|
475
|
+
if ($[28] !== rows || $[29] !== saved || $[30] !== t) {
|
|
476
|
+
t12 = t("claims.changes", { count: changesOf(rows, saved) });
|
|
477
|
+
$[28] = rows;
|
|
478
|
+
$[29] = saved;
|
|
479
|
+
$[30] = t;
|
|
480
|
+
$[31] = t12;
|
|
481
|
+
} else t12 = $[31];
|
|
482
|
+
let t13;
|
|
483
|
+
if ($[32] !== t12) {
|
|
484
|
+
t13 = /* @__PURE__ */ jsx(Text, {
|
|
485
|
+
as: "output",
|
|
486
|
+
children: t12
|
|
487
|
+
});
|
|
488
|
+
$[32] = t12;
|
|
489
|
+
$[33] = t13;
|
|
490
|
+
} else t13 = $[33];
|
|
491
|
+
let t14;
|
|
492
|
+
if ($[34] !== saved || $[35] !== setRows) {
|
|
493
|
+
t14 = () => {
|
|
494
|
+
setRows(saved);
|
|
495
|
+
};
|
|
496
|
+
$[34] = saved;
|
|
497
|
+
$[35] = setRows;
|
|
498
|
+
$[36] = t14;
|
|
499
|
+
} else t14 = $[36];
|
|
500
|
+
let t15;
|
|
501
|
+
if ($[37] !== t) {
|
|
502
|
+
t15 = t("claims.discard");
|
|
503
|
+
$[37] = t;
|
|
504
|
+
$[38] = t15;
|
|
505
|
+
} else t15 = $[38];
|
|
506
|
+
let t16;
|
|
507
|
+
if ($[39] !== t14 || $[40] !== t15) {
|
|
508
|
+
t16 = /* @__PURE__ */ jsx(Button, {
|
|
509
|
+
onClick: t14,
|
|
510
|
+
variant: "ghost",
|
|
511
|
+
children: t15
|
|
512
|
+
});
|
|
513
|
+
$[39] = t14;
|
|
514
|
+
$[40] = t15;
|
|
515
|
+
$[41] = t16;
|
|
516
|
+
} else t16 = $[41];
|
|
517
|
+
let t17;
|
|
518
|
+
if ($[42] !== rows || $[43] !== setSaved) {
|
|
519
|
+
t17 = () => {
|
|
520
|
+
setSaved(rows);
|
|
521
|
+
};
|
|
522
|
+
$[42] = rows;
|
|
523
|
+
$[43] = setSaved;
|
|
524
|
+
$[44] = t17;
|
|
525
|
+
} else t17 = $[44];
|
|
526
|
+
let t18;
|
|
527
|
+
if ($[45] !== t) {
|
|
528
|
+
t18 = t("claims.save");
|
|
529
|
+
$[45] = t;
|
|
530
|
+
$[46] = t18;
|
|
531
|
+
} else t18 = $[46];
|
|
532
|
+
let t19;
|
|
533
|
+
if ($[47] !== t17 || $[48] !== t18) {
|
|
534
|
+
t19 = /* @__PURE__ */ jsx(Button, {
|
|
535
|
+
onClick: t17,
|
|
536
|
+
children: t18
|
|
537
|
+
});
|
|
538
|
+
$[47] = t17;
|
|
539
|
+
$[48] = t18;
|
|
540
|
+
$[49] = t19;
|
|
541
|
+
} else t19 = $[49];
|
|
542
|
+
let t20;
|
|
543
|
+
if ($[50] !== t13 || $[51] !== t16 || $[52] !== t19) {
|
|
544
|
+
t20 = /* @__PURE__ */ jsxs(Stack, {
|
|
545
|
+
direction: "row",
|
|
546
|
+
gap: "sm",
|
|
547
|
+
wrap: true,
|
|
548
|
+
children: [
|
|
549
|
+
t13,
|
|
550
|
+
t16,
|
|
551
|
+
t19
|
|
552
|
+
]
|
|
553
|
+
});
|
|
554
|
+
$[50] = t13;
|
|
555
|
+
$[51] = t16;
|
|
556
|
+
$[52] = t19;
|
|
557
|
+
$[53] = t20;
|
|
558
|
+
} else t20 = $[53];
|
|
559
|
+
let t21;
|
|
560
|
+
if ($[54] !== t11 || $[55] !== t20 || $[56] !== table) {
|
|
561
|
+
t21 = /* @__PURE__ */ jsxs(Root, {
|
|
562
|
+
table,
|
|
563
|
+
children: [t11, t20]
|
|
564
|
+
});
|
|
565
|
+
$[54] = t11;
|
|
566
|
+
$[55] = t20;
|
|
567
|
+
$[56] = table;
|
|
568
|
+
$[57] = t21;
|
|
569
|
+
} else t21 = $[57];
|
|
570
|
+
return t21;
|
|
571
|
+
}
|
|
572
|
+
function _temp4$4(row) {
|
|
573
|
+
return row.id;
|
|
574
|
+
}
|
|
575
|
+
function _temp3$8(cell_1) {
|
|
576
|
+
return amountOf$18(cell_1.getValue());
|
|
577
|
+
}
|
|
578
|
+
function _temp2$19(cell) {
|
|
579
|
+
return claimOf(cell.getValue());
|
|
580
|
+
}
|
|
581
|
+
function _temp$19(claim) {
|
|
582
|
+
return claim.id === "EX-1044" ? writtenTo(claim, "amount", "42.6") : claim;
|
|
583
|
+
}
|
|
584
|
+
const source$20 = "import { type ReactElement, type ReactNode, useState } from \"react\";\n\nimport { Button } from \"@stealthscale/component-actions\";\nimport { Format } from \"@stealthscale/component-data\";\nimport { NativeSelect } from \"@stealthscale/component-forms\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { Code, Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { CATEGORIES, changesOf, type Claim, differs, FILED, writtenTo } from \"./claims.ts\";\n\nconst column = DataTable.createColumnHelper<Claim>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction claimOf(id: string): ReactElement {\n return <Code size=\"sm\">{id}</Code>;\n}\n\nfunction picker(editor: DataTable.EditorProps, names: Readonly<Record<string, string>>): ReactNode {\n return (\n <NativeSelect.Root size={editor.size}>\n <NativeSelect.Field\n aria-label={editor[\"aria-label\"]}\n id={editor.id}\n onChange={(event) => {\n editor.commit(event.currentTarget.value);\n }}\n value={editor.value}\n >\n {CATEGORIES.map((category) => (\n <option key={category} value={category}>\n {names[category]}\n </option>\n ))}\n </NativeSelect.Field>\n </NativeSelect.Root>\n );\n}\n\nexport function Claims(): ReactElement {\n const { t } = useWords(\"data-table\");\n const names = Object.fromEntries(CATEGORIES.map((each) => [each, t(`claims.${each}`)]));\n const [saved, setSaved] = useState(() =>\n FILED.map((filed) => ({\n amount: filed.amount,\n category: filed.category,\n description: t(`claims.${filed.topic}`),\n id: filed.id,\n })),\n );\n const [rows, setRows] = useState(() =>\n saved.map((claim) => (claim.id === \"EX-1044\" ? writtenTo(claim, \"amount\", \"42.6\") : claim)),\n );\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"id\", {\n cell: (cell) => claimOf(cell.getValue()),\n header: t(\"claims.claim\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"description\", {\n header: t(\"claims.description\"),\n meta: {\n edit: { validate: (text) => (text.trim() === \"\" ? t(\"claims.required\") : undefined) },\n },\n }),\n column.accessor(\"category\", {\n cell: (cell) => names[cell.getValue()],\n header: t(\"claims.category\"),\n meta: { edit: { editor: (editor) => picker(editor, names) } },\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"claims.amount\"),\n meta: {\n edit: {\n validate: (text) => (/^\\d+(\\.\\d{1,2})?$/u.test(text) ? undefined : t(\"claims.invalid\")),\n },\n numeric: true,\n },\n }),\n ]),\n data: rows,\n getRowId: (row) => row.id,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"claims.caption\")}\n grid\n onCellEdit={(edit) => {\n setRows(\n rows.map((row) =>\n row.id === edit.rowId ? writtenTo(row, edit.columnId, edit.value) : row,\n ),\n );\n }}\n unsaved={(id, field) => differs(rows, saved, id, field)}\n unsavedLabel={t(\"claims.unsaved\")}\n variant=\"surface\"\n />\n <Stack direction=\"row\" gap=\"sm\" wrap>\n <Text as=\"output\">{t(\"claims.changes\", { count: changesOf(rows, saved) })}</Text>\n <Button\n onClick={() => {\n setRows(saved);\n }}\n variant=\"ghost\"\n >\n {t(\"claims.discard\")}\n </Button>\n <Button\n onClick={() => {\n setSaved(rows);\n }}\n >\n {t(\"claims.save\")}\n </Button>\n </Stack>\n </DataTable.Root>\n );\n}\n";
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region src/data-table/examples/payouts.ts
|
|
587
|
+
/**
|
|
588
|
+
* Lists the quarter's payouts in the order they were first made.
|
|
589
|
+
*/
|
|
590
|
+
const PAYOUTS = [
|
|
591
|
+
{
|
|
592
|
+
account: "bridgewater",
|
|
593
|
+
amount: 4120,
|
|
594
|
+
region: "benelux",
|
|
595
|
+
transfers: 12
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
account: "halden",
|
|
599
|
+
amount: 880.4,
|
|
600
|
+
region: "nordics",
|
|
601
|
+
transfers: 3
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
account: "perrin",
|
|
605
|
+
amount: 12500,
|
|
606
|
+
region: "benelux",
|
|
607
|
+
transfers: 27
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
account: "kestrel",
|
|
611
|
+
amount: 2310.75,
|
|
612
|
+
region: "nordics",
|
|
613
|
+
transfers: 8
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
account: "linnet",
|
|
617
|
+
amount: 640,
|
|
618
|
+
region: "iberia",
|
|
619
|
+
transfers: 2
|
|
620
|
+
}
|
|
621
|
+
];
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/data-table/examples/columns.example.tsx
|
|
624
|
+
var columns_example_exports = /* @__PURE__ */ __exportAll({
|
|
625
|
+
Columns: () => Columns,
|
|
626
|
+
source: () => source$19
|
|
627
|
+
});
|
|
628
|
+
const column$18 = createColumnHelper();
|
|
629
|
+
const EURO$18 = {
|
|
630
|
+
currency: "EUR",
|
|
631
|
+
style: "currency"
|
|
632
|
+
};
|
|
633
|
+
const SHARE = {
|
|
634
|
+
maximumFractionDigits: 1,
|
|
635
|
+
style: "percent"
|
|
636
|
+
};
|
|
637
|
+
const TOTAL = PAYOUTS.reduce((sum, payout) => sum + payout.amount, 0);
|
|
638
|
+
function amountOf$17(value) {
|
|
639
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
640
|
+
options: EURO$18,
|
|
641
|
+
value
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function shareOf(value) {
|
|
645
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
646
|
+
options: SHARE,
|
|
647
|
+
value
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
function Columns() {
|
|
651
|
+
const $ = c(21);
|
|
652
|
+
const { t } = useWords("data-table");
|
|
653
|
+
let t0;
|
|
654
|
+
if ($[0] !== t) {
|
|
655
|
+
let t1;
|
|
656
|
+
let t2;
|
|
657
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
658
|
+
t1 = /* @__PURE__ */ jsx(MinusIcon, { strokeWidth: 3 });
|
|
659
|
+
t2 = /* @__PURE__ */ jsx(CheckIcon, { strokeWidth: 3 });
|
|
660
|
+
$[2] = t1;
|
|
661
|
+
$[3] = t2;
|
|
662
|
+
} else {
|
|
663
|
+
t1 = $[2];
|
|
664
|
+
t2 = $[3];
|
|
665
|
+
}
|
|
666
|
+
t0 = column$18.columns([
|
|
667
|
+
selectColumn({
|
|
668
|
+
allLabel: t("selection.all"),
|
|
669
|
+
indeterminateIndicator: t1,
|
|
670
|
+
indicator: t2,
|
|
671
|
+
label: (payout) => t("selection.one", { account: t(payout.account) })
|
|
672
|
+
}),
|
|
673
|
+
column$18.accessor("account", {
|
|
674
|
+
cell: (cell) => t(cell.getValue()),
|
|
675
|
+
header: t("account"),
|
|
676
|
+
meta: { rowHeader: true },
|
|
677
|
+
size: 200
|
|
678
|
+
}),
|
|
679
|
+
column$18.accessor("transfers", {
|
|
680
|
+
header: t("transfers"),
|
|
681
|
+
meta: { numeric: true },
|
|
682
|
+
size: 120
|
|
683
|
+
}),
|
|
684
|
+
column$18.accessor(_temp$18, {
|
|
685
|
+
cell: _temp2$18,
|
|
686
|
+
header: t("details.average"),
|
|
687
|
+
id: "average",
|
|
688
|
+
meta: { numeric: true },
|
|
689
|
+
size: 180
|
|
690
|
+
}),
|
|
691
|
+
column$18.accessor(_temp3$7, {
|
|
692
|
+
cell: _temp4$3,
|
|
693
|
+
header: t("columns.share"),
|
|
694
|
+
id: "share",
|
|
695
|
+
meta: { numeric: true },
|
|
696
|
+
size: 110
|
|
697
|
+
}),
|
|
698
|
+
column$18.accessor("amount", {
|
|
699
|
+
cell: _temp5,
|
|
700
|
+
header: t("amount"),
|
|
701
|
+
meta: { numeric: true },
|
|
702
|
+
size: 140
|
|
703
|
+
})
|
|
704
|
+
]);
|
|
705
|
+
$[0] = t;
|
|
706
|
+
$[1] = t0;
|
|
707
|
+
} else t0 = $[1];
|
|
708
|
+
let t1;
|
|
709
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
710
|
+
t1 = {
|
|
711
|
+
maxSize: 360,
|
|
712
|
+
minSize: 80
|
|
713
|
+
};
|
|
714
|
+
$[4] = t1;
|
|
715
|
+
} else t1 = $[4];
|
|
716
|
+
let t2;
|
|
717
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
718
|
+
t2 = { columnPinning: {
|
|
719
|
+
end: [],
|
|
720
|
+
start: ["select", "account"]
|
|
721
|
+
} };
|
|
722
|
+
$[5] = t2;
|
|
723
|
+
} else t2 = $[5];
|
|
724
|
+
let t3;
|
|
725
|
+
if ($[6] !== t0) {
|
|
726
|
+
t3 = {
|
|
727
|
+
columns: t0,
|
|
728
|
+
data: PAYOUTS,
|
|
729
|
+
defaultColumn: t1,
|
|
730
|
+
enableColumnResizing: true,
|
|
731
|
+
getRowId: _temp6,
|
|
732
|
+
initialState: t2
|
|
733
|
+
};
|
|
734
|
+
$[6] = t0;
|
|
735
|
+
$[7] = t3;
|
|
736
|
+
} else t3 = $[7];
|
|
737
|
+
const table = useDataTable(t3);
|
|
738
|
+
let t4;
|
|
739
|
+
if ($[8] !== t) {
|
|
740
|
+
t4 = t("columns.caption");
|
|
741
|
+
$[8] = t;
|
|
742
|
+
$[9] = t4;
|
|
743
|
+
} else t4 = $[9];
|
|
744
|
+
let t5;
|
|
745
|
+
let t6;
|
|
746
|
+
if ($[10] !== t) {
|
|
747
|
+
t5 = (name) => t("columns.resize", { column: name });
|
|
748
|
+
t6 = (size) => t("columns.size", { size });
|
|
749
|
+
$[10] = t;
|
|
750
|
+
$[11] = t5;
|
|
751
|
+
$[12] = t6;
|
|
752
|
+
} else {
|
|
753
|
+
t5 = $[11];
|
|
754
|
+
t6 = $[12];
|
|
755
|
+
}
|
|
756
|
+
let t7;
|
|
757
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
758
|
+
t7 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
759
|
+
$[13] = t7;
|
|
760
|
+
} else t7 = $[13];
|
|
761
|
+
let t8;
|
|
762
|
+
if ($[14] !== t4 || $[15] !== t5 || $[16] !== t6) {
|
|
763
|
+
t8 = /* @__PURE__ */ jsx(Table$1, {
|
|
764
|
+
caption: t4,
|
|
765
|
+
resizeLabel: t5,
|
|
766
|
+
resizeValue: t6,
|
|
767
|
+
sortIndicator: t7,
|
|
768
|
+
variant: "surface"
|
|
769
|
+
});
|
|
770
|
+
$[14] = t4;
|
|
771
|
+
$[15] = t5;
|
|
772
|
+
$[16] = t6;
|
|
773
|
+
$[17] = t8;
|
|
774
|
+
} else t8 = $[17];
|
|
775
|
+
let t9;
|
|
776
|
+
if ($[18] !== t8 || $[19] !== table) {
|
|
777
|
+
t9 = /* @__PURE__ */ jsx(Root, {
|
|
778
|
+
table,
|
|
779
|
+
children: t8
|
|
780
|
+
});
|
|
781
|
+
$[18] = t8;
|
|
782
|
+
$[19] = table;
|
|
783
|
+
$[20] = t9;
|
|
784
|
+
} else t9 = $[20];
|
|
785
|
+
return t9;
|
|
786
|
+
}
|
|
787
|
+
function _temp6(row) {
|
|
788
|
+
return row.account;
|
|
789
|
+
}
|
|
790
|
+
function _temp5(cell_2) {
|
|
791
|
+
return amountOf$17(cell_2.getValue());
|
|
792
|
+
}
|
|
793
|
+
function _temp4$3(cell_1) {
|
|
794
|
+
return shareOf(cell_1.getValue());
|
|
795
|
+
}
|
|
796
|
+
function _temp3$7(payout_1) {
|
|
797
|
+
return payout_1.amount / TOTAL;
|
|
798
|
+
}
|
|
799
|
+
function _temp2$18(cell_0) {
|
|
800
|
+
return amountOf$17(cell_0.getValue());
|
|
801
|
+
}
|
|
802
|
+
function _temp$18(payout_0) {
|
|
803
|
+
return payout_0.amount / payout_0.transfers;
|
|
804
|
+
}
|
|
805
|
+
const source$19 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, CheckIcon, MinusIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst SHARE = { maximumFractionDigits: 1, style: \"percent\" } as const;\n\nconst TOTAL = PAYOUTS.reduce((sum, payout) => sum + payout.amount, 0);\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction shareOf(value: number): ReactElement {\n return <Format.Number options={SHARE} value={value} />;\n}\n\nexport function Columns(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n DataTable.selectColumn<Payout>({\n allLabel: t(\"selection.all\"),\n indeterminateIndicator: <MinusIcon strokeWidth={3} />,\n indicator: <CheckIcon strokeWidth={3} />,\n label: (payout) => t(\"selection.one\", { account: t(payout.account) }),\n }),\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n size: 200,\n }),\n column.accessor(\"transfers\", { header: t(\"transfers\"), meta: { numeric: true }, size: 120 }),\n column.accessor((payout) => payout.amount / payout.transfers, {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"details.average\"),\n id: \"average\",\n meta: { numeric: true },\n size: 180,\n }),\n column.accessor((payout) => payout.amount / TOTAL, {\n cell: (cell) => shareOf(cell.getValue()),\n header: t(\"columns.share\"),\n id: \"share\",\n meta: { numeric: true },\n size: 110,\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n size: 140,\n }),\n ]),\n data: PAYOUTS,\n defaultColumn: { maxSize: 360, minSize: 80 },\n enableColumnResizing: true,\n getRowId: (row) => row.account,\n initialState: { columnPinning: { end: [], start: [\"select\", \"account\"] } },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"columns.caption\")}\n resizeLabel={(name) => t(\"columns.resize\", { column: name })}\n resizeValue={(size) => t(\"columns.size\", { size })}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/data-table/examples/details.example.tsx
|
|
808
|
+
var details_example_exports = /* @__PURE__ */ __exportAll({
|
|
809
|
+
Details: () => Details,
|
|
810
|
+
source: () => source$18
|
|
811
|
+
});
|
|
812
|
+
const column$17 = createColumnHelper();
|
|
813
|
+
const EURO$17 = {
|
|
814
|
+
currency: "EUR",
|
|
815
|
+
style: "currency"
|
|
816
|
+
};
|
|
817
|
+
function amountOf$16(value) {
|
|
818
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
819
|
+
options: EURO$17,
|
|
820
|
+
value
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function detailOf(payout, words) {
|
|
824
|
+
return /* @__PURE__ */ jsxs(DataList.Root, {
|
|
825
|
+
orientation: "horizontal",
|
|
826
|
+
children: [/* @__PURE__ */ jsxs(DataList.Item, { children: [/* @__PURE__ */ jsx(DataList.ItemLabel, { children: words.transfers }), /* @__PURE__ */ jsx(DataList.ItemValue, { children: payout.transfers })] }), /* @__PURE__ */ jsxs(DataList.Item, { children: [/* @__PURE__ */ jsx(DataList.ItemLabel, { children: words.average }), /* @__PURE__ */ jsx(DataList.ItemValue, { children: amountOf$16(payout.amount / payout.transfers) })] })]
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
function Details() {
|
|
830
|
+
const $ = c(14);
|
|
831
|
+
const { t } = useWords("data-table");
|
|
832
|
+
const words = {
|
|
833
|
+
average: t("details.average"),
|
|
834
|
+
transfers: t("transfers")
|
|
835
|
+
};
|
|
836
|
+
let t0;
|
|
837
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
838
|
+
t0 = /* @__PURE__ */ jsx(ChevronRightIcon, { size: "1em" });
|
|
839
|
+
$[0] = t0;
|
|
840
|
+
} else t0 = $[0];
|
|
841
|
+
let t1;
|
|
842
|
+
if ($[1] !== t) {
|
|
843
|
+
t1 = (payout_0) => t("details.one", { account: t(payout_0.account) });
|
|
844
|
+
$[1] = t;
|
|
845
|
+
$[2] = t1;
|
|
846
|
+
} else t1 = $[2];
|
|
847
|
+
let t2;
|
|
848
|
+
if ($[3] !== t) {
|
|
849
|
+
t2 = (cell) => t(cell.getValue());
|
|
850
|
+
$[3] = t;
|
|
851
|
+
$[4] = t2;
|
|
852
|
+
} else t2 = $[4];
|
|
853
|
+
const t3 = column$17.columns([
|
|
854
|
+
expandColumn({
|
|
855
|
+
detail: (payout) => detailOf(payout, words),
|
|
856
|
+
header: t("details.header"),
|
|
857
|
+
indicator: t0,
|
|
858
|
+
label: t1
|
|
859
|
+
}),
|
|
860
|
+
column$17.accessor("account", {
|
|
861
|
+
cell: t2,
|
|
862
|
+
header: t("account"),
|
|
863
|
+
meta: { rowHeader: true }
|
|
864
|
+
}),
|
|
865
|
+
column$17.accessor("amount", {
|
|
866
|
+
cell: _temp$17,
|
|
867
|
+
header: t("amount"),
|
|
868
|
+
meta: { numeric: true }
|
|
869
|
+
})
|
|
870
|
+
]);
|
|
871
|
+
let t4;
|
|
872
|
+
if ($[5] !== t3) {
|
|
873
|
+
t4 = {
|
|
874
|
+
columns: t3,
|
|
875
|
+
data: PAYOUTS,
|
|
876
|
+
getRowCanExpand: _temp2$17,
|
|
877
|
+
getRowId: _temp3$6
|
|
878
|
+
};
|
|
879
|
+
$[5] = t3;
|
|
880
|
+
$[6] = t4;
|
|
881
|
+
} else t4 = $[6];
|
|
882
|
+
const table = useDataTable(t4);
|
|
883
|
+
let t5;
|
|
884
|
+
if ($[7] !== t) {
|
|
885
|
+
t5 = t("details.caption");
|
|
886
|
+
$[7] = t;
|
|
887
|
+
$[8] = t5;
|
|
888
|
+
} else t5 = $[8];
|
|
889
|
+
let t6;
|
|
890
|
+
if ($[9] !== t5) {
|
|
891
|
+
t6 = /* @__PURE__ */ jsx(Table$1, {
|
|
892
|
+
caption: t5,
|
|
893
|
+
variant: "surface"
|
|
894
|
+
});
|
|
895
|
+
$[9] = t5;
|
|
896
|
+
$[10] = t6;
|
|
897
|
+
} else t6 = $[10];
|
|
898
|
+
let t7;
|
|
899
|
+
if ($[11] !== t6 || $[12] !== table) {
|
|
900
|
+
t7 = /* @__PURE__ */ jsx(Root, {
|
|
901
|
+
table,
|
|
902
|
+
children: t6
|
|
903
|
+
});
|
|
904
|
+
$[11] = t6;
|
|
905
|
+
$[12] = table;
|
|
906
|
+
$[13] = t7;
|
|
907
|
+
} else t7 = $[13];
|
|
908
|
+
return t7;
|
|
909
|
+
}
|
|
910
|
+
function _temp3$6(row) {
|
|
911
|
+
return row.account;
|
|
912
|
+
}
|
|
913
|
+
function _temp2$17() {
|
|
914
|
+
return true;
|
|
915
|
+
}
|
|
916
|
+
function _temp$17(cell_0) {
|
|
917
|
+
return amountOf$16(cell_0.getValue());
|
|
918
|
+
}
|
|
919
|
+
const source$18 = "import { type ReactElement } from \"react\";\n\nimport { ChevronRightIcon } from \"lucide-react\";\n\nimport { DataList } from \"@stealthscale/component-collections\";\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\ninterface Words {\n readonly average: string;\n readonly transfers: string;\n}\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction detailOf(payout: Payout, words: Words): ReactElement {\n return (\n <DataList.Root orientation=\"horizontal\">\n <DataList.Item>\n <DataList.ItemLabel>{words.transfers}</DataList.ItemLabel>\n <DataList.ItemValue>{payout.transfers}</DataList.ItemValue>\n </DataList.Item>\n <DataList.Item>\n <DataList.ItemLabel>{words.average}</DataList.ItemLabel>\n <DataList.ItemValue>{amountOf(payout.amount / payout.transfers)}</DataList.ItemValue>\n </DataList.Item>\n </DataList.Root>\n );\n}\n\nexport function Details(): ReactElement {\n const { t } = useWords(\"data-table\");\n const words = { average: t(\"details.average\"), transfers: t(\"transfers\") };\n const table = DataTable.useDataTable({\n columns: column.columns([\n DataTable.expandColumn<Payout>({\n detail: (payout) => detailOf(payout, words),\n header: t(\"details.header\"),\n indicator: <ChevronRightIcon size=\"1em\" />,\n label: (payout) => t(\"details.one\", { account: t(payout.account) }),\n }),\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowCanExpand: () => true,\n getRowId: (row) => row.account,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table caption={t(\"details.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/data-table/examples/transfers.ts
|
|
922
|
+
/**
|
|
923
|
+
* Lists each account with its region, in the order the transfers take turns.
|
|
924
|
+
*/
|
|
925
|
+
const ACCOUNTS = [
|
|
926
|
+
["bridgewater", "benelux"],
|
|
927
|
+
["halden", "nordics"],
|
|
928
|
+
["perrin", "benelux"],
|
|
929
|
+
["kestrel", "nordics"],
|
|
930
|
+
["linnet", "iberia"]
|
|
931
|
+
];
|
|
932
|
+
/**
|
|
933
|
+
* Returns the state of the transfer at a place: of every six, the third is pending, the fifth
|
|
934
|
+
* failed and the rest settled.
|
|
935
|
+
*/
|
|
936
|
+
function stateOf(at) {
|
|
937
|
+
if (at % 6 === 2) return "pending";
|
|
938
|
+
return at % 6 === 4 ? "failed" : "settled";
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Returns transfers to the five accounts in turn, newest first.
|
|
942
|
+
*
|
|
943
|
+
* @param count - Number of transfers.
|
|
944
|
+
* @param newest - Number in the newest transfer's reference. Each older reference counts one down.
|
|
945
|
+
* @returns `count` transfers, newest first.
|
|
946
|
+
*/
|
|
947
|
+
function transfersOf(count, newest) {
|
|
948
|
+
return Array.from({ length: Math.ceil(count / ACCOUNTS.length) }, (_, round) => ACCOUNTS.map(([account, region], turn) => ({
|
|
949
|
+
account,
|
|
950
|
+
at: round * ACCOUNTS.length + turn,
|
|
951
|
+
region
|
|
952
|
+
}))).flat().slice(0, count).map(({ account, at, region }) => ({
|
|
953
|
+
account,
|
|
954
|
+
amount: 120 + at * 373 % 4200,
|
|
955
|
+
reference: `TR-${String(newest - at)}`,
|
|
956
|
+
region,
|
|
957
|
+
state: stateOf(at)
|
|
958
|
+
}));
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Lists the quarter's transfers, newest first.
|
|
962
|
+
*/
|
|
963
|
+
const TRANSFERS = transfersOf(48, 1048);
|
|
964
|
+
/**
|
|
965
|
+
* Lists the twelve newest transfers, for the examples that show every row.
|
|
966
|
+
*/
|
|
967
|
+
const RECENT = TRANSFERS.slice(0, 12);
|
|
968
|
+
/**
|
|
969
|
+
* Arrival before the first page, for no request.
|
|
970
|
+
*/
|
|
971
|
+
const NONE = {
|
|
972
|
+
key: "",
|
|
973
|
+
page: {
|
|
974
|
+
count: 0,
|
|
975
|
+
rows: []
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
/**
|
|
979
|
+
* Returns the page of transfers a request asks for.
|
|
980
|
+
*
|
|
981
|
+
* @param request - The page, its size, the search and the sort.
|
|
982
|
+
* @returns The transfers on the page and the number that match.
|
|
983
|
+
*/
|
|
984
|
+
function pageOf({ pageIndex, pageSize, search, sort }) {
|
|
985
|
+
const found = TRANSFERS.filter((transfer) => transfer.reference.toLowerCase().includes(search.toLowerCase()));
|
|
986
|
+
const sorted = sort?.id === "amount" ? found.toSorted((a, b) => sort.desc ? b.amount - a.amount : a.amount - b.amount) : found;
|
|
987
|
+
return {
|
|
988
|
+
count: found.length,
|
|
989
|
+
rows: sorted.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize)
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Resolves a request with its page after the delay.
|
|
994
|
+
*
|
|
995
|
+
* @param request - The page, its size, the search and the sort.
|
|
996
|
+
* @returns The page, once the delay has passed.
|
|
997
|
+
*/
|
|
998
|
+
function fetchPage(request) {
|
|
999
|
+
return new Promise((resolve) => {
|
|
1000
|
+
setTimeout(() => {
|
|
1001
|
+
resolve(pageOf(request));
|
|
1002
|
+
}, 400);
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Requests a page whenever the request changes, and returns the last page that arrived.
|
|
1007
|
+
*
|
|
1008
|
+
* @remarks
|
|
1009
|
+
* A page that arrives for a request a newer one replaced is dropped.
|
|
1010
|
+
* @param request - The page, its size, the search and the sort.
|
|
1011
|
+
* @returns The last page that arrived and whether a newer request waits.
|
|
1012
|
+
*/
|
|
1013
|
+
function useServerPage(request) {
|
|
1014
|
+
const $ = c(17);
|
|
1015
|
+
const { pageIndex, pageSize, search, sort } = request;
|
|
1016
|
+
const id = sort?.id;
|
|
1017
|
+
const desc = sort?.desc === true;
|
|
1018
|
+
let t0;
|
|
1019
|
+
if ($[0] !== desc || $[1] !== id || $[2] !== pageIndex || $[3] !== pageSize || $[4] !== search) {
|
|
1020
|
+
t0 = JSON.stringify([
|
|
1021
|
+
pageIndex,
|
|
1022
|
+
pageSize,
|
|
1023
|
+
search,
|
|
1024
|
+
id,
|
|
1025
|
+
desc
|
|
1026
|
+
]);
|
|
1027
|
+
$[0] = desc;
|
|
1028
|
+
$[1] = id;
|
|
1029
|
+
$[2] = pageIndex;
|
|
1030
|
+
$[3] = pageSize;
|
|
1031
|
+
$[4] = search;
|
|
1032
|
+
$[5] = t0;
|
|
1033
|
+
} else t0 = $[5];
|
|
1034
|
+
const key = t0;
|
|
1035
|
+
const [arrived, setArrived] = useState(NONE);
|
|
1036
|
+
let t1;
|
|
1037
|
+
let t2;
|
|
1038
|
+
if ($[6] !== desc || $[7] !== id || $[8] !== key || $[9] !== pageIndex || $[10] !== pageSize || $[11] !== search) {
|
|
1039
|
+
t1 = () => {
|
|
1040
|
+
let current = true;
|
|
1041
|
+
const sorted = id === void 0 ? void 0 : {
|
|
1042
|
+
desc,
|
|
1043
|
+
id
|
|
1044
|
+
};
|
|
1045
|
+
(async function load() {
|
|
1046
|
+
const page = await fetchPage({
|
|
1047
|
+
pageIndex,
|
|
1048
|
+
pageSize,
|
|
1049
|
+
search,
|
|
1050
|
+
sort: sorted
|
|
1051
|
+
});
|
|
1052
|
+
if (current) setArrived({
|
|
1053
|
+
key,
|
|
1054
|
+
page
|
|
1055
|
+
});
|
|
1056
|
+
})();
|
|
1057
|
+
return () => {
|
|
1058
|
+
current = false;
|
|
1059
|
+
};
|
|
1060
|
+
};
|
|
1061
|
+
t2 = [
|
|
1062
|
+
desc,
|
|
1063
|
+
id,
|
|
1064
|
+
key,
|
|
1065
|
+
pageIndex,
|
|
1066
|
+
pageSize,
|
|
1067
|
+
search
|
|
1068
|
+
];
|
|
1069
|
+
$[6] = desc;
|
|
1070
|
+
$[7] = id;
|
|
1071
|
+
$[8] = key;
|
|
1072
|
+
$[9] = pageIndex;
|
|
1073
|
+
$[10] = pageSize;
|
|
1074
|
+
$[11] = search;
|
|
1075
|
+
$[12] = t1;
|
|
1076
|
+
$[13] = t2;
|
|
1077
|
+
} else {
|
|
1078
|
+
t1 = $[12];
|
|
1079
|
+
t2 = $[13];
|
|
1080
|
+
}
|
|
1081
|
+
useEffect(t1, t2);
|
|
1082
|
+
const t3 = arrived.key !== key;
|
|
1083
|
+
let t4;
|
|
1084
|
+
if ($[14] !== arrived.page || $[15] !== t3) {
|
|
1085
|
+
t4 = {
|
|
1086
|
+
loading: t3,
|
|
1087
|
+
page: arrived.page
|
|
1088
|
+
};
|
|
1089
|
+
$[14] = arrived.page;
|
|
1090
|
+
$[15] = t3;
|
|
1091
|
+
$[16] = t4;
|
|
1092
|
+
} else t4 = $[16];
|
|
1093
|
+
return t4;
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/data-table/examples/endless.example.tsx
|
|
1097
|
+
var endless_example_exports = /* @__PURE__ */ __exportAll({
|
|
1098
|
+
Endless: () => Endless,
|
|
1099
|
+
source: () => source$17
|
|
1100
|
+
});
|
|
1101
|
+
const column$16 = createColumnHelper();
|
|
1102
|
+
const EURO$16 = {
|
|
1103
|
+
currency: "EUR",
|
|
1104
|
+
style: "currency"
|
|
1105
|
+
};
|
|
1106
|
+
const BATCH = 50;
|
|
1107
|
+
const ARCHIVE = transfersOf(1e3, 11e3);
|
|
1108
|
+
function amountOf$15(value) {
|
|
1109
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
1110
|
+
options: EURO$16,
|
|
1111
|
+
value
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
function Endless() {
|
|
1115
|
+
const $ = c(25);
|
|
1116
|
+
const { t } = useWords("data-table");
|
|
1117
|
+
const [rows, setRows] = useState(_temp$16);
|
|
1118
|
+
const [loading, setLoading] = useState(false);
|
|
1119
|
+
let t0;
|
|
1120
|
+
if ($[0] !== t) {
|
|
1121
|
+
t0 = column$16.columns([
|
|
1122
|
+
column$16.accessor("reference", {
|
|
1123
|
+
header: t("ledger.reference"),
|
|
1124
|
+
meta: { rowHeader: true },
|
|
1125
|
+
size: 150
|
|
1126
|
+
}),
|
|
1127
|
+
column$16.accessor((transfer) => t(transfer.account), {
|
|
1128
|
+
header: t("account"),
|
|
1129
|
+
id: "account",
|
|
1130
|
+
size: 230
|
|
1131
|
+
}),
|
|
1132
|
+
column$16.accessor("amount", {
|
|
1133
|
+
cell: _temp2$16,
|
|
1134
|
+
header: t("amount"),
|
|
1135
|
+
meta: { numeric: true },
|
|
1136
|
+
size: 176
|
|
1137
|
+
})
|
|
1138
|
+
]);
|
|
1139
|
+
$[0] = t;
|
|
1140
|
+
$[1] = t0;
|
|
1141
|
+
} else t0 = $[1];
|
|
1142
|
+
let t1;
|
|
1143
|
+
if ($[2] !== rows || $[3] !== t0) {
|
|
1144
|
+
t1 = {
|
|
1145
|
+
columns: t0,
|
|
1146
|
+
data: rows,
|
|
1147
|
+
getRowId: _temp3$5
|
|
1148
|
+
};
|
|
1149
|
+
$[2] = rows;
|
|
1150
|
+
$[3] = t0;
|
|
1151
|
+
$[4] = t1;
|
|
1152
|
+
} else t1 = $[4];
|
|
1153
|
+
const table = useDataTable(t1);
|
|
1154
|
+
let t2;
|
|
1155
|
+
if ($[5] !== t) {
|
|
1156
|
+
t2 = t("endless.caption");
|
|
1157
|
+
$[5] = t;
|
|
1158
|
+
$[6] = t2;
|
|
1159
|
+
} else t2 = $[6];
|
|
1160
|
+
let t3;
|
|
1161
|
+
if ($[7] !== rows.length) {
|
|
1162
|
+
t3 = () => {
|
|
1163
|
+
if (rows.length === ARCHIVE.length) return;
|
|
1164
|
+
setLoading(true);
|
|
1165
|
+
setTimeout(() => {
|
|
1166
|
+
setRows(ARCHIVE.slice(0, rows.length + BATCH));
|
|
1167
|
+
setLoading(false);
|
|
1168
|
+
}, 400);
|
|
1169
|
+
};
|
|
1170
|
+
$[7] = rows.length;
|
|
1171
|
+
$[8] = t3;
|
|
1172
|
+
} else t3 = $[8];
|
|
1173
|
+
let t4;
|
|
1174
|
+
let t5;
|
|
1175
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1176
|
+
t4 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
1177
|
+
t5 = { maxBlockSize: "24rem" };
|
|
1178
|
+
$[9] = t4;
|
|
1179
|
+
$[10] = t5;
|
|
1180
|
+
} else {
|
|
1181
|
+
t4 = $[9];
|
|
1182
|
+
t5 = $[10];
|
|
1183
|
+
}
|
|
1184
|
+
let t6;
|
|
1185
|
+
if ($[11] !== loading || $[12] !== t2 || $[13] !== t3) {
|
|
1186
|
+
t6 = /* @__PURE__ */ jsx(Table$1, {
|
|
1187
|
+
"aria-busy": loading,
|
|
1188
|
+
caption: t2,
|
|
1189
|
+
onEndReached: t3,
|
|
1190
|
+
sortIndicator: t4,
|
|
1191
|
+
style: t5,
|
|
1192
|
+
variant: "surface",
|
|
1193
|
+
windowed: true
|
|
1194
|
+
});
|
|
1195
|
+
$[11] = loading;
|
|
1196
|
+
$[12] = t2;
|
|
1197
|
+
$[13] = t3;
|
|
1198
|
+
$[14] = t6;
|
|
1199
|
+
} else t6 = $[14];
|
|
1200
|
+
let t7;
|
|
1201
|
+
if ($[15] !== loading || $[16] !== rows.length || $[17] !== t) {
|
|
1202
|
+
t7 = loading ? t("endless.loading") : t("endless.loaded", {
|
|
1203
|
+
count: rows.length,
|
|
1204
|
+
total: ARCHIVE.length
|
|
1205
|
+
});
|
|
1206
|
+
$[15] = loading;
|
|
1207
|
+
$[16] = rows.length;
|
|
1208
|
+
$[17] = t;
|
|
1209
|
+
$[18] = t7;
|
|
1210
|
+
} else t7 = $[18];
|
|
1211
|
+
let t8;
|
|
1212
|
+
if ($[19] !== t7) {
|
|
1213
|
+
t8 = /* @__PURE__ */ jsx(Text, {
|
|
1214
|
+
as: "output",
|
|
1215
|
+
children: t7
|
|
1216
|
+
});
|
|
1217
|
+
$[19] = t7;
|
|
1218
|
+
$[20] = t8;
|
|
1219
|
+
} else t8 = $[20];
|
|
1220
|
+
let t9;
|
|
1221
|
+
if ($[21] !== t6 || $[22] !== t8 || $[23] !== table) {
|
|
1222
|
+
t9 = /* @__PURE__ */ jsxs(Root, {
|
|
1223
|
+
table,
|
|
1224
|
+
children: [t6, t8]
|
|
1225
|
+
});
|
|
1226
|
+
$[21] = t6;
|
|
1227
|
+
$[22] = t8;
|
|
1228
|
+
$[23] = table;
|
|
1229
|
+
$[24] = t9;
|
|
1230
|
+
} else t9 = $[24];
|
|
1231
|
+
return t9;
|
|
1232
|
+
}
|
|
1233
|
+
function _temp3$5(row) {
|
|
1234
|
+
return row.reference;
|
|
1235
|
+
}
|
|
1236
|
+
function _temp2$16(cell) {
|
|
1237
|
+
return amountOf$15(cell.getValue());
|
|
1238
|
+
}
|
|
1239
|
+
function _temp$16() {
|
|
1240
|
+
return ARCHIVE.slice(0, BATCH);
|
|
1241
|
+
}
|
|
1242
|
+
const source$17 = "import { type ReactElement, useState } from \"react\";\n\nimport { ArrowUpIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { DELAY } from \"./server.ts\";\nimport { type Transfer, transfersOf } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst BATCH = 50;\n\nconst ARCHIVE = transfersOf(1000, 11_000);\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Endless(): ReactElement {\n const { t } = useWords(\"data-table\");\n const [rows, setRows] = useState(() => ARCHIVE.slice(0, BATCH));\n const [loading, setLoading] = useState(false);\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", {\n header: t(\"ledger.reference\"),\n meta: { rowHeader: true },\n size: 150,\n }),\n column.accessor((transfer) => t(transfer.account), {\n header: t(\"account\"),\n id: \"account\",\n size: 230,\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n size: 176,\n }),\n ]),\n data: rows,\n getRowId: (row) => row.reference,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n aria-busy={loading}\n caption={t(\"endless.caption\")}\n onEndReached={() => {\n if (rows.length === ARCHIVE.length) return;\n\n setLoading(true);\n setTimeout(() => {\n setRows(ARCHIVE.slice(0, rows.length + BATCH));\n setLoading(false);\n }, DELAY);\n }}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n style={{ maxBlockSize: \"24rem\" }}\n variant=\"surface\"\n windowed\n />\n <Text as=\"output\">\n {loading\n ? t(\"endless.loading\")\n : t(\"endless.loaded\", { count: rows.length, total: ARCHIVE.length })}\n </Text>\n </DataTable.Root>\n );\n}\n";
|
|
1243
|
+
//#endregion
|
|
1244
|
+
//#region src/data-table/examples/filters.example.tsx
|
|
1245
|
+
var filters_example_exports = /* @__PURE__ */ __exportAll({
|
|
1246
|
+
Filters: () => Filters,
|
|
1247
|
+
source: () => source$16
|
|
1248
|
+
});
|
|
1249
|
+
const column$15 = createColumnHelper();
|
|
1250
|
+
const EURO$15 = {
|
|
1251
|
+
currency: "EUR",
|
|
1252
|
+
style: "currency"
|
|
1253
|
+
};
|
|
1254
|
+
function amountOf$14(value) {
|
|
1255
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
1256
|
+
options: EURO$15,
|
|
1257
|
+
value
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
function filterOf(each, words) {
|
|
1261
|
+
return /* @__PURE__ */ jsx(ColumnFilter, {
|
|
1262
|
+
...words,
|
|
1263
|
+
checkIndicator: /* @__PURE__ */ jsx(CheckIcon, {}),
|
|
1264
|
+
column: each,
|
|
1265
|
+
indicator: /* @__PURE__ */ jsx(ListFilterIcon, { size: "1em" })
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
function Filters() {
|
|
1269
|
+
const $ = c(32);
|
|
1270
|
+
const { t } = useWords("data-table");
|
|
1271
|
+
let t0;
|
|
1272
|
+
if ($[0] !== t) {
|
|
1273
|
+
t0 = t("filters.clear");
|
|
1274
|
+
$[0] = t;
|
|
1275
|
+
$[1] = t0;
|
|
1276
|
+
} else t0 = $[1];
|
|
1277
|
+
let t1;
|
|
1278
|
+
let t2;
|
|
1279
|
+
if ($[2] !== t) {
|
|
1280
|
+
t1 = (name, active) => t(active ? "filters.active" : "filters.filter", { column: name });
|
|
1281
|
+
t2 = t("filters.max");
|
|
1282
|
+
$[2] = t;
|
|
1283
|
+
$[3] = t1;
|
|
1284
|
+
$[4] = t2;
|
|
1285
|
+
} else {
|
|
1286
|
+
t1 = $[3];
|
|
1287
|
+
t2 = $[4];
|
|
1288
|
+
}
|
|
1289
|
+
let t3;
|
|
1290
|
+
if ($[5] !== t) {
|
|
1291
|
+
t3 = t("filters.min");
|
|
1292
|
+
$[5] = t;
|
|
1293
|
+
$[6] = t3;
|
|
1294
|
+
} else t3 = $[6];
|
|
1295
|
+
let t4;
|
|
1296
|
+
if ($[7] !== t0 || $[8] !== t1 || $[9] !== t2 || $[10] !== t3) {
|
|
1297
|
+
t4 = {
|
|
1298
|
+
clearLabel: t0,
|
|
1299
|
+
label: t1,
|
|
1300
|
+
maxLabel: t2,
|
|
1301
|
+
minLabel: t3
|
|
1302
|
+
};
|
|
1303
|
+
$[7] = t0;
|
|
1304
|
+
$[8] = t1;
|
|
1305
|
+
$[9] = t2;
|
|
1306
|
+
$[10] = t3;
|
|
1307
|
+
$[11] = t4;
|
|
1308
|
+
} else t4 = $[11];
|
|
1309
|
+
const words = t4;
|
|
1310
|
+
let t5;
|
|
1311
|
+
if ($[12] !== t) {
|
|
1312
|
+
t5 = column$15.columns([
|
|
1313
|
+
column$15.accessor("reference", {
|
|
1314
|
+
header: t("ledger.reference"),
|
|
1315
|
+
meta: {
|
|
1316
|
+
filter: "text",
|
|
1317
|
+
rowHeader: true
|
|
1318
|
+
}
|
|
1319
|
+
}),
|
|
1320
|
+
column$15.accessor((transfer) => t(transfer.account), {
|
|
1321
|
+
filterFn: "arrHas",
|
|
1322
|
+
header: t("account"),
|
|
1323
|
+
id: "account",
|
|
1324
|
+
meta: { filter: "select" }
|
|
1325
|
+
}),
|
|
1326
|
+
column$15.accessor((transfer_0) => t(`ledger.${transfer_0.state}`), {
|
|
1327
|
+
filterFn: "arrHas",
|
|
1328
|
+
header: t("ledger.state"),
|
|
1329
|
+
id: "state",
|
|
1330
|
+
meta: { filter: "select" }
|
|
1331
|
+
}),
|
|
1332
|
+
column$15.accessor("amount", {
|
|
1333
|
+
cell: _temp$15,
|
|
1334
|
+
header: t("amount"),
|
|
1335
|
+
meta: {
|
|
1336
|
+
filter: "range",
|
|
1337
|
+
numeric: true
|
|
1338
|
+
}
|
|
1339
|
+
})
|
|
1340
|
+
]);
|
|
1341
|
+
$[12] = t;
|
|
1342
|
+
$[13] = t5;
|
|
1343
|
+
} else t5 = $[13];
|
|
1344
|
+
let t6;
|
|
1345
|
+
if ($[14] !== t5) {
|
|
1346
|
+
t6 = {
|
|
1347
|
+
columns: t5,
|
|
1348
|
+
data: RECENT,
|
|
1349
|
+
getRowId: _temp2$15
|
|
1350
|
+
};
|
|
1351
|
+
$[14] = t5;
|
|
1352
|
+
$[15] = t6;
|
|
1353
|
+
} else t6 = $[15];
|
|
1354
|
+
const table = useDataTable(t6);
|
|
1355
|
+
let t7;
|
|
1356
|
+
if ($[16] !== t) {
|
|
1357
|
+
t7 = t("filters.caption");
|
|
1358
|
+
$[16] = t;
|
|
1359
|
+
$[17] = t7;
|
|
1360
|
+
} else t7 = $[17];
|
|
1361
|
+
let t8;
|
|
1362
|
+
if ($[18] !== words) {
|
|
1363
|
+
t8 = (each) => filterOf(each, words);
|
|
1364
|
+
$[18] = words;
|
|
1365
|
+
$[19] = t8;
|
|
1366
|
+
} else t8 = $[19];
|
|
1367
|
+
let t9;
|
|
1368
|
+
if ($[20] !== t) {
|
|
1369
|
+
t9 = t("filters.empty");
|
|
1370
|
+
$[20] = t;
|
|
1371
|
+
$[21] = t9;
|
|
1372
|
+
} else t9 = $[21];
|
|
1373
|
+
let t10;
|
|
1374
|
+
if ($[22] !== t) {
|
|
1375
|
+
t10 = (count, total) => t("filters.found", {
|
|
1376
|
+
count,
|
|
1377
|
+
total
|
|
1378
|
+
});
|
|
1379
|
+
$[22] = t;
|
|
1380
|
+
$[23] = t10;
|
|
1381
|
+
} else t10 = $[23];
|
|
1382
|
+
let t11;
|
|
1383
|
+
if ($[24] !== t10 || $[25] !== t7 || $[26] !== t8 || $[27] !== t9) {
|
|
1384
|
+
t11 = /* @__PURE__ */ jsx(Table$1, {
|
|
1385
|
+
caption: t7,
|
|
1386
|
+
columnActions: t8,
|
|
1387
|
+
empty: t9,
|
|
1388
|
+
filteredAnnouncement: t10,
|
|
1389
|
+
variant: "surface"
|
|
1390
|
+
});
|
|
1391
|
+
$[24] = t10;
|
|
1392
|
+
$[25] = t7;
|
|
1393
|
+
$[26] = t8;
|
|
1394
|
+
$[27] = t9;
|
|
1395
|
+
$[28] = t11;
|
|
1396
|
+
} else t11 = $[28];
|
|
1397
|
+
let t12;
|
|
1398
|
+
if ($[29] !== t11 || $[30] !== table) {
|
|
1399
|
+
t12 = /* @__PURE__ */ jsx(Root, {
|
|
1400
|
+
table,
|
|
1401
|
+
children: t11
|
|
1402
|
+
});
|
|
1403
|
+
$[29] = t11;
|
|
1404
|
+
$[30] = table;
|
|
1405
|
+
$[31] = t12;
|
|
1406
|
+
} else t12 = $[31];
|
|
1407
|
+
return t12;
|
|
1408
|
+
}
|
|
1409
|
+
function _temp2$15(row) {
|
|
1410
|
+
return row.reference;
|
|
1411
|
+
}
|
|
1412
|
+
function _temp$15(cell) {
|
|
1413
|
+
return amountOf$14(cell.getValue());
|
|
1414
|
+
}
|
|
1415
|
+
const source$16 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, ListFilterIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { RECENT, type Transfer } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\ninterface FilterWords {\n readonly clearLabel: string;\n readonly label: (column: string, active: boolean) => string;\n readonly maxLabel: string;\n readonly minLabel: string;\n}\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction filterOf(each: DataTable.TableColumn, words: FilterWords): ReactElement {\n return (\n <DataTable.ColumnFilter\n {...words}\n checkIndicator={<CheckIcon />}\n column={each}\n indicator={<ListFilterIcon size=\"1em\" />}\n />\n );\n}\n\nexport function Filters(): ReactElement {\n const { t } = useWords(\"data-table\");\n const words: FilterWords = {\n clearLabel: t(\"filters.clear\"),\n label: (name, active) => t(active ? \"filters.active\" : \"filters.filter\", { column: name }),\n maxLabel: t(\"filters.max\"),\n minLabel: t(\"filters.min\"),\n };\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", {\n header: t(\"ledger.reference\"),\n meta: { filter: \"text\", rowHeader: true },\n }),\n column.accessor((transfer) => t(transfer.account), {\n filterFn: \"arrHas\",\n header: t(\"account\"),\n id: \"account\",\n meta: { filter: \"select\" },\n }),\n column.accessor((transfer) => t(`ledger.${transfer.state}`), {\n filterFn: \"arrHas\",\n header: t(\"ledger.state\"),\n id: \"state\",\n meta: { filter: \"select\" },\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { filter: \"range\", numeric: true },\n }),\n ]),\n data: RECENT,\n getRowId: (row) => row.reference,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"filters.caption\")}\n columnActions={(each) => filterOf(each, words)}\n empty={t(\"filters.empty\")}\n filteredAnnouncement={(count, total) => t(\"filters.found\", { count, total })}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
1416
|
+
//#endregion
|
|
1417
|
+
//#region src/data-table/examples/forecast.ts
|
|
1418
|
+
/**
|
|
1419
|
+
* Lists the departments by the size of their budget, the largest first.
|
|
1420
|
+
*/
|
|
1421
|
+
const FORECASTS = [
|
|
1422
|
+
{
|
|
1423
|
+
department: "engineering",
|
|
1424
|
+
q1: 124e4,
|
|
1425
|
+
q2: 131e4,
|
|
1426
|
+
q3: 1355e3,
|
|
1427
|
+
q4: 142e4
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
department: "sales",
|
|
1431
|
+
q1: 72e4,
|
|
1432
|
+
q2: 76e4,
|
|
1433
|
+
q3: 79e4,
|
|
1434
|
+
q4: 845e3
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
department: "marketing",
|
|
1438
|
+
q1: 48e4,
|
|
1439
|
+
q2: 525e3,
|
|
1440
|
+
q3: 61e4,
|
|
1441
|
+
q4: 695e3
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
department: "design",
|
|
1445
|
+
q1: 31e4,
|
|
1446
|
+
q2: 318e3,
|
|
1447
|
+
q3: 322500,
|
|
1448
|
+
q4: 34e4
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
department: "support",
|
|
1452
|
+
q1: 265e3,
|
|
1453
|
+
q2: 27e4,
|
|
1454
|
+
q3: 281e3,
|
|
1455
|
+
q4: 295e3
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
department: "finance",
|
|
1459
|
+
q1: 19e4,
|
|
1460
|
+
q2: 19e4,
|
|
1461
|
+
q3: 196e3,
|
|
1462
|
+
q4: 205e3
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
department: "people",
|
|
1466
|
+
q1: 15e4,
|
|
1467
|
+
q2: 162e3,
|
|
1468
|
+
q3: 158e3,
|
|
1469
|
+
q4: 171e3
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
department: "legal",
|
|
1473
|
+
q1: 95e3,
|
|
1474
|
+
q2: 98500,
|
|
1475
|
+
q3: 101e3,
|
|
1476
|
+
q4: 12e4
|
|
1477
|
+
}
|
|
1478
|
+
];
|
|
1479
|
+
//#endregion
|
|
1480
|
+
//#region src/data-table/examples/grid.example.tsx
|
|
1481
|
+
var grid_example_exports = /* @__PURE__ */ __exportAll({
|
|
1482
|
+
Grid: () => Grid$1,
|
|
1483
|
+
source: () => source$15
|
|
1484
|
+
});
|
|
1485
|
+
const column$14 = createColumnHelper();
|
|
1486
|
+
const EURO$14 = {
|
|
1487
|
+
currency: "EUR",
|
|
1488
|
+
maximumFractionDigits: 0,
|
|
1489
|
+
style: "currency"
|
|
1490
|
+
};
|
|
1491
|
+
const QUARTERS = [
|
|
1492
|
+
"q1",
|
|
1493
|
+
"q2",
|
|
1494
|
+
"q3",
|
|
1495
|
+
"q4"
|
|
1496
|
+
];
|
|
1497
|
+
function amountOf$13(value) {
|
|
1498
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
1499
|
+
options: EURO$14,
|
|
1500
|
+
value
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
function Grid$1() {
|
|
1504
|
+
const $ = c(12);
|
|
1505
|
+
const { t } = useWords("data-table");
|
|
1506
|
+
let t0;
|
|
1507
|
+
if ($[0] !== t) {
|
|
1508
|
+
t0 = column$14.columns([column$14.accessor((row) => t(`grid.${row.department}`), {
|
|
1509
|
+
header: t("grid.department"),
|
|
1510
|
+
id: "department",
|
|
1511
|
+
meta: { rowHeader: true }
|
|
1512
|
+
}), ...QUARTERS.map((quarter) => column$14.accessor(quarter, {
|
|
1513
|
+
cell: _temp$14,
|
|
1514
|
+
header: t(`grid.${quarter}`),
|
|
1515
|
+
meta: { numeric: true }
|
|
1516
|
+
}))]);
|
|
1517
|
+
$[0] = t;
|
|
1518
|
+
$[1] = t0;
|
|
1519
|
+
} else t0 = $[1];
|
|
1520
|
+
let t1;
|
|
1521
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1522
|
+
t1 = { cellSelection: [{
|
|
1523
|
+
anchorColumnId: "q2",
|
|
1524
|
+
anchorRowId: "sales",
|
|
1525
|
+
focusColumnId: "q3",
|
|
1526
|
+
focusRowId: "design"
|
|
1527
|
+
}] };
|
|
1528
|
+
$[2] = t1;
|
|
1529
|
+
} else t1 = $[2];
|
|
1530
|
+
let t2;
|
|
1531
|
+
if ($[3] !== t0) {
|
|
1532
|
+
t2 = {
|
|
1533
|
+
columns: t0,
|
|
1534
|
+
data: FORECASTS,
|
|
1535
|
+
getRowId: _temp2$14,
|
|
1536
|
+
initialState: t1
|
|
1537
|
+
};
|
|
1538
|
+
$[3] = t0;
|
|
1539
|
+
$[4] = t2;
|
|
1540
|
+
} else t2 = $[4];
|
|
1541
|
+
const table = useDataTable(t2);
|
|
1542
|
+
let t3;
|
|
1543
|
+
if ($[5] !== t) {
|
|
1544
|
+
t3 = t("grid.caption");
|
|
1545
|
+
$[5] = t;
|
|
1546
|
+
$[6] = t3;
|
|
1547
|
+
} else t3 = $[6];
|
|
1548
|
+
let t4;
|
|
1549
|
+
if ($[7] !== t3) {
|
|
1550
|
+
t4 = /* @__PURE__ */ jsx(Table$1, {
|
|
1551
|
+
caption: t3,
|
|
1552
|
+
grid: true,
|
|
1553
|
+
variant: "surface"
|
|
1554
|
+
});
|
|
1555
|
+
$[7] = t3;
|
|
1556
|
+
$[8] = t4;
|
|
1557
|
+
} else t4 = $[8];
|
|
1558
|
+
let t5;
|
|
1559
|
+
if ($[9] !== t4 || $[10] !== table) {
|
|
1560
|
+
t5 = /* @__PURE__ */ jsx(Root, {
|
|
1561
|
+
table,
|
|
1562
|
+
children: t4
|
|
1563
|
+
});
|
|
1564
|
+
$[9] = t4;
|
|
1565
|
+
$[10] = table;
|
|
1566
|
+
$[11] = t5;
|
|
1567
|
+
} else t5 = $[11];
|
|
1568
|
+
return t5;
|
|
1569
|
+
}
|
|
1570
|
+
function _temp2$14(row_0) {
|
|
1571
|
+
return row_0.department;
|
|
1572
|
+
}
|
|
1573
|
+
function _temp$14(cell) {
|
|
1574
|
+
return amountOf$13(cell.getValue());
|
|
1575
|
+
}
|
|
1576
|
+
const source$15 = "import { type ReactElement } from \"react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Forecast, FORECASTS } from \"./forecast.ts\";\n\nconst column = DataTable.createColumnHelper<Forecast>();\n\nconst EURO = { currency: \"EUR\", maximumFractionDigits: 0, style: \"currency\" } as const;\n\nconst QUARTERS = [\"q1\", \"q2\", \"q3\", \"q4\"] as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Grid(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor((row) => t(`grid.${row.department}`), {\n header: t(\"grid.department\"),\n id: \"department\",\n meta: { rowHeader: true },\n }),\n ...QUARTERS.map((quarter) =>\n column.accessor(quarter, {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(`grid.${quarter}`),\n meta: { numeric: true },\n }),\n ),\n ]),\n data: FORECASTS,\n getRowId: (row) => row.department,\n initialState: {\n cellSelection: [\n { anchorColumnId: \"q2\", anchorRowId: \"sales\", focusColumnId: \"q3\", focusRowId: \"design\" },\n ],\n },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table caption={t(\"grid.caption\")} grid variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
1577
|
+
//#endregion
|
|
1578
|
+
//#region src/data-table/examples/grouped.example.tsx
|
|
1579
|
+
var grouped_example_exports = /* @__PURE__ */ __exportAll({
|
|
1580
|
+
Grouped: () => Grouped,
|
|
1581
|
+
source: () => source$14
|
|
1582
|
+
});
|
|
1583
|
+
const column$13 = createColumnHelper();
|
|
1584
|
+
const EURO$13 = {
|
|
1585
|
+
currency: "EUR",
|
|
1586
|
+
style: "currency"
|
|
1587
|
+
};
|
|
1588
|
+
const GLYPHS$1 = {
|
|
1589
|
+
ascending: /* @__PURE__ */ jsx(ArrowUpIcon, {}),
|
|
1590
|
+
descending: /* @__PURE__ */ jsx(ArrowDownIcon, {}),
|
|
1591
|
+
grouped: /* @__PURE__ */ jsx(GroupIcon, {}),
|
|
1592
|
+
ungrouped: /* @__PURE__ */ jsx(UngroupIcon, {}),
|
|
1593
|
+
unsorted: /* @__PURE__ */ jsx(XIcon, {})
|
|
1594
|
+
};
|
|
1595
|
+
function amountOf$12(value) {
|
|
1596
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
1597
|
+
options: EURO$13,
|
|
1598
|
+
value
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
function menuOf$1(each, words) {
|
|
1602
|
+
return /* @__PURE__ */ jsx(ColumnMenu, {
|
|
1603
|
+
...words,
|
|
1604
|
+
actionIndicators: GLYPHS$1,
|
|
1605
|
+
column: each,
|
|
1606
|
+
indicator: /* @__PURE__ */ jsx(EllipsisVerticalIcon, { size: "1em" })
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
function Grouped() {
|
|
1610
|
+
const $ = c(41);
|
|
1611
|
+
const { t } = useWords("data-table");
|
|
1612
|
+
let t0;
|
|
1613
|
+
if ($[0] !== t) {
|
|
1614
|
+
t0 = t("menus.ascending");
|
|
1615
|
+
$[0] = t;
|
|
1616
|
+
$[1] = t0;
|
|
1617
|
+
} else t0 = $[1];
|
|
1618
|
+
let t1;
|
|
1619
|
+
if ($[2] !== t) {
|
|
1620
|
+
t1 = t("menus.descending");
|
|
1621
|
+
$[2] = t;
|
|
1622
|
+
$[3] = t1;
|
|
1623
|
+
} else t1 = $[3];
|
|
1624
|
+
let t2;
|
|
1625
|
+
if ($[4] !== t) {
|
|
1626
|
+
t2 = t("grouped.group");
|
|
1627
|
+
$[4] = t;
|
|
1628
|
+
$[5] = t2;
|
|
1629
|
+
} else t2 = $[5];
|
|
1630
|
+
let t3;
|
|
1631
|
+
let t4;
|
|
1632
|
+
if ($[6] !== t) {
|
|
1633
|
+
t3 = (name) => t("menus.options", { column: name });
|
|
1634
|
+
t4 = t("grouped.ungroup");
|
|
1635
|
+
$[6] = t;
|
|
1636
|
+
$[7] = t3;
|
|
1637
|
+
$[8] = t4;
|
|
1638
|
+
} else {
|
|
1639
|
+
t3 = $[7];
|
|
1640
|
+
t4 = $[8];
|
|
1641
|
+
}
|
|
1642
|
+
let t5;
|
|
1643
|
+
if ($[9] !== t) {
|
|
1644
|
+
t5 = t("menus.unsorted");
|
|
1645
|
+
$[9] = t;
|
|
1646
|
+
$[10] = t5;
|
|
1647
|
+
} else t5 = $[10];
|
|
1648
|
+
let t6;
|
|
1649
|
+
if ($[11] !== t0 || $[12] !== t1 || $[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
|
|
1650
|
+
t6 = {
|
|
1651
|
+
ascendingLabel: t0,
|
|
1652
|
+
descendingLabel: t1,
|
|
1653
|
+
groupedLabel: t2,
|
|
1654
|
+
label: t3,
|
|
1655
|
+
ungroupedLabel: t4,
|
|
1656
|
+
unsortedLabel: t5
|
|
1657
|
+
};
|
|
1658
|
+
$[11] = t0;
|
|
1659
|
+
$[12] = t1;
|
|
1660
|
+
$[13] = t2;
|
|
1661
|
+
$[14] = t3;
|
|
1662
|
+
$[15] = t4;
|
|
1663
|
+
$[16] = t5;
|
|
1664
|
+
$[17] = t6;
|
|
1665
|
+
} else t6 = $[17];
|
|
1666
|
+
const words = t6;
|
|
1667
|
+
let t7;
|
|
1668
|
+
if ($[18] !== t) {
|
|
1669
|
+
t7 = column$13.columns([
|
|
1670
|
+
column$13.accessor("reference", {
|
|
1671
|
+
header: t("ledger.reference"),
|
|
1672
|
+
meta: { rowHeader: true }
|
|
1673
|
+
}),
|
|
1674
|
+
column$13.accessor((transfer) => t(transfer.account), {
|
|
1675
|
+
header: t("account"),
|
|
1676
|
+
id: "account"
|
|
1677
|
+
}),
|
|
1678
|
+
column$13.accessor("state", {
|
|
1679
|
+
cell: (cell) => t(`ledger.${cell.getValue()}`),
|
|
1680
|
+
header: t("ledger.state")
|
|
1681
|
+
}),
|
|
1682
|
+
column$13.accessor("amount", {
|
|
1683
|
+
aggregatedCell: _temp$13,
|
|
1684
|
+
aggregationFn: "sum",
|
|
1685
|
+
cell: _temp2$13,
|
|
1686
|
+
header: t("amount"),
|
|
1687
|
+
meta: { numeric: true }
|
|
1688
|
+
})
|
|
1689
|
+
]);
|
|
1690
|
+
$[18] = t;
|
|
1691
|
+
$[19] = t7;
|
|
1692
|
+
} else t7 = $[19];
|
|
1693
|
+
let t8;
|
|
1694
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1695
|
+
t8 = {
|
|
1696
|
+
expanded: { "state:pending": true },
|
|
1697
|
+
grouping: ["state"]
|
|
1698
|
+
};
|
|
1699
|
+
$[20] = t8;
|
|
1700
|
+
} else t8 = $[20];
|
|
1701
|
+
let t9;
|
|
1702
|
+
if ($[21] !== t7) {
|
|
1703
|
+
t9 = {
|
|
1704
|
+
columns: t7,
|
|
1705
|
+
data: TRANSFERS,
|
|
1706
|
+
enableColumnPinning: false,
|
|
1707
|
+
enableGrouping: true,
|
|
1708
|
+
enableHiding: false,
|
|
1709
|
+
getRowId: _temp3$4,
|
|
1710
|
+
initialState: t8
|
|
1711
|
+
};
|
|
1712
|
+
$[21] = t7;
|
|
1713
|
+
$[22] = t9;
|
|
1714
|
+
} else t9 = $[22];
|
|
1715
|
+
const table = useDataTable(t9);
|
|
1716
|
+
let t10;
|
|
1717
|
+
if ($[23] !== t) {
|
|
1718
|
+
t10 = t("grouped.caption");
|
|
1719
|
+
$[23] = t;
|
|
1720
|
+
$[24] = t10;
|
|
1721
|
+
} else t10 = $[24];
|
|
1722
|
+
let t11;
|
|
1723
|
+
if ($[25] !== t) {
|
|
1724
|
+
t11 = t("tree.collapse");
|
|
1725
|
+
$[25] = t;
|
|
1726
|
+
$[26] = t11;
|
|
1727
|
+
} else t11 = $[26];
|
|
1728
|
+
let t12;
|
|
1729
|
+
if ($[27] !== words) {
|
|
1730
|
+
t12 = (each) => menuOf$1(each, words);
|
|
1731
|
+
$[27] = words;
|
|
1732
|
+
$[28] = t12;
|
|
1733
|
+
} else t12 = $[28];
|
|
1734
|
+
let t13;
|
|
1735
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1736
|
+
t13 = /* @__PURE__ */ jsx(ChevronRightIcon, { size: "1em" });
|
|
1737
|
+
$[29] = t13;
|
|
1738
|
+
} else t13 = $[29];
|
|
1739
|
+
let t14;
|
|
1740
|
+
if ($[30] !== t) {
|
|
1741
|
+
t14 = t("tree.expand");
|
|
1742
|
+
$[30] = t;
|
|
1743
|
+
$[31] = t14;
|
|
1744
|
+
} else t14 = $[31];
|
|
1745
|
+
let t15;
|
|
1746
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1747
|
+
t15 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
1748
|
+
$[32] = t15;
|
|
1749
|
+
} else t15 = $[32];
|
|
1750
|
+
let t16;
|
|
1751
|
+
if ($[33] !== t10 || $[34] !== t11 || $[35] !== t12 || $[36] !== t14) {
|
|
1752
|
+
t16 = /* @__PURE__ */ jsx(Table$1, {
|
|
1753
|
+
caption: t10,
|
|
1754
|
+
collapseLabel: t11,
|
|
1755
|
+
columnActions: t12,
|
|
1756
|
+
expandIndicator: t13,
|
|
1757
|
+
expandLabel: t14,
|
|
1758
|
+
sortIndicator: t15,
|
|
1759
|
+
variant: "surface"
|
|
1760
|
+
});
|
|
1761
|
+
$[33] = t10;
|
|
1762
|
+
$[34] = t11;
|
|
1763
|
+
$[35] = t12;
|
|
1764
|
+
$[36] = t14;
|
|
1765
|
+
$[37] = t16;
|
|
1766
|
+
} else t16 = $[37];
|
|
1767
|
+
let t17;
|
|
1768
|
+
if ($[38] !== t16 || $[39] !== table) {
|
|
1769
|
+
t17 = /* @__PURE__ */ jsx(Root, {
|
|
1770
|
+
table,
|
|
1771
|
+
children: t16
|
|
1772
|
+
});
|
|
1773
|
+
$[38] = t16;
|
|
1774
|
+
$[39] = table;
|
|
1775
|
+
$[40] = t17;
|
|
1776
|
+
} else t17 = $[40];
|
|
1777
|
+
return t17;
|
|
1778
|
+
}
|
|
1779
|
+
function _temp3$4(row) {
|
|
1780
|
+
return row.reference;
|
|
1781
|
+
}
|
|
1782
|
+
function _temp2$13(cell_1) {
|
|
1783
|
+
return amountOf$12(cell_1.getValue());
|
|
1784
|
+
}
|
|
1785
|
+
function _temp$13(cell_0) {
|
|
1786
|
+
return amountOf$12(cell_0.getValue());
|
|
1787
|
+
}
|
|
1788
|
+
const source$14 = "import { type ReactElement } from \"react\";\n\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n ChevronRightIcon,\n EllipsisVerticalIcon,\n GroupIcon,\n UngroupIcon,\n XIcon,\n} from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Transfer, TRANSFERS } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst GLYPHS: DataTable.ColumnMenuIndicators = {\n ascending: <ArrowUpIcon />,\n descending: <ArrowDownIcon />,\n grouped: <GroupIcon />,\n ungrouped: <UngroupIcon />,\n unsorted: <XIcon />,\n};\n\ntype MenuWords = Omit<DataTable.ColumnMenuProps, \"actionIndicators\" | \"column\" | \"indicator\">;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction menuOf(each: DataTable.TableColumn, words: MenuWords): ReactElement {\n return (\n <DataTable.ColumnMenu\n {...words}\n actionIndicators={GLYPHS}\n column={each}\n indicator={<EllipsisVerticalIcon size=\"1em\" />}\n />\n );\n}\n\nexport function Grouped(): ReactElement {\n const { t } = useWords(\"data-table\");\n const words: MenuWords = {\n ascendingLabel: t(\"menus.ascending\"),\n descendingLabel: t(\"menus.descending\"),\n groupedLabel: t(\"grouped.group\"),\n label: (name) => t(\"menus.options\", { column: name }),\n ungroupedLabel: t(\"grouped.ungroup\"),\n unsortedLabel: t(\"menus.unsorted\"),\n };\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", { header: t(\"ledger.reference\"), meta: { rowHeader: true } }),\n column.accessor((transfer) => t(transfer.account), { header: t(\"account\"), id: \"account\" }),\n column.accessor(\"state\", {\n cell: (cell) => t(`ledger.${cell.getValue()}`),\n header: t(\"ledger.state\"),\n }),\n column.accessor(\"amount\", {\n aggregatedCell: (cell) => amountOf(cell.getValue()),\n aggregationFn: \"sum\",\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: TRANSFERS,\n enableColumnPinning: false,\n enableGrouping: true,\n enableHiding: false,\n getRowId: (row) => row.reference,\n initialState: { expanded: { \"state:pending\": true }, grouping: [\"state\"] },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"grouped.caption\")}\n collapseLabel={t(\"tree.collapse\")}\n columnActions={(each) => menuOf(each, words)}\n expandIndicator={<ChevronRightIcon size=\"1em\" />}\n expandLabel={t(\"tree.expand\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
1789
|
+
//#endregion
|
|
1790
|
+
//#region src/data-table/examples/drive.ts
|
|
1791
|
+
/**
|
|
1792
|
+
* Serves the lazy example's shared drive: the folders and the file at its top, and the items of a
|
|
1793
|
+
* folder, which the "server" returns after the delay a network adds the first time the folder
|
|
1794
|
+
* opens.
|
|
1795
|
+
*/
|
|
1796
|
+
/**
|
|
1797
|
+
* Returns a folder under the path of its parent.
|
|
1798
|
+
*/
|
|
1799
|
+
function folder(parent, name, size) {
|
|
1800
|
+
return {
|
|
1801
|
+
kind: "folder",
|
|
1802
|
+
name,
|
|
1803
|
+
path: `${parent}/${name}`,
|
|
1804
|
+
size
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Returns a file under the path of its parent.
|
|
1809
|
+
*/
|
|
1810
|
+
function file(parent, name, size) {
|
|
1811
|
+
return {
|
|
1812
|
+
kind: "file",
|
|
1813
|
+
name,
|
|
1814
|
+
path: `${parent}/${name}`,
|
|
1815
|
+
size
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Lists the items at the drive's top.
|
|
1820
|
+
*/
|
|
1821
|
+
const ROOT = [
|
|
1822
|
+
folder("", "contracts", 4812e3),
|
|
1823
|
+
folder("", "invoices", 2310400),
|
|
1824
|
+
folder("", "receipts", 1204800),
|
|
1825
|
+
file("", "readme", 2048)
|
|
1826
|
+
];
|
|
1827
|
+
/**
|
|
1828
|
+
* Lists the items of each folder, by the folder's path.
|
|
1829
|
+
*/
|
|
1830
|
+
const CONTENTS = /* @__PURE__ */ new Map([
|
|
1831
|
+
["/contracts", [
|
|
1832
|
+
folder("/contracts", "archive", 312e4),
|
|
1833
|
+
file("/contracts", "template", 184e3),
|
|
1834
|
+
file("/contracts", "q3", 1508e3)
|
|
1835
|
+
]],
|
|
1836
|
+
["/contracts/archive", [file("/contracts/archive", "q1", 148e4), file("/contracts/archive", "q2", 164e4)]],
|
|
1837
|
+
["/invoices", [file("/invoices", "september", 1120300), file("/invoices", "october", 1190100)]],
|
|
1838
|
+
["/receipts", [folder("/receipts", "travel", 804600), file("/receipts", "meals", 400200)]],
|
|
1839
|
+
["/receipts/travel", [file("/receipts/travel", "trains", 312400), file("/receipts/travel", "hotels", 492200)]]
|
|
1840
|
+
]);
|
|
1841
|
+
/**
|
|
1842
|
+
* Returns the items of the folder at a path.
|
|
1843
|
+
*
|
|
1844
|
+
* @param path - The folder's path.
|
|
1845
|
+
* @returns The folder's items, or none for a path without a folder.
|
|
1846
|
+
*/
|
|
1847
|
+
function contentsOf(path) {
|
|
1848
|
+
return CONTENTS.get(path) ?? [];
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Returns the drive with the items of the folder at a path in place, wherever the folder is.
|
|
1852
|
+
*
|
|
1853
|
+
* @param items - The items at the drive's top.
|
|
1854
|
+
* @param path - The folder's path.
|
|
1855
|
+
* @param contents - The folder's items.
|
|
1856
|
+
* @returns The items, each folder on the way to the path a new object.
|
|
1857
|
+
*/
|
|
1858
|
+
function withItems(items, path, contents) {
|
|
1859
|
+
return items.map((item) => {
|
|
1860
|
+
if (item.path === path) return {
|
|
1861
|
+
...item,
|
|
1862
|
+
items: contents
|
|
1863
|
+
};
|
|
1864
|
+
return item.items === void 0 ? item : {
|
|
1865
|
+
...item,
|
|
1866
|
+
items: withItems(item.items, path, contents)
|
|
1867
|
+
};
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Returns the drive, and asks the server for a folder's items the first time the folder opens.
|
|
1872
|
+
*
|
|
1873
|
+
* @returns The items, the open folders and the handler that opens and closes them.
|
|
1874
|
+
*/
|
|
1875
|
+
function useDrive() {
|
|
1876
|
+
const $ = c(8);
|
|
1877
|
+
const [items, setItems] = useState(ROOT);
|
|
1878
|
+
let t0;
|
|
1879
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1880
|
+
t0 = {};
|
|
1881
|
+
$[0] = t0;
|
|
1882
|
+
} else t0 = $[0];
|
|
1883
|
+
const [expanded, setExpanded] = useState(t0);
|
|
1884
|
+
let t1;
|
|
1885
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1886
|
+
t1 = /* @__PURE__ */ new Set();
|
|
1887
|
+
$[1] = t1;
|
|
1888
|
+
} else t1 = $[1];
|
|
1889
|
+
const requested = useRef(t1);
|
|
1890
|
+
let t2;
|
|
1891
|
+
if ($[2] !== expanded) {
|
|
1892
|
+
t2 = (updater) => {
|
|
1893
|
+
const next = typeof updater === "function" ? updater(expanded) : updater;
|
|
1894
|
+
setExpanded(next);
|
|
1895
|
+
for (const path of Object.keys(next)) {
|
|
1896
|
+
if (requested.current.has(path)) continue;
|
|
1897
|
+
requested.current.add(path);
|
|
1898
|
+
setTimeout(() => {
|
|
1899
|
+
setItems((current) => withItems(current, path, contentsOf(path)));
|
|
1900
|
+
}, 400);
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
$[2] = expanded;
|
|
1904
|
+
$[3] = t2;
|
|
1905
|
+
} else t2 = $[3];
|
|
1906
|
+
let t3;
|
|
1907
|
+
if ($[4] !== expanded || $[5] !== items || $[6] !== t2) {
|
|
1908
|
+
t3 = {
|
|
1909
|
+
expanded,
|
|
1910
|
+
items,
|
|
1911
|
+
onExpandedChange: t2
|
|
1912
|
+
};
|
|
1913
|
+
$[4] = expanded;
|
|
1914
|
+
$[5] = items;
|
|
1915
|
+
$[6] = t2;
|
|
1916
|
+
$[7] = t3;
|
|
1917
|
+
} else t3 = $[7];
|
|
1918
|
+
return t3;
|
|
1919
|
+
}
|
|
1920
|
+
//#endregion
|
|
1921
|
+
//#region src/data-table/examples/lazy.example.tsx
|
|
1922
|
+
var lazy_example_exports = /* @__PURE__ */ __exportAll({
|
|
1923
|
+
Lazy: () => Lazy,
|
|
1924
|
+
source: () => source$13
|
|
1925
|
+
});
|
|
1926
|
+
const column$12 = createColumnHelper();
|
|
1927
|
+
function sizeOf(value) {
|
|
1928
|
+
return /* @__PURE__ */ jsx(Format.Byte, { value });
|
|
1929
|
+
}
|
|
1930
|
+
function Lazy() {
|
|
1931
|
+
const $ = c(26);
|
|
1932
|
+
const { t } = useWords("data-table");
|
|
1933
|
+
const { expanded, items, onExpandedChange } = useDrive();
|
|
1934
|
+
let t0;
|
|
1935
|
+
if ($[0] !== t) {
|
|
1936
|
+
t0 = column$12.columns([column$12.accessor((item) => t(`lazy.${item.name}`), {
|
|
1937
|
+
header: t("lazy.name"),
|
|
1938
|
+
id: "name",
|
|
1939
|
+
meta: { rowHeader: true }
|
|
1940
|
+
}), column$12.accessor("size", {
|
|
1941
|
+
cell: _temp$12,
|
|
1942
|
+
header: t("lazy.size"),
|
|
1943
|
+
meta: { numeric: true }
|
|
1944
|
+
})]);
|
|
1945
|
+
$[0] = t;
|
|
1946
|
+
$[1] = t0;
|
|
1947
|
+
} else t0 = $[1];
|
|
1948
|
+
let t1;
|
|
1949
|
+
if ($[2] !== expanded) {
|
|
1950
|
+
t1 = { expanded };
|
|
1951
|
+
$[2] = expanded;
|
|
1952
|
+
$[3] = t1;
|
|
1953
|
+
} else t1 = $[3];
|
|
1954
|
+
let t2;
|
|
1955
|
+
if ($[4] !== items || $[5] !== onExpandedChange || $[6] !== t0 || $[7] !== t1) {
|
|
1956
|
+
t2 = {
|
|
1957
|
+
autoResetExpanded: false,
|
|
1958
|
+
columns: t0,
|
|
1959
|
+
data: items,
|
|
1960
|
+
getRowCanExpand: _temp2$12,
|
|
1961
|
+
getRowId: _temp3$3,
|
|
1962
|
+
getSubRows: _temp4$2,
|
|
1963
|
+
onExpandedChange,
|
|
1964
|
+
state: t1
|
|
1965
|
+
};
|
|
1966
|
+
$[4] = items;
|
|
1967
|
+
$[5] = onExpandedChange;
|
|
1968
|
+
$[6] = t0;
|
|
1969
|
+
$[7] = t1;
|
|
1970
|
+
$[8] = t2;
|
|
1971
|
+
} else t2 = $[8];
|
|
1972
|
+
const table = useDataTable(t2);
|
|
1973
|
+
let t3;
|
|
1974
|
+
if ($[9] !== t) {
|
|
1975
|
+
t3 = t("lazy.caption");
|
|
1976
|
+
$[9] = t;
|
|
1977
|
+
$[10] = t3;
|
|
1978
|
+
} else t3 = $[10];
|
|
1979
|
+
let t4;
|
|
1980
|
+
if ($[11] !== t) {
|
|
1981
|
+
t4 = t("tree.collapse");
|
|
1982
|
+
$[11] = t;
|
|
1983
|
+
$[12] = t4;
|
|
1984
|
+
} else t4 = $[12];
|
|
1985
|
+
let t5;
|
|
1986
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1987
|
+
t5 = /* @__PURE__ */ jsx(ChevronRightIcon, { size: "1em" });
|
|
1988
|
+
$[13] = t5;
|
|
1989
|
+
} else t5 = $[13];
|
|
1990
|
+
let t6;
|
|
1991
|
+
if ($[14] !== t) {
|
|
1992
|
+
t6 = t("tree.expand");
|
|
1993
|
+
$[14] = t;
|
|
1994
|
+
$[15] = t6;
|
|
1995
|
+
} else t6 = $[15];
|
|
1996
|
+
let t7;
|
|
1997
|
+
if ($[16] !== t) {
|
|
1998
|
+
t7 = t("lazy.loading");
|
|
1999
|
+
$[16] = t;
|
|
2000
|
+
$[17] = t7;
|
|
2001
|
+
} else t7 = $[17];
|
|
2002
|
+
let t8;
|
|
2003
|
+
if ($[18] !== t3 || $[19] !== t4 || $[20] !== t6 || $[21] !== t7) {
|
|
2004
|
+
t8 = /* @__PURE__ */ jsx(Table$1, {
|
|
2005
|
+
caption: t3,
|
|
2006
|
+
collapseLabel: t4,
|
|
2007
|
+
expandIndicator: t5,
|
|
2008
|
+
expandLabel: t6,
|
|
2009
|
+
loadingLabel: t7,
|
|
2010
|
+
variant: "surface"
|
|
2011
|
+
});
|
|
2012
|
+
$[18] = t3;
|
|
2013
|
+
$[19] = t4;
|
|
2014
|
+
$[20] = t6;
|
|
2015
|
+
$[21] = t7;
|
|
2016
|
+
$[22] = t8;
|
|
2017
|
+
} else t8 = $[22];
|
|
2018
|
+
let t9;
|
|
2019
|
+
if ($[23] !== t8 || $[24] !== table) {
|
|
2020
|
+
t9 = /* @__PURE__ */ jsx(Root, {
|
|
2021
|
+
table,
|
|
2022
|
+
children: t8
|
|
2023
|
+
});
|
|
2024
|
+
$[23] = t8;
|
|
2025
|
+
$[24] = table;
|
|
2026
|
+
$[25] = t9;
|
|
2027
|
+
} else t9 = $[25];
|
|
2028
|
+
return t9;
|
|
2029
|
+
}
|
|
2030
|
+
function _temp4$2(item_1) {
|
|
2031
|
+
return item_1.items;
|
|
2032
|
+
}
|
|
2033
|
+
function _temp3$3(item_0) {
|
|
2034
|
+
return item_0.path;
|
|
2035
|
+
}
|
|
2036
|
+
function _temp2$12(row) {
|
|
2037
|
+
return row.original.kind === "folder";
|
|
2038
|
+
}
|
|
2039
|
+
function _temp$12(cell) {
|
|
2040
|
+
return sizeOf(cell.getValue());
|
|
2041
|
+
}
|
|
2042
|
+
const source$13 = "import { type ReactElement } from \"react\";\n\nimport { ChevronRightIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Item, useDrive } from \"./drive.ts\";\n\nconst column = DataTable.createColumnHelper<Item>();\n\nfunction sizeOf(value: number): ReactElement {\n return <Format.Byte value={value} />;\n}\n\nexport function Lazy(): ReactElement {\n const { t } = useWords(\"data-table\");\n const { expanded, items, onExpandedChange } = useDrive();\n const table = DataTable.useDataTable({\n autoResetExpanded: false,\n columns: column.columns([\n column.accessor((item) => t(`lazy.${item.name}`), {\n header: t(\"lazy.name\"),\n id: \"name\",\n meta: { rowHeader: true },\n }),\n column.accessor(\"size\", {\n cell: (cell) => sizeOf(cell.getValue()),\n header: t(\"lazy.size\"),\n meta: { numeric: true },\n }),\n ]),\n data: items,\n getRowCanExpand: (row) => row.original.kind === \"folder\",\n getRowId: (item) => item.path,\n getSubRows: (item) => item.items,\n onExpandedChange,\n state: { expanded },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"lazy.caption\")}\n collapseLabel={t(\"tree.collapse\")}\n expandIndicator={<ChevronRightIcon size=\"1em\" />}\n expandLabel={t(\"tree.expand\")}\n loadingLabel={t(\"lazy.loading\")}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
2043
|
+
//#endregion
|
|
2044
|
+
//#region src/data-table/examples/manager.example.tsx
|
|
2045
|
+
var manager_example_exports = /* @__PURE__ */ __exportAll({
|
|
2046
|
+
Manager: () => Manager,
|
|
2047
|
+
source: () => source$12
|
|
2048
|
+
});
|
|
2049
|
+
const column$11 = createColumnHelper();
|
|
2050
|
+
const EURO$12 = {
|
|
2051
|
+
currency: "EUR",
|
|
2052
|
+
style: "currency"
|
|
2053
|
+
};
|
|
2054
|
+
function amountOf$11(value) {
|
|
2055
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
2056
|
+
options: EURO$12,
|
|
2057
|
+
value
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
function Manager() {
|
|
2061
|
+
const $ = c(41);
|
|
2062
|
+
const { t } = useWords("data-table");
|
|
2063
|
+
let t0;
|
|
2064
|
+
if ($[0] !== t) {
|
|
2065
|
+
t0 = column$11.columns([
|
|
2066
|
+
column$11.accessor("reference", {
|
|
2067
|
+
header: t("ledger.reference"),
|
|
2068
|
+
meta: { rowHeader: true }
|
|
2069
|
+
}),
|
|
2070
|
+
column$11.accessor((transfer) => t(transfer.account), {
|
|
2071
|
+
header: t("account"),
|
|
2072
|
+
id: "account"
|
|
2073
|
+
}),
|
|
2074
|
+
column$11.accessor((transfer_0) => t(transfer_0.region), {
|
|
2075
|
+
header: t("spanned.region"),
|
|
2076
|
+
id: "region"
|
|
2077
|
+
}),
|
|
2078
|
+
column$11.accessor((transfer_1) => t(`ledger.${transfer_1.state}`), {
|
|
2079
|
+
header: t("ledger.state"),
|
|
2080
|
+
id: "state"
|
|
2081
|
+
}),
|
|
2082
|
+
column$11.accessor("amount", {
|
|
2083
|
+
cell: _temp$11,
|
|
2084
|
+
header: t("amount"),
|
|
2085
|
+
meta: { numeric: true }
|
|
2086
|
+
})
|
|
2087
|
+
]);
|
|
2088
|
+
$[0] = t;
|
|
2089
|
+
$[1] = t0;
|
|
2090
|
+
} else t0 = $[1];
|
|
2091
|
+
let t1;
|
|
2092
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2093
|
+
t1 = { columnVisibility: { region: false } };
|
|
2094
|
+
$[2] = t1;
|
|
2095
|
+
} else t1 = $[2];
|
|
2096
|
+
let t2;
|
|
2097
|
+
if ($[3] !== t0) {
|
|
2098
|
+
t2 = {
|
|
2099
|
+
columns: t0,
|
|
2100
|
+
data: RECENT,
|
|
2101
|
+
getRowId: _temp2$11,
|
|
2102
|
+
initialState: t1
|
|
2103
|
+
};
|
|
2104
|
+
$[3] = t0;
|
|
2105
|
+
$[4] = t2;
|
|
2106
|
+
} else t2 = $[4];
|
|
2107
|
+
const table = useDataTable(t2);
|
|
2108
|
+
let t3;
|
|
2109
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2110
|
+
t3 = { placement: "bottom-end" };
|
|
2111
|
+
$[5] = t3;
|
|
2112
|
+
} else t3 = $[5];
|
|
2113
|
+
let t4;
|
|
2114
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2115
|
+
t4 = {
|
|
2116
|
+
size: "sm",
|
|
2117
|
+
variant: "outline"
|
|
2118
|
+
};
|
|
2119
|
+
$[6] = t4;
|
|
2120
|
+
} else t4 = $[6];
|
|
2121
|
+
let t5;
|
|
2122
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2123
|
+
t5 = /* @__PURE__ */ jsx(Columns3Icon, { size: "1em" });
|
|
2124
|
+
$[7] = t5;
|
|
2125
|
+
} else t5 = $[7];
|
|
2126
|
+
let t6;
|
|
2127
|
+
if ($[8] !== t) {
|
|
2128
|
+
t6 = t("manager.button");
|
|
2129
|
+
$[8] = t;
|
|
2130
|
+
$[9] = t6;
|
|
2131
|
+
} else t6 = $[9];
|
|
2132
|
+
let t7;
|
|
2133
|
+
if ($[10] !== t6) {
|
|
2134
|
+
t7 = /* @__PURE__ */ jsx(ButtonPropsProvider, {
|
|
2135
|
+
value: t4,
|
|
2136
|
+
children: /* @__PURE__ */ jsxs(Popover.Trigger, {
|
|
2137
|
+
as: Button,
|
|
2138
|
+
children: [t5, t6]
|
|
2139
|
+
})
|
|
2140
|
+
});
|
|
2141
|
+
$[10] = t6;
|
|
2142
|
+
$[11] = t7;
|
|
2143
|
+
} else t7 = $[11];
|
|
2144
|
+
let t8;
|
|
2145
|
+
if ($[12] !== t) {
|
|
2146
|
+
t8 = t("manager.heading");
|
|
2147
|
+
$[12] = t;
|
|
2148
|
+
$[13] = t8;
|
|
2149
|
+
} else t8 = $[13];
|
|
2150
|
+
let t9;
|
|
2151
|
+
if ($[14] !== t8) {
|
|
2152
|
+
t9 = /* @__PURE__ */ jsx(Popover.Title, { children: t8 });
|
|
2153
|
+
$[14] = t8;
|
|
2154
|
+
$[15] = t9;
|
|
2155
|
+
} else t9 = $[15];
|
|
2156
|
+
let t10;
|
|
2157
|
+
let t11;
|
|
2158
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2159
|
+
t10 = /* @__PURE__ */ jsx(CheckIcon, {});
|
|
2160
|
+
t11 = /* @__PURE__ */ jsx(GripVerticalIcon, { size: "1em" });
|
|
2161
|
+
$[16] = t10;
|
|
2162
|
+
$[17] = t11;
|
|
2163
|
+
} else {
|
|
2164
|
+
t10 = $[16];
|
|
2165
|
+
t11 = $[17];
|
|
2166
|
+
}
|
|
2167
|
+
let t12;
|
|
2168
|
+
let t13;
|
|
2169
|
+
if ($[18] !== t) {
|
|
2170
|
+
t12 = (item) => t("manager.move", { item });
|
|
2171
|
+
t13 = t("manager.heading");
|
|
2172
|
+
$[18] = t;
|
|
2173
|
+
$[19] = t12;
|
|
2174
|
+
$[20] = t13;
|
|
2175
|
+
} else {
|
|
2176
|
+
t12 = $[19];
|
|
2177
|
+
t13 = $[20];
|
|
2178
|
+
}
|
|
2179
|
+
let t14;
|
|
2180
|
+
if ($[21] !== t) {
|
|
2181
|
+
t14 = t("manager.reset");
|
|
2182
|
+
$[21] = t;
|
|
2183
|
+
$[22] = t14;
|
|
2184
|
+
} else t14 = $[22];
|
|
2185
|
+
let t15;
|
|
2186
|
+
if ($[23] !== t12 || $[24] !== t13 || $[25] !== t14) {
|
|
2187
|
+
t15 = /* @__PURE__ */ jsx(ColumnManager, {
|
|
2188
|
+
checkIndicator: t10,
|
|
2189
|
+
handleIndicator: t11,
|
|
2190
|
+
handleLabel: t12,
|
|
2191
|
+
label: t13,
|
|
2192
|
+
resetLabel: t14
|
|
2193
|
+
});
|
|
2194
|
+
$[23] = t12;
|
|
2195
|
+
$[24] = t13;
|
|
2196
|
+
$[25] = t14;
|
|
2197
|
+
$[26] = t15;
|
|
2198
|
+
} else t15 = $[26];
|
|
2199
|
+
let t16;
|
|
2200
|
+
if ($[27] !== t15 || $[28] !== t9) {
|
|
2201
|
+
t16 = /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, { children: /* @__PURE__ */ jsxs(Popover.Content, { children: [t9, t15] }) }) });
|
|
2202
|
+
$[27] = t15;
|
|
2203
|
+
$[28] = t9;
|
|
2204
|
+
$[29] = t16;
|
|
2205
|
+
} else t16 = $[29];
|
|
2206
|
+
let t17;
|
|
2207
|
+
if ($[30] !== t16 || $[31] !== t7) {
|
|
2208
|
+
t17 = /* @__PURE__ */ jsx(Stack, {
|
|
2209
|
+
direction: "row",
|
|
2210
|
+
justify: "end",
|
|
2211
|
+
children: /* @__PURE__ */ jsxs(Popover.Root, {
|
|
2212
|
+
positioning: t3,
|
|
2213
|
+
size: "sm",
|
|
2214
|
+
children: [t7, t16]
|
|
2215
|
+
})
|
|
2216
|
+
});
|
|
2217
|
+
$[30] = t16;
|
|
2218
|
+
$[31] = t7;
|
|
2219
|
+
$[32] = t17;
|
|
2220
|
+
} else t17 = $[32];
|
|
2221
|
+
let t18;
|
|
2222
|
+
if ($[33] !== t) {
|
|
2223
|
+
t18 = t("manager.caption");
|
|
2224
|
+
$[33] = t;
|
|
2225
|
+
$[34] = t18;
|
|
2226
|
+
} else t18 = $[34];
|
|
2227
|
+
let t19;
|
|
2228
|
+
if ($[35] !== t18) {
|
|
2229
|
+
t19 = /* @__PURE__ */ jsx(Table$1, {
|
|
2230
|
+
caption: t18,
|
|
2231
|
+
variant: "surface"
|
|
2232
|
+
});
|
|
2233
|
+
$[35] = t18;
|
|
2234
|
+
$[36] = t19;
|
|
2235
|
+
} else t19 = $[36];
|
|
2236
|
+
let t20;
|
|
2237
|
+
if ($[37] !== t17 || $[38] !== t19 || $[39] !== table) {
|
|
2238
|
+
t20 = /* @__PURE__ */ jsxs(Root, {
|
|
2239
|
+
table,
|
|
2240
|
+
children: [t17, t19]
|
|
2241
|
+
});
|
|
2242
|
+
$[37] = t17;
|
|
2243
|
+
$[38] = t19;
|
|
2244
|
+
$[39] = table;
|
|
2245
|
+
$[40] = t20;
|
|
2246
|
+
} else t20 = $[40];
|
|
2247
|
+
return t20;
|
|
2248
|
+
}
|
|
2249
|
+
function _temp2$11(row) {
|
|
2250
|
+
return row.reference;
|
|
2251
|
+
}
|
|
2252
|
+
function _temp$11(cell) {
|
|
2253
|
+
return amountOf$11(cell.getValue());
|
|
2254
|
+
}
|
|
2255
|
+
const source$12 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, Columns3Icon, GripVerticalIcon } from \"lucide-react\";\n\nimport { Button, ButtonPropsProvider } from \"@stealthscale/component-actions\";\nimport { Format } from \"@stealthscale/component-data\";\nimport { Popover } from \"@stealthscale/component-disclosure\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { Portal } from \"@stealthscale/component-primitives\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { RECENT, type Transfer } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Manager(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", { header: t(\"ledger.reference\"), meta: { rowHeader: true } }),\n column.accessor((transfer) => t(transfer.account), { header: t(\"account\"), id: \"account\" }),\n column.accessor((transfer) => t(transfer.region), {\n header: t(\"spanned.region\"),\n id: \"region\",\n }),\n column.accessor((transfer) => t(`ledger.${transfer.state}`), {\n header: t(\"ledger.state\"),\n id: \"state\",\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: RECENT,\n getRowId: (row) => row.reference,\n initialState: { columnVisibility: { region: false } },\n });\n\n return (\n <DataTable.Root table={table}>\n <Stack direction=\"row\" justify=\"end\">\n <Popover.Root positioning={{ placement: \"bottom-end\" }} size=\"sm\">\n <ButtonPropsProvider value={{ size: \"sm\", variant: \"outline\" }}>\n <Popover.Trigger as={Button}>\n <Columns3Icon size=\"1em\" />\n {t(\"manager.button\")}\n </Popover.Trigger>\n </ButtonPropsProvider>\n <Portal>\n <Popover.Positioner>\n <Popover.Content>\n <Popover.Title>{t(\"manager.heading\")}</Popover.Title>\n <DataTable.ColumnManager\n checkIndicator={<CheckIcon />}\n handleIndicator={<GripVerticalIcon size=\"1em\" />}\n handleLabel={(item) => t(\"manager.move\", { item })}\n label={t(\"manager.heading\")}\n resetLabel={t(\"manager.reset\")}\n />\n </Popover.Content>\n </Popover.Positioner>\n </Portal>\n </Popover.Root>\n </Stack>\n <DataTable.Table caption={t(\"manager.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
2256
|
+
//#endregion
|
|
2257
|
+
//#region src/data-table/examples/menus.example.tsx
|
|
2258
|
+
var menus_example_exports = /* @__PURE__ */ __exportAll({
|
|
2259
|
+
Menus: () => Menus,
|
|
2260
|
+
source: () => source$11
|
|
2261
|
+
});
|
|
2262
|
+
const column$10 = createColumnHelper();
|
|
2263
|
+
const EURO$11 = {
|
|
2264
|
+
currency: "EUR",
|
|
2265
|
+
style: "currency"
|
|
2266
|
+
};
|
|
2267
|
+
const GLYPHS = {
|
|
2268
|
+
ascending: /* @__PURE__ */ jsx(ArrowUpIcon, {}),
|
|
2269
|
+
descending: /* @__PURE__ */ jsx(ArrowDownIcon, {}),
|
|
2270
|
+
end: /* @__PURE__ */ jsx(PinIcon, {}),
|
|
2271
|
+
hide: /* @__PURE__ */ jsx(EyeOffIcon, {}),
|
|
2272
|
+
start: /* @__PURE__ */ jsx(PinIcon, {}),
|
|
2273
|
+
unpinned: /* @__PURE__ */ jsx(PinOffIcon, {}),
|
|
2274
|
+
unsorted: /* @__PURE__ */ jsx(XIcon, {})
|
|
2275
|
+
};
|
|
2276
|
+
function amountOf$10(value) {
|
|
2277
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
2278
|
+
options: EURO$11,
|
|
2279
|
+
value
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
function menuOf(each, words) {
|
|
2283
|
+
return /* @__PURE__ */ jsx(ColumnMenu, {
|
|
2284
|
+
...words,
|
|
2285
|
+
actionIndicators: GLYPHS,
|
|
2286
|
+
column: each,
|
|
2287
|
+
indicator: /* @__PURE__ */ jsx(EllipsisVerticalIcon, { size: "1em" })
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
function Menus() {
|
|
2291
|
+
const $ = c(40);
|
|
2292
|
+
const { t } = useWords("data-table");
|
|
2293
|
+
let t0;
|
|
2294
|
+
if ($[0] !== t) {
|
|
2295
|
+
t0 = t("menus.ascending");
|
|
2296
|
+
$[0] = t;
|
|
2297
|
+
$[1] = t0;
|
|
2298
|
+
} else t0 = $[1];
|
|
2299
|
+
let t1;
|
|
2300
|
+
if ($[2] !== t) {
|
|
2301
|
+
t1 = t("menus.descending");
|
|
2302
|
+
$[2] = t;
|
|
2303
|
+
$[3] = t1;
|
|
2304
|
+
} else t1 = $[3];
|
|
2305
|
+
let t2;
|
|
2306
|
+
if ($[4] !== t) {
|
|
2307
|
+
t2 = t("menus.end");
|
|
2308
|
+
$[4] = t;
|
|
2309
|
+
$[5] = t2;
|
|
2310
|
+
} else t2 = $[5];
|
|
2311
|
+
let t3;
|
|
2312
|
+
if ($[6] !== t) {
|
|
2313
|
+
t3 = t("menus.hide");
|
|
2314
|
+
$[6] = t;
|
|
2315
|
+
$[7] = t3;
|
|
2316
|
+
} else t3 = $[7];
|
|
2317
|
+
let t4;
|
|
2318
|
+
let t5;
|
|
2319
|
+
if ($[8] !== t) {
|
|
2320
|
+
t4 = (name) => t("menus.options", { column: name });
|
|
2321
|
+
t5 = t("menus.start");
|
|
2322
|
+
$[8] = t;
|
|
2323
|
+
$[9] = t4;
|
|
2324
|
+
$[10] = t5;
|
|
2325
|
+
} else {
|
|
2326
|
+
t4 = $[9];
|
|
2327
|
+
t5 = $[10];
|
|
2328
|
+
}
|
|
2329
|
+
let t6;
|
|
2330
|
+
if ($[11] !== t) {
|
|
2331
|
+
t6 = t("menus.unpinned");
|
|
2332
|
+
$[11] = t;
|
|
2333
|
+
$[12] = t6;
|
|
2334
|
+
} else t6 = $[12];
|
|
2335
|
+
let t7;
|
|
2336
|
+
if ($[13] !== t) {
|
|
2337
|
+
t7 = t("menus.unsorted");
|
|
2338
|
+
$[13] = t;
|
|
2339
|
+
$[14] = t7;
|
|
2340
|
+
} else t7 = $[14];
|
|
2341
|
+
let t8;
|
|
2342
|
+
if ($[15] !== t0 || $[16] !== t1 || $[17] !== t2 || $[18] !== t3 || $[19] !== t4 || $[20] !== t5 || $[21] !== t6 || $[22] !== t7) {
|
|
2343
|
+
t8 = {
|
|
2344
|
+
ascendingLabel: t0,
|
|
2345
|
+
descendingLabel: t1,
|
|
2346
|
+
endLabel: t2,
|
|
2347
|
+
hideLabel: t3,
|
|
2348
|
+
label: t4,
|
|
2349
|
+
startLabel: t5,
|
|
2350
|
+
unpinnedLabel: t6,
|
|
2351
|
+
unsortedLabel: t7
|
|
2352
|
+
};
|
|
2353
|
+
$[15] = t0;
|
|
2354
|
+
$[16] = t1;
|
|
2355
|
+
$[17] = t2;
|
|
2356
|
+
$[18] = t3;
|
|
2357
|
+
$[19] = t4;
|
|
2358
|
+
$[20] = t5;
|
|
2359
|
+
$[21] = t6;
|
|
2360
|
+
$[22] = t7;
|
|
2361
|
+
$[23] = t8;
|
|
2362
|
+
} else t8 = $[23];
|
|
2363
|
+
const words = t8;
|
|
2364
|
+
let t9;
|
|
2365
|
+
if ($[24] !== t) {
|
|
2366
|
+
t9 = column$10.columns([
|
|
2367
|
+
column$10.accessor("reference", {
|
|
2368
|
+
header: t("ledger.reference"),
|
|
2369
|
+
meta: { rowHeader: true }
|
|
2370
|
+
}),
|
|
2371
|
+
column$10.accessor((transfer) => t(transfer.account), {
|
|
2372
|
+
header: t("account"),
|
|
2373
|
+
id: "account"
|
|
2374
|
+
}),
|
|
2375
|
+
column$10.accessor((transfer_0) => t(transfer_0.region), {
|
|
2376
|
+
header: t("spanned.region"),
|
|
2377
|
+
id: "region"
|
|
2378
|
+
}),
|
|
2379
|
+
column$10.accessor("amount", {
|
|
2380
|
+
cell: _temp$10,
|
|
2381
|
+
header: t("amount"),
|
|
2382
|
+
meta: { numeric: true }
|
|
2383
|
+
})
|
|
2384
|
+
]);
|
|
2385
|
+
$[24] = t;
|
|
2386
|
+
$[25] = t9;
|
|
2387
|
+
} else t9 = $[25];
|
|
2388
|
+
let t10;
|
|
2389
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2390
|
+
t10 = {
|
|
2391
|
+
minSize: 140,
|
|
2392
|
+
size: 180
|
|
2393
|
+
};
|
|
2394
|
+
$[26] = t10;
|
|
2395
|
+
} else t10 = $[26];
|
|
2396
|
+
let t11;
|
|
2397
|
+
if ($[27] !== t9) {
|
|
2398
|
+
t11 = {
|
|
2399
|
+
columns: t9,
|
|
2400
|
+
data: RECENT,
|
|
2401
|
+
defaultColumn: t10,
|
|
2402
|
+
getRowId: _temp2$10
|
|
2403
|
+
};
|
|
2404
|
+
$[27] = t9;
|
|
2405
|
+
$[28] = t11;
|
|
2406
|
+
} else t11 = $[28];
|
|
2407
|
+
const table = useDataTable(t11);
|
|
2408
|
+
let t12;
|
|
2409
|
+
if ($[29] !== t) {
|
|
2410
|
+
t12 = t("menus.caption");
|
|
2411
|
+
$[29] = t;
|
|
2412
|
+
$[30] = t12;
|
|
2413
|
+
} else t12 = $[30];
|
|
2414
|
+
let t13;
|
|
2415
|
+
if ($[31] !== words) {
|
|
2416
|
+
t13 = (each) => menuOf(each, words);
|
|
2417
|
+
$[31] = words;
|
|
2418
|
+
$[32] = t13;
|
|
2419
|
+
} else t13 = $[32];
|
|
2420
|
+
let t14;
|
|
2421
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2422
|
+
t14 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
2423
|
+
$[33] = t14;
|
|
2424
|
+
} else t14 = $[33];
|
|
2425
|
+
let t15;
|
|
2426
|
+
if ($[34] !== t12 || $[35] !== t13) {
|
|
2427
|
+
t15 = /* @__PURE__ */ jsx(Table$1, {
|
|
2428
|
+
caption: t12,
|
|
2429
|
+
columnActions: t13,
|
|
2430
|
+
sortIndicator: t14,
|
|
2431
|
+
variant: "surface"
|
|
2432
|
+
});
|
|
2433
|
+
$[34] = t12;
|
|
2434
|
+
$[35] = t13;
|
|
2435
|
+
$[36] = t15;
|
|
2436
|
+
} else t15 = $[36];
|
|
2437
|
+
let t16;
|
|
2438
|
+
if ($[37] !== t15 || $[38] !== table) {
|
|
2439
|
+
t16 = /* @__PURE__ */ jsx(Root, {
|
|
2440
|
+
table,
|
|
2441
|
+
children: t15
|
|
2442
|
+
});
|
|
2443
|
+
$[37] = t15;
|
|
2444
|
+
$[38] = table;
|
|
2445
|
+
$[39] = t16;
|
|
2446
|
+
} else t16 = $[39];
|
|
2447
|
+
return t16;
|
|
2448
|
+
}
|
|
2449
|
+
function _temp2$10(row) {
|
|
2450
|
+
return row.reference;
|
|
2451
|
+
}
|
|
2452
|
+
function _temp$10(cell) {
|
|
2453
|
+
return amountOf$10(cell.getValue());
|
|
2454
|
+
}
|
|
2455
|
+
const source$11 = "import { type ReactElement } from \"react\";\n\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n EllipsisVerticalIcon,\n EyeOffIcon,\n PinIcon,\n PinOffIcon,\n XIcon,\n} from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { RECENT, type Transfer } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst GLYPHS: DataTable.ColumnMenuIndicators = {\n ascending: <ArrowUpIcon />,\n descending: <ArrowDownIcon />,\n end: <PinIcon />,\n hide: <EyeOffIcon />,\n start: <PinIcon />,\n unpinned: <PinOffIcon />,\n unsorted: <XIcon />,\n};\n\ntype MenuWords = Omit<DataTable.ColumnMenuProps, \"actionIndicators\" | \"column\" | \"indicator\">;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nfunction menuOf(each: DataTable.TableColumn, words: MenuWords): ReactElement {\n return (\n <DataTable.ColumnMenu\n {...words}\n actionIndicators={GLYPHS}\n column={each}\n indicator={<EllipsisVerticalIcon size=\"1em\" />}\n />\n );\n}\n\nexport function Menus(): ReactElement {\n const { t } = useWords(\"data-table\");\n const words: MenuWords = {\n ascendingLabel: t(\"menus.ascending\"),\n descendingLabel: t(\"menus.descending\"),\n endLabel: t(\"menus.end\"),\n hideLabel: t(\"menus.hide\"),\n label: (name) => t(\"menus.options\", { column: name }),\n startLabel: t(\"menus.start\"),\n unpinnedLabel: t(\"menus.unpinned\"),\n unsortedLabel: t(\"menus.unsorted\"),\n };\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", { header: t(\"ledger.reference\"), meta: { rowHeader: true } }),\n column.accessor((transfer) => t(transfer.account), { header: t(\"account\"), id: \"account\" }),\n column.accessor((transfer) => t(transfer.region), {\n header: t(\"spanned.region\"),\n id: \"region\",\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: RECENT,\n defaultColumn: { minSize: 140, size: 180 },\n getRowId: (row) => row.reference,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"menus.caption\")}\n columnActions={(each) => menuOf(each, words)}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
2456
|
+
//#endregion
|
|
2457
|
+
//#region src/data-table/examples/pages.example.tsx
|
|
2458
|
+
var pages_example_exports = /* @__PURE__ */ __exportAll({
|
|
2459
|
+
Pages: () => Pages,
|
|
2460
|
+
source: () => source$10
|
|
2461
|
+
});
|
|
2462
|
+
const column$9 = createColumnHelper();
|
|
2463
|
+
const EURO$10 = {
|
|
2464
|
+
currency: "EUR",
|
|
2465
|
+
style: "currency"
|
|
2466
|
+
};
|
|
2467
|
+
const SIZES = [
|
|
2468
|
+
10,
|
|
2469
|
+
20,
|
|
2470
|
+
50
|
|
2471
|
+
];
|
|
2472
|
+
function amountOf$9(value) {
|
|
2473
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
2474
|
+
options: EURO$10,
|
|
2475
|
+
value
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
function Pages() {
|
|
2479
|
+
const $ = c(44);
|
|
2480
|
+
const { t } = useWords("data-table");
|
|
2481
|
+
let t0;
|
|
2482
|
+
if ($[0] !== t) {
|
|
2483
|
+
t0 = column$9.columns([
|
|
2484
|
+
column$9.accessor("reference", {
|
|
2485
|
+
header: t("ledger.reference"),
|
|
2486
|
+
meta: { rowHeader: true }
|
|
2487
|
+
}),
|
|
2488
|
+
column$9.accessor((transfer) => t(transfer.account), {
|
|
2489
|
+
header: t("account"),
|
|
2490
|
+
id: "account"
|
|
2491
|
+
}),
|
|
2492
|
+
column$9.accessor((transfer_0) => t(`ledger.${transfer_0.state}`), {
|
|
2493
|
+
header: t("ledger.state"),
|
|
2494
|
+
id: "state"
|
|
2495
|
+
}),
|
|
2496
|
+
column$9.accessor("amount", {
|
|
2497
|
+
cell: _temp$9,
|
|
2498
|
+
header: t("amount"),
|
|
2499
|
+
meta: { numeric: true }
|
|
2500
|
+
})
|
|
2501
|
+
]);
|
|
2502
|
+
$[0] = t;
|
|
2503
|
+
$[1] = t0;
|
|
2504
|
+
} else t0 = $[1];
|
|
2505
|
+
let t1;
|
|
2506
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2507
|
+
t1 = { pagination: {
|
|
2508
|
+
pageIndex: 0,
|
|
2509
|
+
pageSize: 10
|
|
2510
|
+
} };
|
|
2511
|
+
$[2] = t1;
|
|
2512
|
+
} else t1 = $[2];
|
|
2513
|
+
let t2;
|
|
2514
|
+
if ($[3] !== t0) {
|
|
2515
|
+
t2 = {
|
|
2516
|
+
columns: t0,
|
|
2517
|
+
data: TRANSFERS,
|
|
2518
|
+
getRowId: _temp2$9,
|
|
2519
|
+
initialState: t1
|
|
2520
|
+
};
|
|
2521
|
+
$[3] = t0;
|
|
2522
|
+
$[4] = t2;
|
|
2523
|
+
} else t2 = $[4];
|
|
2524
|
+
const table = useDataTable(t2);
|
|
2525
|
+
let t3;
|
|
2526
|
+
if ($[5] !== t) {
|
|
2527
|
+
t3 = t("ledger.caption");
|
|
2528
|
+
$[5] = t;
|
|
2529
|
+
$[6] = t3;
|
|
2530
|
+
} else t3 = $[6];
|
|
2531
|
+
let t4;
|
|
2532
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2533
|
+
t4 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
2534
|
+
$[7] = t4;
|
|
2535
|
+
} else t4 = $[7];
|
|
2536
|
+
let t5;
|
|
2537
|
+
if ($[8] !== t3) {
|
|
2538
|
+
t5 = /* @__PURE__ */ jsx(Table$1, {
|
|
2539
|
+
caption: t3,
|
|
2540
|
+
sortIndicator: t4,
|
|
2541
|
+
variant: "surface"
|
|
2542
|
+
});
|
|
2543
|
+
$[8] = t3;
|
|
2544
|
+
$[9] = t5;
|
|
2545
|
+
} else t5 = $[9];
|
|
2546
|
+
let t6;
|
|
2547
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2548
|
+
t6 = /* @__PURE__ */ jsx(ChevronDownIcon, {});
|
|
2549
|
+
$[10] = t6;
|
|
2550
|
+
} else t6 = $[10];
|
|
2551
|
+
let t7;
|
|
2552
|
+
if ($[11] !== t) {
|
|
2553
|
+
t7 = t("ledger.perPage");
|
|
2554
|
+
$[11] = t;
|
|
2555
|
+
$[12] = t7;
|
|
2556
|
+
} else t7 = $[12];
|
|
2557
|
+
let t8;
|
|
2558
|
+
if ($[13] !== t7) {
|
|
2559
|
+
t8 = /* @__PURE__ */ jsx(PageSize, {
|
|
2560
|
+
indicator: t6,
|
|
2561
|
+
label: t7,
|
|
2562
|
+
size: "sm",
|
|
2563
|
+
sizes: SIZES
|
|
2564
|
+
});
|
|
2565
|
+
$[13] = t7;
|
|
2566
|
+
$[14] = t8;
|
|
2567
|
+
} else t8 = $[14];
|
|
2568
|
+
let t9;
|
|
2569
|
+
if ($[15] !== t) {
|
|
2570
|
+
t9 = t("ledger.pages");
|
|
2571
|
+
$[15] = t;
|
|
2572
|
+
$[16] = t9;
|
|
2573
|
+
} else t9 = $[16];
|
|
2574
|
+
let t10;
|
|
2575
|
+
if ($[17] !== t) {
|
|
2576
|
+
t10 = /* @__PURE__ */ jsx(Pagination.PageText, { format: (t11) => {
|
|
2577
|
+
const { count, pageRange } = t11;
|
|
2578
|
+
return t("ledger.range", {
|
|
2579
|
+
count,
|
|
2580
|
+
end: pageRange.end,
|
|
2581
|
+
start: count === 0 ? 0 : pageRange.start + 1
|
|
2582
|
+
});
|
|
2583
|
+
} });
|
|
2584
|
+
$[17] = t;
|
|
2585
|
+
$[18] = t10;
|
|
2586
|
+
} else t10 = $[18];
|
|
2587
|
+
let t11;
|
|
2588
|
+
if ($[19] !== t) {
|
|
2589
|
+
t11 = t("ledger.previous");
|
|
2590
|
+
$[19] = t;
|
|
2591
|
+
$[20] = t11;
|
|
2592
|
+
} else t11 = $[20];
|
|
2593
|
+
let t12;
|
|
2594
|
+
if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2595
|
+
t12 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
|
|
2596
|
+
$[21] = t12;
|
|
2597
|
+
} else t12 = $[21];
|
|
2598
|
+
let t13;
|
|
2599
|
+
if ($[22] !== t11) {
|
|
2600
|
+
t13 = /* @__PURE__ */ jsx(Pagination.PrevTrigger, {
|
|
2601
|
+
label: t11,
|
|
2602
|
+
children: t12
|
|
2603
|
+
});
|
|
2604
|
+
$[22] = t11;
|
|
2605
|
+
$[23] = t13;
|
|
2606
|
+
} else t13 = $[23];
|
|
2607
|
+
let t14;
|
|
2608
|
+
if ($[24] !== t) {
|
|
2609
|
+
t14 = /* @__PURE__ */ jsx(Pagination.Items, {
|
|
2610
|
+
label: (page) => t("ledger.page", { page }),
|
|
2611
|
+
summary: (t15) => {
|
|
2612
|
+
const { page: page_0, totalPages } = t15;
|
|
2613
|
+
return t("ledger.summary", {
|
|
2614
|
+
page: page_0,
|
|
2615
|
+
totalPages
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
$[24] = t;
|
|
2620
|
+
$[25] = t14;
|
|
2621
|
+
} else t14 = $[25];
|
|
2622
|
+
let t15;
|
|
2623
|
+
if ($[26] !== t) {
|
|
2624
|
+
t15 = t("ledger.next");
|
|
2625
|
+
$[26] = t;
|
|
2626
|
+
$[27] = t15;
|
|
2627
|
+
} else t15 = $[27];
|
|
2628
|
+
let t16;
|
|
2629
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2630
|
+
t16 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
|
|
2631
|
+
$[28] = t16;
|
|
2632
|
+
} else t16 = $[28];
|
|
2633
|
+
let t17;
|
|
2634
|
+
if ($[29] !== t15) {
|
|
2635
|
+
t17 = /* @__PURE__ */ jsx(Pagination.NextTrigger, {
|
|
2636
|
+
label: t15,
|
|
2637
|
+
children: t16
|
|
2638
|
+
});
|
|
2639
|
+
$[29] = t15;
|
|
2640
|
+
$[30] = t17;
|
|
2641
|
+
} else t17 = $[30];
|
|
2642
|
+
let t18;
|
|
2643
|
+
if ($[31] !== t10 || $[32] !== t13 || $[33] !== t14 || $[34] !== t17 || $[35] !== t9) {
|
|
2644
|
+
t18 = /* @__PURE__ */ jsxs(TablePagination, {
|
|
2645
|
+
"aria-label": t9,
|
|
2646
|
+
size: "sm",
|
|
2647
|
+
children: [
|
|
2648
|
+
t10,
|
|
2649
|
+
t13,
|
|
2650
|
+
t14,
|
|
2651
|
+
t17
|
|
2652
|
+
]
|
|
2653
|
+
});
|
|
2654
|
+
$[31] = t10;
|
|
2655
|
+
$[32] = t13;
|
|
2656
|
+
$[33] = t14;
|
|
2657
|
+
$[34] = t17;
|
|
2658
|
+
$[35] = t9;
|
|
2659
|
+
$[36] = t18;
|
|
2660
|
+
} else t18 = $[36];
|
|
2661
|
+
let t19;
|
|
2662
|
+
if ($[37] !== t18 || $[38] !== t8) {
|
|
2663
|
+
t19 = /* @__PURE__ */ jsxs(Stack, {
|
|
2664
|
+
align: "baseline",
|
|
2665
|
+
direction: "row",
|
|
2666
|
+
gap: "md",
|
|
2667
|
+
justify: "between",
|
|
2668
|
+
wrap: true,
|
|
2669
|
+
children: [t8, t18]
|
|
2670
|
+
});
|
|
2671
|
+
$[37] = t18;
|
|
2672
|
+
$[38] = t8;
|
|
2673
|
+
$[39] = t19;
|
|
2674
|
+
} else t19 = $[39];
|
|
2675
|
+
let t20;
|
|
2676
|
+
if ($[40] !== t19 || $[41] !== t5 || $[42] !== table) {
|
|
2677
|
+
t20 = /* @__PURE__ */ jsxs(Root, {
|
|
2678
|
+
table,
|
|
2679
|
+
children: [t5, t19]
|
|
2680
|
+
});
|
|
2681
|
+
$[40] = t19;
|
|
2682
|
+
$[41] = t5;
|
|
2683
|
+
$[42] = table;
|
|
2684
|
+
$[43] = t20;
|
|
2685
|
+
} else t20 = $[43];
|
|
2686
|
+
return t20;
|
|
2687
|
+
}
|
|
2688
|
+
function _temp2$9(row) {
|
|
2689
|
+
return row.reference;
|
|
2690
|
+
}
|
|
2691
|
+
function _temp$9(cell) {
|
|
2692
|
+
return amountOf$9(cell.getValue());
|
|
2693
|
+
}
|
|
2694
|
+
const source$10 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { Pagination } from \"@stealthscale/component-navigation\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Transfer, TRANSFERS } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst SIZES = [10, 20, 50];\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Pages(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", { header: t(\"ledger.reference\"), meta: { rowHeader: true } }),\n column.accessor((transfer) => t(transfer.account), { header: t(\"account\"), id: \"account\" }),\n column.accessor((transfer) => t(`ledger.${transfer.state}`), {\n header: t(\"ledger.state\"),\n id: \"state\",\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: TRANSFERS,\n getRowId: (row) => row.reference,\n initialState: { pagination: { pageIndex: 0, pageSize: 10 } },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"ledger.caption\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n <Stack align=\"baseline\" direction=\"row\" gap=\"md\" justify=\"between\" wrap>\n <DataTable.PageSize\n indicator={<ChevronDownIcon />}\n label={t(\"ledger.perPage\")}\n size=\"sm\"\n sizes={SIZES}\n />\n <DataTable.Pagination aria-label={t(\"ledger.pages\")} size=\"sm\">\n <Pagination.PageText\n format={({ count, pageRange }) =>\n t(\"ledger.range\", {\n count,\n end: pageRange.end,\n start: count === 0 ? 0 : pageRange.start + 1,\n })\n }\n />\n <Pagination.PrevTrigger label={t(\"ledger.previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.Items\n label={(page) => t(\"ledger.page\", { page })}\n summary={({ page, totalPages }) => t(\"ledger.summary\", { page, totalPages })}\n />\n <Pagination.NextTrigger label={t(\"ledger.next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </DataTable.Pagination>\n </Stack>\n </DataTable.Root>\n );\n}\n";
|
|
2695
|
+
//#endregion
|
|
2696
|
+
//#region src/data-table/examples/pinned.example.tsx
|
|
2697
|
+
var pinned_example_exports = /* @__PURE__ */ __exportAll({
|
|
2698
|
+
Pinned: () => Pinned,
|
|
2699
|
+
source: () => source$9
|
|
2700
|
+
});
|
|
2701
|
+
const column$8 = createColumnHelper();
|
|
2702
|
+
const EURO$9 = {
|
|
2703
|
+
currency: "EUR",
|
|
2704
|
+
style: "currency"
|
|
2705
|
+
};
|
|
2706
|
+
function amountOf$8(value) {
|
|
2707
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
2708
|
+
options: EURO$9,
|
|
2709
|
+
value
|
|
2710
|
+
});
|
|
2711
|
+
}
|
|
2712
|
+
function Pinned() {
|
|
2713
|
+
const $ = c(14);
|
|
2714
|
+
const { t } = useWords("data-table");
|
|
2715
|
+
let t0;
|
|
2716
|
+
if ($[0] !== t) {
|
|
2717
|
+
let t1;
|
|
2718
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2719
|
+
t1 = /* @__PURE__ */ jsx(PinIcon, { size: "1em" });
|
|
2720
|
+
$[2] = t1;
|
|
2721
|
+
} else t1 = $[2];
|
|
2722
|
+
t0 = column$8.columns([
|
|
2723
|
+
pinColumn({
|
|
2724
|
+
header: t("pinned.header"),
|
|
2725
|
+
indicator: t1,
|
|
2726
|
+
label: (payout) => t("pinned.one", { account: t(payout.account) })
|
|
2727
|
+
}),
|
|
2728
|
+
column$8.accessor("account", {
|
|
2729
|
+
cell: (cell) => t(cell.getValue()),
|
|
2730
|
+
header: t("account"),
|
|
2731
|
+
meta: { rowHeader: true }
|
|
2732
|
+
}),
|
|
2733
|
+
column$8.accessor("transfers", {
|
|
2734
|
+
header: t("transfers"),
|
|
2735
|
+
meta: { numeric: true }
|
|
2736
|
+
}),
|
|
2737
|
+
column$8.accessor("amount", {
|
|
2738
|
+
cell: _temp$8,
|
|
2739
|
+
header: t("amount"),
|
|
2740
|
+
meta: { numeric: true }
|
|
2741
|
+
})
|
|
2742
|
+
]);
|
|
2743
|
+
$[0] = t;
|
|
2744
|
+
$[1] = t0;
|
|
2745
|
+
} else t0 = $[1];
|
|
2746
|
+
let t1;
|
|
2747
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2748
|
+
t1 = { rowPinning: {
|
|
2749
|
+
bottom: [],
|
|
2750
|
+
top: ["perrin"]
|
|
2751
|
+
} };
|
|
2752
|
+
$[3] = t1;
|
|
2753
|
+
} else t1 = $[3];
|
|
2754
|
+
let t2;
|
|
2755
|
+
if ($[4] !== t0) {
|
|
2756
|
+
t2 = {
|
|
2757
|
+
columns: t0,
|
|
2758
|
+
data: PAYOUTS,
|
|
2759
|
+
getRowId: _temp2$8,
|
|
2760
|
+
initialState: t1
|
|
2761
|
+
};
|
|
2762
|
+
$[4] = t0;
|
|
2763
|
+
$[5] = t2;
|
|
2764
|
+
} else t2 = $[5];
|
|
2765
|
+
const table = useDataTable(t2);
|
|
2766
|
+
let t3;
|
|
2767
|
+
if ($[6] !== t) {
|
|
2768
|
+
t3 = t("pinned.caption");
|
|
2769
|
+
$[6] = t;
|
|
2770
|
+
$[7] = t3;
|
|
2771
|
+
} else t3 = $[7];
|
|
2772
|
+
let t4;
|
|
2773
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2774
|
+
t4 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
2775
|
+
$[8] = t4;
|
|
2776
|
+
} else t4 = $[8];
|
|
2777
|
+
let t5;
|
|
2778
|
+
if ($[9] !== t3) {
|
|
2779
|
+
t5 = /* @__PURE__ */ jsx(Table$1, {
|
|
2780
|
+
caption: t3,
|
|
2781
|
+
sortIndicator: t4,
|
|
2782
|
+
variant: "surface"
|
|
2783
|
+
});
|
|
2784
|
+
$[9] = t3;
|
|
2785
|
+
$[10] = t5;
|
|
2786
|
+
} else t5 = $[10];
|
|
2787
|
+
let t6;
|
|
2788
|
+
if ($[11] !== t5 || $[12] !== table) {
|
|
2789
|
+
t6 = /* @__PURE__ */ jsx(Root, {
|
|
2790
|
+
table,
|
|
2791
|
+
children: t5
|
|
2792
|
+
});
|
|
2793
|
+
$[11] = t5;
|
|
2794
|
+
$[12] = table;
|
|
2795
|
+
$[13] = t6;
|
|
2796
|
+
} else t6 = $[13];
|
|
2797
|
+
return t6;
|
|
2798
|
+
}
|
|
2799
|
+
function _temp2$8(row) {
|
|
2800
|
+
return row.account;
|
|
2801
|
+
}
|
|
2802
|
+
function _temp$8(cell_0) {
|
|
2803
|
+
return amountOf$8(cell_0.getValue());
|
|
2804
|
+
}
|
|
2805
|
+
const source$9 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, PinIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Pinned(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n DataTable.pinColumn<Payout>({\n header: t(\"pinned.header\"),\n indicator: <PinIcon size=\"1em\" />,\n label: (payout) => t(\"pinned.one\", { account: t(payout.account) }),\n }),\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"transfers\", { header: t(\"transfers\"), meta: { numeric: true } }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n initialState: { rowPinning: { bottom: [], top: [\"perrin\"] } },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"pinned.caption\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
2806
|
+
//#endregion
|
|
2807
|
+
//#region src/data-table/examples/pivot.example.tsx
|
|
2808
|
+
var pivot_example_exports = /* @__PURE__ */ __exportAll({
|
|
2809
|
+
Pivot: () => Pivot,
|
|
2810
|
+
source: () => source$8
|
|
2811
|
+
});
|
|
2812
|
+
const EURO$8 = {
|
|
2813
|
+
currency: "EUR",
|
|
2814
|
+
maximumFractionDigits: 0,
|
|
2815
|
+
style: "currency"
|
|
2816
|
+
};
|
|
2817
|
+
function Pivot() {
|
|
2818
|
+
const $ = c(9);
|
|
2819
|
+
const { t } = useWords("data-table");
|
|
2820
|
+
let t0;
|
|
2821
|
+
if ($[0] !== t) {
|
|
2822
|
+
t0 = pivot$1(SALES.map((sale) => ({
|
|
2823
|
+
product: t(`pivot.${sale.product}`),
|
|
2824
|
+
quarter: t(`pivot.${sale.quarter}`),
|
|
2825
|
+
region: t(`pivot.${sale.region}`),
|
|
2826
|
+
value: sale.value
|
|
2827
|
+
})), {
|
|
2828
|
+
column: "quarter",
|
|
2829
|
+
format: EURO$8,
|
|
2830
|
+
headers: {
|
|
2831
|
+
product: t("pivot.product"),
|
|
2832
|
+
region: t("pivot.region")
|
|
2833
|
+
},
|
|
2834
|
+
missingLabel: t("pivot.missing"),
|
|
2835
|
+
rows: ["region", "product"],
|
|
2836
|
+
totalLabel: t("pivot.total"),
|
|
2837
|
+
value: "value"
|
|
2838
|
+
});
|
|
2839
|
+
$[0] = t;
|
|
2840
|
+
$[1] = t0;
|
|
2841
|
+
} else t0 = $[1];
|
|
2842
|
+
const table = useDataTable(t0);
|
|
2843
|
+
let t1;
|
|
2844
|
+
if ($[2] !== t) {
|
|
2845
|
+
t1 = t("pivot.caption");
|
|
2846
|
+
$[2] = t;
|
|
2847
|
+
$[3] = t1;
|
|
2848
|
+
} else t1 = $[3];
|
|
2849
|
+
let t2;
|
|
2850
|
+
if ($[4] !== t1) {
|
|
2851
|
+
t2 = /* @__PURE__ */ jsx(Table$1, {
|
|
2852
|
+
align: "start",
|
|
2853
|
+
caption: t1,
|
|
2854
|
+
variant: "surface"
|
|
2855
|
+
});
|
|
2856
|
+
$[4] = t1;
|
|
2857
|
+
$[5] = t2;
|
|
2858
|
+
} else t2 = $[5];
|
|
2859
|
+
let t3;
|
|
2860
|
+
if ($[6] !== t2 || $[7] !== table) {
|
|
2861
|
+
t3 = /* @__PURE__ */ jsx(Root, {
|
|
2862
|
+
table,
|
|
2863
|
+
children: t2
|
|
2864
|
+
});
|
|
2865
|
+
$[6] = t2;
|
|
2866
|
+
$[7] = table;
|
|
2867
|
+
$[8] = t3;
|
|
2868
|
+
} else t3 = $[8];
|
|
2869
|
+
return t3;
|
|
2870
|
+
}
|
|
2871
|
+
const source$8 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { SALES } from \"./sales.ts\";\n\nconst EURO = { currency: \"EUR\", maximumFractionDigits: 0, style: \"currency\" } as const;\n\nexport function Pivot(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable(\n DataTable.pivot(\n SALES.map((sale) => ({\n product: t(`pivot.${sale.product}`),\n quarter: t(`pivot.${sale.quarter}`),\n region: t(`pivot.${sale.region}`),\n value: sale.value,\n })),\n {\n column: \"quarter\",\n format: EURO,\n headers: { product: t(\"pivot.product\"), region: t(\"pivot.region\") },\n missingLabel: t(\"pivot.missing\"),\n rows: [\"region\", \"product\"],\n totalLabel: t(\"pivot.total\"),\n value: \"value\",\n },\n ),\n );\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table align=\"start\" caption={t(\"pivot.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
2872
|
+
//#endregion
|
|
2873
|
+
//#region src/data-table/examples/search.example.tsx
|
|
2874
|
+
var search_example_exports = /* @__PURE__ */ __exportAll({
|
|
2875
|
+
Searching: () => Searching,
|
|
2876
|
+
source: () => source$7
|
|
2877
|
+
});
|
|
2878
|
+
const column$7 = createColumnHelper();
|
|
2879
|
+
const EURO$7 = {
|
|
2880
|
+
currency: "EUR",
|
|
2881
|
+
style: "currency"
|
|
2882
|
+
};
|
|
2883
|
+
function amountOf$7(value) {
|
|
2884
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
2885
|
+
options: EURO$7,
|
|
2886
|
+
value
|
|
2887
|
+
});
|
|
2888
|
+
}
|
|
2889
|
+
function Searching() {
|
|
2890
|
+
const $ = c(31);
|
|
2891
|
+
const { t } = useWords("data-table");
|
|
2892
|
+
let t0;
|
|
2893
|
+
if ($[0] !== t) {
|
|
2894
|
+
t0 = column$7.columns([
|
|
2895
|
+
column$7.accessor((payout) => t(payout.account), {
|
|
2896
|
+
header: t("account"),
|
|
2897
|
+
id: "account",
|
|
2898
|
+
meta: { rowHeader: true }
|
|
2899
|
+
}),
|
|
2900
|
+
column$7.accessor((payout_0) => t(payout_0.region), {
|
|
2901
|
+
header: t("spanned.region"),
|
|
2902
|
+
id: "region"
|
|
2903
|
+
}),
|
|
2904
|
+
column$7.accessor("amount", {
|
|
2905
|
+
cell: _temp$7,
|
|
2906
|
+
header: t("amount"),
|
|
2907
|
+
meta: { numeric: true }
|
|
2908
|
+
})
|
|
2909
|
+
]);
|
|
2910
|
+
$[0] = t;
|
|
2911
|
+
$[1] = t0;
|
|
2912
|
+
} else t0 = $[1];
|
|
2913
|
+
let t1;
|
|
2914
|
+
if ($[2] !== t0) {
|
|
2915
|
+
t1 = {
|
|
2916
|
+
columns: t0,
|
|
2917
|
+
data: PAYOUTS,
|
|
2918
|
+
getRowId: _temp2$7
|
|
2919
|
+
};
|
|
2920
|
+
$[2] = t0;
|
|
2921
|
+
$[3] = t1;
|
|
2922
|
+
} else t1 = $[3];
|
|
2923
|
+
const table = useDataTable(t1);
|
|
2924
|
+
let t2;
|
|
2925
|
+
if ($[4] !== t) {
|
|
2926
|
+
t2 = t("search.label");
|
|
2927
|
+
$[4] = t;
|
|
2928
|
+
$[5] = t2;
|
|
2929
|
+
} else t2 = $[5];
|
|
2930
|
+
let t3;
|
|
2931
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2932
|
+
t3 = /* @__PURE__ */ jsx(XIcon, { size: "1em" });
|
|
2933
|
+
$[6] = t3;
|
|
2934
|
+
} else t3 = $[6];
|
|
2935
|
+
let t4;
|
|
2936
|
+
if ($[7] !== t) {
|
|
2937
|
+
t4 = t("search.clear");
|
|
2938
|
+
$[7] = t;
|
|
2939
|
+
$[8] = t4;
|
|
2940
|
+
} else t4 = $[8];
|
|
2941
|
+
let t5;
|
|
2942
|
+
if ($[9] !== t) {
|
|
2943
|
+
t5 = t("search.label");
|
|
2944
|
+
$[9] = t;
|
|
2945
|
+
$[10] = t5;
|
|
2946
|
+
} else t5 = $[10];
|
|
2947
|
+
let t6;
|
|
2948
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2949
|
+
t6 = /* @__PURE__ */ jsx(SearchIcon, { size: "1em" });
|
|
2950
|
+
$[11] = t6;
|
|
2951
|
+
} else t6 = $[11];
|
|
2952
|
+
let t7;
|
|
2953
|
+
if ($[12] !== t2 || $[13] !== t4 || $[14] !== t5) {
|
|
2954
|
+
t7 = /* @__PURE__ */ jsx(Search, {
|
|
2955
|
+
"aria-label": t2,
|
|
2956
|
+
clearIndicator: t3,
|
|
2957
|
+
clearLabel: t4,
|
|
2958
|
+
placeholder: t5,
|
|
2959
|
+
searchIndicator: t6
|
|
2960
|
+
});
|
|
2961
|
+
$[12] = t2;
|
|
2962
|
+
$[13] = t4;
|
|
2963
|
+
$[14] = t5;
|
|
2964
|
+
$[15] = t7;
|
|
2965
|
+
} else t7 = $[15];
|
|
2966
|
+
let t8;
|
|
2967
|
+
if ($[16] !== t) {
|
|
2968
|
+
t8 = t("search.caption");
|
|
2969
|
+
$[16] = t;
|
|
2970
|
+
$[17] = t8;
|
|
2971
|
+
} else t8 = $[17];
|
|
2972
|
+
let t9;
|
|
2973
|
+
if ($[18] !== t) {
|
|
2974
|
+
t9 = t("search.empty");
|
|
2975
|
+
$[18] = t;
|
|
2976
|
+
$[19] = t9;
|
|
2977
|
+
} else t9 = $[19];
|
|
2978
|
+
let t10;
|
|
2979
|
+
if ($[20] !== t) {
|
|
2980
|
+
t10 = (count, total) => t("search.found", {
|
|
2981
|
+
count,
|
|
2982
|
+
total
|
|
2983
|
+
});
|
|
2984
|
+
$[20] = t;
|
|
2985
|
+
$[21] = t10;
|
|
2986
|
+
} else t10 = $[21];
|
|
2987
|
+
let t11;
|
|
2988
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2989
|
+
t11 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
2990
|
+
$[22] = t11;
|
|
2991
|
+
} else t11 = $[22];
|
|
2992
|
+
let t12;
|
|
2993
|
+
if ($[23] !== t10 || $[24] !== t8 || $[25] !== t9) {
|
|
2994
|
+
t12 = /* @__PURE__ */ jsx(Table$1, {
|
|
2995
|
+
caption: t8,
|
|
2996
|
+
empty: t9,
|
|
2997
|
+
filteredAnnouncement: t10,
|
|
2998
|
+
sortIndicator: t11,
|
|
2999
|
+
variant: "surface"
|
|
3000
|
+
});
|
|
3001
|
+
$[23] = t10;
|
|
3002
|
+
$[24] = t8;
|
|
3003
|
+
$[25] = t9;
|
|
3004
|
+
$[26] = t12;
|
|
3005
|
+
} else t12 = $[26];
|
|
3006
|
+
let t13;
|
|
3007
|
+
if ($[27] !== t12 || $[28] !== t7 || $[29] !== table) {
|
|
3008
|
+
t13 = /* @__PURE__ */ jsxs(Root, {
|
|
3009
|
+
table,
|
|
3010
|
+
children: [t7, t12]
|
|
3011
|
+
});
|
|
3012
|
+
$[27] = t12;
|
|
3013
|
+
$[28] = t7;
|
|
3014
|
+
$[29] = table;
|
|
3015
|
+
$[30] = t13;
|
|
3016
|
+
} else t13 = $[30];
|
|
3017
|
+
return t13;
|
|
3018
|
+
}
|
|
3019
|
+
function _temp2$7(row) {
|
|
3020
|
+
return row.account;
|
|
3021
|
+
}
|
|
3022
|
+
function _temp$7(cell) {
|
|
3023
|
+
return amountOf$7(cell.getValue());
|
|
3024
|
+
}
|
|
3025
|
+
const source$7 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, SearchIcon, XIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Searching(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor((payout) => t(payout.account), {\n header: t(\"account\"),\n id: \"account\",\n meta: { rowHeader: true },\n }),\n column.accessor((payout) => t(payout.region), { header: t(\"spanned.region\"), id: \"region\" }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Search\n aria-label={t(\"search.label\")}\n clearIndicator={<XIcon size=\"1em\" />}\n clearLabel={t(\"search.clear\")}\n placeholder={t(\"search.label\")}\n searchIndicator={<SearchIcon size=\"1em\" />}\n />\n <DataTable.Table\n caption={t(\"search.caption\")}\n empty={t(\"search.empty\")}\n filteredAnnouncement={(count, total) => t(\"search.found\", { count, total })}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
3026
|
+
//#endregion
|
|
3027
|
+
//#region src/data-table/examples/selection.example.tsx
|
|
3028
|
+
var selection_example_exports = /* @__PURE__ */ __exportAll({
|
|
3029
|
+
Selection: () => Selection,
|
|
3030
|
+
source: () => source$6
|
|
3031
|
+
});
|
|
3032
|
+
const column$6 = createColumnHelper();
|
|
3033
|
+
const EURO$6 = {
|
|
3034
|
+
currency: "EUR",
|
|
3035
|
+
style: "currency"
|
|
3036
|
+
};
|
|
3037
|
+
function amountOf$6(value) {
|
|
3038
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3039
|
+
options: EURO$6,
|
|
3040
|
+
value
|
|
3041
|
+
});
|
|
3042
|
+
}
|
|
3043
|
+
function Selection() {
|
|
3044
|
+
const $ = c(21);
|
|
3045
|
+
const { t } = useWords("data-table");
|
|
3046
|
+
let t0;
|
|
3047
|
+
if ($[0] !== t) {
|
|
3048
|
+
let t1;
|
|
3049
|
+
let t2;
|
|
3050
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3051
|
+
t1 = /* @__PURE__ */ jsx(MinusIcon, { strokeWidth: 3 });
|
|
3052
|
+
t2 = /* @__PURE__ */ jsx(CheckIcon, { strokeWidth: 3 });
|
|
3053
|
+
$[2] = t1;
|
|
3054
|
+
$[3] = t2;
|
|
3055
|
+
} else {
|
|
3056
|
+
t1 = $[2];
|
|
3057
|
+
t2 = $[3];
|
|
3058
|
+
}
|
|
3059
|
+
t0 = column$6.columns([
|
|
3060
|
+
selectColumn({
|
|
3061
|
+
allLabel: t("selection.all"),
|
|
3062
|
+
indeterminateIndicator: t1,
|
|
3063
|
+
indicator: t2,
|
|
3064
|
+
label: (payout) => t("selection.one", { account: t(payout.account) })
|
|
3065
|
+
}),
|
|
3066
|
+
column$6.accessor("account", {
|
|
3067
|
+
cell: (cell) => t(cell.getValue()),
|
|
3068
|
+
header: t("account"),
|
|
3069
|
+
meta: { rowHeader: true }
|
|
3070
|
+
}),
|
|
3071
|
+
column$6.accessor("amount", {
|
|
3072
|
+
cell: _temp$6,
|
|
3073
|
+
header: t("amount"),
|
|
3074
|
+
meta: { numeric: true }
|
|
3075
|
+
})
|
|
3076
|
+
]);
|
|
3077
|
+
$[0] = t;
|
|
3078
|
+
$[1] = t0;
|
|
3079
|
+
} else t0 = $[1];
|
|
3080
|
+
let t1;
|
|
3081
|
+
if ($[4] !== t0) {
|
|
3082
|
+
t1 = {
|
|
3083
|
+
columns: t0,
|
|
3084
|
+
data: PAYOUTS,
|
|
3085
|
+
getRowId: _temp2$6
|
|
3086
|
+
};
|
|
3087
|
+
$[4] = t0;
|
|
3088
|
+
$[5] = t1;
|
|
3089
|
+
} else t1 = $[5];
|
|
3090
|
+
const table = useDataTable(t1);
|
|
3091
|
+
let t2;
|
|
3092
|
+
if ($[6] !== table.state.rowSelection) {
|
|
3093
|
+
t2 = Object.keys(table.state.rowSelection);
|
|
3094
|
+
$[6] = table.state.rowSelection;
|
|
3095
|
+
$[7] = t2;
|
|
3096
|
+
} else t2 = $[7];
|
|
3097
|
+
const count = t2.length;
|
|
3098
|
+
let t3;
|
|
3099
|
+
if ($[8] !== count || $[9] !== t) {
|
|
3100
|
+
t3 = t("selection.count", { count });
|
|
3101
|
+
$[8] = count;
|
|
3102
|
+
$[9] = t;
|
|
3103
|
+
$[10] = t3;
|
|
3104
|
+
} else t3 = $[10];
|
|
3105
|
+
let t4;
|
|
3106
|
+
if ($[11] !== t3) {
|
|
3107
|
+
t4 = /* @__PURE__ */ jsx(Text, {
|
|
3108
|
+
as: "output",
|
|
3109
|
+
children: t3
|
|
3110
|
+
});
|
|
3111
|
+
$[11] = t3;
|
|
3112
|
+
$[12] = t4;
|
|
3113
|
+
} else t4 = $[12];
|
|
3114
|
+
let t5;
|
|
3115
|
+
if ($[13] !== t) {
|
|
3116
|
+
t5 = t("selection.caption");
|
|
3117
|
+
$[13] = t;
|
|
3118
|
+
$[14] = t5;
|
|
3119
|
+
} else t5 = $[14];
|
|
3120
|
+
let t6;
|
|
3121
|
+
if ($[15] !== t5) {
|
|
3122
|
+
t6 = /* @__PURE__ */ jsx(Table$1, {
|
|
3123
|
+
caption: t5,
|
|
3124
|
+
variant: "surface"
|
|
3125
|
+
});
|
|
3126
|
+
$[15] = t5;
|
|
3127
|
+
$[16] = t6;
|
|
3128
|
+
} else t6 = $[16];
|
|
3129
|
+
let t7;
|
|
3130
|
+
if ($[17] !== t4 || $[18] !== t6 || $[19] !== table) {
|
|
3131
|
+
t7 = /* @__PURE__ */ jsxs(Root, {
|
|
3132
|
+
table,
|
|
3133
|
+
children: [t4, t6]
|
|
3134
|
+
});
|
|
3135
|
+
$[17] = t4;
|
|
3136
|
+
$[18] = t6;
|
|
3137
|
+
$[19] = table;
|
|
3138
|
+
$[20] = t7;
|
|
3139
|
+
} else t7 = $[20];
|
|
3140
|
+
return t7;
|
|
3141
|
+
}
|
|
3142
|
+
function _temp2$6(row) {
|
|
3143
|
+
return row.account;
|
|
3144
|
+
}
|
|
3145
|
+
function _temp$6(cell_0) {
|
|
3146
|
+
return amountOf$6(cell_0.getValue());
|
|
3147
|
+
}
|
|
3148
|
+
const source$6 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, MinusIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Selection(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n DataTable.selectColumn<Payout>({\n allLabel: t(\"selection.all\"),\n indeterminateIndicator: <MinusIcon strokeWidth={3} />,\n indicator: <CheckIcon strokeWidth={3} />,\n label: (payout) => t(\"selection.one\", { account: t(payout.account) }),\n }),\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n });\n const count = Object.keys(table.state.rowSelection).length;\n\n return (\n <DataTable.Root table={table}>\n <Text as=\"output\">{t(\"selection.count\", { count })}</Text>\n <DataTable.Table caption={t(\"selection.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
3149
|
+
//#endregion
|
|
3150
|
+
//#region src/data-table/examples/server.example.tsx
|
|
3151
|
+
var server_example_exports = /* @__PURE__ */ __exportAll({
|
|
3152
|
+
Server: () => Server,
|
|
3153
|
+
source: () => source$5
|
|
3154
|
+
});
|
|
3155
|
+
const column$5 = createColumnHelper();
|
|
3156
|
+
const EURO$5 = {
|
|
3157
|
+
currency: "EUR",
|
|
3158
|
+
style: "currency"
|
|
3159
|
+
};
|
|
3160
|
+
function amountOf$5(value) {
|
|
3161
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3162
|
+
options: EURO$5,
|
|
3163
|
+
value
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
function Server() {
|
|
3167
|
+
const $ = c(64);
|
|
3168
|
+
const { t } = useWords("data-table");
|
|
3169
|
+
let t0;
|
|
3170
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3171
|
+
t0 = {
|
|
3172
|
+
pageIndex: 0,
|
|
3173
|
+
pageSize: 8
|
|
3174
|
+
};
|
|
3175
|
+
$[0] = t0;
|
|
3176
|
+
} else t0 = $[0];
|
|
3177
|
+
const [pagination, setPagination] = useState(t0);
|
|
3178
|
+
let t1;
|
|
3179
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3180
|
+
t1 = [];
|
|
3181
|
+
$[1] = t1;
|
|
3182
|
+
} else t1 = $[1];
|
|
3183
|
+
const [sorting, setSorting] = useState(t1);
|
|
3184
|
+
const [search, setSearch] = useState("");
|
|
3185
|
+
let t2;
|
|
3186
|
+
if ($[2] !== pagination || $[3] !== search || $[4] !== sorting[0]) {
|
|
3187
|
+
t2 = {
|
|
3188
|
+
...pagination,
|
|
3189
|
+
search,
|
|
3190
|
+
sort: sorting[0]
|
|
3191
|
+
};
|
|
3192
|
+
$[2] = pagination;
|
|
3193
|
+
$[3] = search;
|
|
3194
|
+
$[4] = sorting[0];
|
|
3195
|
+
$[5] = t2;
|
|
3196
|
+
} else t2 = $[5];
|
|
3197
|
+
const { loading, page } = useServerPage(t2);
|
|
3198
|
+
let t3;
|
|
3199
|
+
if ($[6] !== t) {
|
|
3200
|
+
t3 = column$5.columns([
|
|
3201
|
+
column$5.accessor("reference", {
|
|
3202
|
+
enableSorting: false,
|
|
3203
|
+
header: t("ledger.reference"),
|
|
3204
|
+
meta: { rowHeader: true }
|
|
3205
|
+
}),
|
|
3206
|
+
column$5.accessor((transfer) => t(transfer.account), {
|
|
3207
|
+
enableSorting: false,
|
|
3208
|
+
header: t("account"),
|
|
3209
|
+
id: "account"
|
|
3210
|
+
}),
|
|
3211
|
+
column$5.accessor("amount", {
|
|
3212
|
+
cell: _temp$5,
|
|
3213
|
+
header: t("amount"),
|
|
3214
|
+
meta: { numeric: true }
|
|
3215
|
+
})
|
|
3216
|
+
]);
|
|
3217
|
+
$[6] = t;
|
|
3218
|
+
$[7] = t3;
|
|
3219
|
+
} else t3 = $[7];
|
|
3220
|
+
let t4;
|
|
3221
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3222
|
+
t4 = (next) => {
|
|
3223
|
+
setSearch(next);
|
|
3224
|
+
setPagination(_temp3$2);
|
|
3225
|
+
};
|
|
3226
|
+
$[8] = t4;
|
|
3227
|
+
} else t4 = $[8];
|
|
3228
|
+
let t5;
|
|
3229
|
+
if ($[9] !== pagination || $[10] !== search || $[11] !== sorting) {
|
|
3230
|
+
t5 = {
|
|
3231
|
+
globalFilter: search,
|
|
3232
|
+
pagination,
|
|
3233
|
+
sorting
|
|
3234
|
+
};
|
|
3235
|
+
$[9] = pagination;
|
|
3236
|
+
$[10] = search;
|
|
3237
|
+
$[11] = sorting;
|
|
3238
|
+
$[12] = t5;
|
|
3239
|
+
} else t5 = $[12];
|
|
3240
|
+
let t6;
|
|
3241
|
+
if ($[13] !== page.count || $[14] !== page.rows || $[15] !== t3 || $[16] !== t5) {
|
|
3242
|
+
t6 = {
|
|
3243
|
+
columns: t3,
|
|
3244
|
+
data: page.rows,
|
|
3245
|
+
getRowId: _temp2$5,
|
|
3246
|
+
manualFiltering: true,
|
|
3247
|
+
manualPagination: true,
|
|
3248
|
+
manualSorting: true,
|
|
3249
|
+
onGlobalFilterChange: t4,
|
|
3250
|
+
onPaginationChange: setPagination,
|
|
3251
|
+
onSortingChange: setSorting,
|
|
3252
|
+
rowCount: page.count,
|
|
3253
|
+
state: t5
|
|
3254
|
+
};
|
|
3255
|
+
$[13] = page.count;
|
|
3256
|
+
$[14] = page.rows;
|
|
3257
|
+
$[15] = t3;
|
|
3258
|
+
$[16] = t5;
|
|
3259
|
+
$[17] = t6;
|
|
3260
|
+
} else t6 = $[17];
|
|
3261
|
+
const table = useDataTable(t6);
|
|
3262
|
+
let t7;
|
|
3263
|
+
if ($[18] !== t) {
|
|
3264
|
+
t7 = t("server.search");
|
|
3265
|
+
$[18] = t;
|
|
3266
|
+
$[19] = t7;
|
|
3267
|
+
} else t7 = $[19];
|
|
3268
|
+
let t8;
|
|
3269
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3270
|
+
t8 = /* @__PURE__ */ jsx(XIcon, { size: "1em" });
|
|
3271
|
+
$[20] = t8;
|
|
3272
|
+
} else t8 = $[20];
|
|
3273
|
+
let t9;
|
|
3274
|
+
if ($[21] !== t) {
|
|
3275
|
+
t9 = t("search.clear");
|
|
3276
|
+
$[21] = t;
|
|
3277
|
+
$[22] = t9;
|
|
3278
|
+
} else t9 = $[22];
|
|
3279
|
+
let t10;
|
|
3280
|
+
if ($[23] !== t) {
|
|
3281
|
+
t10 = t("server.search");
|
|
3282
|
+
$[23] = t;
|
|
3283
|
+
$[24] = t10;
|
|
3284
|
+
} else t10 = $[24];
|
|
3285
|
+
let t11;
|
|
3286
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3287
|
+
t11 = /* @__PURE__ */ jsx(SearchIcon, { size: "1em" });
|
|
3288
|
+
$[25] = t11;
|
|
3289
|
+
} else t11 = $[25];
|
|
3290
|
+
let t12;
|
|
3291
|
+
if ($[26] !== t10 || $[27] !== t7 || $[28] !== t9) {
|
|
3292
|
+
t12 = /* @__PURE__ */ jsx(Search, {
|
|
3293
|
+
"aria-label": t7,
|
|
3294
|
+
clearIndicator: t8,
|
|
3295
|
+
clearLabel: t9,
|
|
3296
|
+
placeholder: t10,
|
|
3297
|
+
searchIndicator: t11
|
|
3298
|
+
});
|
|
3299
|
+
$[26] = t10;
|
|
3300
|
+
$[27] = t7;
|
|
3301
|
+
$[28] = t9;
|
|
3302
|
+
$[29] = t12;
|
|
3303
|
+
} else t12 = $[29];
|
|
3304
|
+
let t13;
|
|
3305
|
+
if ($[30] !== t) {
|
|
3306
|
+
t13 = t("server.caption");
|
|
3307
|
+
$[30] = t;
|
|
3308
|
+
$[31] = t13;
|
|
3309
|
+
} else t13 = $[31];
|
|
3310
|
+
let t14;
|
|
3311
|
+
if ($[32] !== loading || $[33] !== t) {
|
|
3312
|
+
t14 = loading ? t("server.loading") : t("server.empty");
|
|
3313
|
+
$[32] = loading;
|
|
3314
|
+
$[33] = t;
|
|
3315
|
+
$[34] = t14;
|
|
3316
|
+
} else t14 = $[34];
|
|
3317
|
+
let t15;
|
|
3318
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3319
|
+
t15 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
3320
|
+
$[35] = t15;
|
|
3321
|
+
} else t15 = $[35];
|
|
3322
|
+
let t16;
|
|
3323
|
+
if ($[36] !== loading || $[37] !== t13 || $[38] !== t14) {
|
|
3324
|
+
t16 = /* @__PURE__ */ jsx(Table$1, {
|
|
3325
|
+
"aria-busy": loading,
|
|
3326
|
+
caption: t13,
|
|
3327
|
+
empty: t14,
|
|
3328
|
+
sortIndicator: t15,
|
|
3329
|
+
variant: "surface"
|
|
3330
|
+
});
|
|
3331
|
+
$[36] = loading;
|
|
3332
|
+
$[37] = t13;
|
|
3333
|
+
$[38] = t14;
|
|
3334
|
+
$[39] = t16;
|
|
3335
|
+
} else t16 = $[39];
|
|
3336
|
+
let t17;
|
|
3337
|
+
if ($[40] !== t) {
|
|
3338
|
+
t17 = t("ledger.pages");
|
|
3339
|
+
$[40] = t;
|
|
3340
|
+
$[41] = t17;
|
|
3341
|
+
} else t17 = $[41];
|
|
3342
|
+
let t18;
|
|
3343
|
+
if ($[42] !== t) {
|
|
3344
|
+
t18 = t("ledger.previous");
|
|
3345
|
+
$[42] = t;
|
|
3346
|
+
$[43] = t18;
|
|
3347
|
+
} else t18 = $[43];
|
|
3348
|
+
let t19;
|
|
3349
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3350
|
+
t19 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
|
|
3351
|
+
$[44] = t19;
|
|
3352
|
+
} else t19 = $[44];
|
|
3353
|
+
let t20;
|
|
3354
|
+
if ($[45] !== t18) {
|
|
3355
|
+
t20 = /* @__PURE__ */ jsx(Pagination.PrevTrigger, {
|
|
3356
|
+
label: t18,
|
|
3357
|
+
children: t19
|
|
3358
|
+
});
|
|
3359
|
+
$[45] = t18;
|
|
3360
|
+
$[46] = t20;
|
|
3361
|
+
} else t20 = $[46];
|
|
3362
|
+
let t21;
|
|
3363
|
+
if ($[47] !== t) {
|
|
3364
|
+
t21 = /* @__PURE__ */ jsx(Pagination.PageText, { format: (t22) => {
|
|
3365
|
+
const { page: current, totalPages } = t22;
|
|
3366
|
+
return t("ledger.summary", {
|
|
3367
|
+
page: current,
|
|
3368
|
+
totalPages
|
|
3369
|
+
});
|
|
3370
|
+
} });
|
|
3371
|
+
$[47] = t;
|
|
3372
|
+
$[48] = t21;
|
|
3373
|
+
} else t21 = $[48];
|
|
3374
|
+
let t22;
|
|
3375
|
+
if ($[49] !== t) {
|
|
3376
|
+
t22 = t("ledger.next");
|
|
3377
|
+
$[49] = t;
|
|
3378
|
+
$[50] = t22;
|
|
3379
|
+
} else t22 = $[50];
|
|
3380
|
+
let t23;
|
|
3381
|
+
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3382
|
+
t23 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
|
|
3383
|
+
$[51] = t23;
|
|
3384
|
+
} else t23 = $[51];
|
|
3385
|
+
let t24;
|
|
3386
|
+
if ($[52] !== t22) {
|
|
3387
|
+
t24 = /* @__PURE__ */ jsx(Pagination.NextTrigger, {
|
|
3388
|
+
label: t22,
|
|
3389
|
+
children: t23
|
|
3390
|
+
});
|
|
3391
|
+
$[52] = t22;
|
|
3392
|
+
$[53] = t24;
|
|
3393
|
+
} else t24 = $[53];
|
|
3394
|
+
let t25;
|
|
3395
|
+
if ($[54] !== t17 || $[55] !== t20 || $[56] !== t21 || $[57] !== t24) {
|
|
3396
|
+
t25 = /* @__PURE__ */ jsxs(TablePagination, {
|
|
3397
|
+
"aria-label": t17,
|
|
3398
|
+
size: "sm",
|
|
3399
|
+
children: [
|
|
3400
|
+
t20,
|
|
3401
|
+
t21,
|
|
3402
|
+
t24
|
|
3403
|
+
]
|
|
3404
|
+
});
|
|
3405
|
+
$[54] = t17;
|
|
3406
|
+
$[55] = t20;
|
|
3407
|
+
$[56] = t21;
|
|
3408
|
+
$[57] = t24;
|
|
3409
|
+
$[58] = t25;
|
|
3410
|
+
} else t25 = $[58];
|
|
3411
|
+
let t26;
|
|
3412
|
+
if ($[59] !== t12 || $[60] !== t16 || $[61] !== t25 || $[62] !== table) {
|
|
3413
|
+
t26 = /* @__PURE__ */ jsxs(Root, {
|
|
3414
|
+
table,
|
|
3415
|
+
children: [
|
|
3416
|
+
t12,
|
|
3417
|
+
t16,
|
|
3418
|
+
t25
|
|
3419
|
+
]
|
|
3420
|
+
});
|
|
3421
|
+
$[59] = t12;
|
|
3422
|
+
$[60] = t16;
|
|
3423
|
+
$[61] = t25;
|
|
3424
|
+
$[62] = table;
|
|
3425
|
+
$[63] = t26;
|
|
3426
|
+
} else t26 = $[63];
|
|
3427
|
+
return t26;
|
|
3428
|
+
}
|
|
3429
|
+
function _temp3$2(old) {
|
|
3430
|
+
return {
|
|
3431
|
+
...old,
|
|
3432
|
+
pageIndex: 0
|
|
3433
|
+
};
|
|
3434
|
+
}
|
|
3435
|
+
function _temp2$5(row) {
|
|
3436
|
+
return row.reference;
|
|
3437
|
+
}
|
|
3438
|
+
function _temp$5(cell) {
|
|
3439
|
+
return amountOf$5(cell.getValue());
|
|
3440
|
+
}
|
|
3441
|
+
const source$5 = "import { type ReactElement, useState } from \"react\";\n\nimport { ArrowUpIcon, ChevronLeftIcon, ChevronRightIcon, SearchIcon, XIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { Pagination } from \"@stealthscale/component-navigation\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { useServerPage } from \"./server.ts\";\nimport { type Transfer } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Server(): ReactElement {\n const { t } = useWords(\"data-table\");\n const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 8 });\n const [sorting, setSorting] = useState<DataTable.SortingState>([]);\n const [search, setSearch] = useState(\"\");\n const { loading, page } = useServerPage({ ...pagination, search, sort: sorting[0] });\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"reference\", {\n enableSorting: false,\n header: t(\"ledger.reference\"),\n meta: { rowHeader: true },\n }),\n column.accessor((transfer) => t(transfer.account), {\n enableSorting: false,\n header: t(\"account\"),\n id: \"account\",\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: page.rows,\n getRowId: (row) => row.reference,\n manualFiltering: true,\n manualPagination: true,\n manualSorting: true,\n onGlobalFilterChange: (next: string) => {\n setSearch(next);\n setPagination((old) => ({ ...old, pageIndex: 0 }));\n },\n onPaginationChange: setPagination,\n onSortingChange: setSorting,\n rowCount: page.count,\n state: { globalFilter: search, pagination, sorting },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Search\n aria-label={t(\"server.search\")}\n clearIndicator={<XIcon size=\"1em\" />}\n clearLabel={t(\"search.clear\")}\n placeholder={t(\"server.search\")}\n searchIndicator={<SearchIcon size=\"1em\" />}\n />\n <DataTable.Table\n aria-busy={loading}\n caption={t(\"server.caption\")}\n empty={loading ? t(\"server.loading\") : t(\"server.empty\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n <DataTable.Pagination aria-label={t(\"ledger.pages\")} size=\"sm\">\n <Pagination.PrevTrigger label={t(\"ledger.previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.PageText\n format={({ page: current, totalPages }) =>\n t(\"ledger.summary\", { page: current, totalPages })\n }\n />\n <Pagination.NextTrigger label={t(\"ledger.next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </DataTable.Pagination>\n </DataTable.Root>\n );\n}\n";
|
|
3442
|
+
//#endregion
|
|
3443
|
+
//#region src/data-table/examples/sorting.example.tsx
|
|
3444
|
+
var sorting_example_exports = /* @__PURE__ */ __exportAll({
|
|
3445
|
+
Sorting: () => Sorting,
|
|
3446
|
+
source: () => source$4
|
|
3447
|
+
});
|
|
3448
|
+
const column$4 = createColumnHelper();
|
|
3449
|
+
const EURO$4 = {
|
|
3450
|
+
currency: "EUR",
|
|
3451
|
+
style: "currency"
|
|
3452
|
+
};
|
|
3453
|
+
function amountOf$4(value) {
|
|
3454
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3455
|
+
options: EURO$4,
|
|
3456
|
+
value
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
function Sorting() {
|
|
3460
|
+
const $ = c(12);
|
|
3461
|
+
const { t } = useWords("data-table");
|
|
3462
|
+
let t0;
|
|
3463
|
+
if ($[0] !== t) {
|
|
3464
|
+
t0 = column$4.columns([
|
|
3465
|
+
column$4.accessor("account", {
|
|
3466
|
+
cell: (cell) => t(cell.getValue()),
|
|
3467
|
+
header: t("account"),
|
|
3468
|
+
meta: { rowHeader: true }
|
|
3469
|
+
}),
|
|
3470
|
+
column$4.accessor("transfers", {
|
|
3471
|
+
header: t("transfers"),
|
|
3472
|
+
meta: { numeric: true }
|
|
3473
|
+
}),
|
|
3474
|
+
column$4.accessor("amount", {
|
|
3475
|
+
cell: _temp$4,
|
|
3476
|
+
header: t("amount"),
|
|
3477
|
+
meta: { numeric: true }
|
|
3478
|
+
})
|
|
3479
|
+
]);
|
|
3480
|
+
$[0] = t;
|
|
3481
|
+
$[1] = t0;
|
|
3482
|
+
} else t0 = $[1];
|
|
3483
|
+
let t1;
|
|
3484
|
+
if ($[2] !== t0) {
|
|
3485
|
+
t1 = {
|
|
3486
|
+
columns: t0,
|
|
3487
|
+
data: PAYOUTS,
|
|
3488
|
+
getRowId: _temp2$4
|
|
3489
|
+
};
|
|
3490
|
+
$[2] = t0;
|
|
3491
|
+
$[3] = t1;
|
|
3492
|
+
} else t1 = $[3];
|
|
3493
|
+
const table = useDataTable(t1);
|
|
3494
|
+
let t2;
|
|
3495
|
+
if ($[4] !== t) {
|
|
3496
|
+
t2 = t("sorting.caption");
|
|
3497
|
+
$[4] = t;
|
|
3498
|
+
$[5] = t2;
|
|
3499
|
+
} else t2 = $[5];
|
|
3500
|
+
let t3;
|
|
3501
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3502
|
+
t3 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
3503
|
+
$[6] = t3;
|
|
3504
|
+
} else t3 = $[6];
|
|
3505
|
+
let t4;
|
|
3506
|
+
if ($[7] !== t2) {
|
|
3507
|
+
t4 = /* @__PURE__ */ jsx(Table$1, {
|
|
3508
|
+
caption: t2,
|
|
3509
|
+
sortIndicator: t3,
|
|
3510
|
+
variant: "surface"
|
|
3511
|
+
});
|
|
3512
|
+
$[7] = t2;
|
|
3513
|
+
$[8] = t4;
|
|
3514
|
+
} else t4 = $[8];
|
|
3515
|
+
let t5;
|
|
3516
|
+
if ($[9] !== t4 || $[10] !== table) {
|
|
3517
|
+
t5 = /* @__PURE__ */ jsx(Root, {
|
|
3518
|
+
table,
|
|
3519
|
+
children: t4
|
|
3520
|
+
});
|
|
3521
|
+
$[9] = t4;
|
|
3522
|
+
$[10] = table;
|
|
3523
|
+
$[11] = t5;
|
|
3524
|
+
} else t5 = $[11];
|
|
3525
|
+
return t5;
|
|
3526
|
+
}
|
|
3527
|
+
function _temp2$4(row) {
|
|
3528
|
+
return row.account;
|
|
3529
|
+
}
|
|
3530
|
+
function _temp$4(cell_0) {
|
|
3531
|
+
return amountOf$4(cell_0.getValue());
|
|
3532
|
+
}
|
|
3533
|
+
const source$4 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Sorting(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"transfers\", { header: t(\"transfers\"), meta: { numeric: true } }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"sorting.caption\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
3534
|
+
//#endregion
|
|
3535
|
+
//#region src/data-table/examples/spanned.example.tsx
|
|
3536
|
+
var spanned_example_exports = /* @__PURE__ */ __exportAll({
|
|
3537
|
+
Spanned: () => Spanned,
|
|
3538
|
+
source: () => source$3
|
|
3539
|
+
});
|
|
3540
|
+
const column$3 = createColumnHelper();
|
|
3541
|
+
const EURO$3 = {
|
|
3542
|
+
currency: "EUR",
|
|
3543
|
+
style: "currency"
|
|
3544
|
+
};
|
|
3545
|
+
function amountOf$3(value) {
|
|
3546
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3547
|
+
options: EURO$3,
|
|
3548
|
+
value
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
function Spanned() {
|
|
3552
|
+
const $ = c(13);
|
|
3553
|
+
const { t } = useWords("data-table");
|
|
3554
|
+
let t0;
|
|
3555
|
+
if ($[0] !== t) {
|
|
3556
|
+
t0 = column$3.columns([
|
|
3557
|
+
column$3.accessor("region", {
|
|
3558
|
+
cell: (cell) => t(cell.getValue()),
|
|
3559
|
+
header: t("spanned.region"),
|
|
3560
|
+
meta: { rowHeader: true },
|
|
3561
|
+
spanRows: true
|
|
3562
|
+
}),
|
|
3563
|
+
column$3.accessor("account", {
|
|
3564
|
+
cell: (cell_0) => t(cell_0.getValue()),
|
|
3565
|
+
header: t("account"),
|
|
3566
|
+
meta: { rowHeader: true }
|
|
3567
|
+
}),
|
|
3568
|
+
column$3.accessor("amount", {
|
|
3569
|
+
cell: _temp$3,
|
|
3570
|
+
header: t("amount"),
|
|
3571
|
+
meta: { numeric: true }
|
|
3572
|
+
})
|
|
3573
|
+
]);
|
|
3574
|
+
$[0] = t;
|
|
3575
|
+
$[1] = t0;
|
|
3576
|
+
} else t0 = $[1];
|
|
3577
|
+
let t1;
|
|
3578
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3579
|
+
t1 = { sorting: [{
|
|
3580
|
+
desc: false,
|
|
3581
|
+
id: "region"
|
|
3582
|
+
}] };
|
|
3583
|
+
$[2] = t1;
|
|
3584
|
+
} else t1 = $[2];
|
|
3585
|
+
let t2;
|
|
3586
|
+
if ($[3] !== t0) {
|
|
3587
|
+
t2 = {
|
|
3588
|
+
columns: t0,
|
|
3589
|
+
data: PAYOUTS,
|
|
3590
|
+
getRowId: _temp2$3,
|
|
3591
|
+
initialState: t1
|
|
3592
|
+
};
|
|
3593
|
+
$[3] = t0;
|
|
3594
|
+
$[4] = t2;
|
|
3595
|
+
} else t2 = $[4];
|
|
3596
|
+
const table = useDataTable(t2);
|
|
3597
|
+
let t3;
|
|
3598
|
+
if ($[5] !== t) {
|
|
3599
|
+
t3 = t("spanned.caption");
|
|
3600
|
+
$[5] = t;
|
|
3601
|
+
$[6] = t3;
|
|
3602
|
+
} else t3 = $[6];
|
|
3603
|
+
let t4;
|
|
3604
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3605
|
+
t4 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
3606
|
+
$[7] = t4;
|
|
3607
|
+
} else t4 = $[7];
|
|
3608
|
+
let t5;
|
|
3609
|
+
if ($[8] !== t3) {
|
|
3610
|
+
t5 = /* @__PURE__ */ jsx(Table$1, {
|
|
3611
|
+
caption: t3,
|
|
3612
|
+
sortIndicator: t4,
|
|
3613
|
+
variant: "surface"
|
|
3614
|
+
});
|
|
3615
|
+
$[8] = t3;
|
|
3616
|
+
$[9] = t5;
|
|
3617
|
+
} else t5 = $[9];
|
|
3618
|
+
let t6;
|
|
3619
|
+
if ($[10] !== t5 || $[11] !== table) {
|
|
3620
|
+
t6 = /* @__PURE__ */ jsx(Root, {
|
|
3621
|
+
table,
|
|
3622
|
+
children: t5
|
|
3623
|
+
});
|
|
3624
|
+
$[10] = t5;
|
|
3625
|
+
$[11] = table;
|
|
3626
|
+
$[12] = t6;
|
|
3627
|
+
} else t6 = $[12];
|
|
3628
|
+
return t6;
|
|
3629
|
+
}
|
|
3630
|
+
function _temp2$3(row) {
|
|
3631
|
+
return row.account;
|
|
3632
|
+
}
|
|
3633
|
+
function _temp$3(cell_1) {
|
|
3634
|
+
return amountOf$3(cell_1.getValue());
|
|
3635
|
+
}
|
|
3636
|
+
const source$3 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Spanned(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"region\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"spanned.region\"),\n meta: { rowHeader: true },\n spanRows: true,\n }),\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n initialState: { sorting: [{ desc: false, id: \"region\" }] },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"spanned.caption\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
3637
|
+
//#endregion
|
|
3638
|
+
//#region src/data-table/examples/totals.example.tsx
|
|
3639
|
+
var totals_example_exports = /* @__PURE__ */ __exportAll({
|
|
3640
|
+
Totals: () => Totals,
|
|
3641
|
+
source: () => source$2
|
|
3642
|
+
});
|
|
3643
|
+
const column$2 = createColumnHelper();
|
|
3644
|
+
const EURO$2 = {
|
|
3645
|
+
currency: "EUR",
|
|
3646
|
+
style: "currency"
|
|
3647
|
+
};
|
|
3648
|
+
function amountOf$2(value) {
|
|
3649
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3650
|
+
options: EURO$2,
|
|
3651
|
+
value
|
|
3652
|
+
});
|
|
3653
|
+
}
|
|
3654
|
+
function Totals() {
|
|
3655
|
+
const $ = c(11);
|
|
3656
|
+
const { t } = useWords("data-table");
|
|
3657
|
+
let t0;
|
|
3658
|
+
if ($[0] !== t) {
|
|
3659
|
+
t0 = column$2.columns([
|
|
3660
|
+
column$2.accessor("account", {
|
|
3661
|
+
cell: (cell) => t(cell.getValue()),
|
|
3662
|
+
footer: t("totals.total"),
|
|
3663
|
+
header: t("account"),
|
|
3664
|
+
meta: { rowHeader: true }
|
|
3665
|
+
}),
|
|
3666
|
+
column$2.accessor("transfers", {
|
|
3667
|
+
aggregationFn: "sum",
|
|
3668
|
+
footer: _temp$2,
|
|
3669
|
+
header: t("transfers"),
|
|
3670
|
+
meta: { numeric: true }
|
|
3671
|
+
}),
|
|
3672
|
+
column$2.accessor("amount", {
|
|
3673
|
+
aggregationFn: "sum",
|
|
3674
|
+
cell: _temp2$2,
|
|
3675
|
+
footer: _temp3$1,
|
|
3676
|
+
header: t("amount"),
|
|
3677
|
+
meta: { numeric: true }
|
|
3678
|
+
})
|
|
3679
|
+
]);
|
|
3680
|
+
$[0] = t;
|
|
3681
|
+
$[1] = t0;
|
|
3682
|
+
} else t0 = $[1];
|
|
3683
|
+
let t1;
|
|
3684
|
+
if ($[2] !== t0) {
|
|
3685
|
+
t1 = {
|
|
3686
|
+
columns: t0,
|
|
3687
|
+
data: PAYOUTS,
|
|
3688
|
+
getRowId: _temp4$1
|
|
3689
|
+
};
|
|
3690
|
+
$[2] = t0;
|
|
3691
|
+
$[3] = t1;
|
|
3692
|
+
} else t1 = $[3];
|
|
3693
|
+
const table = useDataTable(t1);
|
|
3694
|
+
let t2;
|
|
3695
|
+
if ($[4] !== t) {
|
|
3696
|
+
t2 = t("totals.caption");
|
|
3697
|
+
$[4] = t;
|
|
3698
|
+
$[5] = t2;
|
|
3699
|
+
} else t2 = $[5];
|
|
3700
|
+
let t3;
|
|
3701
|
+
if ($[6] !== t2) {
|
|
3702
|
+
t3 = /* @__PURE__ */ jsx(Table$1, {
|
|
3703
|
+
caption: t2,
|
|
3704
|
+
variant: "surface"
|
|
3705
|
+
});
|
|
3706
|
+
$[6] = t2;
|
|
3707
|
+
$[7] = t3;
|
|
3708
|
+
} else t3 = $[7];
|
|
3709
|
+
let t4;
|
|
3710
|
+
if ($[8] !== t3 || $[9] !== table) {
|
|
3711
|
+
t4 = /* @__PURE__ */ jsx(Root, {
|
|
3712
|
+
table,
|
|
3713
|
+
children: t3
|
|
3714
|
+
});
|
|
3715
|
+
$[8] = t3;
|
|
3716
|
+
$[9] = table;
|
|
3717
|
+
$[10] = t4;
|
|
3718
|
+
} else t4 = $[10];
|
|
3719
|
+
return t4;
|
|
3720
|
+
}
|
|
3721
|
+
function _temp4$1(row) {
|
|
3722
|
+
return row.account;
|
|
3723
|
+
}
|
|
3724
|
+
function _temp3$1(footer_0) {
|
|
3725
|
+
return amountOf$2(footer_0.column.getAggregationValue());
|
|
3726
|
+
}
|
|
3727
|
+
function _temp2$2(cell_0) {
|
|
3728
|
+
return amountOf$2(cell_0.getValue());
|
|
3729
|
+
}
|
|
3730
|
+
function _temp$2(footer) {
|
|
3731
|
+
return footer.column.getAggregationValue();
|
|
3732
|
+
}
|
|
3733
|
+
const source$2 = "import { type ReactElement } from \"react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Payout, PAYOUTS } from \"./payouts.ts\";\n\nconst column = DataTable.createColumnHelper<Payout>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Totals(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor(\"account\", {\n cell: (cell) => t(cell.getValue()),\n footer: t(\"totals.total\"),\n header: t(\"account\"),\n meta: { rowHeader: true },\n }),\n column.accessor(\"transfers\", {\n aggregationFn: \"sum\",\n footer: (footer) => footer.column.getAggregationValue<number>(),\n header: t(\"transfers\"),\n meta: { numeric: true },\n }),\n column.accessor(\"amount\", {\n aggregationFn: \"sum\",\n cell: (cell) => amountOf(cell.getValue()),\n footer: (footer) => amountOf(footer.column.getAggregationValue<number>()),\n header: t(\"amount\"),\n meta: { numeric: true },\n }),\n ]),\n data: PAYOUTS,\n getRowId: (row) => row.account,\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table caption={t(\"totals.caption\")} variant=\"surface\" />\n </DataTable.Root>\n );\n}\n";
|
|
3734
|
+
//#endregion
|
|
3735
|
+
//#region src/data-table/examples/budgets.ts
|
|
3736
|
+
/**
|
|
3737
|
+
* Returns a team's cost centre.
|
|
3738
|
+
*/
|
|
3739
|
+
function team(centre, budget, spent) {
|
|
3740
|
+
return {
|
|
3741
|
+
budget,
|
|
3742
|
+
centre,
|
|
3743
|
+
spent
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
/**
|
|
3747
|
+
* Returns a department's cost centre, whose figures are its teams' together.
|
|
3748
|
+
*/
|
|
3749
|
+
function department(centre, teams) {
|
|
3750
|
+
return {
|
|
3751
|
+
budget: teams.reduce((sum, each) => sum + each.budget, 0),
|
|
3752
|
+
centre,
|
|
3753
|
+
spent: teams.reduce((sum, each) => sum + each.spent, 0),
|
|
3754
|
+
teams
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
/**
|
|
3758
|
+
* Lists the quarter's cost centres, the departments first.
|
|
3759
|
+
*/
|
|
3760
|
+
const BUDGETS = [
|
|
3761
|
+
department("engineering", [
|
|
3762
|
+
department("platform", [team("infrastructure", 42e4, 391200), team("tooling", 18e4, 142500)]),
|
|
3763
|
+
team("payments", 36e4, 348900),
|
|
3764
|
+
team("mobile", 24e4, 251300)
|
|
3765
|
+
]),
|
|
3766
|
+
department("sales", [team("enterprise", 31e4, 287400), team("partners", 15e4, 96800)]),
|
|
3767
|
+
department("marketing", [team("brand", 12e4, 131600), team("growth", 2e5, 177900)]),
|
|
3768
|
+
team("operations", 14e4, 118200)
|
|
3769
|
+
];
|
|
3770
|
+
//#endregion
|
|
3771
|
+
//#region src/data-table/examples/tree.example.tsx
|
|
3772
|
+
var tree_example_exports = /* @__PURE__ */ __exportAll({
|
|
3773
|
+
Tree: () => Tree,
|
|
3774
|
+
source: () => source$1
|
|
3775
|
+
});
|
|
3776
|
+
const column$1 = createColumnHelper();
|
|
3777
|
+
const EURO$1 = {
|
|
3778
|
+
currency: "EUR",
|
|
3779
|
+
maximumFractionDigits: 0,
|
|
3780
|
+
style: "currency"
|
|
3781
|
+
};
|
|
3782
|
+
function amountOf$1(value) {
|
|
3783
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3784
|
+
options: EURO$1,
|
|
3785
|
+
value
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3788
|
+
function Tree() {
|
|
3789
|
+
const $ = c(20);
|
|
3790
|
+
const { t } = useWords("data-table");
|
|
3791
|
+
let t0;
|
|
3792
|
+
if ($[0] !== t) {
|
|
3793
|
+
t0 = column$1.columns([
|
|
3794
|
+
column$1.accessor((budget) => t(`tree.${budget.centre}`), {
|
|
3795
|
+
header: t("tree.centre"),
|
|
3796
|
+
id: "centre",
|
|
3797
|
+
meta: { rowHeader: true }
|
|
3798
|
+
}),
|
|
3799
|
+
column$1.accessor("budget", {
|
|
3800
|
+
cell: _temp$1,
|
|
3801
|
+
header: t("tree.budget"),
|
|
3802
|
+
meta: { numeric: true }
|
|
3803
|
+
}),
|
|
3804
|
+
column$1.accessor("spent", {
|
|
3805
|
+
cell: _temp2$1,
|
|
3806
|
+
header: t("tree.spent"),
|
|
3807
|
+
meta: { numeric: true }
|
|
3808
|
+
})
|
|
3809
|
+
]);
|
|
3810
|
+
$[0] = t;
|
|
3811
|
+
$[1] = t0;
|
|
3812
|
+
} else t0 = $[1];
|
|
3813
|
+
let t1;
|
|
3814
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3815
|
+
t1 = { expanded: { engineering: true } };
|
|
3816
|
+
$[2] = t1;
|
|
3817
|
+
} else t1 = $[2];
|
|
3818
|
+
let t2;
|
|
3819
|
+
if ($[3] !== t0) {
|
|
3820
|
+
t2 = {
|
|
3821
|
+
columns: t0,
|
|
3822
|
+
data: BUDGETS,
|
|
3823
|
+
getRowId: _temp3,
|
|
3824
|
+
getSubRows: _temp4,
|
|
3825
|
+
initialState: t1
|
|
3826
|
+
};
|
|
3827
|
+
$[3] = t0;
|
|
3828
|
+
$[4] = t2;
|
|
3829
|
+
} else t2 = $[4];
|
|
3830
|
+
const table = useDataTable(t2);
|
|
3831
|
+
let t3;
|
|
3832
|
+
if ($[5] !== t) {
|
|
3833
|
+
t3 = t("tree.caption");
|
|
3834
|
+
$[5] = t;
|
|
3835
|
+
$[6] = t3;
|
|
3836
|
+
} else t3 = $[6];
|
|
3837
|
+
let t4;
|
|
3838
|
+
if ($[7] !== t) {
|
|
3839
|
+
t4 = t("tree.collapse");
|
|
3840
|
+
$[7] = t;
|
|
3841
|
+
$[8] = t4;
|
|
3842
|
+
} else t4 = $[8];
|
|
3843
|
+
let t5;
|
|
3844
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3845
|
+
t5 = /* @__PURE__ */ jsx(ChevronRightIcon, { size: "1em" });
|
|
3846
|
+
$[9] = t5;
|
|
3847
|
+
} else t5 = $[9];
|
|
3848
|
+
let t6;
|
|
3849
|
+
if ($[10] !== t) {
|
|
3850
|
+
t6 = t("tree.expand");
|
|
3851
|
+
$[10] = t;
|
|
3852
|
+
$[11] = t6;
|
|
3853
|
+
} else t6 = $[11];
|
|
3854
|
+
let t7;
|
|
3855
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3856
|
+
t7 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
3857
|
+
$[12] = t7;
|
|
3858
|
+
} else t7 = $[12];
|
|
3859
|
+
let t8;
|
|
3860
|
+
if ($[13] !== t3 || $[14] !== t4 || $[15] !== t6) {
|
|
3861
|
+
t8 = /* @__PURE__ */ jsx(Table$1, {
|
|
3862
|
+
caption: t3,
|
|
3863
|
+
collapseLabel: t4,
|
|
3864
|
+
expandIndicator: t5,
|
|
3865
|
+
expandLabel: t6,
|
|
3866
|
+
sortIndicator: t7,
|
|
3867
|
+
variant: "surface"
|
|
3868
|
+
});
|
|
3869
|
+
$[13] = t3;
|
|
3870
|
+
$[14] = t4;
|
|
3871
|
+
$[15] = t6;
|
|
3872
|
+
$[16] = t8;
|
|
3873
|
+
} else t8 = $[16];
|
|
3874
|
+
let t9;
|
|
3875
|
+
if ($[17] !== t8 || $[18] !== table) {
|
|
3876
|
+
t9 = /* @__PURE__ */ jsx(Root, {
|
|
3877
|
+
table,
|
|
3878
|
+
children: t8
|
|
3879
|
+
});
|
|
3880
|
+
$[17] = t8;
|
|
3881
|
+
$[18] = table;
|
|
3882
|
+
$[19] = t9;
|
|
3883
|
+
} else t9 = $[19];
|
|
3884
|
+
return t9;
|
|
3885
|
+
}
|
|
3886
|
+
function _temp4(budget_1) {
|
|
3887
|
+
return budget_1.teams;
|
|
3888
|
+
}
|
|
3889
|
+
function _temp3(budget_0) {
|
|
3890
|
+
return budget_0.centre;
|
|
3891
|
+
}
|
|
3892
|
+
function _temp2$1(cell_0) {
|
|
3893
|
+
return amountOf$1(cell_0.getValue());
|
|
3894
|
+
}
|
|
3895
|
+
function _temp$1(cell) {
|
|
3896
|
+
return amountOf$1(cell.getValue());
|
|
3897
|
+
}
|
|
3898
|
+
const source$1 = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Budget, BUDGETS } from \"./budgets.ts\";\n\nconst column = DataTable.createColumnHelper<Budget>();\n\nconst EURO = { currency: \"EUR\", maximumFractionDigits: 0, style: \"currency\" } as const;\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Tree(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n column.accessor((budget) => t(`tree.${budget.centre}`), {\n header: t(\"tree.centre\"),\n id: \"centre\",\n meta: { rowHeader: true },\n }),\n column.accessor(\"budget\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"tree.budget\"),\n meta: { numeric: true },\n }),\n column.accessor(\"spent\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"tree.spent\"),\n meta: { numeric: true },\n }),\n ]),\n data: BUDGETS,\n getRowId: (budget) => budget.centre,\n getSubRows: (budget) => budget.teams,\n initialState: { expanded: { engineering: true } },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"tree.caption\")}\n collapseLabel={t(\"tree.collapse\")}\n expandIndicator={<ChevronRightIcon size=\"1em\" />}\n expandLabel={t(\"tree.expand\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n variant=\"surface\"\n />\n </DataTable.Root>\n );\n}\n";
|
|
3899
|
+
//#endregion
|
|
3900
|
+
//#region src/data-table/examples/windowed.example.tsx
|
|
3901
|
+
var windowed_example_exports = /* @__PURE__ */ __exportAll({
|
|
3902
|
+
Windowed: () => Windowed,
|
|
3903
|
+
source: () => source
|
|
3904
|
+
});
|
|
3905
|
+
const column = createColumnHelper();
|
|
3906
|
+
const EURO = {
|
|
3907
|
+
currency: "EUR",
|
|
3908
|
+
style: "currency"
|
|
3909
|
+
};
|
|
3910
|
+
const YEAR = transfersOf(1e4, 2e4);
|
|
3911
|
+
function amountOf(value) {
|
|
3912
|
+
return /* @__PURE__ */ jsx(Format.Number, {
|
|
3913
|
+
options: EURO,
|
|
3914
|
+
value
|
|
3915
|
+
});
|
|
3916
|
+
}
|
|
3917
|
+
function Windowed() {
|
|
3918
|
+
const $ = c(15);
|
|
3919
|
+
const { t } = useWords("data-table");
|
|
3920
|
+
let t0;
|
|
3921
|
+
if ($[0] !== t) {
|
|
3922
|
+
let t1;
|
|
3923
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3924
|
+
t1 = /* @__PURE__ */ jsx(PinIcon, { size: "1em" });
|
|
3925
|
+
$[2] = t1;
|
|
3926
|
+
} else t1 = $[2];
|
|
3927
|
+
t0 = column.columns([
|
|
3928
|
+
pinColumn({
|
|
3929
|
+
header: t("pinned.header"),
|
|
3930
|
+
indicator: t1,
|
|
3931
|
+
label: (transfer) => t("windowed.pin", { reference: transfer.reference })
|
|
3932
|
+
}),
|
|
3933
|
+
column.accessor("reference", {
|
|
3934
|
+
header: t("ledger.reference"),
|
|
3935
|
+
meta: { rowHeader: true },
|
|
3936
|
+
size: 150
|
|
3937
|
+
}),
|
|
3938
|
+
column.accessor((transfer_0) => t(transfer_0.account), {
|
|
3939
|
+
header: t("account"),
|
|
3940
|
+
id: "account",
|
|
3941
|
+
size: 230
|
|
3942
|
+
}),
|
|
3943
|
+
column.accessor((transfer_1) => t(`ledger.${transfer_1.state}`), {
|
|
3944
|
+
header: t("ledger.state"),
|
|
3945
|
+
id: "state",
|
|
3946
|
+
size: 140
|
|
3947
|
+
}),
|
|
3948
|
+
column.accessor("amount", {
|
|
3949
|
+
cell: _temp,
|
|
3950
|
+
header: t("amount"),
|
|
3951
|
+
meta: { numeric: true },
|
|
3952
|
+
size: 176
|
|
3953
|
+
})
|
|
3954
|
+
]);
|
|
3955
|
+
$[0] = t;
|
|
3956
|
+
$[1] = t0;
|
|
3957
|
+
} else t0 = $[1];
|
|
3958
|
+
let t1;
|
|
3959
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3960
|
+
t1 = { rowPinning: {
|
|
3961
|
+
bottom: [],
|
|
3962
|
+
top: ["TR-19996"]
|
|
3963
|
+
} };
|
|
3964
|
+
$[3] = t1;
|
|
3965
|
+
} else t1 = $[3];
|
|
3966
|
+
let t2;
|
|
3967
|
+
if ($[4] !== t0) {
|
|
3968
|
+
t2 = {
|
|
3969
|
+
columns: t0,
|
|
3970
|
+
data: YEAR,
|
|
3971
|
+
getRowId: _temp2,
|
|
3972
|
+
initialState: t1
|
|
3973
|
+
};
|
|
3974
|
+
$[4] = t0;
|
|
3975
|
+
$[5] = t2;
|
|
3976
|
+
} else t2 = $[5];
|
|
3977
|
+
const table = useDataTable(t2);
|
|
3978
|
+
let t3;
|
|
3979
|
+
if ($[6] !== t) {
|
|
3980
|
+
t3 = t("windowed.caption");
|
|
3981
|
+
$[6] = t;
|
|
3982
|
+
$[7] = t3;
|
|
3983
|
+
} else t3 = $[7];
|
|
3984
|
+
let t4;
|
|
3985
|
+
let t5;
|
|
3986
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
3987
|
+
t4 = /* @__PURE__ */ jsx(ArrowUpIcon, { size: "1em" });
|
|
3988
|
+
t5 = { maxBlockSize: "24rem" };
|
|
3989
|
+
$[8] = t4;
|
|
3990
|
+
$[9] = t5;
|
|
3991
|
+
} else {
|
|
3992
|
+
t4 = $[8];
|
|
3993
|
+
t5 = $[9];
|
|
3994
|
+
}
|
|
3995
|
+
let t6;
|
|
3996
|
+
if ($[10] !== t3) {
|
|
3997
|
+
t6 = /* @__PURE__ */ jsx(Table$1, {
|
|
3998
|
+
caption: t3,
|
|
3999
|
+
sortIndicator: t4,
|
|
4000
|
+
style: t5,
|
|
4001
|
+
variant: "surface",
|
|
4002
|
+
windowed: true
|
|
4003
|
+
});
|
|
4004
|
+
$[10] = t3;
|
|
4005
|
+
$[11] = t6;
|
|
4006
|
+
} else t6 = $[11];
|
|
4007
|
+
let t7;
|
|
4008
|
+
if ($[12] !== t6 || $[13] !== table) {
|
|
4009
|
+
t7 = /* @__PURE__ */ jsx(Root, {
|
|
4010
|
+
table,
|
|
4011
|
+
children: t6
|
|
4012
|
+
});
|
|
4013
|
+
$[12] = t6;
|
|
4014
|
+
$[13] = table;
|
|
4015
|
+
$[14] = t7;
|
|
4016
|
+
} else t7 = $[14];
|
|
4017
|
+
return t7;
|
|
4018
|
+
}
|
|
4019
|
+
function _temp2(row) {
|
|
4020
|
+
return row.reference;
|
|
4021
|
+
}
|
|
4022
|
+
function _temp(cell) {
|
|
4023
|
+
return amountOf(cell.getValue());
|
|
4024
|
+
}
|
|
4025
|
+
const source = "import { type ReactElement } from \"react\";\n\nimport { ArrowUpIcon, PinIcon } from \"lucide-react\";\n\nimport { Format } from \"@stealthscale/component-data\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { DataTable } from \"@stealthscale/component-tables\";\n\nimport { type Transfer, transfersOf } from \"./transfers.ts\";\n\nconst column = DataTable.createColumnHelper<Transfer>();\n\nconst EURO = { currency: \"EUR\", style: \"currency\" } as const;\n\nconst YEAR = transfersOf(10_000, 20_000);\n\nfunction amountOf(value: number): ReactElement {\n return <Format.Number options={EURO} value={value} />;\n}\n\nexport function Windowed(): ReactElement {\n const { t } = useWords(\"data-table\");\n const table = DataTable.useDataTable({\n columns: column.columns([\n DataTable.pinColumn<Transfer>({\n header: t(\"pinned.header\"),\n indicator: <PinIcon size=\"1em\" />,\n label: (transfer) => t(\"windowed.pin\", { reference: transfer.reference }),\n }),\n column.accessor(\"reference\", {\n header: t(\"ledger.reference\"),\n meta: { rowHeader: true },\n size: 150,\n }),\n column.accessor((transfer) => t(transfer.account), {\n header: t(\"account\"),\n id: \"account\",\n size: 230,\n }),\n column.accessor((transfer) => t(`ledger.${transfer.state}`), {\n header: t(\"ledger.state\"),\n id: \"state\",\n size: 140,\n }),\n column.accessor(\"amount\", {\n cell: (cell) => amountOf(cell.getValue()),\n header: t(\"amount\"),\n meta: { numeric: true },\n size: 176,\n }),\n ]),\n data: YEAR,\n getRowId: (row) => row.reference,\n initialState: { rowPinning: { bottom: [], top: [\"TR-19996\"] } },\n });\n\n return (\n <DataTable.Root table={table}>\n <DataTable.Table\n caption={t(\"windowed.caption\")}\n sortIndicator={<ArrowUpIcon size=\"1em\" />}\n style={{ maxBlockSize: \"24rem\" }}\n variant=\"surface\"\n windowed\n />\n </DataTable.Root>\n );\n}\n";
|
|
4026
|
+
//#endregion
|
|
4027
|
+
//#region src/data-table/data-table.specimen.tsx
|
|
4028
|
+
/**
|
|
4029
|
+
* Catalogue page for the data table.
|
|
4030
|
+
*
|
|
4031
|
+
* @remarks
|
|
4032
|
+
* The recipe has no axis, so every scene is hand-written and renders at the page's width, the
|
|
4033
|
+
* room a table takes. The page imports its examples through their barrel, and the sorting
|
|
4034
|
+
* example directly, which the props reader follows to the kit's parts. The words are keys under
|
|
4035
|
+
* `data-table` in `locales/en/specimen/data-table.json`.
|
|
4036
|
+
*/
|
|
4037
|
+
/**
|
|
4038
|
+
* Names each example module a scene renders.
|
|
4039
|
+
*/
|
|
4040
|
+
const { aggregates, claims, columns, details, endless, filters, grid, grouped, lazy, manager, menus, pages, pinned, pivot, search, selection, server, spanned, totals, tree, windowed } = /* @__PURE__ */ __exportAll({
|
|
4041
|
+
aggregates: () => aggregates_example_exports,
|
|
4042
|
+
claims: () => claims_example_exports,
|
|
4043
|
+
columns: () => columns_example_exports,
|
|
4044
|
+
details: () => details_example_exports,
|
|
4045
|
+
endless: () => endless_example_exports,
|
|
4046
|
+
filters: () => filters_example_exports,
|
|
4047
|
+
grid: () => grid_example_exports,
|
|
4048
|
+
grouped: () => grouped_example_exports,
|
|
4049
|
+
lazy: () => lazy_example_exports,
|
|
4050
|
+
manager: () => manager_example_exports,
|
|
4051
|
+
menus: () => menus_example_exports,
|
|
4052
|
+
pages: () => pages_example_exports,
|
|
4053
|
+
pinned: () => pinned_example_exports,
|
|
4054
|
+
pivot: () => pivot_example_exports,
|
|
4055
|
+
search: () => search_example_exports,
|
|
4056
|
+
selection: () => selection_example_exports,
|
|
4057
|
+
server: () => server_example_exports,
|
|
4058
|
+
sorting: () => sorting_example_exports,
|
|
4059
|
+
spanned: () => spanned_example_exports,
|
|
4060
|
+
totals: () => totals_example_exports,
|
|
4061
|
+
tree: () => tree_example_exports,
|
|
4062
|
+
windowed: () => windowed_example_exports
|
|
4063
|
+
});
|
|
4064
|
+
/**
|
|
4065
|
+
* Hand-written scene for sorting from the column headers.
|
|
4066
|
+
*/
|
|
4067
|
+
const sorted = {
|
|
4068
|
+
about: "data-table.sorting.about",
|
|
4069
|
+
draw: () => /* @__PURE__ */ jsx(Sorting, {}),
|
|
4070
|
+
example: sorting_example_exports,
|
|
4071
|
+
title: "data-table.sorting.title"
|
|
4072
|
+
};
|
|
4073
|
+
/**
|
|
4074
|
+
* Hand-written scene for the search field over the table's rows.
|
|
4075
|
+
*/
|
|
4076
|
+
const searched = {
|
|
4077
|
+
about: "data-table.search.about",
|
|
4078
|
+
draw: () => /* @__PURE__ */ jsx(search.Searching, {}),
|
|
4079
|
+
example: search,
|
|
4080
|
+
title: "data-table.search.title"
|
|
4081
|
+
};
|
|
4082
|
+
/**
|
|
4083
|
+
* Hand-written scene for the filters in the columns' headers.
|
|
4084
|
+
*/
|
|
4085
|
+
const filtered = {
|
|
4086
|
+
about: "data-table.filters.about",
|
|
4087
|
+
draw: () => /* @__PURE__ */ jsx(filters.Filters, {}),
|
|
4088
|
+
example: filters,
|
|
4089
|
+
title: "data-table.filters.title"
|
|
4090
|
+
};
|
|
4091
|
+
/**
|
|
4092
|
+
* Hand-written scene for the menus in the columns' headers.
|
|
4093
|
+
*/
|
|
4094
|
+
const menued = {
|
|
4095
|
+
about: "data-table.menus.about",
|
|
4096
|
+
draw: () => /* @__PURE__ */ jsx(menus.Menus, {}),
|
|
4097
|
+
example: menus,
|
|
4098
|
+
title: "data-table.menus.title"
|
|
4099
|
+
};
|
|
4100
|
+
/**
|
|
4101
|
+
* Hand-written scene for the column manager in a popover.
|
|
4102
|
+
*/
|
|
4103
|
+
const managed = {
|
|
4104
|
+
about: "data-table.manager.about",
|
|
4105
|
+
draw: () => /* @__PURE__ */ jsx(manager.Manager, {}),
|
|
4106
|
+
example: manager,
|
|
4107
|
+
title: "data-table.manager.title"
|
|
4108
|
+
};
|
|
4109
|
+
/**
|
|
4110
|
+
* Hand-written scene for the pagination and the page size under the table.
|
|
4111
|
+
*/
|
|
4112
|
+
const paged = {
|
|
4113
|
+
about: "data-table.pages.about",
|
|
4114
|
+
draw: () => /* @__PURE__ */ jsx(pages.Pages, {}),
|
|
4115
|
+
example: pages,
|
|
4116
|
+
title: "data-table.pages.title"
|
|
4117
|
+
};
|
|
4118
|
+
/**
|
|
4119
|
+
* Hand-written scene for a table a server sorts, searches and pages.
|
|
4120
|
+
*/
|
|
4121
|
+
const served = {
|
|
4122
|
+
about: "data-table.server.about",
|
|
4123
|
+
draw: () => /* @__PURE__ */ jsx(server.Server, {}),
|
|
4124
|
+
example: server,
|
|
4125
|
+
title: "data-table.server.title"
|
|
4126
|
+
};
|
|
4127
|
+
/**
|
|
4128
|
+
* Hand-written scene for ten thousand rows of which the table renders those in view.
|
|
4129
|
+
*/
|
|
4130
|
+
const windowedRows = {
|
|
4131
|
+
about: "data-table.windowed.about",
|
|
4132
|
+
draw: () => /* @__PURE__ */ jsx(windowed.Windowed, {}),
|
|
4133
|
+
example: windowed,
|
|
4134
|
+
title: "data-table.windowed.title"
|
|
4135
|
+
};
|
|
4136
|
+
/**
|
|
4137
|
+
* Hand-written scene for rows a windowed table loads as its last row comes into view.
|
|
4138
|
+
*/
|
|
4139
|
+
const endlessRows = {
|
|
4140
|
+
about: "data-table.endless.about",
|
|
4141
|
+
draw: () => /* @__PURE__ */ jsx(endless.Endless, {}),
|
|
4142
|
+
example: endless,
|
|
4143
|
+
title: "data-table.endless.title"
|
|
4144
|
+
};
|
|
4145
|
+
/**
|
|
4146
|
+
* Hand-written scene for selecting rows with the select column.
|
|
4147
|
+
*/
|
|
4148
|
+
const selected = {
|
|
4149
|
+
about: "data-table.selection.about",
|
|
4150
|
+
draw: () => /* @__PURE__ */ jsx(selection.Selection, {}),
|
|
4151
|
+
example: selection,
|
|
4152
|
+
title: "data-table.selection.title"
|
|
4153
|
+
};
|
|
4154
|
+
/**
|
|
4155
|
+
* Hand-written scene for detail rows under expanded rows.
|
|
4156
|
+
*/
|
|
4157
|
+
const detailed = {
|
|
4158
|
+
about: "data-table.details.about",
|
|
4159
|
+
draw: () => /* @__PURE__ */ jsx(details.Details, {}),
|
|
4160
|
+
example: details,
|
|
4161
|
+
title: "data-table.details.title"
|
|
4162
|
+
};
|
|
4163
|
+
/**
|
|
4164
|
+
* Hand-written scene for sub-rows as rows with levels, a `treegrid` of cost centres.
|
|
4165
|
+
*/
|
|
4166
|
+
const treeRows = {
|
|
4167
|
+
about: "data-table.tree.about",
|
|
4168
|
+
draw: () => /* @__PURE__ */ jsx(tree.Tree, {}),
|
|
4169
|
+
example: tree,
|
|
4170
|
+
title: "data-table.tree.title"
|
|
4171
|
+
};
|
|
4172
|
+
/**
|
|
4173
|
+
* Hand-written scene for rows grouped by a column's value, with the sums of each group.
|
|
4174
|
+
*/
|
|
4175
|
+
const groupedRows = {
|
|
4176
|
+
about: "data-table.grouped.about",
|
|
4177
|
+
draw: () => /* @__PURE__ */ jsx(grouped.Grouped, {}),
|
|
4178
|
+
example: grouped,
|
|
4179
|
+
title: "data-table.grouped.title"
|
|
4180
|
+
};
|
|
4181
|
+
/**
|
|
4182
|
+
* Hand-written scene for folders whose items arrive after a delay the first time they open.
|
|
4183
|
+
*/
|
|
4184
|
+
const lazyRows = {
|
|
4185
|
+
about: "data-table.lazy.about",
|
|
4186
|
+
draw: () => /* @__PURE__ */ jsx(lazy.Lazy, {}),
|
|
4187
|
+
example: lazy,
|
|
4188
|
+
title: "data-table.lazy.title"
|
|
4189
|
+
};
|
|
4190
|
+
/**
|
|
4191
|
+
* Hand-written scene for a footer row of totals.
|
|
4192
|
+
*/
|
|
4193
|
+
const totalled = {
|
|
4194
|
+
about: "data-table.totals.about",
|
|
4195
|
+
draw: () => /* @__PURE__ */ jsx(totals.Totals, {}),
|
|
4196
|
+
example: totals,
|
|
4197
|
+
title: "data-table.totals.title"
|
|
4198
|
+
};
|
|
4199
|
+
/**
|
|
4200
|
+
* Hand-written scene for pinned columns and resizable columns, in a room narrower than the columns
|
|
4201
|
+
* together, so the figures scroll under the pinned select and account columns at every width.
|
|
4202
|
+
*/
|
|
4203
|
+
const sized = {
|
|
4204
|
+
about: "data-table.columns.about",
|
|
4205
|
+
draw: () => /* @__PURE__ */ jsx(Room, {
|
|
4206
|
+
size: "lg",
|
|
4207
|
+
children: /* @__PURE__ */ jsx(columns.Columns, {})
|
|
4208
|
+
}),
|
|
4209
|
+
example: columns,
|
|
4210
|
+
title: "data-table.columns.title"
|
|
4211
|
+
};
|
|
4212
|
+
/**
|
|
4213
|
+
* Hand-written scene for rows pinned to the top with the pin column.
|
|
4214
|
+
*/
|
|
4215
|
+
const pinnedRows = {
|
|
4216
|
+
about: "data-table.pinned.about",
|
|
4217
|
+
draw: () => /* @__PURE__ */ jsx(pinned.Pinned, {}),
|
|
4218
|
+
example: pinned,
|
|
4219
|
+
title: "data-table.pinned.title"
|
|
4220
|
+
};
|
|
4221
|
+
/**
|
|
4222
|
+
* Hand-written scene for a column whose equal adjacent values span their rows.
|
|
4223
|
+
*/
|
|
4224
|
+
const spannedCells = {
|
|
4225
|
+
about: "data-table.spanned.about",
|
|
4226
|
+
draw: () => /* @__PURE__ */ jsx(spanned.Spanned, {}),
|
|
4227
|
+
example: spanned,
|
|
4228
|
+
title: "data-table.spanned.title"
|
|
4229
|
+
};
|
|
4230
|
+
/**
|
|
4231
|
+
* Hand-written scene for a pivot of orders by region and product per quarter, with its totals.
|
|
4232
|
+
*/
|
|
4233
|
+
const pivoted = {
|
|
4234
|
+
about: "data-table.pivot.about",
|
|
4235
|
+
draw: () => /* @__PURE__ */ jsx(pivot.Pivot, {}),
|
|
4236
|
+
example: pivot,
|
|
4237
|
+
title: "data-table.pivot.title"
|
|
4238
|
+
};
|
|
4239
|
+
/**
|
|
4240
|
+
* Hand-written scene for a pivot whose aggregate a person picks from a select.
|
|
4241
|
+
*/
|
|
4242
|
+
const aggregated = {
|
|
4243
|
+
about: "data-table.aggregates.about",
|
|
4244
|
+
draw: () => /* @__PURE__ */ jsx(aggregates.Aggregates, {}),
|
|
4245
|
+
example: aggregates,
|
|
4246
|
+
title: "data-table.aggregates.title"
|
|
4247
|
+
};
|
|
4248
|
+
/**
|
|
4249
|
+
* Hand-written scene for a grid of budget cells a person selects with the keys and the pointer and
|
|
4250
|
+
* copies into a spreadsheet.
|
|
4251
|
+
*/
|
|
4252
|
+
const gridded = {
|
|
4253
|
+
about: "data-table.grid.about",
|
|
4254
|
+
draw: () => /* @__PURE__ */ jsx(grid.Grid, {}),
|
|
4255
|
+
example: grid,
|
|
4256
|
+
title: "data-table.grid.title"
|
|
4257
|
+
};
|
|
4258
|
+
/**
|
|
4259
|
+
* Hand-written scene for expense claims a person edits in place, with the unsaved changes marked
|
|
4260
|
+
* until they are saved or discarded.
|
|
4261
|
+
*/
|
|
4262
|
+
const edited = {
|
|
4263
|
+
about: "data-table.claims.about",
|
|
4264
|
+
draw: () => /* @__PURE__ */ jsx(claims.Claims, {}),
|
|
4265
|
+
example: claims,
|
|
4266
|
+
title: "data-table.claims.title"
|
|
4267
|
+
};
|
|
4268
|
+
var data_table_specimen_default = specimen({
|
|
4269
|
+
about: "data-table.about",
|
|
4270
|
+
id: "components/tables/data-table",
|
|
4271
|
+
imports: "import { DataTable } from \"@stealthscale/component-tables\";",
|
|
4272
|
+
scenes: [
|
|
4273
|
+
sorted,
|
|
4274
|
+
searched,
|
|
4275
|
+
filtered,
|
|
4276
|
+
menued,
|
|
4277
|
+
managed,
|
|
4278
|
+
paged,
|
|
4279
|
+
served,
|
|
4280
|
+
windowedRows,
|
|
4281
|
+
endlessRows,
|
|
4282
|
+
selected,
|
|
4283
|
+
detailed,
|
|
4284
|
+
treeRows,
|
|
4285
|
+
groupedRows,
|
|
4286
|
+
lazyRows,
|
|
4287
|
+
totalled,
|
|
4288
|
+
sized,
|
|
4289
|
+
pinnedRows,
|
|
4290
|
+
spannedCells,
|
|
4291
|
+
pivoted,
|
|
4292
|
+
aggregated,
|
|
4293
|
+
gridded,
|
|
4294
|
+
edited
|
|
4295
|
+
],
|
|
4296
|
+
title: "data-table.title"
|
|
4297
|
+
});
|
|
4298
|
+
//#endregion
|
|
4299
|
+
export { aggregated, data_table_specimen_default as default, detailed, edited, endlessRows, filtered, gridded, groupedRows, lazyRows, managed, menued, paged, pinnedRows, pivoted, searched, selected, served, sized, sorted, spannedCells, totalled, treeRows, windowedRows };
|