@stll/ui 0.88.0 → 0.89.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.
@@ -1,4 +1,5 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
2
3
  // src/components/brand-icons.tsx
3
4
  const DiscordLogoIcon = (props) => /* @__PURE__ */ jsx("svg", {
4
5
  "aria-hidden": "true",
@@ -30,23 +31,239 @@ const OpenAILogoIcon = (props) => /* @__PURE__ */ jsx("svg", {
30
31
  });
31
32
  const ClaudeLogoIcon = (props) => /* @__PURE__ */ jsx("svg", {
32
33
  "aria-hidden": "true",
33
- fill: "currentColor",
34
- viewBox: "0 0 24 24",
35
- ...props,
36
- children: /* @__PURE__ */ jsx("path", { d: "M12 2.25l1.35 7.45 5.4-5.2-3.55 6.7 7.3-1.45-6.55 3.65 6.55 3.65-7.3-1.45 3.55 6.7-5.4-5.2L12 21.75l-1.35-7.45-5.4 5.2 3.55-6.7-7.3 1.45 6.55-3.65-6.55-3.65 7.3 1.45-3.55-6.7 5.4 5.2L12 2.25Z" })
37
- });
38
- const GeminiLogoIcon = (props) => /* @__PURE__ */ jsx("svg", {
39
- "aria-hidden": "true",
40
- fill: "currentColor",
41
- viewBox: "0 0 24 24",
42
- ...props,
43
- children: /* @__PURE__ */ jsx("path", { d: "M11.12 1.09H12.88L12.93 1.95C13.22 6.85 17.15 10.78 22.05 11.07L22.91 11.12V12.88L22.05 12.93C17.15 13.22 13.22 17.15 12.93 22.06L12.88 22.91H11.12L11.07 22.06C10.78 17.15 6.85 13.22 1.95 12.93L1.09 12.88V11.12L1.95 11.07C6.85 10.78 10.78 6.85 11.07 1.95L11.12 1.09ZM12 5.85C10.83 8.62 8.62 10.83 5.85 12C8.62 13.17 10.83 15.38 12 18.15C13.17 15.38 15.38 13.17 18.15 12C15.38 10.83 13.17 8.62 12 5.85Z" })
44
- });
45
- const AntigravityLogoIcon = (props) => /* @__PURE__ */ jsx("svg", {
46
- "aria-hidden": "true",
47
- fill: "currentColor",
48
- viewBox: "0 0 24 24",
34
+ fill: "none",
35
+ viewBox: "0 0 94 94",
49
36
  ...props,
50
- children: /* @__PURE__ */ jsx("path", { d: "M12 2.75C10.6 2.75 9.45 3.6 8.65 5.15L2.95 16.4C2.1 18.08 2.85 20.1 4.55 20.75C5.9 21.25 7.35 20.7 8.15 19.45L10.35 16.05C11.1 14.9 12.9 14.9 13.65 16.05L15.85 19.45C16.65 20.7 18.1 21.25 19.45 20.75C21.15 20.1 21.9 18.08 21.05 16.4L15.35 5.15C14.55 3.6 13.4 2.75 12 2.75Z" })
37
+ children: /* @__PURE__ */ jsx("path", {
38
+ d: "M18.7657 62.4437L37.1822 52.1167L37.4857 51.2122L37.1822 50.7085H36.2715L33.1852 50.5208L22.6615 50.2391L13.5545 49.8636L4.70044 49.3942L2.47428 48.9248L0.399902 46.1553L0.602281 44.794L2.47428 43.5266L5.15579 43.7613L11.0754 44.1837L19.98 44.794L26.4055 45.1695L35.9679 46.1553H37.4857L37.6881 45.545L37.1822 45.1695L36.7774 44.794L27.5692 38.5508L17.6021 31.9791L12.3908 28.1769L9.60812 26.2524L8.19147 24.4686L7.58433 20.5256L10.1141 17.7091L13.5545 17.9438L14.4146 18.1785L17.9056 20.8542L25.343 26.6279L35.0572 33.7629L36.4739 34.9364L37.0443 34.5514L37.1316 34.2792L36.4739 33.1996L31.212 23.6706L25.596 13.9539L23.0663 9.91695L22.4086 7.52296C22.1538 6.51831 22.0038 5.68714 22.0038 4.65957L24.8877 0.716544L26.5067 0.200195L30.4025 0.716544L32.0215 2.12477L34.4501 7.66379L38.3458 16.3478L44.4172 28.1769L46.188 31.6975L47.1493 34.9364L47.5035 35.9222H48.1106V35.3589L48.6166 28.6933L49.5273 20.5256L50.438 10.0108L50.7415 7.05356L52.2088 3.48605L55.1433 1.56148L57.42 2.64112L59.292 5.31674L59.039 7.05356L57.926 14.2824L55.7504 25.5952L54.3337 33.1996H55.1433L56.1046 32.2138L59.9497 27.1442L66.3752 19.0704L69.2085 15.8784L72.5478 12.3579L74.6728 10.668H78.7203L81.6548 15.0804L80.3394 19.6337L76.1906 24.8911L72.7502 29.3504L67.8172 35.9595L64.7562 41.2734L65.0307 41.7118L65.7681 41.6489L76.8989 39.255L82.9197 38.1753L90.1041 36.9549L93.3422 38.457L93.6963 40.006L92.4315 43.151L84.7411 45.0287L75.7353 46.8594L62.3244 50.0164L62.1759 50.1358L62.3512 50.3958L68.399 50.9432L70.9794 51.084H77.3037L89.0922 51.9759L92.1785 53.9944L93.9999 56.4822L93.6963 58.4068L88.9404 60.8008L82.5655 59.2987L67.6401 55.7312L62.5301 54.4638H61.8217V54.8862L66.0717 59.064L73.9139 66.1051L83.6786 75.2116L84.1845 77.4648L82.9197 79.2485L81.6042 79.0608L73.0032 72.5829L69.6639 69.6726L62.1759 63.3356H61.67V63.9928L63.3902 66.5276L72.5478 80.2812L73.0032 84.5059L72.3454 85.8672L69.9675 86.7121L67.3871 86.2427L61.9735 78.6852L56.4587 70.2359L52.0064 62.6315L51.4687 62.971L48.8189 91.2654L47.6047 92.7206L44.7714 93.8002L42.3934 92.0164L41.1286 89.1061L42.3934 83.3324L43.9113 75.8219L45.1255 69.8604L46.2386 62.4437L46.9184 59.9661L46.8583 59.8003L46.3153 59.8916L40.7238 67.5603L32.2239 79.0608L25.4948 86.2427L23.8758 86.8999L21.0931 85.4447L21.3461 82.863L22.9145 80.5629L32.2239 68.7338L37.8399 61.3641L41.4594 57.1337L41.4242 56.5218L41.2244 56.5048L16.489 72.6299L12.0873 73.1932L10.1647 71.4094L10.4176 68.4991L11.3283 67.5603L18.7657 62.4437Z",
39
+ fill: "#D97757"
40
+ })
51
41
  });
42
+ const GEMINI_PATH = "M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z";
43
+ const GEMINI_GRADIENTS = [
44
+ {
45
+ layer: 1,
46
+ x1: 7,
47
+ x2: 11,
48
+ y1: 15.5,
49
+ y2: 12,
50
+ color: "#08B962",
51
+ fade: "1"
52
+ },
53
+ {
54
+ layer: 2,
55
+ x1: 8,
56
+ x2: 11.5,
57
+ y1: 5.5,
58
+ y2: 11,
59
+ color: "#F94543",
60
+ fade: "1"
61
+ },
62
+ {
63
+ layer: 3,
64
+ x1: 3.5,
65
+ x2: 17.5,
66
+ y1: 13.5,
67
+ y2: 12,
68
+ color: "#FABC12",
69
+ fade: ".46"
70
+ }
71
+ ];
72
+ const GeminiLogoIcon = (props) => {
73
+ const id = useId();
74
+ return /* @__PURE__ */ jsxs("svg", {
75
+ "aria-hidden": "true",
76
+ fill: "none",
77
+ viewBox: "0 0 24 24",
78
+ ...props,
79
+ children: [
80
+ /* @__PURE__ */ jsx("path", {
81
+ d: GEMINI_PATH,
82
+ fill: "#3186FF"
83
+ }),
84
+ GEMINI_GRADIENTS.map(({ layer }) => /* @__PURE__ */ jsx("path", {
85
+ d: GEMINI_PATH,
86
+ fill: `url(#${id}-${layer})`
87
+ }, layer)),
88
+ /* @__PURE__ */ jsx("defs", { children: GEMINI_GRADIENTS.map(({ layer, color, fade, ...line }) => /* @__PURE__ */ jsxs("linearGradient", {
89
+ gradientUnits: "userSpaceOnUse",
90
+ id: `${id}-${layer}`,
91
+ ...line,
92
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: color }), /* @__PURE__ */ jsx("stop", {
93
+ offset: fade,
94
+ stopColor: color,
95
+ stopOpacity: "0"
96
+ })]
97
+ }, layer)) })
98
+ ]
99
+ });
100
+ };
101
+ const ANTIGRAVITY_SILHOUETTE = "M21.751 22.607c1.34 1.005 3.35.335 1.508-1.508C17.73 15.74 18.904 1 12.037 1 5.17 1 6.342 15.74.815 21.1c-2.01 2.009.167 2.511 1.507 1.506 5.192-3.517 4.857-9.714 9.715-9.714 4.857 0 4.522 6.197 9.714 9.715z";
102
+ const ANTIGRAVITY_GREEN_BLOB = "M-12.443 10.804c1.338 4.703 7.36 7.11 13.453 5.378 6.092-1.733 9.947-6.95 8.61-11.652C8.282-.173 2.26-2.58-3.833-.848-9.925.884-13.78 6.1-12.443 10.804z";
103
+ const ANTIGRAVITY_BLOBS = [
104
+ {
105
+ layer: 1,
106
+ d: "M-1.018-3.992c-.408 3.591 2.686 6.89 6.91 7.37 4.225.48 7.98-2.043 8.387-5.633.408-3.59-2.686-6.89-6.91-7.37-4.225-.479-7.98 2.043-8.387 5.633z",
107
+ fill: "#FFE432",
108
+ x: -3.288,
109
+ y: -11.917,
110
+ width: 19.838,
111
+ height: 17.587,
112
+ blur: 1.117
113
+ },
114
+ {
115
+ layer: 2,
116
+ d: "M15.269 7.747c1.058 4.557 5.691 7.374 10.348 6.293 4.657-1.082 7.575-5.653 6.516-10.21-1.058-4.556-5.691-7.374-10.348-6.292-4.657 1.082-7.575 5.653-6.516 10.21z",
117
+ fill: "#FC413D",
118
+ x: 4.251,
119
+ y: -13.493,
120
+ width: 38.9,
121
+ height: 38.565,
122
+ blur: 5.4
123
+ },
124
+ {
125
+ layer: 3,
126
+ d: ANTIGRAVITY_GREEN_BLOB,
127
+ fill: "#00B95C",
128
+ x: -21.889,
129
+ y: -10.592,
130
+ width: 40.955,
131
+ height: 36.517,
132
+ blur: 4.591
133
+ },
134
+ {
135
+ layer: 4,
136
+ d: ANTIGRAVITY_GREEN_BLOB,
137
+ fill: "#00B95C",
138
+ x: -21.889,
139
+ y: -10.592,
140
+ width: 40.955,
141
+ height: 36.517,
142
+ blur: 4.591
143
+ },
144
+ {
145
+ layer: 5,
146
+ d: "M-7.608 14.703c3.352 3.424 9.126 3.208 12.896-.483 3.77-3.69 4.108-9.459.756-12.883C2.69-2.087-3.083-1.871-6.853 1.82c-3.77 3.69-4.108 9.458-.755 12.883z",
147
+ fill: "#00B95C",
148
+ x: -19.099,
149
+ y: -10.278,
150
+ width: 36.632,
151
+ height: 36.595,
152
+ blur: 4.591
153
+ },
154
+ {
155
+ layer: 6,
156
+ d: "M9.932 27.617c1.04 4.482 5.384 7.303 9.7 6.3 4.316-1.002 6.971-5.448 5.93-9.93-1.04-4.483-5.384-7.304-9.7-6.301-4.316 1.002-6.971 5.448-5.93 9.93z",
157
+ fill: "#3186FF",
158
+ x: .981,
159
+ y: 8.758,
160
+ width: 33.533,
161
+ height: 34.087,
162
+ blur: 4.363
163
+ },
164
+ {
165
+ layer: 7,
166
+ d: "M2.572-8.185C.392-3.329 2.778 2.472 7.9 4.771c5.122 2.3 11.042.227 13.222-4.63 2.18-4.855-.205-10.656-5.327-12.955-5.122-2.3-11.042-.227-13.222 4.63z",
167
+ fill: "#FBBC04",
168
+ x: -6.143,
169
+ y: -21.659,
170
+ width: 35.978,
171
+ height: 35.276,
172
+ blur: 3.954
173
+ },
174
+ {
175
+ layer: 8,
176
+ d: "M-3.267 38.686c-5.277-2.072 3.742-19.117 5.984-24.83 2.243-5.712 8.34-8.664 13.616-6.592 5.278 2.071 11.533 13.482 9.29 19.195-2.242 5.713-23.613 14.298-28.89 12.227z",
177
+ fill: "#3186FF",
178
+ x: -11.96,
179
+ y: -.46,
180
+ width: 45.114,
181
+ height: 46.523,
182
+ blur: 3.531
183
+ },
184
+ {
185
+ layer: 9,
186
+ d: "M28.71 17.471c-1.413 1.649-5.1.808-8.236-1.878-3.135-2.687-4.531-6.201-3.118-7.85 1.412-1.649 5.1-.808 8.235 1.878s4.532 6.2 3.119 7.85z",
187
+ fill: "#749BFF",
188
+ x: 10.485,
189
+ y: .58,
190
+ width: 25.094,
191
+ height: 24.054,
192
+ blur: 3.159
193
+ },
194
+ {
195
+ layer: 10,
196
+ d: "M18.163 9.077c5.81 3.93 12.502 4.19 14.946.577 2.443-3.612-.287-9.727-6.098-13.658-5.81-3.931-12.502-4.19-14.946-.577-2.443 3.612.287 9.727 6.098 13.658z",
197
+ fill: "#FC413D",
198
+ x: 5.833,
199
+ y: -12.467,
200
+ width: 33.508,
201
+ height: 30.007,
202
+ blur: 2.669
203
+ },
204
+ {
205
+ layer: 11,
206
+ d: "M-.915 2.684c-1.44 3.473-.97 6.967 1.05 7.804 2.02.837 4.824-1.3 6.264-4.772 1.44-3.473.97-6.967-1.05-7.804-2.02-.837-4.824 1.3-6.264 4.772z",
207
+ fill: "#FFEE48",
208
+ x: -8.355,
209
+ y: -8.876,
210
+ width: 22.194,
211
+ height: 26.151,
212
+ blur: 3.303
213
+ }
214
+ ];
215
+ const AntigravityLogoIcon = (props) => {
216
+ const id = useId();
217
+ return /* @__PURE__ */ jsxs("svg", {
218
+ "aria-hidden": "true",
219
+ fill: "none",
220
+ viewBox: "0 0 24 24",
221
+ ...props,
222
+ children: [
223
+ /* @__PURE__ */ jsx("mask", {
224
+ height: "23",
225
+ id: `${id}-mask`,
226
+ maskUnits: "userSpaceOnUse",
227
+ width: "24",
228
+ x: "0",
229
+ y: "1",
230
+ children: /* @__PURE__ */ jsx("path", {
231
+ d: ANTIGRAVITY_SILHOUETTE,
232
+ fill: "#fff"
233
+ })
234
+ }),
235
+ /* @__PURE__ */ jsx("g", {
236
+ mask: `url(#${id}-mask)`,
237
+ children: ANTIGRAVITY_BLOBS.map(({ layer, d, fill }) => /* @__PURE__ */ jsx("g", {
238
+ filter: `url(#${id}-${layer})`,
239
+ children: /* @__PURE__ */ jsx("path", {
240
+ d,
241
+ fill
242
+ })
243
+ }, layer))
244
+ }),
245
+ /* @__PURE__ */ jsx("defs", { children: ANTIGRAVITY_BLOBS.map(({ layer, x, y, width, height, blur }) => /* @__PURE__ */ jsxs("filter", {
246
+ colorInterpolationFilters: "sRGB",
247
+ filterUnits: "userSpaceOnUse",
248
+ height,
249
+ id: `${id}-${layer}`,
250
+ width,
251
+ x,
252
+ y,
253
+ children: [
254
+ /* @__PURE__ */ jsx("feFlood", {
255
+ floodOpacity: "0",
256
+ result: "BackgroundImageFix"
257
+ }),
258
+ /* @__PURE__ */ jsx("feBlend", {
259
+ in: "SourceGraphic",
260
+ in2: "BackgroundImageFix",
261
+ result: "shape"
262
+ }),
263
+ /* @__PURE__ */ jsx("feGaussianBlur", { stdDeviation: blur })
264
+ ]
265
+ }, layer)) })
266
+ ]
267
+ });
268
+ };
52
269
  export { AntigravityLogoIcon, ClaudeLogoIcon, DiscordLogoIcon, GeminiLogoIcon, GitHubLogoIcon, OpenAILogoIcon, XLogoIcon };
