beacon-ui 3.1.4 → 3.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useMemo } from "react";
4
- import { SearchIcon, ChevronDownIcon, LoaderIcon } from "../icons";
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,50 @@ const LOADER_ICON_SIZE_MAP = {
54
55
  lg: 32,
55
56
  xl: 40,
56
57
  };
57
- export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon, fillContainer, justifyContent, state, theme, hue, }) {
58
+ export function Button({ variant = "filled", size = "md", cornerRadius = 2, startIcon, endIcon, fillContainer = false, justifyContent = "center", loading = false, disabled = false, state: stateProp, 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 || loading;
101
+ const currentState = isDisabled ? "default" : state;
60
102
  const buttonStyles = useMemo(() => {
61
103
  const baseStyles = {
62
104
  display: "inline-flex",
@@ -71,7 +113,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
71
113
  borderStyle: "solid",
72
114
  borderColor: "transparent",
73
115
  borderRadius,
74
- cursor: state === "disabled" ? "not-allowed" : "pointer",
116
+ cursor: isDisabled ? "not-allowed" : "pointer",
75
117
  transition: "background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease",
76
118
  minHeight: sizeConfig.height,
77
119
  paddingLeft: sizeConfig.paddingX,
@@ -79,7 +121,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
79
121
  paddingTop: sizeConfig.paddingY,
80
122
  paddingBottom: sizeConfig.paddingY,
81
123
  width: fillContainer ? "100%" : "auto",
82
- opacity: state === "disabled" ? 0.6 : 1,
124
+ opacity: isDisabled ? 0.6 : 1,
83
125
  };
84
126
  // Get base variant styles
85
127
  let variantStyles = {};
@@ -119,7 +161,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
119
161
  }
120
162
  // Apply state-specific overrides
121
163
  const stateStyles = {};
122
- if (state === "disabled") {
164
+ if (isDisabled) {
123
165
  if (variant === "filled") {
124
166
  stateStyles.backgroundColor = "var(--bg-disabled)";
125
167
  stateStyles.color = "var(--fg-on-disabled)";
@@ -138,7 +180,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
138
180
  stateStyles.color = "var(--fg-disabled)";
139
181
  }
140
182
  }
141
- else if (state === "hovered") {
183
+ else if (currentState === "hovered") {
142
184
  if (variant === "filled") {
143
185
  stateStyles.backgroundColor = "var(--bg-primary-on-hover)";
144
186
  stateStyles.borderColor = "var(--bg-primary-on-hover)";
@@ -153,7 +195,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
153
195
  stateStyles.color = "var(--fg-primary-on-hover)";
154
196
  }
155
197
  }
156
- else if (state === "pressed") {
198
+ else if (currentState === "pressed") {
157
199
  if (variant === "filled") {
158
200
  stateStyles.backgroundColor = "var(--bg-primary-pressed)";
159
201
  stateStyles.borderColor = "var(--bg-primary-pressed)";
@@ -162,7 +204,7 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
162
204
  stateStyles.backgroundColor = "var(--bg-primary-tonal-on-hover)";
163
205
  }
164
206
  }
165
- else if (state === "focused") {
207
+ else if (currentState === "focused") {
166
208
  if (variant === "filled") {
167
209
  stateStyles.backgroundColor = "var(--bg-primary-on-focused)";
168
210
  stateStyles.borderColor = "var(--bg-primary-on-focused)";
@@ -173,55 +215,9 @@ export function Button({ variant, size, cornerRadius, hasStartIcon, hasEndIcon,
173
215
  stateStyles.outline = "2px solid var(--border-primary)";
174
216
  stateStyles.outlineOffset = "2px";
175
217
  }
176
- else if (state === "success") {
177
- if (variant === "filled") {
178
- stateStyles.backgroundColor = "var(--bg-success)";
179
- stateStyles.borderColor = "var(--border-success)";
180
- }
181
- else if (variant === "tonal") {
182
- stateStyles.backgroundColor = "var(--bg-success-tonal)";
183
- stateStyles.color = "var(--fg-success-on-tonal)";
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
- }
220
- }
221
- return { ...baseStyles, ...variantStyles, ...stateStyles };
222
- }, [variant, sizeConfig, borderRadius, fillContainer, justifyContent, state]);
223
- const isLoading = state === "loading";
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 })] })) }) }) }));
218
+ return { ...baseStyles, ...variantStyles, ...stateStyles, ...style };
219
+ }, [variant, sizeConfig, borderRadius, fillContainer, justifyContent, currentState, isDisabled, style]);
220
+ const showStartIcon = !loading && startIcon;
221
+ const showEndIcon = !loading && endIcon;
222
+ return (_jsx("button", { ref: ref, type: type, className: className, style: buttonStyles, disabled: isDisabled, onClick: onClick, 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
223
  }
@@ -1,14 +1,12 @@
1
- import type { Theme, HueVariant } from "../tokens/types";
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, theme, hue, 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, }: CardProps): import("react/jsx-runtime").JSX.Element;
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":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE3E,KAAK,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAG9D,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AACvC,KAAK,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAGnD,KAAK,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAG5D,KAAK,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;AAEhE,UAAU,SAAS;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAEhB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC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ACf,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"}
@@ -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, theme, hue,
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", { className: "ds-card-preview-container", children: _jsx("div", { className: "ds-card-preview-canvas", children: renderCard() }) }));
518
+ return (_jsx("div", { ref: ref, className: className, style: style, ...rest, children: renderCard() }));
517
519
  }
