viewkitjs 0.22.0 → 0.23.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 +27 -0
- package/package.json +2 -4
- package/views/dist/contract.d.ts +6 -289
- package/views/dist/contract.js +1 -96
- package/views/dist/controls/atoms.d.ts +8 -0
- package/views/dist/controls/atoms.js +8 -0
- package/views/dist/controls/button/tokens.d.ts +351 -0
- package/views/dist/controls/button/tokens.js +90 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +28 -0
- package/views/dist/controls/checkbox/checkbox.js +15 -0
- package/views/dist/controls/checkbox/looks.d.ts +3 -0
- package/views/dist/controls/checkbox/looks.js +8 -0
- package/views/dist/controls/checkbox/map-checkbox.d.ts +2 -0
- package/views/dist/controls/checkbox/map-checkbox.js +5 -0
- package/views/dist/controls/checkbox/tokens.d.ts +131 -0
- package/views/dist/controls/checkbox/tokens.js +35 -0
- package/views/dist/controls/checkbox.css +133 -0
- package/views/dist/controls/controls.d.ts +12 -3
- package/views/dist/controls/controls.js +13 -1
- package/views/dist/controls/field/field.d.ts +94 -0
- package/views/dist/controls/field/field.js +46 -0
- package/views/dist/controls/field/looks.d.ts +13 -0
- package/views/dist/controls/field/looks.js +22 -0
- package/views/dist/controls/field/tokens.d.ts +75 -0
- package/views/dist/controls/field/tokens.js +21 -0
- package/views/dist/controls/field.css +98 -0
- package/views/dist/controls/glass-button/glass-button.d.ts +40 -0
- package/views/dist/controls/glass-button/glass-button.js +16 -0
- package/views/dist/controls/glass-button/looks.d.ts +4 -0
- package/views/dist/controls/glass-button/looks.js +4 -0
- package/views/dist/controls/glass-button/tokens.d.ts +127 -0
- package/views/dist/controls/glass-button/tokens.js +34 -0
- package/views/dist/controls/glass-button.css +111 -0
- package/views/dist/controls/index.d.ts +26 -0
- package/views/dist/controls/index.js +25 -0
- package/views/dist/controls/inline-input/inline-input.d.ts +14 -0
- package/views/dist/controls/inline-input/inline-input.js +10 -0
- package/views/dist/controls/inline-input/looks.d.ts +3 -0
- package/views/dist/controls/inline-input/looks.js +16 -0
- package/views/dist/controls/inline-input/tokens.d.ts +79 -0
- package/views/dist/controls/inline-input/tokens.js +22 -0
- package/views/dist/controls/inline-input.css +78 -0
- package/views/dist/controls/input/autofill.d.ts +25 -0
- package/views/dist/controls/input/autofill.js +17 -0
- package/views/dist/controls/input/input.d.ts +119 -0
- package/views/dist/controls/input/input.js +127 -0
- package/views/dist/controls/input/looks.d.ts +41 -0
- package/views/dist/controls/input/looks.js +48 -0
- package/views/dist/controls/input/map-input.d.ts +2 -0
- package/views/dist/controls/input/map-input.js +5 -0
- package/views/dist/controls/input/tokens.d.ts +171 -0
- package/views/dist/controls/input/tokens.js +45 -0
- package/views/dist/controls/input.css +381 -0
- package/views/dist/controls/internal/anchor.d.ts +16 -0
- package/views/dist/controls/internal/anchor.js +8 -0
- package/views/dist/controls/internal/close-reason.d.ts +5 -0
- package/views/dist/controls/internal/close-reason.js +2 -0
- package/views/dist/controls/internal/popup-host.d.ts +7 -0
- package/views/dist/controls/internal/popup-host.js +10 -0
- package/views/dist/controls/internal/scroll.d.ts +11 -0
- package/views/dist/controls/internal/scroll.js +14 -0
- package/views/dist/controls/kbd/kbd.d.ts +13 -0
- package/views/dist/controls/kbd/kbd.js +10 -0
- package/views/dist/controls/kbd/looks.d.ts +4 -0
- package/views/dist/controls/kbd/looks.js +4 -0
- package/views/dist/controls/kbd/tokens.d.ts +47 -0
- package/views/dist/controls/kbd/tokens.js +14 -0
- package/views/dist/controls/kbd.css +46 -0
- package/views/dist/controls/number-field/number-field.d.ts +48 -0
- package/views/dist/controls/number-field/number-field.js +34 -0
- package/views/dist/controls/number-field/tokens.d.ts +47 -0
- package/views/dist/controls/number-field/tokens.js +14 -0
- package/views/dist/controls/number-field.css +54 -0
- package/views/dist/controls/option/atom-tag.d.ts +6 -0
- package/views/dist/controls/option/atom-tag.js +6 -0
- package/views/dist/controls/option/looks.d.ts +7 -0
- package/views/dist/controls/option/looks.js +21 -0
- package/views/dist/controls/option/option.d.ts +35 -0
- package/views/dist/controls/option/option.js +32 -0
- package/views/dist/controls/option/tokens.d.ts +223 -0
- package/views/dist/controls/option/tokens.js +58 -0
- package/views/dist/controls/option.css +92 -0
- package/views/dist/controls/phone-header/header-bar.d.ts +18 -0
- package/views/dist/controls/phone-header/header-bar.js +9 -0
- package/views/dist/controls/phone-header/looks.d.ts +4 -0
- package/views/dist/controls/phone-header/looks.js +4 -0
- package/views/dist/controls/phone-header/soft-edge.d.ts +5 -0
- package/views/dist/controls/phone-header/soft-edge.js +3 -0
- package/views/dist/controls/phone-header/tokens.d.ts +59 -0
- package/views/dist/controls/phone-header/tokens.js +17 -0
- package/views/dist/controls/phone-header.css +51 -0
- package/views/dist/controls/popover/looks.d.ts +4 -0
- package/views/dist/controls/popover/looks.js +10 -0
- package/views/dist/controls/popover/map-popover.d.ts +3 -0
- package/views/dist/controls/popover/map-popover.js +5 -0
- package/views/dist/controls/popover/popover.d.ts +74 -0
- package/views/dist/controls/popover/popover.js +106 -0
- package/views/dist/controls/popover/tokens.d.ts +83 -0
- package/views/dist/controls/popover/tokens.js +23 -0
- package/views/dist/controls/popover.css +94 -0
- package/views/dist/controls/scrollbar/scrollbar.d.ts +10 -0
- package/views/dist/controls/scrollbar/scrollbar.js +143 -0
- package/views/dist/controls/scrollbar/tokens.d.ts +43 -0
- package/views/dist/controls/scrollbar/tokens.js +13 -0
- package/views/dist/controls/scrollbar.css +47 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +98 -0
- package/views/dist/controls/sheet/bottom-sheet.js +372 -0
- package/views/dist/controls/sheet/forms.d.ts +38 -0
- package/views/dist/controls/sheet/forms.js +26 -0
- package/views/dist/controls/sheet/looks.d.ts +4 -0
- package/views/dist/controls/sheet/looks.js +10 -0
- package/views/dist/controls/sheet/map-sheet.d.ts +3 -0
- package/views/dist/controls/sheet/map-sheet.js +12 -0
- package/views/dist/controls/sheet/spring.d.ts +22 -0
- package/views/dist/controls/sheet/spring.js +48 -0
- package/views/dist/controls/sheet/tokens.d.ts +143 -0
- package/views/dist/controls/sheet/tokens.js +38 -0
- package/views/dist/controls/sheet.css +220 -0
- package/views/dist/controls/spinner/tokens.d.ts +55 -0
- package/views/dist/controls/spinner/tokens.js +16 -0
- package/views/dist/controls/status/atom-status-badge.d.ts +10 -0
- package/views/dist/controls/status/atom-status-badge.js +13 -0
- package/views/dist/controls/status/looks.d.ts +4 -0
- package/views/dist/controls/status/looks.js +22 -0
- package/views/dist/controls/status/marks.d.ts +26 -0
- package/views/dist/controls/status/marks.js +73 -0
- package/views/dist/controls/status/status.d.ts +43 -0
- package/views/dist/controls/status/status.js +26 -0
- package/views/dist/controls/status/tokens.d.ts +407 -0
- package/views/dist/controls/status/tokens.js +104 -0
- package/views/dist/controls/status.css +164 -0
- package/views/dist/controls/switch/looks.d.ts +4 -0
- package/views/dist/controls/switch/looks.js +19 -0
- package/views/dist/controls/switch/switch.d.ts +15 -0
- package/views/dist/controls/switch/switch.js +11 -0
- package/views/dist/controls/switch/tokens.d.ts +139 -0
- package/views/dist/controls/switch/tokens.js +37 -0
- package/views/dist/controls/switch.css +169 -0
- package/views/dist/controls/tag/atom-cell-more.d.ts +3 -0
- package/views/dist/controls/tag/atom-cell-more.js +5 -0
- package/views/dist/controls/tag/looks.d.ts +4 -0
- package/views/dist/controls/tag/looks.js +4 -0
- package/views/dist/controls/tag/tag.d.ts +25 -0
- package/views/dist/controls/tag/tag.js +19 -0
- package/views/dist/controls/tag/tokens.d.ts +63 -0
- package/views/dist/controls/tag/tokens.js +18 -0
- package/views/dist/controls/tag.css +81 -0
- package/views/dist/controls/toggle/looks.d.ts +3 -0
- package/views/dist/controls/toggle/looks.js +12 -0
- package/views/dist/controls/toggle/toggle.d.ts +47 -0
- package/views/dist/controls/toggle/toggle.js +23 -0
- package/views/dist/controls/toggle/tokens.d.ts +55 -0
- package/views/dist/controls/toggle/tokens.js +16 -0
- package/views/dist/controls/toggle.css +67 -0
- package/views/dist/controls/tokens.d.ts +16 -0
- package/views/dist/controls/tokens.js +45 -0
- package/views/dist/controls/tooltip/looks.d.ts +4 -0
- package/views/dist/controls/tooltip/looks.js +4 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +3 -0
- package/views/dist/controls/tooltip/map-tooltip.js +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +75 -0
- package/views/dist/controls/tooltip/tokens.js +21 -0
- package/views/dist/controls/tooltip/tooltip.d.ts +54 -0
- package/views/dist/controls/tooltip/tooltip.js +78 -0
- package/views/dist/controls/tooltip.css +94 -0
- package/views/dist/grid/chrome/GridTable.js +21 -19
- package/views/dist/grid/chrome/grid-row-window.js +3 -0
- package/views/dist/grid/chrome/useGridColumnLayout.d.ts +4 -1
- package/views/dist/grid/chrome/useGridColumnLayout.js +17 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +29 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +46 -0
- package/views/dist/looks/index.d.ts +15 -0
- package/views/dist/looks/index.js +15 -0
- package/views/dist/looks/pieces.js +36 -2
- package/views/dist/model/column-schema.d.ts +3 -2
- package/views/dist/model/column-state.d.ts +11 -1
- package/views/dist/model/column-state.js +8 -2
- package/views/dist/styles.css +1930 -7
- package/views/dist/styles.unlayered.css +1930 -7
- package/views/docs/contract.md +5 -97
- package/views/docs/controls/button.md +93 -0
- package/views/docs/controls/checkbox.md +38 -0
- package/views/docs/controls/field.md +26 -0
- package/views/docs/controls/glass-button.md +37 -0
- package/views/docs/controls/inline-input.md +27 -0
- package/views/docs/controls/input.md +48 -0
- package/views/docs/controls/kbd.md +17 -0
- package/views/docs/controls/number-field.md +17 -0
- package/views/docs/controls/option.md +61 -0
- package/views/docs/controls/phone-header.md +20 -0
- package/views/docs/controls/popover.md +26 -0
- package/views/docs/controls/scrollbar.md +16 -0
- package/views/docs/controls/sheet.md +41 -0
- package/views/docs/controls/spinner.md +19 -0
- package/views/docs/controls/status.md +107 -0
- package/views/docs/controls/switch.md +40 -0
- package/views/docs/controls/tag.md +21 -0
- package/views/docs/controls/toggle.md +19 -0
- package/views/docs/controls/tooltip.md +24 -0
- package/views/docs/getting-started.md +1 -1
- package/views/docs/reference/controls.md +173 -2
- package/views/docs/reference/looks.md +67 -2
- package/views/docs/reference/views.md +7 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* The Inline input: the box a value is typed into where it stands. Every value is a public name.
|
|
2
|
+
|
|
3
|
+
Its options are worn from the nearest frame that picks them (data-inline-input-edge, -corners, -ground, looks.ts), written
|
|
4
|
+
there as variables, so the nearest frame wins with nothing more: its edge, Line (a hairline of the brand) or Ring (a 2px ring
|
|
5
|
+
of the brand inside it); its corners, a step of the radius from None to Full, long text stopping at 2xl; its ground, Plain
|
|
6
|
+
(the overlay's, so a box that grows over the rows below covers them), Tint (a wash of the brand, as strong as its Tint slider says: 10% to 100% of the brand's light step) or None (the cell showing
|
|
7
|
+
through). With no frame round it, each option's default: the line, md corners, a 20% tint. The brand's caret; refused, its edge is red.
|
|
8
|
+
|
|
9
|
+
Its spacing is one rule, whatever holds it. It fills its place's row (--inline-input-row, 36 unless its place says:
|
|
10
|
+
a list's row 28, a phone's 40), one line centred in it. Its words stand 12 from its outer edge, 8 in a row under 32. What
|
|
11
|
+
stands beside the value is 4 from it, and a button at its start or end 4 from its edge, as far in as a 28px button stands from
|
|
12
|
+
the top of a 36 row, so the button's words stand where the box's do.
|
|
13
|
+
|
|
14
|
+
The box alone is the Input's bare control (.o-input-control), and each rule here outweighs that one's: .o-inline-input twice,
|
|
15
|
+
(0,2,0). The rules sit in the components layer, so a utility class still wins. */
|
|
16
|
+
@layer components {
|
|
17
|
+
|
|
18
|
+
/* ── Its options, from the nearest frame: its edge, its corners, its ground ───────────────────────────────────────────── */
|
|
19
|
+
[data-inline-input-edge="line"] { --inline-input-edge: var(--vk-border-width); --inline-input-ring: 0px; }
|
|
20
|
+
[data-inline-input-edge="ring"] { --inline-input-edge: 0px; --inline-input-ring: var(--vk-focus-width); }
|
|
21
|
+
[data-inline-input-corners="none"] { --inline-input-r: 0px; }
|
|
22
|
+
[data-inline-input-corners="xs"] { --inline-input-r: var(--vk-radius-xs); }
|
|
23
|
+
[data-inline-input-corners="sm"] { --inline-input-r: var(--vk-radius-sm); }
|
|
24
|
+
[data-inline-input-corners="md"] { --inline-input-r: var(--vk-radius-md); }
|
|
25
|
+
[data-inline-input-corners="lg"] { --inline-input-r: var(--vk-radius-lg); }
|
|
26
|
+
[data-inline-input-corners="xl"] { --inline-input-r: var(--vk-radius-xl); }
|
|
27
|
+
[data-inline-input-corners="full"] { --inline-input-r: var(--vk-radius-full); }
|
|
28
|
+
[data-inline-input-ground="plain"] { --inline-input-ground: var(--vk-overlay); }
|
|
29
|
+
[data-inline-input-ground="tint"] { --inline-input-ground: color-mix(in oklab, var(--vk-brand-300) var(--inline-input-tint, 20%), var(--vk-overlay)); }
|
|
30
|
+
/* How strong the tint is: how much of the brand's light step (brand-300) is mixed into the overlay's ground, 10% to 100%, a
|
|
31
|
+
tenth at a time. The brand's palest (brand-100) is about 20%, its pale
|
|
32
|
+
(brand-200) about 60%. The frame writes it beside the ground, so it resolves there. */
|
|
33
|
+
[data-inline-input-tint="1"] { --inline-input-tint: 10%; }
|
|
34
|
+
[data-inline-input-tint="2"] { --inline-input-tint: 20%; }
|
|
35
|
+
[data-inline-input-tint="3"] { --inline-input-tint: 30%; }
|
|
36
|
+
[data-inline-input-tint="4"] { --inline-input-tint: 40%; }
|
|
37
|
+
[data-inline-input-tint="5"] { --inline-input-tint: 50%; }
|
|
38
|
+
[data-inline-input-tint="6"] { --inline-input-tint: 60%; }
|
|
39
|
+
[data-inline-input-tint="7"] { --inline-input-tint: 70%; }
|
|
40
|
+
[data-inline-input-tint="8"] { --inline-input-tint: 80%; }
|
|
41
|
+
[data-inline-input-tint="9"] { --inline-input-tint: 90%; }
|
|
42
|
+
[data-inline-input-tint="10"] { --inline-input-tint: 100%; }
|
|
43
|
+
[data-inline-input-ground="none"] { --inline-input-ground: var(--vk-input); }
|
|
44
|
+
|
|
45
|
+
/* ── The box ──────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
46
|
+
.o-inline-input.o-inline-input {
|
|
47
|
+
--inline-input-at: var(--inline-input-row, calc(var(--vk-spacing) * 9));
|
|
48
|
+
--inline-input-e: var(--inline-input-edge, var(--vk-border-width));
|
|
49
|
+
--inline-input-colour: var(--vk-border-brand);
|
|
50
|
+
/* Its words from its outer edge: 12, or 8 in a row under 32 (a list's 28). */
|
|
51
|
+
--inline-input-words: clamp(calc(var(--vk-spacing) * 2), calc(var(--inline-input-at) - var(--vk-spacing) * 5), calc(var(--vk-spacing) * 3));
|
|
52
|
+
box-sizing: border-box; width: 100%; min-width: 0; height: var(--inline-input-at); margin: 0;
|
|
53
|
+
padding: max(0px, calc((var(--inline-input-at) - 1lh) / 2 - var(--inline-input-e))) calc(var(--inline-input-words) - var(--inline-input-e));
|
|
54
|
+
border: var(--inline-input-e) solid var(--inline-input-colour); border-radius: var(--inline-input-r, var(--vk-radius-md));
|
|
55
|
+
box-shadow: inset 0 0 0 var(--inline-input-ring, 0px) var(--inline-input-colour);
|
|
56
|
+
background-color: var(--inline-input-ground, color-mix(in oklab, var(--vk-brand-300) var(--inline-input-tint, 20%), var(--vk-overlay))); color: var(--vk-fg); caret-color: var(--vk-border-brand);
|
|
57
|
+
font: inherit; font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); outline: none;
|
|
58
|
+
}
|
|
59
|
+
/* Refused: its edge red, line or ring. */
|
|
60
|
+
.o-inline-input.o-inline-input:is([aria-invalid="true"], :has(.o-input-control[aria-invalid="true"])) { --inline-input-colour: var(--vk-border-danger); }
|
|
61
|
+
/* Long text: at the height its place gives it, its first line where a line's stands, wrapping. */
|
|
62
|
+
textarea.o-inline-input.o-inline-input { resize: none; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
63
|
+
/* Long text never turns into a pill: its corners stop at 2xl, the largest step that still reads as a box. */
|
|
64
|
+
textarea.o-inline-input.o-inline-input { border-radius: min(var(--inline-input-r, var(--vk-radius-md)), var(--vk-radius-2xl)); }
|
|
65
|
+
|
|
66
|
+
/* ── With sides: one row, everything centred in it ────────────────────────────────────────────────────────────────────── */
|
|
67
|
+
.o-inline-input.o-inline-input-group { display: flex; align-items: center; gap: var(--vk-spacing); padding-block: 0; cursor: text; }
|
|
68
|
+
/* A button at its start or its end: 4 from its outer edge. */
|
|
69
|
+
.o-inline-input.o-inline-input-group:has(> .o-input-addon[data-side="start"] > .o-button:first-child) { padding-left: calc(var(--vk-spacing) - var(--inline-input-e)); }
|
|
70
|
+
.o-inline-input.o-inline-input-group:has(> .o-input-addon[data-side="end"] > .o-button:last-child) { padding-right: calc(var(--vk-spacing) - var(--inline-input-e)); }
|
|
71
|
+
/* Its buttons' focus ring hugs them, inside its edge. */
|
|
72
|
+
.o-inline-input-group > .o-input-addon > .o-button:is(:focus-visible, [data-force="focus"]) { outline-offset: 0; }
|
|
73
|
+
|
|
74
|
+
/* On a phone its words are 16px, so iOS never zooms in when it is tapped: its line is kept, and its padding, worked
|
|
75
|
+
from 1lh, still centres that line in its row. */
|
|
76
|
+
@media (width < 640px) { .o-inline-input.o-inline-input:where(:not([data-computer-host], [data-computer-host] *)) { font-size: var(--vk-font-size-base); } }
|
|
77
|
+
@container o-phone (width < 640px) { .o-inline-input.o-inline-input { font-size: var(--vk-font-size-base); } }
|
|
78
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The word Chromium and Firefox take as "fill nothing here". */
|
|
2
|
+
export declare const OFF_WORD = "language";
|
|
3
|
+
type Nav = {
|
|
4
|
+
userAgent: string;
|
|
5
|
+
userAgentData?: {
|
|
6
|
+
brands: {
|
|
7
|
+
brand: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/** The autocomplete word that turns autofill off in this browser: "language" in Chromium and Firefox, "off" in WebKit. Chrome
|
|
12
|
+
* and Firefox on an iPhone are WebKit (CriOS, FxiOS). With no browser (drawn on the server), "off". */
|
|
13
|
+
export declare function offWord(nav?: Nav): string;
|
|
14
|
+
/** What a box carries with its autofill off, in a browser whose off word is `word`. */
|
|
15
|
+
export declare const autofillOff: (word: string) => {
|
|
16
|
+
"data-1p-ignore": "true";
|
|
17
|
+
"data-lpignore": "true";
|
|
18
|
+
"data-bwignore": "true";
|
|
19
|
+
"data-form-type": "other";
|
|
20
|
+
autoComplete: string;
|
|
21
|
+
};
|
|
22
|
+
/** A box's autofill, on or off: spread `fill(false)` on a box holding someone else's details; `fill()` adds nothing. Drawn on
|
|
23
|
+
* the server, off says "off", and in the browser its own word: React draws it again after hydrating. */
|
|
24
|
+
export declare function useAutofill(): (on?: boolean) => Partial<ReturnType<typeof autofillOff>>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export const OFF_WORD = "language";
|
|
3
|
+
const MANAGERS = { "data-1p-ignore": "true", "data-lpignore": "true", "data-bwignore": "true", "data-form-type": "other" };
|
|
4
|
+
export function offWord(nav) {
|
|
5
|
+
if (!nav)
|
|
6
|
+
return "off";
|
|
7
|
+
const ua = nav.userAgent, iphone = /\b(?:CriOS|FxiOS)\//.test(ua);
|
|
8
|
+
const chromium = nav.userAgentData ? nav.userAgentData.brands.some((b) => b.brand === "Chromium") : /\b(?:Chrome|Chromium)\/\d/.test(ua) && !iphone;
|
|
9
|
+
const firefox = /\bFirefox\/\d/.test(ua) && !iphone;
|
|
10
|
+
return chromium || firefox ? OFF_WORD : "off";
|
|
11
|
+
}
|
|
12
|
+
export const autofillOff = (word) => ({ autoComplete: word, ...MANAGERS });
|
|
13
|
+
const never = () => () => { };
|
|
14
|
+
export function useAutofill() {
|
|
15
|
+
const word = React.useSyncExternalStore(never, () => offWord(navigator), () => "off");
|
|
16
|
+
return (on = true) => (on ? {} : autofillOff(word));
|
|
17
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Input as BaseInput } from "@base-ui/react/input";
|
|
3
|
+
import { type ButtonProps } from "../button/button.js";
|
|
4
|
+
import { type InputOwnLook } from "./looks.js";
|
|
5
|
+
/** The five heights, as the Button's: 24 and 28px in dense rows (24 with 12px words), 32 in toolbars, 36
|
|
6
|
+
* beside other fields, 44 on the phone. Below the small breakpoint every field takes 44 and 16px words,
|
|
7
|
+
* so iOS never zooms in. */
|
|
8
|
+
export type InputSize = "2xs" | "xs" | "sm" | "md" | "lg";
|
|
9
|
+
/** How the Input stands, its kind, which its place picks, as a Button's kind: in its field,
|
|
10
|
+
* wearing the Input's look; Soft, its field in the Soft look as its own whatever the app picks for its Inputs (kindLook); or bare,
|
|
11
|
+
* the control alone, where its place frames it (the box typed into in place is the inline input's; the components map's Input asks for
|
|
12
|
+
* "bare" or "field"). */
|
|
13
|
+
export type InputChrome = "field" | "soft" | "bare";
|
|
14
|
+
/** The group an Input stands in, for a box that frames its Input as the InputGroup does: the inline input's group. Inside
|
|
15
|
+
* it an Input is the box's bare control, and an InputGroupButton is xs (28) where `cell`. */
|
|
16
|
+
export declare const InputGroupContext: React.Context<{
|
|
17
|
+
size: InputSize;
|
|
18
|
+
cell: boolean;
|
|
19
|
+
lines?: number;
|
|
20
|
+
} | null>;
|
|
21
|
+
/** A press on a box that holds an Input and its sides, as the InputGroup takes it: on a segment, that segment; on one of its
|
|
22
|
+
* buttons, nothing, so the box keeps its focus and its cursor; anywhere else, the cursor into its Input. The inline input's
|
|
23
|
+
* group takes a press the same way. */
|
|
24
|
+
export declare function pressGroup(e: React.MouseEvent<HTMLElement>): void;
|
|
25
|
+
export interface InputProps extends Omit<BaseInput.Props, "className" | "size"> {
|
|
26
|
+
/** Its height (InputSize): md 36 unless said; lg is the phone's. Inside an InputGroup, the group's size. */
|
|
27
|
+
size?: InputSize;
|
|
28
|
+
/** Numbers: their digits line up. Give it the matching inputMode too. */
|
|
29
|
+
numeric?: boolean;
|
|
30
|
+
/** Long text: a textarea, at least 84px (minLines sets another start), dragged taller. */
|
|
31
|
+
multiline?: boolean;
|
|
32
|
+
/** Long text that grows with what is written in it, and dragged taller too, as shadcn's Textarea. Inside an
|
|
33
|
+
* InputGroup, and bare, long text always grows. */
|
|
34
|
+
grow?: boolean;
|
|
35
|
+
/** How many lines long text that grows goes to before it scrolls instead: 10 unless said. */
|
|
36
|
+
maxLines?: number;
|
|
37
|
+
/** Long text: the lines it starts at, from which it grows (with grow) or is dragged taller, never shorter; in its field, its
|
|
38
|
+
* padding and edge on top. Without it, at least 84px. With lines, bare or inside an InputGroup, nothing. Past
|
|
39
|
+
* maxLines, it stays at its start and scrolls. */
|
|
40
|
+
minLines?: number;
|
|
41
|
+
/** Long text that shows this many lines: its height theirs, never grown or dragged taller; past them it scrolls. In its
|
|
42
|
+
* field its padding and edge on top; inside an InputGroup the group is the box. Without
|
|
43
|
+
* it, long text is at least 84px. With it, grow means nothing. */
|
|
44
|
+
lines?: number;
|
|
45
|
+
/** Whether the browser and the password managers may fill it: on unless said. Off for a box holding someone else's
|
|
46
|
+
* details (a record's), so nothing offers the user's own (useAutofill). */
|
|
47
|
+
autofill?: boolean;
|
|
48
|
+
/** A box's own look: its options, whole, winning over its frame's. Inside an InputGroup, the group's. Bare,
|
|
49
|
+
* none: its place draws it. */
|
|
50
|
+
look?: InputOwnLook;
|
|
51
|
+
/** How it stands, its kind (InputChrome): in its field unless said, Soft, or bare. Inside an InputGroup it is always the group's
|
|
52
|
+
* bare control, the group's kind its own. size, the field's, means nothing bare. */
|
|
53
|
+
chrome?: InputChrome;
|
|
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
|
+
* and height its place gives it, as the editors size their boxes. In its field, nothing. */
|
|
56
|
+
fills?: boolean;
|
|
57
|
+
/** The Input's list: see InputComboboxProps. */
|
|
58
|
+
combobox?: false;
|
|
59
|
+
/** 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
|
|
60
|
+
* on the box, and what styles the words or the control's own states no longer reaches them. Instead: the words' alignment, case
|
|
61
|
+
* and spacing (`text-right`, `uppercase`, `tracking-*`) through a class on a place's own rule on `.o-input-control` inside the box;
|
|
62
|
+
* `placeholder:`, `focus:`, `disabled:` and `aria-invalid:` through the Input's own states and looks (input.css), never utilities;
|
|
63
|
+
* its padding through the box's `--input-pad-inline` and `--input-pad-block` (a `px-*` adds to the control's own); long text's
|
|
64
|
+
* height through `minLines`, `maxLines` or `lines` (a `height` on the box doesn't size its textarea). Bare, the
|
|
65
|
+
* control's classes, as before. */
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
/** The Input's list: the Input as the box of a list that filters as it is typed into, Base UI's Combobox.Input
|
|
69
|
+
* in its place, inside a Combobox's Root, in one line (multiline means nothing). What it holds is the Root's (its inputValue),
|
|
70
|
+
* so it takes no value of its own; its keys (the arrows, Enter, Escape) and its role are the list's. A picker's search on a
|
|
71
|
+
* phone, a select typed into. */
|
|
72
|
+
export type InputComboboxProps = Omit<InputProps, "combobox" | "value" | "defaultValue" | "onValueChange"> & {
|
|
73
|
+
combobox: true;
|
|
74
|
+
};
|
|
75
|
+
/** What a person types into: alone, or inside a Field (field/), which gives it its label and its note or error;
|
|
76
|
+
* inside an InputGroup, with addons beside, above or below it. */
|
|
77
|
+
export declare const Input: React.ForwardRefExoticComponent<(Omit<InputProps, "ref"> | Omit<InputComboboxProps, "ref">) & React.RefAttributes<HTMLElement>>;
|
|
78
|
+
export interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
79
|
+
/** Its height, as the Input's (InputSize): md 36 unless said. A button inside it fits from sm (32px) up; on a phone a button
|
|
80
|
+
* beside the value takes the value's 16px words. */
|
|
81
|
+
size?: InputSize;
|
|
82
|
+
/** A box's own look: its options, whole, winning over its frame's. */
|
|
83
|
+
look?: InputOwnLook;
|
|
84
|
+
/** How it stands, its kind (InputChrome): in its field unless said, or Soft. */
|
|
85
|
+
chrome?: Exclude<InputChrome, "bare">;
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Its Input and its InputGroupAddons, as its own children. */
|
|
88
|
+
children: React.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
/** A field with something inside it beside the words: an icon, words before or after them, a button
|
|
91
|
+
* (clear, show the password, copy); or rows above and below long text. It draws the field around its
|
|
92
|
+
* Input and addons, in every state and every look, and a press anywhere in it but a button puts the
|
|
93
|
+
* cursor in its Input. A value typed in parts holds InputGroupSegments instead of an Input: the group shows its focus while
|
|
94
|
+
* 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;
|
|
96
|
+
export interface InputGroupAddonProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
97
|
+
/** Where it sits: before the words or after them (start, end), or a row above or below long text (top,
|
|
98
|
+
* bottom). */
|
|
99
|
+
side?: "start" | "end" | "top" | "bottom";
|
|
100
|
+
/** Flush: a Button in it stands as the side's other parts do, so the field keeps its own start or end, size, corners and focus
|
|
101
|
+
* ring for it: none of what a group gives a Button at its start or end (a date's time in its line). */
|
|
102
|
+
flush?: boolean;
|
|
103
|
+
className?: string;
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}
|
|
106
|
+
/** What sits inside the field beside its words: a 16px icon, words before or after them ("https://",
|
|
107
|
+
* "€", "@northbeam.example"), a Spinner, an InputGroupButton; above or below long text, a row of them. */
|
|
108
|
+
export declare function InputGroupAddon({ side, flush, className, children, ...props }: InputGroupAddonProps): import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
/** A button inside the field: the Button, quiet, 28px (24px in a 32px field; 28px in the inline input's group, whatever its size); with
|
|
110
|
+
* no words, an icon-only square (give it an aria-label). At the field's start or end it sits as far in from the side as from
|
|
111
|
+
* the top. On a phone, at the start or end, its words are the value's 16px. A 24 or 28px field has no room for one: it holds
|
|
112
|
+
* icons and words only. */
|
|
113
|
+
export declare const InputGroupButton: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
114
|
+
/** A segment of a value typed in parts inside an InputGroup (a day, a month, a year), a spinbutton: the group shows its focus
|
|
115
|
+
* while any segment has it, and a press on the group off its segments puts the focus in its first. Its keys and its value
|
|
116
|
+
* are its owner's; on (its owner's word) draws it on the brand's tint. */
|
|
117
|
+
export declare const InputGroupSegment: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
118
|
+
on?: boolean;
|
|
119
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Input as BaseInput } from "@base-ui/react/input";
|
|
4
|
+
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
|
|
5
|
+
import { cx } from "../../internal/cx.js";
|
|
6
|
+
import { Button } from "../button/button.js";
|
|
7
|
+
import { useAutofill } from "./autofill.js";
|
|
8
|
+
import { inputOwnAttrs, kindLook } from "./looks.js";
|
|
9
|
+
const sized = (size) => size !== "md" && `o-input-${size}`;
|
|
10
|
+
const InGroup = React.createContext(null);
|
|
11
|
+
export const InputGroupContext = InGroup;
|
|
12
|
+
export function pressGroup(e) {
|
|
13
|
+
const on = e.target;
|
|
14
|
+
if (on.closest(".o-input-segment"))
|
|
15
|
+
return;
|
|
16
|
+
const control = e.currentTarget.querySelector(":scope > .o-input-control") ?? e.currentTarget.querySelector(".o-input-segment");
|
|
17
|
+
if (e.defaultPrevented || !control || on.closest("a, input, textarea, select"))
|
|
18
|
+
return;
|
|
19
|
+
if (on.closest("button, [role='button']")) {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
control.focus();
|
|
25
|
+
}
|
|
26
|
+
function fitHeight(box) {
|
|
27
|
+
box.style.height = "auto";
|
|
28
|
+
box.style.height = `${box.scrollHeight + box.offsetHeight - box.clientHeight}px`;
|
|
29
|
+
}
|
|
30
|
+
function useGrow(el, on, value) {
|
|
31
|
+
React.useLayoutEffect(() => {
|
|
32
|
+
const box = el.current;
|
|
33
|
+
if (!on || !box || CSS.supports("field-sizing", "content"))
|
|
34
|
+
return;
|
|
35
|
+
const fit = () => fitHeight(box);
|
|
36
|
+
fit();
|
|
37
|
+
box.addEventListener("input", fit);
|
|
38
|
+
return () => box.removeEventListener("input", fit);
|
|
39
|
+
}, [el, on, value]);
|
|
40
|
+
}
|
|
41
|
+
function useKeptCursor(el, type) {
|
|
42
|
+
const at = React.useRef(null), drawn = React.useRef(type);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
const box = el.current;
|
|
45
|
+
if (!box)
|
|
46
|
+
return;
|
|
47
|
+
const keep = () => { try {
|
|
48
|
+
if (box.selectionStart != null)
|
|
49
|
+
at.current = [box.selectionStart, box.selectionEnd ?? box.selectionStart];
|
|
50
|
+
}
|
|
51
|
+
catch { } };
|
|
52
|
+
const moved = () => { if (document.activeElement === box)
|
|
53
|
+
keep(); };
|
|
54
|
+
const on = ["keyup", "mouseup", "input", "select", "focus"];
|
|
55
|
+
on.forEach((e) => box.addEventListener(e, keep));
|
|
56
|
+
document.addEventListener("selectionchange", moved);
|
|
57
|
+
return () => { on.forEach((e) => box.removeEventListener(e, keep)); document.removeEventListener("selectionchange", moved); };
|
|
58
|
+
}, [el]);
|
|
59
|
+
React.useLayoutEffect(() => {
|
|
60
|
+
if (drawn.current === type)
|
|
61
|
+
return;
|
|
62
|
+
drawn.current = type;
|
|
63
|
+
const box = el.current, was = at.current;
|
|
64
|
+
if (!box || !was || document.activeElement !== box)
|
|
65
|
+
return;
|
|
66
|
+
const put = () => { try {
|
|
67
|
+
box.setSelectionRange(...was);
|
|
68
|
+
}
|
|
69
|
+
catch { } };
|
|
70
|
+
void box.offsetWidth;
|
|
71
|
+
put();
|
|
72
|
+
const f = requestAnimationFrame(() => { if (document.activeElement === box && box.selectionStart !== was[0])
|
|
73
|
+
put(); });
|
|
74
|
+
return () => cancelAnimationFrame(f);
|
|
75
|
+
}, [el, type]);
|
|
76
|
+
}
|
|
77
|
+
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) {
|
|
78
|
+
const fill = useAutofill(), look = kindLook(chrome, lookGiven);
|
|
79
|
+
const group = React.useContext(InGroup), grouped = group != null;
|
|
80
|
+
const lines = linesGiven ?? look?.lines ?? group?.lines;
|
|
81
|
+
const long = multiline && !combobox;
|
|
82
|
+
const bare = grouped || chrome === "bare", field = !bare, set = long && lines != null, grows = long && !set && (field ? grow : bare);
|
|
83
|
+
const own = React.useRef(null);
|
|
84
|
+
const refs = React.useCallback((n) => { own.current = n; if (typeof ref === "function")
|
|
85
|
+
ref(n);
|
|
86
|
+
else if (ref)
|
|
87
|
+
ref.current = n; }, [ref]);
|
|
88
|
+
useGrow(own, grows, "value" in props ? props.value : undefined);
|
|
89
|
+
useKeptCursor(own, props.type);
|
|
90
|
+
const Control = (combobox ? BaseCombobox.Input : BaseInput);
|
|
91
|
+
const most = grows && maxLines ? { maxHeight: field ? `calc(1lh * ${maxLines} + var(--vk-spacing) * 4 + var(--vk-border-width) * 2)` : `calc(1lh * ${maxLines})` } : undefined;
|
|
92
|
+
const start = long && field && !set && minLines ? { minHeight: `calc(1lh * ${minLines} + var(--vk-spacing) * 4 + var(--vk-border-width) * 2)` } : undefined;
|
|
93
|
+
const control = (attrs) => (_jsx(Control, { ref: refs, ...attrs, ...(long ? { render: _jsx("textarea", {}) } : {}), ...(set ? { rows: lines } : {}), ...props, ...fill(autofill) }));
|
|
94
|
+
if (field) {
|
|
95
|
+
const { "data-force": force, ...rest } = props;
|
|
96
|
+
props = rest;
|
|
97
|
+
return (_jsx("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", ...(force != null ? { "data-force": force } : {}), ...(look ? inputOwnAttrs(look) : {}), onMouseDown: (e) => {
|
|
98
|
+
const box = own.current;
|
|
99
|
+
if (e.target !== e.currentTarget || !box || box.disabled)
|
|
100
|
+
return;
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
box.focus();
|
|
103
|
+
}, children: control({ className: cx("o-input-control", set && "o-input-lines", numeric && "o-input-num"), ...(most ? { style: most } : {}) }) }));
|
|
104
|
+
}
|
|
105
|
+
return control({
|
|
106
|
+
className: cx("o-input-control", set && "o-input-lines", numeric && "o-input-num", className),
|
|
107
|
+
style: most || style ? { ...most, ...style } : undefined,
|
|
108
|
+
"data-kit": "input",
|
|
109
|
+
...(bare && !fills ? { "data-fills": "off" } : {}),
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
export function InputGroup({ size = "md", look: lookGiven, chrome, className, children, onMouseDown, ...props }) {
|
|
113
|
+
const look = kindLook(chrome, lookGiven);
|
|
114
|
+
const tall = React.Children.toArray(children).some((c) => React.isValidElement(c)
|
|
115
|
+
&& ((c.type === Input && c.props.multiline) || (c.type === InputGroupAddon && (c.props.side === "top" || c.props.side === "bottom"))));
|
|
116
|
+
return (_jsx(InGroup.Provider, { value: { size, cell: false, lines: look?.lines }, children: _jsx("div", { role: "group", className: cx("o-input o-input-group o-smooth o-smooth-ease", sized(size), tall && "o-input-long", className), ...(look ? inputOwnAttrs(look) : {}), onMouseDown: (e) => { onMouseDown?.(e); pressGroup(e); }, ...props, children: children }) }));
|
|
117
|
+
}
|
|
118
|
+
export function InputGroupAddon({ side = "start", flush = false, className, children, ...props }) {
|
|
119
|
+
return _jsx("div", { "data-side": side, ...(flush ? { "data-flush": "" } : {}), className: cx("o-input-addon", className), ...props, children: children });
|
|
120
|
+
}
|
|
121
|
+
export const InputGroupButton = React.forwardRef(function InputGroupButton({ kind = "quiet", size, shape, children, ...props }, ref) {
|
|
122
|
+
const group = React.useContext(InGroup);
|
|
123
|
+
return _jsx(Button, { ref: ref, kind: kind, size: size ?? (group?.size === "sm" && !group.cell ? "2xs" : "xs"), shape: shape ?? (children == null ? "icon" : "default"), ...props, children: children });
|
|
124
|
+
});
|
|
125
|
+
export const InputGroupSegment = React.forwardRef(function InputGroupSegment({ on = false, className, ...props }, ref) {
|
|
126
|
+
return _jsx("span", { ref: ref, role: "spinbutton", tabIndex: 0, ...(on ? { "data-on": "" } : {}), className: cx("o-input-segment", className), ...props });
|
|
127
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type LookPicks, type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
export type InputLookOptionId = "radius" | "smoothing" | "style" | "depth" | "hover" | "focus" | "error";
|
|
3
|
+
export declare const INPUT_LOOKS: PieceLooks<InputLookOptionId>;
|
|
4
|
+
export type InputPicks = LookPicks<InputLookOptionId>;
|
|
5
|
+
/** The ground under a box's words: none (the surface shows through), or the overlay's. */
|
|
6
|
+
export type InputGround = "input" | "overlay";
|
|
7
|
+
/** Where a box's words start: the field's own padding inside its edge, or 12px from its outer edge. */
|
|
8
|
+
export type InputPad = "field" | "edge";
|
|
9
|
+
/** A box's corners: the smooth outline the Input draws (its Corner smoothing), or round. */
|
|
10
|
+
export type InputCorner = "squircle" | "round";
|
|
11
|
+
/** A box's words: code, the monospace typeface at xs, for long text that is code. Never a size: its height and its line stay
|
|
12
|
+
* its size's. */
|
|
13
|
+
export type InputWords = "code";
|
|
14
|
+
/** A box's own look: the Input's options set on one box, whole, winning over its frame's. */
|
|
15
|
+
export interface InputOwnLook extends InputPicks {
|
|
16
|
+
ground?: InputGround;
|
|
17
|
+
pad?: InputPad;
|
|
18
|
+
corner?: InputCorner;
|
|
19
|
+
words?: InputWords;
|
|
20
|
+
/** Long text's lines, which an Input reads when it is given none itself (a street address). */
|
|
21
|
+
lines?: 3 | 4;
|
|
22
|
+
/** On a phone the box keeps its own size (32 high, a line of 20, a select's words 14) instead of the phone's: the computer's
|
|
23
|
+
* form of a box shown on a phone's screen. On a frame too. */
|
|
24
|
+
keep?: "size";
|
|
25
|
+
}
|
|
26
|
+
/** The data attributes for a set of picks, an option left out taking its default. */
|
|
27
|
+
export declare function inputAttrs(picks?: InputPicks): Record<string, string>;
|
|
28
|
+
/** The labelled box, one look for every place that draws it (a compound value's parts, a number's sheet): small round corners
|
|
29
|
+
* (a step larger on a phone), the overlay's ground, no lift, nothing under the pointer, focus the edge alone, its words 12px
|
|
30
|
+
* from its outer edge; its computer form keeps its own size on a phone. */
|
|
31
|
+
export declare function attioBox(phone: boolean): InputOwnLook;
|
|
32
|
+
/** A box's own look under its kind: Soft, a kind every field has, is the Soft look's picks as the box's own, whole, whatever the
|
|
33
|
+
* app picks for its Inputs, under any own look the place gives it too; in its field or bare, its own look alone. */
|
|
34
|
+
export declare function kindLook(chrome: string | undefined, look?: InputOwnLook): InputOwnLook | undefined;
|
|
35
|
+
/** The data attributes of a box's own look, on the field's own element: every option, one it doesn't name at its default
|
|
36
|
+
* (never its frame's), and the mark the stylesheet reads it by. */
|
|
37
|
+
export declare function inputOwnAttrs(look: InputOwnLook): Record<string, string>;
|
|
38
|
+
/** A box's own look written on a frame: the same attributes as inputOwnAttrs, without the mark, so every field inside draws as
|
|
39
|
+
* that look draws its own box. Every option is written, one it doesn't name at its default, so the frame holds whole: the
|
|
40
|
+
* nearest frame wins, option by option (input.css's head). */
|
|
41
|
+
export declare function inputFrameAttrs(look: InputOwnLook): Record<string, string>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { lookAttrs } from "../../looks/looks.js";
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "radius", name: "Corners", def: "lg", kind: "steps", unless: ["style", "underline"], values: ["xs", "sm", "md", "lg", "xl", "2xl", "full"].map((id) => ({ id, name: id === "full" ? "Full" : id })) },
|
|
4
|
+
{ id: "smoothing", name: "Corner smoothing", def: "app", unless: ["style", "underline"], values: [{ id: "app", name: "The app's" }, { id: "smooth", name: "Smooth" }, { id: "round", name: "Round" }] },
|
|
5
|
+
{ id: "style", name: "Field", def: "outlined", values: [{ id: "outlined", name: "Outlined" }, { id: "filled", name: "Filled" }, { id: "underline", name: "Underline" }] },
|
|
6
|
+
{ id: "depth", name: "Depth", def: "lift", values: [{ id: "lift", name: "Lift" }, { id: "flat", name: "Flat" }, { id: "sunken", name: "Sunken" }] },
|
|
7
|
+
{ id: "hover", name: "Under the pointer", def: "edge", values: [{ id: "edge", name: "Edge" }, { id: "fill", name: "Fill" }, { id: "strong", name: "Strong" }] },
|
|
8
|
+
{ id: "focus", name: "Focus", def: "glow", unless: ["style", "underline"], values: [{ id: "glow", name: "Glow" }, { id: "line", name: "Edge only" }, { id: "thick", name: "Thick edge" }] },
|
|
9
|
+
{ id: "error", name: "Error", def: "edge", values: [{ id: "edge", name: "Edge" }, { id: "tint", name: "Edge and tint" }] },
|
|
10
|
+
];
|
|
11
|
+
export const INPUT_LOOKS = {
|
|
12
|
+
id: "input",
|
|
13
|
+
name: "Input",
|
|
14
|
+
options,
|
|
15
|
+
looks: [
|
|
16
|
+
{ id: "classic", name: "Classic", picks: { radius: "lg", smoothing: "app", style: "outlined", depth: "lift", hover: "edge", focus: "glow", error: "edge" } },
|
|
17
|
+
{ id: "soft", name: "Soft", picks: { radius: "lg", smoothing: "app", style: "filled", depth: "flat", hover: "fill", focus: "glow", error: "tint" } },
|
|
18
|
+
{ id: "line", name: "Line", picks: { radius: "lg", smoothing: "app", style: "underline", depth: "flat", hover: "edge", focus: "glow", error: "edge" } },
|
|
19
|
+
{ id: "pill", name: "Pill", picks: { radius: "full", smoothing: "app", style: "outlined", depth: "lift", hover: "edge", focus: "glow", error: "edge" } },
|
|
20
|
+
{ id: "inset", name: "Inset", picks: { radius: "lg", smoothing: "app", style: "outlined", depth: "sunken", hover: "edge", focus: "thick", error: "tint" } },
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
export function inputAttrs(picks = {}) {
|
|
24
|
+
return lookAttrs(INPUT_LOOKS, picks);
|
|
25
|
+
}
|
|
26
|
+
const GROUP_OPTIONS = [["keep", "keep"]];
|
|
27
|
+
function groupAttrs(look) {
|
|
28
|
+
return Object.fromEntries(GROUP_OPTIONS.flatMap(([o, attr]) => (look[o] != null ? [[`data-input-${attr}`, String(look[o])]] : [])));
|
|
29
|
+
}
|
|
30
|
+
export function attioBox(phone) {
|
|
31
|
+
return { radius: phone ? "md" : "sm", ground: "overlay", depth: "flat", hover: "none", focus: "line", pad: "edge", corner: "round", ...(phone ? {} : { keep: "size" }) };
|
|
32
|
+
}
|
|
33
|
+
const SOFT = INPUT_LOOKS.looks.find((l) => l.id === "soft").picks;
|
|
34
|
+
export function kindLook(chrome, look) {
|
|
35
|
+
return chrome === "soft" ? { ...SOFT, ...look } : look;
|
|
36
|
+
}
|
|
37
|
+
export function inputOwnAttrs(look) {
|
|
38
|
+
const attrs = inputAttrs(look);
|
|
39
|
+
if (look.hover === "none")
|
|
40
|
+
attrs["data-input-hover"] = "none";
|
|
41
|
+
if (look.focus === "within")
|
|
42
|
+
attrs["data-input-focus"] = "within";
|
|
43
|
+
return { "data-input-own": "", ...attrs, "data-input-ground": look.ground === "overlay" ? "overlay" : "input", "data-input-pad": look.pad === "edge" ? "edge" : "field", "data-input-corner": look.corner === "round" ? "round" : "squircle", ...(look.words === "code" ? { "data-input-words": "code" } : {}), ...groupAttrs(look) };
|
|
44
|
+
}
|
|
45
|
+
export function inputFrameAttrs(look) {
|
|
46
|
+
const { "data-input-own": _own, ...attrs } = inputOwnAttrs(look);
|
|
47
|
+
return attrs;
|
|
48
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "./input.js";
|
|
3
|
+
export function MapInput({ chrome = "bare", size: _width, inputMode, ref, ...rest }) {
|
|
4
|
+
return _jsx(Input, { ref: ref, chrome: chrome, fills: false, inputMode: inputMode, numeric: inputMode === "decimal" || inputMode === "numeric", autofill: false, ...rest });
|
|
5
|
+
}
|