@@ -1,5 +1,6 @@
1
1
  import { ContextMenuAction } from "./context-menu.js";
2
2
  import { ReactNode, Ref } from "react";
3
+ import { useRender } from "@base-ui/react/use-render";
3
4
  /** One action of an object: the same shape `ContextMenu` renders. */
4
5
  export type EntityAction = ContextMenuAction;
5
6
  export type EntityActionsProps = {
@@ -14,12 +15,18 @@ export type EntityActionsProps = {
14
15
  heading?: ReactNode;
15
16
  /** The accessible name of the "…" button, e.g. "Actions". */
16
17
  label: string;
18
+ /**
19
+ * Optional host element to attach the right-click listener to directly
20
+ * (for example `<TableRow />`, where a wrapping `<div className="contents">`
21
+ * would be invalid HTML inside `<tbody>`).
22
+ */
23
+ render?: useRender.RenderProp;
17
24
  };
18
25
  /**
19
26
  * An object's actions: the right-click menu over `children`, and the list
20
27
  * an `EntityActionsButton` inside them opens.
21
28
  */
22
- export declare const EntityActions: ({ actions, children, heading, label }: EntityActionsProps) => import("react").JSX.Element;
29
+ export declare const EntityActions: ({ actions, children, heading, label, render }: EntityActionsProps) => import("react").JSX.Element;
23
30
  export type EntityActionsButtonProps = {
24
31
  /** Popup alignment against the button. */
25
32
  align?: "center" | "end" | "start";
@@ -6,7 +6,9 @@ import { ContextMenuActionItems } from "./context-menu.js";
6
6
  import { DropdownMenu as Menu, DropdownMenuContent as MenuPopup, DropdownMenuGroup as MenuGroup, DropdownMenuLabel as MenuGroupLabel, DropdownMenuSeparator as MenuSeparator, DropdownMenuTrigger as MenuTrigger, MenuAnchor } from "./menu.js";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { createContext, use, useRef, useState } from "react";
9
+ import { useRender } from "@base-ui/react/use-render";
9
10
  import { panic } from "better-result";
11
+ import { createPortal } from "react-dom";
10
12
  // src/components/entity-actions.tsx
11
13
  const EntityActionsContext = createContext(null);
12
14
  const isContextMenuKey = (event) => event.key === "ContextMenu" || event.shiftKey && event.key === "F10";
@@ -39,8 +41,9 @@ const EntityActionItems = ({ actions, heading }) => /* @__PURE__ */ jsxs(Fragmen
39
41
  * An object's actions: the right-click menu over `children`, and the list
40
42
  * an `EntityActionsButton` inside them opens.
41
43
  */
42
- const EntityActions = ({ actions, children, heading, label }) => {
44
+ const EntityActions = ({ actions, children, heading, label, render }) => {
43
45
  const [open, setOpen] = useState(false);
46
+ const [hasOpened, setHasOpened] = useState(false);
44
47
  const [anchor, setAnchor] = useState(null);
45
48
  const returnFocus = useRef(null);
46
49
  const context = {
@@ -53,6 +56,7 @@ const EntityActions = ({ actions, children, heading, label }) => {
53
56
  event.preventDefault();
54
57
  event.stopPropagation();
55
58
  returnFocus.current = focusReturnTarget(event.currentTarget, event.target);
59
+ setHasOpened(true);
56
60
  setAnchor(anchorRect);
57
61
  setOpen(true);
58
62
  };
@@ -71,32 +75,40 @@ const EntityActions = ({ actions, children, heading, label }) => {
71
75
  }) !== null) return;
72
76
  openAt(event, { getBoundingClientRect: () => target.getBoundingClientRect() });
73
77
  };
74
- return /* @__PURE__ */ jsxs(EntityActionsContext, {
75
- value: context,
76
- children: [/* @__PURE__ */ jsx("div", {
77
- className: "contents",
78
+ const target = useRender({
79
+ defaultTagName: "div",
80
+ render,
81
+ props: {
82
+ ...render === void 0 ? {
83
+ className: "contents",
84
+ role: "presentation"
85
+ } : {},
78
86
  "data-context-menu-target": "",
79
87
  "data-slot": "entity-actions",
80
88
  onContextMenu: handleContextMenu,
81
89
  onKeyDown: handleKeyDown,
82
- role: "presentation",
83
90
  children
84
- }), hasActions && /* @__PURE__ */ jsxs(Menu, {
85
- onOpenChange: (nextOpen) => {
86
- setOpen(nextOpen);
87
- if (!nextOpen) setAnchor(null);
88
- },
89
- open,
90
- children: [/* @__PURE__ */ jsx(MenuAnchor, {}), /* @__PURE__ */ jsx(MenuPopup, {
91
- anchor: anchor ?? void 0,
92
- "data-slot": "entity-actions-context-popup",
93
- finalFocus: () => returnFocus.current ?? false,
94
- children: /* @__PURE__ */ jsx(EntityActionItems, {
95
- actions,
96
- heading
97
- })
98
- })]
91
+ }
92
+ });
93
+ const contextMenu = hasActions && hasOpened ? /* @__PURE__ */ jsxs(Menu, {
94
+ onOpenChange: (nextOpen) => {
95
+ setOpen(nextOpen);
96
+ if (!nextOpen) setAnchor(null);
97
+ },
98
+ open,
99
+ children: [/* @__PURE__ */ jsx(MenuAnchor, {}), /* @__PURE__ */ jsx(MenuPopup, {
100
+ anchor: anchor ?? void 0,
101
+ "data-slot": "entity-actions-context-popup",
102
+ finalFocus: () => returnFocus.current ?? false,
103
+ children: /* @__PURE__ */ jsx(EntityActionItems, {
104
+ actions,
105
+ heading
106
+ })
99
107
  })]
108
+ }) : null;
109
+ return /* @__PURE__ */ jsxs(EntityActionsContext, {
110
+ value: context,
111
+ children: [target, contextMenu !== null && typeof document !== "undefined" && createPortal(contextMenu, document.body)]
100
112
  });
101
113
  };
102
114
  /**
@@ -3,15 +3,20 @@ import { Switch as Switch$1 } from "@base-ui/react/switch";
3
3
  import { SwitchSize } from "./toggle-classes.js";
4
4
  type SwitchProps = Switch$1.Root.Props & {
5
5
  size?: SwitchSize | undefined;
6
+ /**
7
+ * Why the switch cannot be toggled right now, in the reader's terms.
8
+ * Shown as a tooltip while `disabled` is true.
9
+ */
10
+ disabledReason?: React.ReactNode;
6
11
  };
7
- declare const Switch: ({ className, size, ...props }: SwitchProps) => React.JSX.Element;
12
+ declare const Switch: ({ className, disabled, disabledReason, size, ...props }: SwitchProps) => React.JSX.Element;
8
13
  /**
9
14
  * A setting row: its label and an optional description at the start, the
10
15
  * switch at the end. The whole row is the label, so a click anywhere on it
11
16
  * flips the switch, and the row is at least 44px tall for touch. The
12
17
  * description is linked to the switch, so it is read after the name.
13
18
  */
14
- declare const SwitchField: ({ className, description, label, size, ...props }: SwitchProps & {
19
+ declare const SwitchField: ({ className, description, disabledReason, label, size, ...props }: SwitchProps & {
15
20
  label: React.ReactNode;
16
21
  description?: React.ReactNode;
17
22
  }) => React.JSX.Element;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/utils.js";
3
3
  import { SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME } from "./toggle-classes.js";
4
+ import { renderTooltipTrigger } from "./tooltip-trigger-helper.js";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  import { useId } from "react";
6
7
  import { Switch as Switch$1 } from "@base-ui/react/switch";
@@ -9,23 +10,31 @@ const SWITCH_THUMB_SIZE_CLASS_NAME = {
9
10
  default: "size-4 ltr:data-checked:translate-x-4.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-4.5 rtl:data-unchecked:-translate-x-0.5",
10
11
  sm: "size-3 ltr:data-checked:translate-x-3.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-3.5 rtl:data-unchecked:-translate-x-0.5"
11
12
  };
12
- const Switch = ({ className, size = "default", ...props }) => /* @__PURE__ */ jsx(Switch$1.Root, {
13
- className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], className),
14
- "data-size": size,
15
- "data-slot": "switch",
16
- ...props,
17
- children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
18
- className: cn("bg-background pointer-events-none block rounded-full shadow-xs transition-transform", SWITCH_THUMB_SIZE_CLASS_NAME[size]),
19
- "data-slot": "switch-thumb"
20
- })
21
- });
13
+ const Switch = ({ className, disabled, disabledReason, size = "default", ...props }) => {
14
+ const trigger = /* @__PURE__ */ jsx(Switch$1.Root, {
15
+ className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], className),
16
+ "data-size": size,
17
+ "data-slot": "switch",
18
+ disabled,
19
+ ...props,
20
+ children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
21
+ className: cn("bg-background pointer-events-none block rounded-full shadow-xs transition-transform", SWITCH_THUMB_SIZE_CLASS_NAME[size]),
22
+ "data-slot": "switch-thumb"
23
+ })
24
+ });
25
+ return renderTooltipTrigger({
26
+ keepTriggerMounted: disabledReason !== void 0,
27
+ tooltip: disabled ? disabledReason : void 0,
28
+ trigger
29
+ });
30
+ };
22
31
  /**
23
32
  * A setting row: its label and an optional description at the start, the
24
33
  * switch at the end. The whole row is the label, so a click anywhere on it
25
34
  * flips the switch, and the row is at least 44px tall for touch. The
26
35
  * description is linked to the switch, so it is read after the name.
27
36
  */
28
- const SwitchField = ({ className, description, label, size, ...props }) => {
37
+ const SwitchField = ({ className, description, disabledReason, label, size, ...props }) => {
29
38
  const descriptionId = useId();
30
39
  return /* @__PURE__ */ jsxs("label", {
31
40
  className: cn("flex min-h-11 cursor-pointer items-center justify-between gap-4 py-2 has-data-disabled:cursor-not-allowed", className),
@@ -43,6 +52,7 @@ const SwitchField = ({ className, description, label, size, ...props }) => {
43
52
  })]
44
53
  }), /* @__PURE__ */ jsx(Switch, {
45
54
  "aria-describedby": description === void 0 ? void 0 : descriptionId,
55
+ disabledReason,
46
56
  size,
47
57
  ...props
48
58
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/ui",
3
- "version": "0.88.0",
3
+ "version": "0.89.1",
4
4
  "description": "Stella's design system: bidi-aware React primitives built on Base UI, the dockable inspector pane, and the Tailwind v4 theme they are styled with.",
5
5
  "keywords": [
6
6
  "base-ui",