viewkitjs 0.30.1 → 0.31.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 +14 -0
- package/package.json +4 -2
- package/views/dist/controls/avatar/avatar.d.ts +10 -4
- package/views/dist/controls/avatar/avatar.js +5 -3
- package/views/dist/controls/avatar/tokens.d.ts +60 -0
- package/views/dist/controls/avatar/tokens.js +15 -0
- package/views/dist/controls/avatar.css +29 -15
- package/views/dist/controls/index.d.ts +3 -2
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.d.ts +12 -1
- package/views/dist/controls/input/input.js +7 -6
- package/views/dist/controls/input/save-mark.d.ts +8 -0
- package/views/dist/controls/input/save-mark.js +26 -0
- package/views/dist/controls/input/tokens.d.ts +16 -0
- package/views/dist/controls/input/tokens.js +4 -0
- package/views/dist/controls/input.css +18 -0
- package/views/dist/controls/radio/radio.d.ts +7 -0
- package/views/dist/controls/radio/radio.js +8 -4
- package/views/dist/controls/radio/tokens.d.ts +40 -0
- package/views/dist/controls/radio/tokens.js +10 -0
- package/views/dist/controls/radio.css +52 -3
- package/views/dist/controls/select/select.d.ts +8 -2
- package/views/dist/controls/select/select.js +6 -4
- package/views/dist/controls/setting-row/looks.d.ts +10 -0
- package/views/dist/controls/setting-row/looks.js +17 -0
- package/views/dist/controls/setting-row/setting-row.d.ts +65 -0
- package/views/dist/controls/setting-row/setting-row.js +66 -0
- package/views/dist/controls/setting-row/tokens.d.ts +84 -0
- package/views/dist/controls/setting-row/tokens.js +23 -0
- package/views/dist/controls/setting-row.css +94 -0
- package/views/dist/controls/switch-row/switch-row.d.ts +1 -15
- package/views/dist/controls/switch-row/switch-row.js +1 -9
- package/views/dist/controls/tokens.js +2 -0
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/styles.css +182 -19
- package/views/dist/styles.unlayered.css +182 -19
- package/views/docs/controls/avatar.md +15 -0
- package/views/docs/controls/input.md +8 -0
- package/views/docs/controls/radio.md +18 -0
- package/views/docs/controls/select.md +4 -0
- package/views/docs/controls/setting-row.md +26 -0
- package/views/docs/reference/controls.md +25 -8
- package/views/docs/reference/looks.md +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.31.0] — 2026-12-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `viewkitjs/views/controls`: the `Avatar` takes `colour`, one of the label hues (`AvatarColour`: blue, green, amber, red, purple, pink, teal or grey, the Option's list). A thing's, an agent's or the workspace's square stands on the hue's fill, its letters or icon in the hue's strong ink, with no edge; a person keeps their tone. Its stylesheet reads the label hues' `--vk-label-<hue>-fill` and `--vk-label-<hue>-strong`.
|
|
13
|
+
- `viewkitjs/views/controls`: the `Avatar` draws at 56 (`AvatarSize`), between 40 and 64, its letters at `--vk-font-size-xl` and a square's corners on 64's steps. An `AvatarStack` takes neither 16 nor 56.
|
|
14
|
+
- The setting row, on `viewkitjs/views/controls`: `SettingRow` draws one setting as a row, its name and a line under it, at its end a switch (`switch`), a select (`select`), a button (`action`) or › to its page (`onOpen`, with its `value`), a `mark` or an `icon` at its start; `locked` (the reason) shuts its control; `alone` stands a lone row bare. `SettingRows` holds them in a card, a line between each, `danger` the danger zone's red edge with each button the Button's danger kind. On a phone the card and its rows are Field rows'. Its stylesheet is `viewkitjs/views/controls/setting-row.css`, in the ready stylesheet; its names are on `docs/controls/setting-row.md`.
|
|
15
|
+
- Its options and looks, `SETTING_ROW_LOOKS` on `viewkitjs/views/looks`: the card (`outlined` or `raised`) and the rows (`snug` or `roomy`), each a computer's, set on the frame as `data-setting-row-card` and `data-setting-row-rows`; two looks, `outright` (nothing picked) and `attio` (`raised`, `roomy`). With them `settingRowWornOf` and `SETTING_ROW_ATTRS`.
|
|
16
|
+
- `SwitchRow` and `SwitchRows` are now the setting row's switch kind, with the props and the classes they had: an app that draws them changes nothing. They draw as before with `switch-row.css`, which stays; an app that imports the controls one by one may import `setting-row.css` in its place to draw the other kinds too (the Showcase does). The portal, Atlas and outright-base draw no SwitchRow and change nothing.
|
|
17
|
+
- `viewkitjs/views/controls`: the Radio's `swatch`, one of the label colours (`blue`, `green`, `amber`, `red`, `purple`, `pink`, `teal`, `grey`) drawn as a 24px dot in place of its ring, for picking a colour. Give it an `aria-label`, the colour's name. Chosen, it is ringed in the selected colour just outside a thin ring of the ground; hovered, the same ring in the field's hovered edge; focused, the focus outline outside that ring; disabled, grey and dashed, passed by the arrows. A `row` group stands them 10 apart. It reads `--vk-label-<hue>-fill` and `--vk-neutral`.
|
|
18
|
+
- `viewkitjs/views/controls`: a marked card's `picture` on the Radio: what your app draws (Light, Dark or System as a little app) fills the card's width, 120 tall, over its mark and its name, which stand side by side under it. A picture makes the card marked with a mark or without. Chosen, its words take the text colour. A `row` group stands pictured cards one beside another at equal widths, on a phone too. New names the Radio reads: `--vk-fg`, `--vk-font-weight-medium`, `--vk-radius-sm`, and the seven `--vk-label-<hue>-fill`.
|
|
19
|
+
- `viewkitjs/views/controls`: `saving` and `saved` on the `Input`, the `InputGroup` and every `Select` field, for a field that saves on its own. Saving, the Spinner stands at the field's end (before a Select's chevron) and the field is busy (`aria-busy`), still typed into; saved, a check and the word "Saved" stand there in the success colour, announced, fade after `--vk-saved-hold` and leave the field. It shows again each time `saved` turns on; saving wins when both are on. `data-force="saved"` holds Saved on a page that shows it. A save that fails is still the Field's `error`, your app putting the value before back.
|
|
20
|
+
- The new name `--vk-saved-hold` (motion; 2000ms at the Outright look), and the Input now reads `--vk-success`, `--vk-duration-base` and `--vk-ease-in`. The Spinner's label is "Saving".
|
|
21
|
+
|
|
8
22
|
## [0.30.1] — 2026-12-01
|
|
9
23
|
|
|
10
24
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viewkitjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "ViewKit — typed fields, the grid and its editors, and a list's SQL for record lists, in one package: viewkitjs/fields, viewkitjs/views and viewkitjs/postgres. By Sheaf.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/outright-agency/
|
|
8
|
+
"url": "git+https://github.com/outright-agency/viewkit.git"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"sideEffects": [
|
|
@@ -244,7 +244,9 @@
|
|
|
244
244
|
"@prisma/adapter-pg": "7.10.0",
|
|
245
245
|
"@prisma/client": "7.10.0",
|
|
246
246
|
"@tailwindcss/postcss": "4.3.3",
|
|
247
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
247
248
|
"@testing-library/react": "^16.3.2",
|
|
249
|
+
"@testing-library/user-event": "^14.6.1",
|
|
248
250
|
"@types/node": "^20",
|
|
249
251
|
"@types/pg": "^8.20.0",
|
|
250
252
|
"@types/react": "^19",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { type OptionColour } from "../option/looks.js";
|
|
3
|
+
export type AvatarSize = 16 | 20 | 24 | 32 | 40 | 56 | 64;
|
|
4
|
+
/** A square's own colour: one of the label hues, or grey, the Option's list. */
|
|
5
|
+
export type AvatarColour = OptionColour;
|
|
3
6
|
/** The initials of a name: the first letters of the first and last names; a first name of two joined
|
|
4
7
|
* parts gives both ("Maximiliane-Theodora von Hohenberg-Lichtenstein" is MT); one name gives one ("Jo" is J). */
|
|
5
8
|
export declare function initials(name: string): string;
|
|
@@ -15,12 +18,15 @@ export interface AvatarProps {
|
|
|
15
18
|
* fills, or with neither its first letter. */
|
|
16
19
|
kind?: "person" | "thing" | "workspace" | "agent";
|
|
17
20
|
/** 16 in a chip (a typed Select's), with no badge; 20 in chips and text, 24 in dense rows and stacks, 32 in list rows,
|
|
18
|
-
* 40 in headers, 64 on a record's own page. */
|
|
21
|
+
* 40 in headers, 56 at a settings page's head, 64 on a record's own page. */
|
|
19
22
|
size?: AvatarSize;
|
|
20
23
|
/** A stable id, for a person's tone. */
|
|
21
24
|
id?: string;
|
|
22
25
|
/** The tone itself, where the app keeps it. */
|
|
23
26
|
tone?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
27
|
+
/** A square's own colour (a team's letter, an app's or an object's icon, the workspace's initials on the colour picked
|
|
28
|
+
* for it): the square on the hue's fill, what it holds in the hue's strong ink, with no edge. A person keeps their tone. */
|
|
29
|
+
colour?: AvatarColour;
|
|
24
30
|
/** A photo or a logo, filling the same shape. */
|
|
25
31
|
src?: string;
|
|
26
32
|
/** A record with no name: its kind's icon instead of a letter. */
|
|
@@ -32,7 +38,7 @@ export interface AvatarProps {
|
|
|
32
38
|
className?: string;
|
|
33
39
|
}
|
|
34
40
|
/** Who or what a row is about, at a glance. */
|
|
35
|
-
export declare function Avatar({ name, kind, size, id, tone, src, icon, presence, badge, className }: AvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare function Avatar({ name, kind, size, id, tone, colour, src, icon, presence, badge, className }: AvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
36
42
|
/** One person on a stack. */
|
|
37
43
|
export type AvatarStackPerson = Omit<AvatarProps, "size" | "kind">;
|
|
38
44
|
export interface AvatarStackProps {
|
|
@@ -40,7 +46,7 @@ export interface AvatarStackProps {
|
|
|
40
46
|
people: AvatarStackPerson[];
|
|
41
47
|
/** How many to show before the rest become a count. */
|
|
42
48
|
max?: number;
|
|
43
|
-
size?: Exclude<AvatarSize, 16>;
|
|
49
|
+
size?: Exclude<AvatarSize, 16 | 56>;
|
|
44
50
|
className?: string;
|
|
45
51
|
/** What everyone is on ("Acme Robotics renewal"): the list's name to a screen reader. Left out, the stack's own words. */
|
|
46
52
|
label?: string;
|
|
@@ -5,9 +5,10 @@ import { cx } from "../../internal/cx.js";
|
|
|
5
5
|
import { Button } from "../button/button.js";
|
|
6
6
|
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
7
7
|
import { Menu } from "../menu/menu.js";
|
|
8
|
+
import { optionColours } from "../option/looks.js";
|
|
8
9
|
import { Icon } from "../internal/icons.js";
|
|
9
10
|
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
|
+
const SIZE = { 16: "o-avatar-2xs", 20: "o-avatar-xs", 24: "o-avatar-sm", 32: "", 40: "o-avatar-lg", 56: "o-avatar-56", 64: "o-avatar-xl" };
|
|
11
12
|
export function initials(name) {
|
|
12
13
|
const words = name.split(/\s+/).filter((w) => /^\p{L}/u.test(w));
|
|
13
14
|
if (!words.length)
|
|
@@ -23,10 +24,11 @@ export function toneOf(id) {
|
|
|
23
24
|
h = (h * 31 + c.charCodeAt(0)) >>> 0;
|
|
24
25
|
return (h % 6) + 1;
|
|
25
26
|
}
|
|
26
|
-
export function Avatar({ name, kind = "person", size = 32, id, tone, src, icon, presence, badge, className }) {
|
|
27
|
+
export function Avatar({ name, kind = "person", size = 32, id, tone, colour, src, icon, presence, badge, className }) {
|
|
27
28
|
const person = kind === "person";
|
|
29
|
+
const coloured = !person && colour && optionColours.includes(colour) ? colour : undefined;
|
|
28
30
|
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 })] }));
|
|
31
|
+
const avatar = (_jsxs(BaseAvatar.Root, { role: "img", "aria-label": presence ? `${name}, ${presence}` : name, "data-kit": "avatar", "data-tone": person ? tone ?? toneOf(id ?? name) : undefined, "data-colour": coloured, 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
32
|
if (size === 16 || (!presence && (badge == null || badge === false)))
|
|
31
33
|
return avatar;
|
|
32
34
|
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" })
|
|
@@ -22,6 +22,62 @@ export declare const AVATAR_TOKENS: readonly [{
|
|
|
22
22
|
readonly name: "--vk-fg-subtlest";
|
|
23
23
|
readonly kind: "colour";
|
|
24
24
|
readonly outright: "--text-subtlest";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-label-amber-fill";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--label-amber-fill";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-label-amber-strong";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--label-amber-strong";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-label-blue-fill";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--label-blue-fill";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-label-blue-strong";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--label-blue-strong";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-label-green-fill";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--label-green-fill";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-label-green-strong";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--label-green-strong";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-label-pink-fill";
|
|
51
|
+
readonly kind: "colour";
|
|
52
|
+
readonly outright: "--label-pink-fill";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-label-pink-strong";
|
|
55
|
+
readonly kind: "colour";
|
|
56
|
+
readonly outright: "--label-pink-strong";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-label-purple-fill";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--label-purple-fill";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-label-purple-strong";
|
|
63
|
+
readonly kind: "colour";
|
|
64
|
+
readonly outright: "--label-purple-strong";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-label-red-fill";
|
|
67
|
+
readonly kind: "colour";
|
|
68
|
+
readonly outright: "--label-red-fill";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-label-red-strong";
|
|
71
|
+
readonly kind: "colour";
|
|
72
|
+
readonly outright: "--label-red-strong";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-label-teal-fill";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--label-teal-fill";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-label-teal-strong";
|
|
79
|
+
readonly kind: "colour";
|
|
80
|
+
readonly outright: "--label-teal-strong";
|
|
25
81
|
}, {
|
|
26
82
|
readonly name: "--vk-neutral";
|
|
27
83
|
readonly kind: "colour";
|
|
@@ -82,6 +138,10 @@ export declare const AVATAR_TOKENS: readonly [{
|
|
|
82
138
|
readonly name: "--vk-font-size-sm";
|
|
83
139
|
readonly kind: "size";
|
|
84
140
|
readonly outright: "--text-sm";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "--vk-font-size-xl";
|
|
143
|
+
readonly kind: "size";
|
|
144
|
+
readonly outright: "--text-xl";
|
|
85
145
|
}, {
|
|
86
146
|
readonly name: "--vk-font-size-xs";
|
|
87
147
|
readonly kind: "size";
|
|
@@ -5,6 +5,20 @@ export const AVATAR_TOKENS = [
|
|
|
5
5
|
{ name: "--vk-fg-on-brand", kind: "colour", outright: "--text-brand-inverse" },
|
|
6
6
|
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
7
7
|
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
8
|
+
{ name: "--vk-label-amber-fill", kind: "colour", outright: "--label-amber-fill" },
|
|
9
|
+
{ name: "--vk-label-amber-strong", kind: "colour", outright: "--label-amber-strong" },
|
|
10
|
+
{ name: "--vk-label-blue-fill", kind: "colour", outright: "--label-blue-fill" },
|
|
11
|
+
{ name: "--vk-label-blue-strong", kind: "colour", outright: "--label-blue-strong" },
|
|
12
|
+
{ name: "--vk-label-green-fill", kind: "colour", outright: "--label-green-fill" },
|
|
13
|
+
{ name: "--vk-label-green-strong", kind: "colour", outright: "--label-green-strong" },
|
|
14
|
+
{ name: "--vk-label-pink-fill", kind: "colour", outright: "--label-pink-fill" },
|
|
15
|
+
{ name: "--vk-label-pink-strong", kind: "colour", outright: "--label-pink-strong" },
|
|
16
|
+
{ name: "--vk-label-purple-fill", kind: "colour", outright: "--label-purple-fill" },
|
|
17
|
+
{ name: "--vk-label-purple-strong", kind: "colour", outright: "--label-purple-strong" },
|
|
18
|
+
{ name: "--vk-label-red-fill", kind: "colour", outright: "--label-red-fill" },
|
|
19
|
+
{ name: "--vk-label-red-strong", kind: "colour", outright: "--label-red-strong" },
|
|
20
|
+
{ name: "--vk-label-teal-fill", kind: "colour", outright: "--label-teal-fill" },
|
|
21
|
+
{ name: "--vk-label-teal-strong", kind: "colour", outright: "--label-teal-strong" },
|
|
8
22
|
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
9
23
|
{ name: "--vk-person-1", kind: "colour", outright: "--person-1" },
|
|
10
24
|
{ name: "--vk-person-2", kind: "colour", outright: "--person-2" },
|
|
@@ -20,6 +34,7 @@ export const AVATAR_TOKENS = [
|
|
|
20
34
|
{ name: "--vk-font-size-2xs", kind: "size", outright: "--text-2xs" },
|
|
21
35
|
{ name: "--vk-font-size-3xs", kind: "size", outright: "--text-3xs" },
|
|
22
36
|
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
37
|
+
{ name: "--vk-font-size-xl", kind: "size", outright: "--text-xl" },
|
|
23
38
|
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
24
39
|
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
25
40
|
{ name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* The Avatar. Every value it draws with is a
|
|
2
2
|
token (control tokens); this file only says which token each kind and size takes. People are circles on
|
|
3
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:
|
|
4
|
+
square holding its own icon; a square handed its own colour (data-colour, a label hue) stands on that hue instead. Its options, on the frame around it (looks.ts), are its squares' alone:
|
|
5
5
|
|
|
6
6
|
data-avatar-corners small · medium · large · xlarge a radius token per size; nothing set is Medium
|
|
7
7
|
data-avatar-smoothing round · smooth how a square's corners bend; nothing set is Smooth
|
|
@@ -27,48 +27,60 @@
|
|
|
27
27
|
.o-avatar-letters svg { width: 55%; height: 55%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
|
|
28
28
|
|
|
29
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 ── */
|
|
30
|
+
40 in headers, 56 at a settings page's head, 64 on a record's page ── */
|
|
31
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
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
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
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-56 { width: calc(var(--vk-spacing) * 14); height: calc(var(--vk-spacing) * 14); font-size: var(--vk-font-size-xl); }
|
|
35
36
|
.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
|
|
|
37
38
|
/* ── A thing: a square, its corners a step that grows with it, on the neutral ground, its edge inside ─ */
|
|
38
39
|
.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
40
|
/* The workspace: the one square in the brand. */
|
|
40
41
|
.o-avatar.o-avatar-workspace { background-color: var(--vk-brand); color: var(--vk-fg-on-brand); box-shadow: none; }
|
|
42
|
+
/* A square's own colour, the workspace's included: on the hue's fill, what it holds in the hue's strong ink, with no edge; grey
|
|
43
|
+
the neutral ground in the quieter ink. */
|
|
44
|
+
.o-avatar.o-avatar-thing[data-colour] { box-shadow: none; }
|
|
45
|
+
.o-avatar.o-avatar-thing[data-colour="blue"] { background-color: var(--vk-label-blue-fill); color: var(--vk-label-blue-strong); }
|
|
46
|
+
.o-avatar.o-avatar-thing[data-colour="green"] { background-color: var(--vk-label-green-fill); color: var(--vk-label-green-strong); }
|
|
47
|
+
.o-avatar.o-avatar-thing[data-colour="amber"] { background-color: var(--vk-label-amber-fill); color: var(--vk-label-amber-strong); }
|
|
48
|
+
.o-avatar.o-avatar-thing[data-colour="red"] { background-color: var(--vk-label-red-fill); color: var(--vk-label-red-strong); }
|
|
49
|
+
.o-avatar.o-avatar-thing[data-colour="purple"] { background-color: var(--vk-label-purple-fill); color: var(--vk-label-purple-strong); }
|
|
50
|
+
.o-avatar.o-avatar-thing[data-colour="pink"] { background-color: var(--vk-label-pink-fill); color: var(--vk-label-pink-strong); }
|
|
51
|
+
.o-avatar.o-avatar-thing[data-colour="teal"] { background-color: var(--vk-label-teal-fill); color: var(--vk-label-teal-strong); }
|
|
52
|
+
.o-avatar.o-avatar-thing[data-colour="grey"] { background-color: var(--vk-neutral); color: var(--vk-fg-subtle); }
|
|
41
53
|
/* 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
54
|
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
55
|
.o-avatar-agent .o-avatar-letters svg { fill: var(--vk-fg); stroke: none; }
|
|
44
56
|
|
|
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,
|
|
57
|
+
/* ── Corners: a radius token per size, in steps, 56 taking 64's; Medium with nothing set: xs at 20, sm at 24 and 32, md at 40, lg at 56 and 64,
|
|
46
58
|
between Small and Large, the tokens holding nothing between xs and sm ────────────────────────────── */
|
|
47
59
|
.o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-sm); }
|
|
48
60
|
.o-avatar.o-avatar-thing:is(.o-avatar-2xs, .o-avatar-xs) { --avatar-r: var(--vk-radius-xs); }
|
|
49
61
|
.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. */
|
|
62
|
+
.o-avatar.o-avatar-thing:is(.o-avatar-56, .o-avatar-xl) { --avatar-r: var(--vk-radius-lg); }
|
|
63
|
+
/* Small: xs at 20 and 24, sm at 32 and 40, md at 56 and 64. */
|
|
52
64
|
[data-avatar-corners="small"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-sm); }
|
|
53
65
|
[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. */
|
|
66
|
+
[data-avatar-corners="small"] .o-avatar.o-avatar-thing:is(.o-avatar-56, .o-avatar-xl) { --avatar-r: var(--vk-radius-md); }
|
|
67
|
+
/* Large, the radii before Medium came: sm at 20 and 24, md at 32, lg at 40, xl at 56 and 64. */
|
|
56
68
|
[data-avatar-corners="large"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-md); }
|
|
57
69
|
[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
70
|
[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. */
|
|
71
|
+
[data-avatar-corners="large"] .o-avatar.o-avatar-thing:is(.o-avatar-56, .o-avatar-xl) { --avatar-r: var(--vk-radius-xl); }
|
|
72
|
+
/* Extra large: md at 20 and 24, lg at 32, xl at 40, 2xl at 56 and 64. */
|
|
61
73
|
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing { --avatar-r: var(--vk-radius-lg); }
|
|
62
74
|
[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
75
|
[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); }
|
|
76
|
+
[data-avatar-corners="xlarge"] .o-avatar.o-avatar-thing:is(.o-avatar-56, .o-avatar-xl) { --avatar-r: var(--vk-radius-2xl); }
|
|
65
77
|
|
|
66
78
|
/* ── Corner smoothing: Smooth, with nothing set, draws a square's corners with the smooth outline (smooth.css),
|
|
67
79
|
every browser that knows shape() showing it; one that doesn't keeps the quarter circles above, and so does Round. Its
|
|
68
80
|
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
81
|
its radius, both tokens, so it follows Corner radius). The outline would cut the edge drawn inside the square, so under it the
|
|
70
82
|
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
|
|
83
|
+
holds; the workspace and a square on its own colour have none. Its smoothing is its own Corner smoothing, never a host's: the outline's amount inherits, and a
|
|
72
84
|
crumb, a tab or a list's card that follows the token sets it on itself, so the square sets it back. ─────── */
|
|
73
85
|
@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
86
|
.o-avatar.o-avatar-thing { --smooth-amount: initial; }
|
|
@@ -76,8 +88,9 @@
|
|
|
76
88
|
--avatar-rr: min(var(--avatar-r), var(--avatar-size) / 2); --smooth-t: var(--avatar-rr); --smooth-side: var(--avatar-size);
|
|
77
89
|
position: relative; box-shadow: none; clip-path: shape(var(--smooth-outline));
|
|
78
90
|
}
|
|
79
|
-
/* Its edge, a hairline ring along the outline, under the picture or the letters it holds; the workspace
|
|
80
|
-
|
|
91
|
+
/* Its edge, a hairline ring along the outline, under the picture or the letters it holds; the workspace and a square on its
|
|
92
|
+
own colour have none. */
|
|
93
|
+
.o-avatar.o-avatar-thing:not(.o-avatar-workspace):not([data-colour]):not([data-avatar-smoothing="round"] *)::before {
|
|
81
94
|
--smooth-t: calc(var(--avatar-rr) - var(--vk-border-width)); --smooth-in: var(--vk-border-width);
|
|
82
95
|
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-color: var(--vk-border-subtle);
|
|
83
96
|
clip-path: shape(var(--smooth-ring));
|
|
@@ -123,13 +136,14 @@
|
|
|
123
136
|
/* The rest, as a count in a neutral circle. */
|
|
124
137
|
.o-avatar.o-avatar-more { background-color: var(--vk-neutral); color: var(--vk-fg-subtle); font-variant-numeric: tabular-nums; }
|
|
125
138
|
/* ── 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
|
|
139
|
+
8, 10, 12, 14, 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
140
|
only on a badged avatar and a stack's faces: a mask clips what is outside the box and makes a stacking context. ──────── */
|
|
128
141
|
: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
142
|
.o-avatar.o-avatar-2xs { --avatar-size: calc(var(--vk-spacing) * 4); }
|
|
130
143
|
: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
144
|
: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
145
|
: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); }
|
|
146
|
+
:is(.o-avatar.o-avatar-56, .o-avatar-badged[data-size="56"]) { --avatar-size: calc(var(--vk-spacing) * 14); --avatar-dot: calc(var(--vk-spacing) * 3.5); --avatar-dot-inset: calc(var(--vk-spacing) * 0.5); }
|
|
133
147
|
: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
148
|
:is(.o-avatar.o-avatar-thing, .o-avatar-badged[data-thing]) { --avatar-dot-inset: calc(var(--vk-spacing) * -0.75); }
|
|
135
149
|
.o-avatar-badged { position: relative; display: inline-flex; flex: none; vertical-align: middle; isolation: isolate; }
|
|
@@ -141,7 +155,7 @@
|
|
|
141
155
|
background-color: var(--vk-brand); color: var(--vk-fg-on-brand);
|
|
142
156
|
}
|
|
143
157
|
.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; }
|
|
158
|
+
.o-avatar-badged:is([data-size="32"], [data-size="40"], [data-size="56"], [data-size="64"]) > .o-avatar-badge > svg { display: block; }
|
|
145
159
|
/* Here, a green dot; away, a hollow ring whose middle shows the ground. */
|
|
146
160
|
.o-avatar-badge[data-presence="here"] { background-color: var(--vk-success-bold); }
|
|
147
161
|
.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); }
|
|
@@ -45,7 +45,7 @@ export { COMPUTER_HOST, ComputerHost, PHONE_MARK, PhoneHost, PhoneLine, phoneMar
|
|
|
45
45
|
export { drawnAt, focusWhereItStands, focusesInPlace, holdsThePage, keepsToItsList, overflows, scaleOf, scrollInList, scrollTopFor, scrollTopForDrag, staysInView, tapsInPlace, typesInto, } from "./internal/scroll.js";
|
|
46
46
|
export { ContextMenu, Menu, MenuDots, useSheetMenus, type MenuChangeDetails, type MenuProps, type MenuWords, } from "./menu/menu.js";
|
|
47
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";
|
|
48
|
+
export { Avatar, AvatarStack, initials, toneOf, type AvatarColour, type AvatarPresence, type AvatarProps, type AvatarSize, type AvatarStackPerson, type AvatarStackProps, } from "./avatar/avatar.js";
|
|
49
49
|
export { PICKER_WORDS, Picker, PickerUnder, usePicker, type PickerAction, type PickerBoxSearch, type PickerDoing, type PickerLead, type PickerParts, type PickerProps, type PickerUnderProps, type PickerWords, } from "./picker/picker.js";
|
|
50
50
|
export { exactMatch, findItem, fold, itemLabel, openLevels, orderMoved, pickerRows, searchShown, type PickerAs, type PickerItem, type PickerRow, type RowsInput, } from "./picker/rows.js";
|
|
51
51
|
export { pickerRead, pickerWornOf, type PickerWorn } from "./picker/looks.js";
|
|
@@ -130,4 +130,5 @@ export { LinksEditor, useLinksEditor, type LinksEditorAction, type LinksEditorLe
|
|
|
130
130
|
export { found, heldOf, leadAfter, offered, removed, said, saidShort, setValue, ticked, type LinkChoice, type LinkField, type LinkFieldKind, type LinkValue, } from "./links-editor/links.js";
|
|
131
131
|
export { LINKS_EDITOR_WORDS, linksWords, type LinksEditorWords } from "./links-editor/words.js";
|
|
132
132
|
export { TagField, type TagFieldProps } from "./tag-field/tag-field.js";
|
|
133
|
-
export { SwitchRow, SwitchRows, type SwitchRowProps } from "./
|
|
133
|
+
export { SettingRow, SettingRows, SwitchRow, SwitchRows, type SettingAction, type SettingRowProps, type SettingRowsProps, type SwitchRowProps } from "./setting-row/setting-row.js";
|
|
134
|
+
export { SETTING_ROW_ATTRS, settingRowWornOf } from "./setting-row/looks.js";
|
|
@@ -122,4 +122,5 @@ export { LinksEditor, useLinksEditor, } from "./links-editor/links-editor.js";
|
|
|
122
122
|
export { found, heldOf, leadAfter, offered, removed, said, saidShort, setValue, ticked, } from "./links-editor/links.js";
|
|
123
123
|
export { LINKS_EDITOR_WORDS, linksWords } from "./links-editor/words.js";
|
|
124
124
|
export { TagField } from "./tag-field/tag-field.js";
|
|
125
|
-
export { SwitchRow, SwitchRows } from "./
|
|
125
|
+
export { SettingRow, SettingRows, SwitchRow, SwitchRows } from "./setting-row/setting-row.js";
|
|
126
|
+
export { SETTING_ROW_ATTRS, settingRowWornOf } from "./setting-row/looks.js";
|
|
@@ -54,6 +54,12 @@ export interface InputProps extends Omit<BaseInput.Props, "className" | "size">
|
|
|
54
54
|
/** Bare, whether it fills its line (the rest of a flex line, its full height): on unless said. Off, it stands at the width
|
|
55
55
|
* and height its place gives it, as the editors size their boxes. In its field, nothing. */
|
|
56
56
|
fills?: boolean;
|
|
57
|
+
/** In its field, the app saving what was typed (VK-921): the Spinner at the box's end, the field busy and still typed
|
|
58
|
+
* into. It wins over saved. Inside an InputGroup, the group's. */
|
|
59
|
+
saving?: boolean;
|
|
60
|
+
/** In its field, the save took: a check and Saved at the box's end, announced, fading after --vk-saved-hold and then
|
|
61
|
+
* gone; it shows again each time it turns on. A save that fails is the Field's error instead. */
|
|
62
|
+
saved?: boolean;
|
|
57
63
|
/** The Input's list: see InputComboboxProps. */
|
|
58
64
|
combobox?: false;
|
|
59
65
|
/** In its field, the box's classes, not the control's: a lone Input is a box round its control, so a utility class lands
|
|
@@ -86,13 +92,18 @@ export interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
86
92
|
className?: string;
|
|
87
93
|
/** Its Input and its InputGroupAddons, as its own children. */
|
|
88
94
|
children: React.ReactNode;
|
|
95
|
+
/** The app saving what was typed (VK-921): the Spinner at the group's end, after its end side, the group busy. It wins
|
|
96
|
+
* over saved. */
|
|
97
|
+
saving?: boolean;
|
|
98
|
+
/** The save took: a check and Saved at the group's end, fading after --vk-saved-hold and then gone. */
|
|
99
|
+
saved?: boolean;
|
|
89
100
|
}
|
|
90
101
|
/** A field with something inside it beside the words: an icon, words before or after them, a button
|
|
91
102
|
* (clear, show the password, copy); or rows above and below long text. It draws the field around its
|
|
92
103
|
* Input and addons, in every state and every look, and a press anywhere in it but a button puts the
|
|
93
104
|
* cursor in its Input. A value typed in parts holds InputGroupSegments instead of an Input: the group shows its focus while
|
|
94
105
|
* any has it, and a press off them puts the focus in the first. */
|
|
95
|
-
export declare function InputGroup({ size, look: lookGiven, chrome, className, children, onMouseDown, ...props }: InputGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
106
|
+
export declare function InputGroup({ size, look: lookGiven, chrome, saving, saved, className, children, onMouseDown, ...props }: InputGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
96
107
|
export interface InputGroupAddonProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
97
108
|
/** Where it sits: before the words or after them (start, end), or a row above or below long text (top,
|
|
98
109
|
* bottom). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Input as BaseInput } from "@base-ui/react/input";
|
|
4
4
|
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
@@ -8,6 +8,7 @@ import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
|
8
8
|
import { useAutofill } from "./autofill.js";
|
|
9
9
|
import { inputOwnAttrs, kindLook } from "./looks.js";
|
|
10
10
|
import { keepTypedRun } from "../internal/typed-run.js";
|
|
11
|
+
import { SaveMark } from "./save-mark.js";
|
|
11
12
|
const sized = (size) => size !== "md" && `o-input-${size}`;
|
|
12
13
|
const InGroup = React.createContext(null);
|
|
13
14
|
export const InputGroupContext = InGroup;
|
|
@@ -76,7 +77,7 @@ function useKeptCursor(el, type) {
|
|
|
76
77
|
return () => cancelAnimationFrame(f);
|
|
77
78
|
}, [el, type]);
|
|
78
79
|
}
|
|
79
|
-
export const Input = React.forwardRef(function Input({ size = "md", numeric = false, multiline = false, grow = false, maxLines, minLines, lines: linesGiven, autofill = true, look: lookGiven, chrome = "field", fills = true, combobox = false, className, style, ...props }, ref) {
|
|
80
|
+
export const Input = React.forwardRef(function Input({ size = "md", numeric = false, multiline = false, grow = false, maxLines, minLines, lines: linesGiven, autofill = true, look: lookGiven, chrome = "field", fills = true, combobox = false, saving = false, saved = false, className, style, ...props }, ref) {
|
|
80
81
|
const fill = useAutofill(), look = kindLook(chrome, lookGiven), phone = usePhoneForm();
|
|
81
82
|
const group = React.useContext(InGroup), grouped = group != null;
|
|
82
83
|
const lines = linesGiven ?? look?.lines ?? group?.lines;
|
|
@@ -101,13 +102,13 @@ export const Input = React.forwardRef(function Input({ size = "md", numeric = fa
|
|
|
101
102
|
if (field) {
|
|
102
103
|
const { "data-force": force, ...rest } = props;
|
|
103
104
|
props = rest;
|
|
104
|
-
return (
|
|
105
|
+
return (_jsxs("span", { className: cx("o-input o-input-lone o-smooth o-smooth-ease", sized(size), long && "o-input-long", grows && "o-input-grow", className), style: start || style ? { ...start, ...style } : undefined, "data-kit": "input", ...phoneMark(phone), ...(force != null ? { "data-force": force } : {}), ...(look ? inputOwnAttrs(look) : {}), onMouseDown: (e) => {
|
|
105
106
|
const box = own.current;
|
|
106
107
|
if (e.target !== e.currentTarget || !box || box.disabled)
|
|
107
108
|
return;
|
|
108
109
|
e.preventDefault();
|
|
109
110
|
box.focus();
|
|
110
|
-
}, children: control({ className: cx("o-input-control", set && "o-input-lines", numeric && "o-input-num"), ...(most ? { style: most } : {}) }) }));
|
|
111
|
+
}, children: [control({ className: cx("o-input-control", set && "o-input-lines", numeric && "o-input-num"), ...(most ? { style: most } : {}), ...(saving ? { "aria-busy": true } : {}) }), _jsx(SaveMark, { saving: saving, saved: saved })] }));
|
|
111
112
|
}
|
|
112
113
|
return control({
|
|
113
114
|
className: cx("o-input-control", set && "o-input-lines", numeric && "o-input-num", className),
|
|
@@ -117,11 +118,11 @@ export const Input = React.forwardRef(function Input({ size = "md", numeric = fa
|
|
|
117
118
|
...(bare && !fills ? { "data-fills": "off" } : {}),
|
|
118
119
|
});
|
|
119
120
|
});
|
|
120
|
-
export function InputGroup({ size = "md", look: lookGiven, chrome, className, children, onMouseDown, ...props }) {
|
|
121
|
+
export function InputGroup({ size = "md", look: lookGiven, chrome, saving = false, saved = false, className, children, onMouseDown, ...props }) {
|
|
121
122
|
const look = kindLook(chrome, lookGiven), phone = usePhoneForm();
|
|
122
123
|
const tall = React.Children.toArray(children).some((c) => React.isValidElement(c)
|
|
123
124
|
&& ((c.type === Input && c.props.multiline) || (c.type === InputGroupAddon && (c.props.side === "top" || c.props.side === "bottom"))));
|
|
124
|
-
return (_jsx(InGroup.Provider, { value: { size, cell: false, lines: look?.lines }, children:
|
|
125
|
+
return (_jsx(InGroup.Provider, { value: { size, cell: false, lines: look?.lines }, children: _jsxs("div", { role: "group", className: cx("o-input o-input-group o-smooth o-smooth-ease", sized(size), tall && "o-input-long", className), ...phoneMark(phone), ...(look ? inputOwnAttrs(look) : {}), onMouseDown: (e) => { onMouseDown?.(e); pressGroup(e); }, ...(saving ? { "aria-busy": true } : {}), ...props, children: [children, _jsx(SaveMark, { saving: saving, saved: saved })] }) }));
|
|
125
126
|
}
|
|
126
127
|
export function InputGroupAddon({ side = "start", flush = false, className, children, ...props }) {
|
|
127
128
|
return _jsx("div", { "data-side": side, ...(flush ? { "data-flush": "" } : {}), className: cx("o-input-addon", className), ...props, children: children });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SaveMarkProps {
|
|
3
|
+
/** The app is saving: the Spinner. It wins over saved. */
|
|
4
|
+
saving?: boolean;
|
|
5
|
+
/** The save took: a check and Saved, for a moment. */
|
|
6
|
+
saved?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function SaveMark({ saving, saved }: SaveMarkProps): React.ReactElement | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Icon } from "../internal/icons.js";
|
|
5
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
6
|
+
export function SaveMark({ saving = false, saved = false }) {
|
|
7
|
+
const [left, setLeft] = React.useState(false);
|
|
8
|
+
if (left && !saved)
|
|
9
|
+
setLeft(false);
|
|
10
|
+
const own = React.useRef(null);
|
|
11
|
+
const shows = !saving && saved && !left;
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
const el = own.current;
|
|
14
|
+
if (!shows || !el)
|
|
15
|
+
return;
|
|
16
|
+
const end = (e) => { if (e.target === el)
|
|
17
|
+
setLeft(true); };
|
|
18
|
+
el.addEventListener("animationend", end);
|
|
19
|
+
return () => el.removeEventListener("animationend", end);
|
|
20
|
+
}, [shows]);
|
|
21
|
+
if (saving)
|
|
22
|
+
return _jsx("span", { className: "o-input-save", "data-save": "saving", children: _jsx(Spinner, { size: 14, label: "Saving" }) });
|
|
23
|
+
if (!saved || left)
|
|
24
|
+
return null;
|
|
25
|
+
return (_jsxs("span", { ref: own, className: "o-input-save", "data-save": "saved", role: "status", children: [_jsx(Icon, { name: "check", size: 14 }), "Saved"] }));
|
|
26
|
+
}
|
|
@@ -38,10 +38,18 @@ export declare const INPUT_TOKENS: readonly [{
|
|
|
38
38
|
readonly name: "--vk-danger-subtlest";
|
|
39
39
|
readonly kind: "colour";
|
|
40
40
|
readonly outright: "--background-danger-subtlest";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-duration-base";
|
|
43
|
+
readonly kind: "motion";
|
|
44
|
+
readonly outright: "--duration-base";
|
|
41
45
|
}, {
|
|
42
46
|
readonly name: "--vk-duration-fast";
|
|
43
47
|
readonly kind: "motion";
|
|
44
48
|
readonly outright: "--duration-fast";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-ease-in";
|
|
51
|
+
readonly kind: "motion";
|
|
52
|
+
readonly outright: "--ease-in";
|
|
45
53
|
}, {
|
|
46
54
|
readonly name: "--vk-ease-out";
|
|
47
55
|
readonly kind: "motion";
|
|
@@ -138,6 +146,10 @@ export declare const INPUT_TOKENS: readonly [{
|
|
|
138
146
|
readonly name: "--vk-radius-xs";
|
|
139
147
|
readonly kind: "size";
|
|
140
148
|
readonly outright: "--radius-xs";
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "--vk-saved-hold";
|
|
151
|
+
readonly kind: "motion";
|
|
152
|
+
readonly outright: "--saved-hold";
|
|
141
153
|
}, {
|
|
142
154
|
readonly name: "--vk-shadow-field";
|
|
143
155
|
readonly kind: "shadow";
|
|
@@ -162,6 +174,10 @@ export declare const INPUT_TOKENS: readonly [{
|
|
|
162
174
|
readonly name: "--vk-spacing";
|
|
163
175
|
readonly kind: "size";
|
|
164
176
|
readonly outright: "--spacing";
|
|
177
|
+
}, {
|
|
178
|
+
readonly name: "--vk-success";
|
|
179
|
+
readonly kind: "colour";
|
|
180
|
+
readonly outright: "--text-success";
|
|
165
181
|
}, {
|
|
166
182
|
readonly name: "--vk-sunken";
|
|
167
183
|
readonly kind: "colour";
|
|
@@ -9,7 +9,9 @@ export const INPUT_TOKENS = [
|
|
|
9
9
|
{ name: "--vk-brand-subtler", kind: "colour", outright: "--background-brand-subtler" },
|
|
10
10
|
{ name: "--vk-corner-smoothing", kind: "size", outright: "--corner-smoothing" },
|
|
11
11
|
{ name: "--vk-danger-subtlest", kind: "colour", outright: "--background-danger-subtlest" },
|
|
12
|
+
{ name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
|
|
12
13
|
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
14
|
+
{ name: "--vk-ease-in", kind: "motion", outright: "--ease-in" },
|
|
13
15
|
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
14
16
|
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
15
17
|
{ name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
|
|
@@ -34,12 +36,14 @@ export const INPUT_TOKENS = [
|
|
|
34
36
|
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
35
37
|
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
36
38
|
{ name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
|
|
39
|
+
{ name: "--vk-saved-hold", kind: "motion", outright: "--saved-hold" },
|
|
37
40
|
{ name: "--vk-shadow-field", kind: "shadow", outright: "--shadow-field" },
|
|
38
41
|
{ name: "--vk-shadow-field-focus", kind: "shadow", outright: "--shadow-field-focus" },
|
|
39
42
|
{ name: "--vk-shadow-field-focus-danger", kind: "shadow", outright: "--shadow-field-focus-danger" },
|
|
40
43
|
{ name: "--vk-shadow-field-hover", kind: "shadow", outright: "--shadow-field-hover" },
|
|
41
44
|
{ name: "--vk-shadow-key-pressed", kind: "shadow", outright: "--shadow-key-pressed" },
|
|
42
45
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
46
|
+
{ name: "--vk-success", kind: "colour", outright: "--text-success" },
|
|
43
47
|
{ name: "--vk-sunken", kind: "colour", outright: "--surface-sunken" },
|
|
44
48
|
];
|
|
45
49
|
export const INPUT_PRIVATE = ["--input-"];
|
|
@@ -349,4 +349,22 @@ textarea.o-input-control.o-input-lines { flex: none; min-height: 0; max-height:
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
@media (prefers-reduced-motion: reduce) { .o-input { transition: none; } .o-input.o-smooth::before, .o-input.o-smooth::after { transition: none; } }
|
|
352
|
+
|
|
353
|
+
/* ── Saving and Saved (VK-921; the settings canvas, round 2, Every part: Saving): at the field's end, where its sides stand,
|
|
354
|
+
while the app saves what was typed or picked and just after. Saving, the Spinner in the quietest words; saved, a check and
|
|
355
|
+
Saved, small, in the success colour, announced, fading after --vk-saved-hold, after which save-mark.tsx takes it out of
|
|
356
|
+
the field. In its field it keeps the box's padding at its end; in a group it stands after the end side; in a Select's
|
|
357
|
+
field, just before the chevron. A page holds Saved with data-force="saved". ─────────────────────────────────────── */
|
|
358
|
+
.o-input-save {
|
|
359
|
+
flex: none; display: inline-flex; align-items: center; gap: calc(var(--vk-spacing) * 1.5);
|
|
360
|
+
font-size: var(--vk-font-size-xs); line-height: var(--vk-line-height-xs); color: var(--vk-fg-subtlest); white-space: nowrap; user-select: none;
|
|
361
|
+
}
|
|
362
|
+
.o-input-lone > .o-input-save { padding-inline-end: var(--input-pad-inline); }
|
|
363
|
+
.o-input-group:not(.o-select-field) > .o-input-save { order: 1; }
|
|
364
|
+
.o-input-save > svg { flex: none; width: calc(var(--vk-spacing) * 3.5); height: calc(var(--vk-spacing) * 3.5); }
|
|
365
|
+
.o-input-save[data-save="saved"] { color: var(--vk-success); animation: o-input-saved-leave var(--vk-duration-base) var(--vk-ease-in) var(--vk-saved-hold) forwards; }
|
|
366
|
+
[data-force="saved"] .o-input-save { animation: none; }
|
|
367
|
+
@keyframes o-input-saved-leave { to { opacity: 0; } }
|
|
368
|
+
@media (prefers-reduced-motion: reduce) { .o-input-save[data-save="saved"] { animation-duration: 1ms; } }
|
|
369
|
+
|
|
352
370
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Radio as BaseRadio } from "@base-ui/react/radio";
|
|
3
3
|
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
|
|
4
|
+
import type { OptionColour } from "../option/looks.js";
|
|
4
5
|
export interface RadioGroupProps extends Omit<React.ComponentProps<typeof BaseRadioGroup>, "className"> {
|
|
5
6
|
/** The group's name, above its choices ("Who can see this deal"). Without one, give it an aria-label. */
|
|
6
7
|
label?: React.ReactNode;
|
|
@@ -27,6 +28,12 @@ export interface RadioProps extends Omit<React.ComponentProps<typeof BaseRadio.R
|
|
|
27
28
|
/** A mark in place of the ring (a layout's icon): a card, the mark over its name and its line, the chosen one ringed in
|
|
28
29
|
* the brand. Disabled, it stands dashed and greyed, with no line, and the arrows pass it by. */
|
|
29
30
|
mark?: React.ReactNode;
|
|
31
|
+
/** A colour in place of the ring: a round dot in one of the label colours, the chosen one ringed. Give it an aria-label,
|
|
32
|
+
* the colour's name (a workspace's colour). It wins over `mark` and `card`. */
|
|
33
|
+
swatch?: OptionColour;
|
|
34
|
+
/** A marked card's picture: what the app draws (Light, Dark or System as a little app), filling the card's width over
|
|
35
|
+
* its mark and its name, which stand side by side under it. A picture makes the card marked, with a mark or without. */
|
|
36
|
+
picture?: React.ReactNode;
|
|
30
37
|
className?: string;
|
|
31
38
|
}
|
|
32
39
|
/** One choice of a RadioGroup: a ring that fills with the brand and a dot when it is the one chosen. */
|