@@ -1,12 +1,11 @@
1
- interface CheckboxProps {
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":"AAQA,UAAU,aAAa;IACrB,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,QAAQ,CAAC,EACvB,OAAe,EACf,QAAQ,EACR,QAAgB,EAChB,EAAE,EACF,SAAS,EACT,KAAK,EACL,SAAiB,GAClB,EAAE,aAAa,2CAmGf"}
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
- export function Checkbox({ checked = false, onChange, disabled = false, id, ariaLabel, label, showLabel = 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 { 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
- }, [checked, disabled, onChange]);
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
- }, [checked, disabled, onChange]);
26
- const handleMouseEnter = useCallback(() => {
27
- if (!disabled) {
28
- setStatus("hovered");
29
+ onKeyDown?.(e);
30
+ }, [checked, disabled, onChange, onKeyDown]);
31
+ const handleMouseEnter = useCallback((e) => {
32
+ if (!disabled && !statusProp) {
33
+ setInternalStatus("hovered");
29
34
  }
30
- }, [disabled]);
31
- const handleMouseLeave = useCallback(() => {
32
- if (!disabled) {
33
- setStatus("default");
35
+ onMouseEnter?.(e);
36
+ }, [disabled, statusProp, onMouseEnter]);
37
+ const handleMouseLeave = useCallback((e) => {
38
+ if (!disabled && !statusProp) {
39
+ setInternalStatus("default");
34
40
  }
35
- }, [disabled]);
36
- const handleFocus = useCallback(() => {
37
- if (!disabled) {
38
- setStatus("focused");
41
+ onMouseLeave?.(e);
42
+ }, [disabled, statusProp, onMouseLeave]);
43
+ const handleFocus = useCallback((e) => {
44
+ if (!disabled && !statusProp) {
45
+ setInternalStatus("focused");
39
46
  }
40
- }, [disabled]);
41
- const handleBlur = useCallback(() => {
42
- if (!disabled) {
43
- setStatus("default");
47
+ onFocus?.(e);
48
+ }, [disabled, statusProp, onFocus]);
49
+ const handleBlur = useCallback((e) => {
50
+ if (!disabled && !statusProp) {
51
+ setInternalStatus("default");
44
52
  }
45
- }, [disabled]);
46
- const handleMouseDown = useCallback(() => {
47
- if (!disabled) {
48
- setStatus("pressed");
53
+ onBlur?.(e);
54
+ }, [disabled, statusProp, onBlur]);
55
+ const handleMouseDown = useCallback((e) => {
56
+ if (!disabled && !statusProp) {
57
+ setInternalStatus("pressed");
49
58
  }
50
- }, [disabled]);
51
- const handleMouseUp = useCallback(() => {
52
- if (!disabled) {
53
- setStatus("default");
59
+ onMouseDown?.(e);
60
+ }, [disabled, statusProp, onMouseDown]);
61
+ const handleMouseUp = useCallback((e) => {
62
+ if (!disabled && !statusProp) {
63
+ setInternalStatus("default");
54
64
  }
55
- }, [disabled]);
65
+ onMouseUp?.(e);
66
+ }, [disabled, statusProp, onMouseUp]);
56
67
  const currentStatus = disabled ? "disabled" : status;
57
- return (_jsx("button", { type: "button", id: id, role: "checkbox", "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: {
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
- }, children: _jsx(CheckboxPreview, { checked: checked, status: currentStatus, label: label, showLabel: showLabel, theme: theme, hue: hue }) }));
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 type { Theme, HueVariant } from "../tokens/types";
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
- showIcon?: boolean;
10
- theme?: Theme;
11
- hue?: HueVariant;
9
+ icon?: React.ReactNode;
12
10
  }
13
- export declare function Chip({ label, color, size, showBorders, showIcon, theme, hue, }: ChipProps): import("react/jsx-runtime").JSX.Element;
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
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../src/components/Chip.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGzD,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACnC,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5E,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAsED,wBAAgB,IAAI,CAAC,EACnB,KAAoB,EACpB,KAAiB,EACjB,IAAW,EACX,WAAmB,EACnB,QAAgB,EAChB,KAAK,EACL,GAAG,GACJ,EAAE,SAAS,2CA0DX"}
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"}
@@ -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 { ListDetailsIcon } from "../icons";
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, showIcon = false, theme, hue, }) {
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: [showIcon && (_jsx("div", { style: iconWrapperStyles, children: _jsx(ListDetailsIcon, { size: sizeConfig.iconSize }) })), _jsx("span", { children: label })] }));
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 type { Theme, HueVariant } from "../tokens/types";
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
- showStartIcon?: boolean;
12
- showEndIcon?: boolean;
13
- showPlaceholderIcon?: boolean;
9
+ startIcon?: React.ReactNode;
10
+ endIcon?: React.ReactNode;
11
+ placeholderIcon?: React.ReactNode;
14
12
  showError?: boolean;
15
- showNumberPrefix?: boolean;
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, placeholder, value, size, status, showLabel, showStartIcon, showEndIcon, showPlaceholderIcon, showError, showNumberPrefix, rounded, iconOnly, disabled, theme, hue, }: InputProps): import("react/jsx-runtime").JSX.Element;
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