beacon-ui 3.1.5 → 3.1.8

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +407 -16
  3. package/dist/components/Avatar.d.ts +13 -16
  4. package/dist/components/Avatar.d.ts.map +1 -1
  5. package/dist/components/Avatar.js +6 -4
  6. package/dist/components/Button.d.ts +21 -19
  7. package/dist/components/Button.d.ts.map +1 -1
  8. package/dist/components/Button.js +100 -80
  9. package/dist/components/Card.d.ts +8 -11
  10. package/dist/components/Card.d.ts.map +1 -1
  11. package/dist/components/Card.js +5 -3
  12. package/dist/components/Checkbox.d.ts +5 -6
  13. package/dist/components/Checkbox.d.ts.map +1 -1
  14. package/dist/components/Checkbox.js +191 -38
  15. package/dist/components/Chip.d.ts +6 -9
  16. package/dist/components/Chip.d.ts.map +1 -1
  17. package/dist/components/Chip.js +6 -5
  18. package/dist/components/Input.d.ts +10 -15
  19. package/dist/components/Input.d.ts.map +1 -1
  20. package/dist/components/Input.js +22 -21
  21. package/dist/components/Menu.d.ts +9 -6
  22. package/dist/components/Menu.d.ts.map +1 -1
  23. package/dist/components/Menu.js +63 -31
  24. package/dist/components/MenuItem.d.ts +13 -0
  25. package/dist/components/MenuItem.d.ts.map +1 -0
  26. package/dist/components/MenuItem.js +90 -0
  27. package/dist/components/RadioButton.d.ts +6 -8
  28. package/dist/components/RadioButton.d.ts.map +1 -1
  29. package/dist/components/RadioButton.js +68 -16
  30. package/dist/components/Switch.d.ts +5 -6
  31. package/dist/components/Switch.d.ts.map +1 -1
  32. package/dist/components/Switch.js +296 -38
  33. package/dist/index.d.ts +11 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +1 -0
  36. package/package.json +1 -1
@@ -1,9 +1,55 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo } from "react";
3
+ import { useMemo, useState, useCallback } from "react";
4
+ import { useThemeSafe } from "../providers/ThemeProvider";
4
5
  const RADIO_SIZE = 20;
