@stealthscale/component-actions 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.
@@ -0,0 +1,400 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { _ as Control, b as Button, d as ValueText, f as Trigger, g as Indicator, h as Input$1, m as Label, p as Root, v as Consumer, x as PropsProvider, y as IconButton } from "../../shared-Dv6Wx5nA.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Stack } from "@stealthscale/component-layout";
6
+ import { Matrix, Room, specimen, useWords } from "@stealthscale/specimen";
7
+ import { CheckIcon, CopyIcon } from "lucide-react";
8
+ import { Input, InputPropsProvider } from "@stealthscale/component-forms";
9
+ //#region src/clipboard/examples/alone.example.tsx
10
+ var alone_example_exports = /* @__PURE__ */ __exportAll({
11
+ Alone: () => Alone,
12
+ source: () => source$4
13
+ });
14
+ function Alone(props) {
15
+ const $ = c(20);
16
+ const { t } = useWords("clipboard");
17
+ let t0;
18
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
19
+ t0 = {
20
+ size: "sm",
21
+ variant: "outline"
22
+ };
23
+ $[0] = t0;
24
+ } else t0 = $[0];
25
+ let t1;
26
+ if ($[1] !== t) {
27
+ t1 = t("copied");
28
+ $[1] = t;
29
+ $[2] = t1;
30
+ } else t1 = $[2];
31
+ let t2;
32
+ if ($[3] !== t) {
33
+ t2 = t("copy");
34
+ $[3] = t;
35
+ $[4] = t2;
36
+ } else t2 = $[4];
37
+ let t3;
38
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
39
+ t3 = /* @__PURE__ */ jsx(Indicator, {
40
+ copied: /* @__PURE__ */ jsx(CheckIcon, { size: "1em" }),
41
+ children: /* @__PURE__ */ jsx(CopyIcon, { size: "1em" })
42
+ });
43
+ $[5] = t3;
44
+ } else t3 = $[5];
45
+ let t4;
46
+ if ($[6] !== t) {
47
+ t4 = t("copied");
48
+ $[6] = t;
49
+ $[7] = t4;
50
+ } else t4 = $[7];
51
+ let t5;
52
+ if ($[8] !== t) {
53
+ t5 = t("copy");
54
+ $[8] = t;
55
+ $[9] = t5;
56
+ } else t5 = $[9];
57
+ let t6;
58
+ if ($[10] !== t4 || $[11] !== t5) {
59
+ t6 = /* @__PURE__ */ jsx(Indicator, {
60
+ copied: t4,
61
+ children: t5
62
+ });
63
+ $[10] = t4;
64
+ $[11] = t5;
65
+ $[12] = t6;
66
+ } else t6 = $[12];
67
+ let t7;
68
+ if ($[13] !== t1 || $[14] !== t2 || $[15] !== t6) {
69
+ t7 = /* @__PURE__ */ jsx(PropsProvider, {
70
+ value: t0,
71
+ children: /* @__PURE__ */ jsxs(Trigger, {
72
+ as: Button,
73
+ copiedLabel: t1,
74
+ label: t2,
75
+ children: [t3, t6]
76
+ })
77
+ });
78
+ $[13] = t1;
79
+ $[14] = t2;
80
+ $[15] = t6;
81
+ $[16] = t7;
82
+ } else t7 = $[16];
83
+ let t8;
84
+ if ($[17] !== props || $[18] !== t7) {
85
+ t8 = /* @__PURE__ */ jsx(Root, {
86
+ value: "https://stealthscale.io/payouts/4109",
87
+ ...props,
88
+ children: t7
89
+ });
90
+ $[17] = props;
91
+ $[18] = t7;
92
+ $[19] = t8;
93
+ } else t8 = $[19];
94
+ return t8;
95
+ }
96
+ const source$4 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Button, ButtonPropsProvider, Clipboard } from \"@stealthscale/component-actions\";\n\nexport function Alone(props: Clipboard.RootProps): ReactElement {\n const { t } = useWords(\"clipboard\");\n\n return (\n <Clipboard.Root value=\"https://stealthscale.io/payouts/4109\" {...props}>\n <ButtonPropsProvider value={{ size: \"sm\", variant: \"outline\" }}>\n <Clipboard.Trigger as={Button} copiedLabel={t(\"copied\")} label={t(\"copy\")}>\n <Clipboard.Indicator copied={<CheckIcon size=\"1em\" />}>\n <CopyIcon size=\"1em\" />\n </Clipboard.Indicator>\n <Clipboard.Indicator copied={t(\"copied\")}>{t(\"copy\")}</Clipboard.Indicator>\n </Clipboard.Trigger>\n </ButtonPropsProvider>\n </Clipboard.Root>\n );\n}\n";
97
+ //#endregion
98
+ //#region src/clipboard/examples/beside.example.tsx
99
+ var beside_example_exports = /* @__PURE__ */ __exportAll({
100
+ Beside: () => Beside,
101
+ source: () => source$3
102
+ });
103
+ function Beside() {
104
+ const $ = c(9);
105
+ const { t } = useWords("clipboard");
106
+ let t0;
107
+ if ($[0] !== t) {
108
+ t0 = t("label");
109
+ $[0] = t;
110
+ $[1] = t0;
111
+ } else t0 = $[1];
112
+ let t1;
113
+ if ($[2] !== t0) {
114
+ t1 = /* @__PURE__ */ jsx(Label, { children: t0 });
115
+ $[2] = t0;
116
+ $[3] = t1;
117
+ } else t1 = $[3];
118
+ let t2;
119
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
120
+ t2 = /* @__PURE__ */ jsx(InputPropsProvider, {
121
+ value: { size: "sm" },
122
+ children: /* @__PURE__ */ jsx(Input$1, { as: Input })
123
+ });
124
+ $[4] = t2;
125
+ } else t2 = $[4];
126
+ let t3;
127
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
128
+ t3 = {
129
+ size: "sm",
130
+ variant: "ghost"
131
+ };
132
+ $[5] = t3;
133
+ } else t3 = $[5];
134
+ let t4;
135
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
136
+ t4 = /* @__PURE__ */ jsxs(Control, { children: [t2, /* @__PURE__ */ jsx(PropsProvider, {
137
+ value: t3,
138
+ children: /* @__PURE__ */ jsx(Trigger, {
139
+ as: IconButton,
140
+ children: /* @__PURE__ */ jsx(Indicator, {
141
+ copied: /* @__PURE__ */ jsx(CheckIcon, { size: "1em" }),
142
+ children: /* @__PURE__ */ jsx(CopyIcon, { size: "1em" })
143
+ })
144
+ })
145
+ })] });
146
+ $[6] = t4;
147
+ } else t4 = $[6];
148
+ let t5;
149
+ if ($[7] !== t1) {
150
+ t5 = /* @__PURE__ */ jsxs(Root, {
151
+ value: "https://stealthscale.io/payouts/4109",
152
+ children: [t1, t4]
153
+ });
154
+ $[7] = t1;
155
+ $[8] = t5;
156
+ } else t5 = $[8];
157
+ return t5;
158
+ }
159
+ const source$3 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\n\nimport { Input, InputPropsProvider } from \"@stealthscale/component-forms\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ButtonPropsProvider, Clipboard, IconButton } from \"@stealthscale/component-actions\";\n\nexport function Beside(): ReactElement {\n const { t } = useWords(\"clipboard\");\n\n return (\n <Clipboard.Root value=\"https://stealthscale.io/payouts/4109\">\n <Clipboard.Label>{t(\"label\")}</Clipboard.Label>\n <Clipboard.Control>\n <InputPropsProvider value={{ size: \"sm\" }}>\n <Clipboard.Input as={Input} />\n </InputPropsProvider>\n <ButtonPropsProvider value={{ size: \"sm\", variant: \"ghost\" }}>\n <Clipboard.Trigger as={IconButton}>\n <Clipboard.Indicator copied={<CheckIcon size=\"1em\" />}>\n <CopyIcon size=\"1em\" />\n </Clipboard.Indicator>\n </Clipboard.Trigger>\n </ButtonPropsProvider>\n </Clipboard.Control>\n </Clipboard.Root>\n );\n}\n";
160
+ //#endregion
161
+ //#region src/clipboard/examples/own.example.tsx
162
+ var own_example_exports = /* @__PURE__ */ __exportAll({
163
+ Own: () => Own,
164
+ source: () => source$2
165
+ });
166
+ function Own() {
167
+ const $ = c(2);
168
+ const { t } = useWords("clipboard");
169
+ let t0;
170
+ if ($[0] !== t) {
171
+ t0 = /* @__PURE__ */ jsx(Root, {
172
+ value: "https://stealthscale.io/payouts/4109",
173
+ children: /* @__PURE__ */ jsx(Consumer, { children: (api) => /* @__PURE__ */ jsx(Button, {
174
+ onClick: api.copy,
175
+ palette: api.copied ? "success" : "neutral",
176
+ size: "sm",
177
+ children: api.copied ? t("copied") : t("copy")
178
+ }) })
179
+ });
180
+ $[0] = t;
181
+ $[1] = t0;
182
+ } else t0 = $[1];
183
+ return t0;
184
+ }
185
+ const source$2 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Button, Clipboard } from \"@stealthscale/component-actions\";\n\nexport function Own(): ReactElement {\n const { t } = useWords(\"clipboard\");\n\n return (\n <Clipboard.Root value=\"https://stealthscale.io/payouts/4109\">\n <Clipboard.Consumer>\n {(api) => (\n <Button onClick={api.copy} palette={api.copied ? \"success\" : \"neutral\"} size=\"sm\">\n {api.copied ? t(\"copied\") : t(\"copy\")}\n </Button>\n )}\n </Clipboard.Consumer>\n </Clipboard.Root>\n );\n}\n";
186
+ //#endregion
187
+ //#region src/clipboard/examples/sizes.example.tsx
188
+ var sizes_example_exports = /* @__PURE__ */ __exportAll({
189
+ Sizes: () => Sizes,
190
+ source: () => source$1
191
+ });
192
+ const SIZES = [
193
+ "sm",
194
+ "md",
195
+ "lg"
196
+ ];
197
+ function Sizes() {
198
+ const $ = c(4);
199
+ const { t } = useWords("clipboard");
200
+ let t0;
201
+ if ($[0] !== t) {
202
+ t0 = SIZES.map((size) => /* @__PURE__ */ jsxs(Root, {
203
+ size,
204
+ value: "https://stealthscale.io/payouts/4109",
205
+ children: [/* @__PURE__ */ jsx(Label, { children: t("label") }), /* @__PURE__ */ jsxs(Control, { children: [/* @__PURE__ */ jsx(InputPropsProvider, {
206
+ value: { size },
207
+ children: /* @__PURE__ */ jsx(Input$1, { as: Input })
208
+ }), /* @__PURE__ */ jsx(PropsProvider, {
209
+ value: {
210
+ size,
211
+ variant: "outline"
212
+ },
213
+ children: /* @__PURE__ */ jsx(Trigger, {
214
+ as: IconButton,
215
+ children: /* @__PURE__ */ jsx(Indicator, {
216
+ copied: /* @__PURE__ */ jsx(CheckIcon, { size: "1em" }),
217
+ children: /* @__PURE__ */ jsx(CopyIcon, { size: "1em" })
218
+ })
219
+ })
220
+ })] })]
221
+ }, size));
222
+ $[0] = t;
223
+ $[1] = t0;
224
+ } else t0 = $[1];
225
+ let t1;
226
+ if ($[2] !== t0) {
227
+ t1 = /* @__PURE__ */ jsx(Stack, {
228
+ direction: "column",
229
+ gap: "lg",
230
+ children: t0
231
+ });
232
+ $[2] = t0;
233
+ $[3] = t1;
234
+ } else t1 = $[3];
235
+ return t1;
236
+ }
237
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\n\nimport { Input, InputPropsProvider } from \"@stealthscale/component-forms\";\nimport { Stack } from \"@stealthscale/component-layout\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ButtonPropsProvider, Clipboard, IconButton } from \"@stealthscale/component-actions\";\n\nconst SIZES = [\"sm\", \"md\", \"lg\"] as const;\n\nexport function Sizes(): ReactElement {\n const { t } = useWords(\"clipboard\");\n\n return (\n <Stack direction=\"column\" gap=\"lg\">\n {SIZES.map((size) => (\n <Clipboard.Root key={size} size={size} value=\"https://stealthscale.io/payouts/4109\">\n <Clipboard.Label>{t(\"label\")}</Clipboard.Label>\n <Clipboard.Control>\n <InputPropsProvider value={{ size }}>\n <Clipboard.Input as={Input} />\n </InputPropsProvider>\n <ButtonPropsProvider value={{ size, variant: \"outline\" }}>\n <Clipboard.Trigger as={IconButton}>\n <Clipboard.Indicator copied={<CheckIcon size=\"1em\" />}>\n <CopyIcon size=\"1em\" />\n </Clipboard.Indicator>\n </Clipboard.Trigger>\n </ButtonPropsProvider>\n </Clipboard.Control>\n </Clipboard.Root>\n ))}\n </Stack>\n );\n}\n";
238
+ //#endregion
239
+ //#region src/clipboard/examples/value.example.tsx
240
+ var value_example_exports = /* @__PURE__ */ __exportAll({
241
+ Value: () => Value,
242
+ source: () => source
243
+ });
244
+ const LINK = "https://stealthscale.io/payouts/4109";
245
+ function Value() {
246
+ const $ = c(10);
247
+ const { t } = useWords("clipboard");
248
+ let t0;
249
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
250
+ t0 = {
251
+ size: "sm",
252
+ variant: "ghost"
253
+ };
254
+ $[0] = t0;
255
+ } else t0 = $[0];
256
+ let t1;
257
+ if ($[1] !== t) {
258
+ t1 = t("copiedValue", { value: LINK });
259
+ $[1] = t;
260
+ $[2] = t1;
261
+ } else t1 = $[2];
262
+ let t2;
263
+ if ($[3] !== t) {
264
+ t2 = t("copyValue", { value: LINK });
265
+ $[3] = t;
266
+ $[4] = t2;
267
+ } else t2 = $[4];
268
+ let t3;
269
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
270
+ t3 = /* @__PURE__ */ jsx(ValueText, {});
271
+ $[5] = t3;
272
+ } else t3 = $[5];
273
+ let t4;
274
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
275
+ t4 = /* @__PURE__ */ jsx(Indicator, {
276
+ copied: /* @__PURE__ */ jsx(CheckIcon, { size: "1em" }),
277
+ children: /* @__PURE__ */ jsx(CopyIcon, { size: "1em" })
278
+ });
279
+ $[6] = t4;
280
+ } else t4 = $[6];
281
+ let t5;
282
+ if ($[7] !== t1 || $[8] !== t2) {
283
+ t5 = /* @__PURE__ */ jsx(Root, {
284
+ value: LINK,
285
+ children: /* @__PURE__ */ jsx(PropsProvider, {
286
+ value: t0,
287
+ children: /* @__PURE__ */ jsxs(Trigger, {
288
+ as: Button,
289
+ copiedLabel: t1,
290
+ label: t2,
291
+ children: [t3, t4]
292
+ })
293
+ })
294
+ });
295
+ $[7] = t1;
296
+ $[8] = t2;
297
+ $[9] = t5;
298
+ } else t5 = $[9];
299
+ return t5;
300
+ }
301
+ const source = "import { type ReactElement } from \"react\";\n\nimport { CheckIcon, CopyIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { Button, ButtonPropsProvider, Clipboard } from \"@stealthscale/component-actions\";\n\nconst LINK = \"https://stealthscale.io/payouts/4109\";\n\nexport function Value(): ReactElement {\n const { t } = useWords(\"clipboard\");\n\n return (\n <Clipboard.Root value={LINK}>\n <ButtonPropsProvider value={{ size: \"sm\", variant: \"ghost\" }}>\n <Clipboard.Trigger\n as={Button}\n copiedLabel={t(\"copiedValue\", { value: LINK })}\n label={t(\"copyValue\", { value: LINK })}\n >\n <Clipboard.ValueText />\n <Clipboard.Indicator copied={<CheckIcon size=\"1em\" />}>\n <CopyIcon size=\"1em\" />\n </Clipboard.Indicator>\n </Clipboard.Trigger>\n </ButtonPropsProvider>\n </Clipboard.Root>\n );\n}\n";
302
+ //#endregion
303
+ //#region src/clipboard/clipboard.specimen.tsx
304
+ /**
305
+ * Catalogue page for the clipboard.
306
+ *
307
+ * @remarks
308
+ * Every scene is hand-written and renders a component from `examples/`. The size scene renders
309
+ * the three sizes itself, because the field and the button take the size through their own
310
+ * providers. The duration scene renders the `alone` example with each `timeout`. The trigger has
311
+ * no styles of its own, so every example renders it as `Button` or `IconButton` through `as`. The
312
+ * words are keys under `clipboard` in the `specimen` namespace, stored in
313
+ * `locales/en/specimen/clipboard.json`.
314
+ */
315
+ /**
316
+ * Copied-state durations the duration scene compares, in milliseconds.
317
+ */
318
+ const TIMEOUTS = [250, 3e3];
319
+ /**
320
+ * Hand-written scene for a copy button with visible text.
321
+ */
322
+ const lone = {
323
+ about: "clipboard.alone.about",
324
+ draw: () => /* @__PURE__ */ jsx(Alone, {}),
325
+ example: alone_example_exports,
326
+ title: "clipboard.alone.title"
327
+ };
328
+ /**
329
+ * Hand-written scene for an icon button next to a read-only field.
330
+ */
331
+ const besides = {
332
+ about: "clipboard.beside.about",
333
+ draw: () => /* @__PURE__ */ jsx(Room, {
334
+ size: "sm",
335
+ children: /* @__PURE__ */ jsx(Beside, {})
336
+ }),
337
+ example: beside_example_exports,
338
+ title: "clipboard.beside.title"
339
+ };
340
+ /**
341
+ * Hand-written scene for the value as the trigger text.
342
+ */
343
+ const value = {
344
+ about: "clipboard.value.about",
345
+ draw: Value,
346
+ example: value_example_exports,
347
+ title: "clipboard.value.title"
348
+ };
349
+ /**
350
+ * Hand-written scene for a control built with `Clipboard.Consumer`.
351
+ */
352
+ const custom = {
353
+ about: "clipboard.own.about",
354
+ draw: Own,
355
+ example: own_example_exports,
356
+ title: "clipboard.own.title"
357
+ };
358
+ /**
359
+ * Hand-written scene for the `size` axis.
360
+ */
361
+ const size = {
362
+ about: "clipboard.size.about",
363
+ axes: ["size"],
364
+ draw: () => /* @__PURE__ */ jsx(Room, {
365
+ size: "sm",
366
+ children: /* @__PURE__ */ jsx(Sizes, {})
367
+ }),
368
+ example: sizes_example_exports,
369
+ title: "clipboard.size.title"
370
+ };
371
+ /**
372
+ * Hand-written scene for two copied-state durations.
373
+ */
374
+ const held = {
375
+ about: "clipboard.held.about",
376
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
377
+ knob: "timeout",
378
+ of: TIMEOUTS,
379
+ children: (timeout) => /* @__PURE__ */ jsx(Alone, { timeout })
380
+ }),
381
+ example: alone_example_exports,
382
+ props: { timeout: 250 },
383
+ title: "clipboard.held.title"
384
+ };
385
+ var clipboard_specimen_default = specimen({
386
+ about: "clipboard.about",
387
+ id: "components/actions/clipboard",
388
+ imports: "import { Button, ButtonPropsProvider, Clipboard, IconButton } from \"@stealthscale/component-actions\";",
389
+ scenes: [
390
+ lone,
391
+ besides,
392
+ value,
393
+ custom,
394
+ size,
395
+ held
396
+ ],
397
+ title: "clipboard.title"
398
+ });
399
+ //#endregion
400
+ export { besides, custom, clipboard_specimen_default as default, held, lone, size, value };
@@ -0,0 +1,3 @@
1
+ export const dropped = {"ConsumerProps": {"conditions": 0, "foreign": 0}, "ControlProps": {"conditions": 284, "foreign": 1041}, "IndicatorProps": {"conditions": 284, "foreign": 1041}, "InputProps": {"conditions": 284, "foreign": 1069}, "LabelProps": {"conditions": 284, "foreign": 1043}, "RootProps": {"conditions": 284, "foreign": 1038}, "TriggerProps": {"conditions": 284, "foreign": 1051}, "ValueTextProps": {"conditions": 284, "foreign": 1041}, "ButtonProps": {"conditions": 284, "foreign": 1051}, "IconButtonProps": {"conditions": 284, "foreign": 1049}};
2
+ export const parts = {"ConsumerProps": [{"accepts": "(api: ClipboardApi<PropTypes>) => ReactNode", "fallback": "", "kind": "option", "name": "children", "refers": ["clipboard.ClipboardApi", "types.PropTypes"], "required": true, "says": "Render function called with the machine's API."}], "ControlProps": [], "IndicatorProps": [{"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "copied", "refers": ["react.ReactElement", "react.ReactPortal"], "required": false, "says": "Mark rendered during the copied state."}], "InputProps": [], "LabelProps": [], "RootProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "defaultValue", "refers": [], "required": false, "says": "The initial value to be copied to the clipboard when rendered. Use when you don't need to control the value of the clipboard."}, {"accepts": "(() => Document | Node | ShadowRoot)", "fallback": "", "kind": "option", "name": "getRootNode", "refers": [], "required": false, "says": "A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "id", "refers": [], "required": false, "says": "The unique identifier of the machine."}, {"accepts": "ElementIds", "fallback": "", "kind": "option", "name": "ids", "refers": ["clipboard.ElementIds"], "required": false, "says": "The ids of the elements in the clipboard. Useful for composition."}, {"accepts": "((details: CopyStatusDetails) => void)", "fallback": "", "kind": "option", "name": "onStatusChange", "refers": ["clipboard.CopyStatusDetails"], "required": false, "says": "The function to be called when the value is copied to the clipboard"}, {"accepts": "((details: ValueChangeDetails) => void)", "fallback": "", "kind": "option", "name": "onValueChange", "refers": ["clipboard.ValueChangeDetails"], "required": false, "says": "The function to be called when the value changes"}, {"accepts": "\"lg\" | \"md\" | \"sm\"", "fallback": "", "kind": "variant", "name": "size", "refers": [], "required": false, "says": "The label text style and the two gaps."}, {"accepts": "number", "fallback": "3000", "kind": "option", "name": "timeout", "refers": [], "required": false, "says": "The timeout for the copy operation"}, {"accepts": "string", "fallback": "", "kind": "option", "name": "value", "refers": [], "required": false, "says": "The controlled value of the clipboard"}], "TriggerProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "copiedLabel", "refers": [], "required": false, "says": "Accessible name in the copied state. Defaults to \"Copied to clipboard\"."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Accessible name in the idle state. Defaults to \"Copy to clipboard\"."}], "ValueTextProps": [], "ButtonProps": [{"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "IconButtonProps": [{"accepts": "string", "fallback": "", "kind": "option", "name": "aria-label", "refers": [], "required": false, "says": "Defines a string value that labels the current element. The accessible name a screen reader announces in place of the icon."}, {"accepts": "string", "fallback": "", "kind": "option", "name": "aria-labelledby", "refers": [], "required": false, "says": "Identifies the element (or elements) that labels the current element. The id of the element whose text names the control."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}]};
3
+ export const shapes = {"types.PropTypes": [{"accepts": "Dict<any>", "name": "button", "says": ""}, {"accepts": "Dict<any>", "name": "circle", "says": ""}, {"accepts": "Dict<any>", "name": "element", "says": ""}, {"accepts": "Dict<any>", "name": "img", "says": ""}, {"accepts": "Dict<any>", "name": "input", "says": ""}, {"accepts": "Dict<any>", "name": "label", "says": ""}, {"accepts": "Dict<any>", "name": "output", "says": ""}, {"accepts": "Dict<any>", "name": "path", "says": ""}, {"accepts": "Dict<any>", "name": "rect", "says": ""}, {"accepts": "Dict<any>", "name": "select", "says": ""}, {"accepts": "Dict<any>", "name": "style", "says": ""}, {"accepts": "Dict<any>", "name": "svg", "says": ""}, {"accepts": "Dict<any>", "name": "textarea", "says": ""}], "clipboard.ClipboardApi": [{"accepts": "boolean", "name": "copied", "says": "Whether the value has been copied to the clipboard"}, {"accepts": "string", "name": "value", "says": "The value to be copied to the clipboard"}, {"accepts": "(value: string) => void", "name": "setValue", "says": "Set the value to be copied to the clipboard"}, {"accepts": "VoidFunction", "name": "copy", "says": "Copy the value to the clipboard"}, {"accepts": "() => Dict<any>", "name": "getRootProps", "says": ""}, {"accepts": "() => Dict<any>", "name": "getLabelProps", "says": ""}, {"accepts": "() => Dict<any>", "name": "getControlProps", "says": ""}, {"accepts": "() => Dict<any>", "name": "getTriggerProps", "says": ""}, {"accepts": "() => Dict<any>", "name": "getInputProps", "says": ""}, {"accepts": "(props: IndicatorProps) => Dict<any>", "name": "getIndicatorProps", "says": ""}], "react.ReactElement": [{"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "react.ReactPortal": [{"accepts": "ReactNode", "name": "children", "says": ""}, {"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "clipboard.ElementIds": [{"accepts": "string", "name": "root", "says": ""}, {"accepts": "string", "name": "input", "says": ""}, {"accepts": "string", "name": "label", "says": ""}], "clipboard.ValueChangeDetails": [{"accepts": "string", "name": "value", "says": ""}], "clipboard.CopyStatusDetails": [{"accepts": "boolean", "name": "copied", "says": ""}], "kit.Lift": [{"accepts": "", "name": "\"floating\"", "says": ""}, {"accepts": "", "name": "\"raised\"", "says": ""}], "kit.Scale": [{"accepts": "", "name": "\"2xl\"", "says": ""}, {"accepts": "", "name": "\"3xl\"", "says": ""}, {"accepts": "", "name": "\"4xl\"", "says": ""}, {"accepts": "", "name": "\"lg\"", "says": ""}, {"accepts": "", "name": "\"md\"", "says": ""}, {"accepts": "", "name": "\"sm\"", "says": ""}, {"accepts": "", "name": "\"xl\"", "says": ""}, {"accepts": "", "name": "\"xs\"", "says": ""}]};
@@ -0,0 +1,176 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { o as ColorModeToggle } from "../../shared-Dv6Wx5nA.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Group } from "@stealthscale/component-layout";
6
+ import { Matrix, specimen, useWords } from "@stealthscale/specimen";
7
+ import { MoonIcon, SunIcon } from "lucide-react";
8
+ import { Text } from "@stealthscale/component-typography";
9
+ //#region src/color-mode-toggle/examples/header.example.tsx
10
+ var header_example_exports = /* @__PURE__ */ __exportAll({
11
+ Header: () => Header,
12
+ source: () => source$1
13
+ });
14
+ function Header() {
15
+ const $ = c(13);
16
+ const { t } = useWords("color-mode-toggle");
17
+ let t0;
18
+ if ($[0] !== t) {
19
+ t0 = t("header.product");
20
+ $[0] = t;
21
+ $[1] = t0;
22
+ } else t0 = $[1];
23
+ let t1;
24
+ if ($[2] !== t0) {
25
+ t1 = /* @__PURE__ */ jsx(Text, {
26
+ weight: "semibold",
27
+ children: t0
28
+ });
29
+ $[2] = t0;
30
+ $[3] = t1;
31
+ } else t1 = $[3];
32
+ let t2;
33
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
34
+ t2 = /* @__PURE__ */ jsx(MoonIcon, {
35
+ "aria-hidden": true,
36
+ size: "1em"
37
+ });
38
+ $[4] = t2;
39
+ } else t2 = $[4];
40
+ let t3;
41
+ if ($[5] !== t) {
42
+ t3 = t("label");
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(SunIcon, {
49
+ "aria-hidden": true,
50
+ size: "1em"
51
+ });
52
+ $[7] = t4;
53
+ } else t4 = $[7];
54
+ let t5;
55
+ if ($[8] !== t3) {
56
+ t5 = /* @__PURE__ */ jsx(ColorModeToggle, {
57
+ dark: t2,
58
+ label: t3,
59
+ light: t4
60
+ });
61
+ $[8] = t3;
62
+ $[9] = t5;
63
+ } else t5 = $[9];
64
+ let t6;
65
+ if ($[10] !== t1 || $[11] !== t5) {
66
+ t6 = /* @__PURE__ */ jsxs(Group, {
67
+ align: "baseline",
68
+ justify: "between",
69
+ children: [t1, t5]
70
+ });
71
+ $[10] = t1;
72
+ $[11] = t5;
73
+ $[12] = t6;
74
+ } else t6 = $[12];
75
+ return t6;
76
+ }
77
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { MoonIcon, SunIcon } from \"lucide-react\";\n\nimport { Group } from \"@stealthscale/component-layout\";\nimport { Text } from \"@stealthscale/component-typography\";\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ColorModeToggle } from \"@stealthscale/component-actions\";\n\nexport function Header(): ReactElement {\n const { t } = useWords(\"color-mode-toggle\");\n\n return (\n <Group align=\"baseline\" justify=\"between\">\n <Text weight=\"semibold\">{t(\"header.product\")}</Text>\n <ColorModeToggle\n dark={<MoonIcon aria-hidden size=\"1em\" />}\n label={t(\"label\")}\n light={<SunIcon aria-hidden size=\"1em\" />}\n />\n </Group>\n );\n}\n";
78
+ //#endregion
79
+ //#region src/color-mode-toggle/examples/looks.example.tsx
80
+ var looks_example_exports = /* @__PURE__ */ __exportAll({
81
+ Looks: () => Looks,
82
+ source: () => source
83
+ });
84
+ function Looks(props) {
85
+ const $ = c(7);
86
+ const { t } = useWords("color-mode-toggle");
87
+ let t0;
88
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
89
+ t0 = /* @__PURE__ */ jsx(MoonIcon, {
90
+ "aria-hidden": true,
91
+ size: "1em"
92
+ });
93
+ $[0] = t0;
94
+ } else t0 = $[0];
95
+ let t1;
96
+ if ($[1] !== t) {
97
+ t1 = t("label");
98
+ $[1] = t;
99
+ $[2] = t1;
100
+ } else t1 = $[2];
101
+ let t2;
102
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
103
+ t2 = /* @__PURE__ */ jsx(SunIcon, {
104
+ "aria-hidden": true,
105
+ size: "1em"
106
+ });
107
+ $[3] = t2;
108
+ } else t2 = $[3];
109
+ let t3;
110
+ if ($[4] !== props || $[5] !== t1) {
111
+ t3 = /* @__PURE__ */ jsx(ColorModeToggle, {
112
+ dark: t0,
113
+ label: t1,
114
+ light: t2,
115
+ ...props
116
+ });
117
+ $[4] = props;
118
+ $[5] = t1;
119
+ $[6] = t3;
120
+ } else t3 = $[6];
121
+ return t3;
122
+ }
123
+ const source = "import { type ReactElement } from \"react\";\n\nimport { MoonIcon, SunIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ColorModeToggle, ColorModeToggleProps } from \"@stealthscale/component-actions\";\n\nexport function Looks(props: Partial<ColorModeToggleProps>): ReactElement {\n const { t } = useWords(\"color-mode-toggle\");\n\n return (\n <ColorModeToggle\n dark={<MoonIcon aria-hidden size=\"1em\" />}\n label={t(\"label\")}\n light={<SunIcon aria-hidden size=\"1em\" />}\n {...props}\n />\n );\n}\n";
124
+ //#endregion
125
+ //#region src/color-mode-toggle/color-mode-toggle.specimen.tsx
126
+ /**
127
+ * Catalogue page for the color mode toggle.
128
+ *
129
+ * @remarks
130
+ * The toggle has no recipe of its own: it renders the button and the swap, so every scene is
131
+ * hand-written. Each toggle switches the catalogue's own color mode, because the catalogue
132
+ * renders inside a color mode provider. The header scene shows the toggle at the end of an
133
+ * application's header, and the looks scene turns the button's `variant`. The words are keys
134
+ * under `color-mode-toggle` in `locales/en/specimen/color-mode-toggle.json`.
135
+ */
136
+ /**
137
+ * Looks of the looks scene: the button's looks for a control in a bar, in reading order.
138
+ */
139
+ const LOOKS = [
140
+ "ghost",
141
+ "outline",
142
+ "subtle",
143
+ "surface"
144
+ ];
145
+ /**
146
+ * Hand-written scene for the toggle at the end of a header.
147
+ */
148
+ const headed = {
149
+ about: "color-mode-toggle.header.about",
150
+ draw: Header,
151
+ example: header_example_exports,
152
+ title: "color-mode-toggle.header.title"
153
+ };
154
+ /**
155
+ * Hand-written scene for the looks a toggle takes from the button.
156
+ */
157
+ const looked = {
158
+ about: "color-mode-toggle.looks.about",
159
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
160
+ knob: "variant",
161
+ of: LOOKS,
162
+ children: (variant) => /* @__PURE__ */ jsx(Looks, { variant })
163
+ }),
164
+ example: looks_example_exports,
165
+ props: { variant: "ghost" },
166
+ title: "color-mode-toggle.looks.title"
167
+ };
168
+ var color_mode_toggle_specimen_default = specimen({
169
+ about: "color-mode-toggle.about",
170
+ id: "components/actions/color-mode-toggle",
171
+ imports: "import { ColorModeToggle } from \"@stealthscale/component-actions\";",
172
+ scenes: [headed, looked],
173
+ title: "color-mode-toggle.title"
174
+ });
175
+ //#endregion
176
+ export { color_mode_toggle_specimen_default as default, headed, looked };
@@ -0,0 +1,3 @@
1
+ export const dropped = {"ColorModeToggleProps": {"conditions": 284, "foreign": 1047}};
2
+ export const parts = {"ColorModeToggleProps": [{"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "dark", "refers": ["react.ReactElement", "react.ReactPortal"], "required": true, "says": "Glyph shown while the page is dark."}, {"accepts": "\"glow\" | \"pulse\"", "fallback": "", "kind": "variant", "name": "effect", "refers": [], "required": false, "says": "The halo around the button, in the palette's solid at half opacity."}, {"accepts": "Lift", "fallback": "", "kind": "variant", "name": "elevation", "refers": ["kit.Lift"], "required": false, "says": ""}, {"accepts": "string", "fallback": "", "kind": "option", "name": "label", "refers": [], "required": false, "says": "Name of the button in both states, \"Dark mode\" unless the caller passes another."}, {"accepts": "ReactNode", "fallback": "", "kind": "option", "name": "light", "refers": ["react.ReactElement", "react.ReactPortal"], "required": true, "says": "Glyph shown while the page is light."}, {"accepts": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"", "fallback": "", "kind": "variant", "name": "palette", "refers": [], "required": false, "says": "Palette of every look. The base sets `primary`."}, {"accepts": "\"square\"", "fallback": "", "kind": "variant", "name": "shape", "refers": [], "required": false, "says": ""}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}]};
3
+ export const shapes = {"react.ReactElement": [{"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "react.ReactPortal": [{"accepts": "ReactNode", "name": "children", "says": ""}, {"accepts": "string | JSXElementConstructor<any>", "name": "type", "says": ""}, {"accepts": "unknown", "name": "props", "says": ""}, {"accepts": "string | null", "name": "key", "says": ""}], "kit.Lift": [{"accepts": "", "name": "\"floating\"", "says": ""}, {"accepts": "", "name": "\"raised\"", "says": ""}], "kit.Scale": [{"accepts": "", "name": "\"2xl\"", "says": ""}, {"accepts": "", "name": "\"3xl\"", "says": ""}, {"accepts": "", "name": "\"4xl\"", "says": ""}, {"accepts": "", "name": "\"lg\"", "says": ""}, {"accepts": "", "name": "\"md\"", "says": ""}, {"accepts": "", "name": "\"sm\"", "says": ""}, {"accepts": "", "name": "\"xl\"", "says": ""}, {"accepts": "", "name": "\"xs\"", "says": ""}]};