viewkitjs 0.21.0 → 0.22.0

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 (51) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/MIGRATION.md +1 -1
  3. package/README.md +1 -1
  4. package/fields/dist/conventions.d.ts +15 -3
  5. package/fields/dist/conventions.js +25 -0
  6. package/fields/dist/design/category-colors.d.ts +12 -5
  7. package/fields/dist/design/category-colors.js +7 -7
  8. package/fields/dist/query/buckets.js +42 -35
  9. package/fields/dist/query/date.js +2 -13
  10. package/fields/docs/guides/conventions.md +1 -1
  11. package/fields/docs/guides/options.md +2 -1
  12. package/fields/docs/reference/design-category-colors.md +2 -2
  13. package/fields/docs/reference/fields.md +1 -1
  14. package/package.json +15 -1
  15. package/views/dist/atoms/tones.js +7 -7
  16. package/views/dist/contract.d.ts +288 -0
  17. package/views/dist/contract.js +96 -0
  18. package/views/dist/controls/button/button.d.ts +40 -0
  19. package/views/dist/controls/button/button.js +40 -0
  20. package/views/dist/controls/button/looks.d.ts +4 -0
  21. package/views/dist/controls/button/looks.js +20 -0
  22. package/views/dist/controls/button/map-button.d.ts +11 -0
  23. package/views/dist/controls/button/map-button.js +20 -0
  24. package/views/dist/controls/button/own-look.d.ts +59 -0
  25. package/views/dist/controls/button/own-look.js +33 -0
  26. package/views/dist/controls/button.css +530 -0
  27. package/views/dist/controls/controls.d.ts +5 -0
  28. package/views/dist/controls/controls.js +2 -0
  29. package/views/dist/controls/index.d.ts +11 -0
  30. package/views/dist/controls/index.js +6 -0
  31. package/views/dist/controls/smooth.css +101 -0
  32. package/views/dist/controls/spinner/looks.d.ts +4 -0
  33. package/views/dist/controls/spinner/looks.js +32 -0
  34. package/views/dist/controls/spinner/spinner.d.ts +23 -0
  35. package/views/dist/controls/spinner/spinner.js +16 -0
  36. package/views/dist/controls/spinner.css +147 -0
  37. package/views/dist/display/date.js +15 -2
  38. package/views/dist/looks/index.d.ts +2 -0
  39. package/views/dist/looks/index.js +2 -0
  40. package/views/dist/looks/looks.d.ts +2 -1
  41. package/views/dist/looks/pieces.js +3 -1
  42. package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
  43. package/views/dist/styles.css +825 -56
  44. package/views/dist/styles.unlayered.css +842 -56
  45. package/views/docs/contract.md +131 -8
  46. package/views/docs/guides/the-provider.md +1 -1
  47. package/views/docs/index.md +1 -0
  48. package/views/docs/install.md +2 -0
  49. package/views/docs/reference/controls.md +36 -0
  50. package/views/docs/reference/looks.md +12 -2
  51. package/views/docs/reference/views.md +4 -1
@@ -82,6 +82,294 @@ export declare const VK_INTERNAL_FAMILIES: readonly ["--vk-col-w-"];
82
82
  * marks its box `vk-fit` and each value's box `vk-fit-value`, which its measure reads. */
83
83
  export declare const VK_INTERNAL_MARKS: readonly ["vk-fit", "vk-fit-value"];
84
84
  export type VkInternalMark = (typeof VK_INTERNAL_MARKS)[number];
