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,58 @@
|
|
|
1
|
+
export const OPTION_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-border-brand", kind: "colour", outright: "--border-focused" },
|
|
4
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
5
|
+
{ name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
|
|
6
|
+
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
7
|
+
{ name: "--vk-label-amber", kind: "colour", outright: "--label-amber" },
|
|
8
|
+
{ name: "--vk-label-amber-edge", kind: "colour", outright: "--label-amber-edge" },
|
|
9
|
+
{ name: "--vk-label-amber-fill", kind: "colour", outright: "--label-amber-fill" },
|
|
10
|
+
{ name: "--vk-label-amber-soft", kind: "colour", outright: "--label-amber-soft" },
|
|
11
|
+
{ name: "--vk-label-amber-strong", kind: "colour", outright: "--label-amber-strong" },
|
|
12
|
+
{ name: "--vk-label-blue", kind: "colour", outright: "--label-blue" },
|
|
13
|
+
{ name: "--vk-label-blue-edge", kind: "colour", outright: "--label-blue-edge" },
|
|
14
|
+
{ name: "--vk-label-blue-fill", kind: "colour", outright: "--label-blue-fill" },
|
|
15
|
+
{ name: "--vk-label-blue-soft", kind: "colour", outright: "--label-blue-soft" },
|
|
16
|
+
{ name: "--vk-label-blue-strong", kind: "colour", outright: "--label-blue-strong" },
|
|
17
|
+
{ name: "--vk-label-green", kind: "colour", outright: "--label-green" },
|
|
18
|
+
{ name: "--vk-label-green-edge", kind: "colour", outright: "--label-green-edge" },
|
|
19
|
+
{ name: "--vk-label-green-fill", kind: "colour", outright: "--label-green-fill" },
|
|
20
|
+
{ name: "--vk-label-green-soft", kind: "colour", outright: "--label-green-soft" },
|
|
21
|
+
{ name: "--vk-label-green-strong", kind: "colour", outright: "--label-green-strong" },
|
|
22
|
+
{ name: "--vk-label-pink", kind: "colour", outright: "--label-pink" },
|
|
23
|
+
{ name: "--vk-label-pink-edge", kind: "colour", outright: "--label-pink-edge" },
|
|
24
|
+
{ name: "--vk-label-pink-fill", kind: "colour", outright: "--label-pink-fill" },
|
|
25
|
+
{ name: "--vk-label-pink-soft", kind: "colour", outright: "--label-pink-soft" },
|
|
26
|
+
{ name: "--vk-label-pink-strong", kind: "colour", outright: "--label-pink-strong" },
|
|
27
|
+
{ name: "--vk-label-purple", kind: "colour", outright: "--label-purple" },
|
|
28
|
+
{ name: "--vk-label-purple-edge", kind: "colour", outright: "--label-purple-edge" },
|
|
29
|
+
{ name: "--vk-label-purple-fill", kind: "colour", outright: "--label-purple-fill" },
|
|
30
|
+
{ name: "--vk-label-purple-soft", kind: "colour", outright: "--label-purple-soft" },
|
|
31
|
+
{ name: "--vk-label-purple-strong", kind: "colour", outright: "--label-purple-strong" },
|
|
32
|
+
{ name: "--vk-label-red", kind: "colour", outright: "--label-red" },
|
|
33
|
+
{ name: "--vk-label-red-edge", kind: "colour", outright: "--label-red-edge" },
|
|
34
|
+
{ name: "--vk-label-red-fill", kind: "colour", outright: "--label-red-fill" },
|
|
35
|
+
{ name: "--vk-label-red-soft", kind: "colour", outright: "--label-red-soft" },
|
|
36
|
+
{ name: "--vk-label-red-strong", kind: "colour", outright: "--label-red-strong" },
|
|
37
|
+
{ name: "--vk-label-teal", kind: "colour", outright: "--label-teal" },
|
|
38
|
+
{ name: "--vk-label-teal-edge", kind: "colour", outright: "--label-teal-edge" },
|
|
39
|
+
{ name: "--vk-label-teal-fill", kind: "colour", outright: "--label-teal-fill" },
|
|
40
|
+
{ name: "--vk-label-teal-soft", kind: "colour", outright: "--label-teal-soft" },
|
|
41
|
+
{ name: "--vk-label-teal-strong", kind: "colour", outright: "--label-teal-strong" },
|
|
42
|
+
{ name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
|
|
43
|
+
{ name: "--vk-neutral-hovered", kind: "colour", outright: "--background-neutral-hovered" },
|
|
44
|
+
{ name: "--vk-pressed", kind: "colour", outright: "--surface-pressed" },
|
|
45
|
+
{ name: "--vk-focus-offset", kind: "size", outright: "--focus-offset" },
|
|
46
|
+
{ name: "--vk-focus-width", kind: "size", outright: "--focus-width" },
|
|
47
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
48
|
+
{ name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
|
|
49
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
50
|
+
{ name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
|
|
51
|
+
{ name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
|
|
52
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
53
|
+
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
54
|
+
{ name: "--vk-duration-instant", kind: "motion", outright: "--duration-instant" },
|
|
55
|
+
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
56
|
+
{ name: "--vk-press-scale", kind: "motion", outright: "--press-scale" },
|
|
57
|
+
];
|
|
58
|
+
export const OPTION_PRIVATE = ["--o-option-"];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* The Option, as the Outright kit draws it: the Tag's chip without the tag icon
|
|
2
|
+
(tag.css draws the chip and its remove button). This file says how several sit together, how none shows, and, at its end,
|
|
3
|
+
how a colour draws in a colour look, then its icon, its shape and its link. Every value it draws with is a
|
|
4
|
+
public name (its tokens list).
|
|
5
|
+
|
|
6
|
+
The rules sit in the components layer, so a utility class on an option still wins. */
|
|
7
|
+
@layer components {
|
|
8
|
+
|
|
9
|
+
/* ── Several side by side, 6px apart; none, a dash ─────────────────────────────────────────────────── */
|
|
10
|
+
.o-options { display: inline-flex; flex-wrap: wrap; align-items: center; gap: calc(var(--vk-spacing) * 1.5); }
|
|
11
|
+
.o-option-none { color: var(--vk-fg-subtlest); font-size: var(--vk-font-size-sm); }
|
|
12
|
+
|
|
13
|
+
/* ── lg: 28 high, for a phone's row, its words text-sm (the Picker's on a phone, rounds 2 to 4 of its sketch) ──────── */
|
|
14
|
+
.o-tag.o-option.o-option-lg { --tag-h: calc(var(--vk-spacing) * 7); padding: 0 calc(var(--vk-spacing) * 2.5); font-size: var(--vk-font-size-sm); }
|
|
15
|
+
|
|
16
|
+
/* ── A colour: an Option given one (data-colour, its value's own) draws it only in a colour look, worn by the frame or
|
|
17
|
+
the app around it (data-option-colour, looks.ts); with nothing picked it is Attio's pill, the Outright look's pick; in No colour, or
|
|
18
|
+
given none, it draws as above. Each colour's tokens once: a label hue's, or grey's neutrals. ──────────────────────────────────────────────────────────────────────────── */
|
|
19
|
+
.o-option[data-colour="blue"] { --o-option-dot: var(--vk-label-blue); --o-option-soft: var(--vk-label-blue-soft); --o-option-soft-words: var(--vk-label-blue); --o-option-fill: var(--vk-label-blue-fill); --o-option-edge: var(--vk-label-blue-edge); --o-option-strong: var(--vk-label-blue-strong); }
|
|
20
|
+
.o-option[data-colour="green"] { --o-option-dot: var(--vk-label-green); --o-option-soft: var(--vk-label-green-soft); --o-option-soft-words: var(--vk-label-green); --o-option-fill: var(--vk-label-green-fill); --o-option-edge: var(--vk-label-green-edge); --o-option-strong: var(--vk-label-green-strong); }
|
|
21
|
+
.o-option[data-colour="amber"] { --o-option-dot: var(--vk-label-amber); --o-option-soft: var(--vk-label-amber-soft); --o-option-soft-words: var(--vk-label-amber); --o-option-fill: var(--vk-label-amber-fill); --o-option-edge: var(--vk-label-amber-edge); --o-option-strong: var(--vk-label-amber-strong); }
|
|
22
|
+
.o-option[data-colour="red"] { --o-option-dot: var(--vk-label-red); --o-option-soft: var(--vk-label-red-soft); --o-option-soft-words: var(--vk-label-red); --o-option-fill: var(--vk-label-red-fill); --o-option-edge: var(--vk-label-red-edge); --o-option-strong: var(--vk-label-red-strong); }
|
|
23
|
+
.o-option[data-colour="purple"] { --o-option-dot: var(--vk-label-purple); --o-option-soft: var(--vk-label-purple-soft); --o-option-soft-words: var(--vk-label-purple); --o-option-fill: var(--vk-label-purple-fill); --o-option-edge: var(--vk-label-purple-edge); --o-option-strong: var(--vk-label-purple-strong); }
|
|
24
|
+
.o-option[data-colour="pink"] { --o-option-dot: var(--vk-label-pink); --o-option-soft: var(--vk-label-pink-soft); --o-option-soft-words: var(--vk-label-pink); --o-option-fill: var(--vk-label-pink-fill); --o-option-edge: var(--vk-label-pink-edge); --o-option-strong: var(--vk-label-pink-strong); }
|
|
25
|
+
.o-option[data-colour="teal"] { --o-option-dot: var(--vk-label-teal); --o-option-soft: var(--vk-label-teal-soft); --o-option-soft-words: var(--vk-label-teal); --o-option-fill: var(--vk-label-teal-fill); --o-option-edge: var(--vk-label-teal-edge); --o-option-strong: var(--vk-label-teal-strong); }
|
|
26
|
+
.o-option[data-colour="grey"] { --o-option-dot: var(--vk-fg-subtlest); --o-option-soft: var(--vk-neutral); --o-option-soft-words: var(--vk-fg-subtle); --o-option-fill: var(--vk-neutral); --o-option-edge: var(--vk-border); --o-option-strong: var(--vk-fg-subtle); }
|
|
27
|
+
|
|
28
|
+
/* Linear's dot: the Option as it is, a dot of its colour before its word, 8 across (9 in a phone's row). */
|
|
29
|
+
[data-option-colour="dot"] .o-option[data-colour]::before {
|
|
30
|
+
content: ""; flex: none; width: calc(var(--vk-spacing) * 2); height: calc(var(--vk-spacing) * 2); margin-left: calc(var(--vk-spacing) * -0.25);
|
|
31
|
+
border-radius: var(--vk-radius-full); background-color: var(--o-option-dot);
|
|
32
|
+
}
|
|
33
|
+
[data-option-colour="dot"] .o-option.o-option-lg[data-colour]::before { width: calc(var(--vk-spacing) * 2.25); height: calc(var(--vk-spacing) * 2.25); }
|
|
34
|
+
/* Attio's pill: its colour's fill, an edge of its hue drawn inside, its words a strong step. */
|
|
35
|
+
[data-option-colour="pill"] .o-option[data-colour], .o-option[data-colour]:not([data-option-colour] *) { --tag-ground: var(--o-option-fill); --tag-edge: var(--o-option-edge); --tag-shadow: initial; color: var(--o-option-strong); }
|
|
36
|
+
/* Notion's flat fill: its colour's soft step, no edge, its words the hue. */
|
|
37
|
+
[data-option-colour="flat"] .o-option[data-colour] { --tag-ground: var(--o-option-soft); --tag-edge: transparent; --tag-shadow: none; color: var(--o-option-soft-words); }
|
|
38
|
+
/* On a fill the remove button's × takes the Option's words, under the pointer too (this outweighs the Tag's hover colour on
|
|
39
|
+
purpose), on the Tag's own hover fill; its focus ring stays the Tag's. */
|
|
40
|
+
:is([data-option-colour="pill"], [data-option-colour="flat"]) .o-option[data-colour] .o-tag-remove, .o-option[data-colour]:not([data-option-colour] *) .o-tag-remove { color: inherit; }
|
|
41
|
+
|
|
42
|
+
/* ── Its icon (after Linear): at its start the value's own mark, quiet (the Tag's icon's colour and its 1px
|
|
43
|
+
nudge), in its colour where a colour look draws one, and in Linear's dot in place of the dot, one mark and never two; at its
|
|
44
|
+
end what a press does, quieter still, on a fill the Option's words. 12px, 14 in a phone's row. While editing the end one is
|
|
45
|
+
left out, the × in its place. ─────────────────────────────────────────────────────────────────────────────── */
|
|
46
|
+
.o-option-icon { flex: none; display: inline-grid; place-items: center; width: calc(var(--vk-spacing) * 3); height: calc(var(--vk-spacing) * 3); color: var(--vk-fg-subtle); }
|
|
47
|
+
.o-option-icon > svg { width: 100%; height: 100%; }
|
|
48
|
+
.o-option-lg > .o-option-icon { width: calc(var(--vk-spacing) * 3.5); height: calc(var(--vk-spacing) * 3.5); }
|
|
49
|
+
.o-option-icon[data-side="start"] { margin-left: calc(var(--vk-spacing) * -0.25); }
|
|
50
|
+
.o-option-icon[data-side="end"] { margin-right: calc(var(--vk-spacing) * -0.25); color: var(--vk-fg-subtlest); }
|
|
51
|
+
:is([data-option-colour="dot"], [data-option-colour="pill"], [data-option-colour="flat"]) .o-option[data-colour] > .o-option-icon[data-side="start"], .o-option[data-colour]:not([data-option-colour] *) > .o-option-icon[data-side="start"] { color: var(--o-option-dot); }
|
|
52
|
+
:is([data-option-colour="pill"], [data-option-colour="flat"]) .o-option[data-colour] > .o-option-icon[data-side="end"], .o-option[data-colour]:not([data-option-colour] *) > .o-option-icon[data-side="end"] { color: inherit; }
|
|
53
|
+
[data-option-colour="dot"] .o-option[data-colour]:has(> .o-option-icon[data-side="start"])::before { content: none; }
|
|
54
|
+
/* A person's or a company's Avatar at its start (a typed Select's chip): the icon takes the Avatar's 16, 4px from the
|
|
55
|
+
chip's edge, the words 4px after it; a mark that wraps its svg once (a stage's glyph) fills the 12px icon as a bare svg does. */
|
|
56
|
+
.o-option > .o-option-icon:has(> .o-avatar) { width: auto; height: auto; margin-left: calc(var(--vk-spacing) * -1); }
|
|
57
|
+
.o-option > .o-option-icon > * > svg { width: 100%; height: 100%; }
|
|
58
|
+
|
|
59
|
+
/* ── Its shape, worn by the frame or the app around it (looks.ts), each of the kit's defaults drawing nothing of its own,
|
|
60
|
+
and Corners at lg where nothing is picked, the Outright look's pick. Height: a
|
|
61
|
+
phone's row keeps its 28, a typed Select's chips their 22 (a field 24 high holds them). Corners: Full truly round, painted as
|
|
62
|
+
before whatever its Corner smoothing (tag.css). Edge: Subtle the light edge, Grey fill a grey ground and none; a coloured Option
|
|
63
|
+
in Attio's pill or Notion's flat fill keeps its colour's own, whose rules weigh more. Each sets the Tag's variables (--tag-h,
|
|
64
|
+
--tag-r, --tag-ground, --tag-edge, --tag-shadow), which the chip and its cut draw.──────────────────────────────────────────────────────────────────────────── */
|
|
65
|
+
[data-option-height="20"] .o-option:not(.o-option-lg, .o-select-chips > *) { --tag-h: calc(var(--vk-spacing) * 5); }
|
|
66
|
+
[data-option-height="24"] .o-option:not(.o-option-lg, .o-select-chips > *) { --tag-h: calc(var(--vk-spacing) * 6); }
|
|
67
|
+
[data-option-radius="xs"] .o-option { --tag-r: var(--vk-radius-xs); }
|
|
68
|
+
[data-option-radius="sm"] .o-option { --tag-r: var(--vk-radius-sm); }
|
|
69
|
+
[data-option-radius="lg"] .o-option, .o-option:not([data-option-radius] *) { --tag-r: var(--vk-radius-lg); }
|
|
70
|
+
[data-option-radius="full"] .o-option { --tag-r: var(--vk-radius-full); }
|
|
71
|
+
[data-option-edge="subtle"] .o-option { --tag-edge: var(--vk-border); }
|
|
72
|
+
[data-option-edge="fill"] .o-option { --tag-ground: var(--vk-neutral); --tag-edge: transparent; --tag-shadow: none; }
|
|
73
|
+
|
|
74
|
+
/* ── A link (after Attio's record chips): at rest the chip as it is, its words the Option's and never
|
|
75
|
+
underlined; under the pointer the hover fill (under Grey fill a step darker; a coloured pill or flat fill its colour's fill, a
|
|
76
|
+
pill's edge its hue), pressed the pressed fill (Grey fill and a coloured fill keep their hover's) at 98%; from the keys the focus
|
|
77
|
+
ring. The states weigh (0,4,0) and more, over the colour looks' grounds. On the phone it takes taps from 44 (the pressing area the app gives it). ── */
|
|
78
|
+
.o-option[data-link] {
|
|
79
|
+
--o-option-hover: var(--vk-hovered); --o-option-pressed: var(--vk-pressed);
|
|
80
|
+
cursor: pointer; text-decoration: none; outline: none; -webkit-tap-highlight-color: transparent;
|
|
81
|
+
transition: background-color var(--vk-duration-fast) var(--vk-ease-out), box-shadow var(--vk-duration-fast) var(--vk-ease-out), scale var(--vk-duration-instant) var(--vk-ease-out);
|
|
82
|
+
}
|
|
83
|
+
[data-option-edge="fill"] .o-option[data-link] { --o-option-hover: var(--vk-neutral-hovered); --o-option-pressed: var(--vk-neutral-hovered); }
|
|
84
|
+
:is([data-option-colour="pill"], [data-option-colour="flat"]) .o-option[data-link][data-colour], .o-option[data-link][data-colour]:not([data-option-colour] *) { --o-option-hover: var(--o-option-fill); --o-option-pressed: var(--o-option-fill); }
|
|
85
|
+
.o-tag.o-option[data-link][data-force="hover"] { --tag-ground: var(--o-option-hover); }
|
|
86
|
+
@media (hover: hover) { .o-tag.o-option[data-link]:hover { --tag-ground: var(--o-option-hover); } }
|
|
87
|
+
.o-tag.o-option[data-link]:is(:active, [data-force="press"]) { --tag-ground: var(--o-option-pressed); scale: var(--vk-press-scale); }
|
|
88
|
+
[data-option-colour="pill"] .o-tag.o-option[data-link][data-colour]:is(:active, [data-force="hover"], [data-force="press"]), .o-tag.o-option[data-link][data-colour]:not([data-option-colour] *):is(:active, [data-force="hover"], [data-force="press"]) { --tag-edge: var(--o-option-dot); }
|
|
89
|
+
@media (hover: hover) { [data-option-colour="pill"] .o-tag.o-option[data-link][data-colour]:hover, .o-tag.o-option[data-link][data-colour]:not([data-option-colour] *):hover { --tag-edge: var(--o-option-dot); } }
|
|
90
|
+
.o-option[data-link]:is(:focus-visible, [data-force="focus"]) { outline: var(--vk-focus-width) solid var(--vk-border-brand); outline-offset: var(--vk-focus-offset); }
|
|
91
|
+
@media (prefers-reduced-motion: reduce) { .o-option[data-link] { transition: none; } }
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface HeaderBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
3
|
+
/** What stands on its left: Back, the menu or a sheet's X. */
|
|
4
|
+
left?: React.ReactNode;
|
|
5
|
+
/** What stands in its middle: the title. */
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
/** A quieter second line under the title: a page's or a sheet's description. */
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
/** The element that draws the description when it must be the caller's own (a sheet's Base UI Dialog.Description); a span by
|
|
10
|
+
* default. Its class and its words are the bar's. */
|
|
11
|
+
descriptionRender?: React.ReactElement;
|
|
12
|
+
/** Where its title stands, which each page and sheet chooses: centred, or at the left, after what stands there. */
|
|
13
|
+
titleAt?: "center" | "left";
|
|
14
|
+
/** What stands on its right: a ⋯, one action, or both, which stand apart or on one piece of glass as the Glass button's Two buttons says. */
|
|
15
|
+
right?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** The phone's header: a left place, the title and a right place, on the soft edge, over what scrolls. */
|
|
18
|
+
export declare function HeaderBar({ left, title, description, descriptionRender, titleAt, right, className, ...props }: HeaderBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
import { GlassButtonGroup } from "../glass-button/glass-button.js";
|
|
5
|
+
import { SoftEdge } from "./soft-edge.js";
|
|
6
|
+
export function HeaderBar({ left, title, description, descriptionRender, titleAt = "center", right, className, ...props }) {
|
|
7
|
+
const shown = useRender({ defaultTagName: "span", render: descriptionRender, props: { className: "o-hd-bar-description", children: description } });
|
|
8
|
+
return (_jsxs("div", { className: cx("o-hd-bar", className), "data-title-at": titleAt === "left" ? "left" : undefined, ...props, children: [_jsx(SoftEdge, { className: "o-hd-bar-edge" }), _jsx("span", { className: "o-hd-bar-side", children: left }), _jsxs("span", { className: "o-hd-bar-title", children: [title, description != null && shown] }), _jsx(GlassButtonGroup, { className: "o-hd-bar-side", children: right })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** What a floating head stands on, so what passes under it melts away with no line: the phone header's and a sheet's in Glass.
|
|
2
|
+
* phone-header.css draws it; what it stands in sets its height. */
|
|
3
|
+
export declare const SoftEdge: ({ className }: {
|
|
4
|
+
className?: string;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../internal/cx.js";
|
|
3
|
+
export const SoftEdge = ({ className }) => _jsxs("div", { className: cx("o-soft-edge", className), "aria-hidden": "true", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {}), _jsx("i", {})] });
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const PHONE_HEADER_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-header";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--surface-header";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-fg";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--text";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-fg-subtle";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--text-subtle";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-blur-xs";
|
|
15
|
+
readonly kind: "size";
|
|
16
|
+
readonly outright: "--blur-xs";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-blur-sm";
|
|
19
|
+
readonly kind: "size";
|
|
20
|
+
readonly outright: "--blur-sm";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-blur-md";
|
|
23
|
+
readonly kind: "size";
|
|
24
|
+
readonly outright: "--blur-md";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-spacing";
|
|
27
|
+
readonly kind: "size";
|
|
28
|
+
readonly outright: "--spacing";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-font-size-base";
|
|
31
|
+
readonly kind: "size";
|
|
32
|
+
readonly outright: "--text-base";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-line-height-base";
|
|
35
|
+
readonly kind: "size";
|
|
36
|
+
readonly outright: "--text-base--line-height";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-font-weight-semibold";
|
|
39
|
+
readonly kind: "size";
|
|
40
|
+
readonly outright: "--font-weight-semibold";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-font-size-xs";
|
|
43
|
+
readonly kind: "size";
|
|
44
|
+
readonly outright: "--text-xs";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-font-weight-normal";
|
|
47
|
+
readonly kind: "size";
|
|
48
|
+
readonly outright: "--font-weight-normal";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-font-size-sm";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--text-sm";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-line-height-sm";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--text-sm--line-height";
|
|
57
|
+
}];
|
|
58
|
+
/** The prefixes of its own machinery, set and read by it alone: not public. */
|
|
59
|
+
export declare const PHONE_HEADER_PRIVATE: readonly ["--hd-", "--soft-edge-", "--page-padding"];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const PHONE_HEADER_TOKENS = [
|
|
2
|
+
{ name: "--vk-header", kind: "colour", outright: "--surface-header" },
|
|
3
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
4
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
5
|
+
{ name: "--vk-blur-xs", kind: "size", outright: "--blur-xs" },
|
|
6
|
+
{ name: "--vk-blur-sm", kind: "size", outright: "--blur-sm" },
|
|
7
|
+
{ name: "--vk-blur-md", kind: "size", outright: "--blur-md" },
|
|
8
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
9
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
10
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
11
|
+
{ name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
|
|
12
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
13
|
+
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
14
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
15
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
16
|
+
];
|
|
17
|
+
export const PHONE_HEADER_PRIVATE = ["--hd-", "--soft-edge-", "--page-padding"];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* The phone's header bar, the one row a page and a sheet's head both draw, and the soft edge it stands on. Every value it draws
|
|
2
|
+
with is a public name (controls/phone-header/tokens.ts); this file only says which name each part takes: 44 tall on the page's
|
|
3
|
+
padding (--page-padding; in a sheet, the sheet's), its title centred between its two places, whatever stands in them, and cut
|
|
4
|
+
before it reaches them. --hd-bar-room is the room standing over it: the soft edge starts that far above it and ends just past
|
|
5
|
+
it, so it always reaches the top of what it stands in. What an app sets once is a data attribute on the frame around it
|
|
6
|
+
(looks.ts):
|
|
7
|
+
|
|
8
|
+
data-phone-header-surface glass · flat on the soft edge, or a plain ground with a smaller title
|
|
9
|
+
|
|
10
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
11
|
+
@layer components {
|
|
12
|
+
|
|
13
|
+
/* ── The soft edge: three blurs of what passes under a floating head, each fading out lower down, so the blur is strongest at
|
|
14
|
+
the top and melts into the page with no line, and over them the ground it stands on, fading to nothing. What it stands in
|
|
15
|
+
gives it its height and, in --soft-edge-ground, its ground. ── */
|
|
16
|
+
.o-soft-edge { position: absolute; inset: 0 0 auto; pointer-events: none; }
|
|
17
|
+
.o-soft-edge > i { position: absolute; inset: 0; border-radius: inherit; -webkit-mask-image: linear-gradient(to bottom, #000 var(--soft-edge-from), transparent var(--soft-edge-to)); mask-image: linear-gradient(to bottom, #000 var(--soft-edge-from), transparent var(--soft-edge-to)); }
|
|
18
|
+
.o-soft-edge > i:nth-child(1) { --soft-edge-from: 75%; --soft-edge-to: 100%; -webkit-backdrop-filter: blur(var(--vk-blur-xs)); backdrop-filter: blur(var(--vk-blur-xs)); }
|
|
19
|
+
.o-soft-edge > i:nth-child(2) { --soft-edge-from: 55%; --soft-edge-to: 85%; -webkit-backdrop-filter: blur(var(--vk-blur-sm)); backdrop-filter: blur(var(--vk-blur-sm)); }
|
|
20
|
+
.o-soft-edge > i:nth-child(3) { --soft-edge-from: 30%; --soft-edge-to: 65%; -webkit-backdrop-filter: blur(var(--vk-blur-md)); backdrop-filter: blur(var(--vk-blur-md)); }
|
|
21
|
+
.o-soft-edge > i:nth-child(4) { --soft-edge-from: 40%; --soft-edge-to: 100%; background: linear-gradient(to bottom, color-mix(in oklab, var(--soft-edge-ground, var(--vk-header)) 85%, transparent), transparent); }
|
|
22
|
+
|
|
23
|
+
.o-hd-bar {
|
|
24
|
+
position: relative; box-sizing: border-box; display: grid; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: 0;
|
|
25
|
+
grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
|
|
26
|
+
height: calc(var(--vk-spacing) * 11); padding-inline: var(--page-padding, calc(var(--vk-spacing) * 6));
|
|
27
|
+
}
|
|
28
|
+
.o-hd-bar > .o-hd-bar-edge { top: calc(-1 * var(--hd-bar-room, 0px)); height: calc(var(--hd-bar-room, 0px) + 100% + var(--vk-spacing) * 1); }
|
|
29
|
+
/* Its places stand over the soft edge. A place stands as wide as the Glass button, so the title keeps clear of an empty one. */
|
|
30
|
+
.o-hd-bar-side { position: relative; display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: calc(var(--vk-spacing) * 11); }
|
|
31
|
+
.o-hd-bar-side:last-child { justify-content: flex-end; }
|
|
32
|
+
.o-hd-bar-title {
|
|
33
|
+
position: relative; display: grid; min-width: 0; text-align: center; color: var(--vk-fg);
|
|
34
|
+
font-size: var(--vk-font-size-base); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); font-weight: var(--vk-font-weight-semibold);
|
|
35
|
+
}
|
|
36
|
+
:where(.o-hd-bar-title) > * { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; }
|
|
37
|
+
/* Its description, a quieter second line. With one, the two together stand as tall as the buttons beside them. */
|
|
38
|
+
.o-hd-bar-description { font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-spacing) * 4); font-weight: var(--vk-font-weight-normal); color: var(--vk-fg-subtle); }
|
|
39
|
+
.o-hd-bar-title > :has(+ .o-hd-bar-description) { line-height: calc(var(--vk-spacing) * 5); }
|
|
40
|
+
/* Its right place is the Glass button group (glass-button.css draws how two stand together, apart or on the glass pill). On
|
|
41
|
+
Together (the Glass button's Two buttons, its default) the place stands as wide as its two, so the pill is theirs alone; under
|
|
42
|
+
Glass, the surface's default. */
|
|
43
|
+
.o-hd-bar-side:last-child:not([data-phone-header-surface="flat"] *):not([data-glass-button-pair="separate"] *):has(.o-glass-button ~ .o-glass-button) { justify-self: end; }
|
|
44
|
+
/* Its title at the left: after what stands on its left, taking the room there is. */
|
|
45
|
+
.o-hd-bar[data-title-at="left"] { grid-template-columns: auto minmax(0, 1fr) auto; }
|
|
46
|
+
.o-hd-bar[data-title-at="left"] > .o-hd-bar-title { text-align: start; }
|
|
47
|
+
/* Flat: no soft edge, and a smaller title. What it stands on is its place's: the page's header on a page, the Sheet's in a sheet. */
|
|
48
|
+
[data-phone-header-surface="flat"] .o-hd-bar > .o-hd-bar-edge { display: none; }
|
|
49
|
+
[data-phone-header-surface="flat"] .o-hd-bar > .o-hd-bar-title { font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
50
|
+
[data-phone-header-surface="flat"] .o-hd-bar > .o-hd-bar-side { gap: calc(var(--vk-spacing) * 0.5); }
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const steps = (ids) => ids.map((id) => ({ id, name: id }));
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "corners", name: "Corners", device: "desktop", def: "xl", kind: "steps", values: steps(["lg", "xl", "2xl"]) },
|
|
4
|
+
{ id: "smoothing", name: "Corner smoothing", device: "desktop", def: "smooth", values: [{ id: "round", name: "Round" }, { id: "smooth", name: "Smooth" }] },
|
|
5
|
+
{ id: "shadow", name: "Shadow", device: "desktop", def: "md", kind: "steps", values: [{ id: "none", name: "None" }, { id: "md", name: "Medium" }, { id: "lg", name: "Large" }, { id: "xl", name: "Extra large" }] },
|
|
6
|
+
{ id: "edge", name: "Edge", device: "desktop", def: "outline", values: [{ id: "outline", name: "Outline" }, { id: "subtle", name: "Subtle" }, { id: "none", name: "None" }] },
|
|
7
|
+
{ id: "padding", name: "Padding", device: "desktop", def: "8", kind: "steps", values: steps(["0", "4", "8", "12", "16"]) },
|
|
8
|
+
{ id: "gap", name: "Gap", device: "desktop", def: "4", kind: "steps", values: steps(["0", "4", "8"]) },
|
|
9
|
+
];
|
|
10
|
+
export const POPOVER_LOOKS = { id: "popover", name: "Popover", options, looks: [] };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ViewsPopoverProps } from "../../provider/components.js";
|
|
2
|
+
/** ViewKit's popup, drawn as the kit's Popover. */
|
|
3
|
+
export declare function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, onPanelClick, panelData, style, className, children }: ViewsPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from "./popover.js";
|
|
3
|
+
export function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, onPanelClick, panelData, style, className, children }) {
|
|
4
|
+
return (_jsx(Popover, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), anchor: anchor, side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, initialFocus: initialFocus, onOutsidePress: onOutsidePress, onEscape: onEscape, style: style, onPopupClick: onPanelClick, popupData: panelData, className: className, children: children }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Anchor } from "../internal/anchor.js";
|
|
3
|
+
import { type CloseReason } from "../internal/close-reason.js";
|
|
4
|
+
/** Where it opens from when it has no trigger: an element, a ref to one, or a point on the page (a right-click's). */
|
|
5
|
+
export type PopoverAnchor = Anchor;
|
|
6
|
+
/** Why it opened or closed, by the components map's one list (ViewsCloseReason): a press on its trigger, a press outside
|
|
7
|
+
* it, Escape, focus leaving it, a row pressed inside it, a Close inside it; any other is `none`. Nothing drags it away. */
|
|
8
|
+
export type PopoverCloseReason = Exclude<CloseReason, "swipe">;
|
|
9
|
+
export interface PopoverChangeDetails {
|
|
10
|
+
reason: PopoverCloseReason;
|
|
11
|
+
/** What did it: the press, the key, the focus. */
|
|
12
|
+
event?: Event;
|
|
13
|
+
}
|
|
14
|
+
export interface PopoverProps {
|
|
15
|
+
/** Open, when it is set from outside; with onOpenChange. */
|
|
16
|
+
open?: boolean;
|
|
17
|
+
/** Open at first, when its trigger keeps its state. */
|
|
18
|
+
defaultOpen?: boolean;
|
|
19
|
+
/** It opens or closes, and why. */
|
|
20
|
+
onOpenChange?: (open: boolean, details: PopoverChangeDetails) => void;
|
|
21
|
+
/** What opens it: one element that takes a ref (a Button). Left out, it is set open from outside, from `anchor`. */
|
|
22
|
+
trigger?: React.ReactElement;
|
|
23
|
+
/** Where it opens from, when it has no trigger (a cell, a point), or another place than its trigger. */
|
|
24
|
+
anchor?: PopoverAnchor;
|
|
25
|
+
/** The side of what it opens from it stands on when there's room: below unless said. */
|
|
26
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
27
|
+
/** Where along that side: its start unless said. */
|
|
28
|
+
align?: "start" | "center" | "end";
|
|
29
|
+
/** How far along its side it moves from where `align` puts it, in px. */
|
|
30
|
+
alignOffset?: number;
|
|
31
|
+
/** How far from what it opens from it stands, in px: none unless said; a negative one lays it over what opens it (an
|
|
32
|
+
* editor over its cell), and then it takes no gap. */
|
|
33
|
+
sideOffset?: number;
|
|
34
|
+
/** Where focus goes as it opens: its first control unless said (true); false keeps focus where it was; or the
|
|
35
|
+
* element a ref holds. */
|
|
36
|
+
initialFocus?: boolean | React.RefObject<HTMLElement | null>;
|
|
37
|
+
/** Where focus goes as it closes: what opened it unless said; false leaves it. */
|
|
38
|
+
finalFocus?: boolean | React.RefObject<HTMLElement | null>;
|
|
39
|
+
/** A press outside it, before it closes: return false to keep it open. Handed the press, also when the focus that
|
|
40
|
+
* press moves is what would close it. A Tab out closes it without asking. */
|
|
41
|
+
onOutsidePress?: (event: Event) => void | false;
|
|
42
|
+
/** Escape, before it closes: return false to keep it open. */
|
|
43
|
+
onEscape?: (event: KeyboardEvent) => void | false;
|
|
44
|
+
/** What names it to a screen reader, when it has no PopoverTitle. */
|
|
45
|
+
"aria-label"?: string;
|
|
46
|
+
/** Its own style, where a class can't say it: a width that follows what it opens. */
|
|
47
|
+
style?: React.CSSProperties;
|
|
48
|
+
/** A press anywhere in it, its edge included: what holds it may stop the press there (a popover is drawn elsewhere on
|
|
49
|
+
* the page, so its presses still reach what opened it). */
|
|
50
|
+
onPopupClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
51
|
+
/** Data on it, for what finds it by its own marks (a grid's editor). */
|
|
52
|
+
popupData?: Readonly<Record<`data-${string}`, string>>;
|
|
53
|
+
/** A class on it. */
|
|
54
|
+
className?: string;
|
|
55
|
+
/** Whatever it holds. */
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
}
|
|
58
|
+
/** A shell that opens from what it belongs to: a button, a cell, a point on the page. */
|
|
59
|
+
export declare function Popover({ open, defaultOpen, onOpenChange, trigger, anchor, side, align, alignOffset, sideOffset, initialFocus, finalFocus, onOutsidePress, onEscape, "aria-label": label, style, onPopupClick, popupData, className, children, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
/** Its title, which names it to a screen reader too. */
|
|
61
|
+
export declare function PopoverTitle({ children, className }: {
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
className?: string;
|
|
64
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
/** What it says under its title, quieter. */
|
|
66
|
+
export declare function PopoverDescription({ children, className }: {
|
|
67
|
+
children: React.ReactNode;
|
|
68
|
+
className?: string;
|
|
69
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
/** What closes it from inside (a Button: `render`), with the reason close-press. */
|
|
71
|
+
export declare function PopoverClose({ render, children }: {
|
|
72
|
+
render: React.ReactElement;
|
|
73
|
+
children?: React.ReactNode;
|
|
74
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { anchorElement, isElement, positionerAnchor } from "../internal/anchor.js";
|
|
6
|
+
import { closeReasonOf } from "../internal/close-reason.js";
|
|
7
|
+
import { popupHostOf } from "../internal/popup-host.js";
|
|
8
|
+
import { Scrollbar } from "../scrollbar/scrollbar.js";
|
|
9
|
+
const reasonOf = (reason) => { const r = closeReasonOf(reason); return r === "swipe" ? "none" : r; };
|
|
10
|
+
function useLastPress(open) {
|
|
11
|
+
const last = React.useRef(null);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
if (!open)
|
|
14
|
+
return;
|
|
15
|
+
const keep = (e) => { last.current = e; };
|
|
16
|
+
const forget = () => { last.current = null; };
|
|
17
|
+
const forgetAfter = () => setTimeout(forget, 0);
|
|
18
|
+
document.addEventListener("pointerdown", keep, true);
|
|
19
|
+
document.addEventListener("click", forgetAfter, true);
|
|
20
|
+
document.addEventListener("pointercancel", forget, true);
|
|
21
|
+
document.addEventListener("keydown", forget, true);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener("pointerdown", keep, true);
|
|
24
|
+
document.removeEventListener("click", forgetAfter, true);
|
|
25
|
+
document.removeEventListener("pointercancel", forget, true);
|
|
26
|
+
document.removeEventListener("keydown", forget, true);
|
|
27
|
+
};
|
|
28
|
+
}, [open]);
|
|
29
|
+
return last;
|
|
30
|
+
}
|
|
31
|
+
function atRest(el) {
|
|
32
|
+
const r = el.getBoundingClientRect(), s = getComputedStyle(el);
|
|
33
|
+
if (!(el instanceof HTMLElement) || (s.scale === "none" && s.translate === "none"))
|
|
34
|
+
return r;
|
|
35
|
+
if (s.rotate !== "none" || s.translate.includes("%"))
|
|
36
|
+
return r;
|
|
37
|
+
const [ox = 0, oy = 0] = s.transformOrigin.split(" ").map(parseFloat);
|
|
38
|
+
const [tx = 0, ty = 0] = s.translate === "none" ? [] : s.translate.split(" ").map(parseFloat);
|
|
39
|
+
const [sx = 1, sy = sx] = s.scale === "none" ? [] : s.scale.split(" ").map(parseFloat);
|
|
40
|
+
const own = new DOMMatrix().translate(ox, oy).multiply(new DOMMatrix(s.transform === "none" ? undefined : s.transform)).translate(-ox, -oy);
|
|
41
|
+
const all = new DOMMatrix().translate(ox + tx, oy + ty).scale(sx, sy).translate(-ox, -oy).multiply(own);
|
|
42
|
+
const w = el.offsetWidth, h = el.offsetHeight;
|
|
43
|
+
if ([own, all].some((m) => m.b || m.c || m.a <= 0 || m.d <= 0) || !w || !h)
|
|
44
|
+
return r;
|
|
45
|
+
const kx = r.width / (all.a * w), ky = r.height / (all.d * h);
|
|
46
|
+
return new DOMRect(r.left + kx * (own.e - all.e), r.top + ky * (own.f - all.f), kx * own.a * w, ky * own.d * h);
|
|
47
|
+
}
|
|
48
|
+
export function Popover({ open, defaultOpen, onOpenChange, trigger, anchor, side = "bottom", align = "start", alignOffset = 0, sideOffset = 0, initialFocus = true, finalFocus, onOutsidePress, onEscape, "aria-label": label, style, onPopupClick, popupData, className, children, }) {
|
|
49
|
+
const [shown, setShown] = React.useState(open ?? defaultOpen ?? false);
|
|
50
|
+
const isOpen = open ?? shown;
|
|
51
|
+
const popup = React.useRef(null), opener = React.useRef(null);
|
|
52
|
+
const holdOpener = React.useCallback((el) => { opener.current = el; }, []);
|
|
53
|
+
const last = useLastPress(isOpen);
|
|
54
|
+
const [host, setHost] = React.useState();
|
|
55
|
+
const [from, setFrom] = React.useState(null);
|
|
56
|
+
React.useLayoutEffect(() => {
|
|
57
|
+
const next = popupHostOf(opener.current ?? anchorElement(anchor));
|
|
58
|
+
setHost((now) => (now === next ? now : next));
|
|
59
|
+
const el = anchor == null ? opener.current : anchorElement(anchor);
|
|
60
|
+
setFrom((now) => (now === el ? now : el));
|
|
61
|
+
});
|
|
62
|
+
const placed = React.useMemo(() => {
|
|
63
|
+
if (!from || (anchor != null && !isElement(anchor) && !("current" in anchor)))
|
|
64
|
+
return positionerAnchor(anchor);
|
|
65
|
+
return { getBoundingClientRect: () => atRest(from), contextElement: from };
|
|
66
|
+
}, [anchor, from]);
|
|
67
|
+
const [positioner, setPositioner] = React.useState(null);
|
|
68
|
+
const left = React.useEffectEvent(() => {
|
|
69
|
+
setShown(false);
|
|
70
|
+
onOpenChange?.(false, { reason: "none" });
|
|
71
|
+
});
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (!isOpen || !positioner)
|
|
74
|
+
return;
|
|
75
|
+
const read = () => { if (positioner.hasAttribute("data-anchor-hidden"))
|
|
76
|
+
left(); };
|
|
77
|
+
const watch = new MutationObserver(read);
|
|
78
|
+
watch.observe(positioner, { attributes: true, attributeFilter: ["data-anchor-hidden"] });
|
|
79
|
+
read();
|
|
80
|
+
return () => watch.disconnect();
|
|
81
|
+
}, [isOpen, positioner]);
|
|
82
|
+
const change = (next, details) => {
|
|
83
|
+
if (!next && details.reason === "outside-press" && onOutsidePress?.(details.event) === false)
|
|
84
|
+
return details.cancel();
|
|
85
|
+
if (!next && details.reason === "focus-out") {
|
|
86
|
+
const press = last.current;
|
|
87
|
+
const outside = press !== null && !(press.target instanceof Node && popup.current?.contains(press.target));
|
|
88
|
+
if (outside && onOutsidePress?.(press) === false)
|
|
89
|
+
return details.cancel();
|
|
90
|
+
}
|
|
91
|
+
if (!next && details.reason === "escape-key" && onEscape?.(details.event) === false)
|
|
92
|
+
return details.cancel();
|
|
93
|
+
setShown(next);
|
|
94
|
+
onOpenChange?.(next, { reason: reasonOf(details.reason), event: details.event });
|
|
95
|
+
};
|
|
96
|
+
return (_jsxs(BasePopover.Root, { open: isOpen, onOpenChange: change, children: [trigger && _jsx(BasePopover.Trigger, { ref: holdOpener, render: trigger }), _jsx(BasePopover.Portal, { container: host, children: _jsx(BasePopover.Positioner, { ref: setPositioner, className: "o-popover-positioner", anchor: placed, positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, children: _jsxs(BasePopover.Popup, { ref: popup, className: cx("o-popover", className), "data-kit": "popover", "aria-label": label, initialFocus: initialFocus, finalFocus: finalFocus, style: style, onClick: onPopupClick, "data-over": sideOffset < 0 ? "" : undefined, ...popupData, children: [_jsx("div", { className: "o-popover-cut o-smooth", children: children }), _jsx(Scrollbar, {})] }) }) })] }));
|
|
97
|
+
}
|
|
98
|
+
export function PopoverTitle({ children, className }) {
|
|
99
|
+
return _jsx(BasePopover.Title, { className: cx("o-popover-title", className), children: children });
|
|
100
|
+
}
|
|
101
|
+
export function PopoverDescription({ children, className }) {
|
|
102
|
+
return _jsx(BasePopover.Description, { className: cx("o-popover-description", className), children: children });
|
|
103
|
+
}
|
|
104
|
+
export function PopoverClose({ render, children }) {
|
|
105
|
+
return _jsx(BasePopover.Close, { render: render, children: children });
|
|
106
|
+
}
|