@stealthscale/component-navigation 0.3.0 → 0.3.2

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.
@@ -0,0 +1,859 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { n as recipe } from "../../recipes-BN0p1O6u.js";
3
+ import { d as PageText, f as NextTrigger, h as FirstTrigger, l as Root, m as Items, p as LastTrigger, u as PrevTrigger } from "../../shared-Cz6A-cF-.js";
4
+ import { c } from "react/compiler-runtime";
5
+ import { useState, useSyncExternalStore } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { Matrix, Room, scenesOf, specimen, useWords } from "@stealthscale/specimen";
8
+ import { Text } from "@stealthscale/component-typography";
9
+ import { ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon } from "lucide-react";
10
+ import { Stack } from "@stealthscale/component-layout";
11
+ import { SegmentGroup } from "@stealthscale/component-forms";
12
+ //#region src/pagination/examples/edges.example.tsx
13
+ var edges_example_exports = /* @__PURE__ */ __exportAll({
14
+ Edges: () => Edges,
15
+ source: () => source$4
16
+ });
17
+ function Edges() {
18
+ const $ = c(28);
19
+ const { t } = useWords("pagination");
20
+ let t0;
21
+ if ($[0] !== t) {
22
+ t0 = t("first");
23
+ $[0] = t;
24
+ $[1] = t0;
25
+ } else t0 = $[1];
26
+ let t1;
27
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
28
+ t1 = /* @__PURE__ */ jsx(ChevronsLeftIcon, {});
29
+ $[2] = t1;
30
+ } else t1 = $[2];
31
+ let t2;
32
+ if ($[3] !== t0) {
33
+ t2 = /* @__PURE__ */ jsx(FirstTrigger, {
34
+ label: t0,
35
+ children: t1
36
+ });
37
+ $[3] = t0;
38
+ $[4] = t2;
39
+ } else t2 = $[4];
40
+ let t3;
41
+ if ($[5] !== t) {
42
+ t3 = t("previous");
43
+ $[5] = t;
44
+ $[6] = t3;
45
+ } else t3 = $[6];
46
+ let t4;
47
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
48
+ t4 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
49
+ $[7] = t4;
50
+ } else t4 = $[7];
51
+ let t5;
52
+ if ($[8] !== t3) {
53
+ t5 = /* @__PURE__ */ jsx(PrevTrigger, {
54
+ label: t3,
55
+ children: t4
56
+ });
57
+ $[8] = t3;
58
+ $[9] = t5;
59
+ } else t5 = $[9];
60
+ let t6;
61
+ if ($[10] !== t) {
62
+ t6 = /* @__PURE__ */ jsx(Items, {
63
+ label: (page) => t("page", { page }),
64
+ summary: (t7) => {
65
+ const { page: page_0, totalPages } = t7;
66
+ return t("summary", {
67
+ page: page_0,
68
+ totalPages
69
+ });
70
+ }
71
+ });
72
+ $[10] = t;
73
+ $[11] = t6;
74
+ } else t6 = $[11];
75
+ let t7;
76
+ if ($[12] !== t) {
77
+ t7 = t("next");
78
+ $[12] = t;
79
+ $[13] = t7;
80
+ } else t7 = $[13];
81
+ let t8;
82
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
83
+ t8 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
84
+ $[14] = t8;
85
+ } else t8 = $[14];
86
+ let t9;
87
+ if ($[15] !== t7) {
88
+ t9 = /* @__PURE__ */ jsx(NextTrigger, {
89
+ label: t7,
90
+ children: t8
91
+ });
92
+ $[15] = t7;
93
+ $[16] = t9;
94
+ } else t9 = $[16];
95
+ let t10;
96
+ if ($[17] !== t) {
97
+ t10 = t("last");
98
+ $[17] = t;
99
+ $[18] = t10;
100
+ } else t10 = $[18];
101
+ let t11;
102
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
103
+ t11 = /* @__PURE__ */ jsx(ChevronsRightIcon, {});
104
+ $[19] = t11;
105
+ } else t11 = $[19];
106
+ let t12;
107
+ if ($[20] !== t10) {
108
+ t12 = /* @__PURE__ */ jsx(LastTrigger, {
109
+ label: t10,
110
+ children: t11
111
+ });
112
+ $[20] = t10;
113
+ $[21] = t12;
114
+ } else t12 = $[21];
115
+ let t13;
116
+ if ($[22] !== t12 || $[23] !== t2 || $[24] !== t5 || $[25] !== t6 || $[26] !== t9) {
117
+ t13 = /* @__PURE__ */ jsxs(Root, {
118
+ count: 240,
119
+ defaultPage: 12,
120
+ pageSize: 10,
121
+ siblingCount: 0,
122
+ children: [
123
+ t2,
124
+ t5,
125
+ t6,
126
+ t9,
127
+ t12
128
+ ]
129
+ });
130
+ $[22] = t12;
131
+ $[23] = t2;
132
+ $[24] = t5;
133
+ $[25] = t6;
134
+ $[26] = t9;
135
+ $[27] = t13;
136
+ } else t13 = $[27];
137
+ return t13;
138
+ }
139
+ const source$4 = "import { type ReactElement } from \"react\";\n\nimport {\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n} from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Pagination } from \"@stealthscale/component-navigation\";\n\nexport function Edges(): ReactElement {\n const { t } = useWords(\"pagination\");\n\n return (\n <Pagination.Root count={240} defaultPage={12} pageSize={10} siblingCount={0}>\n <Pagination.FirstTrigger label={t(\"first\")}>\n <ChevronsLeftIcon />\n </Pagination.FirstTrigger>\n <Pagination.PrevTrigger label={t(\"previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.Items\n label={(page) => t(\"page\", { page })}\n summary={({ page, totalPages }) => t(\"summary\", { page, totalPages })}\n />\n <Pagination.NextTrigger label={t(\"next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n <Pagination.LastTrigger label={t(\"last\")}>\n <ChevronsRightIcon />\n </Pagination.LastTrigger>\n </Pagination.Root>\n );\n}\n";
140
+ //#endregion
141
+ //#region src/pagination/examples/invoices.example.tsx
142
+ var invoices_example_exports = /* @__PURE__ */ __exportAll({
143
+ Invoices: () => Invoices,
144
+ source: () => source$3
145
+ });
146
+ const INVOICES = Array.from({ length: 23 }, (_, index) => ({
147
+ amount: (180 + index * 37).toFixed(2),
148
+ number: 2001 + index
149
+ }));
150
+ const SIZES = [
151
+ "5",
152
+ "10",
153
+ "20"
154
+ ];
155
+ function Invoices() {
156
+ const $ = c(55);
157
+ const { t } = useWords("pagination");
158
+ const [page, setPage] = useState(1);
159
+ const [pageSize, setPageSize] = useState(5);
160
+ let T0;
161
+ let T1;
162
+ let t0;
163
+ let t1;
164
+ let t2;
165
+ let t3;
166
+ if ($[0] !== page || $[1] !== pageSize || $[2] !== t) {
167
+ const shown = INVOICES.slice((page - 1) * pageSize, page * pageSize);
168
+ T1 = Stack;
169
+ t3 = "md";
170
+ T0 = Stack;
171
+ t0 = "ul";
172
+ t1 = "xs";
173
+ let t4;
174
+ if ($[9] !== t) {
175
+ t4 = (invoice) => /* @__PURE__ */ jsxs(Stack, {
176
+ as: "li",
177
+ direction: "row",
178
+ justify: "between",
179
+ children: [/* @__PURE__ */ jsx(Text, {
180
+ as: "span",
181
+ children: t("table.invoice", { number: invoice.number })
182
+ }), /* @__PURE__ */ jsx(Text, {
183
+ as: "span",
184
+ tone: "muted",
185
+ children: t("table.amount", { amount: invoice.amount })
186
+ })]
187
+ }, invoice.number);
188
+ $[9] = t;
189
+ $[10] = t4;
190
+ } else t4 = $[10];
191
+ t2 = shown.map(t4);
192
+ $[0] = page;
193
+ $[1] = pageSize;
194
+ $[2] = t;
195
+ $[3] = T0;
196
+ $[4] = T1;
197
+ $[5] = t0;
198
+ $[6] = t1;
199
+ $[7] = t2;
200
+ $[8] = t3;
201
+ } else {
202
+ T0 = $[3];
203
+ T1 = $[4];
204
+ t0 = $[5];
205
+ t1 = $[6];
206
+ t2 = $[7];
207
+ t3 = $[8];
208
+ }
209
+ let t4;
210
+ if ($[11] !== T0 || $[12] !== t0 || $[13] !== t1 || $[14] !== t2) {
211
+ t4 = /* @__PURE__ */ jsx(T0, {
212
+ as: t0,
213
+ gap: t1,
214
+ children: t2
215
+ });
216
+ $[11] = T0;
217
+ $[12] = t0;
218
+ $[13] = t1;
219
+ $[14] = t2;
220
+ $[15] = t4;
221
+ } else t4 = $[15];
222
+ let t5;
223
+ if ($[16] !== t) {
224
+ t5 = t("table.perPage");
225
+ $[16] = t;
226
+ $[17] = t5;
227
+ } else t5 = $[17];
228
+ let t6;
229
+ if ($[18] !== t5) {
230
+ t6 = /* @__PURE__ */ jsx(Text, {
231
+ "aria-hidden": true,
232
+ as: "span",
233
+ size: "sm",
234
+ tone: "muted",
235
+ children: t5
236
+ });
237
+ $[18] = t5;
238
+ $[19] = t6;
239
+ } else t6 = $[19];
240
+ let t7;
241
+ if ($[20] !== t) {
242
+ t7 = t("table.perPage");
243
+ $[20] = t;
244
+ $[21] = t7;
245
+ } else t7 = $[21];
246
+ let t8;
247
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
248
+ t8 = (t9) => {
249
+ const { value } = t9;
250
+ setPageSize(Number(value));
251
+ setPage(1);
252
+ };
253
+ $[22] = t8;
254
+ } else t8 = $[22];
255
+ const t9 = String(pageSize);
256
+ let t10;
257
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
258
+ t10 = SIZES.map(_temp$1);
259
+ $[23] = t10;
260
+ } else t10 = $[23];
261
+ let t11;
262
+ if ($[24] !== t7 || $[25] !== t9) {
263
+ t11 = /* @__PURE__ */ jsx(SegmentGroup.Root, {
264
+ "aria-label": t7,
265
+ onValueChange: t8,
266
+ size: "sm",
267
+ value: t9,
268
+ children: t10
269
+ });
270
+ $[24] = t7;
271
+ $[25] = t9;
272
+ $[26] = t11;
273
+ } else t11 = $[26];
274
+ let t12;
275
+ if ($[27] !== t11 || $[28] !== t6) {
276
+ t12 = /* @__PURE__ */ jsxs(Stack, {
277
+ align: "baseline",
278
+ direction: "row",
279
+ gap: "sm",
280
+ children: [t6, t11]
281
+ });
282
+ $[27] = t11;
283
+ $[28] = t6;
284
+ $[29] = t12;
285
+ } else t12 = $[29];
286
+ let t13;
287
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
288
+ t13 = (details) => {
289
+ setPage(details.page);
290
+ };
291
+ $[30] = t13;
292
+ } else t13 = $[30];
293
+ let t14;
294
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
295
+ t14 = /* @__PURE__ */ jsx(PageText, { format: "long" });
296
+ $[31] = t14;
297
+ } else t14 = $[31];
298
+ let t15;
299
+ if ($[32] !== t) {
300
+ t15 = t("previous");
301
+ $[32] = t;
302
+ $[33] = t15;
303
+ } else t15 = $[33];
304
+ let t16;
305
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
306
+ t16 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
307
+ $[34] = t16;
308
+ } else t16 = $[34];
309
+ let t17;
310
+ if ($[35] !== t15) {
311
+ t17 = /* @__PURE__ */ jsx(PrevTrigger, {
312
+ label: t15,
313
+ children: t16
314
+ });
315
+ $[35] = t15;
316
+ $[36] = t17;
317
+ } else t17 = $[36];
318
+ let t18;
319
+ if ($[37] !== t) {
320
+ t18 = t("next");
321
+ $[37] = t;
322
+ $[38] = t18;
323
+ } else t18 = $[38];
324
+ let t19;
325
+ if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
326
+ t19 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
327
+ $[39] = t19;
328
+ } else t19 = $[39];
329
+ let t20;
330
+ if ($[40] !== t18) {
331
+ t20 = /* @__PURE__ */ jsx(NextTrigger, {
332
+ label: t18,
333
+ children: t19
334
+ });
335
+ $[40] = t18;
336
+ $[41] = t20;
337
+ } else t20 = $[41];
338
+ let t21;
339
+ if ($[42] !== page || $[43] !== pageSize || $[44] !== t17 || $[45] !== t20) {
340
+ t21 = /* @__PURE__ */ jsxs(Root, {
341
+ count: INVOICES.length,
342
+ onPageChange: t13,
343
+ page,
344
+ pageSize,
345
+ size: "sm",
346
+ children: [
347
+ t14,
348
+ t17,
349
+ t20
350
+ ]
351
+ });
352
+ $[42] = page;
353
+ $[43] = pageSize;
354
+ $[44] = t17;
355
+ $[45] = t20;
356
+ $[46] = t21;
357
+ } else t21 = $[46];
358
+ let t22;
359
+ if ($[47] !== t12 || $[48] !== t21) {
360
+ t22 = /* @__PURE__ */ jsxs(Stack, {
361
+ align: "baseline",
362
+ direction: "row",
363
+ gap: "md",
364
+ justify: "between",
365
+ wrap: true,
366
+ children: [t12, t21]
367
+ });
368
+ $[47] = t12;
369
+ $[48] = t21;
370
+ $[49] = t22;
371
+ } else t22 = $[49];
372
+ let t23;
373
+ if ($[50] !== T1 || $[51] !== t22 || $[52] !== t3 || $[53] !== t4) {
374
+ t23 = /* @__PURE__ */ jsxs(T1, {
375
+ gap: t3,
376
+ children: [t4, t22]
377
+ });
378
+ $[50] = T1;
379
+ $[51] = t22;
380
+ $[52] = t3;
381
+ $[53] = t4;
382
+ $[54] = t23;
383
+ } else t23 = $[54];
384
+ return t23;
385
+ }
386
+ function _temp$1(size) {
387
+ return /* @__PURE__ */ jsx(SegmentGroup.Item, {
388
+ value: size,
389
+ children: /* @__PURE__ */ jsx(SegmentGroup.ItemText, { children: size })
390
+ }, size);
391
+ }
392
+ const source$3 = "import { type ReactElement, useState } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { SegmentGroup } from \"@stealthscale/component-forms\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Pagination } from \"@stealthscale/component-navigation\";\n\nconst INVOICES = Array.from({ length: 23 }, (_, index) => ({\n amount: (180 + index * 37).toFixed(2),\n number: 2001 + index,\n}));\n\nconst SIZES = [\"5\", \"10\", \"20\"] as const;\n\nexport function Invoices(): ReactElement {\n const { t } = useWords(\"pagination\");\n const [page, setPage] = useState(1);\n const [pageSize, setPageSize] = useState(5);\n const shown = INVOICES.slice((page - 1) * pageSize, page * pageSize);\n\n return (\n <Stack gap=\"md\">\n <Stack as=\"ul\" gap=\"xs\">\n {shown.map((invoice) => (\n <Stack as=\"li\" direction=\"row\" justify=\"between\" key={invoice.number}>\n <Text as=\"span\">{t(\"table.invoice\", { number: invoice.number })}</Text>\n <Text as=\"span\" tone=\"muted\">\n {t(\"table.amount\", { amount: invoice.amount })}\n </Text>\n </Stack>\n ))}\n </Stack>\n <Stack align=\"baseline\" direction=\"row\" gap=\"md\" justify=\"between\" wrap>\n <Stack align=\"baseline\" direction=\"row\" gap=\"sm\">\n <Text aria-hidden as=\"span\" size=\"sm\" tone=\"muted\">\n {t(\"table.perPage\")}\n </Text>\n <SegmentGroup.Root\n aria-label={t(\"table.perPage\")}\n onValueChange={({ value }) => {\n setPageSize(Number(value));\n setPage(1);\n }}\n size=\"sm\"\n value={String(pageSize)}\n >\n {SIZES.map((size) => (\n <SegmentGroup.Item key={size} value={size}>\n <SegmentGroup.ItemText>{size}</SegmentGroup.ItemText>\n </SegmentGroup.Item>\n ))}\n </SegmentGroup.Root>\n </Stack>\n <Pagination.Root\n count={INVOICES.length}\n onPageChange={(details) => {\n setPage(details.page);\n }}\n page={page}\n pageSize={pageSize}\n size=\"sm\"\n >\n <Pagination.PageText format=\"long\" />\n <Pagination.PrevTrigger label={t(\"previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.NextTrigger label={t(\"next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </Pagination.Root>\n </Stack>\n </Stack>\n );\n}\n";
393
+ //#endregion
394
+ //#region src/pagination/examples/links.example.tsx
395
+ var links_example_exports = /* @__PURE__ */ __exportAll({
396
+ Links: () => Links,
397
+ source: () => source$2
398
+ });
399
+ const ADDRESS = /^#results-page-(\d+)$/u;
400
+ function subscribe(changed) {
401
+ window.addEventListener("hashchange", changed);
402
+ return () => {
403
+ window.removeEventListener("hashchange", changed);
404
+ };
405
+ }
406
+ function Links() {
407
+ const $ = c(19);
408
+ const { t } = useWords("pagination");
409
+ const hash = useSyncExternalStore(subscribe, _temp, _temp2);
410
+ let t0;
411
+ if ($[0] !== hash) {
412
+ t0 = ADDRESS.exec(hash)?.[1] ?? 3;
413
+ $[0] = hash;
414
+ $[1] = t0;
415
+ } else t0 = $[1];
416
+ const current = Number(t0);
417
+ let t1;
418
+ if ($[2] !== t) {
419
+ t1 = t("previous");
420
+ $[2] = t;
421
+ $[3] = t1;
422
+ } else t1 = $[3];
423
+ let t2;
424
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
425
+ t2 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
426
+ $[4] = t2;
427
+ } else t2 = $[4];
428
+ let t3;
429
+ if ($[5] !== t1) {
430
+ t3 = /* @__PURE__ */ jsx(PrevTrigger, {
431
+ label: t1,
432
+ children: t2
433
+ });
434
+ $[5] = t1;
435
+ $[6] = t3;
436
+ } else t3 = $[6];
437
+ let t4;
438
+ if ($[7] !== t) {
439
+ t4 = /* @__PURE__ */ jsx(Items, {
440
+ label: (page_0) => t("page", { page: page_0 }),
441
+ summary: (t5) => {
442
+ const { page: page_1, totalPages } = t5;
443
+ return t("summary", {
444
+ page: page_1,
445
+ totalPages
446
+ });
447
+ }
448
+ });
449
+ $[7] = t;
450
+ $[8] = t4;
451
+ } else t4 = $[8];
452
+ let t5;
453
+ if ($[9] !== t) {
454
+ t5 = t("next");
455
+ $[9] = t;
456
+ $[10] = t5;
457
+ } else t5 = $[10];
458
+ let t6;
459
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
460
+ t6 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
461
+ $[11] = t6;
462
+ } else t6 = $[11];
463
+ let t7;
464
+ if ($[12] !== t5) {
465
+ t7 = /* @__PURE__ */ jsx(NextTrigger, {
466
+ label: t5,
467
+ children: t6
468
+ });
469
+ $[12] = t5;
470
+ $[13] = t7;
471
+ } else t7 = $[13];
472
+ let t8;
473
+ if ($[14] !== current || $[15] !== t3 || $[16] !== t4 || $[17] !== t7) {
474
+ t8 = /* @__PURE__ */ jsxs(Root, {
475
+ count: 90,
476
+ getPageUrl: _temp3,
477
+ page: current,
478
+ pageSize: 10,
479
+ type: "link",
480
+ children: [
481
+ t3,
482
+ t4,
483
+ t7
484
+ ]
485
+ });
486
+ $[14] = current;
487
+ $[15] = t3;
488
+ $[16] = t4;
489
+ $[17] = t7;
490
+ $[18] = t8;
491
+ } else t8 = $[18];
492
+ return t8;
493
+ }
494
+ function _temp3(t0) {
495
+ const { page } = t0;
496
+ return `#results-page-${page}`;
497
+ }
498
+ function _temp2() {
499
+ return "";
500
+ }
501
+ function _temp() {
502
+ return window.location.hash;
503
+ }
504
+ const source$2 = "import { type ReactElement, useSyncExternalStore } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Pagination } from \"@stealthscale/component-navigation\";\n\nconst ADDRESS = /^#results-page-(\\d+)$/u;\n\nfunction subscribe(changed: () => void): () => void {\n window.addEventListener(\"hashchange\", changed);\n\n return () => {\n window.removeEventListener(\"hashchange\", changed);\n };\n}\n\nexport function Links(): ReactElement {\n const { t } = useWords(\"pagination\");\n const hash = useSyncExternalStore(\n subscribe,\n () => window.location.hash,\n () => \"\",\n );\n const current = Number(ADDRESS.exec(hash)?.[1] ?? 3);\n\n return (\n <Pagination.Root\n count={90}\n getPageUrl={({ page }) => `#results-page-${page}`}\n page={current}\n pageSize={10}\n type=\"link\"\n >\n <Pagination.PrevTrigger label={t(\"previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.Items\n label={(page) => t(\"page\", { page })}\n summary={({ page, totalPages }) => t(\"summary\", { page, totalPages })}\n />\n <Pagination.NextTrigger label={t(\"next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </Pagination.Root>\n );\n}\n";
505
+ //#endregion
506
+ //#region src/pagination/examples/results.example.tsx
507
+ var results_example_exports = /* @__PURE__ */ __exportAll({
508
+ Results: () => Results,
509
+ source: () => source$1
510
+ });
511
+ function Results(props) {
512
+ const $ = c(17);
513
+ const { t } = useWords("pagination");
514
+ let t0;
515
+ if ($[0] !== t) {
516
+ t0 = t("previous");
517
+ $[0] = t;
518
+ $[1] = t0;
519
+ } else t0 = $[1];
520
+ let t1;
521
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
522
+ t1 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
523
+ $[2] = t1;
524
+ } else t1 = $[2];
525
+ let t2;
526
+ if ($[3] !== t0) {
527
+ t2 = /* @__PURE__ */ jsx(PrevTrigger, {
528
+ label: t0,
529
+ children: t1
530
+ });
531
+ $[3] = t0;
532
+ $[4] = t2;
533
+ } else t2 = $[4];
534
+ let t3;
535
+ if ($[5] !== t) {
536
+ t3 = /* @__PURE__ */ jsx(Items, {
537
+ label: (page) => t("page", { page }),
538
+ summary: (t4) => {
539
+ const { page: page_0, totalPages } = t4;
540
+ return t("summary", {
541
+ page: page_0,
542
+ totalPages
543
+ });
544
+ }
545
+ });
546
+ $[5] = t;
547
+ $[6] = t3;
548
+ } else t3 = $[6];
549
+ let t4;
550
+ if ($[7] !== t) {
551
+ t4 = t("next");
552
+ $[7] = t;
553
+ $[8] = t4;
554
+ } else t4 = $[8];
555
+ let t5;
556
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
557
+ t5 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
558
+ $[9] = t5;
559
+ } else t5 = $[9];
560
+ let t6;
561
+ if ($[10] !== t4) {
562
+ t6 = /* @__PURE__ */ jsx(NextTrigger, {
563
+ label: t4,
564
+ children: t5
565
+ });
566
+ $[10] = t4;
567
+ $[11] = t6;
568
+ } else t6 = $[11];
569
+ let t7;
570
+ if ($[12] !== props || $[13] !== t2 || $[14] !== t3 || $[15] !== t6) {
571
+ t7 = /* @__PURE__ */ jsxs(Root, {
572
+ count: 240,
573
+ defaultPage: 12,
574
+ pageSize: 10,
575
+ ...props,
576
+ children: [
577
+ t2,
578
+ t3,
579
+ t6
580
+ ]
581
+ });
582
+ $[12] = props;
583
+ $[13] = t2;
584
+ $[14] = t3;
585
+ $[15] = t6;
586
+ $[16] = t7;
587
+ } else t7 = $[16];
588
+ return t7;
589
+ }
590
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Pagination } from \"@stealthscale/component-navigation\";\n\nexport function Results(props: Pagination.RootProps): ReactElement {\n const { t } = useWords(\"pagination\");\n\n return (\n <Pagination.Root count={240} defaultPage={12} pageSize={10} {...props}>\n <Pagination.PrevTrigger label={t(\"previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.Items\n label={(page) => t(\"page\", { page })}\n summary={({ page, totalPages }) => t(\"summary\", { page, totalPages })}\n />\n <Pagination.NextTrigger label={t(\"next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </Pagination.Root>\n );\n}\n";
591
+ //#endregion
592
+ //#region src/pagination/examples/wording.example.tsx
593
+ var wording_example_exports = /* @__PURE__ */ __exportAll({
594
+ Wording: () => Wording,
595
+ source: () => source
596
+ });
597
+ function Wording(props) {
598
+ const $ = c(16);
599
+ const { t } = useWords("pagination");
600
+ let t0;
601
+ if ($[0] !== t) {
602
+ t0 = t("previous");
603
+ $[0] = t;
604
+ $[1] = t0;
605
+ } else t0 = $[1];
606
+ let t1;
607
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
608
+ t1 = /* @__PURE__ */ jsx(ChevronLeftIcon, {});
609
+ $[2] = t1;
610
+ } else t1 = $[2];
611
+ let t2;
612
+ if ($[3] !== t0) {
613
+ t2 = /* @__PURE__ */ jsx(PrevTrigger, {
614
+ label: t0,
615
+ children: t1
616
+ });
617
+ $[3] = t0;
618
+ $[4] = t2;
619
+ } else t2 = $[4];
620
+ let t3;
621
+ if ($[5] !== props) {
622
+ t3 = /* @__PURE__ */ jsx(PageText, { ...props });
623
+ $[5] = props;
624
+ $[6] = t3;
625
+ } else t3 = $[6];
626
+ let t4;
627
+ if ($[7] !== t) {
628
+ t4 = t("next");
629
+ $[7] = t;
630
+ $[8] = t4;
631
+ } else t4 = $[8];
632
+ let t5;
633
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
634
+ t5 = /* @__PURE__ */ jsx(ChevronRightIcon, {});
635
+ $[9] = t5;
636
+ } else t5 = $[9];
637
+ let t6;
638
+ if ($[10] !== t4) {
639
+ t6 = /* @__PURE__ */ jsx(NextTrigger, {
640
+ label: t4,
641
+ children: t5
642
+ });
643
+ $[10] = t4;
644
+ $[11] = t6;
645
+ } else t6 = $[11];
646
+ let t7;
647
+ if ($[12] !== t2 || $[13] !== t3 || $[14] !== t6) {
648
+ t7 = /* @__PURE__ */ jsxs(Root, {
649
+ count: 240,
650
+ defaultPage: 12,
651
+ pageSize: 10,
652
+ size: "sm",
653
+ children: [
654
+ t2,
655
+ t3,
656
+ t6
657
+ ]
658
+ });
659
+ $[12] = t2;
660
+ $[13] = t3;
661
+ $[14] = t6;
662
+ $[15] = t7;
663
+ } else t7 = $[15];
664
+ return t7;
665
+ }
666
+ const source = "import { type ReactElement } from \"react\";\n\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Pagination } from \"@stealthscale/component-navigation\";\n\nexport function Wording(props: Pagination.PageTextProps): ReactElement {\n const { t } = useWords(\"pagination\");\n\n return (\n <Pagination.Root count={240} defaultPage={12} pageSize={10} size=\"sm\">\n <Pagination.PrevTrigger label={t(\"previous\")}>\n <ChevronLeftIcon />\n </Pagination.PrevTrigger>\n <Pagination.PageText {...props} />\n <Pagination.NextTrigger label={t(\"next\")}>\n <ChevronRightIcon />\n </Pagination.NextTrigger>\n </Pagination.Root>\n );\n}\n";
667
+ //#endregion
668
+ //#region src/pagination/pagination.specimen.tsx
669
+ /**
670
+ * Catalogue page for the pagination.
671
+ *
672
+ * @remarks
673
+ * `scenesOf` generates the sizes from the results example, which starts on page 12 of 24, so
674
+ * every row shows the marks on both sides. The hand-written scenes turn the buttons' look, their
675
+ * palette, `siblingCount` and the page text's format, and show the first and last triggers, a row
676
+ * too narrow for its pages, a controlled pagination under a list, and pages as links. Every row
677
+ * renders in a room at its real width. The words are keys under `pagination` in
678
+ * `locales/en/specimen/pagination.json`.
679
+ */
680
+ /**
681
+ * Looks of the looks scene: the button looks that mark the current page with a fill.
682
+ */
683
+ const LOOKS = [
684
+ "ghost",
685
+ "outline",
686
+ "subtle"
687
+ ];
688
+ /**
689
+ * Palettes of the palette scene.
690
+ */
691
+ const PALETTES = [
692
+ "primary",
693
+ "accent",
694
+ "neutral",
695
+ "success"
696
+ ];
697
+ /**
698
+ * Sibling counts of the siblings scene.
699
+ */
700
+ const SIBLINGS = [
701
+ 0,
702
+ 1,
703
+ 2
704
+ ];
705
+ /**
706
+ * Formats of the page text scene.
707
+ */
708
+ const FORMATS = [
709
+ "compact",
710
+ "short",
711
+ "long"
712
+ ];
713
+ /**
714
+ * Hand-written scene for every look of the buttons.
715
+ */
716
+ const looks = {
717
+ about: "pagination.looks.about",
718
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
719
+ direction: "column",
720
+ knob: "variant",
721
+ of: LOOKS,
722
+ children: (variant) => /* @__PURE__ */ jsx(Room, {
723
+ size: "md",
724
+ children: /* @__PURE__ */ jsx(Results, { variant })
725
+ })
726
+ }),
727
+ example: results_example_exports,
728
+ props: { variant: "ghost" },
729
+ title: "pagination.looks.title"
730
+ };
731
+ /**
732
+ * Hand-written scene for the buttons in several palettes.
733
+ */
734
+ const palette = {
735
+ about: "pagination.palette.about",
736
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
737
+ direction: "column",
738
+ knob: "palette",
739
+ of: PALETTES,
740
+ children: (each) => /* @__PURE__ */ jsx(Room, {
741
+ size: "md",
742
+ children: /* @__PURE__ */ jsx(Results, { palette: each })
743
+ })
744
+ }),
745
+ example: results_example_exports,
746
+ props: { palette: "primary" },
747
+ title: "pagination.palette.title"
748
+ };
749
+ /**
750
+ * Hand-written scene for every sibling count.
751
+ */
752
+ const siblings = {
753
+ about: "pagination.siblings.about",
754
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
755
+ direction: "column",
756
+ knob: "siblingCount",
757
+ of: SIBLINGS,
758
+ children: (count) => /* @__PURE__ */ jsx(Room, {
759
+ size: "lg",
760
+ children: /* @__PURE__ */ jsx(Results, { siblingCount: count })
761
+ })
762
+ }),
763
+ example: results_example_exports,
764
+ props: { siblingCount: 0 },
765
+ title: "pagination.siblings.title"
766
+ };
767
+ /**
768
+ * Hand-written scene for the first and last triggers.
769
+ */
770
+ const edges = {
771
+ about: "pagination.edges.about",
772
+ draw: () => /* @__PURE__ */ jsx(Room, {
773
+ size: "md",
774
+ children: /* @__PURE__ */ jsx(Edges, {})
775
+ }),
776
+ example: edges_example_exports,
777
+ title: "pagination.edges.title"
778
+ };
779
+ /**
780
+ * Hand-written scene for a row too narrow for its pages, which the summary replaces.
781
+ */
782
+ const narrow = {
783
+ about: "pagination.narrow.about",
784
+ draw: () => /* @__PURE__ */ jsx(Room, {
785
+ size: "xs",
786
+ children: /* @__PURE__ */ jsx(Results, {})
787
+ }),
788
+ example: results_example_exports,
789
+ title: "pagination.narrow.title"
790
+ };
791
+ /**
792
+ * Hand-written scene for every format of the page text.
793
+ */
794
+ const text = {
795
+ about: "pagination.text.about",
796
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
797
+ direction: "column",
798
+ knob: "format",
799
+ of: FORMATS,
800
+ children: (format) => /* @__PURE__ */ jsx(Room, {
801
+ size: "sm",
802
+ children: /* @__PURE__ */ jsx(Wording, { format })
803
+ })
804
+ }),
805
+ example: wording_example_exports,
806
+ props: { format: "compact" },
807
+ title: "pagination.text.title"
808
+ };
809
+ /**
810
+ * Hand-written scene for a controlled pagination under a list.
811
+ */
812
+ const table = {
813
+ about: "pagination.table.about",
814
+ draw: () => /* @__PURE__ */ jsx(Room, {
815
+ size: "md",
816
+ children: /* @__PURE__ */ jsx(Invoices, {})
817
+ }),
818
+ example: invoices_example_exports,
819
+ title: "pagination.table.title"
820
+ };
821
+ /**
822
+ * Hand-written scene for pages as links.
823
+ */
824
+ const links = {
825
+ about: "pagination.links.about",
826
+ draw: () => /* @__PURE__ */ jsx(Room, {
827
+ size: "md",
828
+ children: /* @__PURE__ */ jsx(Links, {})
829
+ }),
830
+ example: links_example_exports,
831
+ title: "pagination.links.title"
832
+ };
833
+ var pagination_specimen_default = specimen({
834
+ about: "pagination.about",
835
+ id: "components/navigation/pagination",
836
+ imports: "import { Pagination } from \"@stealthscale/component-navigation\";",
837
+ scenes: [
838
+ ...scenesOf(recipe, {
839
+ axes: { size: { direction: "column" } },
840
+ draw: (props) => /* @__PURE__ */ jsx(Room, {
841
+ size: "lg",
842
+ children: /* @__PURE__ */ jsx(Results, { ...props })
843
+ }),
844
+ example: results_example_exports,
845
+ namespace: "pagination"
846
+ }),
847
+ looks,
848
+ palette,
849
+ siblings,
850
+ edges,
851
+ narrow,
852
+ text,
853
+ table,
854
+ links
855
+ ],
856
+ title: "pagination.title"
857
+ });
858
+ //#endregion
859
+ export { pagination_specimen_default as default, edges, links, looks, narrow, palette, siblings, table, text };