85
+ /** THE CONTROLS' TOKENS: every name ViewKit's default controls (`viewkitjs/views/controls`) read, each with its kind (the
86
+ * Outright token each stands for is docs/contract.md's table). All optional: the ready stylesheet declares each at My preset's value, and an app
87
+ * declares one to change it. Sixteen are the contract's colours already; the rest are the controls' own, named by the rule
88
+ * in docs/contract.md (Tokens, The controls' tokens). */
89
+ export declare const VK_CONTROL_TOKENS: readonly [{
90
+ readonly name: "--vk-brand";
91
+ readonly kind: "colour";
92
+ }, {
93
+ readonly name: "--vk-neutral";
94
+ readonly kind: "colour";
95
+ }, {
96
+ readonly name: "--vk-neutral-hovered";
97
+ readonly kind: "colour";
98
+ }, {
99
+ readonly name: "--vk-border";
100
+ readonly kind: "colour";
101
+ }, {
102
+ readonly name: "--vk-border-bold";
103
+ readonly kind: "colour";
104
+ }, {
105
+ readonly name: "--vk-border-brand";
106
+ readonly kind: "colour";
107
+ }, {
108
+ readonly name: "--vk-border-subtle";
109
+ readonly kind: "colour";
110
+ }, {
111
+ readonly name: "--vk-fg-brand";
112
+ readonly kind: "colour";
113
+ }, {
114
+ readonly name: "--vk-ground";
115
+ readonly kind: "colour";
116
+ }, {
117
+ readonly name: "--vk-hovered";
118
+ readonly kind: "colour";
119
+ }, {
120
+ readonly name: "--vk-pressed";
121
+ readonly kind: "colour";
122
+ }, {
123
+ readonly name: "--vk-fg";
124
+ readonly kind: "colour";
125
+ }, {
126
+ readonly name: "--vk-fg-on-brand";
127
+ readonly kind: "colour";
128
+ }, {
129
+ readonly name: "--vk-fg-inverse";
130
+ readonly kind: "colour";
131
+ }, {
132
+ readonly name: "--vk-fg-subtle";
133
+ readonly kind: "colour";
134
+ }, {
135
+ readonly name: "--vk-fg-subtlest";
136
+ readonly kind: "colour";
137
+ }, {
138
+ readonly name: "--vk-brand-hovered";
139
+ readonly kind: "colour";
140
+ }, {
141
+ readonly name: "--vk-brand-pressed";
142
+ readonly kind: "colour";
143
+ }, {
144
+ readonly name: "--vk-brand-subtler";
145
+ readonly kind: "colour";
146
+ }, {
147
+ readonly name: "--vk-brand-subtler-hovered";
148
+ readonly kind: "colour";
149
+ }, {
150
+ readonly name: "--vk-brand-subtler-pressed";
151
+ readonly kind: "colour";
152
+ }, {
153
+ readonly name: "--vk-danger-bold";
154
+ readonly kind: "colour";
155
+ }, {
156
+ readonly name: "--vk-danger-bold-hovered";
157
+ readonly kind: "colour";
158
+ }, {
159
+ readonly name: "--vk-danger-bold-pressed";
160
+ readonly kind: "colour";
161
+ }, {
162
+ readonly name: "--vk-info-bold";
163
+ readonly kind: "colour";
164
+ }, {
165
+ readonly name: "--vk-info-bold-hovered";
166
+ readonly kind: "colour";
167
+ }, {
168
+ readonly name: "--vk-info-bold-pressed";
169
+ readonly kind: "colour";
170
+ }, {
171
+ readonly name: "--vk-success-bold";
172
+ readonly kind: "colour";
173
+ }, {
174
+ readonly name: "--vk-success-bold-hovered";
175
+ readonly kind: "colour";
176
+ }, {
177
+ readonly name: "--vk-success-bold-pressed";
178
+ readonly kind: "colour";
179
+ }, {
180
+ readonly name: "--vk-warning-bold";
181
+ readonly kind: "colour";
182
+ }, {
183
+ readonly name: "--vk-warning-bold-hovered";
184
+ readonly kind: "colour";
185
+ }, {
186
+ readonly name: "--vk-warning-bold-pressed";
187
+ readonly kind: "colour";
188
+ }, {
189
+ readonly name: "--vk-brighten";
190
+ readonly kind: "colour";
191
+ }, {
192
+ readonly name: "--vk-darken";
193
+ readonly kind: "colour";
194
+ }, {
195
+ readonly name: "--vk-border-input";
196
+ readonly kind: "colour";
197
+ }, {
198
+ readonly name: "--vk-border-input-hovered";
199
+ readonly kind: "colour";
200
+ }, {
201
+ readonly name: "--vk-raised";
202
+ readonly kind: "colour";
203
+ }, {
204
+ readonly name: "--vk-raised-hovered";
205
+ readonly kind: "colour";
206
+ }, {
207
+ readonly name: "--vk-overlay-hovered";
208
+ readonly kind: "colour";
209
+ }, {
210
+ readonly name: "--vk-overlay-pressed";
211
+ readonly kind: "colour";
212
+ }, {
213
+ readonly name: "--vk-overlay-card-pressed";
214
+ readonly kind: "colour";
215
+ }, {
216
+ readonly name: "--vk-fg-disabled";
217
+ readonly kind: "colour";
218
+ }, {
219
+ readonly name: "--vk-fg-accent";
220
+ readonly kind: "colour";
221
+ }, {
222
+ readonly name: "--vk-border-width";
223
+ readonly kind: "size";
224
+ }, {
225
+ readonly name: "--vk-corner-smoothing";
226
+ readonly kind: "size";
227
+ }, {
228
+ readonly name: "--vk-dot-size";
229
+ readonly kind: "size";
230
+ }, {
231
+ readonly name: "--vk-duration-instant";
232
+ readonly kind: "motion";
233
+ }, {
234
+ readonly name: "--vk-duration-fast";
235
+ readonly kind: "motion";
236
+ }, {
237
+ readonly name: "--vk-duration-base";
238
+ readonly kind: "motion";
239
+ }, {
240
+ readonly name: "--vk-duration-slow";
241
+ readonly kind: "motion";
242
+ }, {
243
+ readonly name: "--vk-ease-out";
244
+ readonly kind: "motion";
245
+ }, {
246
+ readonly name: "--vk-ease-in-out";
247
+ readonly kind: "motion";
248
+ }, {
249
+ readonly name: "--vk-ease-spring";
250
+ readonly kind: "motion";
251
+ }, {
252
+ readonly name: "--vk-focus-width";
253
+ readonly kind: "size";
254
+ }, {
255
+ readonly name: "--vk-focus-offset";
256
+ readonly kind: "size";
257
+ }, {
258
+ readonly name: "--vk-font-weight-medium";
259
+ readonly kind: "size";
260
+ }, {
261
+ readonly name: "--vk-font-weight-semibold";
262
+ readonly kind: "size";
263
+ }, {
264
+ readonly name: "--vk-hover-lift";
265
+ readonly kind: "motion";
266
+ }, {
267
+ readonly name: "--vk-loading-dim";
268
+ readonly kind: "motion";
269
+ }, {
270
+ readonly name: "--vk-press-scale";
271
+ readonly kind: "motion";
272
+ }, {
273
+ readonly name: "--vk-press-squash";
274
+ readonly kind: "motion";
275
+ }, {
276
+ readonly name: "--vk-press-travel";
277
+ readonly kind: "motion";
278
+ }, {
279
+ readonly name: "--vk-press-travel-lg";
280
+ readonly kind: "motion";
281
+ }, {
282
+ readonly name: "--vk-progress-slide";
283
+ readonly kind: "motion";
284
+ }, {
285
+ readonly name: "--vk-radius-xs";
286
+ readonly kind: "size";
287
+ }, {
288
+ readonly name: "--vk-radius-sm";
289
+ readonly kind: "size";
290
+ }, {
291
+ readonly name: "--vk-radius-md";
292
+ readonly kind: "size";
293
+ }, {
294
+ readonly name: "--vk-radius-lg";
295
+ readonly kind: "size";
296
+ }, {
297
+ readonly name: "--vk-radius-xl";
298
+ readonly kind: "size";
299
+ }, {
300
+ readonly name: "--vk-radius-2xl";
301
+ readonly kind: "size";
302
+ }, {
303
+ readonly name: "--vk-radius-full";
304
+ readonly kind: "size";
305
+ }, {
306
+ readonly name: "--vk-shadow-key";
307
+ readonly kind: "shadow";
308
+ }, {
309
+ readonly name: "--vk-shadow-key-pressed";
310
+ readonly kind: "shadow";
311
+ }, {
312
+ readonly name: "--vk-shadow-key-pressed-bold";
313
+ readonly kind: "shadow";
314
+ }, {
315
+ readonly name: "--vk-shadow-key-shallow";
316
+ readonly kind: "shadow";
317
+ }, {
318
+ readonly name: "--vk-shadow-key-soft";
319
+ readonly kind: "shadow";
320
+ }, {
321
+ readonly name: "--vk-shadow-key-subtle";
322
+ readonly kind: "shadow";
323
+ }, {
324
+ readonly name: "--vk-shadow-key-subtle-raised";
325
+ readonly kind: "shadow";
326
+ }, {
327
+ readonly name: "--vk-shadow-lift";
328
+ readonly kind: "shadow";
329
+ }, {
330
+ readonly name: "--vk-shadow-lift-raised";
331
+ readonly kind: "shadow";
332
+ }, {
333
+ readonly name: "--vk-shadow-rim";
334
+ readonly kind: "shadow";
335
+ }, {
336
+ readonly name: "--vk-shadow-rim-bold";
337
+ readonly kind: "shadow";
338
+ }, {
339
+ readonly name: "--vk-shadow-rim-bold-raised";
340
+ readonly kind: "shadow";
341
+ }, {
342
+ readonly name: "--vk-shadow-rim-raised";
343
+ readonly kind: "shadow";
344
+ }, {
345
+ readonly name: "--vk-spacing";
346
+ readonly kind: "size";
347
+ }, {
348
+ readonly name: "--vk-spinner-breath";
349
+ readonly kind: "motion";
350
+ }, {
351
+ readonly name: "--vk-spinner-turn";
352
+ readonly kind: "motion";
353
+ }, {
354
+ readonly name: "--vk-spinner-turn-reduced";
355
+ readonly kind: "motion";
356
+ }, {
357
+ readonly name: "--vk-font-size-xs";
358
+ readonly kind: "size";
359
+ }, {
360
+ readonly name: "--vk-font-size-sm";
361
+ readonly kind: "size";
362
+ }, {
363
+ readonly name: "--vk-font-size-base";
364
+ readonly kind: "size";
365
+ }, {
366
+ readonly name: "--vk-font-size-lg";
367
+ readonly kind: "size";
368
+ }];
369
+ export type VkControlToken = (typeof VK_CONTROL_TOKENS)[number]["name"];
370
+ /** The controls' own machinery, set and read by a control alone: not public, and not prefixed, because the names came with
371
+ * the controls from the Outright kit and other pieces still set them. An app neither sets nor reads them. */
372
+ export declare const VK_CONTROL_PRIVATE_FAMILIES: readonly ["--button-", "--smooth-", "--o-spinner-", "--o-loading-", "--pressing-room-"];
85
373
  /** The primitives an app hands in through the provider. */
