@epilot/zenith-react 0.2.0-next.0 → 0.2.0-next.3
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/components/accordion/accordion.js +57 -48
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +120 -92
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/avatar/avatar-group.js +38 -35
- package/dist/components/avatar/avatar-group.js.map +1 -1
- package/dist/components/avatar/avatar.js +78 -71
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js +60 -55
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +99 -54
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js +87 -77
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button-group/button-group.js +36 -32
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/callout/callout.js +105 -98
- package/dist/components/callout/callout.js.map +1 -1
- package/dist/components/card/card.js +62 -52
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +22 -19
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/code-block/code-block.js +135 -123
- package/dist/components/code-block/code-block.js.map +1 -1
- package/dist/components/code-editor/code-editor.js +276 -260
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/collapsible-sidebar/collapsible-sidebar.js +62 -56
- package/dist/components/collapsible-sidebar/collapsible-sidebar.js.map +1 -1
- package/dist/components/command/command.js +116 -105
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/data-table/data-table-body.js +38 -34
- package/dist/components/data-table/data-table-body.js.map +1 -1
- package/dist/components/data-table/data-table-column-header.js +30 -26
- package/dist/components/data-table/data-table-column-header.js.map +1 -1
- package/dist/components/data-table/data-table-column-order.js +79 -73
- package/dist/components/data-table/data-table-column-order.js.map +1 -1
- package/dist/components/data-table/data-table-column-visibility.js +25 -22
- package/dist/components/data-table/data-table-column-visibility.js.map +1 -1
- package/dist/components/data-table/data-table-content.js +47 -44
- package/dist/components/data-table/data-table-content.js.map +1 -1
- package/dist/components/data-table/data-table-error.js +36 -32
- package/dist/components/data-table/data-table-error.js.map +1 -1
- package/dist/components/data-table/data-table-footer.js +10 -8
- package/dist/components/data-table/data-table-footer.js.map +1 -1
- package/dist/components/data-table/data-table-header-draggable.js +40 -36
- package/dist/components/data-table/data-table-header-draggable.js.map +1 -1
- package/dist/components/data-table/data-table-header.js +113 -99
- package/dist/components/data-table/data-table-header.js.map +1 -1
- package/dist/components/data-table/data-table-loading.js +21 -18
- package/dist/components/data-table/data-table-loading.js.map +1 -1
- package/dist/components/data-table/data-table-resize-handle.js +13 -11
- package/dist/components/data-table/data-table-resize-handle.js.map +1 -1
- package/dist/components/data-table/data-table-row.js +71 -59
- package/dist/components/data-table/data-table-row.js.map +1 -1
- package/dist/components/data-table/data-table-toolbar.js +9 -7
- package/dist/components/data-table/data-table-toolbar.js.map +1 -1
- package/dist/components/data-table/data-table.js +48 -46
- package/dist/components/data-table/data-table.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.js +173 -164
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/date-range-picker/range-calendar.js +36 -34
- package/dist/components/date-range-picker/range-calendar.js.map +1 -1
- package/dist/components/date-time-picker/calendar.js +290 -272
- package/dist/components/date-time-picker/calendar.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-input.js +22 -20
- package/dist/components/date-time-picker/date-time-picker-input.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker-panel.js +126 -120
- package/dist/components/date-time-picker/date-time-picker-panel.js.map +1 -1
- package/dist/components/date-time-picker/date-time-picker.js +42 -40
- package/dist/components/date-time-picker/date-time-picker.js.map +1 -1
- package/dist/components/date-time-picker/time-picker.js +95 -87
- package/dist/components/date-time-picker/time-picker.js.map +1 -1
- package/dist/components/dialog/dialog.js +115 -95
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +144 -109
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +141 -112
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field-combobox.js +196 -176
- package/dist/components/field/field-combobox.js.map +1 -1
- package/dist/components/field/field.js +137 -126
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/list/list.js +237 -219
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/option-card/option-card.js +129 -116
- package/dist/components/option-card/option-card.js.map +1 -1
- package/dist/components/pill/pill.js +55 -51
- package/dist/components/pill/pill.js.map +1 -1
- package/dist/components/popover/popover.js +53 -36
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/radio/radio.js +38 -34
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +38 -35
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/scroll-overflow/scroll-overflow.js +166 -151
- package/dist/components/scroll-overflow/scroll-overflow.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +93 -85
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.js +149 -128
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js +19 -16
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/skeleton/skeleton.js +34 -30
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/spinner/spinner.js +22 -17
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/surface/surface.js +25 -22
- package/dist/components/surface/surface.js.map +1 -1
- package/dist/components/switch/switch.js +66 -57
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table-pagination.js +139 -129
- package/dist/components/table/table-pagination.js.map +1 -1
- package/dist/components/table/table.js +104 -90
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.js +206 -128
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/toast/toast.js +112 -100
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toggle/toggle.js +32 -30
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +59 -46
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/lib/clear-button.js +18 -17
- package/dist/lib/clear-button.js.map +1 -1
- package/dist/styles/host-reset.js +47 -0
- package/dist/styles/host-reset.js.map +1 -0
- package/dist/styles/overlay-layer.js +5 -0
- package/dist/styles/overlay-layer.js.map +1 -0
- package/dist/tokens.json +1 -1
- package/package.json +8 -6
- package/scripts/migration-diagnostics.mjs +42 -7
- package/scripts/migration-sweep.mjs +9 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { mergeClasses as
|
|
4
|
-
import { makeZenithStyles as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import { mergeClasses as B, SLOT_ATTR as H, shorthands as n } from "@epilot/zenith-runtime/v1";
|
|
4
|
+
import { makeZenithStyles as R } from "../../styles/make-styles.js";
|
|
5
|
+
import { boxModel as i, nativeControl as I } from "../../styles/host-reset.js";
|
|
6
|
+
import { capTrim as z } from "../../styles/text-box.js";
|
|
7
|
+
import { radiusLg as E, buttonIconSize as h, leadingLg as L, textLg as O, leadingBase as T, textBase as A, buttonBaseMinHeight as D, leadingSm as P, textSm as X, leadingXs as $, textXs as M, errorSoft as u, errorA11 as V, errorSoftHover as W, errorOnSoft as j, errorSolidHover as p, errorContrast as N, errorSolid as F, accentSoft as g, grayA12 as K, accentA11 as Z, accentSoftHover as _, accentOnSoft as q, accentSolidHover as b, accentContrast as G, accentSolid as J, focusRing as Q, fontWeightSemibold as U, buttonBasePaddingInline as Y, spacingElement3 as ee } from "../../tokens/index.js";
|
|
8
|
+
import { Root as oe } from "../../vendor/.bun/@radix-ui_react-slot@1.2.4_0ac650c021fb1b59/vendor/@radix-ui/react-slot/dist/index.js";
|
|
9
|
+
const te = "button", re = R({
|
|
9
10
|
root: {
|
|
11
|
+
...I,
|
|
10
12
|
display: "inline-flex",
|
|
11
13
|
alignItems: "center",
|
|
12
14
|
justifyContent: "center",
|
|
13
|
-
fontWeight:
|
|
15
|
+
fontWeight: U,
|
|
14
16
|
whiteSpace: "nowrap",
|
|
15
17
|
transitionProperty: "all",
|
|
16
18
|
cursor: "pointer",
|
|
@@ -22,7 +24,7 @@ const ee = "button", oe = H({
|
|
|
22
24
|
outlineWidth: "2px",
|
|
23
25
|
outlineStyle: "solid",
|
|
24
26
|
outlineOffset: "2px",
|
|
25
|
-
outlineColor:
|
|
27
|
+
outlineColor: Q
|
|
26
28
|
},
|
|
27
29
|
"@media (prefers-reduced-motion: reduce)": {
|
|
28
30
|
transitionDuration: "0.01ms"
|
|
@@ -33,160 +35,168 @@ const ee = "button", oe = H({
|
|
|
33
35
|
color: "currentColor"
|
|
34
36
|
}
|
|
35
37
|
},
|
|
36
|
-
label:
|
|
38
|
+
label: z,
|
|
37
39
|
primary: {
|
|
38
|
-
backgroundColor:
|
|
39
|
-
color:
|
|
40
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
41
|
-
":active:not(:disabled)": { backgroundColor:
|
|
40
|
+
backgroundColor: J,
|
|
41
|
+
color: G,
|
|
42
|
+
":hover:not(:disabled)": { backgroundColor: b },
|
|
43
|
+
":active:not(:disabled)": { backgroundColor: b }
|
|
42
44
|
},
|
|
43
45
|
secondary: {
|
|
44
|
-
backgroundColor:
|
|
45
|
-
color:
|
|
46
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
46
|
+
backgroundColor: g,
|
|
47
|
+
color: q,
|
|
48
|
+
":hover:not(:disabled)": { backgroundColor: _ }
|
|
47
49
|
},
|
|
48
50
|
tertiary: {
|
|
49
51
|
backgroundColor: "transparent",
|
|
50
|
-
color:
|
|
51
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
52
|
+
color: Z,
|
|
53
|
+
":hover:not(:disabled)": { backgroundColor: g }
|
|
52
54
|
},
|
|
53
55
|
ghost: {
|
|
54
56
|
backgroundColor: "transparent",
|
|
55
|
-
color:
|
|
56
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
57
|
+
color: K,
|
|
58
|
+
":hover:not(:disabled)": { backgroundColor: g }
|
|
57
59
|
},
|
|
58
60
|
primaryDestructive: {
|
|
59
|
-
backgroundColor:
|
|
60
|
-
color:
|
|
61
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
62
|
-
":active:not(:disabled)": { backgroundColor:
|
|
61
|
+
backgroundColor: F,
|
|
62
|
+
color: N,
|
|
63
|
+
":hover:not(:disabled)": { backgroundColor: p },
|
|
64
|
+
":active:not(:disabled)": { backgroundColor: p }
|
|
63
65
|
},
|
|
64
66
|
secondaryDestructive: {
|
|
65
|
-
backgroundColor:
|
|
66
|
-
color:
|
|
67
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
67
|
+
backgroundColor: u,
|
|
68
|
+
color: j,
|
|
69
|
+
":hover:not(:disabled)": { backgroundColor: W }
|
|
68
70
|
},
|
|
69
71
|
tertiaryDestructive: {
|
|
70
72
|
backgroundColor: "transparent",
|
|
71
|
-
color:
|
|
72
|
-
":hover:not(:disabled)": { backgroundColor:
|
|
73
|
+
color: V,
|
|
74
|
+
":hover:not(:disabled)": { backgroundColor: u }
|
|
73
75
|
},
|
|
74
76
|
xs: {
|
|
77
|
+
...i,
|
|
75
78
|
...n.paddingInline("0.5rem"),
|
|
76
79
|
...n.paddingBlock("0.25rem"),
|
|
77
80
|
// Cap trimming removes the line-height's leading from direct text. Keep the established
|
|
78
81
|
// 24px control geometry explicitly instead of relying on that incidental text height.
|
|
79
82
|
minHeight: "1.5rem",
|
|
80
|
-
fontSize:
|
|
81
|
-
lineHeight:
|
|
83
|
+
fontSize: M,
|
|
84
|
+
lineHeight: $,
|
|
82
85
|
gap: "4px",
|
|
83
86
|
"& svg": { width: "0.75rem", height: "0.75rem" }
|
|
84
87
|
},
|
|
85
88
|
sm: {
|
|
86
|
-
...
|
|
89
|
+
...i,
|
|
90
|
+
...n.paddingInline(ee),
|
|
87
91
|
...n.paddingBlock("0.25rem"),
|
|
88
92
|
// As above, the fixed 28px size is part of Button's contract, independent of its label box.
|
|
89
93
|
minHeight: "1.75rem",
|
|
90
|
-
fontSize:
|
|
91
|
-
lineHeight:
|
|
94
|
+
fontSize: X,
|
|
95
|
+
lineHeight: P,
|
|
92
96
|
gap: "0.375rem",
|
|
93
97
|
"& svg": { width: "0.875rem", height: "0.875rem" }
|
|
94
98
|
},
|
|
95
99
|
base: {
|
|
100
|
+
...i,
|
|
96
101
|
// Density-bound (DENSITY-SPEC.md §2.4, WP9B1-ACCEPTANCE-WP9B2A): padding-inline is the
|
|
97
102
|
// compact/comfortable lever; min-height is floored by the fixed line-height + padding-block
|
|
98
103
|
// below and cannot shrink, so it is bound too (compact === normal, comfortable raised via an
|
|
99
104
|
// explicit minHeight above the natural content box, same mechanism `lg` already uses).
|
|
100
|
-
...n.paddingInline(
|
|
105
|
+
...n.paddingInline(Y),
|
|
101
106
|
...n.paddingBlock("0.25rem"),
|
|
102
|
-
minHeight:
|
|
103
|
-
fontSize:
|
|
104
|
-
lineHeight:
|
|
107
|
+
minHeight: D,
|
|
108
|
+
fontSize: A,
|
|
109
|
+
lineHeight: T,
|
|
105
110
|
gap: "0.5rem",
|
|
106
111
|
"& svg": { width: "1rem", height: "1rem" }
|
|
107
112
|
},
|
|
108
113
|
lg: {
|
|
114
|
+
...i,
|
|
109
115
|
...n.paddingInline("1.25rem"),
|
|
110
116
|
...n.paddingBlock("0.25rem"),
|
|
111
117
|
minHeight: "2.5rem",
|
|
112
|
-
fontSize:
|
|
113
|
-
lineHeight:
|
|
118
|
+
fontSize: O,
|
|
119
|
+
lineHeight: L,
|
|
114
120
|
gap: "0.5rem",
|
|
115
121
|
"& svg": { width: "1rem", height: "1rem" }
|
|
116
122
|
},
|
|
117
123
|
iconXs: {
|
|
124
|
+
...i,
|
|
118
125
|
width: "1.5rem",
|
|
119
126
|
height: "1.5rem",
|
|
120
127
|
"& svg": { width: "0.75rem", height: "0.75rem" }
|
|
121
128
|
},
|
|
122
129
|
iconSm: {
|
|
130
|
+
...i,
|
|
123
131
|
width: "1.75rem",
|
|
124
132
|
height: "1.75rem",
|
|
125
133
|
"& svg": { width: "0.875rem", height: "0.875rem" }
|
|
126
134
|
},
|
|
127
135
|
icon: {
|
|
136
|
+
...i,
|
|
128
137
|
// Density-bound: a fixed square, no line-height floor (unlike `base`), so compact/comfortable
|
|
129
138
|
// both move freely (DENSITY-SPEC.md §2.4).
|
|
130
|
-
width:
|
|
131
|
-
height:
|
|
139
|
+
width: h,
|
|
140
|
+
height: h,
|
|
132
141
|
"& svg": { width: "1.125rem", height: "1.125rem" }
|
|
133
142
|
},
|
|
134
143
|
iconLg: {
|
|
144
|
+
...i,
|
|
135
145
|
width: "2.5rem",
|
|
136
146
|
height: "2.5rem",
|
|
137
147
|
"& svg": { width: "1.5rem", height: "1.5rem" }
|
|
138
148
|
},
|
|
139
|
-
normal: { borderRadius:
|
|
149
|
+
normal: { borderRadius: E },
|
|
140
150
|
rounded: { borderRadius: "9999px" }
|
|
141
151
|
});
|
|
142
|
-
function
|
|
143
|
-
return
|
|
144
|
-
const
|
|
145
|
-
return
|
|
152
|
+
function S(d, a = "button") {
|
|
153
|
+
return l.Children.toArray(d).flatMap((e, t) => {
|
|
154
|
+
const s = l.isValidElement(e) && e.key !== null ? String(e.key) : String(t), o = `${a}/${s}`;
|
|
155
|
+
return l.isValidElement(e) && e.type === l.Fragment ? S(e.props.children, o) : [{ node: e, keyPath: o }];
|
|
146
156
|
});
|
|
147
157
|
}
|
|
148
|
-
function
|
|
158
|
+
function ne(d, a) {
|
|
149
159
|
const e = [];
|
|
150
160
|
let t = [];
|
|
151
|
-
const
|
|
161
|
+
const s = () => {
|
|
152
162
|
if (!t.length) return;
|
|
153
163
|
t.every(
|
|
154
164
|
({ node: r }) => typeof r == "string" && r.trim() === ""
|
|
155
165
|
) ? e.push(...t.map(({ node: r }) => r)) : e.push(
|
|
156
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ f(
|
|
157
167
|
"span",
|
|
158
168
|
{
|
|
159
169
|
"data-slot": "button-label",
|
|
160
|
-
className:
|
|
170
|
+
className: a,
|
|
161
171
|
children: t.map(({ node: r }) => r)
|
|
162
172
|
},
|
|
163
173
|
`button-label:${t[0].keyPath}`
|
|
164
174
|
)
|
|
165
175
|
), t = [];
|
|
166
176
|
};
|
|
167
|
-
for (const o of
|
|
177
|
+
for (const o of S(d)) {
|
|
168
178
|
if (typeof o.node == "string" || typeof o.node == "number") {
|
|
169
179
|
t.push(o);
|
|
170
180
|
continue;
|
|
171
181
|
}
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
s(), e.push(
|
|
183
|
+
l.isValidElement(o.node) ? l.cloneElement(o.node, { key: o.keyPath }) : o.node
|
|
174
184
|
);
|
|
175
185
|
}
|
|
176
|
-
return
|
|
186
|
+
return s(), e;
|
|
177
187
|
}
|
|
178
|
-
const
|
|
188
|
+
const me = l.forwardRef(
|
|
179
189
|
function({
|
|
180
|
-
variant:
|
|
190
|
+
variant: a = "primary",
|
|
181
191
|
size: e = "base",
|
|
182
192
|
shape: t = "rounded",
|
|
183
|
-
destructive:
|
|
193
|
+
destructive: s = !1,
|
|
184
194
|
className: o,
|
|
185
195
|
asChild: r = !1,
|
|
186
|
-
children:
|
|
187
|
-
...
|
|
188
|
-
},
|
|
189
|
-
const
|
|
196
|
+
children: m,
|
|
197
|
+
...y
|
|
198
|
+
}, k) {
|
|
199
|
+
const c = re(), v = s && a !== "ghost" ? `${a}Destructive` : a, C = {
|
|
190
200
|
xs: "xs",
|
|
191
201
|
sm: "sm",
|
|
192
202
|
base: "base",
|
|
@@ -195,27 +205,27 @@ const ce = a.forwardRef(
|
|
|
195
205
|
"icon-sm": "iconSm",
|
|
196
206
|
icon: "icon",
|
|
197
207
|
"icon-lg": "iconLg"
|
|
198
|
-
}[e],
|
|
199
|
-
return /* @__PURE__ */
|
|
200
|
-
|
|
208
|
+
}[e], x = r ? oe : te, w = r ? m : ne(m, c.label);
|
|
209
|
+
return /* @__PURE__ */ f(
|
|
210
|
+
x,
|
|
201
211
|
{
|
|
202
|
-
ref:
|
|
212
|
+
ref: k,
|
|
203
213
|
"data-slot": "button",
|
|
204
|
-
[
|
|
205
|
-
className:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
214
|
+
[H]: "button",
|
|
215
|
+
className: B(
|
|
216
|
+
c.root,
|
|
217
|
+
c[v],
|
|
218
|
+
c[C],
|
|
219
|
+
c[t],
|
|
210
220
|
o
|
|
211
221
|
),
|
|
212
|
-
...
|
|
213
|
-
children:
|
|
222
|
+
...y,
|
|
223
|
+
children: w
|
|
214
224
|
}
|
|
215
225
|
);
|
|
216
226
|
}
|
|
217
227
|
);
|
|
218
228
|
export {
|
|
219
|
-
|
|
229
|
+
me as Button
|
|
220
230
|
};
|
|
221
231
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { capTrim } from \"../../styles/text-box\"\nimport * as tokens from \"../../tokens\"\nimport { Slot } from \"@radix-ui/react-slot\"\n\n/**\n * Base UI's type declarations resolve `react` from the hoisted root's `@types/react` (v19), while\n * this package pins `@types/react` 18 in its own node_modules. Re-typing the primitive onto OUR\n * `React` keeps the button's pass-through props and ref on one React type for this package.\n */\n/**\n * A native `<button>`, no primitive.\n *\n * v1's only Radix use here is `Slot`, purely to implement `asChild`, and this does the same. Base\n * UI's button primitive supplied nothing v1 had: it added a dependency, and with it the\n * `@types/react` 19 requirement, for a plain element.\n */\nconst ButtonBase = \"button\" as const\n\nconst useStyles = makeZenithStyles({\n root: {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontWeight: tokens.fontWeightSemibold,\n whiteSpace: \"nowrap\",\n transitionProperty: \"all\",\n cursor: \"pointer\",\n flexShrink: 0,\n // Disabled keeps pointer events so a Tooltip can still explain why, but shows none of the\n // hover or press feedback (every variant guards those with `:not(:disabled)`) and no pointer.\n \":disabled\": { opacity: 0.5, cursor: \"not-allowed\" },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.focusRing,\n },\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \"& svg\": {\n flexShrink: 0,\n pointerEvents: \"none\",\n color: \"currentColor\",\n },\n },\n label: capTrim,\n primary: {\n backgroundColor: tokens.accentSolid,\n color: tokens.accentContrast,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSolidHover },\n \":active:not(:disabled)\": { backgroundColor: tokens.accentSolidHover },\n },\n secondary: {\n backgroundColor: tokens.accentSoft,\n color: tokens.accentOnSoft,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoftHover },\n },\n tertiary: {\n backgroundColor: \"transparent\",\n color: tokens.accentA11,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoft },\n },\n ghost: {\n backgroundColor: \"transparent\",\n color: tokens.grayA12,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoft },\n },\n primaryDestructive: {\n backgroundColor: tokens.errorSolid,\n color: tokens.errorContrast,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSolidHover },\n \":active:not(:disabled)\": { backgroundColor: tokens.errorSolidHover },\n },\n secondaryDestructive: {\n backgroundColor: tokens.errorSoft,\n color: tokens.errorOnSoft,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSoftHover },\n },\n tertiaryDestructive: {\n backgroundColor: \"transparent\",\n color: tokens.errorA11,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSoft },\n },\n xs: {\n ...shorthands.paddingInline(\"0.5rem\"),\n ...shorthands.paddingBlock(\"0.25rem\"),\n // Cap trimming removes the line-height's leading from direct text. Keep the established\n // 24px control geometry explicitly instead of relying on that incidental text height.\n minHeight: \"1.5rem\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n gap: \"4px\",\n \"& svg\": { width: \"0.75rem\", height: \"0.75rem\" },\n },\n sm: {\n ...shorthands.paddingInline(tokens.spacingElement3),\n ...shorthands.paddingBlock(\"0.25rem\"),\n // As above, the fixed 28px size is part of Button's contract, independent of its label box.\n minHeight: \"1.75rem\",\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n gap: \"0.375rem\",\n \"& svg\": { width: \"0.875rem\", height: \"0.875rem\" },\n },\n base: {\n // Density-bound (DENSITY-SPEC.md §2.4, WP9B1-ACCEPTANCE-WP9B2A): padding-inline is the\n // compact/comfortable lever; min-height is floored by the fixed line-height + padding-block\n // below and cannot shrink, so it is bound too (compact === normal, comfortable raised via an\n // explicit minHeight above the natural content box, same mechanism `lg` already uses).\n ...shorthands.paddingInline(tokens.buttonBasePaddingInline),\n ...shorthands.paddingBlock(\"0.25rem\"),\n minHeight: tokens.buttonBaseMinHeight,\n fontSize: tokens.textBase,\n lineHeight: tokens.leadingBase,\n gap: \"0.5rem\",\n \"& svg\": { width: \"1rem\", height: \"1rem\" },\n },\n lg: {\n ...shorthands.paddingInline(\"1.25rem\"),\n ...shorthands.paddingBlock(\"0.25rem\"),\n minHeight: \"2.5rem\",\n fontSize: tokens.textLg,\n lineHeight: tokens.leadingLg,\n gap: \"0.5rem\",\n \"& svg\": { width: \"1rem\", height: \"1rem\" },\n },\n iconXs: {\n width: \"1.5rem\",\n height: \"1.5rem\",\n \"& svg\": { width: \"0.75rem\", height: \"0.75rem\" },\n },\n iconSm: {\n width: \"1.75rem\",\n height: \"1.75rem\",\n \"& svg\": { width: \"0.875rem\", height: \"0.875rem\" },\n },\n icon: {\n // Density-bound: a fixed square, no line-height floor (unlike `base`), so compact/comfortable\n // both move freely (DENSITY-SPEC.md §2.4).\n width: tokens.buttonIconSize,\n height: tokens.buttonIconSize,\n \"& svg\": { width: \"1.125rem\", height: \"1.125rem\" },\n },\n iconLg: {\n width: \"2.5rem\",\n height: \"2.5rem\",\n \"& svg\": { width: \"1.5rem\", height: \"1.5rem\" },\n },\n normal: { borderRadius: tokens.radiusLg },\n rounded: { borderRadius: \"9999px\" },\n})\n\ntype FlatButtonChild = {\n node: React.ReactNode\n keyPath: string\n}\n\n/**\n * Fragments do not create boxes, so flatten them to the same leaf order the flex container sees.\n * React.Children.toArray handles nested arrays and gives keyed elements a stable local key; the\n * parent fragment path keeps equal keys from separate fragment scopes distinct.\n */\nfunction flattenButtonChildren(\n children: React.ReactNode,\n parentPath = \"button\"\n): FlatButtonChild[] {\n return React.Children.toArray(children).flatMap((node, index) => {\n const localKey =\n React.isValidElement(node) && node.key !== null\n ? String(node.key)\n : String(index)\n const keyPath = `${parentPath}/${localKey}`\n\n if (\n React.isValidElement<{ children?: React.ReactNode }>(node) &&\n node.type === React.Fragment\n ) {\n return flattenButtonChildren(node.props.children, keyPath)\n }\n\n return [{ node, keyPath }]\n })\n}\n\n/**\n * A flex container's direct text becomes an anonymous flex item, which `text-box` cannot select.\n * Recreate exactly those contiguous text runs as real label boxes. Consumer elements stay direct\n * children and whitespace-only runs stay raw, preserving today's element order and flex gaps.\n */\nfunction wrapButtonTextRuns(\n children: React.ReactNode,\n labelClassName: string\n): React.ReactNode[] {\n const output: React.ReactNode[] = []\n let textRun: FlatButtonChild[] = []\n\n const flushTextRun = () => {\n if (!textRun.length) return\n\n const whitespaceOnly = textRun.every(\n ({ node }) => typeof node === \"string\" && node.trim() === \"\"\n )\n if (whitespaceOnly) {\n output.push(...textRun.map(({ node }) => node))\n } else {\n output.push(\n <span\n key={`button-label:${textRun[0].keyPath}`}\n data-slot=\"button-label\"\n className={labelClassName}\n >\n {textRun.map(({ node }) => node)}\n </span>\n )\n }\n textRun = []\n }\n\n for (const child of flattenButtonChildren(children)) {\n if (typeof child.node === \"string\" || typeof child.node === \"number\") {\n textRun.push(child)\n continue\n }\n\n flushTextRun()\n output.push(\n React.isValidElement(child.node)\n ? React.cloneElement(child.node, { key: child.keyPath })\n : child.node\n )\n }\n flushTextRun()\n\n return output\n}\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"tertiary\" | \"ghost\"\nexport type ButtonSize =\n \"xs\" | \"sm\" | \"base\" | \"lg\" | \"icon-xs\" | \"icon-sm\" | \"icon\" | \"icon-lg\"\nexport type ButtonShape = \"normal\" | \"rounded\"\n\nexport type ButtonProps = Omit<\n React.ComponentProps<\"button\">,\n \"variant\" | \"size\" | \"shape\" | \"destructive\" | \"className\" | \"render\"\n> & {\n variant?: ButtonVariant\n size?: ButtonSize\n shape?: ButtonShape\n destructive?: boolean\n className?: string\n /**\n * Render the child element instead of a `button`, keeping Button's styling and slot markers.\n * v1 supports this and consumers rely on it to wrap links; it was dropped here while the package\n * was briefly on Base UI, and restored once it moved back to Radix.\n */\n asChild?: boolean\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n variant = \"primary\",\n size = \"base\",\n shape = \"rounded\",\n destructive = false,\n className,\n asChild = false,\n children,\n ...props\n },\n ref\n ) {\n const styles = useStyles()\n const variantSlot:\n | ButtonVariant\n | \"primaryDestructive\"\n | \"secondaryDestructive\"\n | \"tertiaryDestructive\" =\n destructive && variant !== \"ghost\"\n ? (`${variant}Destructive` as\n | \"primaryDestructive\"\n | \"secondaryDestructive\"\n | \"tertiaryDestructive\")\n : variant\n const sizeSlot:\n \"xs\" | \"sm\" | \"base\" | \"lg\" | \"iconXs\" | \"iconSm\" | \"icon\" | \"iconLg\" = (\n {\n xs: \"xs\",\n sm: \"sm\",\n base: \"base\",\n lg: \"lg\",\n \"icon-xs\": \"iconXs\",\n \"icon-sm\": \"iconSm\",\n icon: \"icon\",\n \"icon-lg\": \"iconLg\",\n } as const\n )[size]\n\n const Root = asChild ? Slot : ButtonBase\n const content = asChild\n ? children\n : wrapButtonTextRuns(children, styles.label)\n\n return (\n <Root\n ref={ref}\n data-slot=\"button\"\n {...{ [SLOT_ATTR]: \"button\" }}\n className={mergeClasses(\n styles.root,\n styles[variantSlot],\n styles[sizeSlot],\n styles[shape],\n className\n )}\n {...props}\n >\n {content}\n </Root>\n )\n }\n)\n"],"names":["ButtonBase","useStyles","makeZenithStyles","tokens.fontWeightSemibold","tokens.focusRing","capTrim","tokens.accentSolid","tokens.accentContrast","tokens.accentSolidHover","tokens.accentSoft","tokens.accentOnSoft","tokens.accentSoftHover","tokens.accentA11","tokens.grayA12","tokens.errorSolid","tokens.errorContrast","tokens.errorSolidHover","tokens.errorSoft","tokens.errorOnSoft","tokens.errorSoftHover","tokens.errorA11","shorthands","tokens.textXs","tokens.leadingXs","tokens.spacingElement3","tokens.textSm","tokens.leadingSm","tokens.buttonBasePaddingInline","tokens.buttonBaseMinHeight","tokens.textBase","tokens.leadingBase","tokens.textLg","tokens.leadingLg","tokens.buttonIconSize","tokens.radiusLg","flattenButtonChildren","children","parentPath","React","node","index","localKey","keyPath","wrapButtonTextRuns","labelClassName","output","textRun","flushTextRun","jsx","child","Button","variant","size","shape","destructive","className","asChild","props","ref","styles","variantSlot","sizeSlot","Root","Slot","content","SLOT_ATTR","mergeClasses"],"mappings":";;;;;;;AAsBA,MAAMA,KAAa,UAEbC,KAAYC,EAAiB;AAAA,EACjC,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,YAAYC;AAAAA,IACZ,YAAY;AAAA,IACZ,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,YAA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D,EAAOE,CAAQ;AAAA,UACfF,EAAON,CAAK;AAAA,UACZE;AAAA,QAAA;AAAA,QAED,GAAGE;AAAA,QAEH,UAAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport { capTrim } from \"../../styles/text-box\"\nimport * as tokens from \"../../tokens\"\nimport { Slot } from \"@radix-ui/react-slot\"\n\n/**\n * Base UI's type declarations resolve `react` from the hoisted root's `@types/react` (v19), while\n * this package pins `@types/react` 18 in its own node_modules. Re-typing the primitive onto OUR\n * `React` keeps the button's pass-through props and ref on one React type for this package.\n */\n/**\n * A native `<button>`, no primitive.\n *\n * v1's only Radix use here is `Slot`, purely to implement `asChild`, and this does the same. Base\n * UI's button primitive supplied nothing v1 had: it added a dependency, and with it the\n * `@types/react` 19 requirement, for a plain element.\n */\nconst ButtonBase = \"button\" as const\n\nconst useStyles = makeZenithStyles({\n root: {\n ...nativeControl,\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontWeight: tokens.fontWeightSemibold,\n whiteSpace: \"nowrap\",\n transitionProperty: \"all\",\n cursor: \"pointer\",\n flexShrink: 0,\n // Disabled keeps pointer events so a Tooltip can still explain why, but shows none of the\n // hover or press feedback (every variant guards those with `:not(:disabled)`) and no pointer.\n \":disabled\": { opacity: 0.5, cursor: \"not-allowed\" },\n \":focus-visible\": {\n outlineWidth: \"2px\",\n outlineStyle: \"solid\",\n outlineOffset: \"2px\",\n outlineColor: tokens.focusRing,\n },\n \"@media (prefers-reduced-motion: reduce)\": {\n transitionDuration: \"0.01ms\",\n },\n \"& svg\": {\n flexShrink: 0,\n pointerEvents: \"none\",\n color: \"currentColor\",\n },\n },\n label: capTrim,\n primary: {\n backgroundColor: tokens.accentSolid,\n color: tokens.accentContrast,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSolidHover },\n \":active:not(:disabled)\": { backgroundColor: tokens.accentSolidHover },\n },\n secondary: {\n backgroundColor: tokens.accentSoft,\n color: tokens.accentOnSoft,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoftHover },\n },\n tertiary: {\n backgroundColor: \"transparent\",\n color: tokens.accentA11,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoft },\n },\n ghost: {\n backgroundColor: \"transparent\",\n color: tokens.grayA12,\n \":hover:not(:disabled)\": { backgroundColor: tokens.accentSoft },\n },\n primaryDestructive: {\n backgroundColor: tokens.errorSolid,\n color: tokens.errorContrast,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSolidHover },\n \":active:not(:disabled)\": { backgroundColor: tokens.errorSolidHover },\n },\n secondaryDestructive: {\n backgroundColor: tokens.errorSoft,\n color: tokens.errorOnSoft,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSoftHover },\n },\n tertiaryDestructive: {\n backgroundColor: \"transparent\",\n color: tokens.errorA11,\n \":hover:not(:disabled)\": { backgroundColor: tokens.errorSoft },\n },\n xs: {\n ...boxModel,\n ...shorthands.paddingInline(\"0.5rem\"),\n ...shorthands.paddingBlock(\"0.25rem\"),\n // Cap trimming removes the line-height's leading from direct text. Keep the established\n // 24px control geometry explicitly instead of relying on that incidental text height.\n minHeight: \"1.5rem\",\n fontSize: tokens.textXs,\n lineHeight: tokens.leadingXs,\n gap: \"4px\",\n \"& svg\": { width: \"0.75rem\", height: \"0.75rem\" },\n },\n sm: {\n ...boxModel,\n ...shorthands.paddingInline(tokens.spacingElement3),\n ...shorthands.paddingBlock(\"0.25rem\"),\n // As above, the fixed 28px size is part of Button's contract, independent of its label box.\n minHeight: \"1.75rem\",\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n gap: \"0.375rem\",\n \"& svg\": { width: \"0.875rem\", height: \"0.875rem\" },\n },\n base: {\n ...boxModel,\n // Density-bound (DENSITY-SPEC.md §2.4, WP9B1-ACCEPTANCE-WP9B2A): padding-inline is the\n // compact/comfortable lever; min-height is floored by the fixed line-height + padding-block\n // below and cannot shrink, so it is bound too (compact === normal, comfortable raised via an\n // explicit minHeight above the natural content box, same mechanism `lg` already uses).\n ...shorthands.paddingInline(tokens.buttonBasePaddingInline),\n ...shorthands.paddingBlock(\"0.25rem\"),\n minHeight: tokens.buttonBaseMinHeight,\n fontSize: tokens.textBase,\n lineHeight: tokens.leadingBase,\n gap: \"0.5rem\",\n \"& svg\": { width: \"1rem\", height: \"1rem\" },\n },\n lg: {\n ...boxModel,\n ...shorthands.paddingInline(\"1.25rem\"),\n ...shorthands.paddingBlock(\"0.25rem\"),\n minHeight: \"2.5rem\",\n fontSize: tokens.textLg,\n lineHeight: tokens.leadingLg,\n gap: \"0.5rem\",\n \"& svg\": { width: \"1rem\", height: \"1rem\" },\n },\n iconXs: {\n ...boxModel,\n width: \"1.5rem\",\n height: \"1.5rem\",\n \"& svg\": { width: \"0.75rem\", height: \"0.75rem\" },\n },\n iconSm: {\n ...boxModel,\n width: \"1.75rem\",\n height: \"1.75rem\",\n \"& svg\": { width: \"0.875rem\", height: \"0.875rem\" },\n },\n icon: {\n ...boxModel,\n // Density-bound: a fixed square, no line-height floor (unlike `base`), so compact/comfortable\n // both move freely (DENSITY-SPEC.md §2.4).\n width: tokens.buttonIconSize,\n height: tokens.buttonIconSize,\n \"& svg\": { width: \"1.125rem\", height: \"1.125rem\" },\n },\n iconLg: {\n ...boxModel,\n width: \"2.5rem\",\n height: \"2.5rem\",\n \"& svg\": { width: \"1.5rem\", height: \"1.5rem\" },\n },\n normal: { borderRadius: tokens.radiusLg },\n rounded: { borderRadius: \"9999px\" },\n})\n\ntype FlatButtonChild = {\n node: React.ReactNode\n keyPath: string\n}\n\n/**\n * Fragments do not create boxes, so flatten them to the same leaf order the flex container sees.\n * React.Children.toArray handles nested arrays and gives keyed elements a stable local key; the\n * parent fragment path keeps equal keys from separate fragment scopes distinct.\n */\nfunction flattenButtonChildren(\n children: React.ReactNode,\n parentPath = \"button\"\n): FlatButtonChild[] {\n return React.Children.toArray(children).flatMap((node, index) => {\n const localKey =\n React.isValidElement(node) && node.key !== null\n ? String(node.key)\n : String(index)\n const keyPath = `${parentPath}/${localKey}`\n\n if (\n React.isValidElement<{ children?: React.ReactNode }>(node) &&\n node.type === React.Fragment\n ) {\n return flattenButtonChildren(node.props.children, keyPath)\n }\n\n return [{ node, keyPath }]\n })\n}\n\n/**\n * A flex container's direct text becomes an anonymous flex item, which `text-box` cannot select.\n * Recreate exactly those contiguous text runs as real label boxes. Consumer elements stay direct\n * children and whitespace-only runs stay raw, preserving today's element order and flex gaps.\n */\nfunction wrapButtonTextRuns(\n children: React.ReactNode,\n labelClassName: string\n): React.ReactNode[] {\n const output: React.ReactNode[] = []\n let textRun: FlatButtonChild[] = []\n\n const flushTextRun = () => {\n if (!textRun.length) return\n\n const whitespaceOnly = textRun.every(\n ({ node }) => typeof node === \"string\" && node.trim() === \"\"\n )\n if (whitespaceOnly) {\n output.push(...textRun.map(({ node }) => node))\n } else {\n output.push(\n <span\n key={`button-label:${textRun[0].keyPath}`}\n data-slot=\"button-label\"\n className={labelClassName}\n >\n {textRun.map(({ node }) => node)}\n </span>\n )\n }\n textRun = []\n }\n\n for (const child of flattenButtonChildren(children)) {\n if (typeof child.node === \"string\" || typeof child.node === \"number\") {\n textRun.push(child)\n continue\n }\n\n flushTextRun()\n output.push(\n React.isValidElement(child.node)\n ? React.cloneElement(child.node, { key: child.keyPath })\n : child.node\n )\n }\n flushTextRun()\n\n return output\n}\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"tertiary\" | \"ghost\"\nexport type ButtonSize =\n \"xs\" | \"sm\" | \"base\" | \"lg\" | \"icon-xs\" | \"icon-sm\" | \"icon\" | \"icon-lg\"\nexport type ButtonShape = \"normal\" | \"rounded\"\n\nexport type ButtonProps = Omit<\n React.ComponentProps<\"button\">,\n \"variant\" | \"size\" | \"shape\" | \"destructive\" | \"className\" | \"render\"\n> & {\n variant?: ButtonVariant\n size?: ButtonSize\n shape?: ButtonShape\n destructive?: boolean\n className?: string\n /**\n * Render the child element instead of a `button`, keeping Button's styling and slot markers.\n * v1 supports this and consumers rely on it to wrap links; it was dropped here while the package\n * was briefly on Base UI, and restored once it moved back to Radix.\n */\n asChild?: boolean\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(\n {\n variant = \"primary\",\n size = \"base\",\n shape = \"rounded\",\n destructive = false,\n className,\n asChild = false,\n children,\n ...props\n },\n ref\n ) {\n const styles = useStyles()\n const variantSlot:\n | ButtonVariant\n | \"primaryDestructive\"\n | \"secondaryDestructive\"\n | \"tertiaryDestructive\" =\n destructive && variant !== \"ghost\"\n ? (`${variant}Destructive` as\n | \"primaryDestructive\"\n | \"secondaryDestructive\"\n | \"tertiaryDestructive\")\n : variant\n const sizeSlot:\n \"xs\" | \"sm\" | \"base\" | \"lg\" | \"iconXs\" | \"iconSm\" | \"icon\" | \"iconLg\" = (\n {\n xs: \"xs\",\n sm: \"sm\",\n base: \"base\",\n lg: \"lg\",\n \"icon-xs\": \"iconXs\",\n \"icon-sm\": \"iconSm\",\n icon: \"icon\",\n \"icon-lg\": \"iconLg\",\n } as const\n )[size]\n\n const Root = asChild ? Slot : ButtonBase\n const content = asChild\n ? children\n : wrapButtonTextRuns(children, styles.label)\n\n return (\n <Root\n ref={ref}\n data-slot=\"button\"\n {...{ [SLOT_ATTR]: \"button\" }}\n className={mergeClasses(\n styles.root,\n styles[variantSlot],\n styles[sizeSlot],\n styles[shape],\n className\n )}\n {...props}\n >\n {content}\n </Root>\n )\n }\n)\n"],"names":["ButtonBase","useStyles","makeZenithStyles","nativeControl","tokens.fontWeightSemibold","tokens.focusRing","capTrim","tokens.accentSolid","tokens.accentContrast","tokens.accentSolidHover","tokens.accentSoft","tokens.accentOnSoft","tokens.accentSoftHover","tokens.accentA11","tokens.grayA12","tokens.errorSolid","tokens.errorContrast","tokens.errorSolidHover","tokens.errorSoft","tokens.errorOnSoft","tokens.errorSoftHover","tokens.errorA11","boxModel","shorthands","tokens.textXs","tokens.leadingXs","tokens.spacingElement3","tokens.textSm","tokens.leadingSm","tokens.buttonBasePaddingInline","tokens.buttonBaseMinHeight","tokens.textBase","tokens.leadingBase","tokens.textLg","tokens.leadingLg","tokens.buttonIconSize","tokens.radiusLg","flattenButtonChildren","children","parentPath","React","node","index","localKey","keyPath","wrapButtonTextRuns","labelClassName","output","textRun","flushTextRun","jsx","child","Button","variant","size","shape","destructive","className","asChild","props","ref","styles","variantSlot","sizeSlot","Root","Slot","content","SLOT_ATTR","mergeClasses"],"mappings":";;;;;;;;AAuBA,MAAMA,KAAa,UAEbC,KAAYC,EAAiB;AAAA,EACjC,MAAM;AAAA,IACJ,GAAGC;AAAA,IACH,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,YAAYC;AAAAA,IACZ,YAAY;AAAA,IACZ,oBAAoB;AAAA,IACpB,QAAQ;AAAA,IACR,YAAY;AAAA;AAAA;AAAA,IAGZ,aAAa,EAAE,SAAS,KAAK,QAAQ,cAAA;AAAA,IACrC,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,eAAe;AAAA,MACf,cAAcC;AAAAA,IAAO;AAAA,IAEvB,2CAA2C;AAAA,MACzC,oBAAoB;AAAA,IAAA;AAAA,IAEtB,SAAS;AAAA,MACP,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,OAAO;AAAA,IAAA;AAAA,EACT;AAAA,EAEF,OAAOC;AAAA,EACP,SAAS;AAAA,IACP,iBAAiBC;AAAAA,IACjB,OAAOC;AAAAA,IACP,yBAAyB,EAAE,iBAAiBC,EAAO;AAAA,IACnD,0BAA0B,EAAE,iBAAiBA,EAAO;AAAA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M,aAAaW,EAAM,MAAM,EAAE,KAAKA,EAAM,QAAA,CAAS,IACrDA,EAAM;AAAA,IAAA;AAAA,EAEd;AACA,SAAAF,EAAA,GAEOF;AACT;AAwBO,MAAMK,KAASZ,EAAM;AAAA,EAC1B,SACE;AAAA,IACE,SAAAa,IAAU;AAAA,IACV,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,aAAAC,IAAc;AAAA,IACd,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAApB;AAAA,IACA,GAAGqB;AAAA,EAAA,GAELC,GACA;AACA,UAAMC,IAAS5D,GAAA,GACT6D,IAKJN,KAAeH,MAAY,UACtB,GAAGA,CAAO,gBAIXA,GACAU,IAEJ;AAAA,MACE,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,WAAW;AAAA,MACX,WAAW;AAAA,MACX,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,EAEbT,CAAI,GAEAU,IAAON,IAAUO,KAAOjE,IACxBkE,IAAUR,IACZpB,IACAO,GAAmBP,GAAUuB,EAAO,KAAK;AAE7C,WACE,gBAAAX;AAAA,MAACc;AAAA,MAAA;AAAA,QACC,KAAAJ;AAAA,QACA,aAAU;AAAA,QACJ,CAACO,CAAS,GAAG;AAAA,QACnB,WAAWC;AAAA,UACTP,EAAO;AAAA,UACPA,EAAOC,CAAW;AAAA,UAClBD,EAAOE,CAAQ;AAAA,UACfF,EAAON,CAAK;AAAA,UACZE;AAAA,QAAA;AAAA,QAED,GAAGE;AAAA,QAEH,UAAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { mergeClasses as
|
|
4
|
-
import { makeZenithStyles as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import * as p from "react";
|
|
3
|
+
import { mergeClasses as u, SLOT_ATTR as s, shorthands as o } from "@epilot/zenith-runtime/v1";
|
|
4
|
+
import { makeZenithStyles as m } from "../../styles/make-styles.js";
|
|
5
|
+
import { boxModel as n } from "../../styles/host-reset.js";
|
|
6
|
+
import { fontWeightMedium as f, leadingSm as h, textSm as b, grayA4 as x, spacingElement3 as R, spacingGroup2 as S, grayA5 as v, radiusMd as B, spacingElement2 as g } from "../../tokens/index.js";
|
|
7
|
+
import { Separator as T } from "../separator/separator.js";
|
|
8
|
+
const l = m({
|
|
8
9
|
root: {
|
|
10
|
+
...n,
|
|
9
11
|
display: "flex",
|
|
10
12
|
width: "fit-content",
|
|
11
13
|
alignItems: "stretch",
|
|
@@ -14,7 +16,7 @@ const u = g({
|
|
|
14
16
|
position: "relative"
|
|
15
17
|
},
|
|
16
18
|
[`&:has(> [${s}="button-group"])`]: {
|
|
17
|
-
...o.gap(
|
|
19
|
+
...o.gap(g)
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
horizontal: {
|
|
@@ -41,16 +43,17 @@ const u = g({
|
|
|
41
43
|
}
|
|
42
44
|
},
|
|
43
45
|
text: {
|
|
44
|
-
|
|
46
|
+
...n,
|
|
47
|
+
backgroundColor: x,
|
|
45
48
|
display: "flex",
|
|
46
49
|
alignItems: "center",
|
|
47
|
-
...o.gap(
|
|
48
|
-
...o.borderRadius(
|
|
49
|
-
...o.border("1px", "solid",
|
|
50
|
-
...o.padding(
|
|
51
|
-
fontSize:
|
|
52
|
-
lineHeight:
|
|
53
|
-
fontWeight:
|
|
50
|
+
...o.gap(g),
|
|
51
|
+
...o.borderRadius(B),
|
|
52
|
+
...o.border("1px", "solid", v),
|
|
53
|
+
...o.padding(R, S),
|
|
54
|
+
fontSize: b,
|
|
55
|
+
lineHeight: h,
|
|
56
|
+
fontWeight: f,
|
|
54
57
|
// Tailwind `shadow-xs` — literal per CONVENTIONS B7
|
|
55
58
|
boxShadow: "0 1px 2px 0 #0000000d",
|
|
56
59
|
"& svg": {
|
|
@@ -66,12 +69,13 @@ const u = g({
|
|
|
66
69
|
backgroundColor: "transparent"
|
|
67
70
|
},
|
|
68
71
|
separatorVertical: {
|
|
72
|
+
...n,
|
|
69
73
|
height: "1px"
|
|
70
74
|
}
|
|
71
|
-
}),
|
|
75
|
+
}), k = p.forwardRef(
|
|
72
76
|
function({ className: r, orientation: t = "horizontal", ...e }, a) {
|
|
73
|
-
const i =
|
|
74
|
-
return /* @__PURE__ */
|
|
77
|
+
const i = l();
|
|
78
|
+
return /* @__PURE__ */ d(
|
|
75
79
|
"div",
|
|
76
80
|
{
|
|
77
81
|
ref: a,
|
|
@@ -79,33 +83,33 @@ const u = g({
|
|
|
79
83
|
"data-slot": "button-group",
|
|
80
84
|
[s]: "button-group",
|
|
81
85
|
"data-orientation": t,
|
|
82
|
-
className:
|
|
86
|
+
className: u(i.root, i[t], r),
|
|
83
87
|
...e
|
|
84
88
|
}
|
|
85
89
|
);
|
|
86
90
|
}
|
|
87
|
-
),
|
|
88
|
-
const a =
|
|
89
|
-
return /* @__PURE__ */
|
|
91
|
+
), A = p.forwardRef(function({ className: r, ...t }, e) {
|
|
92
|
+
const a = l();
|
|
93
|
+
return /* @__PURE__ */ d(
|
|
90
94
|
"div",
|
|
91
95
|
{
|
|
92
96
|
ref: e,
|
|
93
97
|
"data-slot": "button-group-text",
|
|
94
98
|
[s]: "button-group-text",
|
|
95
|
-
className:
|
|
99
|
+
className: u(a.text, r),
|
|
96
100
|
...t
|
|
97
101
|
}
|
|
98
102
|
);
|
|
99
|
-
}),
|
|
100
|
-
const i =
|
|
101
|
-
return /* @__PURE__ */
|
|
102
|
-
|
|
103
|
+
}), C = p.forwardRef(function({ className: r, orientation: t = "vertical", ...e }, a) {
|
|
104
|
+
const i = l();
|
|
105
|
+
return /* @__PURE__ */ d(
|
|
106
|
+
T,
|
|
103
107
|
{
|
|
104
108
|
ref: a,
|
|
105
109
|
"data-slot": "button-group-separator",
|
|
106
110
|
[s]: "button-group-separator",
|
|
107
111
|
orientation: t,
|
|
108
|
-
className:
|
|
112
|
+
className: u(
|
|
109
113
|
i.separator,
|
|
110
114
|
t === "vertical" && i.separatorVertical,
|
|
111
115
|
r
|
|
@@ -115,8 +119,8 @@ const u = g({
|
|
|
115
119
|
);
|
|
116
120
|
});
|
|
117
121
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
k as ButtonGroup,
|
|
123
|
+
C as ButtonGroupSeparator,
|
|
124
|
+
A as ButtonGroupText
|
|
121
125
|
};
|
|
122
126
|
//# sourceMappingURL=button-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-group.js","sources":["../../../src/components/button-group/button-group.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport * as tokens from \"../../tokens\"\nimport { Separator, type SeparatorProps } from \"../separator/separator\"\n\n/**\n * ButtonGroup — compound component family for grouping buttons, text, and separators. One\n * `makeZenithStyles` call for the whole family, one slot per sub-component (following `card.tsx`).\n */\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nconst useStyles = makeZenithStyles({\n root: {\n display: \"flex\",\n width: \"fit-content\",\n alignItems: \"stretch\",\n \"& > *:focus-visible\": {\n zIndex: 10,\n position: \"relative\",\n },\n [`&:has(> [${SLOT_ATTR}=\"button-group\"])`]: {\n ...shorthands.gap(tokens.spacingElement2),\n },\n },\n horizontal: {\n \"& > *:not(:first-child)\": {\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n borderLeftWidth: 0,\n },\n \"& > *:not(:last-child)\": {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n },\n },\n vertical: {\n flexDirection: \"column\",\n \"& > *:not(:first-child)\": {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderTopWidth: 0,\n },\n \"& > *:not(:last-child)\": {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n },\n },\n text: {\n backgroundColor: tokens.grayA4,\n display: \"flex\",\n alignItems: \"center\",\n ...shorthands.gap(tokens.spacingElement2),\n ...shorthands.borderRadius(tokens.radiusMd),\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA5),\n ...shorthands.padding(tokens.spacingElement3, tokens.spacingGroup2),\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n fontWeight: tokens.fontWeightMedium,\n // Tailwind `shadow-xs` — literal per CONVENTIONS B7\n boxShadow: \"0 1px 2px 0 #0000000d\",\n \"& svg\": {\n pointerEvents: \"none\",\n width: \"1rem\",\n height: \"1rem\",\n },\n },\n separator: {\n ...shorthands.margin(0),\n position: \"relative\",\n alignSelf: \"stretch\",\n backgroundColor: \"transparent\",\n },\n separatorVertical: {\n height: \"1px\",\n },\n})\n\nexport type ButtonGroupProps = React.ComponentProps<\"div\"> & {\n orientation?: ButtonGroupOrientation\n}\n\nexport const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(\n function ButtonGroup(\n { className, orientation = \"horizontal\", ...props },\n ref\n ) {\n const styles = useStyles()\n\n return (\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"button-group\"\n {...{ [SLOT_ATTR]: \"button-group\" }}\n data-orientation={orientation}\n className={mergeClasses(styles.root, styles[orientation], className)}\n {...props}\n />\n )\n }\n)\n\nexport type ButtonGroupTextProps = React.ComponentProps<\"div\">\n\nexport const ButtonGroupText = React.forwardRef<\n HTMLDivElement,\n ButtonGroupTextProps\n>(function ButtonGroupText({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <div\n ref={ref}\n data-slot=\"button-group-text\"\n {...{ [SLOT_ATTR]: \"button-group-text\" }}\n className={mergeClasses(styles.text, className)}\n {...props}\n />\n )\n})\n\nexport type ButtonGroupSeparatorProps = SeparatorProps\n\nexport const ButtonGroupSeparator = React.forwardRef<\n HTMLDivElement,\n ButtonGroupSeparatorProps\n>(function ButtonGroupSeparator(\n { className, orientation = \"vertical\", ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <Separator\n ref={ref}\n data-slot=\"button-group-separator\"\n {...{ [SLOT_ATTR]: \"button-group-separator\" }}\n orientation={orientation}\n className={mergeClasses(\n styles.separator,\n orientation === \"vertical\" && styles.separatorVertical,\n className\n )}\n {...props}\n />\n )\n})\n"],"names":["useStyles","makeZenithStyles","SLOT_ATTR","shorthands","tokens.spacingElement2","tokens.grayA4","tokens.radiusMd","tokens.grayA5","tokens.spacingElement3","tokens.spacingGroup2","tokens.textSm","tokens.leadingSm","tokens.fontWeightMedium","ButtonGroup","React","className","orientation","props","ref","styles","jsx","mergeClasses","ButtonGroupText","ButtonGroupSeparator","Separator"],"mappings":"
|
|
1
|
+
{"version":3,"file":"button-group.js","sources":["../../../src/components/button-group/button-group.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel } from \"../../styles/host-reset\"\nimport * as tokens from \"../../tokens\"\nimport { Separator, type SeparatorProps } from \"../separator/separator\"\n\n/**\n * ButtonGroup — compound component family for grouping buttons, text, and separators. One\n * `makeZenithStyles` call for the whole family, one slot per sub-component (following `card.tsx`).\n */\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nconst useStyles = makeZenithStyles({\n root: {\n ...boxModel,\n display: \"flex\",\n width: \"fit-content\",\n alignItems: \"stretch\",\n \"& > *:focus-visible\": {\n zIndex: 10,\n position: \"relative\",\n },\n [`&:has(> [${SLOT_ATTR}=\"button-group\"])`]: {\n ...shorthands.gap(tokens.spacingElement2),\n },\n },\n horizontal: {\n \"& > *:not(:first-child)\": {\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n borderLeftWidth: 0,\n },\n \"& > *:not(:last-child)\": {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n },\n },\n vertical: {\n flexDirection: \"column\",\n \"& > *:not(:first-child)\": {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderTopWidth: 0,\n },\n \"& > *:not(:last-child)\": {\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n },\n },\n text: {\n ...boxModel,\n backgroundColor: tokens.grayA4,\n display: \"flex\",\n alignItems: \"center\",\n ...shorthands.gap(tokens.spacingElement2),\n ...shorthands.borderRadius(tokens.radiusMd),\n ...shorthands.border(\"1px\", \"solid\", tokens.grayA5),\n ...shorthands.padding(tokens.spacingElement3, tokens.spacingGroup2),\n fontSize: tokens.textSm,\n lineHeight: tokens.leadingSm,\n fontWeight: tokens.fontWeightMedium,\n // Tailwind `shadow-xs` — literal per CONVENTIONS B7\n boxShadow: \"0 1px 2px 0 #0000000d\",\n \"& svg\": {\n pointerEvents: \"none\",\n width: \"1rem\",\n height: \"1rem\",\n },\n },\n separator: {\n ...shorthands.margin(0),\n position: \"relative\",\n alignSelf: \"stretch\",\n backgroundColor: \"transparent\",\n },\n separatorVertical: {\n ...boxModel,\n height: \"1px\",\n },\n})\n\nexport type ButtonGroupProps = React.ComponentProps<\"div\"> & {\n orientation?: ButtonGroupOrientation\n}\n\nexport const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(\n function ButtonGroup(\n { className, orientation = \"horizontal\", ...props },\n ref\n ) {\n const styles = useStyles()\n\n return (\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"button-group\"\n {...{ [SLOT_ATTR]: \"button-group\" }}\n data-orientation={orientation}\n className={mergeClasses(styles.root, styles[orientation], className)}\n {...props}\n />\n )\n }\n)\n\nexport type ButtonGroupTextProps = React.ComponentProps<\"div\">\n\nexport const ButtonGroupText = React.forwardRef<\n HTMLDivElement,\n ButtonGroupTextProps\n>(function ButtonGroupText({ className, ...props }, ref) {\n const styles = useStyles()\n\n return (\n <div\n ref={ref}\n data-slot=\"button-group-text\"\n {...{ [SLOT_ATTR]: \"button-group-text\" }}\n className={mergeClasses(styles.text, className)}\n {...props}\n />\n )\n})\n\nexport type ButtonGroupSeparatorProps = SeparatorProps\n\nexport const ButtonGroupSeparator = React.forwardRef<\n HTMLDivElement,\n ButtonGroupSeparatorProps\n>(function ButtonGroupSeparator(\n { className, orientation = \"vertical\", ...props },\n ref\n) {\n const styles = useStyles()\n\n return (\n <Separator\n ref={ref}\n data-slot=\"button-group-separator\"\n {...{ [SLOT_ATTR]: \"button-group-separator\" }}\n orientation={orientation}\n className={mergeClasses(\n styles.separator,\n orientation === \"vertical\" && styles.separatorVertical,\n className\n )}\n {...props}\n />\n )\n})\n"],"names":["useStyles","makeZenithStyles","boxModel","SLOT_ATTR","shorthands","tokens.spacingElement2","tokens.grayA4","tokens.radiusMd","tokens.grayA5","tokens.spacingElement3","tokens.spacingGroup2","tokens.textSm","tokens.leadingSm","tokens.fontWeightMedium","ButtonGroup","React","className","orientation","props","ref","styles","jsx","mergeClasses","ButtonGroupText","ButtonGroupSeparator","Separator"],"mappings":";;;;;;;AAiBA,MAAMA,IAAYC,EAAiB;AAAA,EACjC,MAAM;AAAA,IACJ,GAAGC;AAAA,IACH,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,uBAAuB;AAAA,MACrB,QAAQ;AAAA,MACR,UAAU;AAAA,IAAA;AAAA,IAEZ,CAAC,YAAYC,CAAS,mBAAmB,GAAG;AAAA,MAC1C,GAAGC,EAAW,IAAIC,CAAsB;AAAA,IAAA;AAAA,EAC1C;AAAA,EAEF,YAAY;AAAA,IACV,2BAA2B;AAAA,MACzB,qBAAqB;AAAA,MACrB,wBAAwB;AAAA,MACxB,iBAAiB;AAAA,IAAA;AAAA,IAEnB,0BAA0B;AAAA,MACxB,sBAAsB;AAAA,MACtB,yBAAyB;AAAA,IAAA;AAAA,EAC3B;AAAA,E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