viewkitjs 0.24.0 → 0.25.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 +20 -0
- package/fields/dist/creatable.d.ts +9 -5
- package/fields/dist/creatable.js +8 -1
- package/fields/dist/messages.d.ts +19 -1
- package/fields/dist/messages.js +75 -0
- package/fields/dist/registry.js +4 -7
- package/fields/dist/types.d.ts +4 -2
- package/fields/dist/zod.d.ts +58 -0
- package/fields/dist/zod.js +430 -2
- package/fields/docs/guides/checking-definitions.md +6 -1
- package/fields/docs/guides/field-types.md +5 -1
- package/fields/docs/reference/definitions.md +1 -2
- package/fields/docs/reference/types.md +2 -1
- package/fields/skills/viewkit/SKILL.md +2 -2
- package/package.json +1 -1
- package/views/dist/controls/avatar/avatar.d.ts +58 -0
- package/views/dist/controls/avatar/avatar.js +54 -0
- package/views/dist/controls/avatar/looks.d.ts +4 -0
- package/views/dist/controls/avatar/looks.js +5 -0
- package/views/dist/controls/avatar/tokens.d.ts +131 -0
- package/views/dist/controls/avatar/tokens.js +35 -0
- package/views/dist/controls/avatar.css +163 -0
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/index.d.ts +12 -0
- package/views/dist/controls/index.js +12 -0
- package/views/dist/controls/internal/phone.d.ts +9 -0
- package/views/dist/controls/internal/phone.js +15 -0
- package/views/dist/controls/internal/read-token.d.ts +2 -1
- package/views/dist/controls/internal/read-token.js +1 -1
- package/views/dist/controls/internal/scroll.d.ts +38 -0
- package/views/dist/controls/internal/scroll.js +126 -0
- package/views/dist/controls/list/looks.d.ts +4 -0
- package/views/dist/controls/list/looks.js +12 -0
- package/views/dist/controls/list.css +17 -13
- package/views/dist/controls/menu/map-menu.d.ts +11 -0
- package/views/dist/controls/menu/map-menu.js +47 -0
- package/views/dist/controls/menu/menu.d.ts +75 -0
- package/views/dist/controls/menu/menu.js +105 -0
- package/views/dist/controls/menu/tokens.d.ts +23 -0
- package/views/dist/controls/menu/tokens.js +8 -0
- package/views/dist/controls/menu-list/looks.d.ts +5 -1
- package/views/dist/controls/menu-list/looks.js +6 -4
- package/views/dist/controls/menu-list/menu-list.js +3 -1
- package/views/dist/controls/menu-list.css +39 -31
- package/views/dist/controls/menu.css +25 -0
- package/views/dist/controls/picker/looks.d.ts +19 -0
- package/views/dist/controls/picker/looks.js +32 -0
- package/views/dist/controls/picker/picker.d.ts +153 -0
- package/views/dist/controls/picker/picker.js +773 -0
- package/views/dist/controls/picker/rows.d.ts +129 -0
- package/views/dist/controls/picker/rows.js +90 -0
- package/views/dist/controls/picker/tokens.d.ts +147 -0
- package/views/dist/controls/picker/tokens.js +39 -0
- package/views/dist/controls/picker.css +237 -0
- package/views/dist/controls/popup-line/tokens.d.ts +23 -0
- package/views/dist/controls/popup-line/tokens.js +8 -0
- package/views/dist/controls/popup-line.css +44 -0
- package/views/dist/controls/select/filled.d.ts +7 -0
- package/views/dist/controls/select/filled.js +5 -0
- package/views/dist/controls/select/fit.d.ts +9 -0
- package/views/dist/controls/select/fit.js +11 -0
- package/views/dist/controls/select/select.d.ts +131 -0
- package/views/dist/controls/select/select.js +227 -0
- package/views/dist/controls/select/side.d.ts +3 -0
- package/views/dist/controls/select/side.js +4 -0
- package/views/dist/controls/select/tokens.d.ts +27 -0
- package/views/dist/controls/select/tokens.js +9 -0
- package/views/dist/controls/select.css +91 -0
- package/views/dist/controls/tokens.js +10 -0
- package/views/dist/looks/index.d.ts +4 -0
- package/views/dist/looks/index.js +4 -0
- package/views/dist/looks/pieces.js +6 -0
- package/views/dist/styles.css +586 -62
- package/views/dist/styles.unlayered.css +586 -62
- package/views/docs/controls/avatar.md +38 -0
- package/views/docs/controls/menu.md +11 -0
- package/views/docs/controls/picker.md +42 -0
- package/views/docs/controls/popup-line.md +11 -0
- package/views/docs/controls/select.md +12 -0
- package/views/docs/reference/controls.md +86 -0
- package/views/docs/reference/looks.md +8 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
7
|
+
import { Menu } from "../menu/menu.js";
|
|
8
|
+
import { Icon } from "../internal/icons.js";
|
|
9
|
+
import { PhoneHost, usePhone } from "../internal/phone.js";
|
|
10
|
+
const SIZE = { 16: "o-avatar-2xs", 20: "o-avatar-xs", 24: "o-avatar-sm", 32: "", 40: "o-avatar-lg", 64: "o-avatar-xl" };
|
|
11
|
+
export function initials(name) {
|
|
12
|
+
const words = name.split(/\s+/).filter((w) => /^\p{L}/u.test(w));
|
|
13
|
+
if (!words.length)
|
|
14
|
+
return "";
|
|
15
|
+
const first = words[0].split("-").filter(Boolean);
|
|
16
|
+
if (first.length > 1)
|
|
17
|
+
return (first[0][0] + first[1][0]).toUpperCase();
|
|
18
|
+
return (words[0][0] + (words.length > 1 ? words[words.length - 1][0] : "")).toUpperCase();
|
|
19
|
+
}
|
|
20
|
+
export function toneOf(id) {
|
|
21
|
+
let h = 0;
|
|
22
|
+
for (const c of id)
|
|
23
|
+
h = (h * 31 + c.charCodeAt(0)) >>> 0;
|
|
24
|
+
return (h % 6) + 1;
|
|
25
|
+
}
|
|
26
|
+
export function Avatar({ name, kind = "person", size = 32, id, tone, src, icon, presence, badge, className }) {
|
|
27
|
+
const person = kind === "person";
|
|
28
|
+
const letters = icon ? null : kind === "thing" || kind === "agent" ? initials(name).slice(0, 1) : initials(name);
|
|
29
|
+
const avatar = (_jsxs(BaseAvatar.Root, { role: "img", "aria-label": presence ? `${name}, ${presence}` : name, "data-kit": "avatar", "data-tone": person ? tone ?? toneOf(id ?? name) : undefined, className: cx("o-avatar", SIZE[size], !person && "o-avatar-thing o-smooth o-smooth-ease", kind === "workspace" && "o-avatar-workspace", kind === "agent" && "o-avatar-agent", className), children: [src && _jsx(BaseAvatar.Image, { className: "o-avatar-image", src: src, alt: "" }), _jsx(BaseAvatar.Fallback, { className: "o-avatar-letters", "aria-hidden": "true", children: icon ?? letters })] }));
|
|
30
|
+
if (size === 16 || (!presence && (badge == null || badge === false)))
|
|
31
|
+
return avatar;
|
|
32
|
+
return (_jsxs("span", { className: "o-avatar-badged", "data-size": size, "data-thing": person ? undefined : "", children: [avatar, presence ? _jsx("span", { className: "o-avatar-badge", "data-presence": presence, "aria-hidden": "true" })
|
|
33
|
+
: _jsx("span", { className: "o-avatar-badge", "data-badge": "", "aria-hidden": "true", children: badge === true ? null : badge })] }));
|
|
34
|
+
}
|
|
35
|
+
const ADD_SIZE = { 20: "20", 24: "2xs", 32: "sm", 40: "md", 64: "lg" };
|
|
36
|
+
export function AvatarStack({ people, max = 3, size = 24, className, label, onPick, onAdd, addButton }) {
|
|
37
|
+
const screen = React.useContext(PhoneHost), phone = usePhone() || !!screen;
|
|
38
|
+
const shown = people.length > max + 1 ? people.slice(0, max) : people, rest = people.length - shown.length;
|
|
39
|
+
const names = shown.map((p) => p.name), said = rest ? `${names.join(", ")} and ${rest} more` : names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}` : names.join("");
|
|
40
|
+
const faces = _jsxs(_Fragment, { children: [shown.map((p) => _jsx(Avatar, { ...p, size: size }, p.id ?? p.name)), rest > 0 && _jsxs("span", { className: cx("o-avatar o-avatar-more", SIZE[size]), "aria-hidden": "true", children: ["+", rest] })] });
|
|
41
|
+
const add = addButton && onAdd
|
|
42
|
+
? _jsx(Button, { kind: "outline", shape: "round", size: ADD_SIZE[size], className: "o-avatar-add", "data-size": size, "aria-label": "Add someone", icon: _jsx(Icon, { name: "plus" }), onClick: onAdd })
|
|
43
|
+
: null;
|
|
44
|
+
if (!people.length)
|
|
45
|
+
return add;
|
|
46
|
+
const entries = [
|
|
47
|
+
...people.map((p) => ({ icon: _jsx(Avatar, { ...p, size: phone ? 32 : 20 }), label: p.name, onSelect: () => onPick?.(p) })),
|
|
48
|
+
...(onAdd ? [{ kind: "separator" }, { icon: _jsx(Icon, { name: "plus", size: 16 }), label: "Add someone…", onSelect: onAdd }] : []),
|
|
49
|
+
];
|
|
50
|
+
const stack = onPick
|
|
51
|
+
? _jsx(Menu, { label: label ?? said, align: "start", allRows: true, frame: MENU_LIST_CARD_FRAME, entries: entries, trigger: _jsx(Button, { kind: "quiet", className: cx("o-avatar-stack-button", className), "aria-label": said, children: _jsx("span", { className: "o-avatar-stack", "aria-hidden": "true", children: faces }) }) })
|
|
52
|
+
: _jsx("span", { className: cx("o-avatar-stack", className), role: "img", "aria-label": said, children: faces });
|
|
53
|
+
return add ? _jsxs("span", { className: "o-avatar-stack-group", children: [stack, add] }) : stack;
|
|
54
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const options = [
|
|
2
|
+
{ id: "corners", name: "Corners", def: "medium", kind: "steps", values: [{ id: "small", name: "Small" }, { id: "medium", name: "Medium" }, { id: "large", name: "Large" }, { id: "xlarge", name: "Extra large" }] },
|
|
3
|
+
{ id: "smoothing", name: "Corner smoothing", def: "smooth", values: [{ id: "round", name: "Round" }, { id: "smooth", name: "Smooth" }] },
|
|
4
|
+
];
|
|
5
|
+
export const AVATAR_LOOKS = { id: "avatar", name: "Avatar", options, looks: [] };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export declare const AVATAR_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border-subtle";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border-subtle";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-brand";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--background-brand-bold";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-fg";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--text";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-fg-on-brand";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--text-brand-inverse";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-fg-subtle";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--text-subtle";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-fg-subtlest";
|
|
23
|
+
readonly kind: "colour";
|
|
24
|
+
readonly outright: "--text-subtlest";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-neutral";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--background-neutral";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-person-1";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--person-1";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-person-2";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--person-2";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-person-3";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--person-3";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-person-4";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--person-4";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-person-5";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--person-5";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-person-6";
|
|
51
|
+
readonly kind: "colour";
|
|
52
|
+
readonly outright: "--person-6";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-person-fg";
|
|
55
|
+
readonly kind: "colour";
|
|
56
|
+
readonly outright: "--person-foreground";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-success-bold";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--background-success-bold";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-border-width";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--border-width";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-dot-size";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--dot-size";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-font-size-2xl";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--text-2xl";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-font-size-2xs";
|
|
75
|
+
readonly kind: "size";
|
|
76
|
+
readonly outright: "--text-2xs";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-font-size-3xs";
|
|
79
|
+
readonly kind: "size";
|
|
80
|
+
readonly outright: "--text-3xs";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-font-size-sm";
|
|
83
|
+
readonly kind: "size";
|
|
84
|
+
readonly outright: "--text-sm";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-font-size-xs";
|
|
87
|
+
readonly kind: "size";
|
|
88
|
+
readonly outright: "--text-xs";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-font-weight-semibold";
|
|
91
|
+
readonly kind: "size";
|
|
92
|
+
readonly outright: "--font-weight-semibold";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-radius-2xl";
|
|
95
|
+
readonly kind: "size";
|
|
96
|
+
readonly outright: "--radius-2xl";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-radius-full";
|
|
99
|
+
readonly kind: "size";
|
|
100
|
+
readonly outright: "--radius-full";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-radius-lg";
|
|
103
|
+
readonly kind: "size";
|
|
104
|
+
readonly outright: "--radius-lg";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "--vk-radius-md";
|
|
107
|
+
readonly kind: "size";
|
|
108
|
+
readonly outright: "--radius-md";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-radius-sm";
|
|
111
|
+
readonly kind: "size";
|
|
112
|
+
readonly outright: "--radius-sm";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-radius-xl";
|
|
115
|
+
readonly kind: "size";
|
|
116
|
+
readonly outright: "--radius-xl";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "--vk-radius-xs";
|
|
119
|
+
readonly kind: "size";
|
|
120
|
+
readonly outright: "--radius-xs";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-spacing";
|
|
123
|
+
readonly kind: "size";
|
|
124
|
+
readonly outright: "--spacing";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-tracking-normal";
|
|
127
|
+
readonly kind: "size";
|
|
128
|
+
readonly outright: "--tracking-normal";
|
|
129
|
+
}];
|
|
130
|
+
/** The Avatar's own machinery: its size, corners, badge and the cut round each face. */
|
|
131
|
+
export declare const AVATAR_PRIVATE: readonly ["--avatar-"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const AVATAR_TOKENS = [
|
|
2
|
+
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
3
|
+
{ name: "--vk-brand", kind: "colour", outright: "--background-brand-bold" },
|
|
4
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
5
|
+
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
6
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
7
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
8
|
+
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
9
|
+
{ name: "--vk-person-1", kind: "colour", outright: "--person-1" },
|
|
10
|
+
{ name: "--vk-person-2", kind: "colour", outright: "--person-2" },
|
|
11
|
+
{ name: "--vk-person-3", kind: "colour", outright: "--person-3" },
|
|
12
|
+
{ name: "--vk-person-4", kind: "colour", outright: "--person-4" },
|
|
13
|
+
{ name: "--vk-person-5", kind: "colour", outright: "--person-5" },
|
|
14
|
+
{ name: "--vk-person-6", kind: "colour", outright: "--person-6" },
|
|
15
|
+
{ name: "--vk-person-fg", kind: "colour", outright: "--person-foreground" },
|
|
16
|
+
{ name: "--vk-success-bold", kind: "colour", outright: "--background-success-bold" },
|
|
17
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
18
|
+
{ name: "--vk-dot-size", kind: "size", outright: "--dot-size" },
|
|
19
|
+
{ name: "--vk-font-size-2xl", kind: "size", outright: "--text-2xl" },
|
|
20
|
+
{ name: "--vk-font-size-2xs", kind: "size", outright: "--text-2xs" },
|
|
21
|
+
{ name: "--vk-font-size-3xs", kind: "size", outright: "--text-3xs" },
|
|
22
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
23
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
24
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
25
|
+
{ name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
|
|
26
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
27
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
28
|
+
{ name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
|
|
29
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
30
|
+
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
31
|
+
{ name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
|
|
32
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
33
|
+
{ name: "--vk-tracking-normal", kind: "size", outright: "--tracking-normal" },
|
|
34
|
+
];
|
|
35
|
+
export const AVATAR_PRIVATE = ["--avatar-"];
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* The Avatar. Every value it draws with is a
|
|
2
|
+
token (control tokens); this file only says which token each kind and size takes. People are circles on
|
|
3
|
+
their own tone (data-tone, 1 to 6); things are squares on a quiet ground; the workspace is the brand; an agent is a thing's
|
|
4
|
+
square holding its own icon. Its options, on the frame around it (looks.ts), are its squares' alone:
|
|
5
|
+
|
|
6
|
+
data-avatar-corners small · medium · large · xlarge a radius token per size; nothing set is Medium
|
|
7
|
+
data-avatar-smoothing round · smooth how a square's corners bend; nothing set is Smooth
|
|
8
|
+
|
|
9
|
+
The rules sit in the components layer, so a utility class on an avatar still wins. */
|
|
10
|
+
@layer components {
|
|
11
|
+
|
|
12
|
+
/* ── A person: a circle of their initials on their tone, 32px ──────────────────────────────────────── */
|
|
13
|
+
.o-avatar {
|
|
14
|
+
flex: none; display: inline-grid; place-items: center; box-sizing: border-box; overflow: hidden;
|
|
15
|
+
width: calc(var(--vk-spacing) * 8); height: calc(var(--vk-spacing) * 8); border-radius: var(--vk-radius-full);
|
|
16
|
+
background-color: var(--vk-person-1); color: var(--vk-person-fg);
|
|
17
|
+
font-size: var(--vk-font-size-xs); line-height: 1; font-weight: var(--vk-font-weight-semibold); letter-spacing: var(--vk-tracking-normal); user-select: none;
|
|
18
|
+
}
|
|
19
|
+
.o-avatar[data-tone="2"] { background-color: var(--vk-person-2); }
|
|
20
|
+
.o-avatar[data-tone="3"] { background-color: var(--vk-person-3); }
|
|
21
|
+
.o-avatar[data-tone="4"] { background-color: var(--vk-person-4); }
|
|
22
|
+
.o-avatar[data-tone="5"] { background-color: var(--vk-person-5); }
|
|
23
|
+
.o-avatar[data-tone="6"] { background-color: var(--vk-person-6); }
|
|
24
|
+
/* A photo or a logo fills the shape and replaces the tone. */
|
|
25
|
+
.o-avatar-image { width: 100%; height: 100%; object-fit: cover; }
|
|
26
|
+
.o-avatar-letters { display: grid; place-items: center; width: 100%; height: 100%; }
|
|
27
|
+
.o-avatar-letters svg { width: 55%; height: 55%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
|
|
28
|
+
|
|
29
|
+
/* ── Sizes: 16 in a typed Select's chip, its initials at the 3xs type size; 20 in chips and text, 24 in dense rows and stacks,
|
|
30
|
+
40 in headers, 64 on a record's page ── */
|
|
31
|
+
.o-avatar.o-avatar-2xs { width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); font-size: var(--vk-font-size-3xs); }
|
|
32
|
+
.o-avatar.o-avatar-xs { width: calc(var(--vk-spacing) * 5); height: calc(var(--vk-spacing) * 5); font-size: var(--vk-font-size-2xs); }
|
|
33
|
+
.o-avatar.o-avatar-sm { width: calc(var(--vk-spacing) * 6); height: calc(var(--vk-spacing) * 6); font-size: var(--vk-font-size-2xs); }
|
|
34
|
+
.o-avatar.o-avatar-lg { width: calc(var(--vk-spacing) * 10); height: calc(var(--vk-spacing) * 10); font-size: var(--vk-font-size-sm); }
|
|
35
|
+
.o-avatar.o-avatar-xl { width: calc(var(--vk-spacing) * 16); height: calc(var(--vk-spacing) * 16); font-size: var(--vk-font-size-2xl); }
|
|
36
|
+
|
|
37
|
+
/* ── A thing: a square, its corners a step that grows with it, on the neutral ground, its edge inside ─ */
|
|
38
|
+
.o-avatar.o-avatar-thing { border-radius: var(--avatar-r); background-color: var(--vk-neutral); color: var(--vk-fg-subtle); box-shadow: inset 0 0 0 var(--vk-border-width) var(--vk-border-subtle); }
|
|
39
|
+
/* The workspace: the one square in the brand. */
|
|
40
|
+
.o-avatar.o-avatar-workspace { background-color: var(--vk-brand); color: var(--vk-fg-on-brand); box-shadow: none; }
|
|
41
|
+
/* An agent: a thing's square holding its own icon. Its mark comes in its own fills, so it is filled, never drawn as a
|
|
42
|
+
line as a record's icon is; a mark with no colour of its own (Codex's, Grok's) takes the text's ink, as the canvas drew it. */
|
|
43
|
+
.o-avatar-agent .o-avatar-letters svg { fill: var(--vk-fg); stroke: none; }
|
|
44
|
+
|
|
45
|
+
/* ── Corners: a radius token per size, in steps; Medium with nothing set: xs at 20, sm at 24 and 32, md at 40, lg at 64,
|
|
46
|
+
between Small and Large, the tokens holding nothing between xs and sm ────────────────────────────── */
|
|
47
|
+
.o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-sm); }
|
|
48
|
+
.o-avatar.o-avatar-thing:is(.o-avatar-2xs, .o-avatar-xs) { --avatar-r: var(--vk-radius-xs); }
|
|
49
|
+
.o-avatar.o-avatar-thing.o-avatar-lg { --avatar-r: var(--vk-radius-md); }
|
|
50
|
+
.o-avatar.o-avatar-thing.o-avatar-xl { --avatar-r: var(--vk-radius-lg); }
|
|
51
|
+
/* Small: xs at 20 and 24, sm at 32 and 40, md at 64. */
|
|
52
|
+
[data-avatar-corners="small"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-sm); }
|
|
53
|
+
[data-avatar-corners="small"] .o-avatar.o-avatar-thing:is(.o-avatar-2xs, .o-avatar-xs, .o-avatar-sm) { --avatar-r: var(--vk-radius-xs); }
|
|
54
|
+
[data-avatar-corners="small"] .o-avatar.o-avatar-thing.o-avatar-xl { --avatar-r: var(--vk-radius-md); }
|
|
55
|
+
/* Large, the radii before Medium came: sm at 20 and 24, md at 32, lg at 40, xl at 64. */
|
|
56
|
+
[data-avatar-corners="large"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-md); }
|
|
57
|
+
[data-avatar-corners="large"] .o-avatar.o-avatar-thing:is(.o-avatar-2xs, .o-avatar-xs, .o-avatar-sm) { --avatar-r: var(--vk-radius-sm); }
|
|
58
|
+
[data-avatar-corners="large"] .o-avatar.o-avatar-thing.o-avatar-lg { --avatar-r: var(--vk-radius-lg); }
|
|
59
|
+
[data-avatar-corners="large"] .o-avatar.o-avatar-thing.o-avatar-xl { --avatar-r: var(--vk-radius-xl); }
|
|
60
|
+
/* Extra large: md at 20 and 24, lg at 32, xl at 40, 2xl at 64. */
|
|
61
|
+
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-lg); }
|
|
62
|
+
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing:is(.o-avatar-2xs, .o-avatar-xs, .o-avatar-sm) { --avatar-r: var(--vk-radius-md); }
|
|
63
|
+
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing.o-avatar-lg { --avatar-r: var(--vk-radius-xl); }
|
|
64
|
+
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing.o-avatar-xl { --avatar-r: var(--vk-radius-2xl); }
|
|
65
|
+
|
|
66
|
+
/* ── Corner smoothing: Smooth, with nothing set, draws a square's corners with the smooth outline (smooth.css),
|
|
67
|
+
every browser that knows shape() showing it; one that doesn't keeps the quarter circles above, and so does Round. Its
|
|
68
|
+
smoothing eases off where a side is too short for 1.7 radii at each end, as the canvas drew it (o-smooth-ease, from its size and
|
|
69
|
+
its radius, both tokens, so it follows Corner radius). The outline would cut the edge drawn inside the square, so under it the
|
|
70
|
+
edge is a ring of its own (::before), between the outline and the same outline drawn a hairline in, under whatever the square
|
|
71
|
+
holds; the workspace has none. Its smoothing is its own Corner smoothing, never a host's: the outline's amount inherits, and a
|
|
72
|
+
crumb, a tab or a list's card that follows the token sets it on itself, so the square sets it back. ─────── */
|
|
73
|
+
@supports (clip-path: shape(evenodd from 0 0, curve by 1px 1px with 1px 0 / 1px 0, close, move to 0 0, hline to 1px, close)) and (width: calc(tan(atan2(1px, 1px)) * 1px)) {
|
|
74
|
+
.o-avatar.o-avatar-thing { --smooth-amount: initial; }
|
|
75
|
+
.o-avatar.o-avatar-thing:not([data-avatar-smoothing="round"] *) {
|
|
76
|
+
--avatar-rr: min(var(--avatar-r), var(--avatar-size) / 2); --smooth-t: var(--avatar-rr); --smooth-side: var(--avatar-size);
|
|
77
|
+
position: relative; box-shadow: none; clip-path: shape(var(--smooth-outline));
|
|
78
|
+
}
|
|
79
|
+
/* Its edge, a hairline ring along the outline, under the picture or the letters it holds; the workspace has none. */
|
|
80
|
+
.o-avatar.o-avatar-thing:not(.o-avatar-workspace):not([data-avatar-smoothing="round"] *)::before {
|
|
81
|
+
--smooth-t: calc(var(--avatar-rr) - var(--vk-border-width)); --smooth-in: var(--vk-border-width);
|
|
82
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-color: var(--vk-border-subtle);
|
|
83
|
+
clip-path: shape(var(--smooth-ring));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* ── A stack: each after the first overlaps by a fifth of its size, cut out of whatever it stands on (a cut, so a card,
|
|
88
|
+
a hovered row or the dark shows through it, never the page's colour) ──────────────────────────────────────────────── */
|
|
89
|
+
.o-avatar-stack { display: inline-flex; align-items: center; isolation: isolate; }
|
|
90
|
+
:is(.o-avatar, .o-avatar-badged) { --avatar-overlap: calc(var(--vk-spacing) * 1.6); }
|
|
91
|
+
:is(.o-avatar.o-avatar-xs, .o-avatar-badged[data-size="20"]) { --avatar-overlap: calc(var(--vk-spacing) * 1); }
|
|
92
|
+
:is(.o-avatar.o-avatar-sm, .o-avatar-badged[data-size="24"]) { --avatar-overlap: calc(var(--vk-spacing) * 1.2); }
|
|
93
|
+
:is(.o-avatar.o-avatar-lg, .o-avatar-badged[data-size="40"]) { --avatar-overlap: calc(var(--vk-spacing) * 2); }
|
|
94
|
+
:is(.o-avatar.o-avatar-xl, .o-avatar-badged[data-size="64"]) { --avatar-overlap: calc(var(--vk-spacing) * 3.2); }
|
|
95
|
+
.o-avatar-stack > :is(.o-avatar, .o-avatar-badged) + :is(.o-avatar, .o-avatar-badged) { margin-left: calc(var(--avatar-overlap) * -1); }
|
|
96
|
+
/* A face with a face after it: the next one's circle and its ring taken out of it. */
|
|
97
|
+
:is(.o-avatar-stack > .o-avatar:has(+ :is(.o-avatar, .o-avatar-badged)), .o-avatar-stack > .o-avatar-badged:has(+ :is(.o-avatar, .o-avatar-badged)) > .o-avatar) {
|
|
98
|
+
--avatar-next-at: calc(var(--avatar-size) - var(--avatar-overlap) - var(--avatar-cut)) calc(var(--avatar-cut) * -1);
|
|
99
|
+
--avatar-next-size: calc(var(--avatar-size) + var(--avatar-cut) * 2) calc(var(--avatar-size) + var(--avatar-cut) * 2);
|
|
100
|
+
}
|
|
101
|
+
/* A face after a badged one: that face's badge stands over it, its circle and ring taken out of it too. */
|
|
102
|
+
:is(.o-avatar-stack > .o-avatar-badged + .o-avatar, .o-avatar-stack > .o-avatar-badged + .o-avatar-badged > .o-avatar) {
|
|
103
|
+
--avatar-prev-at: calc(var(--avatar-overlap) - var(--avatar-dot-inset) - var(--avatar-dot) - var(--avatar-cut)) calc(var(--avatar-size) - var(--avatar-dot-inset) - var(--avatar-dot) - var(--avatar-cut));
|
|
104
|
+
--avatar-prev-size: calc(var(--avatar-dot) + var(--avatar-cut) * 2) calc(var(--avatar-dot) + var(--avatar-cut) * 2);
|
|
105
|
+
}
|
|
106
|
+
/* The whole stack as one button (after Linear): the quiet Button wearing it, its ground under the pointer showing through the cuts. */
|
|
107
|
+
.o-button.o-avatar-stack-button { height: auto; padding: var(--vk-spacing); --button-r: var(--vk-radius-full); --button-side: calc(var(--vk-spacing) * 10 + var(--button-line) * 2); }
|
|
108
|
+
/* Its side, its faces' size and its padding, which its own corner is fitted to where a frame's Corners outweighs its Full. */
|
|
109
|
+
.o-button.o-avatar-stack-button:has(.o-avatar-xs) { --button-side: calc(var(--vk-spacing) * 7 + var(--button-line) * 2); }
|
|
110
|
+
.o-button.o-avatar-stack-button:has(.o-avatar-sm) { --button-side: calc(var(--vk-spacing) * 8 + var(--button-line) * 2); }
|
|
111
|
+
.o-button.o-avatar-stack-button:has(.o-avatar-lg) { --button-side: calc(var(--vk-spacing) * 12 + var(--button-line) * 2); }
|
|
112
|
+
.o-button.o-avatar-stack-button:has(.o-avatar-xl) { --button-side: calc(var(--vk-spacing) * 18 + var(--button-line) * 2); }
|
|
113
|
+
/* Its add (after Asana): the outline Button the avatar's size, its edge dashed at rest, solid under the pointer. */
|
|
114
|
+
.o-avatar-add[data-size="20"] { --avatar-size: calc(var(--vk-spacing) * 5); }
|
|
115
|
+
.o-avatar-add[data-size="24"] { --avatar-size: calc(var(--vk-spacing) * 6); }
|
|
116
|
+
.o-avatar-add[data-size="32"] { --avatar-size: calc(var(--vk-spacing) * 8); }
|
|
117
|
+
.o-avatar-add[data-size="40"] { --avatar-size: calc(var(--vk-spacing) * 10); }
|
|
118
|
+
.o-avatar-add[data-size="64"] { --avatar-size: calc(var(--vk-spacing) * 16); }
|
|
119
|
+
.o-button.o-avatar-add { flex: none; width: var(--avatar-size); height: var(--avatar-size); --button-side: var(--avatar-size); padding: 0; border-style: dashed; }
|
|
120
|
+
@media (hover: hover) { .o-button.o-avatar-add:hover { border-style: solid; } }
|
|
121
|
+
/* A stack and its add stand together on one line. */
|
|
122
|
+
.o-avatar-stack-group { display: inline-flex; align-items: center; gap: var(--vk-spacing); }
|
|
123
|
+
/* The rest, as a count in a neutral circle. */
|
|
124
|
+
.o-avatar.o-avatar-more { background-color: var(--vk-neutral); color: var(--vk-fg-subtle); font-variant-numeric: tabular-nums; }
|
|
125
|
+
/* ── Presence and the badge: a dot on the corner, its size stepping with the avatar's (6,
|
|
126
|
+
8, 10, 12, 16), cut out of whatever the avatar stands on by a mask, never a ring painted in the page's colour. The mask stands
|
|
127
|
+
only on a badged avatar and a stack's faces: a mask clips what is outside the box and makes a stacking context. ──────── */
|
|
128
|
+
:is(.o-avatar, .o-avatar-badged) { --avatar-size: calc(var(--vk-spacing) * 8); --avatar-dot: calc(var(--vk-spacing) * 2.5); --avatar-cut: calc(var(--vk-spacing) * 0.5); --avatar-dot-inset: 0px; }
|
|
129
|
+
.o-avatar.o-avatar-2xs { --avatar-size: calc(var(--vk-spacing) * 4); }
|
|
130
|
+
:is(.o-avatar.o-avatar-xs, .o-avatar-badged[data-size="20"]) { --avatar-size: calc(var(--vk-spacing) * 5); --avatar-dot: var(--vk-dot-size); --avatar-cut: calc(var(--vk-spacing) * 0.375); }
|
|
131
|
+
:is(.o-avatar.o-avatar-sm, .o-avatar-badged[data-size="24"]) { --avatar-size: calc(var(--vk-spacing) * 6); --avatar-dot: calc(var(--vk-spacing) * 2); }
|
|
132
|
+
:is(.o-avatar.o-avatar-lg, .o-avatar-badged[data-size="40"]) { --avatar-size: calc(var(--vk-spacing) * 10); --avatar-dot: calc(var(--vk-spacing) * 3); }
|
|
133
|
+
:is(.o-avatar.o-avatar-xl, .o-avatar-badged[data-size="64"]) { --avatar-size: calc(var(--vk-spacing) * 16); --avatar-dot: calc(var(--vk-spacing) * 4); --avatar-dot-inset: calc(var(--vk-spacing) * 0.5); }
|
|
134
|
+
:is(.o-avatar.o-avatar-thing, .o-avatar-badged[data-thing]) { --avatar-dot-inset: calc(var(--vk-spacing) * -0.75); }
|
|
135
|
+
.o-avatar-badged { position: relative; display: inline-flex; flex: none; vertical-align: middle; isolation: isolate; }
|
|
136
|
+
/* In a stack the badge stands over the next face, so the stack holds it, not the face. */
|
|
137
|
+
.o-avatar-stack > .o-avatar-badged { isolation: auto; }
|
|
138
|
+
.o-avatar-badge {
|
|
139
|
+
position: absolute; right: var(--avatar-dot-inset); bottom: var(--avatar-dot-inset); z-index: 1; box-sizing: border-box;
|
|
140
|
+
display: grid; place-items: center; width: var(--avatar-dot); height: var(--avatar-dot); border-radius: var(--vk-radius-full);
|
|
141
|
+
background-color: var(--vk-brand); color: var(--vk-fg-on-brand);
|
|
142
|
+
}
|
|
143
|
+
.o-avatar-badge > svg { display: none; width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
|
|
144
|
+
.o-avatar-badged:is([data-size="32"], [data-size="40"], [data-size="64"]) > .o-avatar-badge > svg { display: block; }
|
|
145
|
+
/* Here, a green dot; away, a hollow ring whose middle shows the ground. */
|
|
146
|
+
.o-avatar-badge[data-presence="here"] { background-color: var(--vk-success-bold); }
|
|
147
|
+
.o-avatar-badge[data-presence="away"] { background-color: transparent; box-shadow: inset 0 0 0 calc(var(--vk-border-width) * 2) var(--vk-fg-subtlest); }
|
|
148
|
+
.o-avatar-badged[data-size="20"] > .o-avatar-badge[data-presence="away"] { box-shadow: inset 0 0 0 calc(var(--vk-border-width) * 1.5) var(--vk-fg-subtlest); }
|
|
149
|
+
/* The cut: circles taken out of the avatar, the ground showing through them. Each is an SVG circle (WebKit draws a gradient's
|
|
150
|
+
edge ragged in a mask), set where it stands and how big: the badge's own, with its ring; in a stack, the next face's and the
|
|
151
|
+
badge of the face before. Unused, a circle is drawn at no size. */
|
|
152
|
+
.o-avatar-badged > .o-avatar {
|
|
153
|
+
--avatar-own-at: calc(var(--avatar-size) - var(--avatar-dot-inset) - var(--avatar-dot) - var(--avatar-cut)) calc(var(--avatar-size) - var(--avatar-dot-inset) - var(--avatar-dot) - var(--avatar-cut));
|
|
154
|
+
--avatar-own-size: calc(var(--avatar-dot) + var(--avatar-cut) * 2) calc(var(--avatar-dot) + var(--avatar-cut) * 2);
|
|
155
|
+
}
|
|
156
|
+
:is(.o-avatar-badged > .o-avatar, .o-avatar-stack > .o-avatar, .o-avatar-stack > .o-avatar-badged > .o-avatar) {
|
|
157
|
+
--avatar-hole: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/svg%3E");
|
|
158
|
+
mask-image: linear-gradient(black 0 0), var(--avatar-hole), var(--avatar-hole), var(--avatar-hole);
|
|
159
|
+
mask-repeat: no-repeat; mask-composite: subtract, add, add;
|
|
160
|
+
mask-position: 0 0, var(--avatar-own-at, 0 0), var(--avatar-next-at, 0 0), var(--avatar-prev-at, 0 0);
|
|
161
|
+
mask-size: 100% 100%, var(--avatar-own-size, 0 0), var(--avatar-next-size, 0 0), var(--avatar-prev-size, 0 0);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -4,6 +4,7 @@ import { MapPopover } from "./popover/map-popover.js";
|
|
|
4
4
|
import { MapSheet } from "./sheet/map-sheet.js";
|
|
5
5
|
import { MapCheckbox } from "./checkbox/map-checkbox.js";
|
|
6
6
|
import { MapInput } from "./input/map-input.js";
|
|
7
|
+
import { MapMenu } from "./menu/map-menu.js";
|
|
7
8
|
export declare const CONTROLS: {
|
|
8
9
|
Button: typeof MapButton;
|
|
9
10
|
Tooltip: typeof MapTooltip;
|
|
@@ -11,4 +12,5 @@ export declare const CONTROLS: {
|
|
|
11
12
|
Sheet: typeof MapSheet;
|
|
12
13
|
Input: typeof MapInput;
|
|
13
14
|
Checkbox: typeof MapCheckbox;
|
|
15
|
+
Menu: typeof MapMenu;
|
|
14
16
|
};
|
|
@@ -4,6 +4,7 @@ import { MapPopover } from "./popover/map-popover.js";
|
|
|
4
4
|
import { MapSheet } from "./sheet/map-sheet.js";
|
|
5
5
|
import { MapCheckbox } from "./checkbox/map-checkbox.js";
|
|
6
6
|
import { MapInput } from "./input/map-input.js";
|
|
7
|
+
import { MapMenu } from "./menu/map-menu.js";
|
|
7
8
|
export const CONTROLS = {
|
|
8
9
|
Button: MapButton,
|
|
9
10
|
Tooltip: MapTooltip,
|
|
@@ -11,4 +12,5 @@ export const CONTROLS = {
|
|
|
11
12
|
Sheet: MapSheet,
|
|
12
13
|
Input: MapInput,
|
|
13
14
|
Checkbox: MapCheckbox,
|
|
15
|
+
Menu: MapMenu,
|
|
14
16
|
};
|
|
@@ -41,3 +41,15 @@ export { useHoldDrag, type HoldDragProps, type HoldReads } from "./internal/hold
|
|
|
41
41
|
export { dragAt, gapOf, moved, useReorder, type ReorderDrag, type RowEdges } from "./internal/reorder.js";
|
|
42
42
|
export { rowFor, rowStarting } from "./menu-list/keys.js";
|
|
43
43
|
export { MenuList, MenuListPanelRows, MenuListRow, MenuListRows, MenuListShown, MenuScroll, menuListCloseOf, menuListRowsOf, sheetFormOf, tilesOf, useMenuListOption, useMenuListRows, type MenuChoice, type MenuEntry, type MenuListEntry, type MenuListPanelRowsProps, type MenuListProps, type MenuListTile, } from "./menu-list/menu-list.js";
|
|
44
|
+
export { COMPUTER_HOST, ComputerHost, PhoneHost, usePhone } from "./internal/phone.js";
|
|
45
|
+
export { drawnAt, focusWhereItStands, focusesInPlace, holdsThePage, keepsToItsList, overflows, scaleOf, scrollInList, scrollTopFor, scrollTopForDrag, staysInView, tapsInPlace, typesInto, } from "./internal/scroll.js";
|
|
46
|
+
export { ContextMenu, Menu, MenuDots, useSheetMenus, type MenuChangeDetails, type MenuProps, } from "./menu/menu.js";
|
|
47
|
+
export { MapMenu, menuEntries } from "./menu/map-menu.js";
|
|
48
|
+
export { Avatar, AvatarStack, initials, toneOf, type AvatarPresence, type AvatarProps, type AvatarSize, type AvatarStackPerson, type AvatarStackProps, } from "./avatar/avatar.js";
|
|
49
|
+
export { Picker, PickerUnder, usePicker, type PickerAction, type PickerBoxSearch, type PickerDoing, type PickerLead, type PickerParts, type PickerProps, type PickerUnderProps, } from "./picker/picker.js";
|
|
50
|
+
export { exactMatch, findItem, fold, itemLabel, openLevels, orderMoved, pickerRows, searchShown, type PickerAs, type PickerItem, type PickerRow, type RowsInput, } from "./picker/rows.js";
|
|
51
|
+
export { pickerRead, pickerWornOf, type PickerWorn } from "./picker/looks.js";
|
|
52
|
+
export { Select, SelectShown, toPickerItems, type SelectAloneProps, type SelectItem, type SelectListProps, type SelectProps, type SelectShownProps, } from "./select/select.js";
|
|
53
|
+
export { listSide, type ListSide } from "./select/side.js";
|
|
54
|
+
export { chipsThatFit } from "./select/fit.js";
|
|
55
|
+
export { filledMatch } from "./select/filled.js";
|
|
@@ -35,3 +35,15 @@ export { useHoldDrag } from "./internal/hold.js";
|
|
|
35
35
|
export { dragAt, gapOf, moved, useReorder } from "./internal/reorder.js";
|
|
36
36
|
export { rowFor, rowStarting } from "./menu-list/keys.js";
|
|
37
37
|
export { MenuList, MenuListPanelRows, MenuListRow, MenuListRows, MenuListShown, MenuScroll, menuListCloseOf, menuListRowsOf, sheetFormOf, tilesOf, useMenuListOption, useMenuListRows, } from "./menu-list/menu-list.js";
|
|
38
|
+
export { COMPUTER_HOST, ComputerHost, PhoneHost, usePhone } from "./internal/phone.js";
|
|
39
|
+
export { drawnAt, focusWhereItStands, focusesInPlace, holdsThePage, keepsToItsList, overflows, scaleOf, scrollInList, scrollTopFor, scrollTopForDrag, staysInView, tapsInPlace, typesInto, } from "./internal/scroll.js";
|
|
40
|
+
export { ContextMenu, Menu, MenuDots, useSheetMenus, } from "./menu/menu.js";
|
|
41
|
+
export { MapMenu, menuEntries } from "./menu/map-menu.js";
|
|
42
|
+
export { Avatar, AvatarStack, initials, toneOf, } from "./avatar/avatar.js";
|
|
43
|
+
export { Picker, PickerUnder, usePicker, } from "./picker/picker.js";
|
|
44
|
+
export { exactMatch, findItem, fold, itemLabel, openLevels, orderMoved, pickerRows, searchShown, } from "./picker/rows.js";
|
|
45
|
+
export { pickerRead, pickerWornOf } from "./picker/looks.js";
|
|
46
|
+
export { Select, SelectShown, toPickerItems, } from "./select/select.js";
|
|
47
|
+
export { listSide } from "./select/side.js";
|
|
48
|
+
export { chipsThatFit } from "./select/fit.js";
|
|
49
|
+
export { filledMatch } from "./select/filled.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** A screen standing on a page as a phone's: what stands in it behaves as on a phone, its popups put inside it. */
|
|
3
|
+
export declare const PhoneHost: React.Context<HTMLElement | null>;
|
|
4
|
+
/** The attribute that marks a computer host: a box standing for a computer's screen inside a phone's window. */
|
|
5
|
+
export declare const COMPUTER_HOST = "data-computer-host";
|
|
6
|
+
/** Inside a computer host: usePhone is false there. A PhoneHost screen inside it is still a phone's. */
|
|
7
|
+
export declare const ComputerHost: React.Context<boolean>;
|
|
8
|
+
/** True in a window narrower than 640px, outside a computer host; false through the server's first draw. */
|
|
9
|
+
export declare const usePhone: () => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SMALL = "(max-width: 639px)";
|
|
3
|
+
const listen = (change) => {
|
|
4
|
+
const m = matchMedia(SMALL);
|
|
5
|
+
m.addEventListener("change", change);
|
|
6
|
+
return () => m.removeEventListener("change", change);
|
|
7
|
+
};
|
|
8
|
+
export const PhoneHost = React.createContext(null);
|
|
9
|
+
export const COMPUTER_HOST = "data-computer-host";
|
|
10
|
+
export const ComputerHost = React.createContext(false);
|
|
11
|
+
export const usePhone = () => {
|
|
12
|
+
const computer = React.useContext(ComputerHost);
|
|
13
|
+
const narrow = React.useSyncExternalStore(listen, () => matchMedia(SMALL).matches, () => false);
|
|
14
|
+
return narrow && !computer;
|
|
15
|
+
};
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
export declare function msOf(el: Element | null | undefined, prop: `--${string}`): number;
|
|
3
3
|
/** A length in px ("1px" is 1), 0 where nothing declares it. */
|
|
4
4
|
export declare function pxOf(el: Element | null | undefined, prop: `--${string}`): number;
|
|
5
|
-
/** Steps of the spacing name, in px (1.5 steps is 6px at the default 4px)
|
|
5
|
+
/** Steps of the spacing name, in px (1.5 steps is 6px at the default 4px), read off `el`; with no element (a popup outside any
|
|
6
|
+
* popup host), off the page's root, where the ready stylesheet declares it. */
|
|
6
7
|
export declare const spacingPx: (steps: number, el: Element | null | undefined) => number;
|
|
@@ -8,4 +8,4 @@ export function msOf(el, prop) {
|
|
|
8
8
|
export function pxOf(el, prop) {
|
|
9
9
|
return parseFloat(read(el, prop)) || 0;
|
|
10
10
|
}
|
|
11
|
-
export const spacingPx = (steps, el) => pxOf(el, "--vk-spacing") * steps;
|
|
11
|
+
export const spacingPx = (steps, el) => pxOf(el ?? (typeof document === "undefined" ? undefined : document.documentElement), "--vk-spacing") * steps;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type Block = "start" | "center" | "end" | "nearest";
|
|
1
2
|
/** The scale a length is drawn at: on screen over its own; 1 where they agree to within offset*'s rounding, or it has none. */
|
|
2
3
|
export declare const scaleOf: (onScreen: number, own: number) => number;
|
|
3
4
|
/** The scale an element is drawn at, read along its longer side, where offset*'s whole-pixel rounding weighs least. */
|
|
@@ -9,3 +10,40 @@ export declare const overflows: (room: number, content: number) => boolean;
|
|
|
9
10
|
* moves nothing. */
|
|
10
11
|
export declare function scrollTopForDrag(start: number, moved: number, room: number, content: number, track: number, thumb: number): number;
|
|
11
12
|
export declare const typesInto: (el: EventTarget | null) => el is HTMLElement;
|
|
13
|
+
/** Where a list's scrollTop goes to bring a row into sight, all in the list's own pixels: the row `at` from the list's
|
|
14
|
+
* content top, `height` tall; the list `room` tall, scrolled to `now`, at most to `max`. */
|
|
15
|
+
export declare function scrollTopFor(block: Block, at: number, height: number, room: number, now: number, max: number): number;
|
|
16
|
+
/** Brings a row into sight inside its own list, as scrollIntoView would, the window never moving. The list's own scroll padding
|
|
17
|
+
* (scroll-padding-top and -bottom) is kept clear round the row, as the browser's own scrollIntoView keeps it. */
|
|
18
|
+
export declare function scrollInList(row: Element, options?: boolean | ScrollIntoViewOptions): void;
|
|
19
|
+
/** A row's ref: whatever asks it to scroll into view (Base UI's list navigation) scrolls its own list alone, and a focus on it
|
|
20
|
+
* scrolls nothing. Base UI's focus manager focuses a list's chosen row the frame after it opens, without preventScroll, and
|
|
21
|
+
* where the list's first frame is counted from a box far down, that focus scrolled the page to the row there; the list's own navigation brings the
|
|
22
|
+
* row into view in its list a frame later. */
|
|
23
|
+
export declare function keepsToItsList(row: HTMLElement | null): void;
|
|
24
|
+
/** A row's ref where it stands always in view, outside what scrolls (the Picker's foot): asked to scroll into view, it
|
|
25
|
+
* scrolls nothing, where scrollInList would look past its list for something that scrolls (a page's section); a focus on it
|
|
26
|
+
* scrolls nothing either. */
|
|
27
|
+
export declare function staysInView(row: HTMLElement | null): void;
|
|
28
|
+
/** While a list is open the page behind it never moves, by a wheel or a finger: a scroll goes through only where it moves the
|
|
29
|
+
* list's own rows, and every other is stopped, outside the list, on a list whose rows all fit, at the rows' ends. Base UI
|
|
30
|
+
* locks the document only for a list opened by a pointer, leaving it free for one opened by a finger (so a swipe outside can
|
|
31
|
+
* dismiss it), and a box that doesn't scroll hands a scroll on to whatever scrolls round it in Safari, whatever its
|
|
32
|
+
* overscroll-behavior says: a page's section, or the page. A finger that
|
|
33
|
+
* lands outside the list lands on Base UI's backdrop, which closes the list and turns inert at once, so no script sees that
|
|
34
|
+
* finger again: the Select's stylesheet stops it from panning instead (touch-action, read as the finger lands). A pinch and a zoom (two
|
|
35
|
+
* fingers, or a wheel with Ctrl) go through. Returns what lets the page go. */
|
|
36
|
+
export declare function holdsThePage(doc: Document, popup: () => Element | null): () => void;
|
|
37
|
+
/** Focuses a box where it stands, as Base UI's drawer keyboard provider does: Safari brings a box it focuses into view by
|
|
38
|
+
* scrolling the page, even one focused with preventScroll inside something a transform moves (a Sheet). Moved off the screen for
|
|
39
|
+
* the call alone, and put back before anything is drawn, the box asks for nothing. */
|
|
40
|
+
export declare function focusWhereItStands(box: HTMLElement): void;
|
|
41
|
+
/** A tap on a box that `within` takes is the box's to focus where it stands: a touch that ends within 10px of where it
|
|
42
|
+
* started, on a box the keyboard rises for (or a label of one), not yet focused and not disabled, the page not pinch zoomed. Its
|
|
43
|
+
* default is prevented, so Safari neither focuses the box itself nor scrolls the page to it, and a click is sent in its place, so
|
|
44
|
+
* what listens for one still hears it. A box already focused takes the tap itself, to place the caret. Returns what lets go. */
|
|
45
|
+
export declare function tapsInPlace(doc: Document, within: (box: HTMLElement) => boolean): () => void;
|
|
46
|
+
/** An element in a list's popup (a row, the list's search box) whose focus scrolls nothing: Base UI focuses it in the popup's
|
|
47
|
+
* first frame, before the popup stands in its place. */
|
|
48
|
+
export declare function focusesInPlace(el: HTMLElement | null): void;
|
|
49
|
+
export {};
|