5
- export function RadioButton({ selected = false, status = "default", label = "Radio Button", showLabel = true, theme, hue, }) {
6
- const disabled = status === "disabled";
6
+ export function RadioButton({ selected = false, onChange, disabled = false, id, label = "Radio Button", showLabel = true, status: statusProp, className, style, onClick, onFocus, onBlur, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, ref, ...rest }) {
7
+ useThemeSafe(); // Ensure theme context is available
8
+ const [internalStatus, setInternalStatus] = useState("default");
9
+ const status = statusProp ?? internalStatus;
10
+ const handleClick = useCallback((e) => {
11
+ if (!disabled && onChange) {
12
+ onChange(!selected);
13
+ }
14
+ onClick?.(e);
15
+ }, [selected, disabled, onChange, onClick]);
16
+ const handleFocus = useCallback((e) => {
17
+ if (!disabled && !statusProp) {
18
+ setInternalStatus("focused");
19
+ }
20
+ onFocus?.(e);
21
+ }, [disabled, statusProp, onFocus]);
22
+ const handleBlur = useCallback((e) => {
23
+ if (!disabled && !statusProp) {
24
+ setInternalStatus("default");
25
+ }
26
+ onBlur?.(e);
27
+ }, [disabled, statusProp, onBlur]);
28
+ const handleMouseEnter = useCallback((e) => {
29
+ if (!disabled && !statusProp) {
30
+ setInternalStatus("hovered");
31
+ }
32
+ onMouseEnter?.(e);
33
+ }, [disabled, statusProp, onMouseEnter]);
34
+ const handleMouseLeave = useCallback((e) => {
35
+ if (!disabled && !statusProp) {
36
+ setInternalStatus("default");
37
+ }
38
+ onMouseLeave?.(e);
39
+ }, [disabled, statusProp, onMouseLeave]);
40
+ const handleMouseDown = useCallback((e) => {
41
+ if (!disabled && !statusProp) {
42
+ setInternalStatus("pressed");
43
+ }
44
+ onMouseDown?.(e);
45
+ }, [disabled, statusProp, onMouseDown]);
46
+ const handleMouseUp = useCallback((e) => {
47
+ if (!disabled && !statusProp) {
48
+ setInternalStatus("default");
49
+ }
50
+ onMouseUp?.(e);
51
+ }, [disabled, statusProp, onMouseUp]);
52
+ const currentStatus = disabled ? "disabled" : status;
7
53
  const radioStyles = useMemo(() => {
8
54
  const baseStyles = {
9
55
  width: `${RADIO_SIZE}px`,
@@ -28,7 +74,7 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
28
74
  backgroundColor: "transparent",
29
75
  };
30
76
  }
31
- if (status === "hovered") {
77
+ if (currentStatus === "hovered") {
32
78
  return {
33
79
  ...baseStyles,
34
80
  borderWidth: "var(--border-width-150)",
@@ -37,7 +83,7 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
37
83
  backgroundColor: "transparent",
38
84
  };
39
85
  }
40
- if (status === "focused" || status === "pressed") {
86
+ if (currentStatus === "focused" || currentStatus === "pressed") {
41
87
  return {
42
88
  ...baseStyles,
43
89
  borderWidth: "var(--border-width-150)",
@@ -66,7 +112,7 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
66
112
  backgroundColor: "transparent",
67
113
  };
68
114
  }
69
- if (status === "hovered" || status === "focused" || status === "pressed") {
115
+ if (currentStatus === "hovered" || currentStatus === "focused" || currentStatus === "pressed") {
70
116
  return {
71
117
  ...baseStyles,
72
118
  borderWidth: "var(--border-width-25)",
@@ -84,7 +130,7 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
84
130
  backgroundColor: "transparent",
85
131
  };
86
132
  }
87
- }, [selected, status, disabled]);
133
+ }, [selected, currentStatus, disabled]);
88
134
  const labelStyles = useMemo(() => {
89
135
  const baseStyles = {
90
136
  fontFamily: "var(--font-secondary)",
@@ -105,14 +151,8 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
105
151
  };
106
152
  }, [disabled]);
107
153
  const focusRingStyles = useMemo(() => {
108
- if (status !== "focused")
154
+ if (currentStatus !== "focused")
109
155
  return null;
110
- // Focus ring should be positioned outside the radio button
111
- // The container is always 20px with box-sizing: border-box
112
- // When selected: border is 6px (border-width-150), so the visual outer edge is at 20px
113
- // When unselected: border is 1px (border-width-25), so the visual outer edge is at 20px
114
- // The focus ring should be 4px outside the container edge, centered on the container
115
- // Using explicit width/height and centering to ensure consistent alignment: 20px + 8px (4px on each side) = 28px
116
156
  return {
117
157
  position: "absolute",
118
158
  top: "50%",
@@ -130,11 +170,23 @@ export function RadioButton({ selected = false, status = "default", label = "Rad
130
170
  : "var(--border-neutral-primary)",
131
171
  pointerEvents: "none",
132
172
  };
133
- }, [status, selected]);
173
+ }, [currentStatus, selected]);
134
174
  return (_jsxs("div", { style: {
135
175
  display: "flex",
136
176
  alignItems: "center",
137
177
  gap: "var(--spacing-200)",
138
178
  position: "relative",
139
- }, children: [_jsx("div", { style: radioStyles, children: focusRingStyles && _jsx("div", { style: focusRingStyles }) }), showLabel && label && _jsx("p", { style: labelStyles, children: label })] }));
179
+ }, className: className, children: [_jsx("div", { style: radioStyles, children: focusRingStyles && _jsx("div", { style: focusRingStyles }) }), _jsx("input", { ref: ref, type: "radio", id: id, checked: selected, disabled: disabled, onChange: () => {
180
+ if (!disabled && onChange) {
181
+ onChange(!selected);
182
+ }
183
+ }, onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, style: {
184
+ position: "absolute",
185
+ opacity: 0,
186
+ width: `${RADIO_SIZE}px`,
187
+ height: `${RADIO_SIZE}px`,
188
+ margin: 0,
189
+ cursor: disabled ? "not-allowed" : "pointer",
190
+ ...style,
191
+ }, ...rest }), showLabel && label && (_jsx("label", { htmlFor: id, style: labelStyles, children: label }))] }));
140
192
  }
