viewkitjs 0.20.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.
- package/CHANGELOG.md +39 -0
- package/MIGRATION.md +2 -1
- package/README.md +1 -1
- package/fields/dist/conventions.d.ts +15 -3
- package/fields/dist/conventions.js +25 -0
- package/fields/dist/design/category-colors.d.ts +12 -5
- package/fields/dist/design/category-colors.js +7 -7
- package/fields/dist/query/buckets.js +42 -35
- package/fields/dist/query/date.js +2 -13
- package/fields/docs/guides/conventions.md +1 -1
- package/fields/docs/guides/options.md +2 -1
- package/fields/docs/reference/design-category-colors.md +2 -2
- package/fields/docs/reference/design-status-slots.md +1 -1
- package/fields/docs/reference/fields.md +1 -1
- package/package.json +19 -1
- package/views/README.md +2 -1
- package/views/dist/atoms/StatusBadge.js +1 -1
- package/views/dist/atoms/tones.js +7 -7
- package/views/dist/atoms/types.d.ts +3 -2
- package/views/dist/contract.d.ts +295 -2
- package/views/dist/contract.js +129 -0
- package/views/dist/controls/button/button.d.ts +40 -0
- package/views/dist/controls/button/button.js +40 -0
- package/views/dist/controls/button/looks.d.ts +4 -0
- package/views/dist/controls/button/looks.js +20 -0
- package/views/dist/controls/button/map-button.d.ts +11 -0
- package/views/dist/controls/button/map-button.js +20 -0
- package/views/dist/controls/button/own-look.d.ts +59 -0
- package/views/dist/controls/button/own-look.js +33 -0
- package/views/dist/controls/button.css +530 -0
- package/views/dist/controls/controls.d.ts +5 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/index.d.ts +11 -0
- package/views/dist/controls/index.js +6 -0
- package/views/dist/controls/smooth.css +101 -0
- package/views/dist/controls/spinner/looks.d.ts +4 -0
- package/views/dist/controls/spinner/looks.js +32 -0
- package/views/dist/controls/spinner/spinner.d.ts +23 -0
- package/views/dist/controls/spinner/spinner.js +16 -0
- package/views/dist/controls/spinner.css +147 -0
- package/views/dist/display/date.js +15 -2
- package/views/dist/display/fit-values.d.ts +3 -2
- package/views/dist/display/link.d.ts +1 -1
- package/views/dist/display/location.js +2 -1
- package/views/dist/display/multi-value.js +1 -1
- package/views/dist/display/name.js +3 -1
- package/views/dist/display/select.js +1 -1
- package/views/dist/display/value-list.d.ts +1 -1
- package/views/dist/grid/chrome/GridStructure.js +2 -1
- package/views/dist/grid/looks.d.ts +45 -0
- package/views/dist/grid/looks.js +74 -0
- package/views/dist/looks/index.d.ts +9 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/looks.d.ts +47 -0
- package/views/dist/looks/looks.js +25 -0
- package/views/dist/looks/pieces.d.ts +3 -0
- package/views/dist/looks/pieces.js +4 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
- package/views/dist/provider/ViewsProvider.d.ts +3 -3
- package/views/dist/provider/ViewsProvider.js +1 -1
- package/views/dist/provider/context.d.ts +1 -1
- package/views/dist/styles.css +1000 -119
- package/views/dist/styles.unlayered.css +1017 -119
- package/views/docs/contract.md +172 -7
- package/views/docs/guides/display.md +11 -7
- package/views/docs/guides/looks.md +29 -0
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +3 -0
- package/views/docs/install.md +7 -5
- package/views/docs/reference/controls.md +36 -0
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/looks.md +41 -0
- package/views/docs/reference/react.md +2 -2
- package/views/docs/reference/views.md +5 -2
- package/views/skills/views/SKILL.md +2 -2
|
@@ -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,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)"),
|
|
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,8 +5,9 @@
|
|
|
5
5
|
* edge, and the room the count needs. From then on a change of its width is arithmetic over what it kept,
|
|
6
6
|
* so a column resize reads nothing from the page and draws again only the cells whose number changed.
|
|
7
7
|
*/
|
|
8
|
-
/** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). `
|
|
9
|
-
*
|
|
8
|
+
/** How a cell of several values draws on one line (`ViewsProvider`'s `severalValues`). `fit` (the default):
|
|
9
|
+
* as many whole values as fit its width, then a count. `first`: its first value and a count, at any
|
|
10
|
+
* width, as on 0.5.0. */
|
|
10
11
|
export type ViewsSeveralValues = "first" | "fit";
|
|
11
12
|
/** The most values drawn to be measured: no column fits more, and a cell of 200 records doesn't draw 200
|
|
12
13
|
* chips to find out. */
|
|
@@ -11,7 +11,7 @@ import type { DisplayOptions } from "./options.js";
|
|
|
11
11
|
* A value that is no link (`webHref`) draws as its text. Its platform
|
|
12
12
|
* (`linkPlatform`, read with the host's conventions) goes to the app's
|
|
13
13
|
* `PlatformMark`, drawn before it; the default draws nothing, so a link looks
|
|
14
|
-
* plain. Several links draw
|
|
14
|
+
* plain. Several links draw the main one first, as many as fit, then a count (`renderValueList`).
|
|
15
15
|
*/
|
|
16
16
|
export declare function renderUrl(_field: FieldDefOf<"url">, value: unknown, opts?: DisplayOptions): ReactNode;
|
|
17
17
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { locationShort, locationText } from "viewkitjs/fields";
|
|
4
4
|
import { MultiValueCell } from "./multi-value.js";
|
|
5
|
+
import { cellTextClass } from "./text-class.js";
|
|
5
6
|
import { useDisplayOptions } from "./use-display-options.js";
|
|
6
7
|
export function renderLocation(field, value, opts) {
|
|
7
8
|
void field;
|
|
@@ -18,5 +19,5 @@ function PlaceValue({ value, opts: given }) {
|
|
|
18
19
|
const places = value.map((place) => write(place, locale)).filter(Boolean);
|
|
19
20
|
return (_jsx(MultiValueCell, { items: places, wrap: !!opts.wrap, title: places.join(", "), slotOwnsClick: opts.slotOwnsClick }));
|
|
20
21
|
}
|
|
21
|
-
return write(value, locale);
|
|
22
|
+
return _jsx("span", { className: cellTextClass(opts.wrap), children: write(value, locale) });
|
|
22
23
|
}
|
|
@@ -18,7 +18,7 @@ export function MultiValueCell({ items, details, wrap, title, slotOwnsClick, })
|
|
|
18
18
|
const [open, setOpen] = useState(false);
|
|
19
19
|
const anchor = useRef(null);
|
|
20
20
|
const trigger = useRef(null);
|
|
21
|
-
const fit = severalValues
|
|
21
|
+
const fit = severalValues !== "first" && !wrap && items.length > 1;
|
|
22
22
|
const key = `${items.length}\u0000${title ?? ""}`;
|
|
23
23
|
const keyRef = useRef(key);
|
|
24
24
|
useLayoutEffect(() => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { nameText } from "viewkitjs/fields";
|
|
4
4
|
import { MultiValueCell } from "./multi-value.js";
|
|
5
|
+
import { cellTextClass } from "./text-class.js";
|
|
5
6
|
export function renderName(field, value, opts) {
|
|
6
7
|
void field;
|
|
7
8
|
if (Array.isArray(value)) {
|
|
@@ -10,5 +11,6 @@ export function renderName(field, value, opts) {
|
|
|
10
11
|
return opts?.nameFallback || null;
|
|
11
12
|
return (_jsx(MultiValueCell, { items: names, wrap: !!opts?.wrap, title: names.join(", "), slotOwnsClick: opts?.slotOwnsClick }));
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
const text = nameText(value) || opts?.nameFallback;
|
|
15
|
+
return text ? _jsx("span", { className: cellTextClass(opts?.wrap), children: text }) : null;
|
|
14
16
|
}
|
|
@@ -32,7 +32,7 @@ function StrayOption({ value }) {
|
|
|
32
32
|
}
|
|
33
33
|
function OptionStatus({ slot, label, icon, place, }) {
|
|
34
34
|
const { atoms: { StatusBadge }, components: { AppIcon }, } = useViews();
|
|
35
|
-
return (_jsx(StatusBadge, { slot: slot, label: label, place: place, className: "border-0", leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
|
|
35
|
+
return (_jsx(StatusBadge, { slot: slot, label: label, place: place, size: "row", className: "border-0", leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
|
|
36
36
|
}
|
|
37
37
|
function OptionCategory({ label, color, icon }) {
|
|
38
38
|
const { atoms: { Tag }, components: { AppIcon }, } = useViews();
|
|
@@ -3,7 +3,7 @@ import type { DisplayOptions } from "./options.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Several values of one kind (VK-58's `{ value, label, main }`, or a plain list read as items, the first main):
|
|
5
5
|
* the main one first and the rest in stored order, each drawn by its type's own renderer for one value. The cell
|
|
6
|
-
* shows the main one
|
|
6
|
+
* shows as many as fit, the main one first, then a count; each value's label is drawn beside it behind the count, never in the cell.
|
|
7
7
|
*/
|
|
8
8
|
export declare function renderValueList(value: unknown[], one: (value: unknown) => ReactNode, opts?: DisplayOptions,
|
|
9
9
|
/** One value as plain text, for the native hover. */
|
|
@@ -12,6 +12,7 @@ import { GridGroupMenu } from "./GridGroupMenu.js";
|
|
|
12
12
|
import { groupMenuParts } from "./grid-group-menu-parts.js";
|
|
13
13
|
import { GRID_CHROME_FOCUS, GRID_ROW_PAD } from "./grid-styles.js";
|
|
14
14
|
import { GridRowsSlotContext } from "./grid-wait.js";
|
|
15
|
+
const GROUP_COUNT_CHIP = "ml-2 inline-flex h-6 min-w-6 items-center justify-center rounded-sm bg-(color:--vk-neutral) px-1.5 text-(color:--vk-fg-subtle) tabular-nums";
|
|
15
16
|
function GridRowsSlot({ children }) {
|
|
16
17
|
const slot = useContext(GridRowsSlotContext);
|
|
17
18
|
if (!slot)
|
|
@@ -60,7 +61,7 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
|
|
|
60
61
|
"aria-expanded": !collapsed,
|
|
61
62
|
onClick: () => onToggleGroup?.(group.key),
|
|
62
63
|
children: _jsx(Caret, { className: "h-(--vk-glyph) w-(--vk-glyph)" }),
|
|
63
|
-
}), _jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem-(1.5rem-var(--vk-glyph))/2)] truncate text-(length:--vk-text) font-medium", children: renderGroupLabel?.(group) ?? group.label ?? "—" }), parts.length > 0 && (_jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem)] flex min-w-0 items-baseline gap-1.5 overflow-hidden text-(length:--vk-text) text-(color:--vk-fg-subtle) tabular-nums", children: parts.map((part) => (
|
|
64
|
+
}), _jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem-(1.5rem-var(--vk-glyph))/2)] truncate text-(length:--vk-text) font-medium", children: renderGroupLabel?.(group) ?? group.label ?? "—" }), parts.length > 0 && (_jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem)] flex min-w-0 items-baseline gap-1.5 overflow-hidden text-(length:--vk-text) text-(color:--vk-fg-subtle) tabular-nums", children: parts.map((part) => (_jsx("span", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: part.key === "count" ? (_jsx("span", { "data-slot": "vk-grid-group-count", "data-part": part.key, className: GROUP_COUNT_CHIP, children: part.node })) : (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-group-dot", "data-part": part.key, className: "text-(color:--vk-fg-subtlest)", children: "\u00B7" }), _jsx("span", { "data-slot": "vk-grid-group-figure", "data-part": part.key, children: part.node })] })) }, part.key))) })), groupMenuParts({
|
|
64
65
|
groupMenu,
|
|
65
66
|
hasSort: !!sort,
|
|
66
67
|
sortCount: sortOptions?.length ?? 0,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { GridGroupMenuPart } from "./chrome/grid-group-menu-parts.js";
|
|
2
|
+
import { type LookPicks, type PieceLooks } from "../looks/looks.js";
|
|
3
|
+
export type GridLookOptionId = "header" | "lines" | "columns" | "density" | "phone" | "name" | "edge" | "boxes" | "icon" | "picked" | "cell" | "corners" | "hover" | "frame" | "groups" | "names" | "phones" | "typed" | "figures" | "width" | "more" | "wait" | "foot" | "add" | "picking";
|
|
4
|
+
/** The grid's options and its two looks, attio (every option's default) and portal. */
|
|
5
|
+
export declare const GRID_LOOKS: PieceLooks<GridLookOptionId>;
|
|
6
|
+
/** What the grid's code reads of its options; the rest are its look stylesheet's alone. */
|
|
7
|
+
export type GridLookWorn = {
|
|
8
|
+
columns: "all" | "none" | "pinned";
|
|
9
|
+
density: "compact" | "default" | "roomy";
|
|
10
|
+
phone: "attio" | "computer";
|
|
11
|
+
name: "pinned" | "scrolls";
|
|
12
|
+
boxes: "hover" | "always";
|
|
13
|
+
icon: "on" | "off";
|
|
14
|
+
groups: "compact" | "titles";
|
|
15
|
+
figures: "value" | "word";
|
|
16
|
+
width: "own" | "fill";
|
|
17
|
+
more: "scroll" | "pages";
|
|
18
|
+
wait: "kept" | "cleared";
|
|
19
|
+
foot: "pinned" | "rows";
|
|
20
|
+
add: "name" | "end";
|
|
21
|
+
picking: "press" | "rail";
|
|
22
|
+
};
|
|
23
|
+
/** The options the grid's code reads, in this order. */
|
|
24
|
+
export declare const GRID_LOOK_READ: readonly (keyof GridLookWorn)[];
|
|
25
|
+
/** What the grid's code reads, from a set of picks; a pick left out, or one its option doesn't have, its default. */
|
|
26
|
+
export declare function gridLookWorn(picks?: LookPicks<GridLookOptionId>): GridLookWorn;
|
|
27
|
+
/** The same, from the closest frame round `el` carrying each `data-grid-<option>`; outside any frame, the defaults. */
|
|
28
|
+
export declare function gridLookWornOf(el: Element | null): GridLookWorn;
|
|
29
|
+
/** The GridTable props a look sets. */
|
|
30
|
+
export type GridLookProps = {
|
|
31
|
+
verticalBorders: boolean;
|
|
32
|
+
headerVerticalBorders: boolean;
|
|
33
|
+
scale: number;
|
|
34
|
+
freezeIdentity: boolean;
|
|
35
|
+
alwaysCheckboxes: boolean;
|
|
36
|
+
showRowIcon: boolean;
|
|
37
|
+
oneHeader: boolean;
|
|
38
|
+
groupMenu: GridGroupMenuPart[];
|
|
39
|
+
fillWidth: boolean;
|
|
40
|
+
pinFooter: boolean;
|
|
41
|
+
addColumnAt: "end" | "title";
|
|
42
|
+
phonePicking: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** What a worn look hands GridTable, on a phone or a computer. */
|
|
45
|
+
export declare function gridLookProps(worn: GridLookWorn, phone: boolean): GridLookProps;
|