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
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ export { CONTROLS } from "./controls.js";
3
+ export { Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonClass, } from "./button/button.js";
4
+ export { leadingGlyph } from "./button/map-button.js";
5
+ export { buttonOwnAttrs, buttonOwnOptions } from "./button/own-look.js";
6
+ export { LoadingBar, Spinner } from "./spinner/spinner.js";
@@ -0,0 +1,101 @@
1
+ /* The smooth corner, the kit's one outline: a corner cut by a drawn outline instead of a quarter circle,
2
+ so every browser that knows shape() shows it. Each corner is three curves, Apple's own sheet as measured (smoothing 70%): the bend
3
+ starts 1.7 radii from the corner and meets the quarter circle at its tip, so a corner stands as large as a round one and comes in
4
+ softer. A component puts o-smooth on what it clips, sets its inputs there, and clips with the outputs, inside its own
5
+ @supports (clip-path: shape(…)), so a browser without shape() keeps its quarter circles.
6
+
7
+ Inputs, on the o-smooth element (or its ::before or ::after, for a ring's inner line):
8
+ --smooth-t the top corners' radius
9
+ --smooth-b the bottom corners' radius; --smooth-t unless set
10
+ --smooth-in how far in the outline stands, for a ring's inner line on the element's own box; 0 unless set
11
+ --smooth-foot where its bottom edge stands; 100% unless set (a Blend's cut)
12
+ --smooth-side with o-smooth-ease: the box's shorter side, which eases the smoothing where it is too short for it
13
+ --smooth-amount with o-smooth-ease: the most smoothing it takes, 0.7 (Apple's) unless set; 0 is a quarter circle. A control
14
+ sets it from the token corner-smoothing, or by its own Corner smoothing. It inherits, so it is
15
+ set on what draws the outline (a control's cut), never on a box that can hold another (an Option holds an Avatar);
16
+ where a host that follows the token holds what it can't foresee (a crumb, a tab), the Avatar sets its own, initial,
17
+ so no host's amount reaches it.
18
+ A control gives the outline a radius that fits its side, side / (2 + 2 × amount), so the whole bend fits and the
19
+ smoothing stays; the Avatar gives its own radius and eases instead
20
+ Outputs:
21
+ --smooth-outline the whole outline: clip-path: shape(var(--smooth-outline))
22
+ --smooth-path the outline after its start point
23
+ --smooth-ring on a ::before or ::after: the ring between the element's outline and its own (a line in), as an edge drawn
24
+ along the curve: clip-path: shape(var(--smooth-ring))
25
+
26
+ The curve's numbers are a share of a corner's radius. Apple's are fixed, so whatever takes them draws as the six copies did before
27
+ this file. o-smooth-ease works them out from the smoothing instead, as Figma does where 1.7 radii don't fit at each end of a side:
28
+ --smooth-x, the least of the amount (0.7 unless set) and half the side over the radius less one (0, a quarter circle, where the
29
+ radius takes half the side). A custom property is worked out where it is declared, so the outline is declared on each element
30
+ that draws it.
31
+
32
+ Registered: the top radius, the side and the thirteen numbers, each worked out once, where it is declared, to one
33
+ length or one number, so the outline that reads them holds `8.82px * 1.7` where it held their whole sums again in each of its
34
+ terms (a Button's was 52,000 characters, worked out on every restyle). The radius and the
35
+ side are registered as lengths so that --smooth-x reads them as px: worked out as a number, atan2 over a container's or a
36
+ font's unit is wrong in WebKit and impossible in Firefox. --smooth-b, --smooth-in, --smooth-foot and --smooth-amount stay
37
+ plain, as each is read with a fallback that a registered property never falls back to. */
38
+ @property --smooth-t { syntax: "<length-percentage>"; inherits: true; initial-value: 0px; }
39
+ @property --smooth-side { syntax: "<length>"; inherits: true; initial-value: 0px; }
40
+ @property --smooth-x { syntax: "<number>"; inherits: true; initial-value: 0; }
41
+ @property --smooth-k { syntax: "<number>"; inherits: true; initial-value: 0; }
42
+ @property --smooth-cc { syntax: "<number>"; inherits: true; initial-value: 0; }
43
+ @property --smooth-d { syntax: "<number>"; inherits: true; initial-value: 0; }
44
+ @property --smooth-p { syntax: "<number>"; inherits: true; initial-value: 0; }
45
+ @property --smooth-a2 { syntax: "<number>"; inherits: true; initial-value: 0; }
46
+ @property --smooth-a1 { syntax: "<number>"; inherits: true; initial-value: 0; }
47
+ @property --smooth-bc { syntax: "<number>"; inherits: true; initial-value: 0; }
48
+ @property --smooth-e { syntax: "<number>"; inherits: true; initial-value: 0; }
49
+ @property --smooth-hx { syntax: "<number>"; inherits: true; initial-value: 0; }
50
+ @property --smooth-hy { syntax: "<number>"; inherits: true; initial-value: 0; }
51
+ @property --smooth-khy { syntax: "<number>"; inherits: true; initial-value: 0; }
52
+ @property --smooth-khx { syntax: "<number>"; inherits: true; initial-value: 0; }
53
+ @layer components {
54
+
55
+ .o-smooth, .o-smooth::before, .o-smooth::after {
56
+ /* The first curve's reach (e) and drop (d), its handles (a1, a2); the arc's chord (k) and handles (hx, hy, and k less each); the
57
+ last curve's handles (cc, bc); where the bend starts (p). Apple's, at 70%. */
58
+ --smooth-e: 1.222; --smooth-d: 0.147; --smooth-a1: 0.655; --smooth-a2: 0.982; --smooth-k: 0.33; --smooth-hx: 0.135; --smooth-hy: 0.082;
59
+ --smooth-khy: 0.248; --smooth-khx: 0.196; --smooth-cc: 0.24; --smooth-bc: 0.568; --smooth-p: 1.7;
60
+ --smooth-path:
61
+ hline to calc(100% - var(--smooth-in, 0px) - var(--smooth-t) * var(--smooth-p)),
62
+ curve by calc(var(--smooth-t) * var(--smooth-e)) calc(var(--smooth-t) * var(--smooth-d)) with calc(var(--smooth-t) * var(--smooth-a1)) 0 / calc(var(--smooth-t) * var(--smooth-a2)) 0,
63
+ curve by calc(var(--smooth-t) * var(--smooth-k)) calc(var(--smooth-t) * var(--smooth-k)) with calc(var(--smooth-t) * var(--smooth-hx)) calc(var(--smooth-t) * var(--smooth-hy)) / calc(var(--smooth-t) * var(--smooth-khy)) calc(var(--smooth-t) * var(--smooth-khx)),
64
+ curve by calc(var(--smooth-t) * var(--smooth-d)) calc(var(--smooth-t) * var(--smooth-e)) with calc(var(--smooth-t) * var(--smooth-d)) calc(var(--smooth-t) * var(--smooth-cc)) / calc(var(--smooth-t) * var(--smooth-d)) calc(var(--smooth-t) * var(--smooth-bc)),
65
+ vline to calc(var(--smooth-foot, 100%) - var(--smooth-in, 0px) - var(--smooth-b, var(--smooth-t)) * var(--smooth-p)),
66
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-e)) with 0 calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-a1)) / 0 calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-a2)),
67
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-k) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-k)) with calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-hy) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-hx)) / calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-khx) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-khy)),
68
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-e) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d)) with calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-cc) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d)) / calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-bc) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d)),
69
+ hline to calc(var(--smooth-in, 0px) + var(--smooth-b, var(--smooth-t)) * var(--smooth-p)),
70
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-e) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d) * -1) with calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-a1) * -1) 0 / calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-a2) * -1) 0,
71
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-k) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-k) * -1) with calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-hx) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-hy) * -1) / calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-khy) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-khx) * -1),
72
+ curve by calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-e) * -1) with calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-cc) * -1) / calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-d) * -1) calc(var(--smooth-b, var(--smooth-t)) * var(--smooth-bc) * -1),
73
+ vline to calc(var(--smooth-in, 0px) + var(--smooth-t) * var(--smooth-p)),
74
+ curve by calc(var(--smooth-t) * var(--smooth-d)) calc(var(--smooth-t) * var(--smooth-e) * -1) with 0 calc(var(--smooth-t) * var(--smooth-a1) * -1) / 0 calc(var(--smooth-t) * var(--smooth-a2) * -1),
75
+ curve by calc(var(--smooth-t) * var(--smooth-k)) calc(var(--smooth-t) * var(--smooth-k) * -1) with calc(var(--smooth-t) * var(--smooth-hy)) calc(var(--smooth-t) * var(--smooth-hx) * -1) / calc(var(--smooth-t) * var(--smooth-khx)) calc(var(--smooth-t) * var(--smooth-khy) * -1),
76
+ curve by calc(var(--smooth-t) * var(--smooth-e)) calc(var(--smooth-t) * var(--smooth-d) * -1) with calc(var(--smooth-t) * var(--smooth-cc)) calc(var(--smooth-t) * var(--smooth-d) * -1) / calc(var(--smooth-t) * var(--smooth-bc)) calc(var(--smooth-t) * var(--smooth-d) * -1),
77
+ close;
78
+ --smooth-outline: from calc(var(--smooth-in, 0px) + var(--smooth-t) * var(--smooth-p)) var(--smooth-in, 0px), var(--smooth-path);
79
+ --smooth-ring: evenodd var(--smooth-outer), move to calc(var(--smooth-in, 0px) + var(--smooth-t) * var(--smooth-p)) var(--smooth-in, 0px), var(--smooth-path);
80
+ }
81
+ /* The element's own outline, as it worked it out: what its ::before or ::after reads for a ring's outer line. */
82
+ .o-smooth { --smooth-outer: var(--smooth-outline); }
83
+
84
+ /* Eased on a short side: the smoothing from the side and the top radius, on the element alone so its ring takes the same; each number
85
+ from it (at 0.7 these give Apple's within a thousandth). */
86
+ .o-smooth.o-smooth-ease { --smooth-x: clamp(0, tan(atan2(var(--smooth-side), var(--smooth-t) * 2)) - 1, var(--smooth-amount, 0.7)); }
87
+ .o-smooth.o-smooth-ease, .o-smooth.o-smooth-ease::before, .o-smooth.o-smooth-ease::after {
88
+ --smooth-k: calc(sin(45deg * (1 - var(--smooth-x))) * 1.414214);
89
+ --smooth-cc: calc(tan(22.5deg * var(--smooth-x)) * cos(45deg * var(--smooth-x)));
90
+ --smooth-d: calc(tan(22.5deg * var(--smooth-x)) * sin(45deg * var(--smooth-x)));
91
+ --smooth-p: calc(1 + var(--smooth-x));
92
+ --smooth-a2: calc(var(--smooth-p) - var(--smooth-k) - var(--smooth-cc) - var(--smooth-d));
93
+ --smooth-a1: calc(var(--smooth-a2) * 2 / 3);
94
+ --smooth-bc: calc(var(--smooth-a2) / 3 + var(--smooth-cc));
95
+ --smooth-e: calc(var(--smooth-p) - var(--smooth-k) - var(--smooth-d));
96
+ --smooth-hx: calc(tan(22.5deg * (1 - var(--smooth-x))) * 4 / 3 * cos(45deg * var(--smooth-x)));
97
+ --smooth-hy: calc(tan(22.5deg * (1 - var(--smooth-x))) * 4 / 3 * sin(45deg * var(--smooth-x)));
98
+ --smooth-khy: calc(var(--smooth-k) - var(--smooth-hy));
99
+ --smooth-khx: calc(var(--smooth-k) - var(--smooth-hx));
100
+ }
101
+ }
@@ -0,0 +1,4 @@
1
+ import type { PieceLooks } from "../../looks/looks.js";
2
+ export type SpinnerLookOptionId = "kind" | "breath" | "line" | "track" | "bars" | "loading";
3
+ /** The Spinner's options and looks. */
4
+ export declare const SPINNER_LOOKS: PieceLooks<SpinnerLookOptionId>;
@@ -0,0 +1,32 @@
1
+ const NOT_ARC = ["tail", "halves", "bars", "pulse"];
2
+ const NOT_RING = ["bars", "pulse"];
3
+ const NOT_BARS = ["arc", "tail", "halves", "pulse"];
4
+ const options = [
5
+ { id: "kind", name: "Kind", def: "tail", values: [{ id: "arc", name: "Arc" }, { id: "tail", name: "Tail" }, { id: "halves", name: "Two halves" }, { id: "bars", name: "Bars" }, { id: "pulse", name: "Pulse" }] },
6
+ { id: "breath", name: "Breath", def: "dot", unless: ["kind", NOT_ARC], values: [{ id: "dot", name: "From a dot" }, { id: "slow", name: "Slower" }, { id: "open", name: "Never a dot" }, { id: "soft", name: "Soft" }, { id: "barely", name: "Barely" }] },
7
+ { id: "line", name: "Line", def: "regular", unless: ["kind", NOT_RING], values: [{ id: "regular", name: "Regular" }, { id: "thin", name: "Thin" }] },
8
+ { id: "track", name: "Track", def: "none", unless: ["kind", NOT_RING], values: [{ id: "none", name: "None" }, { id: "faint", name: "Faint" }] },
9
+ { id: "bars", name: "Bars", def: "plain", unless: ["kind", NOT_BARS], values: [{ id: "plain", name: "Plain" }, { id: "eased", name: "Eased" }, { id: "foot", name: "From the foot" }] },
10
+ { id: "loading", name: "Loading bar", def: "soft", values: [{ id: "slides", name: "Slides" }, { id: "soft", name: "Soft ends" }] },
11
+ ];
12
+ const base = { kind: "arc", breath: "dot", line: "regular", track: "none", bars: "plain", loading: "slides" };
13
+ export const SPINNER_LOOKS = {
14
+ id: "spinner",
15
+ name: "Spinner",
16
+ options,
17
+ looks: [
18
+ { id: "arc", name: "Arc", picks: { ...base } },
19
+ { id: "slow", name: "Slow arc", picks: { ...base, breath: "slow" } },
20
+ { id: "open", name: "Never a dot", picks: { ...base, breath: "open" } },
21
+ { id: "soft", name: "Soft breath", picks: { ...base, breath: "soft" } },
22
+ { id: "barely", name: "Barely breathing", picks: { ...base, breath: "barely" } },
23
+ { id: "thin", name: "Thin line", picks: { ...base, breath: "soft", line: "thin" } },
24
+ { id: "track", name: "On a track", picks: { ...base, breath: "soft", track: "faint" } },
25
+ { id: "tail", name: "Tail", picks: { ...base, kind: "tail" } },
26
+ { id: "halves", name: "Two halves", picks: { ...base, kind: "halves" } },
27
+ { id: "bars", name: "Bars", picks: { ...base, kind: "bars" } },
28
+ { id: "bars-eased", name: "Eased bars", picks: { ...base, kind: "bars", bars: "eased" } },
29
+ { id: "equalizer", name: "Equalizer", picks: { ...base, kind: "bars", bars: "foot" } },
30
+ { id: "pulse", name: "Pulse", picks: { ...base, kind: "pulse" } },
31
+ ],
32
+ };
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ export interface SpinnerProps {
3
+ /** Its size in px: 12 in a chip, 14 in a toast or a small button, 16 in a button, field or row, 20 in a panel, 24 in a list, 32 while the app starts, 40 alone on a page. */
4
+ size?: number;
5
+ /** What is loading, said to screen readers ("Loading deals"). Empty when what it stands in for says it, as a busy button does. */
6
+ label?: string;
7
+ className?: string;
8
+ }
9
+ /** Something on its way, in the colour of the words beside it: an arc that grows and shrinks as it turns, or whichever of its
10
+ * looks the app wears (a tail, two halves, bars, a pulse). */
11
+ export declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefAttributes<SVGSVGElement>>;
12
+ export interface LoadingBarProps {
13
+ /** Whether it is loading: the bar shows, and what it holds dims and can't be reached. */
14
+ loading?: boolean;
15
+ /** What is loading, said to screen readers ("Loading deals"). */
16
+ label?: string;
17
+ /** What is loading again: a table's rows, a list. Left out, the bar alone, along the top of the box it stands in, which places it. */
18
+ children?: React.ReactNode;
19
+ className?: string;
20
+ }
21
+ /** The loading bar: a thin bar sliding along the top of what is loading again (a table whose rows change after a filter or a
22
+ * sort), which stays where it is, dimmed and out of reach, until the new rows are in. */
23
+ export declare function LoadingBar({ loading, label, children, className }: LoadingBarProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { cx } from "../../internal/cx.js";
4
+ const LINE = { 12: 6.25, 14: 6.4, 16: 6.25, 20: 5.6, 24: 5.2, 32: 4.7, 40: 4.2 };
5
+ const BARS = [33.33, 46.46, 59.58].map((x, i) => ({ x, at: i ? i * 0.2 - 1 : 0 }));
6
+ const FOOT = [[0.835, -0.14], [1.07, -0.43], [0.74, -0.07], [1.16, -0.64], [0.93, -0.29]].map(([pace, at], i) => ({ x: 31.67 + i * 7.92, pace, at }));
7
+ const set = (vars) => vars;
8
+ export const Spinner = React.forwardRef(function Spinner({ size = 14, label = "Working", className }, ref) {
9
+ return (_jsxs("svg", { ref: ref, className: cx("o-spinner", className), viewBox: "25 25 50 50", style: { width: size, height: size, ...set({ "--o-spinner-l": LINE[size] ?? 6.25 }) }, ...(label ? { role: "status", "aria-label": label } : { "aria-hidden": true }), "data-kit": "spinner", children: [_jsx("circle", { className: "o-spinner-track", cx: "50", cy: "50", r: "20" }), _jsx("circle", { className: "o-spinner-arc", cx: "50", cy: "50", r: "20" }), _jsx("g", { className: "o-spinner-bars", children: BARS.map((b) => _jsx("rect", { x: b.x, y: "33.33", width: "7.08", height: "33.33", rx: "3.54", style: set({ "--o-spinner-at": b.at }) }, b.x)) }), _jsx("g", { className: "o-spinner-bars o-spinner-foot", children: FOOT.map((b) => _jsx("rect", { x: b.x, y: "33.33", width: "5", height: "33.33", rx: "2.5", style: set({ "--o-spinner-at": b.at, "--o-spinner-pace": b.pace }) }, b.x)) }), _jsx("circle", { className: "o-spinner-dot", cx: "50", cy: "50", r: "6.67" }), _jsx("circle", { className: "o-spinner-ring", cx: "50", cy: "50", r: "8.33" })] }));
10
+ });
11
+ export function LoadingBar({ loading = true, label = "Loading", children, className }) {
12
+ const bar = loading ? _jsx("span", { className: "o-loading-bar", role: "progressbar", "aria-label": label, "data-kit": children === undefined ? "spinner" : undefined }) : null;
13
+ if (children === undefined)
14
+ return bar;
15
+ return (_jsxs("div", { className: cx("o-loading", className), "data-loading": loading ? "" : undefined, "aria-busy": loading || undefined, "data-kit": "spinner", children: [bar, _jsx("div", { className: "o-loading-held", inert: loading || undefined, children: children })] }));
16
+ }
@@ -0,0 +1,147 @@
1
+ /* The Spinner, as its card draws it: something on its way, on a 50-unit drawing,
2
+ in the colour of the words beside it. Its line is about an eighth of its size (--o-spinner-l, the drawing's own stroke,
3
+ spinner.tsx). Every kind's parts are in the drawing; this file shows the one the frame or the app around it picks (looks.ts,
4
+ data-spinner-kind, -breath, -line, -track, -bars) and hides the rest. With nothing picked it is the tail, and the loading
5
+ bar's ends are soft: the Outright look's picks. The arc, which a frame names, turns
6
+ once every spinner-turn while its length breathes every spinner-breath, starting a quarter turn and half a breath in, so
7
+ the first frame already shows the arc, never a dot. Every look's pace is a share of those two tokens; the lengths along the
8
+ ring, the bars' heights and the pulse's reach are the drawing's geometry, not tokens.
9
+
10
+ The loading bar is the Spinner's own: a thin bar sliding along the top of what is loading again, which dims to
11
+ loading-dim under it. Its pace is a share of progress-slide, the Progress's bar with no total.
12
+
13
+ The rules sit in the components layer, so a utility class on a spinner still wins. */
14
+ @layer components {
15
+
16
+ /* ── The arc, as a frame that names a kind other than the tail draws it (nothing picked is the tail, below) ─────────────────────────────────────────────────────────────────────── */
17
+ .o-spinner {
18
+ --o-spinner-turn: var(--vk-spinner-turn); --o-spinner-breath: var(--vk-spinner-breath); --o-spinner-weight: 1;
19
+ flex: none; display: inline-block; color: inherit;
20
+ animation: vk-spin-turn var(--o-spinner-turn) linear infinite; animation-delay: calc(var(--o-spinner-turn) * -0.25);
21
+ }
22
+ .o-spinner > :is(.o-spinner-track, .o-spinner-arc) { fill: none; stroke: currentColor; stroke-width: calc(var(--o-spinner-l) * var(--o-spinner-weight) * 1px); }
23
+ .o-spinner > :is(.o-spinner-track, .o-spinner-bars, .o-spinner-dot, .o-spinner-ring) { display: none; }
24
+ .o-spinner-track { opacity: 0.14; }
25
+ .o-spinner-arc {
26
+ stroke-linecap: round; stroke-dasharray: 1 200; stroke-dashoffset: 0;
27
+ animation: vk-spin-breath var(--o-spinner-breath) linear infinite; animation-delay: calc(var(--o-spinner-breath) * -0.5);
28
+ }
29
+
30
+ /* ── Breath, the arc's. Slower: the same at two thirds of its speed. Never a dot: the same two beats, eased, between an eighth
31
+ and five eighths of the ring. Soft: both ends ease out and back round a middle that turns steadily. Barely: the same,
32
+ between a third and a half of the ring ───────────────────────────────────────────────────────────────────────── */
33
+ [data-spinner-breath="slow"] .o-spinner { --o-spinner-turn: calc(var(--vk-spinner-turn) * 1.45); --o-spinner-breath: calc(var(--vk-spinner-breath) * 1.45); }
34
+ [data-spinner-breath="open"] .o-spinner { --o-spinner-turn: calc(var(--vk-spinner-turn) * 2.2); --o-spinner-breath: calc(var(--vk-spinner-breath) * 1.6); }
35
+ [data-spinner-breath="soft"] .o-spinner { --o-spinner-turn: calc(var(--vk-spinner-turn) * 0.8); --o-spinner-breath: calc(var(--vk-spinner-breath) * 1.85); }
36
+ [data-spinner-breath="barely"] .o-spinner { --o-spinner-turn: calc(var(--vk-spinner-turn) * 0.7); --o-spinner-breath: calc(var(--vk-spinner-breath) * 2.15); }
37
+ [data-spinner-breath="open"] .o-spinner-arc { animation-name: vk-spin-open; animation-timing-function: var(--vk-ease-in-out); }
38
+ [data-spinner-breath="soft"] .o-spinner-arc { animation-name: vk-spin-soft; animation-timing-function: var(--vk-ease-in-out); }
39
+ [data-spinner-breath="barely"] .o-spinner-arc { animation-name: vk-spin-barely; animation-timing-function: var(--vk-ease-in-out); }
40
+
41
+ /* ── Line and Track, a ring's: its line lighter, and a faint ring under it ──────────────────────────────────────── */
42
+ [data-spinner-line="thin"] .o-spinner { --o-spinner-weight: 0.65; }
43
+ [data-spinner-track="faint"] .o-spinner > .o-spinner-track { display: inline; }
44
+
45
+ /* ── Kind. These come after Breath, so a kind that isn't the arc takes its own pace and stills the arc's breath.
46
+ Tail: the ring fading out behind its head, steady, only its place changing. The fade is painted on the drawing's own box
47
+ and cut to the ring's line; the arc is its round head, a dot where the fade ends.
48
+ Two halves: two arcs a fifth of the ring each, opposite each other, turning slowly ─────────────────────────────── */
49
+ [data-spinner-kind="tail"] .o-spinner, .o-spinner:not([data-spinner-kind] *) {
50
+ --o-spinner-turn: calc(var(--vk-spinner-turn) * 0.65);
51
+ --o-spinner-in: calc((20 - var(--o-spinner-l) * var(--o-spinner-weight) / 2) * 4%); --o-spinner-out: calc((20 + var(--o-spinner-l) * var(--o-spinner-weight) / 2) * 4%);
52
+ border-radius: var(--vk-radius-full);
53
+ background-image: conic-gradient(transparent 0turn, color-mix(in srgb, currentColor 48%, transparent) 0.133turn, color-mix(in srgb, currentColor 73%, transparent) 0.267turn,
54
+ color-mix(in srgb, currentColor 86%, transparent) 0.4turn, color-mix(in srgb, currentColor 93%, transparent) 0.533turn, transparent 0.533turn);
55
+ -webkit-mask-image: radial-gradient(farthest-side, transparent calc(var(--o-spinner-in) - 0.5px), black var(--o-spinner-in), black var(--o-spinner-out), transparent calc(var(--o-spinner-out) + 0.5px));
56
+ mask-image: radial-gradient(farthest-side, transparent calc(var(--o-spinner-in) - 0.5px), black var(--o-spinner-in), black var(--o-spinner-out), transparent calc(var(--o-spinner-out) + 0.5px));
57
+ }
58
+ [data-spinner-kind="tail"] .o-spinner-arc, .o-spinner-arc:not([data-spinner-kind] *) { animation: none; stroke-dasharray: 0.01 200; stroke-dashoffset: -35.57; }
59
+ [data-spinner-kind="halves"] .o-spinner { --o-spinner-turn: calc(var(--vk-spinner-turn) * 1.1); }
60
+ [data-spinner-kind="halves"] .o-spinner-arc { animation: none; stroke-dasharray: 25.13 37.7; stroke-dashoffset: 0; }
61
+
62
+ /* Bars and the pulse stand still as a whole: only their parts move. */
63
+ :is([data-spinner-kind="bars"], [data-spinner-kind="pulse"]) .o-spinner { animation: none; }
64
+ :is([data-spinner-kind="bars"], [data-spinner-kind="pulse"]) .o-spinner > :is(.o-spinner-track, .o-spinner-arc) { display: none; }
65
+
66
+ /* Bars: three growing from their middle, from three eighths of their height to all of it, one beat every half turn, each a
67
+ fifth of a beat after the one before. Eased: each bar slows at its ends, one beat a breath. From the foot: five, from a
68
+ fifth of their height, each at its own pace (--o-spinner-pace) and place in it (--o-spinner-at) */
69
+ [data-spinner-kind="bars"]:not([data-spinner-bars="foot"]) .o-spinner > .o-spinner-bars:not(.o-spinner-foot),
70
+ [data-spinner-kind="bars"][data-spinner-bars="foot"] .o-spinner > .o-spinner-foot { display: inline; }
71
+ .o-spinner-bars > rect {
72
+ --o-spinner-beat: calc(var(--vk-spinner-turn) * 0.5);
73
+ fill: currentColor; transform-box: fill-box; transform-origin: center;
74
+ animation: vk-spin-bar var(--o-spinner-beat) linear infinite; animation-delay: calc(var(--o-spinner-beat) * var(--o-spinner-at));
75
+ }
76
+ [data-spinner-bars="eased"] .o-spinner-bars > rect { --o-spinner-beat: var(--vk-spinner-breath); animation-timing-function: var(--vk-ease-in-out); }
77
+ .o-spinner-foot > rect {
78
+ --o-spinner-beat: calc(var(--vk-spinner-breath) * var(--o-spinner-pace)); transform-origin: 50% 100%;
79
+ animation-name: vk-spin-foot; animation-timing-function: var(--vk-ease-in-out); animation-delay: calc(var(--vk-spinner-breath) * var(--o-spinner-at));
80
+ }
81
+
82
+ /* The pulse: a dot, and a ring that leaves it and fades, once every four fifths of a turn. */
83
+ [data-spinner-kind="pulse"] .o-spinner > :is(.o-spinner-dot, .o-spinner-ring) { display: inline; }
84
+ .o-spinner-dot { fill: currentColor; }
85
+ .o-spinner-ring {
86
+ --o-spinner-beat: calc(var(--vk-spinner-turn) * 0.8);
87
+ fill: none; stroke: currentColor; stroke-width: 3.33px; opacity: 0;
88
+ animation: vk-spin-ring var(--o-spinner-beat) var(--vk-ease-out) infinite, vk-spin-fade var(--o-spinner-beat) linear infinite;
89
+ }
90
+
91
+ /* ── The loading bar: along the top of the box that holds what is loading again, half a spacing step high, in the brand. A
92
+ third of it slides across, in the Progress's time and on its curve; under Loading bar › Soft ends (data-spinner-loading)
93
+ a longer piece fades out at both ends and takes a little longer. What it holds dims to loading-dim, quickly, and comes
94
+ back in duration-base ────────────────────────────────────────────────────────────────────────────────────────── */
95
+ .o-loading { position: relative; min-width: 0; }
96
+ .o-loading-bar { --o-loading-share: 0.35; position: absolute; inset: 0 0 auto 0; z-index: 1; display: block; height: calc(var(--vk-spacing) * 0.5); overflow: hidden; pointer-events: none; }
97
+ .o-loading-bar::before {
98
+ content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--o-loading-share) * 100%); background-color: var(--vk-brand);
99
+ animation: vk-loading-slide calc(var(--vk-progress-slide) * 0.85) var(--vk-ease-in-out) infinite;
100
+ }
101
+ [data-spinner-loading="soft"] .o-loading-bar, .o-loading-bar:not([data-spinner-loading] *) { --o-loading-share: 0.48; }
102
+ [data-spinner-loading="soft"] .o-loading-bar::before, .o-loading-bar:not([data-spinner-loading] *)::before {
103
+ background-color: transparent; animation-duration: calc(var(--vk-progress-slide) * 1.15);
104
+ background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--vk-brand) 50%, transparent) 17%, color-mix(in srgb, var(--vk-brand) 75%, transparent) 33%,
105
+ color-mix(in srgb, var(--vk-brand) 88%, transparent) 46% 54%, color-mix(in srgb, var(--vk-brand) 75%, transparent) 67%, color-mix(in srgb, var(--vk-brand) 50%, transparent) 83%, transparent);
106
+ }
107
+ .o-loading-held { min-width: 0; transition: opacity var(--vk-duration-base) var(--vk-ease-out); }
108
+ .o-loading[data-loading] > .o-loading-held { opacity: var(--vk-loading-dim); transition-duration: var(--vk-duration-fast); }
109
+
110
+ /* Under reduced motion a ring stops breathing and turns slowly, the bars and the pulse stand still, and the loading bar stands
111
+ across its box in the pale blue, as the Progress's does. */
112
+ @media (prefers-reduced-motion: reduce) {
113
+ .o-spinner { animation-duration: var(--vk-spinner-turn-reduced); }
114
+ .o-spinner-arc { stroke-dasharray: 80 200; }
115
+ :is(.o-spinner-arc, [data-spinner-breath] .o-spinner-arc) { animation: none; }
116
+ :is(.o-spinner-bars, [data-spinner-bars] .o-spinner-bars) > rect { animation: none; }
117
+ .o-spinner-bars > rect:nth-child(odd) { transform: scaleY(0.6); }
118
+ .o-spinner-ring { animation: none; opacity: 0.4; }
119
+ .o-loading-bar::before, [data-spinner-loading] .o-loading-bar::before, .o-loading-bar:not([data-spinner-loading] *)::before { animation: none; width: 100%; background-image: none; background-color: var(--vk-brand-subtler); }
120
+ .o-loading-held { transition: none; }
121
+ }
122
+ }
123
+ @keyframes vk-spin-turn { to { transform: rotate(360deg); } }
124
+ @keyframes vk-spin-breath {
125
+ 0% { stroke-dasharray: 1 200; stroke-dashoffset: 0; }
126
+ 50% { stroke-dasharray: 90 200; stroke-dashoffset: -35; }
127
+ 100% { stroke-dasharray: 90 200; stroke-dashoffset: -124; }
128
+ }
129
+ /* The ring is 125.66 long: these lengths and the gaps after them add up to it, so an arc that passes the ring's start goes on. */
130
+ @keyframes vk-spin-open {
131
+ 0% { stroke-dasharray: 15.08 110.58; stroke-dashoffset: 0; }
132
+ 50% { stroke-dasharray: 77.91 47.75; stroke-dashoffset: -30.16; }
133
+ 100% { stroke-dasharray: 15.08 110.58; stroke-dashoffset: -125.66; }
134
+ }
135
+ @keyframes vk-spin-soft {
136
+ 0%, 100% { stroke-dasharray: 27.65 98.02; stroke-dashoffset: 13.82; }
137
+ 50% { stroke-dasharray: 72.89 52.78; stroke-dashoffset: 36.44; }
138
+ }
139
+ @keyframes vk-spin-barely {
140
+ 0%, 100% { stroke-dasharray: 42.73 82.94; stroke-dashoffset: 21.36; }
141
+ 50% { stroke-dasharray: 62.83 62.83; stroke-dashoffset: 31.42; }
142
+ }
143
+ @keyframes vk-spin-bar { 0%, 100% { transform: scaleY(0.375); } 50% { transform: scaleY(1); } }
144
+ @keyframes vk-spin-foot { 0%, 100% { transform: scaleY(0.22); } 50% { transform: scaleY(1); } }
145
+ @keyframes vk-spin-ring { from { r: 8.33px; } to { r: 21.88px; } }
146
+ @keyframes vk-spin-fade { from { opacity: 0.7; } to { opacity: 0; } }
147
+ @keyframes vk-loading-slide { from { transform: translateX(-100%); } to { transform: translateX(calc(100% / var(--o-loading-share))); } }
@@ -14,14 +14,27 @@ function DateValue({ field, value, opts: given, }) {
14
14
  const opts = useDisplayOptions(given);
15
15
  const { Tooltip } = useViews().components;
16
16
  const [pointed, setPointed] = useState(false);
17
+ const [pressed, setPressed] = useState(false);
18
+ const hold = () => {
19
+ setPressed(true);
20
+ const release = () => {
21
+ window.removeEventListener("pointerup", release, true);
22
+ window.removeEventListener("pointercancel", release, true);
23
+ setTimeout(() => setPressed(false), 0);
24
+ };
25
+ window.addEventListener("pointerup", release, true);
26
+ window.addEventListener("pointercancel", release, true);
27
+ };
17
28
  const withTime = opts.withTime ?? (field.type === "datetime" ? field.format?.withTime : false);
18
- const cell = (_jsx("span", { className: cx(cellTextClass(opts.wrap), "tabular-nums text-(color:--vk-fg)"), onPointerEnter: pointed ? undefined : (event) => event.pointerType !== "touch" && setPointed(true), children: formatDateValue(value, opts.dateStyle ?? field.format?.dateStyle, withTime, field.type, opts) }));
29
+ const cell = (_jsx("span", { className: cx(cellTextClass(opts.wrap), "tabular-nums text-(color:--vk-fg)"), onPointerMove: pointed
30
+ ? undefined
31
+ : (event) => event.pointerType !== "touch" && event.buttons === 0 && setPointed(true), onPointerDown: pointed || pressed ? undefined : (event) => event.pointerType !== "touch" && hold(), children: formatDateValue(value, opts.dateStyle ?? field.format?.dateStyle, withTime, field.type, opts) }));
19
32
  const d = field.type === "date" && typeof value === "string"
20
33
  ? fromDayKey(value)
21
34
  : value instanceof Date
22
35
  ? value
23
36
  : new Date(String(value));
24
- if (!pointed || !d || Number.isNaN(d.getTime()))
37
+ if (!pointed || pressed || !d || Number.isNaN(d.getTime()))
25
38
  return cell;
26
39
  const full = formatDateValue(value, "long", field.type === "datetime", field.type, opts);
27
40
  return (_jsx(Tooltip, { content: full, side: "bottom", align: "start", delayMs: 1000, className: "tabular-nums", children: cell }));
@@ -5,3 +5,5 @@
5
5
  export { lookAttrs, lookPicks, lookWorn, lookWornOf, type Look, type LookDevice, type LookOption, type LookPicks, type LookValue, type PieceLooks, } from "./looks.js";
6
6
  export { LOOKS } from "./pieces.js";
7
7
  export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, type GridLookOptionId, type GridLookProps, type GridLookWorn, } from "../grid/looks.js";
