@stealthscale/component-actions 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,326 @@
1
+ import { t as __exportAll } from "../../rolldown-runtime-D7D4PA-g.js";
2
+ import { n as Root, r as Item } from "../../shared-Dv6Wx5nA.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Matrix, specimen, useWords } from "@stealthscale/specimen";
6
+ import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon, BoldIcon, ItalicIcon, StrikethroughIcon, UnderlineIcon } from "lucide-react";
7
+ //#region src/toggle-group/examples/alignment.example.tsx
8
+ var alignment_example_exports = /* @__PURE__ */ __exportAll({
9
+ Alignment: () => Alignment,
10
+ source: () => source$2
11
+ });
12
+ const ALIGNMENTS = [
13
+ {
14
+ Icon: AlignLeftIcon,
15
+ value: "left"
16
+ },
17
+ {
18
+ Icon: AlignCenterIcon,
19
+ value: "center"
20
+ },
21
+ {
22
+ Icon: AlignRightIcon,
23
+ value: "right"
24
+ }
25
+ ];
26
+ function Alignment(props) {
27
+ const $ = c(9);
28
+ const { t } = useWords("toggle-group");
29
+ let t0;
30
+ if ($[0] !== t) {
31
+ t0 = t("align");
32
+ $[0] = t;
33
+ $[1] = t0;
34
+ } else t0 = $[1];
35
+ let t1;
36
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
+ t1 = ["left"];
38
+ $[2] = t1;
39
+ } else t1 = $[2];
40
+ let t2;
41
+ if ($[3] !== t) {
42
+ t2 = ALIGNMENTS.map((t3) => {
43
+ const { Icon, value } = t3;
44
+ return /* @__PURE__ */ jsxs(Item, {
45
+ value,
46
+ children: [/* @__PURE__ */ jsx(Icon, { size: "1em" }), t(`alignments.${value}`)]
47
+ }, value);
48
+ });
49
+ $[3] = t;
50
+ $[4] = t2;
51
+ } else t2 = $[4];
52
+ let t3;
53
+ if ($[5] !== props || $[6] !== t0 || $[7] !== t2) {
54
+ t3 = /* @__PURE__ */ jsx(Root, {
55
+ "aria-label": t0,
56
+ defaultValue: t1,
57
+ deselectable: false,
58
+ variant: "outline",
59
+ ...props,
60
+ children: t2
61
+ });
62
+ $[5] = props;
63
+ $[6] = t0;
64
+ $[7] = t2;
65
+ $[8] = t3;
66
+ } else t3 = $[8];
67
+ return t3;
68
+ }
69
+ const source$2 = "import { type ReactElement } from \"react\";\n\nimport { AlignCenterIcon, AlignLeftIcon, AlignRightIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ToggleGroup } from \"@stealthscale/component-actions\";\n\nconst ALIGNMENTS = [\n { Icon: AlignLeftIcon, value: \"left\" },\n { Icon: AlignCenterIcon, value: \"center\" },\n { Icon: AlignRightIcon, value: \"right\" },\n] as const;\n\nexport function Alignment(props: ToggleGroup.RootProps): ReactElement {\n const { t } = useWords(\"toggle-group\");\n\n return (\n <ToggleGroup.Root\n aria-label={t(\"align\")}\n defaultValue={[\"left\"]}\n deselectable={false}\n variant=\"outline\"\n {...props}\n >\n {ALIGNMENTS.map(({ Icon, value }) => (\n <ToggleGroup.Item key={value} value={value}>\n <Icon size=\"1em\" />\n {t(`alignments.${value}`)}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n );\n}\n";
70
+ //#endregion
71
+ //#region src/toggle-group/examples/filters.example.tsx
72
+ var filters_example_exports = /* @__PURE__ */ __exportAll({
73
+ Filters: () => Filters,
74
+ source: () => source$1
75
+ });
76
+ const STATUSES = [
77
+ "open",
78
+ "pending",
79
+ "paid",
80
+ "archived"
81
+ ];
82
+ function Filters() {
83
+ const $ = c(8);
84
+ const { t } = useWords("toggle-group");
85
+ let t0;
86
+ if ($[0] !== t) {
87
+ t0 = t("show");
88
+ $[0] = t;
89
+ $[1] = t0;
90
+ } else t0 = $[1];
91
+ let t1;
92
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
93
+ t1 = ["open", "pending"];
94
+ $[2] = t1;
95
+ } else t1 = $[2];
96
+ let t2;
97
+ if ($[3] !== t) {
98
+ t2 = STATUSES.map((status) => /* @__PURE__ */ jsx(Item, {
99
+ disabled: status === "archived",
100
+ value: status,
101
+ children: t(`statuses.${status}`)
102
+ }, status));
103
+ $[3] = t;
104
+ $[4] = t2;
105
+ } else t2 = $[4];
106
+ let t3;
107
+ if ($[5] !== t0 || $[6] !== t2) {
108
+ t3 = /* @__PURE__ */ jsx(Root, {
109
+ "aria-label": t0,
110
+ attached: false,
111
+ defaultValue: t1,
112
+ gap: "xs",
113
+ multiple: true,
114
+ palette: "neutral",
115
+ size: "sm",
116
+ variant: "ghost",
117
+ children: t2
118
+ });
119
+ $[5] = t0;
120
+ $[6] = t2;
121
+ $[7] = t3;
122
+ } else t3 = $[7];
123
+ return t3;
124
+ }
125
+ const source$1 = "import { type ReactElement } from \"react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ToggleGroup } from \"@stealthscale/component-actions\";\n\nconst STATUSES = [\"open\", \"pending\", \"paid\", \"archived\"] as const;\n\nexport function Filters(): ReactElement {\n const { t } = useWords(\"toggle-group\");\n\n return (\n <ToggleGroup.Root\n aria-label={t(\"show\")}\n attached={false}\n defaultValue={[\"open\", \"pending\"]}\n gap=\"xs\"\n multiple\n palette=\"neutral\"\n size=\"sm\"\n variant=\"ghost\"\n >\n {STATUSES.map((status) => (\n <ToggleGroup.Item disabled={status === \"archived\"} key={status} value={status}>\n {t(`statuses.${status}`)}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n );\n}\n";
126
+ //#endregion
127
+ //#region src/toggle-group/examples/formatting.example.tsx
128
+ var formatting_example_exports = /* @__PURE__ */ __exportAll({
129
+ Formatting: () => Formatting,
130
+ source: () => source
131
+ });
132
+ const STYLES = [
133
+ {
134
+ Icon: BoldIcon,
135
+ value: "bold"
136
+ },
137
+ {
138
+ Icon: ItalicIcon,
139
+ value: "italic"
140
+ },
141
+ {
142
+ Icon: UnderlineIcon,
143
+ value: "underline"
144
+ },
145
+ {
146
+ Icon: StrikethroughIcon,
147
+ value: "strikethrough"
148
+ }
149
+ ];
150
+ function Formatting(props) {
151
+ const $ = c(9);
152
+ const { t } = useWords("toggle-group");
153
+ let t0;
154
+ if ($[0] !== t) {
155
+ t0 = t("style");
156
+ $[0] = t;
157
+ $[1] = t0;
158
+ } else t0 = $[1];
159
+ let t1;
160
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
161
+ t1 = ["bold", "italic"];
162
+ $[2] = t1;
163
+ } else t1 = $[2];
164
+ let t2;
165
+ if ($[3] !== t) {
166
+ t2 = STYLES.map((t3) => {
167
+ const { Icon, value } = t3;
168
+ return /* @__PURE__ */ jsx(Item, {
169
+ "aria-label": t(`styles.${value}`),
170
+ shape: "square",
171
+ value,
172
+ children: /* @__PURE__ */ jsx(Icon, { size: "1em" })
173
+ }, value);
174
+ });
175
+ $[3] = t;
176
+ $[4] = t2;
177
+ } else t2 = $[4];
178
+ let t3;
179
+ if ($[5] !== props || $[6] !== t0 || $[7] !== t2) {
180
+ t3 = /* @__PURE__ */ jsx(Root, {
181
+ "aria-label": t0,
182
+ defaultValue: t1,
183
+ multiple: true,
184
+ variant: "outline",
185
+ ...props,
186
+ children: t2
187
+ });
188
+ $[5] = props;
189
+ $[6] = t0;
190
+ $[7] = t2;
191
+ $[8] = t3;
192
+ } else t3 = $[8];
193
+ return t3;
194
+ }
195
+ const source = "import { type ReactElement } from \"react\";\n\nimport { BoldIcon, ItalicIcon, StrikethroughIcon, UnderlineIcon } from \"lucide-react\";\n\nimport { useWords } from \"@stealthscale/specimen\";\n\nimport { ToggleGroup } from \"@stealthscale/component-actions\";\n\nconst STYLES = [\n { Icon: BoldIcon, value: \"bold\" },\n { Icon: ItalicIcon, value: \"italic\" },\n { Icon: UnderlineIcon, value: \"underline\" },\n { Icon: StrikethroughIcon, value: \"strikethrough\" },\n] as const;\n\nexport function Formatting(props: ToggleGroup.RootProps): ReactElement {\n const { t } = useWords(\"toggle-group\");\n\n return (\n <ToggleGroup.Root\n aria-label={t(\"style\")}\n defaultValue={[\"bold\", \"italic\"]}\n multiple\n variant=\"outline\"\n {...props}\n >\n {STYLES.map(({ Icon, value }) => (\n <ToggleGroup.Item\n aria-label={t(`styles.${value}`)}\n key={value}\n shape=\"square\"\n value={value}\n >\n <Icon size=\"1em\" />\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n );\n}\n";
196
+ //#endregion
197
+ //#region src/toggle-group/toggle-group.specimen.tsx
198
+ /**
199
+ * Catalogue page for the toggle group.
200
+ *
201
+ * @remarks
202
+ * The toggle group has no recipe of its own: the layout's `Group` lays the items out and the
203
+ * button's recipe draws them, so every scene is hand-written. The looks and sizes scenes turn the
204
+ * formatting example's `variant` and `size`. The single scene shows the alignment example, the
205
+ * orientation scene turns its `orientation`, the spaced scene shows filters with a gap and one
206
+ * filter disabled, and the states scene a disabled group. The words are keys under
207
+ * `toggle-group` in `locales/en/specimen/toggle-group.json`.
208
+ */
209
+ /**
210
+ * Props of the disabled scene's group.
211
+ */
212
+ const DISABLED = { disabled: true };
213
+ /**
214
+ * Looks of the looks scene: the button's looks that show which icon items are on, in reading order.
215
+ *
216
+ * @remarks
217
+ * The solid look marks a pressed button with an inset shadow and a semibold label, and an icon
218
+ * has no label to set in bold, so the scene leaves it out.
219
+ */
220
+ const LOOKS = [
221
+ "outline",
222
+ "subtle",
223
+ "surface",
224
+ "ghost",
225
+ "plain"
226
+ ];
227
+ /**
228
+ * Sizes of the sizes scene.
229
+ */
230
+ const SIZES = [
231
+ "xs",
232
+ "sm",
233
+ "md",
234
+ "lg",
235
+ "xl"
236
+ ];
237
+ /**
238
+ * Orientations of the orientation scene.
239
+ */
240
+ const ORIENTATIONS = ["horizontal", "vertical"];
241
+ /**
242
+ * Hand-written scene for every look of the items.
243
+ */
244
+ const looks = {
245
+ about: "toggle-group.looks.about",
246
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
247
+ knob: "variant",
248
+ of: LOOKS,
249
+ children: (variant) => /* @__PURE__ */ jsx(Formatting, { variant })
250
+ }),
251
+ example: formatting_example_exports,
252
+ props: { variant: "outline" },
253
+ title: "toggle-group.looks.title"
254
+ };
255
+ /**
256
+ * Hand-written scene for every size of the items.
257
+ */
258
+ const sizes = {
259
+ about: "toggle-group.sizes.about",
260
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
261
+ knob: "size",
262
+ of: SIZES,
263
+ children: (size) => /* @__PURE__ */ jsx(Formatting, { size })
264
+ }),
265
+ example: formatting_example_exports,
266
+ props: { size: "xs" },
267
+ title: "toggle-group.sizes.title"
268
+ };
269
+ /**
270
+ * Hand-written scene for a group that keeps one item on.
271
+ */
272
+ const single = {
273
+ about: "toggle-group.single.about",
274
+ draw: () => /* @__PURE__ */ jsx(Alignment, {}),
275
+ example: alignment_example_exports,
276
+ title: "toggle-group.single.title"
277
+ };
278
+ /**
279
+ * Hand-written scene for a group in a row and in a column.
280
+ */
281
+ const orientation = {
282
+ about: "toggle-group.orientation.about",
283
+ draw: () => /* @__PURE__ */ jsx(Matrix, {
284
+ knob: "orientation",
285
+ of: ORIENTATIONS,
286
+ children: (way) => /* @__PURE__ */ jsx(Alignment, { orientation: way })
287
+ }),
288
+ example: alignment_example_exports,
289
+ props: { orientation: "horizontal" },
290
+ title: "toggle-group.orientation.title"
291
+ };
292
+ /**
293
+ * Hand-written scene for spaced items, one of them disabled.
294
+ */
295
+ const spaced = {
296
+ about: "toggle-group.spaced.about",
297
+ draw: Filters,
298
+ example: filters_example_exports,
299
+ title: "toggle-group.spaced.title"
300
+ };
301
+ /**
302
+ * Hand-written scene for a disabled group.
303
+ */
304
+ const states = {
305
+ about: "toggle-group.states.about",
306
+ draw: () => /* @__PURE__ */ jsx(Formatting, { ...DISABLED }),
307
+ example: formatting_example_exports,
308
+ props: { disabled: true },
309
+ title: "toggle-group.states.title"
310
+ };
311
+ var toggle_group_specimen_default = specimen({
312
+ about: "toggle-group.about",
313
+ id: "components/actions/toggle-group",
314
+ imports: "import { ToggleGroup } from \"@stealthscale/component-actions\";",
315
+ scenes: [
316
+ looks,
317
+ sizes,
318
+ single,
319
+ orientation,
320
+ spaced,
321
+ states
322
+ ],
323
+ title: "toggle-group.title"
324
+ });
325
+ //#endregion
326
+ export { toggle_group_specimen_default as default, looks, orientation, single, sizes, spaced, states };
@@ -0,0 +1,3 @@
1
+ export const dropped = {"ItemProps": {"conditions": 284, "foreign": 1049}, "RootProps": {"conditions": 284, "foreign": 1037}};
2
+ export const parts = {"ItemProps": [{"accepts": "boolean", "fallback": "", "kind": "option", "name": "disabled", "refers": [], "required": false, "says": ""}, {"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": "string", "fallback": "", "kind": "option", "name": "value", "refers": [], "required": true, "says": ""}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}], "RootProps": [{"accepts": "Align", "fallback": "", "kind": "variant", "name": "align", "refers": ["kit.Align"], "required": false, "says": "Cross-axis alignment of the children."}, {"accepts": "boolean", "fallback": "", "kind": "variant", "name": "attached", "refers": [], "required": false, "says": "Joins the children into one control."}, {"accepts": "string[]", "fallback": "", "kind": "option", "name": "defaultValue", "refers": [], "required": false, "says": "The initial selected value of the toggle group when rendered. Use when you don't need to control the selected value of the toggle group."}, {"accepts": "boolean", "fallback": "true", "kind": "option", "name": "deselectable", "refers": [], "required": false, "says": "Whether the toggle group allows empty selection. **Note:** This is ignored if `multiple` is `true`."}, {"accepts": "boolean", "fallback": "", "kind": "variant", "name": "dim", "refers": [], "required": false, "says": "Dims every child except a hovered, keyboard-focused or pressed one."}, {"accepts": "\"ltr\" | \"rtl\"", "fallback": "\"ltr\"", "kind": "option", "name": "dir", "refers": [], "required": false, "says": "The document's text/writing direction."}, {"accepts": "boolean", "fallback": "", "kind": "option", "name": "disabled", "refers": [], "required": false, "says": "Whether the toggle is disabled."}, {"accepts": "\"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\"", "fallback": "", "kind": "variant", "name": "gap", "refers": [], "required": false, "says": "Gap token between the children, from `xs` to `xl`."}, {"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": "boolean", "fallback": "", "kind": "variant", "name": "grow", "refers": [], "required": false, "says": "Makes the group full width and gives every child an equal share of it."}, {"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": ["toggle-group.ElementIds"], "required": false, "says": "The ids of the elements in the toggle. Useful for composition."}, {"accepts": "Justify", "fallback": "", "kind": "variant", "name": "justify", "refers": ["kit.Justify"], "required": false, "says": "Distribution of the space left over along the main axis."}, {"accepts": "boolean", "fallback": "true", "kind": "option", "name": "loopFocus", "refers": [], "required": false, "says": "Whether to loop focus inside the toggle group."}, {"accepts": "boolean", "fallback": "", "kind": "option", "name": "multiple", "refers": [], "required": false, "says": "Whether to allow multiple toggles to be selected."}, {"accepts": "((details: ValueChangeDetails) => void)", "fallback": "", "kind": "option", "name": "onValueChange", "refers": ["toggle-group.ValueChangeDetails"], "required": false, "says": "Function to call when the toggle is clicked."}, {"accepts": "Orientation", "fallback": "\"horizontal\"", "kind": "option", "name": "orientation", "refers": ["types.Orientation"], "required": false, "says": "The orientation of the toggle group."}, {"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": "boolean", "fallback": "true", "kind": "option", "name": "rovingFocus", "refers": [], "required": false, "says": "Whether to use roving tab index to manage focus."}, {"accepts": "Scale", "fallback": "", "kind": "variant", "name": "size", "refers": ["kit.Scale"], "required": false, "says": ""}, {"accepts": "string[]", "fallback": "", "kind": "option", "name": "value", "refers": [], "required": false, "says": "The controlled selected value of the toggle group."}, {"accepts": "\"ghost\" | \"glass\" | \"outline\" | \"plain\" | \"solid\" | \"subtle\" | \"surface\"", "fallback": "", "kind": "variant", "name": "variant", "refers": [], "required": false, "says": ""}]};
3
+ export const shapes = {"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": ""}], "kit.Align": [{"accepts": "", "name": "\"baseline\"", "says": ""}, {"accepts": "", "name": "\"flex-end\"", "says": ""}, {"accepts": "", "name": "\"flex-start\"", "says": ""}, {"accepts": "", "name": "\"stretch\"", "says": ""}], "kit.Justify": [{"accepts": "", "name": "\"around\"", "says": ""}, {"accepts": "", "name": "\"between\"", "says": ""}, {"accepts": "", "name": "\"center\"", "says": ""}, {"accepts": "", "name": "\"end\"", "says": ""}, {"accepts": "", "name": "\"evenly\"", "says": ""}, {"accepts": "", "name": "\"start\"", "says": ""}], "toggle-group.ElementIds": [{"accepts": "string", "name": "root", "says": ""}, {"accepts": "((value: string) => string)", "name": "item", "says": ""}], "toggle-group.ValueChangeDetails": [{"accepts": "string[]", "name": "value", "says": ""}], "types.Orientation": [{"accepts": "", "name": "\"horizontal\"", "says": ""}, {"accepts": "", "name": "\"vertical\"", "says": ""}]};