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,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState, useCallback } from "react";
|
|
4
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
5
|
+
import { LoaderIcon } from "../icons";
|
|
5
6
|
const CORNER_RADIUS_MAP = {
|
|
6
7
|
0: "var(--corner-radius-none)",
|
|
7
8
|
1: "var(--corner-radius-100)",
|
|
@@ -54,9 +55,51 @@ const LOADER_ICON_SIZE_MAP = {
|
|
|
54
55
|
lg: 32,
|
|
55
56
|
xl: 40,
|
|
56
57
|
};
|
|
57
|
-
export function Button({ variant, size, cornerRadius,
|
|
58
|
+
export function Button({ variant = "filled", size = "md", cornerRadius = 2, startIcon, endIcon, fillContainer = false, justifyContent = "center", loading = false, disabled = false, state: stateProp, color = "primary", type = "button", children, className, style, onClick, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }) {
|
|
59
|
+
const themeContext = useThemeSafe();
|
|
58
60
|
const sizeConfig = SIZE_CONFIG[size];
|
|
59
61
|
const borderRadius = CORNER_RADIUS_MAP[cornerRadius];
|
|
62
|
+
const [internalState, setInternalState] = useState("default");
|
|
63
|
+
const state = stateProp ?? internalState;
|
|
64
|
+
const handleMouseEnter = useCallback((e) => {
|
|
65
|
+
if (!disabled && !loading && !stateProp) {
|
|
66
|
+
setInternalState("hovered");
|
|
67
|
+
}
|
|
68
|
+
onMouseEnter?.(e);
|
|
69
|
+
}, [disabled, loading, stateProp, onMouseEnter]);
|
|
70
|
+
const handleMouseLeave = useCallback((e) => {
|
|
71
|
+
if (!disabled && !loading && !stateProp) {
|
|
72
|
+
setInternalState("default");
|
|
73
|
+
}
|
|
74
|
+
onMouseLeave?.(e);
|
|
75
|
+
}, [disabled, loading, stateProp, onMouseLeave]);
|
|
76
|
+
const handleFocus = useCallback((e) => {
|
|
77
|
+
if (!disabled && !loading && !stateProp) {
|
|
78
|
+
setInternalState("focused");
|
|
79
|
+
}
|
|
80
|
+
onFocus?.(e);
|
|
81
|
+
}, [disabled, loading, stateProp, onFocus]);
|
|
82
|
+
const handleBlur = useCallback((e) => {
|
|
83
|
+
if (!disabled && !loading && !stateProp) {
|
|
84
|
+
setInternalState("default");
|
|
85
|
+
}
|
|
86
|
+
onBlur?.(e);
|
|
87
|
+
}, [disabled, loading, stateProp, onBlur]);
|
|
88
|
+
const handleMouseDown = useCallback((e) => {
|
|
89
|
+
if (!disabled && !loading && !stateProp) {
|
|
90
|
+
setInternalState("pressed");
|
|
91
|
+
}
|
|
92
|
+
onMouseDown?.(e);
|
|
93
|
+
}, [disabled, loading, stateProp, onMouseDown]);
|
|
94
|
+
const handleMouseUp = useCallback((e) => {
|
|
95
|
+
if (!disabled && !loading && !stateProp) {
|
|
96
|
+
setInternalState("hovered");
|
|
97
|
+
}
|
|
98
|
+
onMouseUp?.(e);
|
|
99
|
+
}, [disabled, loading, stateProp, onMouseUp]);
|
|
100
|
+
const isDisabled = disabled;
|
|
101
|
+
const isLoading = loading;
|
|
102
|
+
const currentState = isDisabled ? "default" : state;
|
|
60
103
|
const buttonStyles = useMemo(() => {
|
|
61
104
|
const baseStyles = {
|
|
62
105
|
display: "inline-flex",
|
|
@@ -71,7 +114,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
|
|
|
71
114
|
borderStyle: "solid",
|
|
72
115
|
borderColor: "transparent",
|
|
73
116
|
borderRadius,
|
|
74
|
-
cursor:
|
|
117
|
+
cursor: (isDisabled || isLoading) ? "not-allowed" : "pointer",
|
|
75
118
|
transition: "background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease",
|
|
76
119
|
minHeight: sizeConfig.height,
|
|
77
120
|
paddingLeft: sizeConfig.paddingX,
|
|
@@ -79,36 +122,51 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
|
|
|
79
122
|
paddingTop: sizeConfig.paddingY,
|
|
80
123
|
paddingBottom: sizeConfig.paddingY,
|
|
81
124
|
width: fillContainer ? "100%" : "auto",
|
|
82
|
-
opacity:
|
|
125
|
+
opacity: isDisabled ? 0.6 : 1,
|
|
83
126
|
};
|
|
127
|
+
// Get color token prefixes based on color prop
|
|
128
|
+
const colorPrefix = color === "primary" ? "primary" : color;
|
|
129
|
+
const bgToken = `--bg-${colorPrefix}`;
|
|
130
|
+
const bgTonalToken = `--bg-${colorPrefix}-tonal`;
|
|
131
|
+
const bgHoverToken = `--bg-${colorPrefix}-on-hover`;
|
|
132
|
+
const bgPressedToken = color === "primary" ? `--bg-${colorPrefix}-pressed` : `--bg-${colorPrefix}-on-hover`;
|
|
133
|
+
const bgFocusedToken = color === "primary" ? `--bg-${colorPrefix}-on-focused` : `--bg-${colorPrefix}-on-hover`;
|
|
134
|
+
const bgTonalHoverToken = color === "primary" ? `--bg-${colorPrefix}-tonal-on-hover` : `--bg-${colorPrefix}-tonal`;
|
|
135
|
+
const fgToken = `--fg-${colorPrefix}`;
|
|
136
|
+
const fgTonalToken = `--fg-${colorPrefix}-on-tonal`;
|
|
137
|
+
const fgHoverToken = color === "primary" ? `--fg-${colorPrefix}-on-hover` : `--fg-${colorPrefix}`;
|
|
138
|
+
const borderToken = `--border-${colorPrefix}`;
|
|
139
|
+
const borderTonalToken = `--border-${colorPrefix}-tonal`;
|
|
140
|
+
const borderHoverToken = color === "primary" ? `--border-${colorPrefix}-on-hover` : `--border-${colorPrefix}`;
|
|
141
|
+
// For non-primary colors, use the base border token for hover since there's no specific hover border token
|
|
84
142
|
// Get base variant styles
|
|
85
143
|
let variantStyles = {};
|
|
86
144
|
switch (variant) {
|
|
87
145
|
case "filled":
|
|
88
146
|
variantStyles = {
|
|
89
|
-
backgroundColor:
|
|
147
|
+
backgroundColor: `var(${bgToken})`,
|
|
90
148
|
color: "var(--fg-on-action)",
|
|
91
|
-
borderColor:
|
|
149
|
+
borderColor: `var(${bgToken})`,
|
|
92
150
|
};
|
|
93
151
|
break;
|
|
94
152
|
case "tonal":
|
|
95
153
|
variantStyles = {
|
|
96
|
-
backgroundColor:
|
|
97
|
-
color:
|
|
98
|
-
borderColor:
|
|
154
|
+
backgroundColor: `var(${bgTonalToken})`,
|
|
155
|
+
color: `var(${fgTonalToken})`,
|
|
156
|
+
borderColor: `var(${borderTonalToken})`,
|
|
99
157
|
};
|
|
100
158
|
break;
|
|
101
159
|
case "outline":
|
|
102
160
|
variantStyles = {
|
|
103
161
|
backgroundColor: "transparent",
|
|
104
|
-
color:
|
|
105
|
-
borderColor:
|
|
162
|
+
color: `var(${fgToken})`,
|
|
163
|
+
borderColor: `var(${borderToken})`,
|
|
106
164
|
};
|
|
107
165
|
break;
|
|
108
166
|
case "link":
|
|
109
167
|
variantStyles = {
|
|
110
168
|
backgroundColor: "transparent",
|
|
111
|
-
color:
|
|
169
|
+
color: `var(${fgToken})`,
|
|
112
170
|
borderWidth: 0,
|
|
113
171
|
borderStyle: "none",
|
|
114
172
|
borderColor: "transparent",
|
|
@@ -118,8 +176,9 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
|
|
|
118
176
|
break;
|
|
119
177
|
}
|
|
120
178
|
// Apply state-specific overrides
|
|
179
|
+
// When loading, preserve variant colors and don't apply state-specific styles
|
|
121
180
|
const stateStyles = {};
|
|
122
|
-
if (
|
|
181
|
+
if (isDisabled) {
|
|
123
182
|
if (variant === "filled") {
|
|
124
183
|
stateStyles.backgroundColor = "var(--bg-disabled)";
|
|
125
184
|
stateStyles.color = "var(--fg-on-disabled)";
|
|
@@ -138,90 +197,51 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
|
|
|
138
197
|
stateStyles.color = "var(--fg-disabled)";
|
|
139
198
|
}
|
|
140
199
|
}
|
|
141
|
-
else if (
|
|
200
|
+
else if (!isLoading && currentState === "hovered") {
|
|
142
201
|
if (variant === "filled") {
|
|
143
|
-
stateStyles.backgroundColor =
|
|
144
|
-
stateStyles.borderColor =
|
|
202
|
+
stateStyles.backgroundColor = `var(${bgHoverToken})`;
|
|
203
|
+
stateStyles.borderColor = `var(${bgHoverToken})`;
|
|
145
204
|
}
|
|
146
205
|
else if (variant === "tonal") {
|
|
147
|
-
stateStyles.backgroundColor =
|
|
206
|
+
stateStyles.backgroundColor = `var(${bgTonalHoverToken})`;
|
|
148
207
|
}
|
|
149
208
|
else if (variant === "outline") {
|
|
150
|
-
stateStyles.borderColor =
|
|
209
|
+
stateStyles.borderColor = `var(${borderHoverToken})`;
|
|
151
210
|
}
|
|
152
211
|
else if (variant === "link") {
|
|
153
|
-
stateStyles.color =
|
|
212
|
+
stateStyles.color = `var(${fgHoverToken})`;
|
|
154
213
|
}
|
|
155
214
|
}
|
|
156
|
-
else if (
|
|
215
|
+
else if (!isLoading && currentState === "pressed") {
|
|
157
216
|
if (variant === "filled") {
|
|
158
|
-
stateStyles.backgroundColor =
|
|
159
|
-
stateStyles.borderColor =
|
|
217
|
+
stateStyles.backgroundColor = `var(${bgPressedToken})`;
|
|
218
|
+
stateStyles.borderColor = `var(${bgPressedToken})`;
|
|
160
219
|
}
|
|
161
220
|
else if (variant === "tonal") {
|
|
162
|
-
stateStyles.backgroundColor =
|
|
221
|
+
stateStyles.backgroundColor = `var(${bgTonalHoverToken})`;
|
|
163
222
|
}
|
|
164
223
|
}
|
|
165
|
-
else if (
|
|
224
|
+
else if (!isLoading && currentState === "focused") {
|
|
166
225
|
if (variant === "filled") {
|
|
167
|
-
stateStyles.backgroundColor =
|
|
168
|
-
stateStyles.borderColor =
|
|
226
|
+
stateStyles.backgroundColor = `var(${bgFocusedToken})`;
|
|
227
|
+
stateStyles.borderColor = `var(${bgFocusedToken})`;
|
|
169
228
|
}
|
|
170
229
|
else if (variant === "outline") {
|
|
171
|
-
stateStyles.borderColor =
|
|
230
|
+
stateStyles.borderColor = `var(${borderToken})`;
|
|
172
231
|
}
|
|
173
|
-
stateStyles.outline =
|
|
232
|
+
stateStyles.outline = `2px solid var(${borderToken})`;
|
|
174
233
|
stateStyles.outlineOffset = "2px";
|
|
175
234
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
stateStyles.borderColor = "var(--border-success-tonal)";
|
|
185
|
-
}
|
|
186
|
-
else if (variant === "outline") {
|
|
187
|
-
stateStyles.color = "var(--fg-success)";
|
|
188
|
-
stateStyles.borderColor = "var(--border-success)";
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else if (state === "critical") {
|
|
192
|
-
if (variant === "filled") {
|
|
193
|
-
stateStyles.backgroundColor = "var(--bg-critical)";
|
|
194
|
-
stateStyles.borderColor = "var(--border-critical)";
|
|
195
|
-
}
|
|
196
|
-
else if (variant === "tonal") {
|
|
197
|
-
stateStyles.backgroundColor = "var(--bg-critical-tonal)";
|
|
198
|
-
stateStyles.color = "var(--fg-critical-on-tonal)";
|
|
199
|
-
stateStyles.borderColor = "var(--border-critical-tonal)";
|
|
200
|
-
}
|
|
201
|
-
else if (variant === "outline") {
|
|
202
|
-
stateStyles.color = "var(--fg-critical)";
|
|
203
|
-
stateStyles.borderColor = "var(--border-critical)";
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else if (state === "warning") {
|
|
207
|
-
if (variant === "filled") {
|
|
208
|
-
stateStyles.backgroundColor = "var(--bg-warning)";
|
|
209
|
-
stateStyles.borderColor = "var(--border-warning)";
|
|
210
|
-
}
|
|
211
|
-
else if (variant === "tonal") {
|
|
212
|
-
stateStyles.backgroundColor = "var(--bg-warning-tonal)";
|
|
213
|
-
stateStyles.color = "var(--fg-warning-on-tonal)";
|
|
214
|
-
stateStyles.borderColor = "var(--border-warning-tonal)";
|
|
215
|
-
}
|
|
216
|
-
else if (variant === "outline") {
|
|
217
|
-
stateStyles.color = "var(--fg-warning)";
|
|
218
|
-
stateStyles.borderColor = "var(--border-warning)";
|
|
219
|
-
}
|
|
235
|
+
return { ...baseStyles, ...variantStyles, ...stateStyles, ...style };
|
|
236
|
+
}, [variant, sizeConfig, borderRadius, fillContainer, justifyContent, currentState, isDisabled, isLoading, color, style]);
|
|
237
|
+
const showStartIcon = !loading && startIcon;
|
|
238
|
+
const showEndIcon = !loading && endIcon;
|
|
239
|
+
const handleClick = useCallback((e) => {
|
|
240
|
+
if (isDisabled || isLoading) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
return;
|
|
220
243
|
}
|
|
221
|
-
|
|
222
|
-
}, [
|
|
223
|
-
|
|
224
|
-
const showStartIcon = !isLoading && hasStartIcon;
|
|
225
|
-
const showEndIcon = !isLoading && hasEndIcon;
|
|
226
|
-
return (_jsx("div", { className: "ds-button-preview-container", children: _jsx("div", { className: "ds-button-preview-canvas", children: _jsx("button", { type: "button", className: "ds-button-preview-button", style: buttonStyles, disabled: state === "disabled", children: isLoading ? (_jsx(LoaderIcon, { size: LOADER_ICON_SIZE_MAP[size], className: "ds-button-loading-spinner" })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "ds-button-preview-start", children: [showStartIcon && _jsx(SearchIcon, { size: sizeConfig.iconSize }), _jsx("span", { children: "Button" })] }), showEndIcon && _jsx(ChevronDownIcon, { size: sizeConfig.iconSize })] })) }) }) }));
|
|
244
|
+
onClick?.(e);
|
|
245
|
+
}, [isDisabled, isLoading, onClick]);
|
|
246
|
+
return (_jsx("button", { ref: ref, type: type, className: className, style: buttonStyles, disabled: isDisabled, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, ...rest, children: loading ? (_jsx(LoaderIcon, { size: LOADER_ICON_SIZE_MAP[size], className: "ds-button-loading-spinner" })) : (_jsxs(_Fragment, { children: [showStartIcon && _jsx("span", { style: { display: "inline-flex", alignItems: "center" }, children: startIcon }), children, showEndIcon && _jsx("span", { style: { display: "inline-flex", alignItems: "center" }, children: endIcon })] })) }));
|
|
227
247
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
2
|
import { type PatternType } from "../utils/patternPaths";
|
|
3
|
-
type CardType = "product" | "experience" | "info" | "generic";
|
|
4
|
-
type ProductCardSize = "full" | "half";
|
|
5
|
-
type ProductCardStatus = "default" | "highlighted";
|
|
6
|
-
type ExperienceCardType = "default" | "skills" | "contacts";
|
|
7
|
-
type GenericCardStatus = "default" | "highlighted" | "selected";
|
|
8
|
-
interface CardProps {
|
|
3
|
+
export type CardType = "product" | "experience" | "info" | "generic";
|
|
4
|
+
export type ProductCardSize = "full" | "half";
|
|
5
|
+
export type ProductCardStatus = "default" | "highlighted";
|
|
6
|
+
export type ExperienceCardType = "default" | "skills" | "contacts";
|
|
7
|
+
export type GenericCardStatus = "default" | "highlighted" | "selected";
|
|
8
|
+
export interface CardProps extends Omit<ComponentPropsWithRef<"div">, "slot"> {
|
|
9
9
|
cardType: CardType;
|
|
10
|
-
theme: Theme;
|
|
11
|
-
hue: HueVariant;
|
|
12
10
|
size?: ProductCardSize;
|
|
13
11
|
status?: ProductCardStatus;
|
|
14
12
|
hasImage?: boolean;
|
|
@@ -35,6 +33,5 @@ interface CardProps {
|
|
|
35
33
|
showBorder?: boolean;
|
|
36
34
|
slot?: React.ReactNode;
|
|
37
35
|
}
|
|
38
|
-
export declare function Card({ cardType,
|
|
39
|
-
export {};
|
|
36
|
+
export declare function Card({ cardType, size, status, hasImage, imageAspectRatio, hasIdentifiers, hasButton, title, description, experienceType, positionName, companyName, year, experienceDescription, label, details, cardName, cardDescription, hasIcon, genericStatus, showBgPattern, patternType, showOverlay, showShadow, showBorder, slot, className, style, ref, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
40
37
|
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAW,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAGrE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAC9C,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAG1D,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAGnE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;AAEvE,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAC3E,QAAQ,EAAE,QAAQ,CAAC;IAEnB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EAER,IAAa,EACb,MAAkB,EAClB,QAAe,EACf,gBAAyB,EACzB,cAAqB,EACrB,SAAgB,EAChB,KAAuB,EACvB,WAAsI,EAEtI,cAA0B,EAC1B,YAA8B,EAC9B,WAA4B,EAC5B,IAAgB,EAChB,qBAA0C,EAC1C,KAAe,EACf,OAAmB,EAEnB,QAAsB,EACtB,eAAoC,EACpC,OAAc,EAEd,aAAyB,EACzB,aAAoB,EACpB,WAAqB,EACrB,WAAkB,EAClB,UAAiB,EACjB,UAAiB,EACjB,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,SAAS,2CAmyBX"}
|
package/dist/components/Card.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
3
4
|
import { RightArrowIcon, ArrowDownFallSlotIcon } from "../icons";
|
|
4
5
|
import { getPatternConfig } from "../utils/patternPaths";
|
|
5
|
-
export function Card({ cardType,
|
|
6
|
+
export function Card({ cardType,
|
|
6
7
|
// ProductCard
|
|
7
8
|
size = "full", status = "default", hasImage = true, imageAspectRatio = "16x9", hasIdentifiers = true, hasButton = true, title = "Product Title", description = "Add your products Details that description here. This paragraph is restricted only two lines even if content is large.",
|
|
8
9
|
// ExperienceCard
|
|
@@ -10,7 +11,8 @@ experienceType = "default", positionName = "Position Name", companyName = "Compa
|
|
|
10
11
|
// InfoCard
|
|
11
12
|
cardName = "Card Name", cardDescription = "Card Description", hasIcon = true,
|
|
12
13
|
// Generic Card
|
|
13
|
-
genericStatus = "default", showBgPattern = true, patternType = "cubes", showOverlay = true, showShadow = true, showBorder = true, slot, }) {
|
|
14
|
+
genericStatus = "default", showBgPattern = true, patternType = "cubes", showOverlay = true, showShadow = true, showBorder = true, slot, className, style, ref, ...rest }) {
|
|
15
|
+
useThemeSafe(); // Ensure theme context is available
|
|
14
16
|
const renderProductCard = () => {
|
|
15
17
|
const isFull = size === "full";
|
|
16
18
|
const isHighlighted = status === "highlighted";
|
|
@@ -513,5 +515,5 @@ genericStatus = "default", showBgPattern = true, patternType = "cubes", showOver
|
|
|
513
515
|
return null;
|
|
514
516
|
}
|
|
515
517
|
};
|
|
516
|
-
return (_jsx("div", {
|
|
518
|
+
return (_jsx("div", { ref: ref, className: className, style: style, ...rest, children: renderCard() }));
|
|
517
519
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type CheckboxStatus = "default" | "hovered" | "focused" | "pressed" | "disabled";
|
|
3
|
+
export interface CheckboxProps 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
|
label?: string;
|
|
8
7
|
showLabel?: boolean;
|
|
8
|
+
status?: CheckboxStatus;
|
|
9
9
|
}
|
|
10
|
-
export declare function Checkbox({ checked, onChange, disabled, id, ariaLabel, label, showLabel, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
10
|
+
export declare function Checkbox({ checked, onChange, disabled, id, "aria-label": ariaLabel, label, showLabel, status: statusProp, className, style, onClick, onKeyDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAExF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC/F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAKD,wBAAgB,QAAQ,CAAC,EACvB,OAAe,EACf,QAAQ,EACR,QAAgB,EAChB,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,KAAK,EACL,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,aAAa,2CAkSf"}
|
|
@@ -1,64 +1,217 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useCallback } from "react";
|
|
4
|
-
import { CheckboxPreview } from "./CheckboxPreview";
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
5
|
+
import { CheckIcon } from "../icons";
|
|
6
|
+
const CHECKBOX_SIZE = 20;
|
|
7
|
+
const ICON_SIZE = 16; // 20px box - 4px padding (2px each side) = 16px
|
|
8
|
+
export function Checkbox({ checked = false, onChange, disabled = false, id, "aria-label": ariaLabel, label, showLabel = false, status: statusProp, className, style, onClick, onKeyDown, onMouseEnter, onMouseLeave, onFocus, onBlur, onMouseDown, onMouseUp, ref, ...rest }) {
|
|
9
|
+
useThemeSafe(); // Ensure theme context is available
|
|
10
|
+
const [internalStatus, setInternalStatus] = useState("default");
|
|
11
|
+
const status = statusProp ?? internalStatus;
|
|
12
|
+
const handleClick = useCallback((e) => {
|
|
12
13
|
if (!disabled && onChange) {
|
|
13
14
|
onChange(!checked);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
onClick?.(e);
|
|
17
|
+
}, [checked, disabled, onChange, onClick]);
|
|
16
18
|
const handleKeyDown = useCallback((e) => {
|
|
17
|
-
if (disabled)
|
|
19
|
+
if (disabled) {
|
|
20
|
+
onKeyDown?.(e);
|
|
18
21
|
return;
|
|
22
|
+
}
|
|
19
23
|
if (e.key === " " || e.key === "Enter") {
|
|
20
24
|
e.preventDefault();
|
|
21
25
|
if (onChange) {
|
|
22
26
|
onChange(!checked);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
onKeyDown?.(e);
|
|
30
|
+
}, [checked, disabled, onChange, onKeyDown]);
|
|
31
|
+
const handleMouseEnter = useCallback((e) => {
|
|
32
|
+
if (!disabled && !statusProp) {
|
|
33
|
+
setInternalStatus("hovered");
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
onMouseEnter?.(e);
|
|
36
|
+
}, [disabled, statusProp, onMouseEnter]);
|
|
37
|
+
const handleMouseLeave = useCallback((e) => {
|
|
38
|
+
if (!disabled && !statusProp) {
|
|
39
|
+
setInternalStatus("default");
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
onMouseLeave?.(e);
|
|
42
|
+
}, [disabled, statusProp, onMouseLeave]);
|
|
43
|
+
const handleFocus = useCallback((e) => {
|
|
44
|
+
if (!disabled && !statusProp) {
|
|
45
|
+
setInternalStatus("focused");
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
onFocus?.(e);
|
|
48
|
+
}, [disabled, statusProp, onFocus]);
|
|
49
|
+
const handleBlur = useCallback((e) => {
|
|
50
|
+
if (!disabled && !statusProp) {
|
|
51
|
+
setInternalStatus("default");
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
onBlur?.(e);
|
|
54
|
+
}, [disabled, statusProp, onBlur]);
|
|
55
|
+
const handleMouseDown = useCallback((e) => {
|
|
56
|
+
if (!disabled && !statusProp) {
|
|
57
|
+
setInternalStatus("pressed");
|
|
49
58
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
onMouseDown?.(e);
|
|
60
|
+
}, [disabled, statusProp, onMouseDown]);
|
|
61
|
+
const handleMouseUp = useCallback((e) => {
|
|
62
|
+
if (!disabled && !statusProp) {
|
|
63
|
+
setInternalStatus("default");
|
|
54
64
|
}
|
|
55
|
-
|
|
65
|
+
onMouseUp?.(e);
|
|
66
|
+
}, [disabled, statusProp, onMouseUp]);
|
|
56
67
|
const currentStatus = disabled ? "disabled" : status;
|
|
57
|
-
|
|
68
|
+
const isDisabled = disabled;
|
|
69
|
+
const checkboxStyles = useMemo(() => {
|
|
70
|
+
const baseStyles = {
|
|
71
|
+
width: `${CHECKBOX_SIZE}px`,
|
|
72
|
+
height: `${CHECKBOX_SIZE}px`,
|
|
73
|
+
borderRadius: "var(--corner-radius-100)",
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
flexShrink: 0,
|
|
78
|
+
transition: "background-color 0.15s ease, border-color 0.15s ease",
|
|
79
|
+
boxSizing: "border-box",
|
|
80
|
+
overflow: "hidden",
|
|
81
|
+
position: "relative",
|
|
82
|
+
};
|
|
83
|
+
if (checked) {
|
|
84
|
+
// Checked state
|
|
85
|
+
if (isDisabled) {
|
|
86
|
+
return {
|
|
87
|
+
...baseStyles,
|
|
88
|
+
backgroundColor: "var(--bg-disabled)",
|
|
89
|
+
border: "none",
|
|
90
|
+
padding: "var(--spacing-50)",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (currentStatus === "hovered") {
|
|
94
|
+
return {
|
|
95
|
+
...baseStyles,
|
|
96
|
+
backgroundColor: "var(--bg-primary-on-hover)",
|
|
97
|
+
border: "none",
|
|
98
|
+
padding: "var(--spacing-50)",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (currentStatus === "focused" || currentStatus === "pressed") {
|
|
102
|
+
return {
|
|
103
|
+
...baseStyles,
|
|
104
|
+
backgroundColor: "var(--bg-primary-pressed)",
|
|
105
|
+
border: "none",
|
|
106
|
+
padding: "var(--spacing-50)",
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Default checked
|
|
110
|
+
return {
|
|
111
|
+
...baseStyles,
|
|
112
|
+
backgroundColor: "var(--bg-primary)",
|
|
113
|
+
border: "none",
|
|
114
|
+
padding: "var(--spacing-50)",
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Unchecked state
|
|
119
|
+
if (isDisabled) {
|
|
120
|
+
return {
|
|
121
|
+
...baseStyles,
|
|
122
|
+
backgroundColor: "var(--bg-page-primary)",
|
|
123
|
+
border: "var(--border-width-50) solid var(--border-neutral-tertiary)",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (currentStatus === "hovered" || currentStatus === "focused" || currentStatus === "pressed") {
|
|
127
|
+
return {
|
|
128
|
+
...baseStyles,
|
|
129
|
+
backgroundColor: "var(--bg-page-primary)",
|
|
130
|
+
border: "var(--border-width-50) solid var(--border-neutral-primary)",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Default unchecked
|
|
134
|
+
return {
|
|
135
|
+
...baseStyles,
|
|
136
|
+
backgroundColor: "var(--bg-page-primary)",
|
|
137
|
+
border: "var(--border-width-50) solid var(--border-neutral-secondary)",
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}, [checked, currentStatus, isDisabled]);
|
|
141
|
+
const iconColor = useMemo(() => {
|
|
142
|
+
if (isDisabled) {
|
|
143
|
+
return "var(--fg-on-disabled)";
|
|
144
|
+
}
|
|
145
|
+
return "var(--static-white)";
|
|
146
|
+
}, [isDisabled]);
|
|
147
|
+
const labelStyles = useMemo(() => {
|
|
148
|
+
const baseStyles = {
|
|
149
|
+
fontFamily: "var(--font-secondary)",
|
|
150
|
+
fontSize: "var(--body-small-text-size)",
|
|
151
|
+
lineHeight: "var(--body-small-line-height)",
|
|
152
|
+
fontWeight: "var(--font-weight-secondary-medium)",
|
|
153
|
+
margin: 0,
|
|
154
|
+
};
|
|
155
|
+
if (isDisabled) {
|
|
156
|
+
return {
|
|
157
|
+
...baseStyles,
|
|
158
|
+
color: "var(--fg-on-disabled)",
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (checked) {
|
|
162
|
+
return {
|
|
163
|
+
...baseStyles,
|
|
164
|
+
color: "var(--fg-neutral-secondary)",
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
...baseStyles,
|
|
169
|
+
color: "var(--fg-neutral-tertiary)",
|
|
170
|
+
};
|
|
171
|
+
}, [isDisabled, checked]);
|
|
172
|
+
const focusRingStyles = useMemo(() => {
|
|
173
|
+
if (currentStatus !== "focused")
|
|
174
|
+
return null;
|
|
175
|
+
return {
|
|
176
|
+
position: "absolute",
|
|
177
|
+
top: "50%",
|
|
178
|
+
left: "50%",
|
|
179
|
+
transform: "translate(-50%, -50%)",
|
|
180
|
+
width: "28px",
|
|
181
|
+
height: "28px",
|
|
182
|
+
marginTop: "0",
|
|
183
|
+
marginLeft: "0",
|
|
184
|
+
borderRadius: "var(--corner-radius-200)",
|
|
185
|
+
borderWidth: "var(--border-width-25)",
|
|
186
|
+
borderStyle: "solid",
|
|
187
|
+
borderColor: checked
|
|
188
|
+
? "var(--border-primary)"
|
|
189
|
+
: "var(--border-neutral-primary)",
|
|
190
|
+
pointerEvents: "none",
|
|
191
|
+
};
|
|
192
|
+
}, [currentStatus, checked]);
|
|
193
|
+
return (_jsx("button", { ref: ref, type: "button", id: id, role: "checkbox", "aria-checked": checked, "aria-label": ariaLabel, "aria-disabled": disabled, disabled: disabled, className: className, style: {
|
|
58
194
|
border: "none",
|
|
59
195
|
background: "none",
|
|
60
196
|
padding: 0,
|
|
61
197
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
62
198
|
outline: "none",
|
|
63
|
-
|
|
199
|
+
...style,
|
|
200
|
+
}, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, ...rest, children: _jsxs("div", { style: {
|
|
201
|
+
display: "flex",
|
|
202
|
+
alignItems: "center",
|
|
203
|
+
gap: "var(--spacing-200)",
|
|
204
|
+
position: "relative",
|
|
205
|
+
}, children: [_jsxs("div", { style: { position: "relative", display: "flex", alignItems: "center", justifyContent: "center" }, children: [focusRingStyles && _jsx("div", { style: focusRingStyles }), _jsx("div", { style: checkboxStyles, children: checked && (_jsx("div", { style: {
|
|
206
|
+
color: iconColor,
|
|
207
|
+
display: "flex",
|
|
208
|
+
alignItems: "center",
|
|
209
|
+
justifyContent: "center",
|
|
210
|
+
width: `${ICON_SIZE}px`,
|
|
211
|
+
height: `${ICON_SIZE}px`,
|
|
212
|
+
maxWidth: `${ICON_SIZE}px`,
|
|
213
|
+
maxHeight: `${ICON_SIZE}px`,
|
|
214
|
+
flexShrink: 0,
|
|
215
|
+
overflow: "hidden",
|
|
216
|
+
}, children: _jsx(CheckIcon, { size: ICON_SIZE }) })) })] }), showLabel && label && _jsx("p", { style: labelStyles, children: label })] }) }));
|
|
64
217
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
type ChipSize = "sm" | "md" | "lg";
|
|
3
|
-
type ChipColor = "primary" | "neutral" | "success" | "critical" | "warning";
|
|
4
|
-
interface ChipProps {
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type ChipSize = "sm" | "md" | "lg";
|
|
3
|
+
export type ChipColor = "primary" | "neutral" | "success" | "critical" | "warning";
|
|
4
|
+
export interface ChipProps extends ComponentPropsWithRef<"div"> {
|
|
5
5
|
label?: string;
|
|
6
6
|
color?: ChipColor;
|
|
7
7
|
size?: ChipSize;
|
|
8
8
|
showBorders?: boolean;
|
|
9
|
-
|
|
10
|
-
theme?: Theme;
|
|
11
|
-
hue?: HueVariant;
|
|
9
|
+
icon?: React.ReactNode;
|
|
12
10
|
}
|
|
13
|
-
export declare function Chip({ label, color, size, showBorders,
|
|
14
|
-
export {};
|
|
11
|
+
export declare function Chip({ label, color, size, showBorders, icon, className, style, children, ref, ...rest }: ChipProps): import("react/jsx-runtime").JSX.Element;
|
|
15
12
|
//# sourceMappingURL=Chip.d.ts.map
|