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.
- package/CHANGELOG.md +31 -0
- package/README.md +407 -16
- package/dist/components/Avatar.d.ts +13 -16
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +6 -4
- package/dist/components/Button.d.ts +21 -19
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +100 -80
- package/dist/components/Card.d.ts +8 -11
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +5 -3
- package/dist/components/Checkbox.d.ts +5 -6
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +191 -38
- package/dist/components/Chip.d.ts +6 -9
- package/dist/components/Chip.d.ts.map +1 -1
- package/dist/components/Chip.js +6 -5
- package/dist/components/Input.d.ts +10 -15
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +22 -21
- package/dist/components/Menu.d.ts +9 -6
- package/dist/components/Menu.d.ts.map +1 -1
- package/dist/components/Menu.js +63 -31
- package/dist/components/MenuItem.d.ts +13 -0
- package/dist/components/MenuItem.d.ts.map +1 -0
- package/dist/components/MenuItem.js +90 -0
- package/dist/components/RadioButton.d.ts +6 -8
- package/dist/components/RadioButton.d.ts.map +1 -1
- package/dist/components/RadioButton.js +68 -16
- package/dist/components/Switch.d.ts +5 -6
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +296 -38
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../src/components/Chip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../src/components/Chip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnF,MAAM,WAAW,SAAU,SAAQ,qBAAqB,CAAC,KAAK,CAAC;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAsED,wBAAgB,IAAI,CAAC,EACnB,KAAoB,EACpB,KAAiB,EACjB,IAAW,EACX,WAAmB,EACnB,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,IAAI,EACR,EAAE,SAAS,2CA2DX"}
|
package/dist/components/Chip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
5
5
|
const SIZE_CONFIG = {
|
|
6
6
|
sm: {
|
|
7
7
|
iconSize: 16,
|
|
@@ -52,7 +52,8 @@ const COLOR_CONFIG = {
|
|
|
52
52
|
border: "var(--border-warning)",
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
|
-
export function Chip({ label = "Identifier", color = "primary", size = "md", showBorders = false,
|
|
55
|
+
export function Chip({ label = "Identifier", color = "primary", size = "md", showBorders = false, icon, className, style, children, ref, ...rest }) {
|
|
56
|
+
useThemeSafe(); // Ensure theme context is available
|
|
56
57
|
const sizeConfig = SIZE_CONFIG[size];
|
|
57
58
|
const colorConfig = COLOR_CONFIG[color];
|
|
58
59
|
const chipStyles = useMemo(() => {
|
|
@@ -79,8 +80,8 @@ export function Chip({ label = "Identifier", color = "primary", size = "md", sho
|
|
|
79
80
|
borderColor: colorConfig.border,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
return baseStyles;
|
|
83
|
-
}, [colorConfig, sizeConfig, showBorders]);
|
|
83
|
+
return { ...baseStyles, ...style };
|
|
84
|
+
}, [colorConfig, sizeConfig, showBorders, style]);
|
|
84
85
|
const iconWrapperStyles = useMemo(() => {
|
|
85
86
|
return {
|
|
86
87
|
display: "flex",
|
|
@@ -95,5 +96,5 @@ export function Chip({ label = "Identifier", color = "primary", size = "md", sho
|
|
|
95
96
|
color: colorConfig.fg,
|
|
96
97
|
};
|
|
97
98
|
}, [sizeConfig.iconSize, colorConfig.fg]);
|
|
98
|
-
return (_jsxs("div", { style: chipStyles, children: [
|
|
99
|
+
return (_jsxs("div", { ref: ref, className: className, style: chipStyles, ...rest, children: [icon && (_jsx("div", { style: iconWrapperStyles, children: icon })), children || _jsx("span", { children: label })] }));
|
|
99
100
|
}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
type InputSize = "sm" | "md" | "lg";
|
|
3
|
-
type InputStatus = "default" | "active";
|
|
4
|
-
interface InputProps {
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type InputSize = "sm" | "md" | "lg";
|
|
3
|
+
export type InputStatus = "default" | "active";
|
|
4
|
+
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size"> {
|
|
5
5
|
label?: string;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
value?: string;
|
|
8
6
|
size?: InputSize;
|
|
9
7
|
status?: InputStatus;
|
|
10
8
|
showLabel?: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
startIcon?: React.ReactNode;
|
|
10
|
+
endIcon?: React.ReactNode;
|
|
11
|
+
placeholderIcon?: React.ReactNode;
|
|
14
12
|
showError?: boolean;
|
|
15
|
-
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
numberPrefix?: string;
|
|
16
15
|
rounded?: boolean;
|
|
17
16
|
iconOnly?: boolean;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
theme?: Theme;
|
|
20
|
-
hue?: HueVariant;
|
|
21
17
|
}
|
|
22
|
-
export declare function Input({ label,
|
|
23
|
-
export {};
|
|
18
|
+
export declare function Input({ label, size, status, showLabel, startIcon, endIcon, placeholderIcon, showError, errorMessage, numberPrefix, rounded, iconOnly, disabled, className, style, value, placeholder, ref, ...rest }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
24
19
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/C,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuDD,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,IAAW,EACX,MAAkB,EAClB,SAAgB,EAChB,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAiB,EACjB,YAA+B,EAC/B,YAAY,EACZ,OAAe,EACf,QAAgB,EAChB,QAAgB,EAChB,SAAS,EACT,KAAK,EACL,KAAK,EACL,WAAW,EACX,GAAG,EACH,GAAG,IAAI,EACR,EAAE,UAAU,2CAuKZ"}
|
package/dist/components/Input.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
5
|
+
import { AlertTriangleErrorIcon } from "../icons";
|
|
5
6
|
const SIZE_CONFIG = {
|
|
6
7
|
sm: {
|
|
7
8
|
height: "28px",
|
|
@@ -40,9 +41,10 @@ const SIZE_CONFIG = {
|
|
|
40
41
|
gap: "var(--spacing-200)",
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
|
-
export function Input({ label
|
|
44
|
+
export function Input({ label, size = "md", status = "default", showLabel = true, startIcon, endIcon, placeholderIcon, showError = false, errorMessage = "Error message!", numberPrefix, rounded = false, iconOnly = false, disabled = false, className, style, value, placeholder, ref, ...rest }) {
|
|
45
|
+
useThemeSafe(); // Ensure theme context is available
|
|
44
46
|
const sizeConfig = SIZE_CONFIG[size];
|
|
45
|
-
const hasValue = value.length > 0;
|
|
47
|
+
const hasValue = value != null && String(value).length > 0;
|
|
46
48
|
const borderColor = useMemo(() => {
|
|
47
49
|
if (disabled) {
|
|
48
50
|
return "var(--border-strong-100)";
|
|
@@ -72,22 +74,6 @@ export function Input({ label = "Label", placeholder = "Placeholder", value = ""
|
|
|
72
74
|
};
|
|
73
75
|
return baseStyles;
|
|
74
76
|
}, [sizeConfig, borderColor, rounded, iconOnly, disabled]);
|
|
75
|
-
const textStyles = useMemo(() => {
|
|
76
|
-
return {
|
|
77
|
-
fontSize: sizeConfig.fontSize,
|
|
78
|
-
lineHeight: sizeConfig.lineHeight,
|
|
79
|
-
fontFamily: "var(--font-secondary)",
|
|
80
|
-
color: hasValue
|
|
81
|
-
? "var(--fg-neutral-secondary)"
|
|
82
|
-
: disabled
|
|
83
|
-
? "var(--fg-disabled)"
|
|
84
|
-
: "var(--fg-disabled)",
|
|
85
|
-
fontWeight: hasValue ? 500 : 400,
|
|
86
|
-
flex: iconOnly ? "none" : "1 0 0",
|
|
87
|
-
minWidth: iconOnly ? "auto" : 0,
|
|
88
|
-
minHeight: iconOnly ? "auto" : 0,
|
|
89
|
-
};
|
|
90
|
-
}, [sizeConfig, hasValue, disabled, iconOnly]);
|
|
91
77
|
const labelStyles = useMemo(() => {
|
|
92
78
|
return {
|
|
93
79
|
fontSize: sizeConfig.labelFontSize,
|
|
@@ -131,8 +117,23 @@ export function Input({ label = "Label", placeholder = "Placeholder", value = ""
|
|
|
131
117
|
color: "var(--fg-critical)",
|
|
132
118
|
};
|
|
133
119
|
}, []);
|
|
120
|
+
const inputStyles = {
|
|
121
|
+
fontSize: sizeConfig.fontSize,
|
|
122
|
+
lineHeight: sizeConfig.lineHeight,
|
|
123
|
+
fontFamily: "var(--font-secondary)",
|
|
124
|
+
color: hasValue ? "var(--fg-neutral-secondary)" : disabled ? "var(--fg-disabled)" : "var(--fg-disabled)",
|
|
125
|
+
fontWeight: hasValue ? 500 : 400,
|
|
126
|
+
flex: iconOnly ? "none" : "1 0 0",
|
|
127
|
+
minWidth: iconOnly ? "auto" : 0,
|
|
128
|
+
minHeight: iconOnly ? "auto" : 0,
|
|
129
|
+
border: "none",
|
|
130
|
+
background: "transparent",
|
|
131
|
+
outline: "none",
|
|
132
|
+
padding: 0,
|
|
133
|
+
width: "100%",
|
|
134
|
+
};
|
|
134
135
|
if (iconOnly) {
|
|
135
|
-
return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: "100%" }, children: _jsxs("div", { style: inputContainerStyles, children: [
|
|
136
|
+
return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: "100%" }, children: _jsxs("div", { style: inputContainerStyles, children: [placeholderIcon && (_jsx("div", { style: { color: "var(--fg-neutral)", display: "flex", alignItems: "center", justifyContent: "center" }, children: placeholderIcon })), startIcon && !placeholderIcon && (_jsx("div", { style: { color: "var(--fg-neutral)", display: "flex", alignItems: "center", justifyContent: "center" }, children: startIcon }))] }) }));
|
|
136
137
|
}
|
|
137
|
-
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: "100%" }, children: [showLabel && (_jsx("
|
|
138
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: "100%" }, children: [showLabel && label && (_jsx("label", { htmlFor: rest.id, style: labelStyles, children: label })), _jsxs("div", { style: inputContainerStyles, children: [startIcon && (_jsx("div", { style: { color: "var(--fg-neutral)", flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: startIcon })), placeholderIcon && !hasValue && (_jsx("div", { style: { color: iconOnly ? "var(--fg-neutral)" : "var(--fg-disabled)", flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: placeholderIcon })), numberPrefix && (_jsx("div", { style: prefixStyles, children: numberPrefix })), _jsx("input", { ref: ref, type: "text", value: value, placeholder: placeholder, disabled: disabled, className: className, style: { ...inputStyles, ...style }, ...rest }), endIcon && (_jsx("div", { style: { color: "var(--fg-neutral-tertiary)", flexShrink: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: endIcon }))] }), showError && (_jsxs("div", { style: errorContainerStyles, children: [_jsx("div", { style: { ...errorIconStyles, display: "flex", alignItems: "center", justifyContent: "center" }, children: _jsx(AlertTriangleErrorIcon, { size: 16 }) }), _jsx("p", { style: errorMessageStyles, children: errorMessage })] }))] }));
|
|
138
139
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
2
|
type MenuVariant = "desktop" | "tablet-open" | "tablet-closed" | "mobile-open" | "mobile-closed" | "close-menu";
|
|
3
|
-
interface MenuItem {
|
|
3
|
+
export interface MenuItem {
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
onClick?: (item: MenuItem) => void;
|
|
6
9
|
}
|
|
7
|
-
interface MenuProps {
|
|
10
|
+
export interface MenuProps extends ComponentPropsWithRef<"div"> {
|
|
8
11
|
variant?: MenuVariant;
|
|
9
12
|
showMenu?: boolean;
|
|
10
13
|
showButton?: boolean;
|
|
@@ -13,9 +16,9 @@ interface MenuProps {
|
|
|
13
16
|
headerSubtitle?: string;
|
|
14
17
|
showChevrons?: boolean;
|
|
15
18
|
avatarImageUrl?: string;
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
selectedItemId?: string;
|
|
20
|
+
onItemClick?: (item: MenuItem) => void;
|
|
18
21
|
}
|
|
19
|
-
export declare function Menu({ variant, showMenu, showButton, menuItems, headerTitle, headerSubtitle, showChevrons, avatarImageUrl,
|
|
22
|
+
export declare function Menu({ variant, showMenu, showButton, menuItems, headerTitle, headerSubtitle, showChevrons, avatarImageUrl, selectedItemId, onItemClick, className, style, ref, ...rest }: MenuProps): import("react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
21
24
|
//# sourceMappingURL=Menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/components/Menu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/components/Menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,qBAAqB,EAAY,SAAS,EAAE,MAAM,OAAO,CAAC;AAM5E,KAAK,WAAW,GAAG,SAAS,GAAG,aAAa,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe,GAAG,YAAY,CAAC;AAEhH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,SAAU,SAAQ,qBAAqB,CAAC,KAAK,CAAC;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACxC;AAUD,wBAAgB,IAAI,CAAC,EACnB,OAAmB,EACnB,QAAe,EACf,UAAiB,EACjB,SAA8B,EAC9B,WAAqB,EACrB,cAA2B,EAC3B,YAAmB,EACnB,cAAc,EACd,cAAc,EACd,WAAW,EACX,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,SAAS,2CA2aX"}
|
package/dist/components/Menu.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import {
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { CloseIcon, MenuIcon, DownloadIcon } from "../icons";
|
|
5
5
|
import { Switch } from "./Switch";
|
|
6
6
|
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
7
|
+
import { MenuItem as MenuItemComponent } from "./MenuItem";
|
|
7
8
|
const DEFAULT_MENU_ITEMS = [
|
|
8
9
|
{ id: "1", label: "Menu Item #1" },
|
|
9
10
|
{ id: "2", label: "Menu Item #2" },
|
|
@@ -11,10 +12,10 @@ const DEFAULT_MENU_ITEMS = [
|
|
|
11
12
|
{ id: "4", label: "Menu Item #4" },
|
|
12
13
|
{ id: "5", label: "Menu Item #5" },
|
|
13
14
|
];
|
|
14
|
-
export function Menu({ variant = "desktop", showMenu = true, showButton = true, menuItems = DEFAULT_MENU_ITEMS, headerTitle = "Title", headerSubtitle = "Subtitle", showChevrons = true, avatarImageUrl,
|
|
15
|
+
export function Menu({ variant = "desktop", showMenu = true, showButton = true, menuItems = DEFAULT_MENU_ITEMS, headerTitle = "Title", headerSubtitle = "Subtitle", showChevrons = true, avatarImageUrl, selectedItemId, onItemClick, className, style, ref, ...rest }) {
|
|
15
16
|
const themeContext = useThemeSafe();
|
|
16
|
-
const theme =
|
|
17
|
-
const
|
|
17
|
+
const theme = themeContext?.theme ?? "dark";
|
|
18
|
+
const [hoveredItemId, setHoveredItemId] = useState(null);
|
|
18
19
|
const containerStyles = useMemo(() => {
|
|
19
20
|
const baseStyles = {
|
|
20
21
|
display: "flex",
|
|
@@ -30,7 +31,7 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
30
31
|
return {
|
|
31
32
|
...baseStyles,
|
|
32
33
|
width: "240px",
|
|
33
|
-
height: "
|
|
34
|
+
height: "100%",
|
|
34
35
|
borderLeft: "none",
|
|
35
36
|
borderTop: "none",
|
|
36
37
|
borderBottom: "none",
|
|
@@ -112,17 +113,6 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
112
113
|
overflow: "hidden",
|
|
113
114
|
};
|
|
114
115
|
}, []);
|
|
115
|
-
const menuItemStyles = useMemo(() => {
|
|
116
|
-
return {
|
|
117
|
-
display: "flex",
|
|
118
|
-
gap: "var(--spacing-200)",
|
|
119
|
-
alignItems: "center",
|
|
120
|
-
padding: "var(--spacing-200) var(--spacing-200)",
|
|
121
|
-
borderRadius: "var(--corner-radius-200)",
|
|
122
|
-
backgroundColor: "var(--bg-page-primary)",
|
|
123
|
-
width: "100%",
|
|
124
|
-
};
|
|
125
|
-
}, []);
|
|
126
116
|
const buttonStyles = useMemo(() => {
|
|
127
117
|
return {
|
|
128
118
|
display: "flex",
|
|
@@ -188,7 +178,7 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
188
178
|
};
|
|
189
179
|
}, []);
|
|
190
180
|
if (variant === "close-menu") {
|
|
191
|
-
return (_jsx("div", { style: containerStyles, children: _jsx("button", { style: iconButtonStyles, children: _jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px" }, children: _jsx(CloseIcon, { size: 32 }) }) }) }));
|
|
181
|
+
return (_jsx("div", { ref: ref, className: className, style: { ...containerStyles, ...style }, ...rest, children: _jsx("button", { style: iconButtonStyles, children: _jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px" }, children: _jsx(CloseIcon, { size: 32 }) }) }) }));
|
|
192
182
|
}
|
|
193
183
|
const isDesktop = variant === "desktop";
|
|
194
184
|
const isTabletOpen = variant === "tablet-open";
|
|
@@ -197,12 +187,27 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
197
187
|
const isMobileClosed = variant === "mobile-closed";
|
|
198
188
|
const showMenuItems = (isDesktop || isTabletOpen || isMobileOpen) && showMenu;
|
|
199
189
|
const showHeaderContent = isDesktop || isTabletOpen || isTabletClosed;
|
|
200
|
-
return (_jsxs("div", { style: containerStyles, children: [isDesktop ? (_jsx(_Fragment, { children: _jsxs("div", { style: headerStyles, children: [_jsx("div", { style: avatarStyles, children:
|
|
190
|
+
return (_jsxs("div", { ref: ref, className: className, style: { ...containerStyles, ...style }, ...rest, children: [isDesktop ? (_jsx(_Fragment, { children: _jsxs("div", { style: headerStyles, children: [_jsx("div", { style: avatarStyles, children: _jsx("img", { src: avatarImageUrl || "/images/avatars/avatar-female.png", alt: "User avatar", style: {
|
|
201
191
|
width: "100%",
|
|
202
192
|
height: "100%",
|
|
203
193
|
objectFit: "cover",
|
|
204
194
|
objectPosition: "center",
|
|
205
|
-
}
|
|
195
|
+
}, onError: (e) => {
|
|
196
|
+
// Fallback to icon if image fails to load
|
|
197
|
+
const target = e.target;
|
|
198
|
+
target.style.display = "none";
|
|
199
|
+
const iconContainer = target.parentElement;
|
|
200
|
+
if (iconContainer && !iconContainer.querySelector("svg")) {
|
|
201
|
+
const iconWrapper = document.createElement("div");
|
|
202
|
+
iconWrapper.style.display = "flex";
|
|
203
|
+
iconWrapper.style.alignItems = "center";
|
|
204
|
+
iconWrapper.style.justifyContent = "center";
|
|
205
|
+
iconWrapper.style.width = "100%";
|
|
206
|
+
iconWrapper.style.height = "100%";
|
|
207
|
+
iconWrapper.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z" fill="var(--fg-neutral)"/></svg>`;
|
|
208
|
+
iconContainer.appendChild(iconWrapper);
|
|
209
|
+
}
|
|
210
|
+
} }) }), showHeaderContent && (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-none)", flex: 1 }, children: [_jsx("p", { style: {
|
|
206
211
|
fontFamily: "var(--font-secondary)",
|
|
207
212
|
fontSize: "var(--body-small-text-size)",
|
|
208
213
|
lineHeight: "var(--body-small-line-height)",
|
|
@@ -218,12 +223,27 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
218
223
|
margin: 0,
|
|
219
224
|
}, children: headerSubtitle })] }))] }) })) : (
|
|
220
225
|
/* Tablet/Mobile: Header and Footer in single row */
|
|
221
|
-
_jsxs("div", { style: mainRowStyles, children: [_jsxs("div", { style: headerStyles, children: [_jsx("div", { style: avatarStyles, children:
|
|
226
|
+
_jsxs("div", { style: mainRowStyles, children: [_jsxs("div", { style: headerStyles, children: [_jsx("div", { style: avatarStyles, children: _jsx("img", { src: avatarImageUrl || "/images/avatars/avatar-female.png", alt: "User avatar", style: {
|
|
222
227
|
width: "100%",
|
|
223
228
|
height: "100%",
|
|
224
229
|
objectFit: "cover",
|
|
225
230
|
objectPosition: "center",
|
|
226
|
-
}
|
|
231
|
+
}, onError: (e) => {
|
|
232
|
+
// Fallback to icon if image fails to load
|
|
233
|
+
const target = e.target;
|
|
234
|
+
target.style.display = "none";
|
|
235
|
+
const iconContainer = target.parentElement;
|
|
236
|
+
if (iconContainer && !iconContainer.querySelector("svg")) {
|
|
237
|
+
const iconWrapper = document.createElement("div");
|
|
238
|
+
iconWrapper.style.display = "flex";
|
|
239
|
+
iconWrapper.style.alignItems = "center";
|
|
240
|
+
iconWrapper.style.justifyContent = "center";
|
|
241
|
+
iconWrapper.style.width = "100%";
|
|
242
|
+
iconWrapper.style.height = "100%";
|
|
243
|
+
iconWrapper.innerHTML = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z" fill="var(--fg-neutral)"/></svg>`;
|
|
244
|
+
iconContainer.appendChild(iconWrapper);
|
|
245
|
+
}
|
|
246
|
+
} }) }), showHeaderContent && (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-none)", flex: 1 }, children: [_jsx("p", { style: {
|
|
227
247
|
fontFamily: "var(--font-secondary)",
|
|
228
248
|
fontSize: "var(--body-small-text-size)",
|
|
229
249
|
lineHeight: "var(--body-small-line-height)",
|
|
@@ -244,13 +264,25 @@ export function Menu({ variant = "desktop", showMenu = true, showButton = true,
|
|
|
244
264
|
padding: isDesktop ? "var(--spacing-600) 0" : "var(--spacing-400) var(--spacing-200)",
|
|
245
265
|
width: "100%",
|
|
246
266
|
flex: isDesktop ? 1 : undefined,
|
|
247
|
-
}, children: menuItems.map((item) =>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
267
|
+
}, children: menuItems.map((item) => {
|
|
268
|
+
const isSelected = selectedItemId === item.id || item.selected === true;
|
|
269
|
+
const isHovered = hoveredItemId === item.id;
|
|
270
|
+
const handleClick = () => {
|
|
271
|
+
if (item.onClick) {
|
|
272
|
+
item.onClick(item);
|
|
273
|
+
}
|
|
274
|
+
if (onItemClick) {
|
|
275
|
+
onItemClick(item);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const handleMouseEnter = () => {
|
|
279
|
+
setHoveredItemId(item.id);
|
|
280
|
+
};
|
|
281
|
+
const handleMouseLeave = () => {
|
|
282
|
+
setHoveredItemId(null);
|
|
283
|
+
};
|
|
284
|
+
// Determine state for MenuItem component
|
|
285
|
+
const itemState = isSelected ? "Active" : isHovered ? "Hovered" : "Default";
|
|
286
|
+
return (_jsx(MenuItemComponent, { menuTitle: item.label, iconStart: true, iconStart1: item.icon || null, iconEnd: showChevrons, iconEnd1: null, state: itemState, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, item.id));
|
|
287
|
+
}) })), isDesktop && (_jsxs(_Fragment, { children: [showButton && (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-400)", padding: "var(--spacing-400)", width: "100%" }, children: _jsxs("div", { style: buttonStyles, children: [_jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "16px", height: "16px" }, children: _jsx(DownloadIcon, { size: 16 }) }), _jsx("span", { children: "Button" })] }) })), _jsx("div", { style: footerStyles, children: _jsx(Switch, { checked: theme === "dark", showIcons: true }) })] }))] }));
|
|
256
288
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
export type MenuItemState = "Default" | "Hovered" | "Active" | "Disabled";
|
|
3
|
+
export interface MenuItemProps extends Omit<ComponentPropsWithRef<"button">, "onClick"> {
|
|
4
|
+
menuTitle?: string;
|
|
5
|
+
iconStart?: boolean;
|
|
6
|
+
iconStart1?: ReactNode | null;
|
|
7
|
+
iconEnd?: boolean;
|
|
8
|
+
iconEnd1?: ReactNode | null;
|
|
9
|
+
state?: MenuItemState;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function MenuItem({ menuTitle, iconStart, iconStart1, iconEnd, iconEnd1, state, onClick, className, style, ...rest }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=MenuItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../src/components/MenuItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE1E,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,QAAQ,CAAC,EACvB,SAAuB,EACvB,SAAgB,EAChB,UAAiB,EACjB,OAAc,EACd,QAAe,EACf,KAAiB,EACjB,OAAO,EACP,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,aAAa,2CAiIf"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { UserPersonIcon, ChevronRightIcon } from "../icons";
|
|
4
|
+
export function MenuItem({ menuTitle = "Menu Item", iconStart = true, iconStart1 = null, iconEnd = true, iconEnd1 = null, state = "Default", onClick, className, style, ...rest }) {
|
|
5
|
+
const isActive = state === "Active";
|
|
6
|
+
const isDisabled = state === "Disabled";
|
|
7
|
+
const isHovered = state === "Hovered";
|
|
8
|
+
const isDefault = state === "Default";
|
|
9
|
+
// Background colors based on state
|
|
10
|
+
const backgroundColor = isActive
|
|
11
|
+
? "var(--bg-primary-tonal)"
|
|
12
|
+
: isHovered
|
|
13
|
+
? "var(--bg-page-secondary)"
|
|
14
|
+
: isDisabled
|
|
15
|
+
? "var(--bg-page-primary)"
|
|
16
|
+
: "var(--bg-page-primary)";
|
|
17
|
+
// Text colors based on state
|
|
18
|
+
const textColor = isActive
|
|
19
|
+
? "var(--fg-primary-on-tonal)"
|
|
20
|
+
: isDisabled
|
|
21
|
+
? "var(--fg-on-disabled)"
|
|
22
|
+
: isHovered
|
|
23
|
+
? "var(--fg-neutral)"
|
|
24
|
+
: "var(--fg-neutral-secondary)";
|
|
25
|
+
// Icon colors based on state
|
|
26
|
+
const iconColor = isActive
|
|
27
|
+
? "var(--fg-primary-on-tonal)"
|
|
28
|
+
: isDisabled
|
|
29
|
+
? "var(--fg-on-disabled)"
|
|
30
|
+
: isHovered
|
|
31
|
+
? "var(--fg-neutral)"
|
|
32
|
+
: "var(--fg-neutral-secondary)";
|
|
33
|
+
// Chevron colors based on state
|
|
34
|
+
const chevronColor = isActive
|
|
35
|
+
? "var(--fg-primary-on-tonal)"
|
|
36
|
+
: isDisabled
|
|
37
|
+
? "var(--fg-on-disabled)"
|
|
38
|
+
: "var(--fg-neutral)";
|
|
39
|
+
// Border for disabled state
|
|
40
|
+
const borderStyle = isDisabled
|
|
41
|
+
? "var(--border-width-25) solid var(--border-neutral-tertiary)"
|
|
42
|
+
: "none";
|
|
43
|
+
const containerStyles = {
|
|
44
|
+
display: "flex",
|
|
45
|
+
gap: "var(--spacing-200)",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
padding: "var(--spacing-200) var(--spacing-200)",
|
|
48
|
+
borderRadius: "var(--corner-radius-200)",
|
|
49
|
+
width: "100%",
|
|
50
|
+
backgroundColor,
|
|
51
|
+
border: borderStyle,
|
|
52
|
+
cursor: isDisabled ? "not-allowed" : onClick ? "pointer" : "default",
|
|
53
|
+
transition: "background-color 0.2s ease, border-color 0.2s ease",
|
|
54
|
+
...style,
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs("button", { type: "button", className: className, style: containerStyles, onClick: isDisabled ? undefined : onClick, disabled: isDisabled, ...rest, children: [iconStart && (_jsx("div", { style: {
|
|
57
|
+
display: "flex",
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
width: "20px",
|
|
61
|
+
height: "20px",
|
|
62
|
+
flexShrink: 0,
|
|
63
|
+
color: iconColor,
|
|
64
|
+
}, children: iconStart1 || _jsx(UserPersonIcon, { size: 20 }) })), _jsx("p", { style: {
|
|
65
|
+
fontFamily: "var(--font-secondary)",
|
|
66
|
+
fontSize: "var(--body-small-text-size)",
|
|
67
|
+
lineHeight: "var(--body-small-line-height)",
|
|
68
|
+
fontWeight: isActive ? "var(--font-weight-secondary-semibold)" : "var(--font-weight-secondary-medium)",
|
|
69
|
+
color: textColor,
|
|
70
|
+
margin: 0,
|
|
71
|
+
flex: 1,
|
|
72
|
+
textAlign: "left",
|
|
73
|
+
}, children: menuTitle }), iconEnd && !isDisabled && (_jsx("div", { style: {
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
width: "16px",
|
|
78
|
+
height: "16px",
|
|
79
|
+
flexShrink: 0,
|
|
80
|
+
color: chevronColor,
|
|
81
|
+
}, children: iconEnd1 || _jsx(ChevronRightIcon, { size: 16 }) })), iconEnd && isDisabled && (_jsx("div", { style: {
|
|
82
|
+
display: "flex",
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
justifyContent: "center",
|
|
85
|
+
width: "16px",
|
|
86
|
+
height: "16px",
|
|
87
|
+
flexShrink: 0,
|
|
88
|
+
color: chevronColor,
|
|
89
|
+
}, children: iconEnd1 || _jsx(ChevronRightIcon, { size: 16 }) }))] }));
|
|
90
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
type RadioButtonStatus = "default" | "hovered" | "focused" | "pressed" | "disabled";
|
|
3
|
-
interface RadioButtonProps {
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type RadioButtonStatus = "default" | "hovered" | "focused" | "pressed" | "disabled";
|
|
3
|
+
export interface RadioButtonProps extends Omit<ComponentPropsWithRef<"input">, "type" | "onChange"> {
|
|
4
4
|
selected?: boolean;
|
|
5
|
-
|
|
5
|
+
onChange?: (selected: boolean) => void;
|
|
6
6
|
label?: string;
|
|
7
7
|
showLabel?: boolean;
|
|
8
|
-
|
|
9
|
-
hue?: HueVariant;
|
|
8
|
+
status?: RadioButtonStatus;
|
|
10
9
|
}
|
|
11
|
-
export declare function RadioButton({ selected,
|
|
12
|
-
export {};
|
|
10
|
+
export declare function RadioButton({ selected, onChange, disabled, id, label, showLabel, status: statusProp, className, style, onClick, onFocus, onBlur, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, ref, ...rest }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
13
11
|
//# sourceMappingURL=RadioButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../src/components/RadioButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../src/components/RadioButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAG9E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAE3F,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAID,wBAAgB,WAAW,CAAC,EAC1B,QAAgB,EAChB,QAAQ,EACR,QAAgB,EAChB,EAAE,EACF,KAAsB,EACtB,SAAgB,EAChB,MAAM,EAAE,UAAU,EAClB,SAAS,EACT,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,gBAAgB,2CA4PlB"}
|