@stealthscale/component-collections 0.1.1 → 0.1.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 -5700
- package/dist/pages/data-list/data-list.js +351 -0
- package/dist/pages/data-list/data-list.props.js +3 -0
- package/dist/pages/listbox/listbox.js +1277 -0
- package/dist/pages/listbox/listbox.props.js +3 -0
- package/dist/pages/pages.json +105 -0
- package/dist/pages/sortable/sortable.js +576 -0
- package/dist/pages/sortable/sortable.props.js +3 -0
- package/dist/pages/status-matrix/status-matrix.js +1403 -0
- package/dist/pages/status-matrix/status-matrix.props.js +3 -0
- package/dist/pages/swipe-actions/swipe-actions.js +212 -0
- package/dist/pages/swipe-actions/swipe-actions.props.js +3 -0
- package/dist/pages/table/table.js +1701 -0
- package/dist/pages/table/table.props.js +3 -0
- package/dist/pages/timeline/timeline.js +380 -0
- package/dist/pages/timeline/timeline.props.js +3 -0
- package/dist/pages/transfer/transfer.js +465 -0
- package/dist/pages/transfer/transfer.props.js +3 -0
- package/dist/pages/tree-view/tree-view.js +1059 -0
- package/dist/pages/tree-view/tree-view.props.js +3 -0
- package/dist/shared-DVn824MJ.js +5701 -0
- package/dist/theme.js +23 -13
- package/locales/en/specimen/data-list.json +64 -0
- package/locales/en/specimen/listbox.json +98 -0
- package/locales/en/specimen/sortable.json +65 -0
- package/locales/en/specimen/status-matrix.json +47 -0
- package/locales/en/specimen/swipe-actions.json +32 -0
- package/locales/en/specimen/table.json +94 -0
- package/locales/en/specimen/timeline.json +72 -0
- package/locales/en/specimen/transfer.json +34 -0
- package/locales/en/specimen/tree-view.json +107 -0
- package/package.json +10 -9
- /package/dist/{recipe-C1oaF8pO.js → recipes-C1oaF8pO.js} +0 -0
|
@@ -0,0 +1,1277 @@
|
|
|
1
|
+
import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { Z as Simple, at as useFilter, it as useGridCollection, ot as useListCollection } from "../../shared-DVn824MJ.js";
|
|
3
|
+
import { u as recipe } from "../../recipes-C1oaF8pO.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Button, ButtonPropsProvider } from "@stealthscale/component-actions";
|
|
8
|
+
import { Matrix, Room, scenesOf, specimen, useWords } from "@stealthscale/specimen";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { CheckIcon, LandmarkIcon, MinusIcon, StoreIcon, XIcon } from "lucide-react";
|
|
11
|
+
import { Popover } from "@stealthscale/component-disclosure";
|
|
12
|
+
import { Group, Stack } from "@stealthscale/component-layout";
|
|
13
|
+
//#region src/listbox/examples/clients.example.tsx
|
|
14
|
+
var clients_example_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
+
Clients: () => Clients,
|
|
16
|
+
source: () => source$10
|
|
17
|
+
});
|
|
18
|
+
const CLIENTS$8 = [
|
|
19
|
+
"fathom",
|
|
20
|
+
"lantern",
|
|
21
|
+
"pebble",
|
|
22
|
+
"quartz"
|
|
23
|
+
];
|
|
24
|
+
function Clients(props) {
|
|
25
|
+
const $ = c(12);
|
|
26
|
+
const { t } = useWords("listbox");
|
|
27
|
+
let t0;
|
|
28
|
+
if ($[0] !== t) {
|
|
29
|
+
t0 = CLIENTS$8.map((id) => ({
|
|
30
|
+
id,
|
|
31
|
+
name: t(id)
|
|
32
|
+
}));
|
|
33
|
+
$[0] = t;
|
|
34
|
+
$[1] = t0;
|
|
35
|
+
} else t0 = $[1];
|
|
36
|
+
let t1;
|
|
37
|
+
if ($[2] !== t0) {
|
|
38
|
+
t1 = {
|
|
39
|
+
itemToString: _temp$10,
|
|
40
|
+
itemToValue: _temp2$10,
|
|
41
|
+
rows: t0
|
|
42
|
+
};
|
|
43
|
+
$[2] = t0;
|
|
44
|
+
$[3] = t1;
|
|
45
|
+
} else t1 = $[3];
|
|
46
|
+
const { collection } = useListCollection(t1);
|
|
47
|
+
let t2;
|
|
48
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
+
t2 = ["fathom"];
|
|
50
|
+
$[4] = t2;
|
|
51
|
+
} else t2 = $[4];
|
|
52
|
+
let t3;
|
|
53
|
+
if ($[5] !== t) {
|
|
54
|
+
t3 = t("clients");
|
|
55
|
+
$[5] = t;
|
|
56
|
+
$[6] = t3;
|
|
57
|
+
} else t3 = $[6];
|
|
58
|
+
let t4;
|
|
59
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
+
t4 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
61
|
+
$[7] = t4;
|
|
62
|
+
} else t4 = $[7];
|
|
63
|
+
let t5;
|
|
64
|
+
if ($[8] !== collection || $[9] !== props || $[10] !== t3) {
|
|
65
|
+
t5 = /* @__PURE__ */ jsx(Simple, {
|
|
66
|
+
collection,
|
|
67
|
+
defaultValue: t2,
|
|
68
|
+
label: t3,
|
|
69
|
+
mark: t4,
|
|
70
|
+
...props
|
|
71
|
+
});
|
|
72
|
+
$[8] = collection;
|
|
73
|
+
$[9] = props;
|
|
74
|
+
$[10] = t3;
|
|
75
|
+
$[11] = t5;
|
|
76
|
+
} else t5 = $[11];
|
|
77
|
+
return t5;
|
|
78
|
+
}
|
|
79
|
+
function _temp2$10(client_0) {
|
|
80
|
+
return client_0.id;
|
|
81
|
+
}
|
|
82
|
+
function _temp$10(client) {
|
|
83
|
+
return client.name;
|
|
84
|
+
}
|
|
85
|
+
const source$10 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nexport function Clients(props: Omit<Listbox.SimpleProps<Client>, \"collection\">): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n {...props}\n />\n );\n}\n";
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/listbox/examples/consignments.example.tsx
|
|
88
|
+
var consignments_example_exports = /* @__PURE__ */ __exportAll({
|
|
89
|
+
Consignments: () => Consignments,
|
|
90
|
+
source: () => source$9
|
|
91
|
+
});
|
|
92
|
+
const COUNT = 1e4;
|
|
93
|
+
function Consignments() {
|
|
94
|
+
const $ = c(11);
|
|
95
|
+
const { i18n, t } = useWords("listbox");
|
|
96
|
+
let t0;
|
|
97
|
+
if ($[0] !== t) {
|
|
98
|
+
t0 = Array.from({ length: COUNT }, (_, at) => ({
|
|
99
|
+
id: String(at),
|
|
100
|
+
name: t("consignment", { at: String(at + 1).padStart(5, "0") })
|
|
101
|
+
}));
|
|
102
|
+
$[0] = t;
|
|
103
|
+
$[1] = t0;
|
|
104
|
+
} else t0 = $[1];
|
|
105
|
+
const rows = t0;
|
|
106
|
+
let t1;
|
|
107
|
+
if ($[2] !== rows) {
|
|
108
|
+
t1 = {
|
|
109
|
+
itemToString: _temp$9,
|
|
110
|
+
itemToValue: _temp2$9,
|
|
111
|
+
rows
|
|
112
|
+
};
|
|
113
|
+
$[2] = rows;
|
|
114
|
+
$[3] = t1;
|
|
115
|
+
} else t1 = $[3];
|
|
116
|
+
const { collection } = useListCollection(t1);
|
|
117
|
+
let t2;
|
|
118
|
+
if ($[4] !== i18n.language || $[5] !== t) {
|
|
119
|
+
t2 = t("consignments", { count: COUNT.toLocaleString(i18n.language) });
|
|
120
|
+
$[4] = i18n.language;
|
|
121
|
+
$[5] = t;
|
|
122
|
+
$[6] = t2;
|
|
123
|
+
} else t2 = $[6];
|
|
124
|
+
let t3;
|
|
125
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
126
|
+
t3 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
127
|
+
$[7] = t3;
|
|
128
|
+
} else t3 = $[7];
|
|
129
|
+
let t4;
|
|
130
|
+
if ($[8] !== collection || $[9] !== t2) {
|
|
131
|
+
t4 = /* @__PURE__ */ jsx(Simple, {
|
|
132
|
+
collection,
|
|
133
|
+
label: t2,
|
|
134
|
+
mark: t3,
|
|
135
|
+
tall: 8,
|
|
136
|
+
variant: "surface"
|
|
137
|
+
});
|
|
138
|
+
$[8] = collection;
|
|
139
|
+
$[9] = t2;
|
|
140
|
+
$[10] = t4;
|
|
141
|
+
} else t4 = $[10];
|
|
142
|
+
return t4;
|
|
143
|
+
}
|
|
144
|
+
function _temp2$9(consignment_0) {
|
|
145
|
+
return consignment_0.id;
|
|
146
|
+
}
|
|
147
|
+
function _temp$9(consignment) {
|
|
148
|
+
return consignment.name;
|
|
149
|
+
}
|
|
150
|
+
const source$9 = "import { type ReactElement, useMemo } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Consignment {\n readonly id: string;\n readonly name: string;\n}\n\nconst COUNT = 10_000;\n\nexport function Consignments(): ReactElement {\n const { i18n, t } = useWords(\"listbox\");\n const rows = useMemo(\n () =>\n Array.from({ length: COUNT }, (_, at) => ({\n id: String(at),\n name: t(\"consignment\", { at: String(at + 1).padStart(5, \"0\") }),\n })),\n [t],\n );\n const { collection } = useListCollection<Consignment>({\n itemToString: (consignment) => consignment.name,\n itemToValue: (consignment) => consignment.id,\n rows,\n });\n\n return (\n <Listbox.Simple<Consignment>\n collection={collection}\n label={t(\"consignments\", { count: COUNT.toLocaleString(i18n.language) })}\n mark={<CheckIcon size=\"100%\" />}\n tall={8}\n variant=\"surface\"\n />\n );\n}\n";
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/listbox/examples/described.example.tsx
|
|
153
|
+
var described_example_exports = /* @__PURE__ */ __exportAll({
|
|
154
|
+
Described: () => Described,
|
|
155
|
+
source: () => source$8
|
|
156
|
+
});
|
|
157
|
+
const CLIENTS$7 = [
|
|
158
|
+
"fathom",
|
|
159
|
+
"lantern",
|
|
160
|
+
"pebble",
|
|
161
|
+
"quartz"
|
|
162
|
+
];
|
|
163
|
+
function Described(props) {
|
|
164
|
+
const $ = c(14);
|
|
165
|
+
const { t } = useWords("listbox");
|
|
166
|
+
let t0;
|
|
167
|
+
if ($[0] !== t) {
|
|
168
|
+
t0 = CLIENTS$7.map((id) => ({
|
|
169
|
+
id,
|
|
170
|
+
name: t(id)
|
|
171
|
+
}));
|
|
172
|
+
$[0] = t;
|
|
173
|
+
$[1] = t0;
|
|
174
|
+
} else t0 = $[1];
|
|
175
|
+
let t1;
|
|
176
|
+
if ($[2] !== t0) {
|
|
177
|
+
t1 = {
|
|
178
|
+
itemToString: _temp$8,
|
|
179
|
+
itemToValue: _temp2$8,
|
|
180
|
+
rows: t0
|
|
181
|
+
};
|
|
182
|
+
$[2] = t0;
|
|
183
|
+
$[3] = t1;
|
|
184
|
+
} else t1 = $[3];
|
|
185
|
+
const { collection } = useListCollection(t1);
|
|
186
|
+
let t2;
|
|
187
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
188
|
+
t2 = ["fathom"];
|
|
189
|
+
$[4] = t2;
|
|
190
|
+
} else t2 = $[4];
|
|
191
|
+
let t3;
|
|
192
|
+
let t4;
|
|
193
|
+
if ($[5] !== t) {
|
|
194
|
+
t3 = (client_1) => t(`${client_1.id}Of`);
|
|
195
|
+
t4 = t("clients");
|
|
196
|
+
$[5] = t;
|
|
197
|
+
$[6] = t3;
|
|
198
|
+
$[7] = t4;
|
|
199
|
+
} else {
|
|
200
|
+
t3 = $[6];
|
|
201
|
+
t4 = $[7];
|
|
202
|
+
}
|
|
203
|
+
let t5;
|
|
204
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
205
|
+
t5 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
206
|
+
$[8] = t5;
|
|
207
|
+
} else t5 = $[8];
|
|
208
|
+
let t6;
|
|
209
|
+
if ($[9] !== collection || $[10] !== props || $[11] !== t3 || $[12] !== t4) {
|
|
210
|
+
t6 = /* @__PURE__ */ jsx(Simple, {
|
|
211
|
+
collection,
|
|
212
|
+
defaultValue: t2,
|
|
213
|
+
description: t3,
|
|
214
|
+
label: t4,
|
|
215
|
+
mark: t5,
|
|
216
|
+
...props
|
|
217
|
+
});
|
|
218
|
+
$[9] = collection;
|
|
219
|
+
$[10] = props;
|
|
220
|
+
$[11] = t3;
|
|
221
|
+
$[12] = t4;
|
|
222
|
+
$[13] = t6;
|
|
223
|
+
} else t6 = $[13];
|
|
224
|
+
return t6;
|
|
225
|
+
}
|
|
226
|
+
function _temp2$8(client_0) {
|
|
227
|
+
return client_0.id;
|
|
228
|
+
}
|
|
229
|
+
function _temp$8(client) {
|
|
230
|
+
return client.name;
|
|
231
|
+
}
|
|
232
|
+
const source$8 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nexport function Described(props: Omit<Listbox.SimpleProps<Client>, \"collection\">): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n description={(client) => t(`${client.id}Of`)}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n {...props}\n />\n );\n}\n";
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/listbox/examples/everything.example.tsx
|
|
235
|
+
var everything_example_exports = /* @__PURE__ */ __exportAll({
|
|
236
|
+
Everything: () => Everything,
|
|
237
|
+
source: () => source$7
|
|
238
|
+
});
|
|
239
|
+
const CLIENTS$6 = [
|
|
240
|
+
"fathom",
|
|
241
|
+
"lantern",
|
|
242
|
+
"pebble",
|
|
243
|
+
"quartz"
|
|
244
|
+
];
|
|
245
|
+
function Everything() {
|
|
246
|
+
const $ = c(18);
|
|
247
|
+
const { t } = useWords("listbox");
|
|
248
|
+
let t0;
|
|
249
|
+
if ($[0] !== t) {
|
|
250
|
+
t0 = CLIENTS$6.map((id) => ({
|
|
251
|
+
id,
|
|
252
|
+
name: t(id)
|
|
253
|
+
}));
|
|
254
|
+
$[0] = t;
|
|
255
|
+
$[1] = t0;
|
|
256
|
+
} else t0 = $[1];
|
|
257
|
+
let t1;
|
|
258
|
+
if ($[2] !== t0) {
|
|
259
|
+
t1 = {
|
|
260
|
+
itemToString: _temp$7,
|
|
261
|
+
itemToValue: _temp2$7,
|
|
262
|
+
rows: t0
|
|
263
|
+
};
|
|
264
|
+
$[2] = t0;
|
|
265
|
+
$[3] = t1;
|
|
266
|
+
} else t1 = $[3];
|
|
267
|
+
const { collection } = useListCollection(t1);
|
|
268
|
+
let t2;
|
|
269
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
270
|
+
t2 = ["fathom"];
|
|
271
|
+
$[4] = t2;
|
|
272
|
+
} else t2 = $[4];
|
|
273
|
+
let t3;
|
|
274
|
+
if ($[5] !== t) {
|
|
275
|
+
t3 = t("clients");
|
|
276
|
+
$[5] = t;
|
|
277
|
+
$[6] = t3;
|
|
278
|
+
} else t3 = $[6];
|
|
279
|
+
let t4;
|
|
280
|
+
let t5;
|
|
281
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
282
|
+
t4 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
283
|
+
t5 = /* @__PURE__ */ jsx(MinusIcon, { size: "100%" });
|
|
284
|
+
$[7] = t4;
|
|
285
|
+
$[8] = t5;
|
|
286
|
+
} else {
|
|
287
|
+
t4 = $[7];
|
|
288
|
+
t5 = $[8];
|
|
289
|
+
}
|
|
290
|
+
let t6;
|
|
291
|
+
if ($[9] !== t) {
|
|
292
|
+
t6 = t("all");
|
|
293
|
+
$[9] = t;
|
|
294
|
+
$[10] = t6;
|
|
295
|
+
} else t6 = $[10];
|
|
296
|
+
let t7;
|
|
297
|
+
if ($[11] !== t) {
|
|
298
|
+
t7 = t("nothing");
|
|
299
|
+
$[11] = t;
|
|
300
|
+
$[12] = t7;
|
|
301
|
+
} else t7 = $[12];
|
|
302
|
+
let t8;
|
|
303
|
+
if ($[13] !== collection || $[14] !== t3 || $[15] !== t6 || $[16] !== t7) {
|
|
304
|
+
t8 = /* @__PURE__ */ jsx(Simple, {
|
|
305
|
+
boxed: true,
|
|
306
|
+
collection,
|
|
307
|
+
defaultValue: t2,
|
|
308
|
+
label: t3,
|
|
309
|
+
mark: t4,
|
|
310
|
+
mixedMark: t5,
|
|
311
|
+
selectAll: t6,
|
|
312
|
+
selectionMode: "multiple",
|
|
313
|
+
summary: t7,
|
|
314
|
+
variant: "surface"
|
|
315
|
+
});
|
|
316
|
+
$[13] = collection;
|
|
317
|
+
$[14] = t3;
|
|
318
|
+
$[15] = t6;
|
|
319
|
+
$[16] = t7;
|
|
320
|
+
$[17] = t8;
|
|
321
|
+
} else t8 = $[17];
|
|
322
|
+
return t8;
|
|
323
|
+
}
|
|
324
|
+
function _temp2$7(client_0) {
|
|
325
|
+
return client_0.id;
|
|
326
|
+
}
|
|
327
|
+
function _temp$7(client) {
|
|
328
|
+
return client.name;
|
|
329
|
+
}
|
|
330
|
+
const source$7 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, MinusIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nexport function Everything(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n boxed\n collection={collection}\n defaultValue={[\"fathom\"]}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n mixedMark={<MinusIcon size=\"100%\" />}\n selectAll={t(\"all\")}\n selectionMode=\"multiple\"\n summary={t(\"nothing\")}\n variant=\"surface\"\n />\n );\n}\n";
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/listbox/examples/filtered.example.tsx
|
|
333
|
+
var filtered_example_exports = /* @__PURE__ */ __exportAll({
|
|
334
|
+
Filtered: () => Filtered,
|
|
335
|
+
source: () => source$6
|
|
336
|
+
});
|
|
337
|
+
const CLIENTS$5 = [
|
|
338
|
+
"fathom",
|
|
339
|
+
"lantern",
|
|
340
|
+
"pebble",
|
|
341
|
+
"quartz"
|
|
342
|
+
];
|
|
343
|
+
function Filtered() {
|
|
344
|
+
const $ = c(25);
|
|
345
|
+
const { t } = useWords("listbox");
|
|
346
|
+
const filter = useFilter();
|
|
347
|
+
const t0 = filter.contains;
|
|
348
|
+
let t1;
|
|
349
|
+
if ($[0] !== t) {
|
|
350
|
+
t1 = CLIENTS$5.map((id) => ({
|
|
351
|
+
id,
|
|
352
|
+
name: t(id)
|
|
353
|
+
}));
|
|
354
|
+
$[0] = t;
|
|
355
|
+
$[1] = t1;
|
|
356
|
+
} else t1 = $[1];
|
|
357
|
+
let t2;
|
|
358
|
+
if ($[2] !== filter.contains || $[3] !== t1) {
|
|
359
|
+
t2 = {
|
|
360
|
+
filter: t0,
|
|
361
|
+
itemToString: _temp$6,
|
|
362
|
+
itemToValue: _temp2$6,
|
|
363
|
+
rows: t1
|
|
364
|
+
};
|
|
365
|
+
$[2] = filter.contains;
|
|
366
|
+
$[3] = t1;
|
|
367
|
+
$[4] = t2;
|
|
368
|
+
} else t2 = $[4];
|
|
369
|
+
const { collection, narrow } = useListCollection(t2);
|
|
370
|
+
let t3;
|
|
371
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
372
|
+
t3 = ["fathom"];
|
|
373
|
+
$[5] = t3;
|
|
374
|
+
} else t3 = $[5];
|
|
375
|
+
let t4;
|
|
376
|
+
if ($[6] !== t) {
|
|
377
|
+
t4 = t("none");
|
|
378
|
+
$[6] = t;
|
|
379
|
+
$[7] = t4;
|
|
380
|
+
} else t4 = $[7];
|
|
381
|
+
let t5;
|
|
382
|
+
if ($[8] !== t) {
|
|
383
|
+
t5 = t("clients");
|
|
384
|
+
$[8] = t;
|
|
385
|
+
$[9] = t5;
|
|
386
|
+
} else t5 = $[9];
|
|
387
|
+
let t6;
|
|
388
|
+
let t7;
|
|
389
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
390
|
+
t6 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
391
|
+
t7 = /* @__PURE__ */ jsx(XIcon, { size: "100%" });
|
|
392
|
+
$[10] = t6;
|
|
393
|
+
$[11] = t7;
|
|
394
|
+
} else {
|
|
395
|
+
t6 = $[10];
|
|
396
|
+
t7 = $[11];
|
|
397
|
+
}
|
|
398
|
+
let t8;
|
|
399
|
+
if ($[12] !== t) {
|
|
400
|
+
t8 = t("clear");
|
|
401
|
+
$[12] = t;
|
|
402
|
+
$[13] = t8;
|
|
403
|
+
} else t8 = $[13];
|
|
404
|
+
let t9;
|
|
405
|
+
if ($[14] !== t) {
|
|
406
|
+
t9 = t("filter");
|
|
407
|
+
$[14] = t;
|
|
408
|
+
$[15] = t9;
|
|
409
|
+
} else t9 = $[15];
|
|
410
|
+
let t10;
|
|
411
|
+
if ($[16] !== narrow || $[17] !== t8 || $[18] !== t9) {
|
|
412
|
+
t10 = {
|
|
413
|
+
clearIndicator: t7,
|
|
414
|
+
clearLabel: t8,
|
|
415
|
+
onNarrow: narrow,
|
|
416
|
+
placeholder: t9
|
|
417
|
+
};
|
|
418
|
+
$[16] = narrow;
|
|
419
|
+
$[17] = t8;
|
|
420
|
+
$[18] = t9;
|
|
421
|
+
$[19] = t10;
|
|
422
|
+
} else t10 = $[19];
|
|
423
|
+
let t11;
|
|
424
|
+
if ($[20] !== collection || $[21] !== t10 || $[22] !== t4 || $[23] !== t5) {
|
|
425
|
+
t11 = /* @__PURE__ */ jsx(Simple, {
|
|
426
|
+
collection,
|
|
427
|
+
defaultValue: t3,
|
|
428
|
+
empty: t4,
|
|
429
|
+
label: t5,
|
|
430
|
+
mark: t6,
|
|
431
|
+
narrowing: t10,
|
|
432
|
+
variant: "surface"
|
|
433
|
+
});
|
|
434
|
+
$[20] = collection;
|
|
435
|
+
$[21] = t10;
|
|
436
|
+
$[22] = t4;
|
|
437
|
+
$[23] = t5;
|
|
438
|
+
$[24] = t11;
|
|
439
|
+
} else t11 = $[24];
|
|
440
|
+
return t11;
|
|
441
|
+
}
|
|
442
|
+
function _temp2$6(client_0) {
|
|
443
|
+
return client_0.id;
|
|
444
|
+
}
|
|
445
|
+
function _temp$6(client) {
|
|
446
|
+
return client.name;
|
|
447
|
+
}
|
|
448
|
+
const source$6 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, XIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useFilter, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nexport function Filtered(): ReactElement {\n const { t } = useWords(\"listbox\");\n const filter = useFilter();\n const { collection, narrow } = useListCollection<Client>({\n filter: filter.contains,\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n empty={t(\"none\")}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n narrowing={{\n clearIndicator: <XIcon size=\"100%\" />,\n clearLabel: t(\"clear\"),\n onNarrow: narrow,\n placeholder: t(\"filter\"),\n }}\n variant=\"surface\"\n />\n );\n}\n";
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/listbox/examples/grouped.example.tsx
|
|
451
|
+
var grouped_example_exports = /* @__PURE__ */ __exportAll({
|
|
452
|
+
Grouped: () => Grouped,
|
|
453
|
+
source: () => source$5
|
|
454
|
+
});
|
|
455
|
+
const CLIENTS$4 = [
|
|
456
|
+
{
|
|
457
|
+
id: "fathom",
|
|
458
|
+
status: "held"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
id: "lantern",
|
|
462
|
+
status: "held"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
id: "pebble",
|
|
466
|
+
status: "closed"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
id: "quartz",
|
|
470
|
+
status: "closed"
|
|
471
|
+
}
|
|
472
|
+
];
|
|
473
|
+
function Grouped() {
|
|
474
|
+
const $ = c(13);
|
|
475
|
+
const { t } = useWords("listbox");
|
|
476
|
+
let t0;
|
|
477
|
+
if ($[0] !== t) {
|
|
478
|
+
t0 = CLIENTS$4.map((t1) => {
|
|
479
|
+
const { id, status } = t1;
|
|
480
|
+
return {
|
|
481
|
+
id,
|
|
482
|
+
name: t(id),
|
|
483
|
+
status
|
|
484
|
+
};
|
|
485
|
+
});
|
|
486
|
+
$[0] = t;
|
|
487
|
+
$[1] = t0;
|
|
488
|
+
} else t0 = $[1];
|
|
489
|
+
let t1;
|
|
490
|
+
if ($[2] !== t0) {
|
|
491
|
+
t1 = {
|
|
492
|
+
itemToString: _temp$5,
|
|
493
|
+
itemToValue: _temp2$5,
|
|
494
|
+
rows: t0
|
|
495
|
+
};
|
|
496
|
+
$[2] = t0;
|
|
497
|
+
$[3] = t1;
|
|
498
|
+
} else t1 = $[3];
|
|
499
|
+
const { collection } = useListCollection(t1);
|
|
500
|
+
let t2;
|
|
501
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
502
|
+
t2 = ["fathom"];
|
|
503
|
+
$[4] = t2;
|
|
504
|
+
} else t2 = $[4];
|
|
505
|
+
let t3;
|
|
506
|
+
let t4;
|
|
507
|
+
if ($[5] !== t) {
|
|
508
|
+
t3 = (status_0) => t(status_0);
|
|
509
|
+
t4 = t("clients");
|
|
510
|
+
$[5] = t;
|
|
511
|
+
$[6] = t3;
|
|
512
|
+
$[7] = t4;
|
|
513
|
+
} else {
|
|
514
|
+
t3 = $[6];
|
|
515
|
+
t4 = $[7];
|
|
516
|
+
}
|
|
517
|
+
let t5;
|
|
518
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
519
|
+
t5 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
520
|
+
$[8] = t5;
|
|
521
|
+
} else t5 = $[8];
|
|
522
|
+
let t6;
|
|
523
|
+
if ($[9] !== collection || $[10] !== t3 || $[11] !== t4) {
|
|
524
|
+
t6 = /* @__PURE__ */ jsx(Simple, {
|
|
525
|
+
collection,
|
|
526
|
+
defaultValue: t2,
|
|
527
|
+
groupBy: _temp3$2,
|
|
528
|
+
groupLabel: t3,
|
|
529
|
+
label: t4,
|
|
530
|
+
mark: t5,
|
|
531
|
+
variant: "surface"
|
|
532
|
+
});
|
|
533
|
+
$[9] = collection;
|
|
534
|
+
$[10] = t3;
|
|
535
|
+
$[11] = t4;
|
|
536
|
+
$[12] = t6;
|
|
537
|
+
} else t6 = $[12];
|
|
538
|
+
return t6;
|
|
539
|
+
}
|
|
540
|
+
function _temp3$2(client_1) {
|
|
541
|
+
return client_1.status;
|
|
542
|
+
}
|
|
543
|
+
function _temp2$5(client_0) {
|
|
544
|
+
return client_0.id;
|
|
545
|
+
}
|
|
546
|
+
function _temp$5(client) {
|
|
547
|
+
return client.name;
|
|
548
|
+
}
|
|
549
|
+
const source$5 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n readonly status: \"closed\" | \"held\";\n}\n\nconst CLIENTS = [\n { id: \"fathom\", status: \"held\" },\n { id: \"lantern\", status: \"held\" },\n { id: \"pebble\", status: \"closed\" },\n { id: \"quartz\", status: \"closed\" },\n] as const;\n\nexport function Grouped(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map(({ id, status }) => ({ id, name: t(id), status })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n groupBy={(client) => client.status}\n groupLabel={(status) => t(status)}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n variant=\"surface\"\n />\n );\n}\n";
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/listbox/examples/held.example.tsx
|
|
552
|
+
var held_example_exports = /* @__PURE__ */ __exportAll({
|
|
553
|
+
Held: () => Held,
|
|
554
|
+
source: () => source$4
|
|
555
|
+
});
|
|
556
|
+
const CLIENTS$3 = [
|
|
557
|
+
"fathom",
|
|
558
|
+
"lantern",
|
|
559
|
+
"pebble",
|
|
560
|
+
"quartz"
|
|
561
|
+
];
|
|
562
|
+
function Held() {
|
|
563
|
+
const $ = c(29);
|
|
564
|
+
const { t } = useWords("listbox");
|
|
565
|
+
let t0;
|
|
566
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
567
|
+
t0 = ["fathom"];
|
|
568
|
+
$[0] = t0;
|
|
569
|
+
} else t0 = $[0];
|
|
570
|
+
const [picked, setPicked] = useState(t0);
|
|
571
|
+
let t1;
|
|
572
|
+
if ($[1] !== t) {
|
|
573
|
+
t1 = CLIENTS$3.map((id) => ({
|
|
574
|
+
id,
|
|
575
|
+
name: t(id)
|
|
576
|
+
}));
|
|
577
|
+
$[1] = t;
|
|
578
|
+
$[2] = t1;
|
|
579
|
+
} else t1 = $[2];
|
|
580
|
+
let t2;
|
|
581
|
+
if ($[3] !== t1) {
|
|
582
|
+
t2 = {
|
|
583
|
+
itemToString: _temp$4,
|
|
584
|
+
itemToValue: _temp2$4,
|
|
585
|
+
rows: t1
|
|
586
|
+
};
|
|
587
|
+
$[3] = t1;
|
|
588
|
+
$[4] = t2;
|
|
589
|
+
} else t2 = $[4];
|
|
590
|
+
const { collection } = useListCollection(t2);
|
|
591
|
+
let t3;
|
|
592
|
+
if ($[5] !== t) {
|
|
593
|
+
t3 = t("clients");
|
|
594
|
+
$[5] = t;
|
|
595
|
+
$[6] = t3;
|
|
596
|
+
} else t3 = $[6];
|
|
597
|
+
let t4;
|
|
598
|
+
let t5;
|
|
599
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
600
|
+
t4 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
601
|
+
t5 = (next) => {
|
|
602
|
+
setPicked(next.value);
|
|
603
|
+
};
|
|
604
|
+
$[7] = t4;
|
|
605
|
+
$[8] = t5;
|
|
606
|
+
} else {
|
|
607
|
+
t4 = $[7];
|
|
608
|
+
t5 = $[8];
|
|
609
|
+
}
|
|
610
|
+
let t6;
|
|
611
|
+
if ($[9] !== collection || $[10] !== picked || $[11] !== t3) {
|
|
612
|
+
t6 = /* @__PURE__ */ jsx(Simple, {
|
|
613
|
+
boxed: true,
|
|
614
|
+
collection,
|
|
615
|
+
label: t3,
|
|
616
|
+
mark: t4,
|
|
617
|
+
onValueChange: t5,
|
|
618
|
+
selectionMode: "multiple",
|
|
619
|
+
value: picked,
|
|
620
|
+
variant: "surface"
|
|
621
|
+
});
|
|
622
|
+
$[9] = collection;
|
|
623
|
+
$[10] = picked;
|
|
624
|
+
$[11] = t3;
|
|
625
|
+
$[12] = t6;
|
|
626
|
+
} else t6 = $[12];
|
|
627
|
+
let t7;
|
|
628
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
629
|
+
t7 = () => {
|
|
630
|
+
setPicked([...CLIENTS$3]);
|
|
631
|
+
};
|
|
632
|
+
$[13] = t7;
|
|
633
|
+
} else t7 = $[13];
|
|
634
|
+
let t8;
|
|
635
|
+
if ($[14] !== t) {
|
|
636
|
+
t8 = t("takeAll");
|
|
637
|
+
$[14] = t;
|
|
638
|
+
$[15] = t8;
|
|
639
|
+
} else t8 = $[15];
|
|
640
|
+
let t9;
|
|
641
|
+
if ($[16] !== t8) {
|
|
642
|
+
t9 = /* @__PURE__ */ jsx(Button, {
|
|
643
|
+
onClick: t7,
|
|
644
|
+
size: "sm",
|
|
645
|
+
variant: "outline",
|
|
646
|
+
children: t8
|
|
647
|
+
});
|
|
648
|
+
$[16] = t8;
|
|
649
|
+
$[17] = t9;
|
|
650
|
+
} else t9 = $[17];
|
|
651
|
+
let t10;
|
|
652
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
653
|
+
t10 = () => {
|
|
654
|
+
setPicked([]);
|
|
655
|
+
};
|
|
656
|
+
$[18] = t10;
|
|
657
|
+
} else t10 = $[18];
|
|
658
|
+
let t11;
|
|
659
|
+
if ($[19] !== t) {
|
|
660
|
+
t11 = t("takeNone");
|
|
661
|
+
$[19] = t;
|
|
662
|
+
$[20] = t11;
|
|
663
|
+
} else t11 = $[20];
|
|
664
|
+
let t12;
|
|
665
|
+
if ($[21] !== t11) {
|
|
666
|
+
t12 = /* @__PURE__ */ jsx(Button, {
|
|
667
|
+
onClick: t10,
|
|
668
|
+
size: "sm",
|
|
669
|
+
variant: "outline",
|
|
670
|
+
children: t11
|
|
671
|
+
});
|
|
672
|
+
$[21] = t11;
|
|
673
|
+
$[22] = t12;
|
|
674
|
+
} else t12 = $[22];
|
|
675
|
+
let t13;
|
|
676
|
+
if ($[23] !== t12 || $[24] !== t9) {
|
|
677
|
+
t13 = /* @__PURE__ */ jsxs(Group, {
|
|
678
|
+
attached: true,
|
|
679
|
+
children: [t9, t12]
|
|
680
|
+
});
|
|
681
|
+
$[23] = t12;
|
|
682
|
+
$[24] = t9;
|
|
683
|
+
$[25] = t13;
|
|
684
|
+
} else t13 = $[25];
|
|
685
|
+
let t14;
|
|
686
|
+
if ($[26] !== t13 || $[27] !== t6) {
|
|
687
|
+
t14 = /* @__PURE__ */ jsxs(Stack, {
|
|
688
|
+
gap: "md",
|
|
689
|
+
children: [t6, t13]
|
|
690
|
+
});
|
|
691
|
+
$[26] = t13;
|
|
692
|
+
$[27] = t6;
|
|
693
|
+
$[28] = t14;
|
|
694
|
+
} else t14 = $[28];
|
|
695
|
+
return t14;
|
|
696
|
+
}
|
|
697
|
+
function _temp2$4(client_0) {
|
|
698
|
+
return client_0.id;
|
|
699
|
+
}
|
|
700
|
+
function _temp$4(client) {
|
|
701
|
+
return client.name;
|
|
702
|
+
}
|
|
703
|
+
const source$4 = "import { type ReactElement, useState } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { Button } from \"@stealthscale/component-actions\";\nimport { Group, Stack } from \"@stealthscale/component-layout\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nexport function Held(): ReactElement {\n const { t } = useWords(\"listbox\");\n const [picked, setPicked] = useState<string[]>([\"fathom\"]);\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Stack gap=\"md\">\n <Listbox.Simple<Client>\n boxed\n collection={collection}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n onValueChange={(next) => {\n setPicked(next.value);\n }}\n selectionMode=\"multiple\"\n value={picked}\n variant=\"surface\"\n />\n <Group attached>\n <Button\n onClick={() => {\n setPicked([...CLIENTS]);\n }}\n size=\"sm\"\n variant=\"outline\"\n >\n {t(\"takeAll\")}\n </Button>\n <Button\n onClick={() => {\n setPicked([]);\n }}\n size=\"sm\"\n variant=\"outline\"\n >\n {t(\"takeNone\")}\n </Button>\n </Group>\n </Stack>\n );\n}\n";
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/listbox/examples/kinds.example.tsx
|
|
706
|
+
var kinds_example_exports = /* @__PURE__ */ __exportAll({
|
|
707
|
+
Kinds: () => Kinds,
|
|
708
|
+
source: () => source$3
|
|
709
|
+
});
|
|
710
|
+
const CLIENTS$2 = [
|
|
711
|
+
{
|
|
712
|
+
id: "fathom",
|
|
713
|
+
kind: "bank"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
id: "lantern",
|
|
717
|
+
kind: "shop"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
id: "pebble",
|
|
721
|
+
kind: "bank"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
id: "quartz",
|
|
725
|
+
kind: "shop"
|
|
726
|
+
}
|
|
727
|
+
];
|
|
728
|
+
function kindOf(client) {
|
|
729
|
+
return client.kind === "bank" ? /* @__PURE__ */ jsx(LandmarkIcon, {
|
|
730
|
+
"aria-hidden": true,
|
|
731
|
+
size: "1em"
|
|
732
|
+
}) : /* @__PURE__ */ jsx(StoreIcon, {
|
|
733
|
+
"aria-hidden": true,
|
|
734
|
+
size: "1em"
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
function Kinds() {
|
|
738
|
+
const $ = c(11);
|
|
739
|
+
const { t } = useWords("listbox");
|
|
740
|
+
let t0;
|
|
741
|
+
if ($[0] !== t) {
|
|
742
|
+
t0 = CLIENTS$2.map((t1) => {
|
|
743
|
+
const { id, kind } = t1;
|
|
744
|
+
return {
|
|
745
|
+
id,
|
|
746
|
+
kind,
|
|
747
|
+
name: t(id)
|
|
748
|
+
};
|
|
749
|
+
});
|
|
750
|
+
$[0] = t;
|
|
751
|
+
$[1] = t0;
|
|
752
|
+
} else t0 = $[1];
|
|
753
|
+
let t1;
|
|
754
|
+
if ($[2] !== t0) {
|
|
755
|
+
t1 = {
|
|
756
|
+
itemToString: _temp$3,
|
|
757
|
+
itemToValue: _temp2$3,
|
|
758
|
+
rows: t0
|
|
759
|
+
};
|
|
760
|
+
$[2] = t0;
|
|
761
|
+
$[3] = t1;
|
|
762
|
+
} else t1 = $[3];
|
|
763
|
+
const { collection } = useListCollection(t1);
|
|
764
|
+
let t2;
|
|
765
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
766
|
+
t2 = ["fathom"];
|
|
767
|
+
$[4] = t2;
|
|
768
|
+
} else t2 = $[4];
|
|
769
|
+
let t3;
|
|
770
|
+
if ($[5] !== t) {
|
|
771
|
+
t3 = t("clients");
|
|
772
|
+
$[5] = t;
|
|
773
|
+
$[6] = t3;
|
|
774
|
+
} else t3 = $[6];
|
|
775
|
+
let t4;
|
|
776
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
777
|
+
t4 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
778
|
+
$[7] = t4;
|
|
779
|
+
} else t4 = $[7];
|
|
780
|
+
let t5;
|
|
781
|
+
if ($[8] !== collection || $[9] !== t3) {
|
|
782
|
+
t5 = /* @__PURE__ */ jsx(Simple, {
|
|
783
|
+
collection,
|
|
784
|
+
defaultValue: t2,
|
|
785
|
+
icon: kindOf,
|
|
786
|
+
label: t3,
|
|
787
|
+
mark: t4,
|
|
788
|
+
variant: "surface"
|
|
789
|
+
});
|
|
790
|
+
$[8] = collection;
|
|
791
|
+
$[9] = t3;
|
|
792
|
+
$[10] = t5;
|
|
793
|
+
} else t5 = $[10];
|
|
794
|
+
return t5;
|
|
795
|
+
}
|
|
796
|
+
function _temp2$3(client_0) {
|
|
797
|
+
return client_0.id;
|
|
798
|
+
}
|
|
799
|
+
function _temp$3(client) {
|
|
800
|
+
return client.name;
|
|
801
|
+
}
|
|
802
|
+
const source$3 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, LandmarkIcon, StoreIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly kind: \"bank\" | \"shop\";\n readonly name: string;\n}\n\nconst CLIENTS = [\n { id: \"fathom\", kind: \"bank\" },\n { id: \"lantern\", kind: \"shop\" },\n { id: \"pebble\", kind: \"bank\" },\n { id: \"quartz\", kind: \"shop\" },\n] as const;\n\nfunction kindOf(client: Client): ReactElement {\n return client.kind === \"bank\" ? (\n <LandmarkIcon aria-hidden size=\"1em\" />\n ) : (\n <StoreIcon aria-hidden size=\"1em\" />\n );\n}\n\nexport function Kinds(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map(({ id, kind }) => ({ id, kind, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n icon={kindOf}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n variant=\"surface\"\n />\n );\n}\n";
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/listbox/examples/locked.example.tsx
|
|
805
|
+
var locked_example_exports = /* @__PURE__ */ __exportAll({
|
|
806
|
+
Locked: () => Locked,
|
|
807
|
+
source: () => source$2
|
|
808
|
+
});
|
|
809
|
+
const CLIENTS$1 = [
|
|
810
|
+
{
|
|
811
|
+
closed: false,
|
|
812
|
+
id: "fathom"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
closed: false,
|
|
816
|
+
id: "lantern"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
closed: false,
|
|
820
|
+
id: "pebble"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
closed: true,
|
|
824
|
+
id: "quartz"
|
|
825
|
+
}
|
|
826
|
+
];
|
|
827
|
+
function Locked() {
|
|
828
|
+
const $ = c(11);
|
|
829
|
+
const { t } = useWords("listbox");
|
|
830
|
+
let t0;
|
|
831
|
+
if ($[0] !== t) {
|
|
832
|
+
t0 = CLIENTS$1.map((t1) => {
|
|
833
|
+
const { closed, id } = t1;
|
|
834
|
+
return {
|
|
835
|
+
closed,
|
|
836
|
+
id,
|
|
837
|
+
name: t(id)
|
|
838
|
+
};
|
|
839
|
+
});
|
|
840
|
+
$[0] = t;
|
|
841
|
+
$[1] = t0;
|
|
842
|
+
} else t0 = $[1];
|
|
843
|
+
let t1;
|
|
844
|
+
if ($[2] !== t0) {
|
|
845
|
+
t1 = {
|
|
846
|
+
isItemDisabled: _temp$2,
|
|
847
|
+
itemToString: _temp2$2,
|
|
848
|
+
itemToValue: _temp3$1,
|
|
849
|
+
rows: t0
|
|
850
|
+
};
|
|
851
|
+
$[2] = t0;
|
|
852
|
+
$[3] = t1;
|
|
853
|
+
} else t1 = $[3];
|
|
854
|
+
const { collection } = useListCollection(t1);
|
|
855
|
+
let t2;
|
|
856
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
857
|
+
t2 = ["fathom"];
|
|
858
|
+
$[4] = t2;
|
|
859
|
+
} else t2 = $[4];
|
|
860
|
+
let t3;
|
|
861
|
+
if ($[5] !== t) {
|
|
862
|
+
t3 = t("clients");
|
|
863
|
+
$[5] = t;
|
|
864
|
+
$[6] = t3;
|
|
865
|
+
} else t3 = $[6];
|
|
866
|
+
let t4;
|
|
867
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
868
|
+
t4 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
869
|
+
$[7] = t4;
|
|
870
|
+
} else t4 = $[7];
|
|
871
|
+
let t5;
|
|
872
|
+
if ($[8] !== collection || $[9] !== t3) {
|
|
873
|
+
t5 = /* @__PURE__ */ jsx(Simple, {
|
|
874
|
+
collection,
|
|
875
|
+
defaultValue: t2,
|
|
876
|
+
label: t3,
|
|
877
|
+
mark: t4,
|
|
878
|
+
variant: "surface"
|
|
879
|
+
});
|
|
880
|
+
$[8] = collection;
|
|
881
|
+
$[9] = t3;
|
|
882
|
+
$[10] = t5;
|
|
883
|
+
} else t5 = $[10];
|
|
884
|
+
return t5;
|
|
885
|
+
}
|
|
886
|
+
function _temp3$1(client_1) {
|
|
887
|
+
return client_1.id;
|
|
888
|
+
}
|
|
889
|
+
function _temp2$2(client_0) {
|
|
890
|
+
return client_0.name;
|
|
891
|
+
}
|
|
892
|
+
function _temp$2(client) {
|
|
893
|
+
return client.closed;
|
|
894
|
+
}
|
|
895
|
+
const source$2 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly closed: boolean;\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\n { closed: false, id: \"fathom\" },\n { closed: false, id: \"lantern\" },\n { closed: false, id: \"pebble\" },\n { closed: true, id: \"quartz\" },\n] as const;\n\nexport function Locked(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n isItemDisabled: (client) => client.closed,\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map(({ closed, id }) => ({ closed, id, name: t(id) })),\n });\n\n return (\n <Listbox.Simple<Client>\n collection={collection}\n defaultValue={[\"fathom\"]}\n label={t(\"clients\")}\n mark={<CheckIcon size=\"100%\" />}\n variant=\"surface\"\n />\n );\n}\n";
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/listbox/examples/ports.example.tsx
|
|
898
|
+
var ports_example_exports = /* @__PURE__ */ __exportAll({
|
|
899
|
+
Ports: () => Ports,
|
|
900
|
+
source: () => source$1
|
|
901
|
+
});
|
|
902
|
+
const COLUMNS = "4";
|
|
903
|
+
const PORTS = [
|
|
904
|
+
"NLRTM",
|
|
905
|
+
"DEHAM",
|
|
906
|
+
"BEANR",
|
|
907
|
+
"FRLEH",
|
|
908
|
+
"GBFXT",
|
|
909
|
+
"ESVLC",
|
|
910
|
+
"ITGOA",
|
|
911
|
+
"PLGDN",
|
|
912
|
+
"SEGOT",
|
|
913
|
+
"DKAAR",
|
|
914
|
+
"NOOSL",
|
|
915
|
+
"FIHEL"
|
|
916
|
+
];
|
|
917
|
+
function Ports() {
|
|
918
|
+
const $ = c(8);
|
|
919
|
+
const { t } = useWords("listbox");
|
|
920
|
+
let t0;
|
|
921
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
922
|
+
t0 = {
|
|
923
|
+
columnCount: Number(COLUMNS),
|
|
924
|
+
itemToString: _temp$1,
|
|
925
|
+
itemToValue: _temp2$1,
|
|
926
|
+
rows: PORTS.map(_temp3)
|
|
927
|
+
};
|
|
928
|
+
$[0] = t0;
|
|
929
|
+
} else t0 = $[0];
|
|
930
|
+
const { collection } = useGridCollection(t0);
|
|
931
|
+
let t1;
|
|
932
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
933
|
+
t1 = ["NLRTM", "DEHAM"];
|
|
934
|
+
$[1] = t1;
|
|
935
|
+
} else t1 = $[1];
|
|
936
|
+
let t2;
|
|
937
|
+
if ($[2] !== t) {
|
|
938
|
+
t2 = t("ports");
|
|
939
|
+
$[2] = t;
|
|
940
|
+
$[3] = t2;
|
|
941
|
+
} else t2 = $[3];
|
|
942
|
+
let t3;
|
|
943
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
944
|
+
t3 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
945
|
+
$[4] = t3;
|
|
946
|
+
} else t3 = $[4];
|
|
947
|
+
let t4;
|
|
948
|
+
if ($[5] !== collection || $[6] !== t2) {
|
|
949
|
+
t4 = /* @__PURE__ */ jsx(Simple, {
|
|
950
|
+
boxed: true,
|
|
951
|
+
collection,
|
|
952
|
+
columns: COLUMNS,
|
|
953
|
+
defaultValue: t1,
|
|
954
|
+
label: t2,
|
|
955
|
+
mark: t3,
|
|
956
|
+
selectionMode: "multiple",
|
|
957
|
+
variant: "surface"
|
|
958
|
+
});
|
|
959
|
+
$[5] = collection;
|
|
960
|
+
$[6] = t2;
|
|
961
|
+
$[7] = t4;
|
|
962
|
+
} else t4 = $[7];
|
|
963
|
+
return t4;
|
|
964
|
+
}
|
|
965
|
+
function _temp3(code) {
|
|
966
|
+
return { code };
|
|
967
|
+
}
|
|
968
|
+
function _temp2$1(port_0) {
|
|
969
|
+
return port_0.code;
|
|
970
|
+
}
|
|
971
|
+
function _temp$1(port) {
|
|
972
|
+
return port.code;
|
|
973
|
+
}
|
|
974
|
+
const source$1 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useGridCollection } from \"@stealthscale/component-collections\";\n\ninterface Port {\n readonly code: string;\n}\n\nconst COLUMNS = \"4\";\n\nconst PORTS = [\n \"NLRTM\",\n \"DEHAM\",\n \"BEANR\",\n \"FRLEH\",\n \"GBFXT\",\n \"ESVLC\",\n \"ITGOA\",\n \"PLGDN\",\n \"SEGOT\",\n \"DKAAR\",\n \"NOOSL\",\n \"FIHEL\",\n];\n\nexport function Ports(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useGridCollection<Port>({\n columnCount: Number(COLUMNS),\n itemToString: (port) => port.code,\n itemToValue: (port) => port.code,\n rows: PORTS.map((code) => ({ code })),\n });\n\n return (\n <Listbox.Simple<Port>\n boxed\n collection={collection}\n columns={COLUMNS}\n defaultValue={[\"NLRTM\", \"DEHAM\"]}\n label={t(\"ports\")}\n mark={<CheckIcon size=\"100%\" />}\n selectionMode=\"multiple\"\n variant=\"surface\"\n />\n );\n}\n";
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region src/listbox/examples/triggered.example.tsx
|
|
977
|
+
var triggered_example_exports = /* @__PURE__ */ __exportAll({
|
|
978
|
+
Triggered: () => Triggered,
|
|
979
|
+
source: () => source
|
|
980
|
+
});
|
|
981
|
+
const CLIENTS = [
|
|
982
|
+
"fathom",
|
|
983
|
+
"lantern",
|
|
984
|
+
"pebble",
|
|
985
|
+
"quartz"
|
|
986
|
+
];
|
|
987
|
+
const OUTLINED = { variant: "outline" };
|
|
988
|
+
function Triggered() {
|
|
989
|
+
const $ = c(18);
|
|
990
|
+
const { t } = useWords("listbox");
|
|
991
|
+
let t0;
|
|
992
|
+
if ($[0] !== t) {
|
|
993
|
+
t0 = CLIENTS.map((id) => ({
|
|
994
|
+
id,
|
|
995
|
+
name: t(id)
|
|
996
|
+
}));
|
|
997
|
+
$[0] = t;
|
|
998
|
+
$[1] = t0;
|
|
999
|
+
} else t0 = $[1];
|
|
1000
|
+
let t1;
|
|
1001
|
+
if ($[2] !== t0) {
|
|
1002
|
+
t1 = {
|
|
1003
|
+
itemToString: _temp,
|
|
1004
|
+
itemToValue: _temp2,
|
|
1005
|
+
rows: t0
|
|
1006
|
+
};
|
|
1007
|
+
$[2] = t0;
|
|
1008
|
+
$[3] = t1;
|
|
1009
|
+
} else t1 = $[3];
|
|
1010
|
+
const { collection } = useListCollection(t1);
|
|
1011
|
+
let t2;
|
|
1012
|
+
if ($[4] !== t) {
|
|
1013
|
+
t2 = t("pick");
|
|
1014
|
+
$[4] = t;
|
|
1015
|
+
$[5] = t2;
|
|
1016
|
+
} else t2 = $[5];
|
|
1017
|
+
let t3;
|
|
1018
|
+
if ($[6] !== t2) {
|
|
1019
|
+
t3 = /* @__PURE__ */ jsx(ButtonPropsProvider, {
|
|
1020
|
+
value: OUTLINED,
|
|
1021
|
+
children: /* @__PURE__ */ jsx(Popover.Trigger, {
|
|
1022
|
+
as: Button,
|
|
1023
|
+
children: t2
|
|
1024
|
+
})
|
|
1025
|
+
});
|
|
1026
|
+
$[6] = t2;
|
|
1027
|
+
$[7] = t3;
|
|
1028
|
+
} else t3 = $[7];
|
|
1029
|
+
let t4;
|
|
1030
|
+
if ($[8] !== t) {
|
|
1031
|
+
t4 = t("clients");
|
|
1032
|
+
$[8] = t;
|
|
1033
|
+
$[9] = t4;
|
|
1034
|
+
} else t4 = $[9];
|
|
1035
|
+
let t5;
|
|
1036
|
+
let t6;
|
|
1037
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1038
|
+
t5 = ["fathom"];
|
|
1039
|
+
t6 = /* @__PURE__ */ jsx(CheckIcon, { size: "100%" });
|
|
1040
|
+
$[10] = t5;
|
|
1041
|
+
$[11] = t6;
|
|
1042
|
+
} else {
|
|
1043
|
+
t5 = $[10];
|
|
1044
|
+
t6 = $[11];
|
|
1045
|
+
}
|
|
1046
|
+
let t7;
|
|
1047
|
+
if ($[12] !== collection || $[13] !== t4) {
|
|
1048
|
+
t7 = createPortal(/* @__PURE__ */ jsx(Popover.Positioner, { children: /* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsx(Simple, {
|
|
1049
|
+
"aria-label": t4,
|
|
1050
|
+
collection,
|
|
1051
|
+
defaultValue: t5,
|
|
1052
|
+
mark: t6
|
|
1053
|
+
}) }) }), document.body);
|
|
1054
|
+
$[12] = collection;
|
|
1055
|
+
$[13] = t4;
|
|
1056
|
+
$[14] = t7;
|
|
1057
|
+
} else t7 = $[14];
|
|
1058
|
+
let t8;
|
|
1059
|
+
if ($[15] !== t3 || $[16] !== t7) {
|
|
1060
|
+
t8 = /* @__PURE__ */ jsxs(Popover.Root, {
|
|
1061
|
+
size: "xs",
|
|
1062
|
+
children: [t3, t7]
|
|
1063
|
+
});
|
|
1064
|
+
$[15] = t3;
|
|
1065
|
+
$[16] = t7;
|
|
1066
|
+
$[17] = t8;
|
|
1067
|
+
} else t8 = $[17];
|
|
1068
|
+
return t8;
|
|
1069
|
+
}
|
|
1070
|
+
function _temp2(client_0) {
|
|
1071
|
+
return client_0.id;
|
|
1072
|
+
}
|
|
1073
|
+
function _temp(client) {
|
|
1074
|
+
return client.name;
|
|
1075
|
+
}
|
|
1076
|
+
const source = "import { type ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { CheckIcon } from \"lucide-react\";\n\nimport { Button, ButtonPropsProvider } from \"@stealthscale/component-actions\";\nimport { Popover } from \"@stealthscale/component-disclosure\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Listbox, useListCollection } from \"@stealthscale/component-collections\";\n\ninterface Client {\n readonly id: string;\n readonly name: string;\n}\n\nconst CLIENTS = [\"fathom\", \"lantern\", \"pebble\", \"quartz\"] as const;\n\nconst OUTLINED = { variant: \"outline\" } as const;\n\nexport function Triggered(): ReactElement {\n const { t } = useWords(\"listbox\");\n const { collection } = useListCollection<Client>({\n itemToString: (client) => client.name,\n itemToValue: (client) => client.id,\n rows: CLIENTS.map((id) => ({ id, name: t(id) })),\n });\n\n return (\n <Popover.Root size=\"xs\">\n <ButtonPropsProvider value={OUTLINED}>\n <Popover.Trigger as={Button}>{t(\"pick\")}</Popover.Trigger>\n </ButtonPropsProvider>\n {createPortal(\n <Popover.Positioner>\n <Popover.Content>\n <Listbox.Simple<Client>\n aria-label={t(\"clients\")}\n collection={collection}\n defaultValue={[\"fathom\"]}\n mark={<CheckIcon size=\"100%\" />}\n />\n </Popover.Content>\n </Popover.Positioner>,\n document.body,\n )}\n </Popover.Root>\n );\n}\n";
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/listbox/listbox.specimen.tsx
|
|
1079
|
+
/**
|
|
1080
|
+
* Catalogue page for the listbox.
|
|
1081
|
+
*
|
|
1082
|
+
* @remarks
|
|
1083
|
+
* `scenesOf` generates the looks by sizes, selected fills, highlights, palettes, effects, corners
|
|
1084
|
+
* and orientations, each from an example in a room of a sidebar's width, with Fathom selected.
|
|
1085
|
+
* The highlight scene highlights Lantern, so the highlight and the selection show together. The
|
|
1086
|
+
* columns axis has a hand-written scene, because twelve column counts in one room truncate the
|
|
1087
|
+
* port codes past five columns. The other hand-written scenes show props that are not recipe
|
|
1088
|
+
* axes: selection modes, select all, a controlled value, icons, descriptions, groups, a disabled
|
|
1089
|
+
* row, a popover, a windowed list and a filter. Every scene renders a component from `examples/`
|
|
1090
|
+
* and shows that file as its source. The words are keys under `listbox` in
|
|
1091
|
+
* `locales/en/specimen/listbox.json`.
|
|
1092
|
+
*/
|
|
1093
|
+
/**
|
|
1094
|
+
* Selection modes of the modes scene.
|
|
1095
|
+
*/
|
|
1096
|
+
const MODES = [
|
|
1097
|
+
"single",
|
|
1098
|
+
"multiple",
|
|
1099
|
+
"extended"
|
|
1100
|
+
];
|
|
1101
|
+
/**
|
|
1102
|
+
* Props every raised list in a generated scene takes.
|
|
1103
|
+
*/
|
|
1104
|
+
const RAISED = { variant: "surface" };
|
|
1105
|
+
/**
|
|
1106
|
+
* Renders its children and sets `data-highlighted` on the Lantern row.
|
|
1107
|
+
*
|
|
1108
|
+
* @remarks
|
|
1109
|
+
* The machine sets the attribute on the highlighted row only while the list has keyboard focus,
|
|
1110
|
+
* and one list on a page has focus at a time. The attribute is staging, so it never appears in
|
|
1111
|
+
* an example.
|
|
1112
|
+
*/
|
|
1113
|
+
function Highlighted(t0) {
|
|
1114
|
+
const $ = c(5);
|
|
1115
|
+
const { children } = t0;
|
|
1116
|
+
const [box, setBox] = useState(null);
|
|
1117
|
+
let t1;
|
|
1118
|
+
let t2;
|
|
1119
|
+
if ($[0] !== box) {
|
|
1120
|
+
t1 = () => {
|
|
1121
|
+
const row = box?.querySelector("[role=\"option\"][data-value=\"lantern\"]");
|
|
1122
|
+
if (row === void 0 || row === null) return;
|
|
1123
|
+
row.dataset["highlighted"] = "";
|
|
1124
|
+
return () => {
|
|
1125
|
+
delete row.dataset["highlighted"];
|
|
1126
|
+
};
|
|
1127
|
+
};
|
|
1128
|
+
t2 = [box];
|
|
1129
|
+
$[0] = box;
|
|
1130
|
+
$[1] = t1;
|
|
1131
|
+
$[2] = t2;
|
|
1132
|
+
} else {
|
|
1133
|
+
t1 = $[1];
|
|
1134
|
+
t2 = $[2];
|
|
1135
|
+
}
|
|
1136
|
+
useEffect(t1, t2);
|
|
1137
|
+
let t3;
|
|
1138
|
+
if ($[3] !== children) {
|
|
1139
|
+
t3 = /* @__PURE__ */ jsx("div", {
|
|
1140
|
+
ref: setBox,
|
|
1141
|
+
children
|
|
1142
|
+
});
|
|
1143
|
+
$[3] = children;
|
|
1144
|
+
$[4] = t3;
|
|
1145
|
+
} else t3 = $[4];
|
|
1146
|
+
return t3;
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Hand-written scene for the three selection modes, boxed where the list allows several rows.
|
|
1150
|
+
*/
|
|
1151
|
+
const modes = {
|
|
1152
|
+
about: "listbox.modes.about",
|
|
1153
|
+
draw: () => /* @__PURE__ */ jsx(Matrix, {
|
|
1154
|
+
knob: "selectionMode",
|
|
1155
|
+
of: MODES,
|
|
1156
|
+
children: (selectionMode) => /* @__PURE__ */ jsx(Room, {
|
|
1157
|
+
size: "xs",
|
|
1158
|
+
children: /* @__PURE__ */ jsx(Clients, {
|
|
1159
|
+
boxed: selectionMode !== "single",
|
|
1160
|
+
selectionMode,
|
|
1161
|
+
variant: "surface"
|
|
1162
|
+
})
|
|
1163
|
+
})
|
|
1164
|
+
}),
|
|
1165
|
+
example: clients_example_exports,
|
|
1166
|
+
props: {
|
|
1167
|
+
boxed: false,
|
|
1168
|
+
selectionMode: "single",
|
|
1169
|
+
variant: "surface"
|
|
1170
|
+
},
|
|
1171
|
+
title: "listbox.modes.title"
|
|
1172
|
+
};
|
|
1173
|
+
/**
|
|
1174
|
+
* Returns a hand-written scene that renders one example in a room of a sidebar's width.
|
|
1175
|
+
*
|
|
1176
|
+
* @param key - The scene's key under `listbox`.
|
|
1177
|
+
* @param example - The example module the scene shows as its source.
|
|
1178
|
+
* @param Drawing - The example's component.
|
|
1179
|
+
* @param props - Props the scene passes to an example that takes them.
|
|
1180
|
+
* @returns The scene.
|
|
1181
|
+
*/
|
|
1182
|
+
function roomed(key, example, Drawing, props) {
|
|
1183
|
+
return {
|
|
1184
|
+
about: `listbox.${key}.about`,
|
|
1185
|
+
draw: () => /* @__PURE__ */ jsx(Room, {
|
|
1186
|
+
size: "xs",
|
|
1187
|
+
children: /* @__PURE__ */ jsx(Drawing, { ...props })
|
|
1188
|
+
}),
|
|
1189
|
+
example,
|
|
1190
|
+
...props === void 0 ? {} : { props },
|
|
1191
|
+
title: `listbox.${key}.title`
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Hand-written scene for a grid of tiles in four columns.
|
|
1196
|
+
*/
|
|
1197
|
+
const tiles = {
|
|
1198
|
+
about: "listbox.columns.about",
|
|
1199
|
+
axes: ["columns"],
|
|
1200
|
+
draw: () => /* @__PURE__ */ jsx(Room, {
|
|
1201
|
+
size: "md",
|
|
1202
|
+
children: /* @__PURE__ */ jsx(Ports, {})
|
|
1203
|
+
}),
|
|
1204
|
+
example: ports_example_exports,
|
|
1205
|
+
title: "listbox.columns.title"
|
|
1206
|
+
};
|
|
1207
|
+
var listbox_specimen_default = specimen({
|
|
1208
|
+
about: "listbox.about",
|
|
1209
|
+
id: "components/collections/listbox",
|
|
1210
|
+
imports: "import { Listbox } from \"@stealthscale/component-collections\";",
|
|
1211
|
+
scenes: [
|
|
1212
|
+
...scenesOf(recipe, {
|
|
1213
|
+
axes: {
|
|
1214
|
+
effect: { with: {
|
|
1215
|
+
...RAISED,
|
|
1216
|
+
selected: "solid"
|
|
1217
|
+
} },
|
|
1218
|
+
highlight: {
|
|
1219
|
+
draw: (props) => /* @__PURE__ */ jsx(Room, {
|
|
1220
|
+
size: "xs",
|
|
1221
|
+
children: /* @__PURE__ */ jsx(Highlighted, { children: /* @__PURE__ */ jsx(Clients, { ...props }) })
|
|
1222
|
+
}),
|
|
1223
|
+
with: {
|
|
1224
|
+
...RAISED,
|
|
1225
|
+
defaultHighlightedValue: "lantern"
|
|
1226
|
+
}
|
|
1227
|
+
},
|
|
1228
|
+
orientation: {
|
|
1229
|
+
direction: "column",
|
|
1230
|
+
draw: (props) => /* @__PURE__ */ jsx(Room, {
|
|
1231
|
+
size: "sm",
|
|
1232
|
+
children: /* @__PURE__ */ jsx(Described, { ...props })
|
|
1233
|
+
}),
|
|
1234
|
+
example: described_example_exports,
|
|
1235
|
+
with: RAISED
|
|
1236
|
+
},
|
|
1237
|
+
palette: { with: {
|
|
1238
|
+
...RAISED,
|
|
1239
|
+
selected: "solid"
|
|
1240
|
+
} },
|
|
1241
|
+
radius: { with: RAISED },
|
|
1242
|
+
selected: { with: RAISED },
|
|
1243
|
+
variant: { across: "size" }
|
|
1244
|
+
},
|
|
1245
|
+
draw: (props) => /* @__PURE__ */ jsx(Room, {
|
|
1246
|
+
size: "xs",
|
|
1247
|
+
children: /* @__PURE__ */ jsx(Clients, { ...props })
|
|
1248
|
+
}),
|
|
1249
|
+
example: clients_example_exports,
|
|
1250
|
+
namespace: "listbox",
|
|
1251
|
+
order: [
|
|
1252
|
+
"variant",
|
|
1253
|
+
"selected",
|
|
1254
|
+
"highlight",
|
|
1255
|
+
"palette",
|
|
1256
|
+
"effect",
|
|
1257
|
+
"radius",
|
|
1258
|
+
"orientation"
|
|
1259
|
+
],
|
|
1260
|
+
skip: { columns: "twelve counts in one room truncate the codes, so a hand-written scene shows four" }
|
|
1261
|
+
}),
|
|
1262
|
+
tiles,
|
|
1263
|
+
modes,
|
|
1264
|
+
roomed("whole", everything_example_exports, Everything),
|
|
1265
|
+
roomed("outside", held_example_exports, Held),
|
|
1266
|
+
roomed("kinds", kinds_example_exports, Kinds),
|
|
1267
|
+
roomed("described", described_example_exports, Described, RAISED),
|
|
1268
|
+
roomed("grouped", grouped_example_exports, Grouped),
|
|
1269
|
+
roomed("locked", locked_example_exports, Locked),
|
|
1270
|
+
roomed("triggered", triggered_example_exports, Triggered),
|
|
1271
|
+
roomed("many", consignments_example_exports, Consignments),
|
|
1272
|
+
roomed("narrowing", filtered_example_exports, Filtered)
|
|
1273
|
+
],
|
|
1274
|
+
title: "listbox.title"
|
|
1275
|
+
});
|
|
1276
|
+
//#endregion
|
|
1277
|
+
export { listbox_specimen_default as default, modes, tiles };
|