@@ -1,11 +1,10 @@
1
- interface SwitchProps {
1
+ import { ComponentPropsWithRef } from "react";
2
+ export type SwitchStatus = "default" | "hovered" | "focused" | "pressed" | "disabled";
3
+ export interface SwitchProps extends Omit<ComponentPropsWithRef<"button">, "onChange" | "type"> {
2
4
  checked?: boolean;
3
5
  onChange?: (checked: boolean) => void;
4
- disabled?: boolean;
5
- id?: string;
6
- ariaLabel?: string;
7
6
  showIcons?: boolean;
7
+ status?: SwitchStatus;
8
8
  }
9
- export declare function Switch({ checked, onChange, disabled, id, ariaLabel, showIcons, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
10
- export {};
9
+ export declare function Switch({ checked, onChange, disabled, id, "aria-label": ariaLabel, showIcons, status: statusProp, className, style, onClick, onKeyDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }: SwitchProps): import("react/jsx-runtime").JSX.Element;
11
10
  //# sourceMappingURL=Switch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAQA,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,EACrB,OAAe,EACf,QAAQ,EACR,QAAgB,EAChB,EAAE,EACF,SAAS,EACT,SAAiB,GAClB,EAAE,WAAW,2CAkGb"}
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAEtF,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC7F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAOD,wBAAgB,MAAM,CAAC,EACrB,OAAe,EACf,QAAQ,EACR,QAAgB,EAChB,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,SAAiB,EACjB,MAAM,EAAE,UAAU,EAClB,SAAS,EACT,KAAK,EACL,OAAO,EACP,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,2CA2Yb"}
@@ -1,64 +1,322 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useState, useCallback } from "react";
4
- import { SwitchPreview } from "./SwitchPreview";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState, useCallback, useMemo } from "react";
5
4
  import { useThemeSafe } from "../providers/ThemeProvider";
6
- export function Switch({ checked = false, onChange, disabled = false, id, ariaLabel, showIcons = false, }) {
7
- const themeContext = useThemeSafe();
8
- const theme = themeContext?.theme;
9
- const hue = themeContext?.hue;
10
- const [status, setStatus] = useState("default");
11
- const handleClick = useCallback(() => {
5
+ import { SunIcon, MoonIcon } from "../icons";
6
+ const TRACK_WIDTH = "52px";
7
+ const HANDLE_SIZE = 24;
8
+ const ICON_CONTAINER_SIZE = 32;
9
+ const ICON_SIZE = 20;
10
+ export function Switch({ checked = false, onChange, disabled = false, id, "aria-label": ariaLabel, showIcons = false, status: statusProp, className, style, onClick, onKeyDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }) {
11
+ useThemeSafe(); // Ensure theme context is available
12
+ const [internalStatus, setInternalStatus] = useState("default");
13
+ const status = statusProp ?? internalStatus;
14
+ const handleClick = useCallback((e) => {
12
15
  if (!disabled && onChange) {
13
16
  onChange(!checked);
14
17
  }
15
- }, [checked, disabled, onChange]);
18
+ onClick?.(e);
19
+ }, [checked, disabled, onChange, onClick]);
16
20
  const handleKeyDown = useCallback((e) => {
17
- if (disabled)
21
+ if (disabled) {
22
+ onKeyDown?.(e);
18
23
  return;
24
+ }
19
25
  if (e.key === " " || e.key === "Enter") {
20
26
  e.preventDefault();
21
27
  if (onChange) {
22
28
  onChange(!checked);
23
29
  }
24
30
  }
25
- }, [checked, disabled, onChange]);
26
- const handleMouseEnter = useCallback(() => {
27
- if (!disabled) {
28
- setStatus("hovered");
31
+ onKeyDown?.(e);
32
+ }, [checked, disabled, onChange, onKeyDown]);
33
+ const handleMouseEnter = useCallback((e) => {
34
+ if (!disabled && !statusProp) {
35
+ setInternalStatus("hovered");
29
36
  }
30
- }, [disabled]);
31
- const handleMouseLeave = useCallback(() => {
32
- if (!disabled) {
33
- setStatus("default");
37
+ onMouseEnter?.(e);
38
+ }, [disabled, statusProp, onMouseEnter]);
39
+ const handleMouseLeave = useCallback((e) => {
40
+ if (!disabled && !statusProp) {
41
+ setInternalStatus("default");
34
42
  }
35
- }, [disabled]);
36
- const handleFocus = useCallback(() => {
37
- if (!disabled) {
38
- setStatus("focused");
43
+ onMouseLeave?.(e);
44
+ }, [disabled, statusProp, onMouseLeave]);
45
+ const handleFocus = useCallback((e) => {
46
+ if (!disabled && !statusProp) {
47
+ setInternalStatus("focused");
39
48
  }
40
- }, [disabled]);
41
- const handleBlur = useCallback(() => {
42
- if (!disabled) {
43
- setStatus("default");
49
+ onFocus?.(e);
50
+ }, [disabled, statusProp, onFocus]);
51
+ const handleBlur = useCallback((e) => {
52
+ if (!disabled && !statusProp) {
53
+ setInternalStatus("default");
44
54
  }
45
- }, [disabled]);
46
- const handleMouseDown = useCallback(() => {
47
- if (!disabled) {
48
- setStatus("pressed");
55
+ onBlur?.(e);
56
+ }, [disabled, statusProp, onBlur]);
57
+ const handleMouseDown = useCallback((e) => {
58
+ if (!disabled && !statusProp) {
59
+ setInternalStatus("pressed");
49
60
  }
50
- }, [disabled]);
51
- const handleMouseUp = useCallback(() => {
52
- if (!disabled) {
53
- setStatus("hovered");
61
+ onMouseDown?.(e);
62
+ }, [disabled, statusProp, onMouseDown]);
63
+ const handleMouseUp = useCallback((e) => {
64
+ if (!disabled && !statusProp) {
65
+ setInternalStatus("hovered");
54
66
  }
55
- }, [disabled]);
67
+ onMouseUp?.(e);
68
+ }, [disabled, statusProp, onMouseUp]);
56
69
  const currentStatus = disabled ? "disabled" : status;
57
- return (_jsx("button", { type: "button", id: id, role: "switch", "aria-checked": checked, "aria-label": ariaLabel, "aria-disabled": disabled, disabled: disabled, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, style: {
70
+ const isDisabled = disabled;
71
+ const trackStyles = useMemo(() => {
72
+ const baseStyles = {
73
+ display: "flex",
74
+ alignItems: "center",
75
+ padding: "var(--spacing-50)",
76
+ borderRadius: "var(--corner-radius-full)",
77
+ borderWidth: "var(--border-width-25)",
78
+ borderStyle: "solid",
79
+ position: "relative",
80
+ transition: "background-color 0.15s ease, border-color 0.15s ease",
81
+ };
82
+ if (showIcons) {
83
+ // With icons variant
84
+ if (currentStatus === "disabled") {
85
+ return {
86
+ ...baseStyles,
87
+ width: "auto",
88
+ backgroundColor: "var(--bg-page-primary)",
89
+ borderColor: "var(--border-strong-100)",
90
+ justifyContent: "flex-end",
91
+ };
92
+ }
93
+ if (currentStatus === "hovered") {
94
+ return {
95
+ ...baseStyles,
96
+ width: "auto",
97
+ backgroundColor: "var(--bg-page-secondary)",
98
+ borderColor: "var(--border-strong-200)",
99
+ justifyContent: "flex-end",
100
+ };
101
+ }
102
+ if (currentStatus === "focused" || currentStatus === "pressed") {
103
+ return {
104
+ ...baseStyles,
105
+ width: "auto",
106
+ backgroundColor: "var(--bg-page-secondary)",
107
+ borderColor: "var(--border-neutral-primary)",
108
+ justifyContent: "flex-end",
109
+ };
110
+ }
111
+ return {
112
+ ...baseStyles,
113
+ width: "auto",
114
+ backgroundColor: "var(--bg-page-primary)",
115
+ borderColor: "var(--border-strong-200)",
116
+ justifyContent: "flex-end",
117
+ };
118
+ }
119
+ // Default variant (no icons)
120
+ if (currentStatus === "disabled") {
121
+ if (checked) {
122
+ return {
123
+ ...baseStyles,
124
+ width: TRACK_WIDTH,
125
+ backgroundColor: "var(--bg-primary-disabled)",
126
+ borderColor: "var(--border-strong-100)",
127
+ justifyContent: "flex-end",
128
+ };
129
+ }
130
+ else {
131
+ return {
132
+ ...baseStyles,
133
+ width: TRACK_WIDTH,
134
+ backgroundColor: "var(--bg-disabled)",
135
+ borderColor: "var(--border-strong-100)",
136
+ justifyContent: "flex-start",
137
+ };
138
+ }
139
+ }
140
+ if (checked) {
141
+ if (currentStatus === "hovered") {
142
+ return {
143
+ ...baseStyles,
144
+ width: TRACK_WIDTH,
145
+ backgroundColor: "var(--bg-primary-on-hover)",
146
+ borderColor: "var(--border-strong-100)",
147
+ justifyContent: "flex-end",
148
+ };
149
+ }
150
+ if (currentStatus === "focused") {
151
+ return {
152
+ ...baseStyles,
153
+ width: TRACK_WIDTH,
154
+ backgroundColor: "var(--bg-primary-on-focused)",
155
+ borderColor: "var(--border-primary)",
156
+ justifyContent: "flex-end",
157
+ };
158
+ }
159
+ if (currentStatus === "pressed") {
160
+ return {
161
+ ...baseStyles,
162
+ width: TRACK_WIDTH,
163
+ backgroundColor: "var(--bg-primary-pressed)",
164
+ borderColor: "var(--border-primary)",
165
+ justifyContent: "flex-end",
166
+ };
167
+ }
168
+ return {
169
+ ...baseStyles,
170
+ width: TRACK_WIDTH,
171
+ backgroundColor: "var(--bg-primary)",
172
+ borderColor: "var(--border-strong-100)",
173
+ justifyContent: "flex-end",
174
+ };
175
+ }
176
+ else {
177
+ if (currentStatus === "hovered") {
178
+ return {
179
+ ...baseStyles,
180
+ width: TRACK_WIDTH,
181
+ backgroundColor: "var(--bg-page-secondary)",
182
+ borderColor: "var(--border-strong-100)",
183
+ justifyContent: "flex-start",
184
+ };
185
+ }
186
+ if (currentStatus === "focused") {
187
+ return {
188
+ ...baseStyles,
189
+ width: TRACK_WIDTH,
190
+ backgroundColor: "var(--bg-page-secondary)",
191
+ borderColor: "var(--border-neutral-secondary)",
192
+ justifyContent: "flex-start",
193
+ };
194
+ }
195
+ if (currentStatus === "pressed") {
196
+ return {
197
+ ...baseStyles,
198
+ width: TRACK_WIDTH,
199
+ backgroundColor: "var(--bg-page-secondary)",
200
+ borderColor: "var(--border-strong)",
201
+ justifyContent: "flex-start",
202
+ };
203
+ }
204
+ return {
205
+ ...baseStyles,
206
+ width: TRACK_WIDTH,
207
+ backgroundColor: "var(--bg-page-primary)",
208
+ borderColor: "var(--border-strong-100)",
209
+ justifyContent: "flex-start",
210
+ };
211
+ }
212
+ }, [checked, currentStatus, showIcons]);
213
+ const handleStyles = useMemo(() => {
214
+ return {
215
+ width: `${HANDLE_SIZE}px`,
216
+ height: `${HANDLE_SIZE}px`,
217
+ borderRadius: "var(--corner-radius-full)",
218
+ backgroundColor: checked ? "var(--fg-on-action)" : "var(--fg-disabled)",
219
+ flexShrink: 0,
220
+ boxShadow: "var(--shadow-subtle)",
221
+ };
222
+ }, [checked]);
223
+ const nightContainerStyles = useMemo(() => {
224
+ const baseStyles = {
225
+ display: "flex",
226
+ alignItems: "center",
227
+ justifyContent: "center",
228
+ width: `${ICON_CONTAINER_SIZE}px`,
229
+ height: `${ICON_CONTAINER_SIZE}px`,
230
+ borderRadius: "var(--corner-radius-full)",
231
+ flexShrink: 0,
232
+ border: "none",
233
+ };
234
+ if (checked) {
235
+ return {
236
+ ...baseStyles,
237
+ backgroundColor: "transparent",
238
+ };
239
+ }
240
+ else {
241
+ if (currentStatus === "disabled") {
242
+ return {
243
+ ...baseStyles,
244
+ backgroundColor: "var(--bg-page-secondary)",
245
+ };
246
+ }
247
+ if (currentStatus === "pressed") {
248
+ return {
249
+ ...baseStyles,
250
+ backgroundColor: "var(--bg-page-tertiary)",
251
+ };
252
+ }
253
+ return {
254
+ ...baseStyles,
255
+ backgroundColor: "var(--bg-page-tertiary)",
256
+ };
257
+ }
258
+ }, [checked, currentStatus]);
259
+ const dayContainerStyles = useMemo(() => {
260
+ const baseStyles = {
261
+ display: "flex",
262
+ alignItems: "center",
263
+ justifyContent: "center",
264
+ width: `${ICON_CONTAINER_SIZE}px`,
265
+ height: `${ICON_CONTAINER_SIZE}px`,
266
+ borderRadius: "var(--corner-radius-full)",
267
+ flexShrink: 0,
268
+ border: "none",
269
+ };
270
+ if (checked) {
271
+ if (currentStatus === "disabled") {
272
+ return {
273
+ ...baseStyles,
274
+ backgroundColor: "var(--bg-page-secondary)",
275
+ };
276
+ }
277
+ if (currentStatus === "pressed") {
278
+ return {
279
+ ...baseStyles,
280
+ backgroundColor: "var(--bg-page-tertiary)",
281
+ };
282
+ }
283
+ return {
284
+ ...baseStyles,
285
+ backgroundColor: "var(--bg-page-tertiary)",
286
+ };
287
+ }
288
+ else {
289
+ return {
290
+ ...baseStyles,
291
+ backgroundColor: "transparent",
292
+ };
293
+ }
294
+ }, [checked, currentStatus]);
295
+ const nightIconColor = useMemo(() => {
296
+ if (currentStatus === "disabled") {
297
+ return "var(--fg-disabled)";
298
+ }
299
+ if (checked) {
300
+ return "var(--fg-primary)";
301
+ }
302
+ return "var(--fg-neutral)";
303
+ }, [checked, currentStatus]);
304
+ const dayIconColor = useMemo(() => {
305
+ if (currentStatus === "disabled") {
306
+ return "var(--fg-disabled)";
307
+ }
308
+ if (checked) {
309
+ return "var(--fg-neutral)";
310
+ }
311
+ return "var(--fg-warning)";
312
+ }, [checked, currentStatus]);
313
+ const switchElement = showIcons ? (_jsxs("div", { style: trackStyles, children: [_jsx("div", { style: nightContainerStyles, children: _jsx("div", { style: { color: nightIconColor, display: "flex", alignItems: "center", justifyContent: "center" }, children: _jsx(MoonIcon, { size: ICON_SIZE }) }) }), _jsx("div", { style: dayContainerStyles, children: _jsx("div", { style: { color: dayIconColor, display: "flex", alignItems: "center", justifyContent: "center" }, children: _jsx(SunIcon, { size: ICON_SIZE }) }) })] })) : (_jsx("div", { style: trackStyles, children: _jsx("div", { style: handleStyles }) }));
314
+ return (_jsx("button", { ref: ref, type: "button", id: id, role: "switch", "aria-checked": checked, "aria-label": ariaLabel, "aria-disabled": disabled, disabled: disabled, className: className, style: {
58
315
  border: "none",
59
316
  background: "none",
60
317
  padding: 0,
61
318
  cursor: disabled ? "not-allowed" : "pointer",
62
319
  outline: "none",
63
- }, children: _jsx(SwitchPreview, { checked: checked, status: currentStatus, showIcons: showIcons, theme: theme, hue: hue }) }));
320
+ ...style,
321
+ }, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, ...rest, children: switchElement }));
64
322
  }
package/dist/index.d.ts CHANGED
@@ -5,8 +5,18 @@ export { Switch } from "./components/Switch";
5
5
  export { Input } from "./components/Input";
6
6
  export { Avatar } from "./components/Avatar";
7
7
  export { Chip } from "./components/Chip";
8
- export { Menu } from "./components/Menu";
8
+ export { Menu, type MenuItem as MenuItemData } from "./components/Menu";
9
+ export { MenuItem, type MenuItemProps, type MenuItemState } from "./components/MenuItem";
9
10
  export { RadioButton } from "./components/RadioButton";
11
+ export type { ButtonProps, ButtonVariant, ButtonSize, CornerRadiusStep, JustifyContent, ButtonState, ButtonColor } from "./components/Button";
12
+ export type { CardProps, CardType, ProductCardSize, ProductCardStatus, ExperienceCardType, GenericCardStatus } from "./components/Card";
13
+ export type { CheckboxProps, CheckboxStatus } from "./components/Checkbox";
14
+ export type { SwitchProps, SwitchStatus } from "./components/Switch";
15
+ export type { InputProps, InputSize, InputStatus } from "./components/Input";
16
+ export type { AvatarProps, AvatarSize, AvatarType, AvatarColor, AvatarVariant } from "./components/Avatar";
17
+ export type { ChipProps, ChipSize, ChipColor } from "./components/Chip";
18
+ export type { MenuProps } from "./components/Menu";
19
+ export type { RadioButtonProps, RadioButtonStatus } from "./components/RadioButton";
10
20
  export { ThemeProvider, useTheme, useThemeSafe } from "./providers/ThemeProvider";
11
21
  export type { Theme, HueVariant } from "./tokens/types";
12
22
  export type { ColorPrimitive, SemanticColor, SpacingToken, BackgroundToken, ForegroundToken, BorderToken, } from "./tokens/types";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlF,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,EACf,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9I,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxI,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC3E,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3G,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlF,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,EACf,WAAW,GACZ,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export { Input } from "./components/Input";
7
7
  export { Avatar } from "./components/Avatar";
8
8
  export { Chip } from "./components/Chip";
9
9
  export { Menu } from "./components/Menu";
10
+ export { MenuItem } from "./components/MenuItem";
10
11
  export { RadioButton } from "./components/RadioButton";
11
12
  // Providers
12
13
  export { ThemeProvider, useTheme, useThemeSafe } from "./providers/ThemeProvider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beacon-ui",
3
- "version": "3.1.5",
3
+ "version": "3.1.8",
4
4
  "description": "Beacon Design System - Components and tokens",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",