8
+ export { BUTTON_LOOKS, type ButtonLookOptionId } from "../controls/button/looks.js";
9
+ export { SPINNER_LOOKS, type SpinnerLookOptionId } from "../controls/spinner/looks.js";
@@ -1,3 +1,5 @@
1
1
  export { lookAttrs, lookPicks, lookWorn, lookWornOf, } from "./looks.js";
2
2
  export { LOOKS } from "./pieces.js";
3
3
  export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, } from "../grid/looks.js";
4
+ export { BUTTON_LOOKS } from "../controls/button/looks.js";
5
+ export { SPINNER_LOOKS } from "../controls/spinner/looks.js";
@@ -27,7 +27,8 @@ export type Look<Id extends string = string> = {
27
27
  readonly device?: LookDevice;
28
28
  readonly picks: Readonly<Record<Id, string>>;
29
29
  };
30
- /** A piece's options and looks; its first look is the one worn when nothing is picked. */
30
+ /** A piece's options and looks. Nothing picked wears each option's default (`def`), My preset's pick, which no look need
31
+ * match whole. */
31
32
  export type PieceLooks<Id extends string = string> = {
32
33
  readonly id: string;
33
34
  readonly name: string;
@@ -1,2 +1,4 @@
1
+ import { BUTTON_LOOKS } from "../controls/button/looks.js";
2
+ import { SPINNER_LOOKS } from "../controls/spinner/looks.js";
1
3
  import { GRID_LOOKS } from "../grid/looks.js";
2
- export const LOOKS = [GRID_LOOKS];
4
+ export const LOOKS = [GRID_LOOKS, BUTTON_LOOKS, SPINNER_LOOKS];
@@ -89,14 +89,14 @@ export function FoldingViewRow({ axis, folded: told }) {
89
89
  const ordered = pills.filter(inBlock).map((pill) => (visibleValues.has(pill.value) ? dealt.shift() : pill.value));
90
90
  axis.onReorder(ordered);
91
91
  };
92
- return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: axis.onCreate }), !isTold && (_jsxs("div", { ref: measureRef, "aria-hidden": true, inert: true, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", style: { visibility: "hidden" }, children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : views.panelButtons === "button" ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
93
- own: MORE_CHIP_CLASS,
94
- frame: MORE_CHIP_FRAME,
95
- variant: "ghost",
96
- size: "sm",
97
- "data-slot": "vk-views-more",
98
- children: _jsx(MoreChipInner, { count: 99 }),
99
- }) })) : (_jsx("span", { "data-measure-more": true, "data-slot": "vk-views-more", className: MORE_CHIP_CLASS, children: _jsx(MoreChipInner, { count: 99 }) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }))] }));
92
+ return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: axis.onCreate }), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : views.panelButtons === "button" ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
93
+ own: MORE_CHIP_CLASS,
94
+ frame: MORE_CHIP_FRAME,
95
+ variant: "ghost",
96
+ size: "sm",
97
+ "data-slot": "vk-views-more",
98
+ children: _jsx(MoreChipInner, { count: 99 }),
99
+ }) })) : (_jsx("span", { "data-measure-more": true, "data-slot": "vk-views-more", className: MORE_CHIP_CLASS, children: _jsx(MoreChipInner, { count: 99 }) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
100
100
  }
101
101
  const MORE_CHIP_CLASS = "inline-flex h-8 shrink-0 items-center gap-0.5 whitespace-nowrap rounded-full px-2.5 text-sm font-medium text-(color:--vk-fg-subtle) transition-colors duration-(--vk-duration,150ms) hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg) data-[state=open]:bg-(color:--vk-pressed) data-[state=open]:text-(color:--vk-fg)";
102
102
  const MORE_CHIP_FRAME = "h-8 shrink-0 gap-0.5 whitespace-nowrap px-2.5";