@stealthscale/component-screen 0.2.1 → 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.
Files changed (44) hide show
  1. package/dist/cyclonedx/bom.json +1 -1
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +1 -8216
  4. package/dist/pages/action-bar/action-bar.js +471 -0
  5. package/dist/pages/action-bar/action-bar.props.js +3 -0
  6. package/dist/pages/app-shell/app-shell.js +4899 -0
  7. package/dist/pages/app-shell/app-shell.props.js +3 -0
  8. package/dist/pages/floating-panel/floating-panel.js +995 -0
  9. package/dist/pages/floating-panel/floating-panel.props.js +3 -0
  10. package/dist/pages/locale-switcher/locale-switcher.js +180 -0
  11. package/dist/pages/locale-switcher/locale-switcher.props.js +3 -0
  12. package/dist/pages/page/page.js +2308 -0
  13. package/dist/pages/page/page.props.js +3 -0
  14. package/dist/pages/pages.json +123 -0
  15. package/dist/pages/section/section.js +1241 -0
  16. package/dist/pages/section/section.props.js +3 -0
  17. package/dist/pages/sidebar/sidebar.js +1743 -0
  18. package/dist/pages/sidebar/sidebar.props.js +3 -0
  19. package/dist/pages/splitter/splitter.js +1563 -0
  20. package/dist/pages/splitter/splitter.props.js +3 -0
  21. package/dist/pages/switcher/switcher.js +900 -0
  22. package/dist/pages/switcher/switcher.props.js +3 -0
  23. package/dist/pages/theme-switcher/theme-switcher.js +180 -0
  24. package/dist/pages/theme-switcher/theme-switcher.props.js +3 -0
  25. package/dist/pages/toolbar/toolbar.js +1045 -0
  26. package/dist/pages/toolbar/toolbar.props.js +3 -0
  27. package/dist/{recipe-sZAQY6Kq.js → recipes-Cmy1leBm.js} +312 -30
  28. package/dist/shared-DxlFabHA.js +9547 -0
  29. package/dist/shell.js +1 -165
  30. package/dist/theme.js +3 -4
  31. package/locales/en/specimen/action-bar.json +46 -0
  32. package/locales/en/specimen/app-shell.json +288 -0
  33. package/locales/en/specimen/floating-panel.json +70 -0
  34. package/locales/en/specimen/locale-switcher.json +15 -0
  35. package/locales/en/specimen/page.json +198 -0
  36. package/locales/en/specimen/section.json +91 -0
  37. package/locales/en/specimen/sidebar.json +87 -0
  38. package/locales/en/specimen/splitter.json +93 -0
  39. package/locales/en/specimen/switcher.json +61 -0
  40. package/locales/en/specimen/theme-switcher.json +15 -0
  41. package/locales/en/specimen/toolbar.json +80 -0
  42. package/package.json +25 -24
  43. package/dist/recipe-DRMsitrw.js +0 -283
  44. package/dist/root-qEh4u7y5.js +0 -1182