86
374
  export declare const COMPONENT_NAMES: readonly ["Button", "Popover", "Tooltip", "Checkbox", "Menu", "Collapse", "Sheet", "AppIcon", "Markdown"];
87
375
  export type ComponentName = (typeof COMPONENT_NAMES)[number];
@@ -199,6 +199,102 @@ export const VK_INTERNAL = [
199
199
  ];
200
200
  export const VK_INTERNAL_FAMILIES = ["--vk-col-w-"];
201
201
  export const VK_INTERNAL_MARKS = ["vk-fit", "vk-fit-value"];
202
+ export const VK_CONTROL_TOKENS = [
203
+ { name: "--vk-brand", kind: "colour" },
204
+ { name: "--vk-neutral", kind: "colour" },
205
+ { name: "--vk-neutral-hovered", kind: "colour" },
206
+ { name: "--vk-border", kind: "colour" },
207
+ { name: "--vk-border-bold", kind: "colour" },
208
+ { name: "--vk-border-brand", kind: "colour" },
209
+ { name: "--vk-border-subtle", kind: "colour" },
210
+ { name: "--vk-fg-brand", kind: "colour" },
211
+ { name: "--vk-ground", kind: "colour" },
212
+ { name: "--vk-hovered", kind: "colour" },
213
+ { name: "--vk-pressed", kind: "colour" },
214
+ { name: "--vk-fg", kind: "colour" },
215
+ { name: "--vk-fg-on-brand", kind: "colour" },
216
+ { name: "--vk-fg-inverse", kind: "colour" },
217
+ { name: "--vk-fg-subtle", kind: "colour" },
218
+ { name: "--vk-fg-subtlest", kind: "colour" },
219
+ { name: "--vk-brand-hovered", kind: "colour" },
220
+ { name: "--vk-brand-pressed", kind: "colour" },
221
+ { name: "--vk-brand-subtler", kind: "colour" },
222
+ { name: "--vk-brand-subtler-hovered", kind: "colour" },
223
+ { name: "--vk-brand-subtler-pressed", kind: "colour" },
224
+ { name: "--vk-danger-bold", kind: "colour" },
225
+ { name: "--vk-danger-bold-hovered", kind: "colour" },
226
+ { name: "--vk-danger-bold-pressed", kind: "colour" },
227
+ { name: "--vk-info-bold", kind: "colour" },
228
+ { name: "--vk-info-bold-hovered", kind: "colour" },
229
+ { name: "--vk-info-bold-pressed", kind: "colour" },
230
+ { name: "--vk-success-bold", kind: "colour" },
231
+ { name: "--vk-success-bold-hovered", kind: "colour" },
232
+ { name: "--vk-success-bold-pressed", kind: "colour" },
233
+ { name: "--vk-warning-bold", kind: "colour" },
234
+ { name: "--vk-warning-bold-hovered", kind: "colour" },
235
+ { name: "--vk-warning-bold-pressed", kind: "colour" },
236
+ { name: "--vk-brighten", kind: "colour" },
237
+ { name: "--vk-darken", kind: "colour" },
238
+ { name: "--vk-border-input", kind: "colour" },
239
+ { name: "--vk-border-input-hovered", kind: "colour" },
240
+ { name: "--vk-raised", kind: "colour" },
241
+ { name: "--vk-raised-hovered", kind: "colour" },
242
+ { name: "--vk-overlay-hovered", kind: "colour" },
243
+ { name: "--vk-overlay-pressed", kind: "colour" },
244
+ { name: "--vk-overlay-card-pressed", kind: "colour" },
245
+ { name: "--vk-fg-disabled", kind: "colour" },
246
+ { name: "--vk-fg-accent", kind: "colour" },
247
+ { name: "--vk-border-width", kind: "size" },
248
+ { name: "--vk-corner-smoothing", kind: "size" },
249
+ { name: "--vk-dot-size", kind: "size" },
250
+ { name: "--vk-duration-instant", kind: "motion" },
251
+ { name: "--vk-duration-fast", kind: "motion" },
252
+ { name: "--vk-duration-base", kind: "motion" },
253
+ { name: "--vk-duration-slow", kind: "motion" },
254
+ { name: "--vk-ease-out", kind: "motion" },
255
+ { name: "--vk-ease-in-out", kind: "motion" },
256
+ { name: "--vk-ease-spring", kind: "motion" },
257
+ { name: "--vk-focus-width", kind: "size" },
258
+ { name: "--vk-focus-offset", kind: "size" },
259
+ { name: "--vk-font-weight-medium", kind: "size" },
260
+ { name: "--vk-font-weight-semibold", kind: "size" },
261
+ { name: "--vk-hover-lift", kind: "motion" },
262
+ { name: "--vk-loading-dim", kind: "motion" },
263
+ { name: "--vk-press-scale", kind: "motion" },
264
+ { name: "--vk-press-squash", kind: "motion" },
265
+ { name: "--vk-press-travel", kind: "motion" },
266
+ { name: "--vk-press-travel-lg", kind: "motion" },
267
+ { name: "--vk-progress-slide", kind: "motion" },
268
+ { name: "--vk-radius-xs", kind: "size" },
269
+ { name: "--vk-radius-sm", kind: "size" },
270
+ { name: "--vk-radius-md", kind: "size" },
271
+ { name: "--vk-radius-lg", kind: "size" },
272
+ { name: "--vk-radius-xl", kind: "size" },
273
+ { name: "--vk-radius-2xl", kind: "size" },
274
+ { name: "--vk-radius-full", kind: "size" },
275
+ { name: "--vk-shadow-key", kind: "shadow" },
276
+ { name: "--vk-shadow-key-pressed", kind: "shadow" },
277
+ { name: "--vk-shadow-key-pressed-bold", kind: "shadow" },
278
+ { name: "--vk-shadow-key-shallow", kind: "shadow" },
279
+ { name: "--vk-shadow-key-soft", kind: "shadow" },
280
+ { name: "--vk-shadow-key-subtle", kind: "shadow" },
281
+ { name: "--vk-shadow-key-subtle-raised", kind: "shadow" },
282
+ { name: "--vk-shadow-lift", kind: "shadow" },
283
+ { name: "--vk-shadow-lift-raised", kind: "shadow" },
284
+ { name: "--vk-shadow-rim", kind: "shadow" },
285
+ { name: "--vk-shadow-rim-bold", kind: "shadow" },
286
+ { name: "--vk-shadow-rim-bold-raised", kind: "shadow" },
287
+ { name: "--vk-shadow-rim-raised", kind: "shadow" },
288
+ { name: "--vk-spacing", kind: "size" },
289
+ { name: "--vk-spinner-breath", kind: "motion" },
290
+ { name: "--vk-spinner-turn", kind: "motion" },
291
+ { name: "--vk-spinner-turn-reduced", kind: "motion" },
292
+ { name: "--vk-font-size-xs", kind: "size" },
293
+ { name: "--vk-font-size-sm", kind: "size" },
294
+ { name: "--vk-font-size-base", kind: "size" },
295
+ { name: "--vk-font-size-lg", kind: "size" },
296
+ ];
297
+ export const VK_CONTROL_PRIVATE_FAMILIES = ["--button-", "--smooth-", "--o-spinner-", "--o-loading-", "--pressing-room-"];
202
298
  export const COMPONENT_NAMES = [
203
299
  "Button",
204
300
  "Popover",
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import { Button as BaseButton } from "@base-ui/react/button";
3
+ import { type ButtonOwnLook } from "./own-look.js";
4
+ export type ButtonKind = "primary" | "outline" | "soft" | "quiet" | "danger" | "information" | "success" | "warning" | "link" | "text";
5
+ export type ButtonSize = "2xs" | "xs" | "sm" | "md" | "lg" | "44" | "20" | "22" | "26" | "20x24" | "32x44" | "40x44" | "line";
6
+ export type ButtonShape = "default" | "icon" | "round";
7
+ /** The Button's classes for a kind, a size and a form; left out, outline, md and default. */
8
+ export declare function buttonClass(kind?: ButtonKind | null, size?: ButtonSize | null, shape?: ButtonShape | null): string;
9
+ export interface ButtonProps extends Omit<BaseButton.Props, "className"> {
10
+ kind?: ButtonKind | null;
11
+ size?: ButtonSize | null;
12
+ shape?: ButtonShape | null;
13
+ /** Working: the label keeps the button's width under a spinner, and a press does nothing. */
14
+ loading?: boolean;
15
+ /** An icon before the label (15px); an icon-only button's one icon. */
16
+ icon?: React.ReactNode;
17
+ /** An icon after the label: a menu's chevron. */
18
+ iconEnd?: React.ReactNode;
19
+ /** A Button's own look: the options it names, set on it. */
20
+ look?: ButtonOwnLook;
21
+ className?: string;
22
+ }
23
+ /** What a person presses to make something happen. */
24
+ export declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
25
+ /** Buttons joined in one row (or a column): the corners between them square, the edges shared, as one control. It holds
26
+ * Buttons, a ButtonGroupText, a ButtonGroupSeparator, or groups of its own, set apart. */
27
+ export declare function ButtonGroup({ orientation, className, children, ...props }: {
28
+ orientation?: "horizontal" | "vertical";
29
+ className?: string;
30
+ children: React.ReactNode;
31
+ } & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
32
+ /** Words inside a group, on the neutral ground with the group's edge: a unit, a count, what the buttons act on. */
33
+ export declare function ButtonGroupText({ className, children, ...props }: {
34
+ className?: string;
35
+ children: React.ReactNode;
36
+ } & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
37
+ /** A line between two buttons of a group that have no edge of their own (the soft kind, the primary). */
38
+ export declare function ButtonGroupSeparator({ className }: {
39
+ className?: string;
40
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Button as BaseButton } from "@base-ui/react/button";
4
+ import { cx } from "../../internal/cx.js";
5
+ import { Spinner } from "../spinner/spinner.js";
6
+ import { buttonOwnAttrs } from "./own-look.js";
7
+ const KIND = {
8
+ primary: "o-button-primary", outline: "o-button-outline", soft: "o-button-soft", quiet: "o-button-quiet", danger: "o-button-danger",
9
+ information: "o-button-information", success: "o-button-success", warning: "o-button-warning", link: "o-button-link", text: "o-button-text",
10
+ };
11
+ const SIZE = {
12
+ "2xs": "o-button-2xs", xs: "o-button-xs", sm: "o-button-sm", md: "", lg: "o-button-lg", "44": "o-button-44",
13
+ "20": "o-button-20", "22": "o-button-22", "26": "o-button-26", "20x24": "o-button-20x24", "32x44": "o-button-32x44", "40x44": "o-button-40x44", line: "o-button-line",
14
+ };
15
+ const SHAPE = { default: "", icon: "o-button-icon", round: "o-button-round" };
16
+ export function buttonClass(kind, size, shape) {
17
+ return cx("o-button", KIND[kind ?? "outline"], SIZE[size ?? "md"], SHAPE[shape ?? "default"]);
18
+ }
19
+ export const Button = React.forwardRef(function Button({ kind, size, shape, loading = false, icon, iconEnd, look, className, children, onClick, ...props }, ref) {
20
+ if (process.env.NODE_ENV !== "production" && (shape === "icon" || shape === "round") && !props["aria-label"] && !props["aria-labelledby"])
21
+ console.warn("ViewKit Button: an icon-only button needs an aria-label, the name its tooltip shows too.");
22
+ const link = React.isValidElement(props.render) && props.render.props.href != null;
23
+ const linkKeys = link ? {
24
+ role: props.role,
25
+ onKeyDown: (e) => { if (e.key === " ")
26
+ e.preventBaseUIHandler?.(); props.onKeyDown?.(e); },
27
+ onKeyUp: (e) => { if (e.key === " ")
28
+ e.preventBaseUIHandler?.(); props.onKeyUp?.(e); },
29
+ } : {};
30
+ return (_jsxs(BaseButton, { ref: ref, className: cx(buttonClass(kind, size, shape), className), "aria-busy": loading || undefined, onClick: loading ? (e) => e.preventDefault() : onClick, "data-kit": "button", ...(look ? buttonOwnAttrs(look) : {}), ...props, ...linkKeys, children: [icon != null && _jsx("span", { "data-slot": "vk-button-icon", children: icon }), children != null && _jsx("span", { "data-slot": "vk-button-label", children: children }), iconEnd != null && _jsx("span", { "data-slot": "vk-button-icon", children: iconEnd }), loading && _jsx("span", { "data-slot": "vk-button-spinner", children: _jsx(Spinner, { size: size === "sm" ? 14 : size == null || size === "md" || size === "lg" || size === "44" || size === "32x44" || size === "40x44" ? 16 : 12, label: "" }) }), _jsx("span", { className: "o-button-cut", "aria-hidden": "true", children: _jsx("span", { className: "o-smooth o-smooth-ease" }) })] }));
31
+ });
32
+ export function ButtonGroup({ orientation = "horizontal", className, children, ...props }) {
33
+ return _jsx("div", { role: "group", "data-orientation": orientation, className: cx("o-button-group", className), ...props, children: children });
34
+ }
35
+ export function ButtonGroupText({ className, children, ...props }) {
36
+ return _jsx("div", { className: cx("o-button-group-text", className), ...props, children: children });
37
+ }
38
+ export function ButtonGroupSeparator({ className }) {
39
+ return _jsx("span", { role: "separator", className: cx("o-button-group-sep", className) });
40
+ }
@@ -0,0 +1,4 @@
1
+ import type { PieceLooks } from "../../looks/looks.js";
2
+ export type ButtonLookOptionId = "radius" | "smoothing" | "depth" | "hover" | "press" | "soft" | "weight";
3
+ /** The Button's options and looks. */
4
+ export declare const BUTTON_LOOKS: PieceLooks<ButtonLookOptionId>;
@@ -0,0 +1,20 @@
1
+ const options = [
2
+ { id: "radius", name: "Corners", def: "lg", kind: "steps", values: ["xs", "sm", "md", "lg", "xl", "2xl", "full"].map((id) => ({ id, name: id === "full" ? "Full" : id })) },
3
+ { id: "smoothing", name: "Corner smoothing", def: "app", values: [{ id: "app", name: "The app's" }, { id: "smooth", name: "Smooth" }, { id: "round", name: "Round" }] },
4
+ { id: "depth", name: "Depth", def: "flat", values: [{ id: "flat", name: "Flat" }, { id: "edged", name: "Edged" }, { id: "lifted", name: "Lifted" }] },
5
+ { id: "hover", name: "Under the pointer", def: "tone", values: [{ id: "tone", name: "A tone" }, { id: "brighter", name: "Brighter" }, { id: "rises", name: "Rises" }] },
6
+ { id: "press", name: "Press", def: "settles", values: [{ id: "settles", name: "Settles" }, { id: "sinks", name: "Sinks" }, { id: "springs", name: "Springs" }, { id: "lands", name: "Lands" }] },
7
+ { id: "soft", name: "The soft kind", def: "grey", values: [{ id: "grey", name: "Grey" }, { id: "tint", name: "Brand tint" }] },
8
+ { id: "weight", name: "Label weight", def: "medium", values: [{ id: "medium", name: "Medium" }, { id: "semibold", name: "Semibold" }] },
9
+ ];
10
+ export const BUTTON_LOOKS = {
11
+ id: "button",
12
+ name: "Button",
13
+ options,
14
+ looks: [
15
+ { id: "classic", name: "Classic", picks: { radius: "lg", smoothing: "app", depth: "flat", hover: "tone", press: "settles", soft: "grey", weight: "medium" } },
16
+ { id: "keycap", name: "Keycap", picks: { radius: "lg", smoothing: "app", depth: "edged", hover: "brighter", press: "sinks", soft: "grey", weight: "medium" } },
17
+ { id: "pill", name: "Pill", picks: { radius: "full", smoothing: "app", depth: "flat", hover: "tone", press: "springs", soft: "tint", weight: "medium" } },
18
+ { id: "soft-lift", name: "Soft lift", picks: { radius: "lg", smoothing: "app", depth: "lifted", hover: "rises", press: "lands", soft: "grey", weight: "medium" } },
19
+ ],
20
+ };
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import type { ViewsButtonProps } from "../../provider/components.js";
3
+ /** A glyph ViewKit hands before a button's words (+ Add column's "+", its icon in a fragment with the words) is the Button's
4
+ * icon, so it stands before the words on one line, never stacked over them in the label. The glyph is an svg or one of the
5
+ * app's icons (`glyphs`), never another component; a glyph alone stays the children. */
6
+ export declare function leadingGlyph(children: React.ReactNode, glyphs: ReadonlySet<unknown>): {
7
+ icon?: React.ReactNode;
8
+ label: React.ReactNode;
9
+ };
10
+ /** ViewKit's button, drawn as the kit's Button. Outside a provider (an app drawing it on its own) only an svg is a glyph. */
11
+ export declare function MapButton({ variant, size, type, children, ...rest }: ViewsButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { ViewsContext } from "../../provider/context.js";
4
+ import { Button } from "./button.js";
5
+ const KIND = {
6
+ default: "primary", ghost: "quiet", outline: "outline", destructive: "danger", secondary: "soft",
7
+ };
8
+ export function leadingGlyph(children, glyphs) {
9
+ const inner = React.isValidElement(children) && children.type === React.Fragment ? children.props.children : children;
10
+ const parts = React.Children.toArray(inner);
11
+ const first = parts[0];
12
+ const glyph = React.isValidElement(first) && (first.type === "svg" || glyphs.has(first.type));
13
+ return parts.length > 1 && glyph ? { icon: first, label: parts.slice(1) } : { label: children };
14
+ }
15
+ export function MapButton({ variant = "default", size = "default", type = "button", children, ...rest }) {
16
+ const icons = React.useContext(ViewsContext)?.icons;
17
+ const glyphs = React.useMemo(() => new Set(icons ? Object.values(icons) : []), [icons]);
18
+ const { icon, label } = size === "icon" ? { icon: undefined, label: children } : leadingGlyph(children, glyphs);
19
+ return _jsx(Button, { kind: KIND[variant], size: size === "default" ? "md" : "sm", shape: size === "icon" ? "icon" : "default", type: type, icon: icon, ...rest, children: label });
20
+ }
@@ -0,0 +1,59 @@
1
+ export interface ButtonOwnLook {
2
+ /** Its radius step; none, square. */
3
+ radius?: "none" | "xs" | "sm" | "md" | "lg";
4
+ /** Its corners round, never the smooth corner. */
5
+ corner?: "round";
6
+ /** No edge: none of the Button's 1px border. */
7
+ edge?: "none";
8
+ /** Its words: the place's (size, weight, line), or the place's at xs or sm, or xs at medium. */
9
+ words?: "inherit" | "xs" | "sm" | "xs-medium" | "lg";
10
+ /** Its colour, kept in every state but disabled: faint, the link's, the text's, or the place's. */
11
+ colour?: "faint" | "link" | "text" | "inherit";
12
+ /** Its icons' size, px. */
13
+ icon?: "12" | "14" | "15" | "16" | "20";
14
+ /** Its icons' colour apart from its words: faint, in every state; or subtle, the quiet kind's rest, kept while its words
15
+ * take the text's colour under the pointer, in every state but disabled; or the brand's. */
16
+ iconColour?: "faint" | "subtle" | "brand";
17
+ /** Its room left and right, px: none, the same each side, or 6 at its start and 4 at its end. */
18
+ pad?: "0" | "4" | "6" | "8" | "6-4";
19
+ /** The room between its words and its icons, px. */
20
+ gap?: "3" | "4" | "6" | "8" | "10";
21
+ /** Under the pointer: nothing changes; or its words alone take the text's colour, no ground under them; or a ground of its
22
+ * own: the popup's hover (overlay), or the neutral ground, pressed too. */
23
+ hover?: "none" | "words" | "overlay" | "neutral";
24
+ /** Open (aria-expanded="true"): the ground it has under the pointer; its words and icons in the brand's colour; or the
25
+ * neutral ground. */
26
+ open?: "hovered" | "brand" | "neutral";
27
+ /** Standing pressed (aria-pressed="true"): the popup's hover as its ground, its words the text's. */
28
+ pressed?: "hovered";
29
+ /** Disabled, it keeps its colour and the arrow: plain, never the disabled grey. With a colour named; a quiet Button keeps no
30
+ * ground. */
31
+ disabled?: "plain";
32
+ /** The hand that grabs: a grip's. */
33
+ cursor?: "grab";
34
+ /** Pressed on a card in a popup: the card's pressed step. */
35
+ press?: "card";
36
+ /** Its words at its start, its label growing so an end icon stands at its end. */
37
+ align?: "start";
38
+ /** Its words semibold, over its words' own weight. The frame's Label weight is read from around it, never from it. */
39
+ weight?: "semibold" | "medium";
40
+ /** Its digits one width each (tabular), a month and a year that change in place. */
41
+ digits?: "tabular";
42
+ /** Its last icon turned while what it opens is open or shut (aria-expanded): a quarter clockwise while open (an arrow drawn
43
+ * pointing right), or a quarter back while shut (an arrow drawn pointing down). */
44
+ turn?: "quarter" | "back";
45
+ /** A dot in the brand's colour at its top end corner, saying something is on: set it while it is. */
46
+ dot?: "brand";
47
+ /** Its words cut with … at their end when its place is narrower than they are. */
48
+ cut?: "end";
49
+ /** Room at its end, px, for something laid over it. */
50
+ endRoom?: "30";
51
+ }
52
+ /** Each own option, the attribute it sets (data-button-<attr>) and its values. */
53
+ export declare const buttonOwnOptions: {
54
+ id: keyof ButtonOwnLook;
55
+ attr: string;
56
+ values: string[];
57
+ }[];
58
+ /** The attributes of a Button's own look, on the Button: data-button-own, then each option it names, and only those. */
59
+ export declare function buttonOwnAttrs(look: ButtonOwnLook): Record<string, string>;
@@ -0,0 +1,33 @@
1
+ export const buttonOwnOptions = [
2
+ { id: "radius", attr: "radius", values: ["none", "xs", "sm", "md", "lg"] },
3
+ { id: "corner", attr: "corner", values: ["round"] },
4
+ { id: "edge", attr: "edge", values: ["none"] },
5
+ { id: "words", attr: "words", values: ["inherit", "xs", "sm", "xs-medium", "lg"] },
6
+ { id: "colour", attr: "colour", values: ["faint", "link", "text", "inherit"] },
7
+ { id: "icon", attr: "icon", values: ["12", "14", "15", "16", "20"] },
8
+ { id: "iconColour", attr: "icon-colour", values: ["faint", "subtle", "brand"] },
9
+ { id: "pad", attr: "pad", values: ["0", "4", "6", "8", "6-4"] },
10
+ { id: "gap", attr: "gap", values: ["3", "4", "6", "8", "10"] },
11
+ { id: "hover", attr: "hover", values: ["none", "words", "overlay", "neutral"] },
12
+ { id: "open", attr: "open", values: ["hovered", "brand", "neutral"] },
13
+ { id: "pressed", attr: "pressed", values: ["hovered"] },
14
+ { id: "disabled", attr: "disabled", values: ["plain"] },
15
+ { id: "cursor", attr: "cursor", values: ["grab"] },
16
+ { id: "press", attr: "press", values: ["card"] },
17
+ { id: "align", attr: "align", values: ["start"] },
18
+ { id: "weight", attr: "weight", values: ["semibold", "medium"] },
19
+ { id: "digits", attr: "digits", values: ["tabular"] },
20
+ { id: "turn", attr: "turn", values: ["quarter", "back"] },
21
+ { id: "dot", attr: "dot", values: ["brand"] },
22
+ { id: "cut", attr: "cut", values: ["end"] },
23
+ { id: "endRoom", attr: "end-room", values: ["30"] },
24
+ ];
25
+ export function buttonOwnAttrs(look) {
26
+ const attrs = { "data-button-own": "" };
27
+ for (const o of buttonOwnOptions) {
28
+ const v = look[o.id];
29
+ if (v != null)
30
+ attrs[`data-button-${o.attr}`] = v;
31
+ }
32
+ return attrs;
33
+ }