viewkitjs 0.26.0 → 0.27.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 +24 -0
- package/MIGRATION.md +84 -6
- package/package.json +1 -1
- package/views/dist/contract.d.ts +171 -1
- package/views/dist/contract.js +162 -0
- package/views/dist/controls/compound-editor/map-parts-body.js +2 -1
- package/views/dist/controls/compound-editor/name-parts.js +10 -2
- package/views/dist/controls/compound-editor/place.d.ts +2 -1
- package/views/dist/controls/compound-editor/place.js +2 -0
- package/views/dist/controls/controls.d.ts +8 -0
- package/views/dist/controls/controls.js +8 -0
- package/views/dist/controls/index.d.ts +16 -0
- package/views/dist/controls/index.js +16 -0
- package/views/dist/controls/internal/editor-parts.d.ts +40 -0
- package/views/dist/controls/internal/editor-parts.js +43 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +78 -0
- package/views/dist/controls/links-editor/links-editor.js +308 -0
- package/views/dist/controls/links-editor/links.d.ts +62 -0
- package/views/dist/controls/links-editor/links.js +50 -0
- package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
- package/views/dist/controls/links-editor/map-links-body.js +71 -0
- package/views/dist/controls/links-editor/tokens.d.ts +71 -0
- package/views/dist/controls/links-editor/tokens.js +20 -0
- package/views/dist/controls/links-editor/words.d.ts +56 -0
- package/views/dist/controls/links-editor/words.js +33 -0
- package/views/dist/controls/links-editor.css +132 -0
- package/views/dist/controls/number-editor/format.d.ts +31 -0
- package/views/dist/controls/number-editor/format.js +79 -0
- package/views/dist/controls/number-editor/looks.d.ts +14 -0
- package/views/dist/controls/number-editor/looks.js +17 -0
- package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
- package/views/dist/controls/number-editor/map-number-body.js +57 -0
- package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
- package/views/dist/controls/number-editor/number-editor.js +202 -0
- package/views/dist/controls/number-editor/tokens.d.ts +28 -0
- package/views/dist/controls/number-editor/tokens.js +9 -0
- package/views/dist/controls/number-editor/words.d.ts +23 -0
- package/views/dist/controls/number-editor/words.js +13 -0
- package/views/dist/controls/number-editor.css +37 -0
- package/views/dist/controls/number-field/number-field.js +57 -5
- package/views/dist/controls/radio/radio.d.ts +33 -0
- package/views/dist/controls/radio/radio.js +19 -0
- package/views/dist/controls/radio/tokens.d.ts +127 -0
- package/views/dist/controls/radio/tokens.js +34 -0
- package/views/dist/controls/radio.css +104 -0
- package/views/dist/controls/text-editor/phone-number.d.ts +4 -0
- package/views/dist/controls/text-editor/phone-number.js +20 -0
- package/views/dist/controls/text-editor/text-editor.js +2 -19
- package/views/dist/controls/tokens.js +10 -0
- package/views/dist/controls/values-editor/looks.d.ts +16 -0
- package/views/dist/controls/values-editor/looks.js +19 -0
- package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
- package/views/dist/controls/values-editor/map-values-body.js +71 -0
- package/views/dist/controls/values-editor/tokens.d.ts +132 -0
- package/views/dist/controls/values-editor/tokens.js +35 -0
- package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
- package/views/dist/controls/values-editor/values-editor.js +435 -0
- package/views/dist/controls/values-editor/values.d.ts +71 -0
- package/views/dist/controls/values-editor/values.js +59 -0
- package/views/dist/controls/values-editor/words.d.ts +50 -0
- package/views/dist/controls/values-editor/words.js +29 -0
- package/views/dist/controls/values-editor.css +207 -0
- package/views/dist/controls/views-list/looks.d.ts +13 -0
- package/views/dist/controls/views-list/looks.js +12 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
- package/views/dist/controls/views-list/map-views-list-body.js +65 -0
- package/views/dist/controls/views-list/rules.d.ts +72 -0
- package/views/dist/controls/views-list/rules.js +4 -0
- package/views/dist/controls/views-list/tokens.d.ts +11 -0
- package/views/dist/controls/views-list/tokens.js +5 -0
- package/views/dist/controls/views-list/views-list.d.ts +44 -0
- package/views/dist/controls/views-list/views-list.js +57 -0
- package/views/dist/controls/views-list/words.d.ts +22 -0
- package/views/dist/controls/views-list/words.js +3 -0
- package/views/dist/controls/views-list.css +8 -0
- package/views/dist/editors/NumberEditor.js +3 -1
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +3 -1
- package/views/dist/grid/chrome/GridDateEditor.js +2 -1
- package/views/dist/looks/index.d.ts +3 -0
- package/views/dist/looks/index.js +3 -0
- package/views/dist/looks/pieces.js +6 -0
- package/views/dist/provider/components.d.ts +4 -0
- package/views/dist/styles.css +432 -2
- package/views/dist/styles.unlayered.css +432 -2
- package/views/docs/contract.md +10 -8
- package/views/docs/controls/links-editor.md +25 -0
- package/views/docs/controls/number-editor.md +12 -0
- package/views/docs/controls/radio.md +39 -0
- package/views/docs/controls/values-editor.md +40 -0
- package/views/docs/controls/views-list.md +8 -0
- package/views/docs/reference/controls.md +117 -5
- package/views/docs/reference/looks.md +9 -2
- package/views/docs/reference/react.md +2 -2
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* The Radio, as its card draws it. Every value it draws with is a public name (radio/tokens.ts); this file only says which
|
|
2
|
+
token each part and state takes. Base UI marks the ring
|
|
3
|
+
data-checked and data-disabled; data-force draws a state for the sheet. The states come in the card's
|
|
4
|
+
order, a later one winning: the pointer, on, error, focus, disabled.
|
|
5
|
+
|
|
6
|
+
The rules sit in the components layer, so a utility class on a radio still wins. */
|
|
7
|
+
@layer components {
|
|
8
|
+
|
|
9
|
+
/* ── A group: its choices one under another, 14px apart, or two to four in a row; its name is the FieldSet's
|
|
10
|
+
legend (field.css) ─────────────────────────────────────────────────────────────────────────────────── */
|
|
11
|
+
.o-radio-group { display: grid; gap: calc(var(--vk-spacing) * 3.5); }
|
|
12
|
+
.o-radio-group.o-radio-row { display: flex; flex-wrap: wrap; gap: calc(var(--vk-spacing) * 2) calc(var(--vk-spacing) * 6); }
|
|
13
|
+
|
|
14
|
+
/* ── At rest: a 16px ring, see-through; the label 10px to its right presses it ─────────────────────── */
|
|
15
|
+
.o-radio { position: relative; display: inline-flex; align-items: flex-start; gap: calc(var(--vk-spacing) * 2.5); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
16
|
+
.o-radio-ring {
|
|
17
|
+
flex: none; box-sizing: border-box; display: grid; place-items: center;
|
|
18
|
+
width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); margin-top: calc(var(--vk-spacing) * 0.5);
|
|
19
|
+
border: var(--vk-border-width) solid var(--vk-border-input); border-radius: var(--vk-radius-full);
|
|
20
|
+
background-color: var(--vk-input); outline: none;
|
|
21
|
+
transition: background-color var(--vk-duration-fast) var(--vk-ease-out), border-color var(--vk-duration-fast) var(--vk-ease-out);
|
|
22
|
+
}
|
|
23
|
+
/* The dot grows in its middle when the ring is chosen. */
|
|
24
|
+
.o-radio-dot { width: calc(var(--vk-spacing) * 1.5); height: calc(var(--vk-spacing) * 1.5); border-radius: var(--vk-radius-full); background-color: var(--vk-fg-inverse); scale: 0; transition: scale var(--vk-duration-base) var(--vk-ease-out); }
|
|
25
|
+
|
|
26
|
+
/* ── Under the pointer, on the ring or its label: a louder edge; a chosen ring a deeper brand ─────── */
|
|
27
|
+
/* A hover only on a screen with a pointer (KIT-368: iOS keeps :hover on what was last tapped); a press and the forced state stay out. */
|
|
28
|
+
.o-radio-ring[data-force="hover"]:not([data-disabled]) { border-color: var(--vk-border-input-hovered); }
|
|
29
|
+
@media (hover: hover) { .o-radio:hover > .o-radio-ring:not([data-disabled]) { border-color: var(--vk-border-input-hovered); } }
|
|
30
|
+
|
|
31
|
+
/* ── On: the brand, with the dot ───────────────────────────────────────────────────────────────────── */
|
|
32
|
+
.o-radio-ring[data-checked] { border-color: var(--vk-brand); background-color: var(--vk-brand); }
|
|
33
|
+
.o-radio-ring[data-force="hover"][data-checked]:not([data-disabled]) { border-color: var(--vk-brand-hovered); background-color: var(--vk-brand-hovered); }
|
|
34
|
+
@media (hover: hover) { .o-radio:hover > .o-radio-ring[data-checked]:not([data-disabled]) { border-color: var(--vk-brand-hovered); background-color: var(--vk-brand-hovered); } }
|
|
35
|
+
.o-radio-ring[data-checked] .o-radio-dot { scale: 1; background-color: var(--vk-fg-on-brand); }
|
|
36
|
+
|
|
37
|
+
/* ── In error (aria-invalid, its Field's error, or a group in error around it): a red edge; chosen, the
|
|
38
|
+
danger colour fills it. The pointer never takes it away; focus rings it in red; disabled wins. ─── */
|
|
39
|
+
.o-radio-ring:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]),
|
|
40
|
+
.o-radio-ring[data-force="hover"]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { border-color: var(--vk-border-danger); }
|
|
41
|
+
@media (hover: hover) { .o-radio:hover > .o-radio-ring:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { border-color: var(--vk-border-danger); } }
|
|
42
|
+
.o-radio-ring[data-checked]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { border-color: var(--vk-danger-bold); background-color: var(--vk-danger-bold); }
|
|
43
|
+
.o-radio-ring[data-checked]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) .o-radio-dot { background-color: var(--vk-fg-inverse); }
|
|
44
|
+
.o-radio-ring[data-force="hover"][data-checked]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { border-color: var(--vk-danger-bold-hovered); background-color: var(--vk-danger-bold-hovered); }
|
|
45
|
+
@media (hover: hover) { .o-radio:hover > .o-radio-ring[data-checked]:is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *):not([data-disabled]) { border-color: var(--vk-danger-bold-hovered); background-color: var(--vk-danger-bold-hovered); } }
|
|
46
|
+
.o-radio-ring:is(:focus-visible, [data-force="focus"]):is([aria-invalid="true"], [data-invalid], .o-fieldset[data-invalid] *) { outline-color: var(--vk-border-danger); }
|
|
47
|
+
|
|
48
|
+
/* ── Focus: the outline 2px outside the ring ───────────────────────────────────────────────────────── */
|
|
49
|
+
.o-radio-ring:is(:focus-visible, [data-force="focus"]) { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
|
|
50
|
+
|
|
51
|
+
/* ── Disabled: a grey ring, a softer edge, the dot and the label greyed ─────────────────────────────── */
|
|
52
|
+
.o-radio-ring[data-disabled] { border-color: var(--vk-border-subtle); background-color: var(--vk-neutral); }
|
|
53
|
+
.o-radio-ring[data-disabled] .o-radio-dot { background-color: var(--vk-fg-disabled); }
|
|
54
|
+
.o-radio:has(> .o-radio-ring[data-disabled]) { cursor: not-allowed; }
|
|
55
|
+
.o-radio:has(> .o-radio-ring[data-disabled]) .o-choice-label { color: var(--vk-fg-disabled); }
|
|
56
|
+
|
|
57
|
+
/* ── A marked card (KIT-668; the map, UI Kit · doc · list toolbar, parts 51 and 79; the canvas, rounds 5, 6 and 12): a mark
|
|
58
|
+
in place of the ring, the radio itself still, its name under it and an optional line under that. Its edge the field's;
|
|
59
|
+
chosen, ringed in the brand, its edge and a hairline just outside it as the map draws it (KIT-816), the mark in the brand, no
|
|
60
|
+
selected ground; one that can't be picked yet
|
|
61
|
+
dashed, all of it greyed, with no word under its name (KIT-777), which the arrows pass by. Focus rings the whole card. Each rule
|
|
62
|
+
carries a class more than choice.css's card, which it draws over. ─────────────────────────────────────────────────── */
|
|
63
|
+
.o-choice-card.o-radio-marked { flex-direction: column; align-items: flex-start; gap: var(--vk-spacing); padding: calc(var(--vk-spacing) * 3); border-color: var(--vk-border-input); }
|
|
64
|
+
.o-radio-mark { flex: none; display: grid; place-items: center; color: var(--vk-fg-subtle); outline: none; transition: color var(--vk-duration-fast) var(--vk-ease-out); }
|
|
65
|
+
.o-radio-mark > svg { width: calc(var(--vk-spacing) * 5); height: calc(var(--vk-spacing) * 5); }
|
|
66
|
+
.o-choice-card.o-radio-marked:has(> [data-checked]) { border-color: var(--vk-border-selected); box-shadow: 0 0 0 var(--vk-border-width) var(--vk-border-selected); background-color: var(--vk-ground); }
|
|
67
|
+
.o-radio-mark[data-checked] { color: var(--vk-fg-accent); }
|
|
68
|
+
.o-choice-card.o-radio-marked:has(> [data-force="hover"]:not([data-checked], [data-disabled])) { background-color: var(--vk-hovered); }
|
|
69
|
+
.o-choice-card.o-radio-marked:has(> .o-radio-mark:is(:focus-visible, [data-force="focus"])) { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
|
|
70
|
+
/* Marked cards in a row: two across, as New view's layouts; one under another on a phone. Marked cards, as a row or as tiles, keep
|
|
71
|
+
room on every side for what stands outside a card's edge, the chosen one's ring and the focus outline, so a holder that clips
|
|
72
|
+
its sides (the Pane's body) never cuts either (KIT-816); the map's tiles stand as far in. */
|
|
73
|
+
.o-radio-group.o-radio-row:has(> .o-radio-marked.o-choice-card) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
74
|
+
.o-radio-group:where(.o-radio-row, .o-radio-tiles):has(> .o-radio-marked.o-choice-card) { padding: calc(var(--vk-focus-width) + var(--vk-focus-offset)); }
|
|
75
|
+
|
|
76
|
+
/* ── Tiles: marked cards three across, each centred, its mark over its name in the card's quieter words; chosen, the mark
|
|
77
|
+
and the name in the brand. On a computer the marks of a row stand on one line, a tile with a line growing under its
|
|
78
|
+
name; on a phone they stand on one card, each at least 72 tall, what it holds in its middle. ──────────────────────── */
|
|
79
|
+
.o-radio-group.o-radio-tiles:has(> .o-choice-card) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(var(--vk-spacing) * 1.5); }
|
|
80
|
+
.o-radio-tiles > .o-choice-card.o-radio-marked {
|
|
81
|
+
justify-content: flex-start; align-items: center; gap: calc(var(--vk-spacing) * 1.5); padding: calc(var(--vk-spacing) * 2.5) var(--vk-spacing);
|
|
82
|
+
border-radius: var(--vk-radius-lg); background-color: transparent; color: var(--vk-fg-subtle); text-align: center;
|
|
83
|
+
}
|
|
84
|
+
.o-radio-tiles > .o-radio-marked > .o-choice-text { max-width: 100%; }
|
|
85
|
+
.o-radio-tiles > .o-radio-marked .o-choice-label { font-weight: var(--vk-font-weight-normal); color: inherit; }
|
|
86
|
+
.o-radio-tiles > .o-radio-marked > .o-radio-mark { color: inherit; }
|
|
87
|
+
.o-radio-tiles > .o-radio-marked > .o-radio-mark > svg { width: calc(var(--vk-spacing) * 4.5); height: calc(var(--vk-spacing) * 4.5); }
|
|
88
|
+
.o-radio-tiles > .o-choice-card.o-radio-marked:has(> [data-checked]) { background-color: transparent; color: var(--vk-fg-accent); }
|
|
89
|
+
@media (hover: hover) { .o-radio-tiles > .o-choice-card.o-radio-marked:hover:not(:has(> :is([data-checked], [data-disabled]))) { background-color: var(--vk-hovered); } }
|
|
90
|
+
.o-radio-tiles > .o-choice-card.o-radio-marked:has(> [data-force="hover"]:not([data-checked], [data-disabled])) { background-color: var(--vk-hovered); }
|
|
91
|
+
|
|
92
|
+
/* ── A marked card that can't be picked yet: dashed, greyed, no ground; it wins over the tiles' colours. ──────────── */
|
|
93
|
+
.o-choice-card.o-radio-marked:has(> [data-disabled]) { border-style: dashed; border-color: var(--vk-border-input); box-shadow: none; background-color: transparent; cursor: not-allowed; }
|
|
94
|
+
.o-choice-card.o-radio-marked:has(> [data-disabled]) :is(.o-radio-mark, .o-choice-label, .o-choice-note) { color: var(--vk-fg-disabled); }
|
|
95
|
+
|
|
96
|
+
/* On a phone (`data-vk-phone`, the group's own mark from the device, or a phone frame round it): marked cards one under
|
|
97
|
+
another, tiles on one card. */
|
|
98
|
+
.o-radio-group.o-radio-row:where([data-vk-phone], [data-vk-phone] *):has(> .o-radio-marked.o-choice-card) { grid-template-columns: minmax(0, 1fr); }
|
|
99
|
+
.o-radio-group.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *):has(> .o-choice-card) { gap: calc(var(--vk-spacing) * 2); padding: calc(var(--vk-spacing) * 3); border-radius: var(--vk-radius-xl); background-color: var(--vk-overlay-card); }
|
|
100
|
+
.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *) > .o-choice-card.o-radio-marked { justify-content: center; min-height: calc(var(--vk-spacing) * 18); }
|
|
101
|
+
.o-radio-tiles:where([data-vk-phone], [data-vk-phone] *) > .o-radio-marked > .o-radio-mark > svg { width: calc(var(--vk-spacing) * 5.5); height: calc(var(--vk-spacing) * 5.5); }
|
|
102
|
+
|
|
103
|
+
@media (prefers-reduced-motion: reduce) { .o-radio-ring, .o-radio-dot, .o-radio-mark { transition: none; } }
|
|
104
|
+
}
|
|
@@ -13,6 +13,10 @@ export declare function exampleOf(country: string): string;
|
|
|
13
13
|
export declare const patternOf: (country: string) => string;
|
|
14
14
|
/** A country's name in a language, English unless said (Spain, España); its code when there is none. */
|
|
15
15
|
export declare function countryName(country: string, language?: string): string;
|
|
16
|
+
/** The country a number was last kept in, for the next box to start from (the Text editor's). */
|
|
17
|
+
export declare const keepLast: (country: string) => void;
|
|
18
|
+
/** The first of `held`, the last kept, the browser's region and the US that the library knows. */
|
|
19
|
+
export declare function firstCountry(held?: string): string;
|
|
16
20
|
/** What is kept from what is typed in a country: its international form, or why not. Nothing typed keeps nothing. A number
|
|
17
21
|
* typed with its own + code is read as that number, whatever the country (Attio ignores it; a pasted number carries it). */
|
|
18
22
|
export declare function phoneOf(country: string, typed: string): {
|
|
@@ -35,6 +35,26 @@ export function countryName(country, language = "en") {
|
|
|
35
35
|
return country;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
const LAST = "kit-text-body-country";
|
|
39
|
+
const lastKept = () => { try {
|
|
40
|
+
return localStorage.getItem(LAST) ?? undefined;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
} };
|
|
45
|
+
export const keepLast = (country) => { try {
|
|
46
|
+
localStorage.setItem(LAST, country);
|
|
47
|
+
}
|
|
48
|
+
catch { } };
|
|
49
|
+
const browserRegion = () => { try {
|
|
50
|
+
return new Intl.Locale(navigator.language).maximize().region;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
} };
|
|
55
|
+
export function firstCountry(held) {
|
|
56
|
+
return [held, lastKept(), browserRegion(), "US"].find((c) => !!c && !!dialOf(c)) ?? "US";
|
|
57
|
+
}
|
|
38
58
|
function dialTyped(typed) {
|
|
39
59
|
const digits = typed.replace(/\D/g, ""), codes = metadata.country_calling_codes;
|
|
40
60
|
for (const n of [3, 2, 1]) {
|
|
@@ -10,7 +10,7 @@ import { drawnAt } from "../internal/scroll.js";
|
|
|
10
10
|
import { spacingPx } from "../internal/read-token.js";
|
|
11
11
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
12
12
|
import { TEXT_KEYS, enterDoes, kept, midWord, ownChange, textRefusal } from "./check.js";
|
|
13
|
-
import { countryName, dialOf, patternOf, phoneHanded, phoneOf, phoneParts } from "./phone-number.js";
|
|
13
|
+
import { countryName, dialOf, firstCountry, keepLast, patternOf, phoneHanded, phoneOf, phoneParts } from "./phone-number.js";
|
|
14
14
|
import { TEXT_EDITOR_ATTRS, textEditorWornOf } from "./looks.js";
|
|
15
15
|
import { Countries } from "./countries.js";
|
|
16
16
|
import { textWords } from "./words.js";
|
|
@@ -28,24 +28,7 @@ const keepTypedRun = (el) => {
|
|
|
28
28
|
};
|
|
29
29
|
const ONE_LINE = new Set(["email", "link", "domain", "phone"]);
|
|
30
30
|
const ROWS = 8;
|
|
31
|
-
const
|
|
32
|
-
const lastKept = () => { try {
|
|
33
|
-
return localStorage.getItem(LAST) ?? undefined;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return undefined;
|
|
37
|
-
} };
|
|
38
|
-
const keepLast = (country) => { try {
|
|
39
|
-
localStorage.setItem(LAST, country);
|
|
40
|
-
}
|
|
41
|
-
catch { } };
|
|
42
|
-
const region = () => { try {
|
|
43
|
-
return new Intl.Locale(navigator.language).maximize().region;
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return undefined;
|
|
47
|
-
} };
|
|
48
|
-
const startOf = (value, country) => phoneParts(value, [country, lastKept(), region(), "US"].find((c) => !!c && !!dialOf(c)) ?? "US");
|
|
31
|
+
const startOf = (value, country) => phoneParts(value, firstCountry(country));
|
|
49
32
|
function useWorn(el) {
|
|
50
33
|
const [worn, setWorn] = React.useState(() => textEditorWornOf(null));
|
|
51
34
|
React.useLayoutEffect(() => {
|
|
@@ -24,10 +24,15 @@ import { SELECT_PRIVATE, SELECT_TOKENS } from "./select/tokens.js";
|
|
|
24
24
|
import { PICKER_PRIVATE, PICKER_TOKENS } from "./picker/tokens.js";
|
|
25
25
|
import { AVATAR_PRIVATE, AVATAR_TOKENS } from "./avatar/tokens.js";
|
|
26
26
|
import { POPUP_LINE_PRIVATE, POPUP_LINE_TOKENS } from "./popup-line/tokens.js";
|
|
27
|
+
import { RADIO_PRIVATE, RADIO_TOKENS } from "./radio/tokens.js";
|
|
28
|
+
import { VIEWS_LIST_PRIVATE, VIEWS_LIST_TOKENS } from "./views-list/tokens.js";
|
|
27
29
|
import { TEXT_EDITOR_PRIVATE, TEXT_EDITOR_TOKENS } from "./text-editor/tokens.js";
|
|
28
30
|
import { DATE_EDITOR_PRIVATE, DATE_EDITOR_TOKENS } from "./date-editor/tokens.js";
|
|
29
31
|
import { COMPOUND_EDITOR_PRIVATE, COMPOUND_EDITOR_TOKENS } from "./compound-editor/tokens.js";
|
|
30
32
|
import { FLAG_PRIVATE, FLAG_TOKENS } from "./flag/tokens.js";
|
|
33
|
+
import { NUMBER_EDITOR_PRIVATE, NUMBER_EDITOR_TOKENS } from "./number-editor/tokens.js";
|
|
34
|
+
import { VALUES_EDITOR_PRIVATE, VALUES_EDITOR_TOKENS } from "./values-editor/tokens.js";
|
|
35
|
+
import { LINKS_EDITOR_PRIVATE, LINKS_EDITOR_TOKENS } from "./links-editor/tokens.js";
|
|
31
36
|
const CONTROLS_OWN = {
|
|
32
37
|
button: { tokens: BUTTON_TOKENS, private: BUTTON_PRIVATE },
|
|
33
38
|
spinner: { tokens: SPINNER_TOKENS, private: SPINNER_PRIVATE },
|
|
@@ -55,10 +60,15 @@ const CONTROLS_OWN = {
|
|
|
55
60
|
select: { tokens: SELECT_TOKENS, private: SELECT_PRIVATE },
|
|
56
61
|
picker: { tokens: PICKER_TOKENS, private: PICKER_PRIVATE },
|
|
57
62
|
avatar: { tokens: AVATAR_TOKENS, private: AVATAR_PRIVATE },
|
|
63
|
+
radio: { tokens: RADIO_TOKENS, private: RADIO_PRIVATE },
|
|
64
|
+
"views-list": { tokens: VIEWS_LIST_TOKENS, private: VIEWS_LIST_PRIVATE },
|
|
58
65
|
"text-editor": { tokens: TEXT_EDITOR_TOKENS, private: TEXT_EDITOR_PRIVATE },
|
|
59
66
|
"date-editor": { tokens: DATE_EDITOR_TOKENS, private: DATE_EDITOR_PRIVATE },
|
|
60
67
|
"compound-editor": { tokens: COMPOUND_EDITOR_TOKENS, private: COMPOUND_EDITOR_PRIVATE },
|
|
61
68
|
flag: { tokens: FLAG_TOKENS, private: FLAG_PRIVATE },
|
|
69
|
+
"number-editor": { tokens: NUMBER_EDITOR_TOKENS, private: NUMBER_EDITOR_PRIVATE },
|
|
70
|
+
"values-editor": { tokens: VALUES_EDITOR_TOKENS, private: VALUES_EDITOR_PRIVATE },
|
|
71
|
+
"links-editor": { tokens: LINKS_EDITOR_TOKENS, private: LINKS_EDITOR_PRIVATE },
|
|
62
72
|
};
|
|
63
73
|
export const VK_CONTROL_TOKENS_BY_PIECE = Object.fromEntries(Object.entries(CONTROLS_OWN).map(([piece, own]) => [piece, own.tokens]));
|
|
64
74
|
export const VK_CONTROL_TOKENS = Object.entries(VK_CONTROL_TOKENS_BY_PIECE)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type ValuesEditorOptionId = "rows" | "main" | "line" | "lists" | "phone";
|
|
3
|
+
/** What the body reads from the frame round it. */
|
|
4
|
+
export interface ValuesEditorWorn {
|
|
5
|
+
rows: "copy" | "fill";
|
|
6
|
+
main: "none" | "pill";
|
|
7
|
+
line: "plus" | "icon";
|
|
8
|
+
lists: "under" | "inplace";
|
|
9
|
+
phone: "rows" | "cards";
|
|
10
|
+
}
|
|
11
|
+
/** The Values editor's options and looks. */
|
|
12
|
+
export declare const VALUES_EDITOR_LOOKS: PieceLooks<ValuesEditorOptionId>;
|
|
13
|
+
/** The options worn round `el`, each from the nearest frame that picks it; outside any frame, Attio's. */
|
|
14
|
+
export declare const valuesEditorWornOf: (el: Element | null) => ValuesEditorWorn;
|
|
15
|
+
/** The attributes the body watches, so a look changed while it is open reaches it. */
|
|
16
|
+
export declare const VALUES_EDITOR_ATTRS: string[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { lookWornOf } from "../../looks/looks.js";
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "rows", name: "The values", device: "desktop", def: "copy", values: [{ id: "copy", name: "Copy and trash" }, { id: "fill", name: "A fill and ×" }] },
|
|
4
|
+
{ id: "main", name: "The main one", device: "desktop", def: "none", values: [{ id: "none", name: "Unmarked" }, { id: "pill", name: "Main" }] },
|
|
5
|
+
{ id: "line", name: "The line to add one", def: "plus", values: [{ id: "plus", name: "A plus" }, { id: "icon", name: "Its icon" }] },
|
|
6
|
+
{ id: "lists", name: "A label's or a country's list", device: "desktop", def: "under", values: [{ id: "under", name: "Under it" }, { id: "inplace", name: "In the values' place" }] },
|
|
7
|
+
{ id: "phone", name: "On a phone", device: "phone", def: "rows", values: [{ id: "rows", name: "Rows in a card" }, { id: "cards", name: "A card each" }] },
|
|
8
|
+
];
|
|
9
|
+
export const VALUES_EDITOR_LOOKS = {
|
|
10
|
+
id: "values-editor",
|
|
11
|
+
name: "Values editor",
|
|
12
|
+
options,
|
|
13
|
+
looks: [
|
|
14
|
+
{ id: "attio", name: "Attio", picks: { rows: "copy", main: "none", line: "plus", lists: "under", phone: "rows" } },
|
|
15
|
+
{ id: "mihai", name: "Mihai's", picks: { rows: "fill", main: "pill", line: "icon", lists: "inplace", phone: "cards" } },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
export const valuesEditorWornOf = (el) => lookWornOf(VALUES_EDITOR_LOOKS, el, ["rows", "main", "line", "lists", "phone"]);
|
|
19
|
+
export const VALUES_EDITOR_ATTRS = VALUES_EDITOR_LOOKS.options.map((o) => `data-values-editor-${o.id}`);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
2
|
+
import type { ViewsValuesBodyProps } from "../../provider/components.js";
|
|
3
|
+
import { type ValuesEditorProps } from "./values-editor.js";
|
|
4
|
+
import type { ValuesEditorWords } from "./words.js";
|
|
5
|
+
/** The Values editor's words in the app's messages: the old value list editor's keys where it had one (Add, Label, Main, Remove,
|
|
6
|
+
* the open actions, the place editor's country and its search), the rest its own. */
|
|
7
|
+
export declare function valuesEditorWordsOf(say: ViewsMessageResolver): ValuesEditorWords;
|
|
8
|
+
/** ViewKit's values body's props as the Values editor's, held as a shell that keeps the draft. */
|
|
9
|
+
export declare function valuesBodyPropsOf(p: ViewsValuesBodyProps, words?: ValuesEditorWords, language?: string): ValuesEditorProps;
|
|
10
|
+
/** ViewKit's values body, drawn as the Values editor in the app's words; on a phone, a list's step told to its sheet. Outside a
|
|
11
|
+
* provider (a page drawing the body alone), ViewKit's English. */
|
|
12
|
+
export declare function MapValuesBody(props: ViewsValuesBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { resolveViewsMessage } from "../../contract.js";
|
|
5
|
+
import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
|
|
6
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
7
|
+
import { pickerWordsOf } from "../picker/map-picker.js";
|
|
8
|
+
import { useToldStep } from "../internal/told-step.js";
|
|
9
|
+
import { useValuesEditor } from "./values-editor.js";
|
|
10
|
+
export function valuesEditorWordsOf(say) {
|
|
11
|
+
return {
|
|
12
|
+
line: { email: say({ key: "views.editors.values-line-email" }), link: say({ key: "views.editors.values-line-link" }), domain: say({ key: "views.editors.values-line-domain" }) },
|
|
13
|
+
cardLine: { email: say({ key: "views.editors.values-card-line-email" }), link: say({ key: "views.editors.values-card-line-link" }), domain: say({ key: "views.editors.values-card-line-domain" }) },
|
|
14
|
+
add: { email: say({ key: "views.editors.values-add-email" }), phone: say({ key: "views.editors.values-add-phone" }), link: say({ key: "views.editors.values-add-link" }), domain: say({ key: "views.editors.values-add-domain" }) },
|
|
15
|
+
nth: {
|
|
16
|
+
email: (n) => say({ key: "views.editors.values-nth-email", values: { n } }),
|
|
17
|
+
phone: (n) => say({ key: "views.editors.values-nth-phone", values: { n } }),
|
|
18
|
+
link: (n) => say({ key: "views.editors.values-nth-link", values: { n } }),
|
|
19
|
+
domain: (n) => say({ key: "views.editors.values-nth-domain", values: { n } }),
|
|
20
|
+
},
|
|
21
|
+
addButton: say({ key: "views.editors.values-add" }),
|
|
22
|
+
change: (value) => say({ key: "views.editors.values-change", values: { value } }),
|
|
23
|
+
copy: (value) => say({ key: "views.editors.values-copy", values: { value } }),
|
|
24
|
+
move: (value) => say({ key: "views.editors.values-move", values: { value } }),
|
|
25
|
+
remove: (value) => say({ key: "views.editors.values-remove", values: { value } }),
|
|
26
|
+
open: {
|
|
27
|
+
email: (value) => say({ key: "views.editors.open-email", values: { value } }),
|
|
28
|
+
phone: (value) => say({ key: "views.editors.open-phone", values: { value } }),
|
|
29
|
+
link: (value) => say({ key: "views.editors.open-link", values: { value } }),
|
|
30
|
+
domain: (value) => say({ key: "views.editors.open-link", values: { value } }),
|
|
31
|
+
},
|
|
32
|
+
main: say({ key: "views.editors.values-main" }),
|
|
33
|
+
label: say({ key: "views.editors.values-label" }),
|
|
34
|
+
labelIs: (label) => say({ key: "views.editors.values-label-is", values: { label } }),
|
|
35
|
+
noLabel: say({ key: "views.editors.values-no-label" }),
|
|
36
|
+
labelSearch: say({ key: "views.editors.values-label-search" }),
|
|
37
|
+
labelFind: say({ key: "views.editors.values-label-find" }),
|
|
38
|
+
labels: {
|
|
39
|
+
work: say({ key: "views.editors.values-label-work" }),
|
|
40
|
+
personal: say({ key: "views.editors.values-label-personal" }),
|
|
41
|
+
mobile: say({ key: "views.editors.values-label-mobile" }),
|
|
42
|
+
other: say({ key: "views.editors.values-label-other" }),
|
|
43
|
+
},
|
|
44
|
+
country: say({ key: "views.editors.place-country" }),
|
|
45
|
+
searchCountry: say({ key: "views.editors.place-country-search" }),
|
|
46
|
+
findCountry: say({ key: "views.editors.place-find-country" }),
|
|
47
|
+
countryCode: say({ key: "views.editors.values-country-code" }),
|
|
48
|
+
countryIs: (country) => say({ key: "views.editors.values-country-is", values: { country } }),
|
|
49
|
+
countryCodeIs: (country) => say({ key: "views.editors.values-country-code-is", values: { country } }),
|
|
50
|
+
backTo: (label) => say({ key: "views.editors.values-back-to", values: { label } }),
|
|
51
|
+
close: say({ key: "views.editors.discard" }),
|
|
52
|
+
save: say({ key: "views.editors.save" }),
|
|
53
|
+
picker: pickerWordsOf(say),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function valuesBodyPropsOf(p, words, language) {
|
|
57
|
+
return {
|
|
58
|
+
label: p.label, kind: p.kind === "url" ? "link" : p.kind, value: p.value.map((l) => ({ ...l })),
|
|
59
|
+
onValueChange: (list) => p.onValueChange(list.map((v, i) => ({ value: v.value, ...(v.label ? { label: v.label } : {}), main: i === 0 }))),
|
|
60
|
+
onDone: p.onDone, check: p.check, holds: p.holds, autoFocus: p.autoFocus, form: p.form, draft: "shell", popupData: { [EDITOR_INNER_ESCAPE]: "" },
|
|
61
|
+
...(p.labels ? {} : { labels: [] }), ...(p.region ? { dial: p.region } : {}), ...(p.typed != null ? { typed: p.typed } : {}),
|
|
62
|
+
...(words ? { words } : {}), ...(language ? { language } : {}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function MapValuesBody(props) {
|
|
66
|
+
const views = React.useContext(ViewsContext), messages = views?.messages ?? resolveViewsMessage;
|
|
67
|
+
const words = React.useMemo(() => valuesEditorWordsOf(messages), [messages]);
|
|
68
|
+
const parts = useValuesEditor(valuesBodyPropsOf(props, words, views?.conventions.language));
|
|
69
|
+
useToldStep(parts, props.onStepChange);
|
|
70
|
+
return _jsx(_Fragment, { children: parts.body });
|
|
71
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export declare const VALUES_EDITOR_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-border-brand";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--border-focused";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-border-danger";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--border-danger";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-border-overlay-card";
|
|
15
|
+
readonly kind: "colour";
|
|
16
|
+
readonly outright: "--border-overlay-card";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-border-subtle";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--border-subtle";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-border-width";
|
|
23
|
+
readonly kind: "size";
|
|
24
|
+
readonly outright: "--border-width";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-brand-subtler";
|
|
27
|
+
readonly kind: "colour";
|
|
28
|
+
readonly outright: "--background-brand-subtler";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-danger";
|
|
31
|
+
readonly kind: "colour";
|
|
32
|
+
readonly outright: "--text-danger";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-fg";
|
|
35
|
+
readonly kind: "colour";
|
|
36
|
+
readonly outright: "--text";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-fg-brand";
|
|
39
|
+
readonly kind: "colour";
|
|
40
|
+
readonly outright: "--link";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-fg-inverse";
|
|
43
|
+
readonly kind: "colour";
|
|
44
|
+
readonly outright: "--text-inverse";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-fg-subtle";
|
|
47
|
+
readonly kind: "colour";
|
|
48
|
+
readonly outright: "--text-subtle";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-fg-subtlest";
|
|
51
|
+
readonly kind: "colour";
|
|
52
|
+
readonly outright: "--text-subtlest";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-focus-width";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--focus-width";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-font-size-base";
|
|
59
|
+
readonly kind: "size";
|
|
60
|
+
readonly outright: "--text-base";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-font-size-sm";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--text-sm";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-font-size-xs";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--text-xs";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-font-weight-medium";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--font-weight-medium";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-layer-popup";
|
|
75
|
+
readonly kind: "size";
|
|
76
|
+
readonly outright: "--layer-popup";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-line-height-base";
|
|
79
|
+
readonly kind: "size";
|
|
80
|
+
readonly outright: "--text-base--line-height";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "--vk-line-height-sm";
|
|
83
|
+
readonly kind: "size";
|
|
84
|
+
readonly outright: "--text-sm--line-height";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "--vk-line-height-xs";
|
|
87
|
+
readonly kind: "size";
|
|
88
|
+
readonly outright: "--text-xs--line-height";
|
|
89
|
+
}, {
|
|
90
|
+
readonly name: "--vk-neutral";
|
|
91
|
+
readonly kind: "colour";
|
|
92
|
+
readonly outright: "--background-neutral";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "--vk-overlay";
|
|
95
|
+
readonly kind: "colour";
|
|
96
|
+
readonly outright: "--surface-overlay";
|
|
97
|
+
}, {
|
|
98
|
+
readonly name: "--vk-overlay-hovered";
|
|
99
|
+
readonly kind: "colour";
|
|
100
|
+
readonly outright: "--surface-overlay-hovered";
|
|
101
|
+
}, {
|
|
102
|
+
readonly name: "--vk-radius-full";
|
|
103
|
+
readonly kind: "size";
|
|
104
|
+
readonly outright: "--radius-full";
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "--vk-radius-lg";
|
|
107
|
+
readonly kind: "size";
|
|
108
|
+
readonly outright: "--radius-lg";
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "--vk-radius-md";
|
|
111
|
+
readonly kind: "size";
|
|
112
|
+
readonly outright: "--radius-md";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "--vk-radius-sm";
|
|
115
|
+
readonly kind: "size";
|
|
116
|
+
readonly outright: "--radius-sm";
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "--vk-radius-xl";
|
|
119
|
+
readonly kind: "size";
|
|
120
|
+
readonly outright: "--radius-xl";
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "--vk-shadow-lg";
|
|
123
|
+
readonly kind: "shadow";
|
|
124
|
+
readonly outright: "--shadow-lg";
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "--vk-spacing";
|
|
127
|
+
readonly kind: "size";
|
|
128
|
+
readonly outright: "--spacing";
|
|
129
|
+
}];
|
|
130
|
+
/** The prefixes of the Values editor's own machinery, set and read by it alone: not public. Its line's inset, --values-line-in.
|
|
131
|
+
* It reads the Popover's corners, the popup line's reach and a list's dividers, those controls' own families. */
|
|
132
|
+
export declare const VALUES_EDITOR_PRIVATE: readonly ["--values-"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const VALUES_EDITOR_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
4
|
+
{ name: "--vk-border-danger", kind: "colour", outright: "--border-danger" },
|
|
5
|
+
{ name: "--vk-border-overlay-card", kind: "colour", outright: "--border-overlay-card" },
|
|
6
|
+
{ name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
|
|
7
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
8
|
+
{ name: "--vk-brand-subtler", kind: "colour", outright: "--background-brand-subtler" },
|
|
9
|
+
{ name: "--vk-danger", kind: "colour", outright: "--text-danger" },
|
|
10
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
11
|
+
{ name: "--vk-fg-brand", kind: "colour", outright: "--link" },
|
|
12
|
+
{ name: "--vk-fg-inverse", kind: "colour", outright: "--text-inverse" },
|
|
13
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
14
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
15
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
16
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
17
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
18
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
19
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
20
|
+
{ name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
|
|
21
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
22
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
23
|
+
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
24
|
+
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
25
|
+
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
26
|
+
{ name: "--vk-overlay-hovered", kind: "colour", outright: "--surface-overlay-hovered" },
|
|
27
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
28
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
29
|
+
{ name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
|
|
30
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
31
|
+
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
32
|
+
{ name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
|
|
33
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
34
|
+
];
|
|
35
|
+
export const VALUES_EDITOR_PRIVATE = ["--values-"];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SheetHeadProps } from "../sheet/bottom-sheet.js";
|
|
3
|
+
import { type ValuesEditorWorn } from "./looks.js";
|
|
4
|
+
import { type DialCode, type ListedValue, type ValuesKind } from "./values.js";
|
|
5
|
+
import { type ValuesEditorWords } from "./words.js";
|
|
6
|
+
import type { Draft } from "../internal/shell.js";
|
|
7
|
+
export type { DialCode, ListedValue, ValuesKind } from "./values.js";
|
|
8
|
+
export interface ValuesEditorProps {
|
|
9
|
+
/** The field's name (Phones): the Sheet's title, and the list's name to a screen reader. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** What it holds several of: emails, phones, links or domains, each read by the Text editor's rule for its kind. */
|
|
12
|
+
kind: ValuesKind;
|
|
13
|
+
/** What the field holds, the main one first. */
|
|
14
|
+
value: ListedValue[];
|
|
15
|
+
/** What it keeps, when it changed: the list, the main one first. */
|
|
16
|
+
onValueChange: (value: ListedValue[]) => void;
|
|
17
|
+
/** The job is done and what holds it closes: after a keep (Escape keeps on a computer), and after ✕, which leaves it as it was. */
|
|
18
|
+
onDone?: () => void;
|
|
19
|
+
/** The labels a value is picked from (one may be typed too); [] for none, as a company's domains. Left out, Work, Personal, Mobile and Other in its words. */
|
|
20
|
+
labels?: string[];
|
|
21
|
+
/** A phone's country, from the record's place (RO): its code stands first in the line. */
|
|
22
|
+
dial?: string;
|
|
23
|
+
/** The country codes a phone may be added with; more than one, a press on the code picks another. */
|
|
24
|
+
dialCodes?: DialCode[];
|
|
25
|
+
/** Why a value is refused; left out, the Text editor's rule for its kind. */
|
|
26
|
+
check?: (value: string) => string | null;
|
|
27
|
+
/** For a page that shows a state: a value being edited, what the line holds (refused at once when it isn't one), a value
|
|
28
|
+
* held by its grip over the first. */
|
|
29
|
+
editing?: number;
|
|
30
|
+
typed?: string;
|
|
31
|
+
moving?: number;
|
|
32
|
+
/** Takes the focus as it opens, on the line; a page standing several still says false. */
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
/** Which form; by default the device's (usePhoneForm). */
|
|
35
|
+
form?: "computer" | "phone";
|
|
36
|
+
/** One value (an email, a domain: no grip, no label, no line while it holds one) or several; left out, several. */
|
|
37
|
+
holds?: "one" | "several";
|
|
38
|
+
/** Where the draft, the close and a phone's ✕ and ✓ stand: `own` (the default), the editor's; `shell`, its holder's (ViewKit's
|
|
39
|
+
* values slot, KIT-744): it hands the whole list on every change, what is typed on the cell is already its one value (edited
|
|
40
|
+
* as it opens), Enter only says it is done, and a press elsewhere, Escape, Tab and a phone's ✕ and ✓ are the holder's. */
|
|
41
|
+
draft?: Draft;
|
|
42
|
+
/** Data on the label's and the country's list, drawn in a Popover of its own outside the body: the holder's mark for a popup
|
|
43
|
+
* that keeps its own Escape. */
|
|
44
|
+
popupData?: Readonly<Record<`data-${string}`, string>>;
|
|
45
|
+
/** Its words, over the English: ViewKit hands the app's (map-values-body.tsx). */
|
|
46
|
+
words?: Partial<ValuesEditorWords>;
|
|
47
|
+
/** The language a country is named in; English unless said. */
|
|
48
|
+
language?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ValuesEditorParts {
|
|
51
|
+
body: React.ReactNode;
|
|
52
|
+
/** On a phone, the Sheet head's buttons: ✕ and ✓; Back on a list's step. */
|
|
53
|
+
head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "close" | "children">;
|
|
54
|
+
/** On a phone, the Sheet's title while it is on a list's step (Label, Country code). */
|
|
55
|
+
title?: string;
|
|
56
|
+
}
|
|
57
|
+
/** The options worn around the body, read once it stands on the page and again as its looks change; Attio's first. */
|
|
58
|
+
export declare function useValuesEditorWorn(el: HTMLElement | null): ValuesEditorWorn;
|
|
59
|
+
/** The Values editor's state and the parts a shell pours in. */
|
|
60
|
+
export declare function useValuesEditor(props: ValuesEditorProps): ValuesEditorParts;
|
|
61
|
+
/** The body alone, for a shell that holds only a body (the Popover). */
|
|
62
|
+
export declare function ValuesEditor(props: ValuesEditorProps): import("react/jsx-runtime").JSX.Element;
|