@@ -0,0 +1,900 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { n as recipe } from "../../recipes-Cmy1leBm.js";
3
+ import { A as Nav, At as Trigger, Bt as Body, It as Navbar, L as Content, Lt as Main, Nt as Root$3, O as Search, P as Header$1, Rt as Header, _ as Name, a as Start, b as Action$1, c as Root$1, d as End, f as Center, g as Trigger$1, h as Root, j as NavLabel, k as Root$2, p as Action, qt as Item, v as Label, y as Indicator } from "../../shared-DxlFabHA.js";
4
+ import { c } from "react/compiler-runtime";
5
+ import { Button, ButtonPropsProvider } from "@stealthscale/component-actions";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useState } from "react";
8
+ import { Portal } from "@stealthscale/component-primitives";
9
+ import { Menu } from "@stealthscale/component-disclosure";
10
+ import { NavList } from "@stealthscale/component-navigation";
11
+ import { Stack } from "@stealthscale/component-layout";
12
+ import { Room, Sample, Screen, scenesOf, specimen, useWords } from "@stealthscale/specimen";
13
+ import { Building2Icon, CheckIcon, ChevronsUpDownIcon, GitBranchIcon, HouseIcon, MenuIcon, PlayIcon, PlusIcon, RocketIcon, SearchIcon, SettingsIcon } from "lucide-react";
14
+ import { Text } from "@stealthscale/component-typography";
15
+ //#region src/switcher/examples/bar.example.tsx
16
+ var bar_example_exports = /* @__PURE__ */ __exportAll({
17
+ Bar: () => Bar,
18
+ source: () => source$4
19
+ });
20
+ const WORKSPACES$2 = [
21
+ ["ledger", "production"],
22
+ ["northwind", "trial"],
23
+ ["acme", "enterprise"]
24
+ ];
25
+ function Bar() {
26
+ const $ = c(25);
27
+ const { t } = useWords("switcher");
28
+ let t0;
29
+ if ($[0] !== t) {
30
+ t0 = t("application");
31
+ $[0] = t;
32
+ $[1] = t0;
33
+ } else t0 = $[1];
34
+ let t1;
35
+ let t2;
36
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
+ t1 = /* @__PURE__ */ jsx(CheckIcon, { size: "1em" });
38
+ t2 = /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: "1em" });
39
+ $[2] = t1;
40
+ $[3] = t2;
41
+ } else {
42
+ t1 = $[2];
43
+ t2 = $[3];
44
+ }
45
+ let t3;
46
+ if ($[4] !== t) {
47
+ t3 = WORKSPACES$2.map((t4) => {
48
+ const [name, plan] = t4;
49
+ return {
50
+ detail: t(plan),
51
+ label: t(name),
52
+ value: name
53
+ };
54
+ });
55
+ $[4] = t;
56
+ $[5] = t3;
57
+ } else t3 = $[5];
58
+ let t4;
59
+ if ($[6] !== t) {
60
+ t4 = t("workspace");
61
+ $[6] = t;
62
+ $[7] = t4;
63
+ } else t4 = $[7];
64
+ let t5;
65
+ if ($[8] !== t3 || $[9] !== t4) {
66
+ t5 = /* @__PURE__ */ jsx(Start, { children: /* @__PURE__ */ jsx(Root, {
67
+ checkIcon: t1,
68
+ indicator: t2,
69
+ items: t3,
70
+ label: t4
71
+ }) });
72
+ $[8] = t3;
73
+ $[9] = t4;
74
+ $[10] = t5;
75
+ } else t5 = $[10];
76
+ let t6;
77
+ if ($[11] !== t) {
78
+ t6 = t("runs");
79
+ $[11] = t;
80
+ $[12] = t6;
81
+ } else t6 = $[12];
82
+ let t7;
83
+ if ($[13] !== t6) {
84
+ t7 = /* @__PURE__ */ jsx(Center, { children: /* @__PURE__ */ jsx(Text, {
85
+ as: "span",
86
+ size: "sm",
87
+ weight: "medium",
88
+ children: t6
89
+ }) });
90
+ $[13] = t6;
91
+ $[14] = t7;
92
+ } else t7 = $[14];
93
+ let t8;
94
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
95
+ t8 = /* @__PURE__ */ jsx(PlayIcon, { size: "1em" });
96
+ $[15] = t8;
97
+ } else t8 = $[15];
98
+ let t9;
99
+ if ($[16] !== t) {
100
+ t9 = t("newRun");
101
+ $[16] = t;
102
+ $[17] = t9;
103
+ } else t9 = $[17];
104
+ let t10;
105
+ if ($[18] !== t9) {
106
+ t10 = /* @__PURE__ */ jsx(End, { children: /* @__PURE__ */ jsx(Action, {
107
+ icon: t8,
108
+ primary: true,
109
+ children: t9
110
+ }) });
111
+ $[18] = t9;
112
+ $[19] = t10;
113
+ } else t10 = $[19];
114
+ let t11;
115
+ if ($[20] !== t0 || $[21] !== t10 || $[22] !== t5 || $[23] !== t7) {
116
+ t11 = /* @__PURE__ */ jsxs(Root$1, {
117
+ "aria-label": t0,
118
+ size: "sm",
119
+ children: [
120
+ t5,
121
+ t7,
122
+ t10
123
+ ]
124
+ });
125
+ $[20] = t0;
126
+ $[21] = t10;
127
+ $[22] = t5;
128
+ $[23] = t7;
129
+ $[24] = t11;
130
+ } else t11 = $[24];
131
+ return t11;
132
+ }
133
+ const source$4 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, ChevronsUpDownIcon, PlayIcon } from \"lucide-react\";\n\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Switcher, Toolbar } from \"@stealthscale/component-screen\";\n\nconst WORKSPACES = [\n [\"ledger\", \"production\"],\n [\"northwind\", \"trial\"],\n [\"acme\", \"enterprise\"],\n] as const;\n\nexport function Bar(): ReactElement {\n const { t } = useWords(\"switcher\");\n\n return (\n <Toolbar.Root aria-label={t(\"application\")} size=\"sm\">\n <Toolbar.Start>\n <Switcher.Root\n checkIcon={<CheckIcon size=\"1em\" />}\n indicator={<ChevronsUpDownIcon size=\"1em\" />}\n items={WORKSPACES.map(([name, plan]) => ({\n detail: t(plan),\n label: t(name),\n value: name,\n }))}\n label={t(\"workspace\")}\n />\n </Toolbar.Start>\n <Toolbar.Center>\n <Text as=\"span\" size=\"sm\" weight=\"medium\">\n {t(\"runs\")}\n </Text>\n </Toolbar.Center>\n <Toolbar.End>\n <Toolbar.Action icon={<PlayIcon size=\"1em\" />} primary>\n {t(\"newRun\")}\n </Toolbar.Action>\n </Toolbar.End>\n </Toolbar.Root>\n );\n}\n";
134
+ //#endregion
135
+ //#region src/switcher/examples/console.example.tsx
136
+ var console_example_exports = /* @__PURE__ */ __exportAll({
137
+ Console: () => Console,
138
+ source: () => source$3
139
+ });
140
+ const GHOST = {
141
+ shape: "square",
142
+ size: "sm",
143
+ variant: "ghost"
144
+ };
145
+ const WORKSPACES$1 = [
146
+ ["ledger", "production"],
147
+ ["northwind", "trial"],
148
+ ["acme", "enterprise"]
149
+ ];
150
+ const PAGES = [
151
+ [
152
+ "overview",
153
+ HouseIcon,
154
+ void 0
155
+ ],
156
+ [
157
+ "runs",
158
+ PlayIcon,
159
+ "page"
160
+ ],
161
+ [
162
+ "pipelines",
163
+ GitBranchIcon,
164
+ void 0
165
+ ]
166
+ ];
167
+ function Console(props) {
168
+ const $ = c(52);
169
+ const { t } = useWords("switcher");
170
+ let t0;
171
+ if ($[0] !== t) {
172
+ t0 = t("navigation");
173
+ $[0] = t;
174
+ $[1] = t0;
175
+ } else t0 = $[1];
176
+ let t1;
177
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
178
+ t1 = /* @__PURE__ */ jsx(MenuIcon, {});
179
+ $[2] = t1;
180
+ } else t1 = $[2];
181
+ let t2;
182
+ if ($[3] !== t0) {
183
+ t2 = /* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(ButtonPropsProvider, {
184
+ value: GHOST,
185
+ children: /* @__PURE__ */ jsx(Trigger, {
186
+ "aria-label": t0,
187
+ as: Button,
188
+ children: t1
189
+ })
190
+ }) });
191
+ $[3] = t0;
192
+ $[4] = t2;
193
+ } else t2 = $[4];
194
+ let t3;
195
+ let t4;
196
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
197
+ t3 = /* @__PURE__ */ jsx(CheckIcon, { size: "1em" });
198
+ t4 = /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: "1em" });
199
+ $[5] = t3;
200
+ $[6] = t4;
201
+ } else {
202
+ t3 = $[5];
203
+ t4 = $[6];
204
+ }
205
+ let t5;
206
+ if ($[7] !== t) {
207
+ t5 = WORKSPACES$1.map((t6) => {
208
+ const [name, plan] = t6;
209
+ return {
210
+ detail: t(plan),
211
+ label: t(name),
212
+ value: name
213
+ };
214
+ });
215
+ $[7] = t;
216
+ $[8] = t5;
217
+ } else t5 = $[8];
218
+ let t6;
219
+ if ($[9] !== t) {
220
+ t6 = t("workspace");
221
+ $[9] = t;
222
+ $[10] = t6;
223
+ } else t6 = $[10];
224
+ let t7;
225
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
226
+ t7 = /* @__PURE__ */ jsx(PlusIcon, { size: "1em" });
227
+ $[11] = t7;
228
+ } else t7 = $[11];
229
+ let t8;
230
+ if ($[12] !== t) {
231
+ t8 = t("new");
232
+ $[12] = t;
233
+ $[13] = t8;
234
+ } else t8 = $[13];
235
+ let t9;
236
+ if ($[14] !== t8) {
237
+ t9 = /* @__PURE__ */ jsx(Action$1, {
238
+ icon: t7,
239
+ children: t8
240
+ });
241
+ $[14] = t8;
242
+ $[15] = t9;
243
+ } else t9 = $[15];
244
+ let t10;
245
+ if ($[16] !== t5 || $[17] !== t6 || $[18] !== t9) {
246
+ t10 = /* @__PURE__ */ jsx(Root, {
247
+ checkIcon: t3,
248
+ indicator: t4,
249
+ items: t5,
250
+ label: t6,
251
+ children: t9
252
+ });
253
+ $[16] = t5;
254
+ $[17] = t6;
255
+ $[18] = t9;
256
+ $[19] = t10;
257
+ } else t10 = $[19];
258
+ let t11;
259
+ if ($[20] !== t) {
260
+ t11 = t("findPage");
261
+ $[20] = t;
262
+ $[21] = t11;
263
+ } else t11 = $[21];
264
+ let t12;
265
+ if ($[22] !== t) {
266
+ t12 = t("filter");
267
+ $[22] = t;
268
+ $[23] = t12;
269
+ } else t12 = $[23];
270
+ let t13;
271
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
272
+ t13 = /* @__PURE__ */ jsx(SearchIcon, {});
273
+ $[24] = t13;
274
+ } else t13 = $[24];
275
+ let t14;
276
+ if ($[25] !== t11 || $[26] !== t12) {
277
+ t14 = /* @__PURE__ */ jsx(Search, {
278
+ "aria-label": t11,
279
+ placeholder: t12,
280
+ searchIndicator: t13
281
+ });
282
+ $[25] = t11;
283
+ $[26] = t12;
284
+ $[27] = t14;
285
+ } else t14 = $[27];
286
+ let t15;
287
+ if ($[28] !== t10 || $[29] !== t14) {
288
+ t15 = /* @__PURE__ */ jsxs(Header$1, { children: [t10, t14] });
289
+ $[28] = t10;
290
+ $[29] = t14;
291
+ $[30] = t15;
292
+ } else t15 = $[30];
293
+ let t16;
294
+ if ($[31] !== t) {
295
+ t16 = t("platform");
296
+ $[31] = t;
297
+ $[32] = t16;
298
+ } else t16 = $[32];
299
+ let t17;
300
+ if ($[33] !== t16) {
301
+ t17 = /* @__PURE__ */ jsx(NavLabel, {
302
+ as: "h3",
303
+ children: t16
304
+ });
305
+ $[33] = t16;
306
+ $[34] = t17;
307
+ } else t17 = $[34];
308
+ let t18;
309
+ if ($[35] !== t) {
310
+ t18 = PAGES.map((t19) => {
311
+ const [page, Glyph, current] = t19;
312
+ return /* @__PURE__ */ jsx(NavList.Item, { children: /* @__PURE__ */ jsxs(NavList.Link, {
313
+ "aria-current": current,
314
+ href: `#${page}`,
315
+ tooltip: t(page),
316
+ children: [/* @__PURE__ */ jsx(Glyph, {}), /* @__PURE__ */ jsx("span", { children: t(page) })]
317
+ }) }, page);
318
+ });
319
+ $[35] = t;
320
+ $[36] = t18;
321
+ } else t18 = $[36];
322
+ let t19;
323
+ if ($[37] !== t18) {
324
+ t19 = /* @__PURE__ */ jsx(NavList.Root, { children: t18 });
325
+ $[37] = t18;
326
+ $[38] = t19;
327
+ } else t19 = $[38];
328
+ let t20;
329
+ if ($[39] !== t17 || $[40] !== t19) {
330
+ t20 = /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsxs(Nav, { children: [t17, t19] }) });
331
+ $[39] = t17;
332
+ $[40] = t19;
333
+ $[41] = t20;
334
+ } else t20 = $[41];
335
+ let t21;
336
+ if ($[42] !== t15 || $[43] !== t20) {
337
+ t21 = /* @__PURE__ */ jsx(Navbar, {
338
+ collapse: "icons",
339
+ foldsBelow: "sm",
340
+ children: /* @__PURE__ */ jsxs(Root$2, {
341
+ variant: "subtle",
342
+ children: [t15, t20]
343
+ })
344
+ });
345
+ $[42] = t15;
346
+ $[43] = t20;
347
+ $[44] = t21;
348
+ } else t21 = $[44];
349
+ let t22;
350
+ if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
351
+ t22 = /* @__PURE__ */ jsx(Main, {});
352
+ $[45] = t22;
353
+ } else t22 = $[45];
354
+ let t23;
355
+ if ($[46] !== t21) {
356
+ t23 = /* @__PURE__ */ jsxs(Body, { children: [t21, t22] });
357
+ $[46] = t21;
358
+ $[47] = t23;
359
+ } else t23 = $[47];
360
+ let t24;
361
+ if ($[48] !== props || $[49] !== t2 || $[50] !== t23) {
362
+ t24 = /* @__PURE__ */ jsxs(Root$3, {
363
+ ...props,
364
+ children: [t2, t23]
365
+ });
366
+ $[48] = props;
367
+ $[49] = t2;
368
+ $[50] = t23;
369
+ $[51] = t24;
370
+ } else t24 = $[51];
371
+ return t24;
372
+ }
373
+ const source$3 = "import { type ReactElement } from \"react\";\n\nimport {\n CheckIcon,\n ChevronsUpDownIcon,\n GitBranchIcon,\n HouseIcon,\n MenuIcon,\n PlayIcon,\n PlusIcon,\n SearchIcon,\n} from \"lucide-react\";\n\nimport { Button, ButtonPropsProvider } from \"@stealthscale/component-actions\";\nimport { NavList } from \"@stealthscale/component-navigation\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { AppShell, Sidebar, Switcher } from \"@stealthscale/component-screen\";\n\nconst GHOST = { shape: \"square\", size: \"sm\", variant: \"ghost\" } as const;\n\nconst WORKSPACES = [\n [\"ledger\", \"production\"],\n [\"northwind\", \"trial\"],\n [\"acme\", \"enterprise\"],\n] as const;\n\nconst PAGES = [\n [\"overview\", HouseIcon, undefined],\n [\"runs\", PlayIcon, \"page\"],\n [\"pipelines\", GitBranchIcon, undefined],\n] as const;\n\nexport function Console(props: AppShell.RootProps): ReactElement {\n const { t } = useWords(\"switcher\");\n\n return (\n <AppShell.Root {...props}>\n <AppShell.Header>\n <ButtonPropsProvider value={GHOST}>\n <AppShell.Trigger aria-label={t(\"navigation\")} as={Button}>\n <MenuIcon />\n </AppShell.Trigger>\n </ButtonPropsProvider>\n </AppShell.Header>\n <AppShell.Body>\n <AppShell.Navbar collapse=\"icons\" foldsBelow=\"sm\">\n <Sidebar.Root variant=\"subtle\">\n <Sidebar.Header>\n <Switcher.Root\n checkIcon={<CheckIcon size=\"1em\" />}\n indicator={<ChevronsUpDownIcon size=\"1em\" />}\n items={WORKSPACES.map(([name, plan]) => ({\n detail: t(plan),\n label: t(name),\n value: name,\n }))}\n label={t(\"workspace\")}\n >\n <Switcher.Action icon={<PlusIcon size=\"1em\" />}>{t(\"new\")}</Switcher.Action>\n </Switcher.Root>\n <Sidebar.Search\n aria-label={t(\"findPage\")}\n placeholder={t(\"filter\")}\n searchIndicator={<SearchIcon />}\n />\n </Sidebar.Header>\n <Sidebar.Content>\n <Sidebar.Nav>\n <Sidebar.NavLabel as=\"h3\">{t(\"platform\")}</Sidebar.NavLabel>\n <NavList.Root>\n {PAGES.map(([page, Glyph, current]) => (\n <NavList.Item key={page}>\n <NavList.Link aria-current={current} href={`#${page}`} tooltip={t(page)}>\n <Glyph />\n <span>{t(page)}</span>\n </NavList.Link>\n </NavList.Item>\n ))}\n </NavList.Root>\n </Sidebar.Nav>\n </Sidebar.Content>\n </Sidebar.Root>\n </AppShell.Navbar>\n <AppShell.Main />\n </AppShell.Body>\n </AppShell.Root>\n );\n}\n";
374
+ //#endregion
375
+ //#region src/switcher/examples/environment.example.tsx
376
+ var environment_example_exports = /* @__PURE__ */ __exportAll({
377
+ Environment: () => Environment,
378
+ source: () => source$2
379
+ });
380
+ const STAGES = [
381
+ "production",
382
+ "staging",
383
+ "preview"
384
+ ];
385
+ function Environment(props) {
386
+ const $ = c(31);
387
+ const { t } = useWords("switcher");
388
+ const [chosen, setChosen] = useState("production");
389
+ let t0;
390
+ if ($[0] !== t) {
391
+ t0 = t("deployments");
392
+ $[0] = t;
393
+ $[1] = t0;
394
+ } else t0 = $[1];
395
+ let t1;
396
+ if ($[2] !== t) {
397
+ t1 = t("environment");
398
+ $[2] = t;
399
+ $[3] = t1;
400
+ } else t1 = $[3];
401
+ let t2;
402
+ if ($[4] !== chosen || $[5] !== t) {
403
+ t2 = t(chosen);
404
+ $[4] = chosen;
405
+ $[5] = t;
406
+ $[6] = t2;
407
+ } else t2 = $[6];
408
+ let t3;
409
+ if ($[7] !== t2) {
410
+ t3 = /* @__PURE__ */ jsx(Label, { children: /* @__PURE__ */ jsx(Name, { children: t2 }) });
411
+ $[7] = t2;
412
+ $[8] = t3;
413
+ } else t3 = $[8];
414
+ let t4;
415
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
416
+ t4 = /* @__PURE__ */ jsx(Indicator, { children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: "1em" }) });
417
+ $[9] = t4;
418
+ } else t4 = $[9];
419
+ let t5;
420
+ if ($[10] !== t1 || $[11] !== t3) {
421
+ t5 = /* @__PURE__ */ jsxs(Item, {
422
+ as: Trigger$1,
423
+ label: t1,
424
+ children: [t3, t4]
425
+ });
426
+ $[10] = t1;
427
+ $[11] = t3;
428
+ $[12] = t5;
429
+ } else t5 = $[12];
430
+ let t6;
431
+ if ($[13] !== chosen || $[14] !== t) {
432
+ t6 = STAGES.map((stage) => /* @__PURE__ */ jsxs(Menu.OptionItem, {
433
+ checked: stage === chosen,
434
+ onCheckedChange: () => {
435
+ setChosen(stage);
436
+ },
437
+ type: "radio",
438
+ value: stage,
439
+ children: [/* @__PURE__ */ jsx(Menu.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { size: "1em" }) }), /* @__PURE__ */ jsx(Menu.ItemText, { children: t(stage) })]
440
+ }, stage));
441
+ $[13] = chosen;
442
+ $[14] = t;
443
+ $[15] = t6;
444
+ } else t6 = $[15];
445
+ let t7;
446
+ if ($[16] !== t6) {
447
+ t7 = /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: t6 }) }) });
448
+ $[16] = t6;
449
+ $[17] = t7;
450
+ } else t7 = $[17];
451
+ let t8;
452
+ if ($[18] !== props || $[19] !== t5 || $[20] !== t7) {
453
+ t8 = /* @__PURE__ */ jsx(Start, { children: /* @__PURE__ */ jsxs(Root, {
454
+ placement: "toolbar",
455
+ size: "sm",
456
+ variant: "outline",
457
+ ...props,
458
+ children: [t5, t7]
459
+ }) });
460
+ $[18] = props;
461
+ $[19] = t5;
462
+ $[20] = t7;
463
+ $[21] = t8;
464
+ } else t8 = $[21];
465
+ let t9;
466
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
467
+ t9 = /* @__PURE__ */ jsx(RocketIcon, { size: "1em" });
468
+ $[22] = t9;
469
+ } else t9 = $[22];
470
+ let t10;
471
+ if ($[23] !== t) {
472
+ t10 = t("deploy");
473
+ $[23] = t;
474
+ $[24] = t10;
475
+ } else t10 = $[24];
476
+ let t11;
477
+ if ($[25] !== t10) {
478
+ t11 = /* @__PURE__ */ jsx(End, { children: /* @__PURE__ */ jsx(Action, {
479
+ icon: t9,
480
+ primary: true,
481
+ children: t10
482
+ }) });
483
+ $[25] = t10;
484
+ $[26] = t11;
485
+ } else t11 = $[26];
486
+ let t12;
487
+ if ($[27] !== t0 || $[28] !== t11 || $[29] !== t8) {
488
+ t12 = /* @__PURE__ */ jsxs(Root$1, {
489
+ "aria-label": t0,
490
+ size: "sm",
491
+ variant: "outline",
492
+ children: [t8, t11]
493
+ });
494
+ $[27] = t0;
495
+ $[28] = t11;
496
+ $[29] = t8;
497
+ $[30] = t12;
498
+ } else t12 = $[30];
499
+ return t12;
500
+ }
501
+ const source$2 = "import { type ReactElement, useState } from \"react\";\n\nimport { CheckIcon, ChevronsUpDownIcon, RocketIcon } from \"lucide-react\";\n\nimport { Menu } from \"@stealthscale/component-disclosure\";\nimport { Portal } from \"@stealthscale/component-primitives\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Switcher, Toolbar } from \"@stealthscale/component-screen\";\n\nconst STAGES = [\"production\", \"staging\", \"preview\"] as const;\n\nexport function Environment(props: Switcher.RootProps): ReactElement {\n const { t } = useWords(\"switcher\");\n const [chosen, setChosen] = useState<(typeof STAGES)[number]>(\"production\");\n\n return (\n <Toolbar.Root aria-label={t(\"deployments\")} size=\"sm\" variant=\"outline\">\n <Toolbar.Start>\n <Switcher.Root placement=\"toolbar\" size=\"sm\" variant=\"outline\" {...props}>\n <Toolbar.Item as={Switcher.Trigger} label={t(\"environment\")}>\n <Switcher.Label>\n <Switcher.Name>{t(chosen)}</Switcher.Name>\n </Switcher.Label>\n <Switcher.Indicator>\n <ChevronsUpDownIcon size=\"1em\" />\n </Switcher.Indicator>\n </Toolbar.Item>\n <Portal>\n <Menu.Positioner>\n <Menu.Content>\n {STAGES.map((stage) => (\n <Menu.OptionItem\n checked={stage === chosen}\n key={stage}\n onCheckedChange={() => {\n setChosen(stage);\n }}\n type=\"radio\"\n value={stage}\n >\n <Menu.ItemIndicator>\n <CheckIcon size=\"1em\" />\n </Menu.ItemIndicator>\n <Menu.ItemText>{t(stage)}</Menu.ItemText>\n </Menu.OptionItem>\n ))}\n </Menu.Content>\n </Menu.Positioner>\n </Portal>\n </Switcher.Root>\n </Toolbar.Start>\n <Toolbar.End>\n <Toolbar.Action icon={<RocketIcon size=\"1em\" />} primary>\n {t(\"deploy\")}\n </Toolbar.Action>\n </Toolbar.End>\n </Toolbar.Root>\n );\n}\n";
502
+ //#endregion
503
+ //#region src/switcher/examples/linked.example.tsx
504
+ var linked_example_exports = /* @__PURE__ */ __exportAll({
505
+ Linked: () => Linked,
506
+ source: () => source$1
507
+ });
508
+ const WORKSPACES = [
509
+ ["ledger", "production"],
510
+ ["northwind", "trial"],
511
+ ["acme", "enterprise"]
512
+ ];
513
+ function Linked() {
514
+ const $ = c(15);
515
+ const { t } = useWords("switcher");
516
+ let t0;
517
+ let t1;
518
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
519
+ t0 = /* @__PURE__ */ jsx(CheckIcon, { size: "1em" });
520
+ t1 = /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: "1em" });
521
+ $[0] = t0;
522
+ $[1] = t1;
523
+ } else {
524
+ t0 = $[0];
525
+ t1 = $[1];
526
+ }
527
+ let t2;
528
+ if ($[2] !== t) {
529
+ t2 = WORKSPACES.map((t3) => {
530
+ const [name, plan] = t3;
531
+ return {
532
+ detail: t(plan),
533
+ href: `#${name}`,
534
+ label: t(name),
535
+ value: name
536
+ };
537
+ });
538
+ $[2] = t;
539
+ $[3] = t2;
540
+ } else t2 = $[3];
541
+ let t3;
542
+ if ($[4] !== t) {
543
+ t3 = t("workspace");
544
+ $[4] = t;
545
+ $[5] = t3;
546
+ } else t3 = $[5];
547
+ let t4;
548
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
549
+ t4 = /* @__PURE__ */ jsx(PlusIcon, { size: "1em" });
550
+ $[6] = t4;
551
+ } else t4 = $[6];
552
+ let t5;
553
+ if ($[7] !== t) {
554
+ t5 = t("new");
555
+ $[7] = t;
556
+ $[8] = t5;
557
+ } else t5 = $[8];
558
+ let t6;
559
+ if ($[9] !== t5) {
560
+ t6 = /* @__PURE__ */ jsx(Action$1, {
561
+ icon: t4,
562
+ children: t5
563
+ });
564
+ $[9] = t5;
565
+ $[10] = t6;
566
+ } else t6 = $[10];
567
+ let t7;
568
+ if ($[11] !== t2 || $[12] !== t3 || $[13] !== t6) {
569
+ t7 = /* @__PURE__ */ jsx(Root, {
570
+ checkIcon: t0,
571
+ indicator: t1,
572
+ items: t2,
573
+ label: t3,
574
+ value: "northwind",
575
+ children: t6
576
+ });
577
+ $[11] = t2;
578
+ $[12] = t3;
579
+ $[13] = t6;
580
+ $[14] = t7;
581
+ } else t7 = $[14];
582
+ return t7;
583
+ }
584
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, ChevronsUpDownIcon, PlusIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Switcher } from \"@stealthscale/component-screen\";\n\nconst WORKSPACES = [\n [\"ledger\", \"production\"],\n [\"northwind\", \"trial\"],\n [\"acme\", \"enterprise\"],\n] as const;\n\nexport function Linked(): ReactElement {\n const { t } = useWords(\"switcher\");\n\n return (\n <Switcher.Root\n checkIcon={<CheckIcon size=\"1em\" />}\n indicator={<ChevronsUpDownIcon size=\"1em\" />}\n items={WORKSPACES.map(([name, plan]) => ({\n detail: t(plan),\n href: `#${name}`,\n label: t(name),\n value: name,\n }))}\n label={t(\"workspace\")}\n value=\"northwind\"\n >\n <Switcher.Action icon={<PlusIcon size=\"1em\" />}>{t(\"new\")}</Switcher.Action>\n </Switcher.Root>\n );\n}\n";
585
+ //#endregion
586
+ //#region src/switcher/examples/workspaces.example.tsx
587
+ var workspaces_example_exports = /* @__PURE__ */ __exportAll({
588
+ Workspaces: () => Workspaces,
589
+ source: () => source
590
+ });
591
+ function Workspaces(props) {
592
+ const $ = c(54);
593
+ const { t } = useWords("switcher");
594
+ let t0;
595
+ if ($[0] !== t) {
596
+ t0 = t("production");
597
+ $[0] = t;
598
+ $[1] = t0;
599
+ } else t0 = $[1];
600
+ let t1;
601
+ if ($[2] !== t) {
602
+ t1 = t("ledger");
603
+ $[2] = t;
604
+ $[3] = t1;
605
+ } else t1 = $[3];
606
+ let t2;
607
+ if ($[4] !== t0 || $[5] !== t1) {
608
+ t2 = {
609
+ detail: t0,
610
+ label: t1,
611
+ value: "ledger"
612
+ };
613
+ $[4] = t0;
614
+ $[5] = t1;
615
+ $[6] = t2;
616
+ } else t2 = $[6];
617
+ let t3;
618
+ if ($[7] !== t) {
619
+ t3 = t("trial");
620
+ $[7] = t;
621
+ $[8] = t3;
622
+ } else t3 = $[8];
623
+ let t4;
624
+ if ($[9] !== t) {
625
+ t4 = t("northwind");
626
+ $[9] = t;
627
+ $[10] = t4;
628
+ } else t4 = $[10];
629
+ let t5;
630
+ if ($[11] !== t3 || $[12] !== t4) {
631
+ t5 = {
632
+ detail: t3,
633
+ label: t4,
634
+ value: "northwind"
635
+ };
636
+ $[11] = t3;
637
+ $[12] = t4;
638
+ $[13] = t5;
639
+ } else t5 = $[13];
640
+ let t6;
641
+ if ($[14] !== t) {
642
+ t6 = t("enterprise");
643
+ $[14] = t;
644
+ $[15] = t6;
645
+ } else t6 = $[15];
646
+ let t7;
647
+ if ($[16] !== t) {
648
+ t7 = t("acme");
649
+ $[16] = t;
650
+ $[17] = t7;
651
+ } else t7 = $[17];
652
+ let t8;
653
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
654
+ t8 = /* @__PURE__ */ jsx(Building2Icon, { size: "1em" });
655
+ $[18] = t8;
656
+ } else t8 = $[18];
657
+ let t9;
658
+ if ($[19] !== t6 || $[20] !== t7) {
659
+ t9 = {
660
+ detail: t6,
661
+ label: t7,
662
+ mark: t8,
663
+ value: "acme"
664
+ };
665
+ $[19] = t6;
666
+ $[20] = t7;
667
+ $[21] = t9;
668
+ } else t9 = $[21];
669
+ let t10;
670
+ if ($[22] !== t) {
671
+ t10 = t("suspended");
672
+ $[22] = t;
673
+ $[23] = t10;
674
+ } else t10 = $[23];
675
+ let t11;
676
+ if ($[24] !== t) {
677
+ t11 = t("oldBooks");
678
+ $[24] = t;
679
+ $[25] = t11;
680
+ } else t11 = $[25];
681
+ let t12;
682
+ if ($[26] !== t10 || $[27] !== t11) {
683
+ t12 = {
684
+ detail: t10,
685
+ disabled: true,
686
+ label: t11,
687
+ value: "oldBooks"
688
+ };
689
+ $[26] = t10;
690
+ $[27] = t11;
691
+ $[28] = t12;
692
+ } else t12 = $[28];
693
+ let t13;
694
+ if ($[29] !== t12 || $[30] !== t2 || $[31] !== t5 || $[32] !== t9) {
695
+ t13 = [
696
+ t2,
697
+ t5,
698
+ t9,
699
+ t12
700
+ ];
701
+ $[29] = t12;
702
+ $[30] = t2;
703
+ $[31] = t5;
704
+ $[32] = t9;
705
+ $[33] = t13;
706
+ } else t13 = $[33];
707
+ const workspaces = t13;
708
+ let t14;
709
+ let t15;
710
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
711
+ t14 = /* @__PURE__ */ jsx(CheckIcon, { size: "1em" });
712
+ t15 = /* @__PURE__ */ jsx(ChevronsUpDownIcon, { size: "1em" });
713
+ $[34] = t14;
714
+ $[35] = t15;
715
+ } else {
716
+ t14 = $[34];
717
+ t15 = $[35];
718
+ }
719
+ let t16;
720
+ if ($[36] !== t) {
721
+ t16 = t("workspace");
722
+ $[36] = t;
723
+ $[37] = t16;
724
+ } else t16 = $[37];
725
+ let t17;
726
+ if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
727
+ t17 = /* @__PURE__ */ jsx(PlusIcon, { size: "1em" });
728
+ $[38] = t17;
729
+ } else t17 = $[38];
730
+ let t18;
731
+ if ($[39] !== t) {
732
+ t18 = t("new");
733
+ $[39] = t;
734
+ $[40] = t18;
735
+ } else t18 = $[40];
736
+ let t19;
737
+ if ($[41] !== t18) {
738
+ t19 = /* @__PURE__ */ jsx(Action$1, {
739
+ icon: t17,
740
+ children: t18
741
+ });
742
+ $[41] = t18;
743
+ $[42] = t19;
744
+ } else t19 = $[42];
745
+ let t20;
746
+ if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
747
+ t20 = /* @__PURE__ */ jsx(SettingsIcon, { size: "1em" });
748
+ $[43] = t20;
749
+ } else t20 = $[43];
750
+ let t21;
751
+ if ($[44] !== t) {
752
+ t21 = t("settings");
753
+ $[44] = t;
754
+ $[45] = t21;
755
+ } else t21 = $[45];
756
+ let t22;
757
+ if ($[46] !== t21) {
758
+ t22 = /* @__PURE__ */ jsx(Action$1, {
759
+ icon: t20,
760
+ children: t21
761
+ });
762
+ $[46] = t21;
763
+ $[47] = t22;
764
+ } else t22 = $[47];
765
+ let t23;
766
+ if ($[48] !== props || $[49] !== t16 || $[50] !== t19 || $[51] !== t22 || $[52] !== workspaces) {
767
+ t23 = /* @__PURE__ */ jsxs(Root, {
768
+ checkIcon: t14,
769
+ indicator: t15,
770
+ items: workspaces,
771
+ label: t16,
772
+ ...props,
773
+ children: [t19, t22]
774
+ });
775
+ $[48] = props;
776
+ $[49] = t16;
777
+ $[50] = t19;
778
+ $[51] = t22;
779
+ $[52] = workspaces;
780
+ $[53] = t23;
781
+ } else t23 = $[53];
782
+ return t23;
783
+ }
784
+ const source = "import { type ReactElement } from \"react\";\n\nimport { Building2Icon, CheckIcon, ChevronsUpDownIcon, PlusIcon, SettingsIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Switcher } from \"@stealthscale/component-screen\";\n\nexport function Workspaces(props: Switcher.RootProps): ReactElement {\n const { t } = useWords(\"switcher\");\n const workspaces: Switcher.Choice[] = [\n { detail: t(\"production\"), label: t(\"ledger\"), value: \"ledger\" },\n { detail: t(\"trial\"), label: t(\"northwind\"), value: \"northwind\" },\n {\n detail: t(\"enterprise\"),\n label: t(\"acme\"),\n mark: <Building2Icon size=\"1em\" />,\n value: \"acme\",\n },\n { detail: t(\"suspended\"), disabled: true, label: t(\"oldBooks\"), value: \"oldBooks\" },\n ];\n\n return (\n <Switcher.Root\n checkIcon={<CheckIcon size=\"1em\" />}\n indicator={<ChevronsUpDownIcon size=\"1em\" />}\n items={workspaces}\n label={t(\"workspace\")}\n {...props}\n >\n <Switcher.Action icon={<PlusIcon size=\"1em\" />}>{t(\"new\")}</Switcher.Action>\n <Switcher.Action icon={<SettingsIcon size=\"1em\" />}>{t(\"settings\")}</Switcher.Action>\n </Switcher.Root>\n );\n}\n";
785
+ //#endregion
786
+ //#region src/switcher/switcher.specimen.tsx
787
+ /**
788
+ * Catalogue page for the switcher.
789
+ *
790
+ * @remarks
791
+ * The first three scenes render the switcher where an application renders it: at the head of a
792
+ * sidebar in an app shell whose navigation closes to icons, in a toolbar at a card's width and at
793
+ * a phone's width, and on its own with a page per workspace. The composed scene renders an
794
+ * environment switcher from the parts in a toolbar. `scenesOf` generates the looks, the palettes,
795
+ * the sizes and the placements from the workspaces example. Every switcher renders closed and
796
+ * portals its menu to the document body. The rooms and the boxes never appear in the examples.
797
+ * The words are keys under `switcher` in `locales/en/specimen/switcher.json`.
798
+ */
799
+ /**
800
+ * Hand-written scene for the switcher at the head of a sidebar in an app shell.
801
+ */
802
+ const sidebar = {
803
+ about: "switcher.sidebar.about",
804
+ draw: () => /* @__PURE__ */ jsx(Screen, {
805
+ size: "md",
806
+ children: /* @__PURE__ */ jsx(Console, {})
807
+ }),
808
+ example: console_example_exports,
809
+ frame: "bleed",
810
+ title: "switcher.sidebar.title"
811
+ };
812
+ /**
813
+ * Hand-written scene for the switcher in a toolbar, wide and at a phone's width.
814
+ */
815
+ const toolbar = {
816
+ about: "switcher.toolbar.about",
817
+ draw: () => /* @__PURE__ */ jsxs(Stack, {
818
+ gap: "md",
819
+ children: [/* @__PURE__ */ jsx(Sample, {
820
+ place: "stretch",
821
+ variant: "outline",
822
+ children: /* @__PURE__ */ jsx(Bar, {})
823
+ }), /* @__PURE__ */ jsx(Room, {
824
+ size: "sm",
825
+ children: /* @__PURE__ */ jsx(Sample, {
826
+ place: "stretch",
827
+ variant: "outline",
828
+ children: /* @__PURE__ */ jsx(Bar, {})
829
+ })
830
+ })]
831
+ }),
832
+ example: bar_example_exports,
833
+ title: "switcher.toolbar.title"
834
+ };
835
+ /**
836
+ * Hand-written scene for the switcher on its own, a link per workspace.
837
+ */
838
+ const alone = {
839
+ about: "switcher.alone.about",
840
+ draw: Linked,
841
+ example: linked_example_exports,
842
+ title: "switcher.alone.title"
843
+ };
844
+ /**
845
+ * Hand-written scene for a switcher composed from its parts.
846
+ */
847
+ const composed = {
848
+ about: "switcher.composed.about",
849
+ draw: () => /* @__PURE__ */ jsx(Room, {
850
+ size: "md",
851
+ children: /* @__PURE__ */ jsx(Environment, {})
852
+ }),
853
+ example: environment_example_exports,
854
+ title: "switcher.composed.title"
855
+ };
856
+ var switcher_specimen_default = specimen({
857
+ about: "switcher.about",
858
+ id: "components/screen/switcher",
859
+ imports: "import { Switcher } from \"@stealthscale/component-screen\";",
860
+ scenes: [
861
+ sidebar,
862
+ toolbar,
863
+ alone,
864
+ ...scenesOf(recipe, {
865
+ axes: {
866
+ palette: { with: { variant: "subtle" } },
867
+ placement: {
868
+ draw: (props) => /* @__PURE__ */ jsx(Room, {
869
+ size: "xs",
870
+ children: /* @__PURE__ */ jsx(Workspaces, { ...props })
871
+ }),
872
+ with: { variant: "outline" }
873
+ },
874
+ size: {
875
+ draw: (props) => /* @__PURE__ */ jsx(Room, {
876
+ size: "xs",
877
+ children: /* @__PURE__ */ jsx(Workspaces, { ...props })
878
+ }),
879
+ with: {
880
+ placement: "sidebar",
881
+ variant: "outline"
882
+ }
883
+ }
884
+ },
885
+ draw: (props) => /* @__PURE__ */ jsx(Workspaces, { ...props }),
886
+ example: workspaces_example_exports,
887
+ namespace: "switcher",
888
+ order: [
889
+ "variant",
890
+ "palette",
891
+ "size",
892
+ "placement"
893
+ ]
894
+ }),
895
+ composed
896
+ ],
897
+ title: "switcher.title"
898
+ });
899
+ //#endregion
900
+ export { alone, composed, switcher_specimen_default as default, sidebar, toolbar };