@vouched-id/ui 0.0.0-stage → 0.1.1
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/dist/Accordion.d.ts +8 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +20 -0
- package/dist/Accordion.js.map +1 -0
- package/dist/Alert.d.ts +12 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Alert.js +64 -0
- package/dist/Alert.js.map +1 -0
- package/dist/AlertDialog.d.ts +90 -0
- package/dist/AlertDialog.d.ts.map +1 -0
- package/dist/AlertDialog.js +148 -0
- package/dist/AlertDialog.js.map +1 -0
- package/dist/Avatar.d.ts +43 -0
- package/dist/Avatar.d.ts.map +1 -0
- package/dist/Avatar.js +29 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.d.ts +31 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +22 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Banner.d.ts +57 -0
- package/dist/Banner.d.ts.map +1 -0
- package/dist/Banner.js +30 -0
- package/dist/Banner.js.map +1 -0
- package/dist/Button.d.ts +56 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +106 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +79 -0
- package/dist/Card.d.ts.map +1 -0
- package/dist/Card.js +50 -0
- package/dist/Card.js.map +1 -0
- package/dist/Chart.d.ts +63 -0
- package/dist/Chart.d.ts.map +1 -0
- package/dist/Chart.js +120 -0
- package/dist/Chart.js.map +1 -0
- package/dist/Checkbox.d.ts +4 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +10 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/CodeBlock.d.ts +101 -0
- package/dist/CodeBlock.d.ts.map +1 -0
- package/dist/CodeBlock.js +99 -0
- package/dist/CodeBlock.js.map +1 -0
- package/dist/Collapsible.d.ts +6 -0
- package/dist/Collapsible.d.ts.map +1 -0
- package/dist/Collapsible.js +14 -0
- package/dist/Collapsible.js.map +1 -0
- package/dist/DataTable.d.ts +59 -0
- package/dist/DataTable.d.ts.map +1 -0
- package/dist/DataTable.js +162 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/Dialog.d.ts +71 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +185 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/DropdownMenu.d.ts +82 -0
- package/dist/DropdownMenu.d.ts.map +1 -0
- package/dist/DropdownMenu.js +111 -0
- package/dist/DropdownMenu.js.map +1 -0
- package/dist/EditorialHeading.d.ts +42 -0
- package/dist/EditorialHeading.d.ts.map +1 -0
- package/dist/EditorialHeading.js +36 -0
- package/dist/EditorialHeading.js.map +1 -0
- package/dist/EmptyState.d.ts +40 -0
- package/dist/EmptyState.d.ts.map +1 -0
- package/dist/EmptyState.js +7 -0
- package/dist/EmptyState.js.map +1 -0
- package/dist/Eyebrow.d.ts +27 -0
- package/dist/Eyebrow.d.ts.map +1 -0
- package/dist/Eyebrow.js +23 -0
- package/dist/Eyebrow.js.map +1 -0
- package/dist/Field.d.ts +33 -0
- package/dist/Field.d.ts.map +1 -0
- package/dist/Field.js +26 -0
- package/dist/Field.js.map +1 -0
- package/dist/HoverCard.d.ts +7 -0
- package/dist/HoverCard.d.ts.map +1 -0
- package/dist/HoverCard.js +17 -0
- package/dist/HoverCard.js.map +1 -0
- package/dist/Input.d.ts +20 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +17 -0
- package/dist/Input.js.map +1 -0
- package/dist/InstallCommand.d.ts +48 -0
- package/dist/InstallCommand.d.ts.map +1 -0
- package/dist/InstallCommand.js +60 -0
- package/dist/InstallCommand.js.map +1 -0
- package/dist/Kbd.d.ts +23 -0
- package/dist/Kbd.d.ts.map +1 -0
- package/dist/Kbd.js +7 -0
- package/dist/Kbd.js.map +1 -0
- package/dist/Label.d.ts +5 -0
- package/dist/Label.d.ts.map +1 -0
- package/dist/Label.js +9 -0
- package/dist/Label.js.map +1 -0
- package/dist/Popover.d.ts +41 -0
- package/dist/Popover.d.ts.map +1 -0
- package/dist/Popover.js +27 -0
- package/dist/Popover.js.map +1 -0
- package/dist/Progress.d.ts +6 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Progress.js +9 -0
- package/dist/Progress.js.map +1 -0
- package/dist/RadioGroup.d.ts +5 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +15 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/ScrollArea.d.ts +32 -0
- package/dist/ScrollArea.d.ts.map +1 -0
- package/dist/ScrollArea.js +13 -0
- package/dist/ScrollArea.js.map +1 -0
- package/dist/SegmentedControl.d.ts +37 -0
- package/dist/SegmentedControl.d.ts.map +1 -0
- package/dist/SegmentedControl.js +85 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/Select.d.ts +21 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +52 -0
- package/dist/Select.js.map +1 -0
- package/dist/Separator.d.ts +4 -0
- package/dist/Separator.d.ts.map +1 -0
- package/dist/Separator.js +9 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Sheet.d.ts +71 -0
- package/dist/Sheet.d.ts.map +1 -0
- package/dist/Sheet.js +173 -0
- package/dist/Sheet.js.map +1 -0
- package/dist/Skeleton.d.ts +26 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +9 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/Slider.d.ts +5 -0
- package/dist/Slider.d.ts.map +1 -0
- package/dist/Slider.js +12 -0
- package/dist/Slider.js.map +1 -0
- package/dist/StatusDot.d.ts +29 -0
- package/dist/StatusDot.d.ts.map +1 -0
- package/dist/StatusDot.js +55 -0
- package/dist/StatusDot.js.map +1 -0
- package/dist/StatusText.d.ts +15 -0
- package/dist/StatusText.d.ts.map +1 -0
- package/dist/StatusText.js +49 -0
- package/dist/StatusText.js.map +1 -0
- package/dist/Switch.d.ts +47 -0
- package/dist/Switch.d.ts.map +1 -0
- package/dist/Switch.js +17 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Table.d.ts +22 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +42 -0
- package/dist/Table.js.map +1 -0
- package/dist/Tabs.d.ts +96 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +319 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tag.d.ts +19 -0
- package/dist/Tag.d.ts.map +1 -0
- package/dist/Tag.js +50 -0
- package/dist/Tag.js.map +1 -0
- package/dist/Textarea.d.ts +32 -0
- package/dist/Textarea.d.ts.map +1 -0
- package/dist/Textarea.js +11 -0
- package/dist/Textarea.js.map +1 -0
- package/dist/Toast.d.ts +47 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +110 -0
- package/dist/Toast.js.map +1 -0
- package/dist/ToggleGroup.d.ts +48 -0
- package/dist/ToggleGroup.d.ts.map +1 -0
- package/dist/ToggleGroup.js +27 -0
- package/dist/ToggleGroup.js.map +1 -0
- package/dist/Tooltip.d.ts +8 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +81 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/VouchedLogo.d.ts +31 -0
- package/dist/VouchedLogo.d.ts.map +1 -0
- package/dist/VouchedLogo.js +215 -0
- package/dist/VouchedLogo.js.map +1 -0
- package/dist/_code-copy-button.d.ts +9 -0
- package/dist/_code-copy-button.d.ts.map +1 -0
- package/dist/_code-copy-button.js +72 -0
- package/dist/_code-copy-button.js.map +1 -0
- package/dist/_code-syntax.d.ts +81 -0
- package/dist/_code-syntax.d.ts.map +1 -0
- package/dist/_code-syntax.js +293 -0
- package/dist/_code-syntax.js.map +1 -0
- package/dist/_status-icons.d.ts +22 -0
- package/dist/_status-icons.d.ts.map +1 -0
- package/dist/_status-icons.js +40 -0
- package/dist/_status-icons.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/format-numbers.d.ts +51 -0
- package/dist/lib/format-numbers.d.ts.map +1 -0
- package/dist/lib/format-numbers.js +158 -0
- package/dist/lib/format-numbers.js.map +1 -0
- package/dist/lib/utils.d.ts +20 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +23 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/public.d.ts +62 -0
- package/dist/public.d.ts.map +1 -0
- package/dist/public.js +66 -0
- package/dist/public.js.map +1 -0
- package/dist/theme-scope.d.ts +55 -0
- package/dist/theme-scope.d.ts.map +1 -0
- package/dist/theme-scope.js +90 -0
- package/dist/theme-scope.js.map +1 -0
- package/dist/tokens.generated.d.ts +335 -0
- package/dist/tokens.generated.d.ts.map +1 -0
- package/dist/tokens.generated.js +349 -0
- package/dist/tokens.generated.js.map +1 -0
- package/package.json +100 -3
- package/styles/README.md +106 -0
- package/styles/base.css +301 -0
- package/styles/canvas.css +147 -0
- package/styles/colors_and_type.css +136 -0
- package/styles/component-contracts.css +471 -0
- package/styles/fonts.css +28 -0
- package/styles/package.css +6 -0
- package/styles/primitive-skins.css +104 -0
- package/styles/semantic-bindings.css +119 -0
- package/styles/shell.css +50 -0
- package/styles/source.css +4 -0
- package/styles/tailwind-bridge.css +255 -0
- package/styles/theme.css +15 -0
- package/styles/tokens.css +1281 -0
- package/styles/vouched-logo.css +336 -0
- package/README.md +0 -3
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Checkpoint · Tabs
|
|
5
|
+
*
|
|
6
|
+
* The canonical animated tab bar: a framer-motion underline that springs
|
|
7
|
+
* between the active segment's measured DOM offsets (the v1 "nice" animation,
|
|
8
|
+
* ported), sitting on a hairline track. The moving bar is the ONLY active
|
|
9
|
+
* indicator — no per-tab static border — so it can't read as a "double
|
|
10
|
+
* underline" (the failure mode of the earlier rejected attempt).
|
|
11
|
+
*
|
|
12
|
+
* Two modes:
|
|
13
|
+
* - controlled — pass `value` + `onValueChange`; renders <button role="tab">.
|
|
14
|
+
* - routed — give each item an `href`; renders a link so tabs drive the
|
|
15
|
+
* URL (nested-route tabs). Active state still comes from `value`
|
|
16
|
+
* (derive it from the pathname at the call site). The link is a
|
|
17
|
+
* plain <a> unless you pass your router's link as
|
|
18
|
+
* `linkComponent` (see TabLinkComponent).
|
|
19
|
+
*
|
|
20
|
+
* Casing-agnostic: `variant="ui"` (Inter, label as-passed; default) or
|
|
21
|
+
* `variant="mono"` (Geist Mono, uppercase tape label) — each surface keeps its
|
|
22
|
+
* own casing. Underline colour is `var(--tab-underline)` → cream on dark,
|
|
23
|
+
* violet on light (tokens.css), so it auto-swaps with the theme.
|
|
24
|
+
*
|
|
25
|
+
* Panels: each tab emits `id="${value}-tab"`. In controlled mode pair your panel
|
|
26
|
+
* with `aria-labelledby` that id (and, if you want full APG semantics, set
|
|
27
|
+
* `role="tabpanel"` + `aria-controls`). Routed mode intentionally omits tabpanel
|
|
28
|
+
* semantics — the panel is a separate route, not a controlled region.
|
|
29
|
+
*
|
|
30
|
+
* `badge` content is part of the tab's accessible name (a count chip reads as
|
|
31
|
+
* "Sessions 12"); wrap a purely decorative badge in `aria-hidden` yourself.
|
|
32
|
+
*/
|
|
33
|
+
import * as React from 'react';
|
|
34
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
35
|
+
import { motion, useReducedMotion } from 'motion/react';
|
|
36
|
+
import { cn } from './lib/utils.js';
|
|
37
|
+
// `hideUnderline` opts a Radix Tabs subtree out of the Checkpoint-wide
|
|
38
|
+
// underline rules in styles/component-contracts.css. The stylesheet
|
|
39
|
+
// targets the list and triggers directly, so the root propagates the decision
|
|
40
|
+
// through context and each styled element stamps the matching data attribute.
|
|
41
|
+
const TabsUnderlineContext = React.createContext(false);
|
|
42
|
+
const TabsValueContext = React.createContext(undefined);
|
|
43
|
+
// useLayoutEffect on the client, useEffect on the server — measure the underline
|
|
44
|
+
// before paint (no grow-in flash) without the SSR warning.
|
|
45
|
+
const useIsoLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
46
|
+
/** Neutral mono count chip for a tab `badge` — one style for every tab strip. */
|
|
47
|
+
export function TabCount({ value }) {
|
|
48
|
+
return (_jsx("span", { style: {
|
|
49
|
+
fontFamily: 'var(--font-mono)',
|
|
50
|
+
fontSize: 'var(--text-mono)',
|
|
51
|
+
background: 'var(--surface-strong)',
|
|
52
|
+
color: 'var(--fg-tertiary)',
|
|
53
|
+
borderRadius: 'var(--radius-xs)',
|
|
54
|
+
padding: '1px 7px',
|
|
55
|
+
fontVariantNumeric: 'tabular-nums',
|
|
56
|
+
}, children: value }));
|
|
57
|
+
}
|
|
58
|
+
export function AnimatedTabs({ items, value, onValueChange, ariaLabel, variant = 'ui', linkComponent, className, }) {
|
|
59
|
+
const reduce = useReducedMotion();
|
|
60
|
+
const listRef = React.useRef(null);
|
|
61
|
+
const tabRefs = React.useRef([]);
|
|
62
|
+
const [underline, setUnderline] = React.useState({ left: 0, width: 0, top: 0 });
|
|
63
|
+
// The indicator springs ONLY in response to a real tab switch (the active
|
|
64
|
+
// index moving between two valid tabs). Mount, SSR→client hydration, resize
|
|
65
|
+
// and font-load re-measures all SNAP — otherwise a first measurement that
|
|
66
|
+
// lands late would slide the bar in from the top-left {0,0,0} origin.
|
|
67
|
+
const [spring, setSpring] = React.useState(false);
|
|
68
|
+
// Last active index, so the layout effect can tell a tab switch (spring) from
|
|
69
|
+
// a re-measure of the same tab (snap). Starts -1 = "no tab positioned yet".
|
|
70
|
+
const prevActiveRef = React.useRef(-1);
|
|
71
|
+
const activeIndex = items.findIndex((t) => t.value === value);
|
|
72
|
+
// Routed if ANY item carries an href — the call site opts in by supplying them.
|
|
73
|
+
const routed = items.some((t) => t.href != null);
|
|
74
|
+
const measure = React.useCallback(() => {
|
|
75
|
+
const el = tabRefs.current[activeIndex];
|
|
76
|
+
if (el)
|
|
77
|
+
setUnderline({
|
|
78
|
+
left: el.offsetLeft,
|
|
79
|
+
width: el.offsetWidth,
|
|
80
|
+
top: el.offsetTop + el.offsetHeight - 2,
|
|
81
|
+
});
|
|
82
|
+
}, [activeIndex]);
|
|
83
|
+
// Position before paint on mount + whenever the active tab changes. Flip on
|
|
84
|
+
// the spring only when the active tab actually changes between two valid tabs,
|
|
85
|
+
// so mount / hydration / resize / font settles stay snapped (no top-left
|
|
86
|
+
// slide-in). Once true it stays true — every later switch springs.
|
|
87
|
+
useIsoLayoutEffect(() => {
|
|
88
|
+
measure();
|
|
89
|
+
if (prevActiveRef.current !== activeIndex) {
|
|
90
|
+
const wasPositioned = prevActiveRef.current >= 0;
|
|
91
|
+
prevActiveRef.current = activeIndex;
|
|
92
|
+
if (wasPositioned && activeIndex >= 0)
|
|
93
|
+
setSpring(true);
|
|
94
|
+
}
|
|
95
|
+
}, [measure, items.length, activeIndex]);
|
|
96
|
+
// Reveal active changes horizontally; resize/font measurements preserve manual scrolling.
|
|
97
|
+
useIsoLayoutEffect(() => {
|
|
98
|
+
const tab = tabRefs.current[activeIndex];
|
|
99
|
+
const list = listRef.current;
|
|
100
|
+
if (!tab)
|
|
101
|
+
return;
|
|
102
|
+
const reveal = () => {
|
|
103
|
+
// Keep the list's inline padding beside the tab, where its focus ring sits.
|
|
104
|
+
const room = parseFloat(getComputedStyle(list).paddingLeft) || 0;
|
|
105
|
+
const left = tab.offsetLeft - room;
|
|
106
|
+
const right = tab.offsetLeft + tab.offsetWidth + room;
|
|
107
|
+
if (left < list.scrollLeft || right - left > list.clientWidth)
|
|
108
|
+
list.scrollLeft = left;
|
|
109
|
+
else if (right > list.scrollLeft + list.clientWidth)
|
|
110
|
+
list.scrollLeft = right - list.clientWidth;
|
|
111
|
+
};
|
|
112
|
+
reveal();
|
|
113
|
+
const initialScrollLeft = list.scrollLeft;
|
|
114
|
+
let cancelled = false;
|
|
115
|
+
const fonts = document.fonts;
|
|
116
|
+
fonts?.ready
|
|
117
|
+
?.then(() => {
|
|
118
|
+
if (!cancelled && list.scrollLeft === initialScrollLeft)
|
|
119
|
+
reveal();
|
|
120
|
+
})
|
|
121
|
+
.catch(() => { });
|
|
122
|
+
return () => {
|
|
123
|
+
cancelled = true;
|
|
124
|
+
};
|
|
125
|
+
}, [activeIndex]);
|
|
126
|
+
// Re-measure on resize/font-load AND when any individual tab changes width
|
|
127
|
+
// (e.g. a count badge ticks 9→10) — observe each tab, not just the container,
|
|
128
|
+
// since a child growing inside a scrolling row needn't resize the container.
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
const ro = new ResizeObserver(() => measure());
|
|
131
|
+
tabRefs.current.forEach((el) => el && ro.observe(el));
|
|
132
|
+
ro.observe(listRef.current);
|
|
133
|
+
const fonts = document.fonts;
|
|
134
|
+
fonts?.ready?.then(() => measure()).catch(() => { });
|
|
135
|
+
return () => ro.disconnect();
|
|
136
|
+
}, [measure, items.length]);
|
|
137
|
+
// Roving-tabindex keyboard model. Arrows/Home/End move focus between tabs,
|
|
138
|
+
// SKIPPING disabled ones (WAI-ARIA APG). A focus target that has no href
|
|
139
|
+
// auto-activates (controlled / mixed); routed targets (href) only take focus
|
|
140
|
+
// so Enter/Space on the Link navigates — arrows don't fire route loads.
|
|
141
|
+
const step = (from, dir) => {
|
|
142
|
+
const n = items.length;
|
|
143
|
+
let next = -1;
|
|
144
|
+
for (let k = 1; k <= n; k++) {
|
|
145
|
+
const idx = (((from + dir * k) % n) + n) % n;
|
|
146
|
+
if (!items[idx].disabled) {
|
|
147
|
+
next = idx;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return next;
|
|
152
|
+
};
|
|
153
|
+
const onKeyDown = (e, index) => {
|
|
154
|
+
let next = -1;
|
|
155
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown')
|
|
156
|
+
next = step(index, 1);
|
|
157
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp')
|
|
158
|
+
next = step(index, -1);
|
|
159
|
+
else if (e.key === 'Home')
|
|
160
|
+
next = step(-1, 1);
|
|
161
|
+
else if (e.key === 'End')
|
|
162
|
+
next = step(0, -1);
|
|
163
|
+
if (next < 0)
|
|
164
|
+
return;
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
tabRefs.current[next]?.focus();
|
|
167
|
+
if (!items[next].href)
|
|
168
|
+
onValueChange?.(items[next].value);
|
|
169
|
+
};
|
|
170
|
+
const isMono = variant === 'mono';
|
|
171
|
+
const activeWeight = isMono ? 500 : 600;
|
|
172
|
+
return (_jsxs("div", { ref: listRef, role: "tablist", "aria-label": ariaLabel, className: cn('cp-tabs min-w-0 flex-nowrap overflow-x-auto overflow-y-hidden', className), style: {
|
|
173
|
+
position: 'relative',
|
|
174
|
+
display: 'flex',
|
|
175
|
+
alignItems: 'stretch',
|
|
176
|
+
gap: 28,
|
|
177
|
+
// A tab's focus ring stands var(--spacing-1) outside it
|
|
178
|
+
// (component-contracts.css), and this scroll box clips at its padding
|
|
179
|
+
// edge. Inline padding gives an edge tab's ring that room; the equal
|
|
180
|
+
// negative margin lines the tabs and the underline up with the
|
|
181
|
+
// container's edges. The track stays the bottom border, below the
|
|
182
|
+
// horizontal scrollbar, and its image leaves the padding's width
|
|
183
|
+
// clear at each end, so it runs between those edges only.
|
|
184
|
+
paddingInline: 'var(--spacing-1)',
|
|
185
|
+
marginInline: 'calc(-1 * var(--spacing-1))',
|
|
186
|
+
maxWidth: 'calc(100% + 2 * var(--spacing-1))',
|
|
187
|
+
scrollPaddingInline: 'var(--spacing-1)',
|
|
188
|
+
borderBottom: '1px solid var(--border-subtle)',
|
|
189
|
+
borderImage: 'linear-gradient(to right, transparent var(--spacing-1), var(--border-subtle) var(--spacing-1), var(--border-subtle) calc(100% - var(--spacing-1)), transparent calc(100% - var(--spacing-1))) 0 0 1 0',
|
|
190
|
+
}, children: [items.map((tab, index) => {
|
|
191
|
+
const isActive = tab.value === value;
|
|
192
|
+
const setRef = (el) => {
|
|
193
|
+
tabRefs.current[index] = el;
|
|
194
|
+
};
|
|
195
|
+
const inner = (_jsxs(_Fragment, { children: [tab.icon ? (_jsx("span", { "aria-hidden": true, style: {
|
|
196
|
+
display: 'inline-flex',
|
|
197
|
+
alignItems: 'center',
|
|
198
|
+
justifyContent: 'center',
|
|
199
|
+
width: 16,
|
|
200
|
+
height: 16,
|
|
201
|
+
color: isActive ? 'var(--tab-underline)' : 'var(--fg-muted)',
|
|
202
|
+
}, children: tab.icon })) : null, _jsxs("span", { style: { position: 'relative', display: 'inline-block', lineHeight: 'normal' }, children: [_jsx("span", { "aria-hidden": true, style: { visibility: 'hidden', fontWeight: activeWeight }, children: tab.label }), _jsx("span", { style: {
|
|
203
|
+
position: 'absolute',
|
|
204
|
+
inset: 0,
|
|
205
|
+
fontWeight: isActive ? activeWeight : 400,
|
|
206
|
+
}, children: tab.label })] }), tab.badge != null ? _jsx("span", { style: { lineHeight: 1 }, children: tab.badge }) : null] }));
|
|
207
|
+
const sharedStyle = {
|
|
208
|
+
position: 'relative',
|
|
209
|
+
display: 'inline-flex',
|
|
210
|
+
alignItems: 'center',
|
|
211
|
+
gap: 8,
|
|
212
|
+
padding: '6px 2px 14px',
|
|
213
|
+
flexShrink: 0,
|
|
214
|
+
whiteSpace: 'nowrap',
|
|
215
|
+
appearance: 'none',
|
|
216
|
+
background: 'transparent',
|
|
217
|
+
border: 0,
|
|
218
|
+
color: isActive ? 'var(--fg-primary)' : 'var(--fg-tertiary)',
|
|
219
|
+
fontFamily: isMono ? 'var(--font-mono)' : 'var(--font-ui)',
|
|
220
|
+
fontSize: isMono ? 'var(--text-xs)' : 'var(--text-sm)',
|
|
221
|
+
letterSpacing: isMono ? 'var(--tracking-eyebrow)' : '0.01em',
|
|
222
|
+
textTransform: isMono ? 'uppercase' : 'none',
|
|
223
|
+
textDecoration: 'none',
|
|
224
|
+
cursor: tab.disabled ? 'not-allowed' : 'pointer',
|
|
225
|
+
opacity: tab.disabled ? 0.45 : 1,
|
|
226
|
+
transition: 'color var(--duration-fast) var(--ease-out)',
|
|
227
|
+
};
|
|
228
|
+
const sharedProps = {
|
|
229
|
+
role: 'tab',
|
|
230
|
+
id: `${tab.value}-tab`,
|
|
231
|
+
'aria-selected': isActive,
|
|
232
|
+
// Only the active tab points at its panel — inactive panels may be
|
|
233
|
+
// lazily unmounted, so a static reference would dangle.
|
|
234
|
+
'aria-controls': isActive && tab.panelId ? tab.panelId : undefined,
|
|
235
|
+
tabIndex: isActive ? 0 : -1,
|
|
236
|
+
onKeyDown: (e) => onKeyDown(e, index),
|
|
237
|
+
style: sharedStyle,
|
|
238
|
+
};
|
|
239
|
+
if (routed && tab.href && !tab.disabled) {
|
|
240
|
+
const TabLink = linkComponent ?? 'a';
|
|
241
|
+
return (_jsx(TabLink, { href: tab.href, ref: setRef, ...sharedProps, children: inner }, tab.value));
|
|
242
|
+
}
|
|
243
|
+
return (_jsx("button", { type: "button", ref: setRef, disabled: tab.disabled, onClick: () => !tab.disabled && onValueChange?.(tab.value), ...sharedProps, children: inner }, tab.value));
|
|
244
|
+
}), _jsx(motion.div, { "aria-hidden": true, style: {
|
|
245
|
+
position: 'absolute',
|
|
246
|
+
top: 0,
|
|
247
|
+
height: 2,
|
|
248
|
+
borderRadius: 'var(--radius-full)',
|
|
249
|
+
background: 'var(--tab-underline)',
|
|
250
|
+
opacity: activeIndex < 0 ? 0 : 1,
|
|
251
|
+
}, initial: false, animate: { left: underline.left, width: underline.width, top: underline.top }, transition: reduce || !spring ? { duration: 0 } : { type: 'spring', stiffness: 300, damping: 30 } })] }));
|
|
252
|
+
}
|
|
253
|
+
export function Tabs({ className, hideUnderline = false, value, defaultValue, onValueChange, ...props }) {
|
|
254
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
255
|
+
return (_jsx(TabsUnderlineContext.Provider, { value: hideUnderline, children: _jsx(TabsValueContext.Provider, { value: value ?? uncontrolledValue, children: _jsx(TabsPrimitive.Root, { "data-slot": "tabs", "data-no-underline": hideUnderline ? 'true' : undefined, className: cn('flex min-w-0 flex-col gap-2', className), value: value, defaultValue: defaultValue, onValueChange: (next) => {
|
|
256
|
+
setUncontrolledValue(next);
|
|
257
|
+
onValueChange?.(next);
|
|
258
|
+
}, ...props }) }) }));
|
|
259
|
+
}
|
|
260
|
+
export function TabsList({ className, ref, ...props }) {
|
|
261
|
+
const hideUnderline = React.useContext(TabsUnderlineContext);
|
|
262
|
+
const activeValue = React.useContext(TabsValueContext);
|
|
263
|
+
const listRef = React.useRef(null);
|
|
264
|
+
const setRef = React.useCallback((node) => {
|
|
265
|
+
listRef.current = node;
|
|
266
|
+
if (typeof ref === 'function')
|
|
267
|
+
return ref(node);
|
|
268
|
+
if (ref)
|
|
269
|
+
ref.current = node;
|
|
270
|
+
}, [ref]);
|
|
271
|
+
useIsoLayoutEffect(() => {
|
|
272
|
+
const list = listRef.current;
|
|
273
|
+
if (list.getAttribute('aria-orientation') === 'vertical' ||
|
|
274
|
+
!['auto', 'scroll'].includes(getComputedStyle(list).overflowX))
|
|
275
|
+
return;
|
|
276
|
+
const tab = list.querySelector('[role="tab"][data-state="active"]');
|
|
277
|
+
if (!tab)
|
|
278
|
+
return;
|
|
279
|
+
const reveal = () => {
|
|
280
|
+
const bounds = list.getBoundingClientRect();
|
|
281
|
+
if (!list.offsetWidth || !bounds.width)
|
|
282
|
+
return;
|
|
283
|
+
// Rects include ancestor scale/zoom; scrolling and client sizes use layout pixels.
|
|
284
|
+
const scale = bounds.width / list.offsetWidth;
|
|
285
|
+
const target = tab.getBoundingClientRect();
|
|
286
|
+
const left = (target.left - bounds.left) / scale - list.clientLeft;
|
|
287
|
+
const width = target.width / scale;
|
|
288
|
+
const right = left + width;
|
|
289
|
+
if (left < 0 || width > list.clientWidth)
|
|
290
|
+
list.scrollLeft += left;
|
|
291
|
+
else if (right > list.clientWidth)
|
|
292
|
+
list.scrollLeft += right - list.clientWidth;
|
|
293
|
+
};
|
|
294
|
+
reveal();
|
|
295
|
+
const initialScrollLeft = list.scrollLeft;
|
|
296
|
+
let cancelled = false;
|
|
297
|
+
const fonts = document.fonts;
|
|
298
|
+
fonts?.ready
|
|
299
|
+
?.then(() => {
|
|
300
|
+
if (!cancelled && list.scrollLeft === initialScrollLeft)
|
|
301
|
+
reveal();
|
|
302
|
+
})
|
|
303
|
+
.catch(() => { });
|
|
304
|
+
return () => {
|
|
305
|
+
cancelled = true;
|
|
306
|
+
};
|
|
307
|
+
}, [activeValue]);
|
|
308
|
+
return (_jsx(TabsPrimitive.List, { ref: setRef, "data-slot": "tabs-list", "data-no-underline": hideUnderline ? 'true' : undefined, className: cn('inline-flex min-h-9 w-fit min-w-0 max-w-full flex-nowrap items-center overflow-x-auto overflow-y-hidden rounded-[var(--radius-md)] bg-[color:var(--surface-default)] p-1 text-[color:var(--fg-muted)]', className), ...props }));
|
|
309
|
+
}
|
|
310
|
+
export function TabsTrigger({ className, ...props }) {
|
|
311
|
+
const { hideFocusRing, ...rest } = props;
|
|
312
|
+
const hideUnderline = React.useContext(TabsUnderlineContext);
|
|
313
|
+
return (_jsx(TabsPrimitive.Trigger, { "data-slot": "tabs-trigger", "data-no-underline": hideUnderline ? 'true' : undefined, className: cn('inline-flex h-7 shrink-0 items-center justify-center whitespace-nowrap rounded-sm px-2 text-sm font-medium', 'text-[color:var(--fg-tertiary)] data-[state=active]:bg-[color:var(--bg-elevated)] data-[state=active]:text-[color:var(--fg-primary)]', !hideFocusRing &&
|
|
314
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring', className), ...rest }));
|
|
315
|
+
}
|
|
316
|
+
export function TabsContent({ className, ...props }) {
|
|
317
|
+
return (_jsx(TabsPrimitive.Content, { "data-slot": "tabs-content", className: cn('min-w-0 flex-1 outline-none', className), ...props }));
|
|
318
|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AAC"}
|
package/dist/Tag.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
/**
|
|
4
|
+
* Generic categorical label. Use `Pill` for verdict vocabulary and
|
|
5
|
+
* `Badge` for notification counts/presence.
|
|
6
|
+
*
|
|
7
|
+
* Categorical means a value from the data (a detection class, a scope,
|
|
8
|
+
* an environment), never a promotional word like New / Free / Beta
|
|
9
|
+
* (docs/design-system/rule-book-marks.md).
|
|
10
|
+
*/
|
|
11
|
+
declare const tagVariants: (props?: ({
|
|
12
|
+
variant?: "default" | "success" | "info" | "destructive" | "warning" | "primary" | "secondary" | "outline" | "ghost" | "neutral" | "subtle" | null | undefined;
|
|
13
|
+
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
14
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
|
+
export interface TagProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof tagVariants> {
|
|
16
|
+
}
|
|
17
|
+
export declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export { tagVariants };
|
|
19
|
+
//# sourceMappingURL=Tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../src/Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE;;;;;;;GAOG;AACH,QAAA,MAAM,WAAW;;;8EAuChB,CAAC;AAEF,MAAM,WAAW,QACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC,OAAO,WAAW,CAAC;CAAG;AAEnF,eAAO,MAAM,GAAG,iFAcd,CAAC;AAEH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/Tag.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from './lib/utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Generic categorical label. Use `Pill` for verdict vocabulary and
|
|
7
|
+
* `Badge` for notification counts/presence.
|
|
8
|
+
*
|
|
9
|
+
* Categorical means a value from the data (a detection class, a scope,
|
|
10
|
+
* an environment), never a promotional word like New / Free / Beta
|
|
11
|
+
* (docs/design-system/rule-book-marks.md).
|
|
12
|
+
*/
|
|
13
|
+
const tagVariants = cva('inline-flex items-center gap-1 rounded-[var(--radius-xs)] border font-medium tracking-tight transition-colors', {
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
default: 'border-transparent bg-brand text-on-brand hover:bg-brand-hover',
|
|
17
|
+
primary: 'border-transparent bg-brand text-on-brand hover:bg-brand-hover',
|
|
18
|
+
secondary: 'border-transparent bg-[color:var(--surface-default)] text-[color:var(--fg-primary)]',
|
|
19
|
+
// --surface-strong is the one surface step as heavy as the tone washes
|
|
20
|
+
// below (1.13-1.21:1 against canvas, card and hovered row in both
|
|
21
|
+
// themes); --surface-subtle read 1.03-1.06:1, a box you can't see.
|
|
22
|
+
neutral: 'border-transparent bg-[color:var(--surface-strong)] text-[color:var(--fg-primary)]',
|
|
23
|
+
// --fg-muted read 3.14:1 dark and 4.15:1 light; --fg-tertiary is the
|
|
24
|
+
// quietest step that clears AA in both (4.8:1 at worst, on a hovered
|
|
25
|
+
// dark row).
|
|
26
|
+
subtle: 'border-transparent bg-[color:var(--surface-strong)] text-[color:var(--fg-tertiary)]',
|
|
27
|
+
outline: 'border-[color:var(--border-default)] bg-transparent text-[color:var(--fg-primary)]',
|
|
28
|
+
ghost: 'border-transparent bg-transparent text-[color:var(--fg-primary)]',
|
|
29
|
+
// Tones carry fill and text only: a tinted border on top of a
|
|
30
|
+
// tinted fill drew a second box around the value.
|
|
31
|
+
success: 'border-transparent bg-[color:var(--allow)]/10 text-allow-text',
|
|
32
|
+
warning: 'border-transparent bg-warn/10 text-warn-text',
|
|
33
|
+
// --brand read 2.11:1 on its dark wash; --brand-text clears AA in both themes.
|
|
34
|
+
info: 'border-transparent bg-brand-soft text-[color:var(--brand-text)]',
|
|
35
|
+
destructive: 'border-transparent bg-deny/10 text-deny-text hover:bg-deny/20',
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
xs: 'h-5 px-2 text-[length:var(--text-control-xs)] leading-4',
|
|
39
|
+
sm: 'h-6 px-2.5 text-xs leading-4',
|
|
40
|
+
md: 'h-7 px-3 text-sm leading-4.5',
|
|
41
|
+
lg: 'h-8 px-3.5 text-sm leading-5',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: { variant: 'primary', size: 'sm' },
|
|
45
|
+
});
|
|
46
|
+
export const Tag = React.forwardRef(function Tag({ className, variant = 'primary', size = 'sm', ...props }, ref) {
|
|
47
|
+
return (_jsx("div", { ref: ref, "data-slot": "tag", "data-variant": variant, "data-size": size, className: cn(tagVariants({ variant, size }), className), ...props }));
|
|
48
|
+
});
|
|
49
|
+
export { tagVariants };
|
|
50
|
+
//# sourceMappingURL=Tag.js.map
|
package/dist/Tag.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../src/Tag.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,GAAG,CACrB,+GAA+G,EAC/G;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,gEAAgE;YACzE,OAAO,EAAE,gEAAgE;YACzE,SAAS,EACP,qFAAqF;YACvF,uEAAuE;YACvE,kEAAkE;YAClE,mEAAmE;YACnE,OAAO,EACL,oFAAoF;YACtF,qEAAqE;YACrE,qEAAqE;YACrE,aAAa;YACb,MAAM,EACJ,qFAAqF;YACvF,OAAO,EACL,oFAAoF;YACtF,KAAK,EAAE,kEAAkE;YACzE,8DAA8D;YAC9D,kDAAkD;YAClD,OAAO,EAAE,+DAA+D;YACxE,OAAO,EAAE,8CAA8C;YACvD,+EAA+E;YAC/E,IAAI,EAAE,iEAAiE;YACvE,WAAW,EAAE,+DAA+D;SAC7E;QACD,IAAI,EAAE;YACJ,EAAE,EAAE,yDAAyD;YAC7D,EAAE,EAAE,8BAA8B;YAClC,EAAE,EAAE,8BAA8B;YAClC,EAAE,EAAE,8BAA8B;SACnC;KACF;IACD,eAAe,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE;CACpD,CACF,CAAC;AAKF,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAA2B,SAAS,GAAG,CACxE,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,EACzD,GAAG;IAEH,OAAO,CACL,cACE,GAAG,EAAE,GAAG,eACE,KAAK,kBACD,OAAO,eACV,IAAI,EACf,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,KACpD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Checkpoint · Textarea
|
|
4
|
+
*
|
|
5
|
+
* Multi-line text input. Distinct primitive from `<Input>` per the
|
|
6
|
+
* SSOT — different min-height, vertical-only resize, and `:focus`
|
|
7
|
+
* recipe lifted to a real native pseudoclass (Input handles focus
|
|
8
|
+
* via shared CSS too, but the layout is single-line so it's
|
|
9
|
+
* cosmetically equivalent).
|
|
10
|
+
*
|
|
11
|
+
* Same chrome as Input + Select — 34h floor → 80h min for multi-line
|
|
12
|
+
* content, surf-1 bg, line border, radius-xs corners, accent-line
|
|
13
|
+
* focus + bg-1 lift. `resize: vertical` so users can grow the field
|
|
14
|
+
* but not blow out the column horizontally.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
*
|
|
18
|
+
* <Textarea
|
|
19
|
+
* value={notes}
|
|
20
|
+
* onChange={(e) => setNotes(e.target.value)}
|
|
21
|
+
* placeholder="Describe the policy intent…"
|
|
22
|
+
* rows={4}
|
|
23
|
+
* />
|
|
24
|
+
*
|
|
25
|
+
* {/* Inside Field for label + helper + error treatment *\/}
|
|
26
|
+
* <Field label="Policy notes" hint="Visible to other reviewers.">
|
|
27
|
+
* <Textarea value={notes} onChange={...} />
|
|
28
|
+
* </Field>
|
|
29
|
+
*/
|
|
30
|
+
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
31
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
32
|
+
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../src/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;AAE9E,eAAO,MAAM,QAAQ,2FA0BnB,CAAC"}
|
package/dist/Textarea.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from './lib/utils.js';
|
|
4
|
+
export const Textarea = React.forwardRef(function Textarea({ className, rows = 4, ...rest }, ref) {
|
|
5
|
+
return (_jsx("textarea", { ref: ref, rows: rows, className: cn(
|
|
6
|
+
// Same family chrome as Input — 80h min vs Input's 34h fixed.
|
|
7
|
+
'block w-full min-h-[80px]', 'bg-[var(--surface-subtle)] text-[var(--fg-primary)]', 'border border-[color:var(--border-subtle)] rounded-[var(--radius-xs)]', 'font-sans text-[length:var(--text-control)] leading-[var(--text-control--line-height)]', 'px-3 py-2.5', 'placeholder:text-[var(--fg-muted)]', 'resize-y',
|
|
8
|
+
// Focus matches Input and Select: the --ring outline, plus a bg-1 lift.
|
|
9
|
+
'focus:bg-[var(--bg-surface)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring', 'disabled:opacity-50 disabled:cursor-not-allowed', 'transition-[background-color] duration-[var(--duration-fast)] ease-[var(--ease-out)]', className), ...rest }));
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=Textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../src/Textarea.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAiCpC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAqC,SAAS,QAAQ,CAC5F,EAAE,SAAS,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,EAChC,GAAG;IAEH,OAAO,CACL,mBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE;QACX,8DAA8D;QAC9D,2BAA2B,EAC3B,qDAAqD,EACrD,uEAAuE,EACvE,wFAAwF,EACxF,aAAa,EACb,oCAAoC,EACpC,UAAU;QACV,wEAAwE;QACxE,gHAAgH,EAChH,iDAAiD,EACjD,sFAAsF,EACtF,SAAS,CACV,KACG,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Toaster as SonnerToaster, toast as sonnerToast } from 'sonner';
|
|
3
|
+
/**
|
|
4
|
+
* Checkpoint · Toast
|
|
5
|
+
*
|
|
6
|
+
* Sonner wrapped in checkpoint chrome. Same behavior layer (queue,
|
|
7
|
+
* auto-dismiss, swipe, stacking, focus on hover-pause), different
|
|
8
|
+
* look layer matching the SSOT `.demo-toast` spec:
|
|
9
|
+
*
|
|
10
|
+
* - Surface: `--bg-elevated` + 1px `--border-default`
|
|
11
|
+
* - Radius: `--radius-md` (6 px) per SSOT
|
|
12
|
+
* - Width: min 280 / max 380 per SSOT
|
|
13
|
+
* - Icon inherits status color (allow / deny / warn / info)
|
|
14
|
+
* - Title 14 px / 500, description 12.5 px / regular
|
|
15
|
+
* - Anchored bottom-right; 4–6 s auto-dismiss
|
|
16
|
+
*
|
|
17
|
+
* Theme scope — identical problem/solution as Tooltip's portal scope.
|
|
18
|
+
* Sonner renders its container inline (not via Radix portal), but it still
|
|
19
|
+
* sits outside the `[data-theme*="checkpoint"]` ancestry unless we stamp
|
|
20
|
+
* the scope ourselves. `useThemeScope()` gives the theme and the mode
|
|
21
|
+
* (the nearest ThemeScopeProvider's, else next-themes') so the toast
|
|
22
|
+
* chrome follows the shell's active theme instead of being pinned to dark.
|
|
23
|
+
*
|
|
24
|
+
* Mount the `<Toaster>` once at the dashboard root (or any checkpoint
|
|
25
|
+
* surface that wants toasts), then call `toast.success(...)` etc.
|
|
26
|
+
* from anywhere in the subtree.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
*
|
|
30
|
+
* // Once in the layout:
|
|
31
|
+
* import { Toaster } from '@vouched-id/ui';
|
|
32
|
+
* <Toaster />
|
|
33
|
+
*
|
|
34
|
+
* // Anywhere:
|
|
35
|
+
* import { toast } from '@vouched-id/ui';
|
|
36
|
+
* toast.success('Policy saved', { description: 'customer-success-v3 is now live.' });
|
|
37
|
+
* toast.error('Webhook failed', { description: '3 deliveries returned 502.' });
|
|
38
|
+
* toast.warn('Approaching plan limit', { description: 'You\'ve used 1.8M of 2M.' });
|
|
39
|
+
* toast.info('SDK v4 is out', { description: 'New agent identity ladder.' });
|
|
40
|
+
*/
|
|
41
|
+
export interface ToasterProps extends React.ComponentProps<typeof SonnerToaster> {
|
|
42
|
+
}
|
|
43
|
+
export declare function Toaster(props: ToasterProps): React.JSX.Element;
|
|
44
|
+
export declare const toast: typeof sonnerToast & {
|
|
45
|
+
warn: typeof sonnerToast.warning;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAKxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC;CAAG;AAEnF,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,qBAsE1C;AA+CD,eAAO,MAAM,KAAK,EAOZ,OAAO,WAAW,GAAG;IAAE,IAAI,EAAE,OAAO,WAAW,CAAC,OAAO,CAAA;CAAE,CAAC"}
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Toaster as SonnerToaster, toast as sonnerToast } from 'sonner';
|
|
5
|
+
import { DenyGlyph, InfoGlyph, SuccessGlyph, WarnGlyph } from './_status-icons.js';
|
|
6
|
+
import { useThemeScope } from './theme-scope.js';
|
|
7
|
+
export function Toaster(props) {
|
|
8
|
+
const scope = useThemeScope();
|
|
9
|
+
return (
|
|
10
|
+
// `data-theme` and the mode class scope checkpoint CSS custom properties
|
|
11
|
+
// into the Sonner container, from `useThemeScope()`. `suppressHydrationWarning` is intentional, not a bandaid:
|
|
12
|
+
// the server can't know the user's theme preference so it always emits the
|
|
13
|
+
// dark default; the client corrects it after next-themes hydrates. No toast
|
|
14
|
+
// children are SSR-rendered (toasts only appear after user interaction,
|
|
15
|
+
// post-hydration), so there is nothing to flash. Compare ShellLayout, which
|
|
16
|
+
// also uses suppressHydrationWarning but adds a pre-paint script because its
|
|
17
|
+
// visible content needs the right theme from first paint — the Toaster has
|
|
18
|
+
// no visible content at SSR time, so the script is unnecessary here.
|
|
19
|
+
_jsx("div", { "data-theme": scope.theme, className: scope.mode, style: { display: 'contents' }, suppressHydrationWarning: true, children: _jsx(SonnerToaster, { position: "bottom-right", duration: 5000, gap: 12, className: "checkpoint-toaster", icons: ICONS, toastOptions: {
|
|
20
|
+
// Per-class skin — checkpoint surface + border + radius + type
|
|
21
|
+
// scale. Sonner exposes a class for every sub-part; we hit
|
|
22
|
+
// each so default sonner styling can't bleed through.
|
|
23
|
+
classNames: {
|
|
24
|
+
toast: [
|
|
25
|
+
'group',
|
|
26
|
+
'flex items-start gap-3',
|
|
27
|
+
'px-4 py-3.5',
|
|
28
|
+
'min-w-[280px] max-w-[380px]',
|
|
29
|
+
'bg-[var(--bg-elevated)]',
|
|
30
|
+
'border border-[color:var(--border-default)]',
|
|
31
|
+
'rounded-[var(--radius-md)]',
|
|
32
|
+
'shadow-[var(--shadow-md)]',
|
|
33
|
+
'font-sans',
|
|
34
|
+
].join(' '),
|
|
35
|
+
title: 'text-[length:var(--text-sm)] font-medium text-ink leading-snug',
|
|
36
|
+
// `text-ink-muted` (not `text-ink-secondary`) — the @theme
|
|
37
|
+
// bridge in tailwind-bridge.css maps the checkpoint --fg-secondary
|
|
38
|
+
// token to `--color-ink-muted`, so Tailwind generates the
|
|
39
|
+
// utility as `text-ink-muted`. The earlier `text-ink-secondary`
|
|
40
|
+
// was a typo and didn't resolve — description text fell
|
|
41
|
+
// back to inheritance, rendering identical to the title.
|
|
42
|
+
description: 'text-[length:var(--text-caption)] font-normal text-ink-muted leading-[var(--text-caption--line-height)] mt-0.5',
|
|
43
|
+
icon: 'shrink-0 w-[18px] h-[18px] mt-px',
|
|
44
|
+
closeButton: [
|
|
45
|
+
'right-2 top-2 left-auto',
|
|
46
|
+
'h-5 w-5 grid place-items-center',
|
|
47
|
+
'border-0 bg-transparent',
|
|
48
|
+
'text-ink-muted hover:text-ink hover:bg-[var(--surface-default)]',
|
|
49
|
+
'rounded-sm transition-colors',
|
|
50
|
+
].join(' '),
|
|
51
|
+
// Status tint flows to the icon via Sonner's class-on-toast
|
|
52
|
+
// pattern. The icon SVG uses `currentColor` so coloring the
|
|
53
|
+
// toast's text class cascades to it.
|
|
54
|
+
success: 'text-allow-text',
|
|
55
|
+
error: 'text-deny-text',
|
|
56
|
+
warning: 'text-warn-text',
|
|
57
|
+
info: 'text-info-text',
|
|
58
|
+
},
|
|
59
|
+
}, ...props }) }));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Status icons consumed by Sonner's per-toast icon slot. Same four
|
|
63
|
+
* glyphs Banner uses — sourced from the shared `_status-icons`
|
|
64
|
+
* module so both primitives stay byte-identical.
|
|
65
|
+
*/
|
|
66
|
+
const ICONS = {
|
|
67
|
+
success: _jsx(SuccessGlyph, {}),
|
|
68
|
+
error: _jsx(DenyGlyph, {}),
|
|
69
|
+
warning: _jsx(WarnGlyph, {}),
|
|
70
|
+
info: _jsx(InfoGlyph, {}),
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Checkpoint-flavored `toast` API.
|
|
74
|
+
*
|
|
75
|
+
* Wraps Sonner's `toast` function + every method (`success`,
|
|
76
|
+
* `error`, `warning`, `info`, `message`, `promise`, `custom`,
|
|
77
|
+
* `dismiss`, `loading`, …) and adds one ergonomic alias: `warn` →
|
|
78
|
+
* sonner's `warning`, matching our status vocabulary everywhere
|
|
79
|
+
* else (`--warn` / `--warn-soft` / `--warn-line` / `Pill verdict="warn"`).
|
|
80
|
+
*
|
|
81
|
+
* Implementation note — Proxy over Object.assign
|
|
82
|
+
* ----------------------------------------------
|
|
83
|
+
*
|
|
84
|
+
* The earlier `Object.assign(sonnerToast, { warn: sonnerToast.warning })`
|
|
85
|
+
* mutated Sonner's exported `toast` function in place. ES modules
|
|
86
|
+
* share references, so every `import { toast } from 'sonner'` call
|
|
87
|
+
* site in the rest of the app would have silently picked up `.warn`
|
|
88
|
+
* as a side effect of loading the checkpoint barrel — implicit
|
|
89
|
+
* cross-module coupling, and a collision risk if Sonner ever adds
|
|
90
|
+
* its own `.warn`. Also crashed under partial test mocks because
|
|
91
|
+
* `sonnerToast.warning` was read at module load.
|
|
92
|
+
*
|
|
93
|
+
* The Proxy here defers ALL property reads to call time. Reads go
|
|
94
|
+
* through the `get` trap, never touch sonner at module load (so
|
|
95
|
+
* partial mocks don't crash), and never mutate sonner's export.
|
|
96
|
+
* `warn` is intercepted to alias to sonner's `warning`; every other
|
|
97
|
+
* property falls through to whatever sonner exposes natively.
|
|
98
|
+
*/
|
|
99
|
+
const toastTarget = function (...args) {
|
|
100
|
+
return sonnerToast(...args);
|
|
101
|
+
};
|
|
102
|
+
export const toast = new Proxy(toastTarget, {
|
|
103
|
+
get(_target, prop, receiver) {
|
|
104
|
+
if (prop === 'warn') {
|
|
105
|
+
return sonnerToast?.warning;
|
|
106
|
+
}
|
|
107
|
+
return Reflect.get(sonnerToast, prop, receiver);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=Toast.js.map
|