@stealthscale/component-screen 0.0.0-stage → 0.2.1

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,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };
@@ -0,0 +1,327 @@
1
+ import { RecipeProps } from "@stealthscale/theme/authoring";
2
+ import { ComponentProps, ReactElement, ReactNode } from "react";
3
+ import { Menu } from "@stealthscale/component-disclosure";
4
+ //#region src/switcher/choice.d.ts
5
+ /**
6
+ * Describes one workspace, project or tenant a switcher lists.
7
+ */
8
+ interface Choice {
9
+ /**
10
+ * Plan, role or region, rendered under the name in a sidebar and in the menu's row.
11
+ */
12
+ readonly detail?: string | undefined;
13
+ /**
14
+ * Whether the reader cannot switch to the choice.
15
+ */
16
+ readonly disabled?: boolean | undefined;
17
+ /**
18
+ * Address of the choice's own page, which renders its row as a link.
19
+ */
20
+ readonly href?: string | undefined;
21
+ /**
22
+ * Name of the choice.
23
+ */
24
+ readonly label: string;
25
+ /**
26
+ * Logo or avatar. The mark shows the name's initials without one.
27
+ */
28
+ readonly mark?: ReactNode | undefined;
29
+ /**
30
+ * Value the application knows the choice by.
31
+ */
32
+ readonly value: string;
33
+ }
34
+ //#endregion
35
+ //#region src/switcher/recipe.d.ts
36
+ /**
37
+ * Declares the switcher's slot recipe, which styles the control that shows the current workspace,
38
+ * project or environment and opens the menu of the others.
39
+ *
40
+ * @remarks
41
+ * The recipe has six slots. The root slot is the trigger, and the mark, the label, the name, the
42
+ * detail and the indicator are inside it. `Switcher.Root` is the disclosure package's menu, so
43
+ * the menu's recipe styles the panel and its rows. The trigger takes the button's looks and
44
+ * palettes from the same layer styles, so an outlined switcher has the button's light edge. The
45
+ * mark renders an initial, an icon or an avatar in the palette's ink, without a fill. The name
46
+ * and the detail truncate to keep the control at one height. A pair of chevrons marks a control
47
+ * that switches and not a direction, so the indicator does not rotate while the menu is open. In
48
+ * a sidebar closed to icons, and in a narrow toolbar for a switcher with a mark, the control is
49
+ * its mark alone, square. The words remain in the accessible name in both.
50
+ */
51
+ /**
52
+ * Styles a ghost switcher at the middle size, alone.
53
+ */
54
+ declare const recipe: import("@stealthscale/theme/authoring").SlotRecipe<"detail" | "indicator" | "label" | "mark" | "name" | "root", {
55
+ /**
56
+ * The palette of the look and the mark.
57
+ */
58
+ readonly palette: {
59
+ accent: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
60
+ error: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
61
+ info: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
62
+ neutral: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
63
+ primary: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
64
+ secondary: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
65
+ success: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
66
+ warning: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
67
+ };
68
+ /**
69
+ * Where the control is placed, which sets its width and its lines.
70
+ *
71
+ * @remarks
72
+ * `Switcher.Root` reads the placement from the sidebar or the toolbar around it unless a
73
+ * caller states one. The `marked` compound sizes the mark to `icon.lg` on one line, because
74
+ * the size axis sizes it for a sidebar and a compound applies over an axis.
75
+ */
76
+ readonly placement: {
77
+ alone: {
78
+ detail: {
79
+ display: string;
80
+ };
81
+ root: {
82
+ "&[data-narrow]:has(.switcher__mark)": {
83
+ aspectRatio: string;
84
+ inlineSize: string;
85
+ justifyContent: string;
86
+ paddingInline: string;
87
+ };
88
+ inlineSize: string;
89
+ minBlockSize: string;
90
+ };
91
+ };
92
+ sidebar: {
93
+ root: {
94
+ "&[data-iconic]": {
95
+ alignSelf: string;
96
+ aspectRatio: string;
97
+ borderWidth: string;
98
+ inlineSize: string;
99
+ justifyContent: string;
100
+ padding: string;
101
+ };
102
+ inlineSize: string;
103
+ };
104
+ };
105
+ toolbar: {
106
+ detail: {
107
+ display: string;
108
+ };
109
+ root: {
110
+ "&[data-narrow]:has(.switcher__mark)": {
111
+ aspectRatio: string;
112
+ inlineSize: string;
113
+ justifyContent: string;
114
+ paddingInline: string;
115
+ };
116
+ inlineSize: string;
117
+ minBlockSize: string;
118
+ };
119
+ };
120
+ };
121
+ readonly size: {
122
+ lg: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
123
+ md: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
124
+ sm: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
125
+ };
126
+ /**
127
+ * The button's six looks, each one of the theme's layer styles.
128
+ *
129
+ * @remarks
130
+ * `ghost`, the default, has no fill at rest, so a switcher at the head of a sidebar shows the
131
+ * sidebar's own ground and fills under a pointer.
132
+ */
133
+ readonly variant: {
134
+ ghost: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
135
+ outline: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
136
+ plain: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
137
+ solid: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
138
+ subtle: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
139
+ surface: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
140
+ };
141
+ }>;
142
+ //#endregion
143
+ //#region src/switcher/sized.d.ts
144
+ /**
145
+ * Selects one of the sizes the menu renders at, which are the switcher's sizes.
146
+ */
147
+ type Step = "lg" | "md" | "sm";
148
+ /**
149
+ * Describes the props of `Sized`: the menu's props and the step.
150
+ */
151
+ interface SizedProps extends Omit<ComponentProps<typeof Menu.Root>, "size"> {
152
+ /**
153
+ * Size the switcher renders at.
154
+ */
155
+ readonly step: Step;
156
+ }
157
+ /**
158
+ * Renders the menu at the step.
159
+ *
160
+ * @param props - The step and the menu's props.
161
+ * @returns The menu at that size.
162
+ */
163
+ declare function Sized({ step, ...rest }: SizedProps): ReactElement;
164
+ //#endregion
165
+ //#region src/switcher/state.d.ts
166
+ /**
167
+ * Derives where a switcher renders from the sidebar or the toolbar around it, and provides it to
168
+ * the switcher's parts.
169
+ *
170
+ * @remarks
171
+ * A switcher in a sidebar is a row at the sidebar's size, and its mark alone while the sidebar
172
+ * is a rail. A switcher in a toolbar is one of the row's controls at the toolbar's size, and a
173
+ * switcher with a mark hides its name while the toolbar is narrow. Anywhere else it is one line
174
+ * at its own size. A caller's `placement` or `size` applies over the derived one.
175
+ */
176
+ /**
177
+ * Selects where a switcher renders.
178
+ */
179
+ type Placement = "alone" | "sidebar" | "toolbar";
180
+ /**
181
+ * Selects the size of a switcher.
182
+ */
183
+ type SwitcherSize = "lg" | "md" | "sm";
184
+ //#endregion
185
+ //#region src/switcher/root.d.ts
186
+ /**
187
+ * Binds the sized menu as the root that provides the variants.
188
+ */
189
+ declare const Bound: import("@stealthscale/theme").RootProvider<typeof Sized, {
190
+ readonly palette: {
191
+ accent: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
192
+ error: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
193
+ info: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
194
+ neutral: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
195
+ primary: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
196
+ secondary: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
197
+ success: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
198
+ warning: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
199
+ };
200
+ readonly placement: {
201
+ alone: {
202
+ detail: {
203
+ display: string;
204
+ };
205
+ root: {
206
+ "&[data-narrow]:has(.switcher__mark)": {
207
+ aspectRatio: string;
208
+ inlineSize: string;
209
+ justifyContent: string;
210
+ paddingInline: string;
211
+ };
212
+ inlineSize: string;
213
+ minBlockSize: string;
214
+ };
215
+ };
216
+ sidebar: {
217
+ root: {
218
+ "&[data-iconic]": {
219
+ alignSelf: string;
220
+ aspectRatio: string;
221
+ borderWidth: string;
222
+ inlineSize: string;
223
+ justifyContent: string;
224
+ padding: string;
225
+ };
226
+ inlineSize: string;
227
+ };
228
+ };
229
+ toolbar: {
230
+ detail: {
231
+ display: string;
232
+ };
233
+ root: {
234
+ "&[data-narrow]:has(.switcher__mark)": {
235
+ aspectRatio: string;
236
+ inlineSize: string;
237
+ justifyContent: string;
238
+ paddingInline: string;
239
+ };
240
+ inlineSize: string;
241
+ minBlockSize: string;
242
+ };
243
+ };
244
+ };
245
+ readonly size: {
246
+ lg: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
247
+ md: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
248
+ sm: Partial<Record<"indicator" | "mark" | "name" | "root", import("@stealthscale/theme").SystemStyleObject>>;
249
+ };
250
+ readonly variant: {
251
+ ghost: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
252
+ outline: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
253
+ plain: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
254
+ solid: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
255
+ subtle: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
256
+ surface: Record<"root", import("@stealthscale/theme").SystemStyleObject>;
257
+ };
258
+ }>;
259
+ /**
260
+ * Variant props of the switcher's recipe.
261
+ */
262
+ type Variants = RecipeProps<typeof recipe>;
263
+ /**
264
+ * Props of the binding, with the variants typed as the recipe types them.
265
+ */
266
+ type ProvidedProps = Omit<ComponentProps<typeof Bound>, keyof Variants> & Variants;
267
+ /**
268
+ * Describes the props of `Root`: the choices and their glyphs, the switcher's variants and the
269
+ * menu's props.
270
+ *
271
+ * @remarks
272
+ * The menu's recipe also offers `size` and `variant`. Over the menu's root the two `variant` axes
273
+ * intersect to a type no value satisfies, so the switcher's axes replace the menu's here. The
274
+ * menu's size is the switcher's `size`, so `step` is omitted.
275
+ */
276
+ interface RootProps extends Omit<ProvidedProps, "placement" | "size" | "step"> {
277
+ /**
278
+ * Glyph that marks the current choice's row in the menu.
279
+ */
280
+ readonly checkIcon?: ReactNode | undefined;
281
+ /**
282
+ * Value of the choice that is current at first, when the caller does not control it. Defaults to
283
+ * the first choice.
284
+ */
285
+ readonly defaultValue?: string | undefined;
286
+ /**
287
+ * Glyph at the end of the trigger.
288
+ */
289
+ readonly indicator?: ReactNode | undefined;
290
+ /**
291
+ * The choices. With them the root renders the trigger and the menu.
292
+ */
293
+ readonly items?: readonly Choice[] | undefined;
294
+ /**
295
+ * Kind of thing the switcher switches, which a screen reader announces before the current name.
296
+ * Used with `items`.
297
+ */
298
+ readonly label?: string | undefined;
299
+ /**
300
+ * Called with the value of the choice the reader switches to.
301
+ */
302
+ readonly onValueChange?: ((value: string) => void) | undefined;
303
+ /**
304
+ * Where the switcher renders. Read from the sidebar or the toolbar around it when absent.
305
+ */
306
+ readonly placement?: Placement | undefined;
307
+ /**
308
+ * Size of the switcher. The sidebar's or the toolbar's size when absent, and `md` alone.
309
+ */
310
+ readonly size?: SwitcherSize | undefined;
311
+ /**
312
+ * Value of the current choice, when the caller controls it.
313
+ */
314
+ readonly value?: string | undefined;
315
+ }
316
+ /**
317
+ * Renders the menu with the switcher's variants, at the switcher's size.
318
+ *
319
+ * @remarks
320
+ * A caller's `positioning` applies over the placement's, and a caller's `ids` over the trigger id
321
+ * the root shares with the rail's tooltip.
322
+ * @param props - The choices, the glyphs, the switcher's variants and the menu's props.
323
+ * @returns The menu, providing the variants and the placement.
324
+ */
325
+ declare function Root({ checkIcon, children, defaultValue, indicator, items, label, onValueChange, placement, positioning, size, value, ...rest }: RootProps): ReactElement;
326
+ //#endregion
327
+ export { Choice as a, SwitcherSize as i, RootProps as n, Placement as r, Root as t };