@underpin/ui 0.0.0-stage → 2.0.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/LICENSE +21 -0
- package/README.md +45 -2
- package/components/autocomplete.d.ts +25 -0
- package/components/autocomplete.js +71 -0
- package/components/autocomplete.js.map +1 -0
- package/components/avatar.d.ts +5 -0
- package/components/avatar.js +26 -0
- package/components/avatar.js.map +1 -0
- package/components/badge.d.ts +36 -0
- package/components/badge.js +140 -0
- package/components/badge.js.map +1 -0
- package/components/bar-list.d.ts +133 -0
- package/components/bar-list.js +204 -0
- package/components/bar-list.js.map +1 -0
- package/components/breakdown-card.d.ts +30 -0
- package/components/breakdown-card.js +43 -0
- package/components/breakdown-card.js.map +1 -0
- package/components/button-group.d.ts +17 -0
- package/components/button-group.js +27 -0
- package/components/button-group.js.map +1 -0
- package/components/button.d.ts +39 -0
- package/components/button.js +128 -0
- package/components/button.js.map +1 -0
- package/components/calendar.d.ts +27 -0
- package/components/calendar.js +95 -0
- package/components/calendar.js.map +1 -0
- package/components/callout.d.ts +26 -0
- package/components/callout.js +71 -0
- package/components/callout.js.map +1 -0
- package/components/card.d.ts +55 -0
- package/components/card.js +96 -0
- package/components/card.js.map +1 -0
- package/components/chart.d.ts +32 -0
- package/components/chart.js +43 -0
- package/components/chart.js.map +1 -0
- package/components/checkbox.d.ts +15 -0
- package/components/checkbox.js +42 -0
- package/components/checkbox.js.map +1 -0
- package/components/code-block.d.ts +21 -0
- package/components/code-block.js +35 -0
- package/components/code-block.js.map +1 -0
- package/components/collapse.d.ts +14 -0
- package/components/collapse.js +25 -0
- package/components/collapse.js.map +1 -0
- package/components/combobox.d.ts +71 -0
- package/components/combobox.js +155 -0
- package/components/combobox.js.map +1 -0
- package/components/copy-button.d.ts +29 -0
- package/components/copy-button.js +100 -0
- package/components/copy-button.js.map +1 -0
- package/components/copy-input.d.ts +15 -0
- package/components/copy-input.js +51 -0
- package/components/copy-input.js.map +1 -0
- package/components/date-picker-trigger.d.ts +12 -0
- package/components/date-picker-trigger.js +30 -0
- package/components/date-picker-trigger.js.map +1 -0
- package/components/date-picker.d.ts +36 -0
- package/components/date-picker.js +70 -0
- package/components/date-picker.js.map +1 -0
- package/components/detail-row.d.ts +51 -0
- package/components/detail-row.js +77 -0
- package/components/detail-row.js.map +1 -0
- package/components/dialog.d.ts +121 -0
- package/components/dialog.js +327 -0
- package/components/dialog.js.map +1 -0
- package/components/disabled-reason.d.ts +31 -0
- package/components/disabled-reason.js +67 -0
- package/components/disabled-reason.js.map +1 -0
- package/components/empty-state.d.ts +41 -0
- package/components/empty-state.js +84 -0
- package/components/empty-state.js.map +1 -0
- package/components/entity-avatar.d.ts +54 -0
- package/components/entity-avatar.js +68 -0
- package/components/entity-avatar.js.map +1 -0
- package/components/form-section.d.ts +22 -0
- package/components/form-section.js +38 -0
- package/components/form-section.js.map +1 -0
- package/components/form.d.ts +199 -0
- package/components/form.js +456 -0
- package/components/form.js.map +1 -0
- package/components/formatted-number.d.ts +21 -0
- package/components/formatted-number.js +13 -0
- package/components/formatted-number.js.map +1 -0
- package/components/heading.d.ts +23 -0
- package/components/heading.js +44 -0
- package/components/heading.js.map +1 -0
- package/components/icon-swap.d.ts +15 -0
- package/components/icon-swap.js +29 -0
- package/components/icon-swap.js.map +1 -0
- package/components/inline-action.d.ts +21 -0
- package/components/inline-action.js +36 -0
- package/components/inline-action.js.map +1 -0
- package/components/input.d.ts +51 -0
- package/components/input.js +52 -0
- package/components/input.js.map +1 -0
- package/components/kbd.d.ts +17 -0
- package/components/kbd.js +34 -0
- package/components/kbd.js.map +1 -0
- package/components/label.d.ts +10 -0
- package/components/label.js +20 -0
- package/components/label.js.map +1 -0
- package/components/menu.d.ts +77 -0
- package/components/menu.js +189 -0
- package/components/menu.js.map +1 -0
- package/components/nav-button.d.ts +34 -0
- package/components/nav-button.js +71 -0
- package/components/nav-button.js.map +1 -0
- package/components/nav.d.ts +39 -0
- package/components/nav.js +68 -0
- package/components/nav.js.map +1 -0
- package/components/number-input.d.ts +16 -0
- package/components/number-input.js +25 -0
- package/components/number-input.js.map +1 -0
- package/components/page.d.ts +14 -0
- package/components/page.js +23 -0
- package/components/page.js.map +1 -0
- package/components/pagination.d.ts +15 -0
- package/components/pagination.js +63 -0
- package/components/pagination.js.map +1 -0
- package/components/ping.d.ts +38 -0
- package/components/ping.js +50 -0
- package/components/ping.js.map +1 -0
- package/components/popover.d.ts +5 -0
- package/components/popover.js +25 -0
- package/components/popover.js.map +1 -0
- package/components/radio-group.d.ts +35 -0
- package/components/radio-group.js +81 -0
- package/components/radio-group.js.map +1 -0
- package/components/relative-time.d.ts +25 -0
- package/components/relative-time.js +51 -0
- package/components/relative-time.js.map +1 -0
- package/components/saved-mark.d.ts +15 -0
- package/components/saved-mark.js +45 -0
- package/components/saved-mark.js.map +1 -0
- package/components/search-input.d.ts +13 -0
- package/components/search-input.js +44 -0
- package/components/search-input.js.map +1 -0
- package/components/section-header.d.ts +83 -0
- package/components/section-header.js +170 -0
- package/components/section-header.js.map +1 -0
- package/components/segmented-control.d.ts +24 -0
- package/components/segmented-control.js +70 -0
- package/components/segmented-control.js.map +1 -0
- package/components/select.d.ts +28 -0
- package/components/select.js +129 -0
- package/components/select.js.map +1 -0
- package/components/shortcut-keys.d.ts +14 -0
- package/components/shortcut-keys.js +32 -0
- package/components/shortcut-keys.js.map +1 -0
- package/components/shortcuts-dialog.d.ts +10 -0
- package/components/shortcuts-dialog.js +92 -0
- package/components/shortcuts-dialog.js.map +1 -0
- package/components/skeleton.d.ts +8 -0
- package/components/skeleton.js +23 -0
- package/components/skeleton.js.map +1 -0
- package/components/sparkline.d.ts +25 -0
- package/components/sparkline.js +70 -0
- package/components/sparkline.js.map +1 -0
- package/components/stack.d.ts +21 -0
- package/components/stack.js +45 -0
- package/components/stack.js.map +1 -0
- package/components/stat-strip.d.ts +43 -0
- package/components/stat-strip.js +151 -0
- package/components/stat-strip.js.map +1 -0
- package/components/steps.d.ts +19 -0
- package/components/steps.js +25 -0
- package/components/steps.js.map +1 -0
- package/components/switch.d.ts +16 -0
- package/components/switch.js +29 -0
- package/components/switch.js.map +1 -0
- package/components/tabs.d.ts +18 -0
- package/components/tabs.js +65 -0
- package/components/tabs.js.map +1 -0
- package/components/text-link.d.ts +16 -0
- package/components/text-link.js +32 -0
- package/components/text-link.js.map +1 -0
- package/components/textarea.d.ts +10 -0
- package/components/textarea.js +23 -0
- package/components/textarea.js.map +1 -0
- package/components/theme.d.ts +28 -0
- package/components/theme.js +158 -0
- package/components/theme.js.map +1 -0
- package/components/time-series-chart.d.ts +122 -0
- package/components/time-series-chart.js +722 -0
- package/components/time-series-chart.js.map +1 -0
- package/components/toaster.d.ts +3 -0
- package/components/toaster.js +44 -0
- package/components/toaster.js.map +1 -0
- package/components/tooltip.d.ts +64 -0
- package/components/tooltip.js +126 -0
- package/components/tooltip.js.map +1 -0
- package/components/view-picker.d.ts +20 -0
- package/components/view-picker.js +24 -0
- package/components/view-picker.js.map +1 -0
- package/fonts/inter-OFL.txt +93 -0
- package/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/fonts/inter-cyrillic.woff2 +0 -0
- package/fonts/inter-greek-ext.woff2 +0 -0
- package/fonts/inter-greek.woff2 +0 -0
- package/fonts/inter-latin-ext.woff2 +0 -0
- package/fonts/inter-latin.woff2 +0 -0
- package/fonts/inter-vietnamese.woff2 +0 -0
- package/fonts.css +83 -0
- package/lib/animation.d.ts +14 -0
- package/lib/animation.js +20 -0
- package/lib/animation.js.map +1 -0
- package/lib/aria.d.ts +5 -0
- package/lib/aria.js +12 -0
- package/lib/aria.js.map +1 -0
- package/lib/chart-curve.d.ts +13 -0
- package/lib/chart-curve.js +79 -0
- package/lib/chart-curve.js.map +1 -0
- package/lib/classes.d.ts +134 -0
- package/lib/classes.js +152 -0
- package/lib/classes.js.map +1 -0
- package/lib/color.d.ts +25 -0
- package/lib/color.js +149 -0
- package/lib/color.js.map +1 -0
- package/lib/day.d.ts +9 -0
- package/lib/day.js +20 -0
- package/lib/day.js.map +1 -0
- package/lib/design-tokens.d.ts +56 -0
- package/lib/design-tokens.js +196 -0
- package/lib/design-tokens.js.map +1 -0
- package/lib/icon.d.ts +17 -0
- package/lib/icon.js +34 -0
- package/lib/icon.js.map +1 -0
- package/lib/icons.d.ts +23 -0
- package/lib/icons.js +28 -0
- package/lib/icons.js.map +1 -0
- package/lib/interactive.d.ts +21 -0
- package/lib/interactive.js +31 -0
- package/lib/interactive.js.map +1 -0
- package/lib/media.d.ts +58 -0
- package/lib/media.js +116 -0
- package/lib/media.js.map +1 -0
- package/lib/segmented.d.ts +57 -0
- package/lib/segmented.js +83 -0
- package/lib/segmented.js.map +1 -0
- package/lib/shortcuts.d.ts +94 -0
- package/lib/shortcuts.js +271 -0
- package/lib/shortcuts.js.map +1 -0
- package/lib/slot.d.ts +9 -0
- package/lib/slot.js +18 -0
- package/lib/slot.js.map +1 -0
- package/lib/time-series.d.ts +100 -0
- package/lib/time-series.js +144 -0
- package/lib/time-series.js.map +1 -0
- package/lib/tone.d.ts +6 -0
- package/lib/tone.js +0 -0
- package/lib/variants.d.ts +12 -0
- package/lib/variants.js +14 -0
- package/lib/variants.js.map +1 -0
- package/package.json +116 -4
- package/styles.css +619 -0
- package/tokens.d.ts +104 -0
- package/tokens.js +108 -0
- package/tokens.js.map +1 -0
package/fonts.css
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Generated by `scripts/fonts.py` at the repo root, which says when to run it again. Edit
|
|
3
|
+
* the script, not this file. One file per script; the browser fetches a file only for a
|
|
4
|
+
* character in its `unicode-range`, and `apps/web/index.html` preloads the Latin one.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
@font-face {
|
|
8
|
+
font-family: "Inter Variable";
|
|
9
|
+
font-style: normal;
|
|
10
|
+
font-display: swap;
|
|
11
|
+
font-weight: 100 900;
|
|
12
|
+
src: url("./fonts/inter-cyrillic-ext.woff2") format("woff2-variations");
|
|
13
|
+
unicode-range: U+460-479, U+480-49D, U+4A0-4FF, U+52F, U+20B4, U+2DFF, U+A69F;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@font-face {
|
|
17
|
+
font-family: "Inter Variable";
|
|
18
|
+
font-style: normal;
|
|
19
|
+
font-display: swap;
|
|
20
|
+
font-weight: 100 900;
|
|
21
|
+
src: url("./fonts/inter-cyrillic.woff2") format("woff2-variations");
|
|
22
|
+
unicode-range: U+301, U+400-45F, U+490-491, U+4B0-4B1, U+2116;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@font-face {
|
|
26
|
+
font-family: "Inter Variable";
|
|
27
|
+
font-style: normal;
|
|
28
|
+
font-display: swap;
|
|
29
|
+
font-weight: 100 900;
|
|
30
|
+
src: url("./fonts/inter-greek-ext.woff2") format("woff2-variations");
|
|
31
|
+
unicode-range:
|
|
32
|
+
U+1F00-1F15, U+1F18-1F1D, U+1F20-1F45, U+1F48-1F4D, U+1F50-1F57, U+1F59, U+1F5B, U+1F5D,
|
|
33
|
+
U+1F5F-1F7D, U+1F80-1FB4, U+1FB6-1FC4, U+1FC6-1FD3, U+1FD6-1FDB, U+1FDD-1FEF, U+1FF2-1FF4,
|
|
34
|
+
U+1FF6-1FFE;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: "Inter Variable";
|
|
39
|
+
font-style: normal;
|
|
40
|
+
font-display: swap;
|
|
41
|
+
font-weight: 100 900;
|
|
42
|
+
src: url("./fonts/inter-greek.woff2") format("woff2-variations");
|
|
43
|
+
unicode-range:
|
|
44
|
+
U+374-376, U+37A-37F, U+384-38A, U+38C, U+38E-3A1, U+3A3-3D7, U+3DC-3DD, U+3F0-3F6, U+3F9-3FA,
|
|
45
|
+
U+3FC-3FF;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@font-face {
|
|
49
|
+
font-family: "Inter Variable";
|
|
50
|
+
font-style: normal;
|
|
51
|
+
font-display: swap;
|
|
52
|
+
font-weight: 100 900;
|
|
53
|
+
src: url("./fonts/inter-vietnamese.woff2") format("woff2-variations");
|
|
54
|
+
unicode-range:
|
|
55
|
+
U+102-103, U+110-111, U+128-129, U+168-169, U+1A0-1A1, U+1AF-1B0, U+300-301, U+303-304,
|
|
56
|
+
U+308-309, U+323, U+1EA0-1EF9, U+20AB;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@font-face {
|
|
60
|
+
font-family: "Inter Variable";
|
|
61
|
+
font-style: normal;
|
|
62
|
+
font-display: swap;
|
|
63
|
+
font-weight: 100 900;
|
|
64
|
+
src: url("./fonts/inter-latin-ext.woff2") format("woff2-variations");
|
|
65
|
+
unicode-range:
|
|
66
|
+
U+100-148, U+14A-1C3, U+1C5-254, U+256-27B, U+27E-284, U+286-290, U+292-2A4, U+2A6-2BA,
|
|
67
|
+
U+2BD-2C5, U+2C7-2CC, U+2CE-2D7, U+2DD-2FF, U+304, U+308, U+1D00, U+1D0D, U+1D1B, U+1D43,
|
|
68
|
+
U+1D47-1D49, U+1D4D, U+1D4F-1D50, U+1D52, U+1D56-1D58, U+1D5B, U+1D62-1D65, U+1D9C, U+1DA0,
|
|
69
|
+
U+1DBB, U+1DBF, U+1E00-1E9B, U+1E9D-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20AF,
|
|
70
|
+
U+20B1-20B5, U+20B8-20BA, U+20BC-20BF, U+2113, U+2C7C, U+2C7F, U+A7FF;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@font-face {
|
|
74
|
+
font-family: "Inter Variable";
|
|
75
|
+
font-style: normal;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
font-weight: 100 900;
|
|
78
|
+
src: url("./fonts/inter-latin.woff2") format("woff2-variations");
|
|
79
|
+
unicode-range:
|
|
80
|
+
U+0, U+20-7E, U+A0-AC, U+AE-FF, U+131, U+152-153, U+2BB-2BC, U+2C6, U+2DA, U+2DC, U+304, U+308,
|
|
81
|
+
U+2000-200B, U+2010-2027, U+202F-2055, U+2057, U+205F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
82
|
+
U+FEFF;
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timing for the JS-driven chart updates, matching the CSS transitions. `easeOutExpo` is the
|
|
3
|
+
* curve behind the `--ease-out-expo` CSS token; JS cannot read a Tailwind theme token, so the
|
|
4
|
+
* curve is restated here, and a change to one is a change to both. The chart renderer honours
|
|
5
|
+
* `prefers-reduced-motion` on its own.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ANIMATION_DURATION = 250;
|
|
8
|
+
export declare function easeOutExpo(progress: number): number;
|
|
9
|
+
/** The tween every chart moves with, in the shape the chart renderer's `motion()` takes. */
|
|
10
|
+
export declare const CHART_TRANSITION: {
|
|
11
|
+
readonly type: "tween";
|
|
12
|
+
readonly duration: 250;
|
|
13
|
+
readonly easing: typeof easeOutExpo;
|
|
14
|
+
};
|
package/lib/animation.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/lib/animation.ts
|
|
2
|
+
/**
|
|
3
|
+
* Timing for the JS-driven chart updates, matching the CSS transitions. `easeOutExpo` is the
|
|
4
|
+
* curve behind the `--ease-out-expo` CSS token; JS cannot read a Tailwind theme token, so the
|
|
5
|
+
* curve is restated here, and a change to one is a change to both. The chart renderer honours
|
|
6
|
+
* `prefers-reduced-motion` on its own.
|
|
7
|
+
*/
|
|
8
|
+
const ANIMATION_DURATION = 250;
|
|
9
|
+
function easeOutExpo(progress) {
|
|
10
|
+
return progress >= 1 ? 1 : 1 - 2 ** (-10 * progress);
|
|
11
|
+
}
|
|
12
|
+
/** The tween every chart moves with, in the shape the chart renderer's `motion()` takes. */
|
|
13
|
+
const CHART_TRANSITION = {
|
|
14
|
+
type: "tween",
|
|
15
|
+
duration: 250,
|
|
16
|
+
easing: easeOutExpo
|
|
17
|
+
};
|
|
18
|
+
export { ANIMATION_DURATION, CHART_TRANSITION, easeOutExpo };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.js","names":[],"sources":["../../src/lib/animation.ts"],"sourcesContent":["/**\n * Timing for the JS-driven chart updates, matching the CSS transitions. `easeOutExpo` is the\n * curve behind the `--ease-out-expo` CSS token; JS cannot read a Tailwind theme token, so the\n * curve is restated here, and a change to one is a change to both. The chart renderer honours\n * `prefers-reduced-motion` on its own.\n */\nexport const ANIMATION_DURATION = 250\n\nexport function easeOutExpo(progress: number) {\n return progress >= 1 ? 1 : 1 - 2 ** (-10 * progress)\n}\n\n/** The tween every chart moves with, in the shape the chart renderer's `motion()` takes. */\nexport const CHART_TRANSITION = {\n type: \"tween\",\n duration: ANIMATION_DURATION,\n easing: easeOutExpo,\n} as const\n"],"mappings":";;;;;;;AAMA,MAAa,qBAAqB;AAElC,SAAgB,YAAY,UAAkB;CAC5C,OAAO,YAAY,IAAI,IAAI,IAAI,MAAM,MAAM;AAC7C;;AAGA,MAAa,mBAAmB;CAC9B,MAAM;CACN,UAAA;CACA,QAAQ;AACV"}
|
package/lib/aria.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An id list for `aria-describedby` or `aria-labelledby`, skipping the parts that are not on
|
|
3
|
+
* screen; `undefined` when none are, so the attribute is left off.
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatIdList(...ids: (string | false | undefined)[]): string | undefined;
|
package/lib/aria.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/lib/aria.ts
|
|
2
|
+
/**
|
|
3
|
+
* An id list for `aria-describedby` or `aria-labelledby`, skipping the parts that are not on
|
|
4
|
+
* screen; `undefined` when none are, so the attribute is left off.
|
|
5
|
+
*/
|
|
6
|
+
function formatIdList(...ids) {
|
|
7
|
+
const shown = ids.filter(Boolean);
|
|
8
|
+
return shown.length ? shown.join(" ") : void 0;
|
|
9
|
+
}
|
|
10
|
+
export { formatIdList };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=aria.js.map
|
package/lib/aria.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.js","names":[],"sources":["../../src/lib/aria.ts"],"sourcesContent":["/**\n * An id list for `aria-describedby` or `aria-labelledby`, skipping the parts that are not on\n * screen; `undefined` when none are, so the attribute is left off.\n */\nexport function formatIdList(...ids: (string | false | undefined)[]) {\n const shown = ids.filter(Boolean)\n return shown.length ? shown.join(\" \") : undefined\n}\n"],"mappings":";;;;;AAIA,SAAgB,aAAa,GAAG,KAAqC;CACnE,MAAM,QAAQ,IAAI,OAAO,OAAO;CAChC,OAAO,MAAM,SAAS,MAAM,KAAK,GAAG,IAAI,KAAA;AAC1C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CurveFactory } from "d3-shape";
|
|
2
|
+
import { ChartCurve } from "@tanstack/charts";
|
|
3
|
+
/**
|
|
4
|
+
* One curve split around a series' partial buckets: `complete` draws the line between the
|
|
5
|
+
* finished buckets, and `running` the first `leadingBuckets` segments and the last
|
|
6
|
+
* `runningBuckets`. Both trace the curve the whole series makes, so the parts meet on one
|
|
7
|
+
* tangent and run along the edge of an area drawn under the whole series; parts drawn as series
|
|
8
|
+
* of their own would each bend on their own. The area of both is the whole series' area.
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitCurve(factory: CurveFactory, runningBuckets: number, leadingBuckets?: number): {
|
|
11
|
+
complete: ChartCurve;
|
|
12
|
+
running: ChartCurve;
|
|
13
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { line } from "d3-shape";
|
|
2
|
+
import { d3Curve } from "@tanstack/charts/d3/shape";
|
|
3
|
+
// src/lib/chart-curve.ts
|
|
4
|
+
/** A coordinate as d3 writes it into a path: three decimals. */
|
|
5
|
+
function round(value) {
|
|
6
|
+
return Math.round(value * 1e3) / 1e3;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The path of a line through every point, as `factory` bends it, keeping only the segments `keep`
|
|
10
|
+
* accepts: the segment from point `index` to the next is `index`, out of `count`. A run of kept
|
|
11
|
+
* segments starts where its first segment starts, so it carries the tangents the whole line has
|
|
12
|
+
* there rather than bending as a line of its own would.
|
|
13
|
+
*/
|
|
14
|
+
function drawSegments(points, factory, keep) {
|
|
15
|
+
const count = Math.max(points.length - 1, 0);
|
|
16
|
+
let path = "";
|
|
17
|
+
let index = 0;
|
|
18
|
+
let open = false;
|
|
19
|
+
let currentX = 0;
|
|
20
|
+
let currentY = 0;
|
|
21
|
+
function draw(command, endX, endY) {
|
|
22
|
+
if (keep(index, count)) {
|
|
23
|
+
if (!open) path += `M${round(currentX)},${round(currentY)}`;
|
|
24
|
+
path += command;
|
|
25
|
+
open = true;
|
|
26
|
+
} else open = false;
|
|
27
|
+
index += 1;
|
|
28
|
+
currentX = endX;
|
|
29
|
+
currentY = endY;
|
|
30
|
+
}
|
|
31
|
+
line().x((point) => point[0]).y((point) => point[1]).curve(factory).context({
|
|
32
|
+
moveTo(toX, toY) {
|
|
33
|
+
currentX = toX;
|
|
34
|
+
currentY = toY;
|
|
35
|
+
open = false;
|
|
36
|
+
},
|
|
37
|
+
lineTo(toX, toY) {
|
|
38
|
+
draw(`L${round(toX)},${round(toY)}`, toX, toY);
|
|
39
|
+
},
|
|
40
|
+
bezierCurveTo(x1, y1, x2, y2, toX, toY) {
|
|
41
|
+
draw(`C${[
|
|
42
|
+
x1,
|
|
43
|
+
y1,
|
|
44
|
+
x2,
|
|
45
|
+
y2,
|
|
46
|
+
toX,
|
|
47
|
+
toY
|
|
48
|
+
].map(round).join(",")}`, toX, toY);
|
|
49
|
+
},
|
|
50
|
+
closePath() {}
|
|
51
|
+
})(points);
|
|
52
|
+
return path;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One curve split around a series' partial buckets: `complete` draws the line between the
|
|
56
|
+
* finished buckets, and `running` the first `leadingBuckets` segments and the last
|
|
57
|
+
* `runningBuckets`. Both trace the curve the whole series makes, so the parts meet on one
|
|
58
|
+
* tangent and run along the edge of an area drawn under the whole series; parts drawn as series
|
|
59
|
+
* of their own would each bend on their own. The area of both is the whole series' area.
|
|
60
|
+
*/
|
|
61
|
+
function splitCurve(factory, runningBuckets, leadingBuckets = 0) {
|
|
62
|
+
const whole = d3Curve(factory);
|
|
63
|
+
function isComplete(index, count) {
|
|
64
|
+
return index >= leadingBuckets && index < count - runningBuckets;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
complete: {
|
|
68
|
+
line: (points) => drawSegments(points, factory, isComplete),
|
|
69
|
+
area: whole.area
|
|
70
|
+
},
|
|
71
|
+
running: {
|
|
72
|
+
line: (points) => drawSegments(points, factory, (index, count) => !isComplete(index, count)),
|
|
73
|
+
area: whole.area
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { splitCurve };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=chart-curve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-curve.js","names":[],"sources":["../../src/lib/chart-curve.ts"],"sourcesContent":["import type { ChartCurve } from \"@tanstack/charts\"\nimport { d3Curve } from \"@tanstack/charts/d3/shape\"\nimport { type CurveFactory, line } from \"d3-shape\"\n\ntype Point = readonly [number, number]\n\n/** A coordinate as d3 writes it into a path: three decimals. */\nfunction round(value: number) {\n return Math.round(value * 1000) / 1000\n}\n\n/**\n * The path of a line through every point, as `factory` bends it, keeping only the segments `keep`\n * accepts: the segment from point `index` to the next is `index`, out of `count`. A run of kept\n * segments starts where its first segment starts, so it carries the tangents the whole line has\n * there rather than bending as a line of its own would.\n */\nfunction drawSegments(\n points: readonly Point[],\n factory: CurveFactory,\n keep: (index: number, count: number) => boolean,\n) {\n const count = Math.max(points.length - 1, 0)\n let path = \"\"\n let index = 0\n let open = false\n // Where the last segment ended, which is where the next one starts.\n let currentX = 0\n let currentY = 0\n\n function draw(command: string, endX: number, endY: number) {\n if (keep(index, count)) {\n if (!open) path += `M${round(currentX)},${round(currentY)}`\n path += command\n open = true\n } else {\n open = false\n }\n index += 1\n currentX = endX\n currentY = endY\n }\n\n // A canvas context in shape only: the curve draws into it, and it writes the path's commands.\n const context = {\n moveTo(toX: number, toY: number) {\n currentX = toX\n currentY = toY\n open = false\n },\n lineTo(toX: number, toY: number) {\n draw(`L${round(toX)},${round(toY)}`, toX, toY)\n },\n bezierCurveTo(x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const values = [x1, y1, x2, y2, toX, toY].map(round).join(\",\")\n draw(`C${values}`, toX, toY)\n },\n closePath() {},\n }\n\n line<Point>()\n .x(point => point[0])\n .y(point => point[1])\n .curve(factory)\n .context(context as unknown as CanvasRenderingContext2D)(points)\n\n return path\n}\n\n/**\n * One curve split around a series' partial buckets: `complete` draws the line between the\n * finished buckets, and `running` the first `leadingBuckets` segments and the last\n * `runningBuckets`. Both trace the curve the whole series makes, so the parts meet on one\n * tangent and run along the edge of an area drawn under the whole series; parts drawn as series\n * of their own would each bend on their own. The area of both is the whole series' area.\n */\nexport function splitCurve(\n factory: CurveFactory,\n runningBuckets: number,\n leadingBuckets = 0,\n): { complete: ChartCurve; running: ChartCurve } {\n const whole = d3Curve(factory)\n\n function isComplete(index: number, count: number) {\n return index >= leadingBuckets && index < count - runningBuckets\n }\n\n return {\n complete: {\n line: points => drawSegments(points, factory, isComplete),\n area: whole.area,\n },\n running: {\n line: points => drawSegments(points, factory, (index, count) => !isComplete(index, count)),\n area: whole.area,\n },\n }\n}\n"],"mappings":";;;;AAOA,SAAS,MAAM,OAAe;CAC5B,OAAO,KAAK,MAAM,QAAQ,GAAI,IAAI;AACpC;;;;;;;AAQA,SAAS,aACP,QACA,SACA,MACA;CACA,MAAM,QAAQ,KAAK,IAAI,OAAO,SAAS,GAAG,CAAC;CAC3C,IAAI,OAAO;CACX,IAAI,QAAQ;CACZ,IAAI,OAAO;CAEX,IAAI,WAAW;CACf,IAAI,WAAW;CAEf,SAAS,KAAK,SAAiB,MAAc,MAAc;EACzD,IAAI,KAAK,OAAO,KAAK,GAAG;GACtB,IAAI,CAAC,MAAM,QAAQ,IAAI,MAAM,QAAQ,EAAE,GAAG,MAAM,QAAQ;GACxD,QAAQ;GACR,OAAO;EACT,OACE,OAAO;EAET,SAAS;EACT,WAAW;EACX,WAAW;CACb;CAmBA,KAAY,CAAC,CACV,GAAE,UAAS,MAAM,EAAE,CAAC,CACpB,GAAE,UAAS,MAAM,EAAE,CAAC,CACpB,MAAM,OAAO,CAAC,CACd,QAAQ;EAnBT,OAAO,KAAa,KAAa;GAC/B,WAAW;GACX,WAAW;GACX,OAAO;EACT;EACA,OAAO,KAAa,KAAa;GAC/B,KAAK,IAAI,MAAM,GAAG,EAAE,GAAG,MAAM,GAAG,KAAK,KAAK,GAAG;EAC/C;EACA,cAAc,IAAY,IAAY,IAAY,IAAY,KAAa,KAAa;GAEtF,KAAK,IADU;IAAC;IAAI;IAAI;IAAI;IAAI;IAAK;GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,GAC5C,KAAK,KAAK,GAAG;EAC7B;EACA,YAAY,CAAC;CAOE,CAAwC,CAAC,CAAC,MAAM;CAEjE,OAAO;AACT;;;;;;;;AASA,SAAgB,WACd,SACA,gBACA,iBAAiB,GAC8B;CAC/C,MAAM,QAAQ,QAAQ,OAAO;CAE7B,SAAS,WAAW,OAAe,OAAe;EAChD,OAAO,SAAS,kBAAkB,QAAQ,QAAQ;CACpD;CAEA,OAAO;EACL,UAAU;GACR,OAAM,WAAU,aAAa,QAAQ,SAAS,UAAU;GACxD,MAAM,MAAM;EACd;EACA,SAAS;GACP,OAAM,WAAU,aAAa,QAAQ,UAAU,OAAO,UAAU,CAAC,WAAW,OAAO,KAAK,CAAC;GACzF,MAAM,MAAM;EACd;CACF;AACF"}
|
package/lib/classes.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enter/exit animation classes for Base UI popups (Menu, Select, Popover, …).
|
|
3
|
+
* Keyed on Base UI's `data-open`/`data-closed` state attributes and the positioner's
|
|
4
|
+
* `data-[side=*]`, with the zoom anchored to the `--transform-origin` Base UI exposes on
|
|
5
|
+
* the popup. Animation utilities (and their `duration-*`/`ease-*` bindings) come from
|
|
6
|
+
* `tailwindcss-animate`.
|
|
7
|
+
*
|
|
8
|
+
* The `data-closed` animation is essential: Base UI keeps the popup mounted until the
|
|
9
|
+
* exit animation finishes, so without it there is no close animation at all. The exit holds its
|
|
10
|
+
* last frame (`fill-mode-forwards`): a keyframe animation otherwise hands the popup back to full
|
|
11
|
+
* opacity the moment it ends, and any frame painted before the unmount flashes the whole panel.
|
|
12
|
+
*
|
|
13
|
+
* Feel: a 97% zoom out of the trigger and an 8px directional slide. Enter is 150ms on
|
|
14
|
+
* `--ease-out-expo`; exit is a plainer, faster 100ms ease-out, since a popup on its way out has
|
|
15
|
+
* nothing to announce. `data-instant` collapses the duration to 0 so Base UI's instant transitions
|
|
16
|
+
* (keyboard nav between items, grouped tooltips) don't stutter.
|
|
17
|
+
*/
|
|
18
|
+
export declare const popoverAnimationClasses: string[];
|
|
19
|
+
/**
|
|
20
|
+
* How a tooltip comes and goes. Transitions rather than the popups' keyframes, so a pointer that
|
|
21
|
+
* leaves and returns mid-way turns the panel around from where it is instead of restarting it.
|
|
22
|
+
* The panel grows out of its arrow's tip (`--transform-origin`) from 96% while it fades in, and
|
|
23
|
+
* only fades on the way out, faster than it came: nothing travels, since a tooltip opens on
|
|
24
|
+
* every pass of the pointer and movement there costs attention each time. The scale is left out
|
|
25
|
+
* for a reader who asks for reduced motion, and `data-instant` (a keyboard focus, a sibling
|
|
26
|
+
* taking over within the provider's timeout, a dismissal) skips the transition altogether.
|
|
27
|
+
*/
|
|
28
|
+
export declare const tooltipAnimationClasses: string[];
|
|
29
|
+
/**
|
|
30
|
+
* The invisible layer between an anchored popup (a menu, a select, a popover) and the page. A
|
|
31
|
+
* mouse passes through it, so one click closes the popup and reaches the control underneath. A
|
|
32
|
+
* finger stops on it: a tap meant to dismiss the popup must not land on a link, and `touch-none`
|
|
33
|
+
* stops a drag beside the popup from scrolling the page.
|
|
34
|
+
*/
|
|
35
|
+
export declare const popupBackdropClasses = "pointer-events-none fixed inset-0 z-50 touch-none pointer-coarse:pointer-events-auto";
|
|
36
|
+
/**
|
|
37
|
+
* The panel every floating list and popover is drawn on: popover fill, `lg` corners, and a 1px
|
|
38
|
+
* border over `shadow-popup`. The corners nest the rows inside: the list's 4px padding plus the
|
|
39
|
+
* row's `sm` radius. Menu, Combobox, Select, Autocomplete, Popover and the toast share it so
|
|
40
|
+
* they read as the same card.
|
|
41
|
+
*/
|
|
42
|
+
export declare const popupSurfaceClasses = "rounded-lg border border-edge-float bg-overlay text-ink shadow-popup";
|
|
43
|
+
/**
|
|
44
|
+
* A single chevron in a button's suffix, turning over while the button's menu is open so it
|
|
45
|
+
* points at what it opened. Never on a two-way chevron, which looks the same turned over and only
|
|
46
|
+
* spins. A plain ease-out: the half turn is long, and `--ease-out-expo` covers nearly all of it
|
|
47
|
+
* in the first few frames, which reads as a flicker.
|
|
48
|
+
*/
|
|
49
|
+
export declare const chevronTurnClasses = "transition-[rotate] duration-200 ease-out group-aria-expanded/button:rotate-180";
|
|
50
|
+
export declare const POPUP_SIDE_OFFSET = 6;
|
|
51
|
+
/**
|
|
52
|
+
* The surface every tooltip on the site is drawn on, Base UI's and the chart's alike: the popup
|
|
53
|
+
* panel at caption size under the lower tooltip shadow, so a tooltip reads as the same card as
|
|
54
|
+
* a menu or a popover, only smaller and closer to the page. `tooltipLabelClasses` mutes a label
|
|
55
|
+
* against it and `tooltipRuleClasses` draws a rule inside it.
|
|
56
|
+
*/
|
|
57
|
+
export declare const tooltipSurfaceClasses = "rounded-md border border-edge-float bg-overlay text-ink shadow-tooltip text-xs";
|
|
58
|
+
export declare const tooltipLabelClasses = "text-ink-muted";
|
|
59
|
+
export declare const tooltipRuleClasses = "border-edge";
|
|
60
|
+
/**
|
|
61
|
+
* Small muted label over a group of items: sidebar sections, menu groups. One place so every
|
|
62
|
+
* eyebrow in the app shares its size and weight.
|
|
63
|
+
*/
|
|
64
|
+
export declare const eyebrowClasses = "text-xs font-medium text-ink-muted";
|
|
65
|
+
/**
|
|
66
|
+
* A headline number: a stat, a usage total, a site's visitors. Every figure shares the weight
|
|
67
|
+
* and tracking; the caller sets the size, `text-figure` or a fluid one with `leading-figure`.
|
|
68
|
+
*/
|
|
69
|
+
export declare const figureClasses = "font-display font-semibold tracking-figure tabular-nums";
|
|
70
|
+
/**
|
|
71
|
+
* A 20px glyph on a raised tile over a heading: an empty state, a step reached from a link. The
|
|
72
|
+
* tile is drawn like a segmented control's chosen option, an edged surface lifted by the control
|
|
73
|
+
* shadow. The caller sets the tile's size.
|
|
74
|
+
*/
|
|
75
|
+
export declare const iconTileClasses = "flex shrink-0 items-center justify-center rounded-lg border border-edge-strong bg-surface text-ink-secondary shadow-control [&_svg]:size-5";
|
|
76
|
+
/**
|
|
77
|
+
* Muted supporting copy under a heading, label, or control: one step under the 14px label it
|
|
78
|
+
* sits beneath, on the 20px reading line, since a description is a sentence to read rather
|
|
79
|
+
* than a label to scan. It stops at a readable line length, however wide its row grows; a
|
|
80
|
+
* container that borrows the type sets `max-w-none`.
|
|
81
|
+
*/
|
|
82
|
+
export declare const descriptionClasses = "max-w-prose text-copy text-ink-muted";
|
|
83
|
+
/**
|
|
84
|
+
* A row of a table or a list, pressed: past its hover fill, and fading into it. Only the press
|
|
85
|
+
* fades. A pointer sweeping down the list lights and clears each row at once, since a fading row
|
|
86
|
+
* trails the cursor and reads as lag. The row's link or button carries `data-press-target`, so a
|
|
87
|
+
* press on a smaller control in the row leaves the row alone.
|
|
88
|
+
*/
|
|
89
|
+
export declare const rowPressClasses = "transition-colors duration-0 ease-out has-[[data-press-target]:active]:bg-fill-strong has-[[data-press-target]:active]:duration-150";
|
|
90
|
+
/**
|
|
91
|
+
* One row in any floating list. Vertical padding, control text, secondary foreground,
|
|
92
|
+
* disabled state, and the highlight. The highlight covers both `focus` (Menu, Select) and
|
|
93
|
+
* `data-highlighted` (Combobox, Autocomplete) because Base UI drives those primitives
|
|
94
|
+
* differently; carrying both selectors keeps every list lighting up the same way. Horizontal
|
|
95
|
+
* padding stays on the component: `px-2`, or `pl-8` on an inset menu item. `cn` does not treat
|
|
96
|
+
* those as the same group, so a shared `px-2` would sit beside the inset and fight it. Under a
|
|
97
|
+
* finger every list's rows grow from 28px to 32px, and no further: a taller row reads as
|
|
98
|
+
* padding rather than a row, and stretches a long list past the screen.
|
|
99
|
+
*/
|
|
100
|
+
export declare const popupItemClasses: string;
|
|
101
|
+
/**
|
|
102
|
+
* Group heading and divider around the rows of a floating list. The list itself pads with
|
|
103
|
+
* `p-1` so a separator's `-mx-1` reaches the panel edge.
|
|
104
|
+
*/
|
|
105
|
+
export declare const popupGroupLabelClasses: string;
|
|
106
|
+
export declare const popupSeparatorClasses = "-mx-1 my-1 h-px shrink-0 bg-edge";
|
|
107
|
+
/**
|
|
108
|
+
* The line that stands in for a floating list while nothing matches, or reports its loading
|
|
109
|
+
* state. It collapses to nothing while it has no text.
|
|
110
|
+
*/
|
|
111
|
+
export declare const popupEmptyClasses: string;
|
|
112
|
+
/**
|
|
113
|
+
* A string a machine wrote: an id, a path, an event name, a header value. Mono, so a column of
|
|
114
|
+
* them lines up on its stem and the one that differs is the one you see, and a step down from
|
|
115
|
+
* the body size, since mono carries more ink per character and reads larger beside the sans it
|
|
116
|
+
* sits next to.
|
|
117
|
+
*/
|
|
118
|
+
export declare const monoTextClasses = "font-mono text-xs";
|
|
119
|
+
/**
|
|
120
|
+
* A table whose hairlines are borders on its cells rather than on its rows. The collapsed
|
|
121
|
+
* model splits every 1px line between the two rows it parts, which puts the rows on half
|
|
122
|
+
* pixels and a stuck heading half a pixel off its slot; the separate model keeps a border
|
|
123
|
+
* inside its cell, where it moves with the cell when the cell sticks. Row borders do not
|
|
124
|
+
* paint in this model, so every hairline is on a `th` or a `td`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const separateTableClasses = "w-full table-fixed border-separate border-spacing-0";
|
|
127
|
+
/**
|
|
128
|
+
* The heading cell that cuts a table into runs: a day of a feed, a group of a detail view.
|
|
129
|
+
* Set in the foreground weight rather than as a muted eyebrow, since it is what a reader
|
|
130
|
+
* scans for. It sticks while its own `<tbody>` is in view and is pushed out by the next one,
|
|
131
|
+
* so the run a reader is in is always named at the top. Opaque: the rows slide under it. The
|
|
132
|
+
* caller sets `top-*`, which depends on what else is pinned above the table.
|
|
133
|
+
*/
|
|
134
|
+
export declare const groupHeadingClasses: string;
|
package/lib/classes.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { cn } from "./variants.js";
|
|
2
|
+
// src/lib/classes.ts
|
|
3
|
+
/**
|
|
4
|
+
* Enter/exit animation classes for Base UI popups (Menu, Select, Popover, …).
|
|
5
|
+
* Keyed on Base UI's `data-open`/`data-closed` state attributes and the positioner's
|
|
6
|
+
* `data-[side=*]`, with the zoom anchored to the `--transform-origin` Base UI exposes on
|
|
7
|
+
* the popup. Animation utilities (and their `duration-*`/`ease-*` bindings) come from
|
|
8
|
+
* `tailwindcss-animate`.
|
|
9
|
+
*
|
|
10
|
+
* The `data-closed` animation is essential: Base UI keeps the popup mounted until the
|
|
11
|
+
* exit animation finishes, so without it there is no close animation at all. The exit holds its
|
|
12
|
+
* last frame (`fill-mode-forwards`): a keyframe animation otherwise hands the popup back to full
|
|
13
|
+
* opacity the moment it ends, and any frame painted before the unmount flashes the whole panel.
|
|
14
|
+
*
|
|
15
|
+
* Feel: a 97% zoom out of the trigger and an 8px directional slide. Enter is 150ms on
|
|
16
|
+
* `--ease-out-expo`; exit is a plainer, faster 100ms ease-out, since a popup on its way out has
|
|
17
|
+
* nothing to announce. `data-instant` collapses the duration to 0 so Base UI's instant transitions
|
|
18
|
+
* (keyboard nav between items, grouped tooltips) don't stutter.
|
|
19
|
+
*/
|
|
20
|
+
const popoverAnimationClasses = [
|
|
21
|
+
"origin-(--transform-origin) data-instant:duration-0",
|
|
22
|
+
"data-open:duration-150 data-open:animate-in data-open:ease-out-expo data-open:fade-in-0 data-open:zoom-in-97",
|
|
23
|
+
"data-closed:duration-100 data-closed:animate-out data-closed:fill-mode-forwards data-closed:ease-out data-closed:fade-out-0 data-closed:zoom-out-97",
|
|
24
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=bottom]:slide-out-to-top-2",
|
|
25
|
+
"data-[side=left]:slide-in-from-right-2 data-[side=left]:slide-out-to-right-2",
|
|
26
|
+
"data-[side=right]:slide-in-from-left-2 data-[side=right]:slide-out-to-left-2",
|
|
27
|
+
"data-[side=top]:slide-in-from-bottom-2 data-[side=top]:slide-out-to-bottom-2"
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* How a tooltip comes and goes. Transitions rather than the popups' keyframes, so a pointer that
|
|
31
|
+
* leaves and returns mid-way turns the panel around from where it is instead of restarting it.
|
|
32
|
+
* The panel grows out of its arrow's tip (`--transform-origin`) from 96% while it fades in, and
|
|
33
|
+
* only fades on the way out, faster than it came: nothing travels, since a tooltip opens on
|
|
34
|
+
* every pass of the pointer and movement there costs attention each time. The scale is left out
|
|
35
|
+
* for a reader who asks for reduced motion, and `data-instant` (a keyboard focus, a sibling
|
|
36
|
+
* taking over within the provider's timeout, a dismissal) skips the transition altogether.
|
|
37
|
+
*/
|
|
38
|
+
const tooltipAnimationClasses = [
|
|
39
|
+
"origin-(--transform-origin) transition-[opacity,scale] duration-150 ease-out-expo",
|
|
40
|
+
"data-starting-style:opacity-0 motion-safe:data-starting-style:scale-96",
|
|
41
|
+
"data-ending-style:opacity-0 data-ending-style:duration-100 data-ending-style:ease-out",
|
|
42
|
+
"data-instant:transition-none"
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The invisible layer between an anchored popup (a menu, a select, a popover) and the page. A
|
|
46
|
+
* mouse passes through it, so one click closes the popup and reaches the control underneath. A
|
|
47
|
+
* finger stops on it: a tap meant to dismiss the popup must not land on a link, and `touch-none`
|
|
48
|
+
* stops a drag beside the popup from scrolling the page.
|
|
49
|
+
*/
|
|
50
|
+
const popupBackdropClasses = "pointer-events-none fixed inset-0 z-50 touch-none pointer-coarse:pointer-events-auto";
|
|
51
|
+
/**
|
|
52
|
+
* The panel every floating list and popover is drawn on: popover fill, `lg` corners, and a 1px
|
|
53
|
+
* border over `shadow-popup`. The corners nest the rows inside: the list's 4px padding plus the
|
|
54
|
+
* row's `sm` radius. Menu, Combobox, Select, Autocomplete, Popover and the toast share it so
|
|
55
|
+
* they read as the same card.
|
|
56
|
+
*/
|
|
57
|
+
const popupSurfaceClasses = "rounded-lg border border-edge-float bg-overlay text-ink shadow-popup";
|
|
58
|
+
/**
|
|
59
|
+
* A single chevron in a button's suffix, turning over while the button's menu is open so it
|
|
60
|
+
* points at what it opened. Never on a two-way chevron, which looks the same turned over and only
|
|
61
|
+
* spins. A plain ease-out: the half turn is long, and `--ease-out-expo` covers nearly all of it
|
|
62
|
+
* in the first few frames, which reads as a flicker.
|
|
63
|
+
*/
|
|
64
|
+
const chevronTurnClasses = "transition-[rotate] duration-200 ease-out group-aria-expanded/button:rotate-180";
|
|
65
|
+
const POPUP_SIDE_OFFSET = 6;
|
|
66
|
+
/**
|
|
67
|
+
* The surface every tooltip on the site is drawn on, Base UI's and the chart's alike: the popup
|
|
68
|
+
* panel at caption size under the lower tooltip shadow, so a tooltip reads as the same card as
|
|
69
|
+
* a menu or a popover, only smaller and closer to the page. `tooltipLabelClasses` mutes a label
|
|
70
|
+
* against it and `tooltipRuleClasses` draws a rule inside it.
|
|
71
|
+
*/
|
|
72
|
+
const tooltipSurfaceClasses = "rounded-md border border-edge-float bg-overlay text-ink shadow-tooltip text-xs";
|
|
73
|
+
const tooltipLabelClasses = "text-ink-muted";
|
|
74
|
+
const tooltipRuleClasses = "border-edge";
|
|
75
|
+
/**
|
|
76
|
+
* Small muted label over a group of items: sidebar sections, menu groups. One place so every
|
|
77
|
+
* eyebrow in the app shares its size and weight.
|
|
78
|
+
*/
|
|
79
|
+
const eyebrowClasses = "text-xs font-medium text-ink-muted";
|
|
80
|
+
/**
|
|
81
|
+
* A headline number: a stat, a usage total, a site's visitors. Every figure shares the weight
|
|
82
|
+
* and tracking; the caller sets the size, `text-figure` or a fluid one with `leading-figure`.
|
|
83
|
+
*/
|
|
84
|
+
const figureClasses = "font-display font-semibold tracking-figure tabular-nums";
|
|
85
|
+
/**
|
|
86
|
+
* A 20px glyph on a raised tile over a heading: an empty state, a step reached from a link. The
|
|
87
|
+
* tile is drawn like a segmented control's chosen option, an edged surface lifted by the control
|
|
88
|
+
* shadow. The caller sets the tile's size.
|
|
89
|
+
*/
|
|
90
|
+
const iconTileClasses = "flex shrink-0 items-center justify-center rounded-lg border border-edge-strong bg-surface text-ink-secondary shadow-control [&_svg]:size-5";
|
|
91
|
+
/**
|
|
92
|
+
* Muted supporting copy under a heading, label, or control: one step under the 14px label it
|
|
93
|
+
* sits beneath, on the 20px reading line, since a description is a sentence to read rather
|
|
94
|
+
* than a label to scan. It stops at a readable line length, however wide its row grows; a
|
|
95
|
+
* container that borrows the type sets `max-w-none`.
|
|
96
|
+
*/
|
|
97
|
+
const descriptionClasses = "max-w-prose text-copy text-ink-muted";
|
|
98
|
+
/**
|
|
99
|
+
* A row of a table or a list, pressed: past its hover fill, and fading into it. Only the press
|
|
100
|
+
* fades. A pointer sweeping down the list lights and clears each row at once, since a fading row
|
|
101
|
+
* trails the cursor and reads as lag. The row's link or button carries `data-press-target`, so a
|
|
102
|
+
* press on a smaller control in the row leaves the row alone.
|
|
103
|
+
*/
|
|
104
|
+
const rowPressClasses = "transition-colors duration-0 ease-out has-[[data-press-target]:active]:bg-fill-strong has-[[data-press-target]:active]:duration-150";
|
|
105
|
+
/**
|
|
106
|
+
* One row in any floating list. Vertical padding, control text, secondary foreground,
|
|
107
|
+
* disabled state, and the highlight. The highlight covers both `focus` (Menu, Select) and
|
|
108
|
+
* `data-highlighted` (Combobox, Autocomplete) because Base UI drives those primitives
|
|
109
|
+
* differently; carrying both selectors keeps every list lighting up the same way. Horizontal
|
|
110
|
+
* padding stays on the component: `px-2`, or `pl-8` on an inset menu item. `cn` does not treat
|
|
111
|
+
* those as the same group, so a shared `px-2` would sit beside the inset and fight it. Under a
|
|
112
|
+
* finger every list's rows grow from 28px to 32px, and no further: a taller row reads as
|
|
113
|
+
* padding rather than a row, and stretches a long list past the screen.
|
|
114
|
+
*/
|
|
115
|
+
const popupItemClasses = cn("flex cursor-pointer select-none items-center rounded-sm py-1.5 pointer-coarse:min-h-8", "text-control", "text-ink-secondary outline-none focus:bg-fill focus:text-ink data-highlighted:bg-fill data-highlighted:text-ink data-disabled:cursor-not-allowed data-disabled:opacity-50", "transition-[background-color,color,box-shadow] duration-0 ease-out not-data-disabled:active:bg-fill-strong not-data-disabled:active:text-ink not-data-disabled:active:duration-75", "not-data-disabled:active:shadow-well");
|
|
116
|
+
/**
|
|
117
|
+
* Group heading and divider around the rows of a floating list. The list itself pads with
|
|
118
|
+
* `p-1` so a separator's `-mx-1` reaches the panel edge.
|
|
119
|
+
*/
|
|
120
|
+
const popupGroupLabelClasses = cn("px-2 pt-1.5 pb-1", eyebrowClasses);
|
|
121
|
+
const popupSeparatorClasses = "-mx-1 my-1 h-px shrink-0 bg-edge";
|
|
122
|
+
/**
|
|
123
|
+
* The line that stands in for a floating list while nothing matches, or reports its loading
|
|
124
|
+
* state. It collapses to nothing while it has no text.
|
|
125
|
+
*/
|
|
126
|
+
const popupEmptyClasses = cn("px-3 py-2", "text-control", "text-ink-muted empty:m-0 empty:p-0");
|
|
127
|
+
/**
|
|
128
|
+
* A string a machine wrote: an id, a path, an event name, a header value. Mono, so a column of
|
|
129
|
+
* them lines up on its stem and the one that differs is the one you see, and a step down from
|
|
130
|
+
* the body size, since mono carries more ink per character and reads larger beside the sans it
|
|
131
|
+
* sits next to.
|
|
132
|
+
*/
|
|
133
|
+
const monoTextClasses = "font-mono text-xs";
|
|
134
|
+
/**
|
|
135
|
+
* A table whose hairlines are borders on its cells rather than on its rows. The collapsed
|
|
136
|
+
* model splits every 1px line between the two rows it parts, which puts the rows on half
|
|
137
|
+
* pixels and a stuck heading half a pixel off its slot; the separate model keeps a border
|
|
138
|
+
* inside its cell, where it moves with the cell when the cell sticks. Row borders do not
|
|
139
|
+
* paint in this model, so every hairline is on a `th` or a `td`.
|
|
140
|
+
*/
|
|
141
|
+
const separateTableClasses = "w-full table-fixed border-separate border-spacing-0";
|
|
142
|
+
/**
|
|
143
|
+
* The heading cell that cuts a table into runs: a day of a feed, a group of a detail view.
|
|
144
|
+
* Set in the foreground weight rather than as a muted eyebrow, since it is what a reader
|
|
145
|
+
* scans for. It sticks while its own `<tbody>` is in view and is pushed out by the next one,
|
|
146
|
+
* so the run a reader is in is always named at the top. Opaque: the rows slide under it. The
|
|
147
|
+
* caller sets `top-*`, which depends on what else is pinned above the table.
|
|
148
|
+
*/
|
|
149
|
+
const groupHeadingClasses = ["sticky z-10 h-8 border-b text-left font-semibold text-ink text-xs", "bg-[color-mix(in_oklab,var(--color-fill)_40%,var(--color-surface))]"].join(" ");
|
|
150
|
+
export { POPUP_SIDE_OFFSET, chevronTurnClasses, descriptionClasses, eyebrowClasses, figureClasses, groupHeadingClasses, iconTileClasses, monoTextClasses, popoverAnimationClasses, popupBackdropClasses, popupEmptyClasses, popupGroupLabelClasses, popupItemClasses, popupSeparatorClasses, popupSurfaceClasses, rowPressClasses, separateTableClasses, tooltipAnimationClasses, tooltipLabelClasses, tooltipRuleClasses, tooltipSurfaceClasses };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=classes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.js","names":[],"sources":["../../src/lib/classes.ts"],"sourcesContent":["import { cn } from \"./variants\"\n\n/**\n * Enter/exit animation classes for Base UI popups (Menu, Select, Popover, …).\n * Keyed on Base UI's `data-open`/`data-closed` state attributes and the positioner's\n * `data-[side=*]`, with the zoom anchored to the `--transform-origin` Base UI exposes on\n * the popup. Animation utilities (and their `duration-*`/`ease-*` bindings) come from\n * `tailwindcss-animate`.\n *\n * The `data-closed` animation is essential: Base UI keeps the popup mounted until the\n * exit animation finishes, so without it there is no close animation at all. The exit holds its\n * last frame (`fill-mode-forwards`): a keyframe animation otherwise hands the popup back to full\n * opacity the moment it ends, and any frame painted before the unmount flashes the whole panel.\n *\n * Feel: a 97% zoom out of the trigger and an 8px directional slide. Enter is 150ms on\n * `--ease-out-expo`; exit is a plainer, faster 100ms ease-out, since a popup on its way out has\n * nothing to announce. `data-instant` collapses the duration to 0 so Base UI's instant transitions\n * (keyboard nav between items, grouped tooltips) don't stutter.\n */\nexport const popoverAnimationClasses = [\n \"origin-(--transform-origin) data-instant:duration-0\",\n \"data-open:duration-150 data-open:animate-in data-open:ease-out-expo data-open:fade-in-0 data-open:zoom-in-97\",\n \"data-closed:duration-100 data-closed:animate-out data-closed:fill-mode-forwards data-closed:ease-out data-closed:fade-out-0 data-closed:zoom-out-97\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=bottom]:slide-out-to-top-2\",\n \"data-[side=left]:slide-in-from-right-2 data-[side=left]:slide-out-to-right-2\",\n \"data-[side=right]:slide-in-from-left-2 data-[side=right]:slide-out-to-left-2\",\n \"data-[side=top]:slide-in-from-bottom-2 data-[side=top]:slide-out-to-bottom-2\",\n]\n\n/**\n * How a tooltip comes and goes. Transitions rather than the popups' keyframes, so a pointer that\n * leaves and returns mid-way turns the panel around from where it is instead of restarting it.\n * The panel grows out of its arrow's tip (`--transform-origin`) from 96% while it fades in, and\n * only fades on the way out, faster than it came: nothing travels, since a tooltip opens on\n * every pass of the pointer and movement there costs attention each time. The scale is left out\n * for a reader who asks for reduced motion, and `data-instant` (a keyboard focus, a sibling\n * taking over within the provider's timeout, a dismissal) skips the transition altogether.\n */\nexport const tooltipAnimationClasses = [\n \"origin-(--transform-origin) transition-[opacity,scale] duration-150 ease-out-expo\",\n \"data-starting-style:opacity-0 motion-safe:data-starting-style:scale-96\",\n \"data-ending-style:opacity-0 data-ending-style:duration-100 data-ending-style:ease-out\",\n \"data-instant:transition-none\",\n]\n\n/**\n * The invisible layer between an anchored popup (a menu, a select, a popover) and the page. A\n * mouse passes through it, so one click closes the popup and reaches the control underneath. A\n * finger stops on it: a tap meant to dismiss the popup must not land on a link, and `touch-none`\n * stops a drag beside the popup from scrolling the page.\n */\nexport const popupBackdropClasses =\n \"pointer-events-none fixed inset-0 z-50 touch-none pointer-coarse:pointer-events-auto\"\n\n/**\n * The panel every floating list and popover is drawn on: popover fill, `lg` corners, and a 1px\n * border over `shadow-popup`. The corners nest the rows inside: the list's 4px padding plus the\n * row's `sm` radius. Menu, Combobox, Select, Autocomplete, Popover and the toast share it so\n * they read as the same card.\n */\nexport const popupSurfaceClasses =\n \"rounded-lg border border-edge-float bg-overlay text-ink shadow-popup\"\n\n/**\n * A single chevron in a button's suffix, turning over while the button's menu is open so it\n * points at what it opened. Never on a two-way chevron, which looks the same turned over and only\n * spins. A plain ease-out: the half turn is long, and `--ease-out-expo` covers nearly all of it\n * in the first few frames, which reads as a flicker.\n */\nexport const chevronTurnClasses =\n \"transition-[rotate] duration-200 ease-out group-aria-expanded/button:rotate-180\"\n\nexport const POPUP_SIDE_OFFSET = 6\n\n/**\n * The surface every tooltip on the site is drawn on, Base UI's and the chart's alike: the popup\n * panel at caption size under the lower tooltip shadow, so a tooltip reads as the same card as\n * a menu or a popover, only smaller and closer to the page. `tooltipLabelClasses` mutes a label\n * against it and `tooltipRuleClasses` draws a rule inside it.\n */\nexport const tooltipSurfaceClasses =\n \"rounded-md border border-edge-float bg-overlay text-ink shadow-tooltip text-xs\"\nexport const tooltipLabelClasses = \"text-ink-muted\"\nexport const tooltipRuleClasses = \"border-edge\"\n\n/**\n * Small muted label over a group of items: sidebar sections, menu groups. One place so every\n * eyebrow in the app shares its size and weight.\n */\nexport const eyebrowClasses = \"text-xs font-medium text-ink-muted\"\n\n/**\n * A headline number: a stat, a usage total, a site's visitors. Every figure shares the weight\n * and tracking; the caller sets the size, `text-figure` or a fluid one with `leading-figure`.\n */\nexport const figureClasses = \"font-display font-semibold tracking-figure tabular-nums\"\n\n/**\n * A 20px glyph on a raised tile over a heading: an empty state, a step reached from a link. The\n * tile is drawn like a segmented control's chosen option, an edged surface lifted by the control\n * shadow. The caller sets the tile's size.\n */\nexport const iconTileClasses =\n \"flex shrink-0 items-center justify-center rounded-lg border border-edge-strong bg-surface text-ink-secondary shadow-control [&_svg]:size-5\"\n\n/**\n * Muted supporting copy under a heading, label, or control: one step under the 14px label it\n * sits beneath, on the 20px reading line, since a description is a sentence to read rather\n * than a label to scan. It stops at a readable line length, however wide its row grows; a\n * container that borrows the type sets `max-w-none`.\n */\nexport const descriptionClasses = \"max-w-prose text-copy text-ink-muted\"\n\n/**\n * A row of a table or a list, pressed: past its hover fill, and fading into it. Only the press\n * fades. A pointer sweeping down the list lights and clears each row at once, since a fading row\n * trails the cursor and reads as lag. The row's link or button carries `data-press-target`, so a\n * press on a smaller control in the row leaves the row alone.\n */\nexport const rowPressClasses =\n \"transition-colors duration-0 ease-out has-[[data-press-target]:active]:bg-fill-strong has-[[data-press-target]:active]:duration-150\"\n\n/**\n * One row in any floating list. Vertical padding, control text, secondary foreground,\n * disabled state, and the highlight. The highlight covers both `focus` (Menu, Select) and\n * `data-highlighted` (Combobox, Autocomplete) because Base UI drives those primitives\n * differently; carrying both selectors keeps every list lighting up the same way. Horizontal\n * padding stays on the component: `px-2`, or `pl-8` on an inset menu item. `cn` does not treat\n * those as the same group, so a shared `px-2` would sit beside the inset and fight it. Under a\n * finger every list's rows grow from 28px to 32px, and no further: a taller row reads as\n * padding rather than a row, and stretches a long list past the screen.\n */\nexport const popupItemClasses = cn(\n \"flex cursor-pointer select-none items-center rounded-sm py-1.5 pointer-coarse:min-h-8\",\n \"text-control\",\n \"text-ink-secondary outline-none focus:bg-fill focus:text-ink data-highlighted:bg-fill data-highlighted:text-ink data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n // The highlight is the only keyboard cue in a list, so it takes the full fill and the ink rather\n // than a hover tint. A press goes a step past it and sinks, so the row answers before the menu\n // closes. A disabled row does not answer. Only the press fades: the highlight follows the\n // pointer, so it moves at once, as a native menu's does, and never trails the cursor.\n \"transition-[background-color,color,box-shadow] duration-0 ease-out not-data-disabled:active:bg-fill-strong not-data-disabled:active:text-ink not-data-disabled:active:duration-75\",\n \"not-data-disabled:active:shadow-well\",\n)\n\n/**\n * Group heading and divider around the rows of a floating list. The list itself pads with\n * `p-1` so a separator's `-mx-1` reaches the panel edge.\n */\nexport const popupGroupLabelClasses = cn(\"px-2 pt-1.5 pb-1\", eyebrowClasses)\nexport const popupSeparatorClasses = \"-mx-1 my-1 h-px shrink-0 bg-edge\"\n\n/**\n * The line that stands in for a floating list while nothing matches, or reports its loading\n * state. It collapses to nothing while it has no text.\n */\nexport const popupEmptyClasses = cn(\n \"px-3 py-2\",\n \"text-control\",\n \"text-ink-muted empty:m-0 empty:p-0\",\n)\n\n/**\n * A string a machine wrote: an id, a path, an event name, a header value. Mono, so a column of\n * them lines up on its stem and the one that differs is the one you see, and a step down from\n * the body size, since mono carries more ink per character and reads larger beside the sans it\n * sits next to.\n */\nexport const monoTextClasses = \"font-mono text-xs\"\n\n/**\n * A table whose hairlines are borders on its cells rather than on its rows. The collapsed\n * model splits every 1px line between the two rows it parts, which puts the rows on half\n * pixels and a stuck heading half a pixel off its slot; the separate model keeps a border\n * inside its cell, where it moves with the cell when the cell sticks. Row borders do not\n * paint in this model, so every hairline is on a `th` or a `td`.\n */\nexport const separateTableClasses = \"w-full table-fixed border-separate border-spacing-0\"\n\n/**\n * The heading cell that cuts a table into runs: a day of a feed, a group of a detail view.\n * Set in the foreground weight rather than as a muted eyebrow, since it is what a reader\n * scans for. It sticks while its own `<tbody>` is in view and is pushed out by the next one,\n * so the run a reader is in is always named at the top. Opaque: the rows slide under it. The\n * caller sets `top-*`, which depends on what else is pinned above the table.\n */\nexport const groupHeadingClasses = [\n \"sticky z-10 h-8 border-b text-left font-semibold text-ink text-xs\",\n \"bg-[color-mix(in_oklab,var(--color-fill)_40%,var(--color-surface))]\",\n].join(\" \")\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAa,uBACX;;;;;;;AAQF,MAAa,sBACX;;;;;;;AAQF,MAAa,qBACX;AAEF,MAAa,oBAAoB;;;;;;;AAQjC,MAAa,wBACX;AACF,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;;;;;AAMlC,MAAa,iBAAiB;;;;;AAM9B,MAAa,gBAAgB;;;;;;AAO7B,MAAa,kBACX;;;;;;;AAQF,MAAa,qBAAqB;;;;;;;AAQlC,MAAa,kBACX;;;;;;;;;;;AAYF,MAAa,mBAAmB,GAC9B,yFACA,gBACA,6KAKA,qLACA,sCACF;;;;;AAMA,MAAa,yBAAyB,GAAG,oBAAoB,cAAc;AAC3E,MAAa,wBAAwB;;;;;AAMrC,MAAa,oBAAoB,GAC/B,aACA,gBACA,oCACF;;;;;;;AAQA,MAAa,kBAAkB;;;;;;;;AAS/B,MAAa,uBAAuB;;;;;;;;AASpC,MAAa,sBAAsB,CACjC,qEACA,qEACF,CAAC,CAAC,KAAK,GAAG"}
|
package/lib/color.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Rgb = [number, number, number];
|
|
2
|
+
export type Theme = "light" | "dark";
|
|
3
|
+
export interface Oklch {
|
|
4
|
+
lightness: number;
|
|
5
|
+
chroma: number;
|
|
6
|
+
hue: number;
|
|
7
|
+
alpha: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const THEMES: Theme[];
|
|
10
|
+
/** Splits `value` on each top-level `separator` (a comma by default), not those in nested calls. */
|
|
11
|
+
export declare function splitTopLevel(value: string, separator?: string): string[];
|
|
12
|
+
/** A token's two sides, following `var()` to a gray setting, a gray step or another token. */
|
|
13
|
+
export declare function readToken(css: string, name: string): Record<Theme, Oklch>;
|
|
14
|
+
/** OKLCH to gamma-encoded sRGB in 0 to 1, clipped to the gamut. */
|
|
15
|
+
export declare function toSrgb({ lightness, chroma, hue }: Oklch): Rgb;
|
|
16
|
+
export declare function formatHex(rgb: Rgb): string;
|
|
17
|
+
/** The colour tokens and gray steps the stylesheet declares, in its order. */
|
|
18
|
+
export declare function readColorNames(css: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Every opaque colour token and gray step as hex, per theme. A translucent edge is the hex it
|
|
21
|
+
* makes over a card's surface, which is where code that cannot blend (an email) draws its lines.
|
|
22
|
+
* Any other translucent token (a `-subtle` tint, a coloured `-edge`, the scrim) has no single hex
|
|
23
|
+
* and is left out.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readOpaqueTokens(css: string): Record<Theme, Record<string, string>>;
|