beacon-ui 3.4.6 → 3.4.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 +10 -0
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +3 -1
- package/dist/components/Input.d.ts +4 -3
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +140 -24
- package/dist/components/Select.d.ts +27 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +276 -0
- package/dist/components/Slider.d.ts +21 -0
- package/dist/components/Slider.d.ts.map +1 -0
- package/dist/components/Slider.js +308 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/tokens/generated/index.css +65 -40
- package/tokens/generated/primitives.css +16 -15
- package/tokens/generated/semantic.css +42 -0
- package/tokens/generated/typography.css +7 -25
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.4.8] - 2026-01-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Slider component for selecting single values or ranges with support for tooltips, step indicators, and customizable labels
|
|
12
|
+
- Slider supports both single value and range modes with configurable min, max, and step values
|
|
13
|
+
- Slider component includes status states (default, hover, active, disabled) and keyboard navigation support
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Input and Select components updated with improved styling consistency and enhanced functionality
|
|
17
|
+
|
|
8
18
|
## [3.4.5] - 2026-01-06
|
|
9
19
|
|
|
10
20
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAgC,MAAM,OAAO,CAAC;AAI5G,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,eAAe,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAChF,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAkED,wBAAgB,MAAM,CAAC,EACrB,OAAkB,EAClB,IAAW,EACX,YAAgB,EAChB,SAAS,EACT,OAAO,EACP,aAAqB,EACrB,cAAyB,EACzB,OAAe,EACf,QAAgB,EAChB,KAAK,EAAE,SAAS,EAChB,KAAiB,EACjB,IAAe,EACf,SAAS,EACT,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAgC,MAAM,OAAO,CAAC;AAI5G,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,eAAe,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAChF,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAkED,wBAAgB,MAAM,CAAC,EACrB,OAAkB,EAClB,IAAW,EACX,YAAgB,EAChB,SAAS,EACT,OAAO,EACP,aAAqB,EACrB,cAAyB,EACzB,OAAe,EACf,QAAgB,EAChB,KAAK,EAAE,SAAS,EAChB,KAAiB,EACjB,IAAe,EACf,SAAS,EACT,QAAQ,EACR,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,2CAwSb"}
|
|
@@ -207,7 +207,9 @@ export function Button({ variant = "filled", size = "md", cornerRadius = 2, star
|
|
|
207
207
|
stateStyles.backgroundColor = `var(${bgTonalHoverToken})`;
|
|
208
208
|
}
|
|
209
209
|
else if (variant === "outline") {
|
|
210
|
-
stateStyles.
|
|
210
|
+
stateStyles.backgroundColor = "var(--bg-primary)";
|
|
211
|
+
stateStyles.color = "var(--fg-neutral)";
|
|
212
|
+
stateStyles.borderColor = "var(--bg-primary)";
|
|
211
213
|
}
|
|
212
214
|
else if (variant === "link") {
|
|
213
215
|
stateStyles.color = `var(${fgHoverToken})`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from "react";
|
|
2
|
-
export type InputSize = "sm" | "md" | "lg";
|
|
3
|
-
export type InputStatus = "default" | "active";
|
|
2
|
+
export type InputSize = "sm" | "md" | "lg" | "xl";
|
|
3
|
+
export type InputStatus = "default" | "hover" | "active" | "error" | "disabled";
|
|
4
4
|
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size"> {
|
|
5
5
|
label?: string;
|
|
6
6
|
size?: InputSize;
|
|
@@ -15,6 +15,7 @@ export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size">
|
|
|
15
15
|
rounded?: boolean;
|
|
16
16
|
iconOnly?: boolean;
|
|
17
17
|
borderRadius?: string;
|
|
18
|
+
fullWidth?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare function Input({ label, size, status, showLabel, startIcon, endIcon, placeholderIcon, showError, errorMessage, numberPrefix, rounded, iconOnly, disabled, borderRadius, className, style, value, placeholder, ref, ...rest }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function Input({ label, size, status, showLabel, startIcon, endIcon, placeholderIcon, showError, errorMessage, numberPrefix, rounded, iconOnly, disabled, borderRadius, fullWidth, className, style, value, placeholder, ref, ...rest }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkC,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAI9E,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC;AAEhF,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;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAmED,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,YAAY,EACZ,SAAgB,EAChB,SAAS,EACT,KAAK,EACL,KAAK,EACL,WAAW,EACX,GAAG,EACH,GAAG,IAAI,EACR,EAAE,UAAU,2CAwTZ"}
|
package/dist/components/Input.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
3
|
+
import { useMemo, useState, useCallback } from "react";
|
|
4
4
|
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
5
|
-
import { AlertTriangleErrorIcon } from "../icons";
|
|
5
|
+
import { AlertTriangleErrorIcon, CloseIcon } from "../icons";
|
|
6
6
|
const SIZE_CONFIG = {
|
|
7
7
|
sm: {
|
|
8
8
|
height: "28px",
|
|
@@ -40,20 +40,39 @@ const SIZE_CONFIG = {
|
|
|
40
40
|
borderRadius: "var(--corner-radius-200)",
|
|
41
41
|
gap: "var(--spacing-200)",
|
|
42
42
|
},
|
|
43
|
+
xl: {
|
|
44
|
+
height: "56px",
|
|
45
|
+
iconSize: 24,
|
|
46
|
+
fontSize: "var(--body-regular-text-size)",
|
|
47
|
+
lineHeight: "var(--body-regular-line-height)",
|
|
48
|
+
labelFontSize: "var(--body-regular-text-size)",
|
|
49
|
+
labelLineHeight: "var(--body-regular-line-height)",
|
|
50
|
+
paddingX: "var(--spacing-450)",
|
|
51
|
+
paddingY: "var(--spacing-400)",
|
|
52
|
+
borderRadius: "var(--corner-radius-200)",
|
|
53
|
+
gap: "var(--spacing-200)",
|
|
54
|
+
},
|
|
43
55
|
};
|
|
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, borderRadius, className, style, value, placeholder, ref, ...rest }) {
|
|
56
|
+
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, borderRadius, fullWidth = true, className, style, value, placeholder, ref, ...rest }) {
|
|
45
57
|
useThemeSafe(); // Ensure theme context is available
|
|
46
58
|
const sizeConfig = SIZE_CONFIG[size];
|
|
47
59
|
const hasValue = value != null && String(value).length > 0;
|
|
60
|
+
const isDisabled = disabled || status === "disabled";
|
|
48
61
|
const borderColor = useMemo(() => {
|
|
49
|
-
if (
|
|
50
|
-
return "var(--border-
|
|
62
|
+
if (isDisabled) {
|
|
63
|
+
return "var(--border-disabled)";
|
|
64
|
+
}
|
|
65
|
+
if (status === "error") {
|
|
66
|
+
return "var(--border-critical)";
|
|
51
67
|
}
|
|
52
68
|
if (status === "active") {
|
|
53
69
|
return "var(--border-primary)";
|
|
54
70
|
}
|
|
71
|
+
if (status === "hover") {
|
|
72
|
+
return "var(--border-neutral-primary)";
|
|
73
|
+
}
|
|
55
74
|
return "var(--border-strong-200)";
|
|
56
|
-
}, [status,
|
|
75
|
+
}, [status, isDisabled]);
|
|
57
76
|
const inputContainerStyles = useMemo(() => {
|
|
58
77
|
const baseStyles = {
|
|
59
78
|
display: "flex",
|
|
@@ -66,36 +85,49 @@ export function Input({ label, size = "md", status = "default", showLabel = true
|
|
|
66
85
|
paddingRight: sizeConfig.paddingX,
|
|
67
86
|
paddingTop: sizeConfig.paddingY,
|
|
68
87
|
paddingBottom: sizeConfig.paddingY,
|
|
69
|
-
width: iconOnly ? sizeConfig.height : "100%",
|
|
88
|
+
width: iconOnly ? sizeConfig.height : fullWidth ? "100%" : "fit-content",
|
|
70
89
|
height: iconOnly ? sizeConfig.height : sizeConfig.height,
|
|
71
90
|
justifyContent: iconOnly ? "center" : "flex-start",
|
|
72
|
-
cursor:
|
|
73
|
-
opacity:
|
|
74
|
-
transition: "border-color 0.15s ease",
|
|
91
|
+
cursor: isDisabled ? "not-allowed" : "text",
|
|
92
|
+
opacity: isDisabled ? 0.6 : 1,
|
|
93
|
+
transition: "border-color 0.15s ease, box-shadow 0.15s ease",
|
|
94
|
+
position: "relative",
|
|
75
95
|
};
|
|
76
96
|
return baseStyles;
|
|
77
|
-
}, [sizeConfig, borderColor, rounded, borderRadius, iconOnly,
|
|
97
|
+
}, [sizeConfig, borderColor, rounded, borderRadius, iconOnly, isDisabled, fullWidth]);
|
|
78
98
|
const labelStyles = useMemo(() => {
|
|
79
99
|
return {
|
|
80
100
|
fontSize: sizeConfig.labelFontSize,
|
|
81
101
|
lineHeight: sizeConfig.labelLineHeight,
|
|
82
102
|
fontFamily: "var(--font-secondary)",
|
|
83
|
-
color:
|
|
84
|
-
marginBottom: "var(--spacing-100)",
|
|
103
|
+
color: isDisabled ? "var(--fg-disabled)" : "var(--fg-neutral)",
|
|
85
104
|
};
|
|
86
|
-
}, [sizeConfig,
|
|
105
|
+
}, [sizeConfig, isDisabled]);
|
|
87
106
|
const prefixStyles = useMemo(() => {
|
|
107
|
+
let borderColor = "var(--border-strong-200)";
|
|
108
|
+
if (isDisabled) {
|
|
109
|
+
borderColor = "var(--border-disabled)";
|
|
110
|
+
}
|
|
111
|
+
else if (status === "error") {
|
|
112
|
+
borderColor = "var(--border-critical)";
|
|
113
|
+
}
|
|
114
|
+
else if (status === "active") {
|
|
115
|
+
borderColor = "var(--border-primary)";
|
|
116
|
+
}
|
|
117
|
+
else if (status === "hover") {
|
|
118
|
+
borderColor = "var(--border-neutral-primary)";
|
|
119
|
+
}
|
|
88
120
|
return {
|
|
89
121
|
fontSize: sizeConfig.fontSize,
|
|
90
122
|
lineHeight: sizeConfig.lineHeight,
|
|
91
123
|
fontFamily: "var(--font-secondary)",
|
|
92
124
|
color: "var(--fg-neutral-tertiary)",
|
|
93
125
|
paddingRight: "var(--spacing-100)",
|
|
94
|
-
borderRight: `var(--border-width-25) solid ${
|
|
126
|
+
borderRight: `var(--border-width-25) solid ${borderColor}`,
|
|
95
127
|
display: "flex",
|
|
96
128
|
alignItems: "center",
|
|
97
129
|
};
|
|
98
|
-
}, [sizeConfig, status]);
|
|
130
|
+
}, [sizeConfig, status, isDisabled]);
|
|
99
131
|
const errorContainerStyles = useMemo(() => {
|
|
100
132
|
return {
|
|
101
133
|
display: "flex",
|
|
@@ -122,32 +154,116 @@ export function Input({ label, size = "md", status = "default", showLabel = true
|
|
|
122
154
|
fontSize: sizeConfig.fontSize,
|
|
123
155
|
lineHeight: sizeConfig.lineHeight,
|
|
124
156
|
fontFamily: "var(--font-secondary)",
|
|
125
|
-
color:
|
|
157
|
+
color: isDisabled ? "var(--fg-disabled)" : "var(--fg-neutral)",
|
|
126
158
|
fontWeight: hasValue ? 500 : 400,
|
|
127
|
-
flex: iconOnly ? "none" : "1 0 0",
|
|
159
|
+
flex: iconOnly || !fullWidth ? "none" : "1 0 0",
|
|
128
160
|
minWidth: iconOnly ? "auto" : 0,
|
|
129
161
|
minHeight: iconOnly ? "auto" : 0,
|
|
130
162
|
border: "none",
|
|
131
163
|
background: "transparent",
|
|
132
164
|
outline: "none",
|
|
133
165
|
padding: 0,
|
|
134
|
-
width: "100%",
|
|
166
|
+
width: fullWidth ? "100%" : "auto",
|
|
167
|
+
caretColor: isDisabled ? "var(--fg-disabled)" : "var(--fg-primary)",
|
|
135
168
|
};
|
|
136
169
|
const [isHovered, setIsHovered] = useState(false);
|
|
170
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
171
|
+
const handleFocus = useCallback((e) => {
|
|
172
|
+
if (!isDisabled) {
|
|
173
|
+
setIsFocused(true);
|
|
174
|
+
}
|
|
175
|
+
rest.onFocus?.(e);
|
|
176
|
+
}, [isDisabled, rest]);
|
|
177
|
+
const handleBlur = useCallback((e) => {
|
|
178
|
+
setIsFocused(false);
|
|
179
|
+
rest.onBlur?.(e);
|
|
180
|
+
}, [rest]);
|
|
181
|
+
const handleClear = useCallback((e) => {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
if (!isDisabled && rest.onChange) {
|
|
184
|
+
const syntheticEvent = {
|
|
185
|
+
target: { value: "" },
|
|
186
|
+
};
|
|
187
|
+
rest.onChange(syntheticEvent);
|
|
188
|
+
}
|
|
189
|
+
}, [isDisabled, rest]);
|
|
190
|
+
const effectiveStatus = useMemo(() => {
|
|
191
|
+
if (isDisabled)
|
|
192
|
+
return status;
|
|
193
|
+
if (status === "error")
|
|
194
|
+
return status;
|
|
195
|
+
if (isFocused)
|
|
196
|
+
return "active";
|
|
197
|
+
return status;
|
|
198
|
+
}, [status, isDisabled, isFocused]);
|
|
137
199
|
const hoverBorderColor = useMemo(() => {
|
|
138
|
-
if (
|
|
200
|
+
if (isDisabled) {
|
|
201
|
+
return borderColor;
|
|
202
|
+
}
|
|
203
|
+
if (status === "error") {
|
|
204
|
+
return borderColor;
|
|
205
|
+
}
|
|
206
|
+
if (isFocused || status === "active") {
|
|
207
|
+
return "var(--border-primary)";
|
|
208
|
+
}
|
|
209
|
+
if (status === "hover") {
|
|
139
210
|
return borderColor;
|
|
140
211
|
}
|
|
141
212
|
return isHovered ? "var(--border-neutral-primary)" : borderColor;
|
|
142
|
-
}, [
|
|
213
|
+
}, [isDisabled, status, isHovered, isFocused, borderColor]);
|
|
143
214
|
const containerStylesWithHover = useMemo(() => {
|
|
144
215
|
return {
|
|
145
216
|
...inputContainerStyles,
|
|
146
217
|
border: `var(--border-width-25) solid ${hoverBorderColor}`,
|
|
218
|
+
...(isFocused && !isDisabled && status !== "error" ? {
|
|
219
|
+
boxShadow: `0 0 0 2px rgba(5, 109, 255, 0.2)`,
|
|
220
|
+
} : {}),
|
|
147
221
|
};
|
|
148
|
-
}, [inputContainerStyles, hoverBorderColor]);
|
|
222
|
+
}, [inputContainerStyles, hoverBorderColor, isFocused, isDisabled, status]);
|
|
149
223
|
if (iconOnly) {
|
|
150
|
-
return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: "100%" }, children: _jsxs("div", { style: containerStylesWithHover, onMouseEnter: () => !
|
|
224
|
+
return (_jsx("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: fullWidth ? "100%" : "fit-content" }, children: _jsxs("div", { style: containerStylesWithHover, onMouseEnter: () => !isDisabled && setIsHovered(true), onMouseLeave: () => setIsHovered(false), 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 }))] }) }));
|
|
151
225
|
}
|
|
152
|
-
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: containerStylesWithHover, onMouseEnter: () => !
|
|
226
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "var(--spacing-100)", width: fullWidth ? "100%" : "fit-content" }, children: [showLabel && label && (_jsx("label", { htmlFor: rest.id, style: labelStyles, children: label })), _jsxs("div", { style: containerStylesWithHover, onMouseEnter: () => !isDisabled && setIsHovered(true), onMouseLeave: () => setIsHovered(false), 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: isDisabled, readOnly: value != null && !rest.onChange, className: className, style: { ...inputStyles, ...style }, onFocus: handleFocus, onBlur: handleBlur, ...rest }), _jsx("style", { children: `
|
|
227
|
+
input[type="text"]::placeholder {
|
|
228
|
+
color: var(--fg-disabled) !important;
|
|
229
|
+
opacity: 1;
|
|
230
|
+
}
|
|
231
|
+
input[type="text"]:disabled::placeholder {
|
|
232
|
+
color: var(--fg-disabled) !important;
|
|
233
|
+
opacity: 1;
|
|
234
|
+
}
|
|
235
|
+
input[type="text"]:not(:placeholder-shown) {
|
|
236
|
+
color: var(--fg-neutral) !important;
|
|
237
|
+
}
|
|
238
|
+
input[type="text"]:disabled:not(:placeholder-shown) {
|
|
239
|
+
color: var(--fg-disabled) !important;
|
|
240
|
+
}
|
|
241
|
+
input[type="text"]:placeholder-shown:not(:disabled) {
|
|
242
|
+
color: transparent !important;
|
|
243
|
+
}
|
|
244
|
+
input[type="text"]:not(:disabled) {
|
|
245
|
+
caret-color: var(--fg-primary) !important;
|
|
246
|
+
}
|
|
247
|
+
input[type="text"]:disabled {
|
|
248
|
+
caret-color: var(--fg-disabled) !important;
|
|
249
|
+
}
|
|
250
|
+
` }), (endIcon || hasValue) && (_jsx("div", { onClick: !endIcon && hasValue && rest.onChange ? handleClear : undefined, style: {
|
|
251
|
+
color: "var(--fg-neutral-tertiary)",
|
|
252
|
+
flexShrink: 0,
|
|
253
|
+
display: "flex",
|
|
254
|
+
alignItems: "center",
|
|
255
|
+
justifyContent: "center",
|
|
256
|
+
cursor: !endIcon && hasValue && rest.onChange ? "pointer" : "default",
|
|
257
|
+
transition: "color 0.15s ease, transform 0.15s ease",
|
|
258
|
+
}, onMouseEnter: (e) => {
|
|
259
|
+
if (!endIcon && hasValue && rest.onChange) {
|
|
260
|
+
e.currentTarget.style.color = "var(--fg-neutral)";
|
|
261
|
+
e.currentTarget.style.transform = "scale(1.1)";
|
|
262
|
+
}
|
|
263
|
+
}, onMouseLeave: (e) => {
|
|
264
|
+
if (!endIcon && hasValue && rest.onChange) {
|
|
265
|
+
e.currentTarget.style.color = "var(--fg-neutral-tertiary)";
|
|
266
|
+
e.currentTarget.style.transform = "scale(1)";
|
|
267
|
+
}
|
|
268
|
+
}, children: endIcon || _jsx(CloseIcon, { size: sizeConfig.iconSize }) }))] }), status === "error" && (_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 })] }))] }));
|
|
153
269
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import type { CornerRadiusStep } from "./Button";
|
|
3
|
+
export type SelectSize = "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type SelectStatus = "default" | "hover" | "active" | "disabled";
|
|
5
|
+
export interface SelectOption {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface SelectProps extends Omit<ComponentPropsWithoutRef<"button">, "size" | "onClick" | "onSelect"> {
|
|
11
|
+
label?: string;
|
|
12
|
+
size?: SelectSize;
|
|
13
|
+
status?: SelectStatus;
|
|
14
|
+
showLabel?: boolean;
|
|
15
|
+
showStartIcon?: boolean;
|
|
16
|
+
showEndIcon?: boolean;
|
|
17
|
+
startIcon?: React.ReactNode;
|
|
18
|
+
endIcon?: React.ReactNode;
|
|
19
|
+
selectedValue?: string;
|
|
20
|
+
options?: SelectOption[];
|
|
21
|
+
onSelect?: (value: string) => void;
|
|
22
|
+
fullWidth?: boolean;
|
|
23
|
+
cornerRadius?: CornerRadiusStep;
|
|
24
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function Select({ label, size, status: statusProp, showLabel, showStartIcon, showEndIcon, startIcon, endIcon, selectedValue, options, onSelect, fullWidth, cornerRadius, className, style, id, ...rest }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA+C,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAGrG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEvE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAWD,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IAC5G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAChE;AAmED,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,IAAW,EACX,MAAM,EAAE,UAAU,EAClB,SAAgB,EAChB,aAAoB,EACpB,WAAkB,EAClB,SAAS,EACT,OAAO,EACP,aAAa,EACb,OAAY,EACZ,QAAQ,EACR,SAAgB,EAChB,YAAY,EACZ,SAAS,EACT,KAAK,EACL,EAAE,EACF,GAAG,IAAI,EACR,EAAE,WAAW,2CA4Tb"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useMemo, useState, useRef, useEffect, useId } from "react";
|
|
4
|
+
import { useThemeSafe } from "../providers/ThemeProvider";
|
|
5
|
+
import { ChevronDownIcon, CheckIcon, UserPersonIcon } from "../icons";
|
|
6
|
+
const CORNER_RADIUS_MAP = {
|
|
7
|
+
0: "var(--corner-radius-none)",
|
|
8
|
+
1: "var(--corner-radius-100)",
|
|
9
|
+
2: "var(--corner-radius-200)",
|
|
10
|
+
3: "var(--corner-radius-300)",
|
|
11
|
+
4: "var(--corner-radius-400)",
|
|
12
|
+
5: "var(--corner-radius-full)",
|
|
13
|
+
};
|
|
14
|
+
const SIZE_CONFIG = {
|
|
15
|
+
sm: {
|
|
16
|
+
height: "28px",
|
|
17
|
+
iconSize: 16,
|
|
18
|
+
fontSize: "var(--fonts-body-small-text-size)",
|
|
19
|
+
lineHeight: "var(--fonts-body-small-line-height)",
|
|
20
|
+
labelFontSize: "var(--fonts-body-extra-small-text-size)",
|
|
21
|
+
labelLineHeight: "var(--fonts-body-extra-small-line-height)",
|
|
22
|
+
paddingX: "var(--spacing-200)",
|
|
23
|
+
paddingY: "var(--spacing-100)",
|
|
24
|
+
borderRadius: "var(--corner-radius-100)",
|
|
25
|
+
gap: "var(--spacing-100)",
|
|
26
|
+
},
|
|
27
|
+
md: {
|
|
28
|
+
height: "36px",
|
|
29
|
+
iconSize: 16,
|
|
30
|
+
fontSize: "var(--fonts-body-small-text-size)",
|
|
31
|
+
lineHeight: "var(--fonts-body-small-line-height)",
|
|
32
|
+
labelFontSize: "var(--fonts-body-small-text-size)",
|
|
33
|
+
labelLineHeight: "var(--fonts-body-small-line-height)",
|
|
34
|
+
paddingX: "var(--spacing-300)",
|
|
35
|
+
paddingY: "var(--spacing-200)",
|
|
36
|
+
borderRadius: "var(--corner-radius-100)",
|
|
37
|
+
gap: "var(--spacing-100)",
|
|
38
|
+
},
|
|
39
|
+
lg: {
|
|
40
|
+
height: "48px",
|
|
41
|
+
iconSize: "sm",
|
|
42
|
+
fontSize: "var(--fonts-body-regular-text-size)",
|
|
43
|
+
lineHeight: "var(--fonts-body-regular-line-height)",
|
|
44
|
+
labelFontSize: "var(--fonts-body-regular-text-size)",
|
|
45
|
+
labelLineHeight: "var(--fonts-body-regular-line-height)",
|
|
46
|
+
paddingX: "var(--spacing-400)",
|
|
47
|
+
paddingY: "var(--spacing-300)",
|
|
48
|
+
borderRadius: "var(--corner-radius-100)",
|
|
49
|
+
gap: "var(--spacing-200)",
|
|
50
|
+
},
|
|
51
|
+
xl: {
|
|
52
|
+
height: "56px",
|
|
53
|
+
iconSize: "rg",
|
|
54
|
+
fontSize: "var(--fonts-body-regular-text-size)",
|
|
55
|
+
lineHeight: "var(--fonts-body-regular-line-height)",
|
|
56
|
+
labelFontSize: "var(--fonts-body-regular-text-size)",
|
|
57
|
+
labelLineHeight: "var(--fonts-body-regular-line-height)",
|
|
58
|
+
paddingX: "var(--spacing-450)",
|
|
59
|
+
paddingY: "var(--spacing-400)",
|
|
60
|
+
borderRadius: "var(--corner-radius-200)",
|
|
61
|
+
gap: "var(--spacing-200)",
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
export function Select({ label, size = "md", status: statusProp, showLabel = true, showStartIcon = true, showEndIcon = true, startIcon, endIcon, selectedValue, options = [], onSelect, fullWidth = true, cornerRadius, className, style, id, ...rest }) {
|
|
65
|
+
useThemeSafe();
|
|
66
|
+
const sizeConfig = SIZE_CONFIG[size];
|
|
67
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
68
|
+
const [internalStatus, setInternalStatus] = useState("default");
|
|
69
|
+
const [hoveredOptionIndex, setHoveredOptionIndex] = useState(null);
|
|
70
|
+
const selectRef = useRef(null);
|
|
71
|
+
// Use controlled status if provided, otherwise use internal state
|
|
72
|
+
const status = statusProp ?? (isOpen ? "active" : internalStatus);
|
|
73
|
+
const selectedOption = useMemo(() => {
|
|
74
|
+
return options.find((opt) => opt.value === selectedValue);
|
|
75
|
+
}, [options, selectedValue]);
|
|
76
|
+
const displayText = selectedOption?.label || "Selected Item";
|
|
77
|
+
const borderColor = useMemo(() => {
|
|
78
|
+
if (status === "disabled") {
|
|
79
|
+
return "var(--border-disabled)";
|
|
80
|
+
}
|
|
81
|
+
if (status === "active") {
|
|
82
|
+
return "var(--border-primary)";
|
|
83
|
+
}
|
|
84
|
+
if (status === "hover") {
|
|
85
|
+
return "var(--border-neutral-primary)";
|
|
86
|
+
}
|
|
87
|
+
return "var(--border-strong-200)";
|
|
88
|
+
}, [status]);
|
|
89
|
+
const containerStyles = useMemo(() => {
|
|
90
|
+
const borderRadius = cornerRadius !== undefined
|
|
91
|
+
? CORNER_RADIUS_MAP[cornerRadius]
|
|
92
|
+
: sizeConfig.borderRadius;
|
|
93
|
+
return {
|
|
94
|
+
display: "flex",
|
|
95
|
+
alignItems: "center",
|
|
96
|
+
border: `var(--border-width-25) solid ${borderColor}`,
|
|
97
|
+
backgroundColor: "var(--bg-page-primary)",
|
|
98
|
+
borderRadius,
|
|
99
|
+
gap: sizeConfig.gap,
|
|
100
|
+
paddingLeft: sizeConfig.paddingX,
|
|
101
|
+
paddingRight: sizeConfig.paddingX,
|
|
102
|
+
paddingTop: sizeConfig.paddingY,
|
|
103
|
+
paddingBottom: sizeConfig.paddingY,
|
|
104
|
+
width: fullWidth ? "100%" : "fit-content",
|
|
105
|
+
height: sizeConfig.height,
|
|
106
|
+
cursor: status === "disabled" ? "not-allowed" : "pointer",
|
|
107
|
+
transition: "border-color 0.15s ease",
|
|
108
|
+
opacity: status === "disabled" ? 0.6 : 1,
|
|
109
|
+
};
|
|
110
|
+
}, [sizeConfig, borderColor, fullWidth, cornerRadius]);
|
|
111
|
+
const labelStyles = useMemo(() => {
|
|
112
|
+
return {
|
|
113
|
+
fontSize: sizeConfig.labelFontSize,
|
|
114
|
+
lineHeight: sizeConfig.labelLineHeight,
|
|
115
|
+
fontFamily: "var(--font-secondary)",
|
|
116
|
+
color: status === "disabled" ? "var(--fg-disabled)" : "var(--fg-neutral)",
|
|
117
|
+
};
|
|
118
|
+
}, [sizeConfig, status]);
|
|
119
|
+
const textStyles = useMemo(() => {
|
|
120
|
+
return {
|
|
121
|
+
fontSize: sizeConfig.fontSize,
|
|
122
|
+
lineHeight: sizeConfig.lineHeight,
|
|
123
|
+
fontFamily: "var(--font-secondary)",
|
|
124
|
+
color: status === "disabled" ? "var(--fg-disabled)" : "var(--fg-neutral-secondary)",
|
|
125
|
+
flex: "1 0 0",
|
|
126
|
+
minWidth: 0,
|
|
127
|
+
textAlign: "left",
|
|
128
|
+
};
|
|
129
|
+
}, [sizeConfig, status]);
|
|
130
|
+
const handleClick = () => {
|
|
131
|
+
if (status === "disabled")
|
|
132
|
+
return;
|
|
133
|
+
if (!statusProp) {
|
|
134
|
+
setIsOpen(!isOpen);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const handleOptionClick = (value) => {
|
|
138
|
+
onSelect?.(value);
|
|
139
|
+
if (!statusProp) {
|
|
140
|
+
setIsOpen(false);
|
|
141
|
+
setInternalStatus("default");
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const handleMouseEnter = () => {
|
|
145
|
+
if (status === "disabled")
|
|
146
|
+
return;
|
|
147
|
+
if (!statusProp && !isOpen) {
|
|
148
|
+
setInternalStatus("hover");
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const handleMouseLeave = () => {
|
|
152
|
+
if (!statusProp && !isOpen) {
|
|
153
|
+
setInternalStatus("default");
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
// Close dropdown when clicking outside
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const handleClickOutside = (event) => {
|
|
159
|
+
if (selectRef.current && !selectRef.current.contains(event.target)) {
|
|
160
|
+
if (!statusProp) {
|
|
161
|
+
setIsOpen(false);
|
|
162
|
+
setInternalStatus("default");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
if (isOpen) {
|
|
167
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
168
|
+
}
|
|
169
|
+
return () => {
|
|
170
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
171
|
+
};
|
|
172
|
+
}, [isOpen, statusProp]);
|
|
173
|
+
const dropdownStyles = useMemo(() => {
|
|
174
|
+
if (!isOpen && status !== "active")
|
|
175
|
+
return { display: "none" };
|
|
176
|
+
const baseStyles = {
|
|
177
|
+
position: "absolute",
|
|
178
|
+
top: "100%",
|
|
179
|
+
left: 0,
|
|
180
|
+
width: "100%",
|
|
181
|
+
marginTop: "var(--spacing-100)",
|
|
182
|
+
display: "flex",
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
backgroundColor: "var(--bg-page-primary)",
|
|
185
|
+
border: "var(--border-width-25) solid var(--border-strong-100)",
|
|
186
|
+
borderRadius: cornerRadius !== undefined
|
|
187
|
+
? CORNER_RADIUS_MAP[cornerRadius]
|
|
188
|
+
: sizeConfig.borderRadius,
|
|
189
|
+
overflow: "hidden",
|
|
190
|
+
zIndex: 1000,
|
|
191
|
+
};
|
|
192
|
+
return baseStyles;
|
|
193
|
+
}, [isOpen, status, sizeConfig, cornerRadius]);
|
|
194
|
+
const getOptionStyles = (isSelected, isHovered, isLast, isFirst) => {
|
|
195
|
+
const borderRadius = cornerRadius !== undefined
|
|
196
|
+
? CORNER_RADIUS_MAP[cornerRadius]
|
|
197
|
+
: sizeConfig.borderRadius;
|
|
198
|
+
const baseStyles = {
|
|
199
|
+
display: "flex",
|
|
200
|
+
alignItems: "center",
|
|
201
|
+
gap: size === "sm" || size === "md" ? "var(--spacing-100)" : "var(--spacing-200)",
|
|
202
|
+
padding: size === "sm" || size === "md" ? "var(--spacing-200)" : "var(--spacing-200) var(--spacing-200) var(--spacing-300) var(--spacing-200)",
|
|
203
|
+
cursor: "pointer",
|
|
204
|
+
border: "none",
|
|
205
|
+
borderTop: isFirst ? "var(--border-width-25) solid var(--border-strong-100)" : "none",
|
|
206
|
+
borderLeft: "var(--border-width-25) solid var(--border-strong-100)",
|
|
207
|
+
borderRight: "var(--border-width-25) solid var(--border-strong-100)",
|
|
208
|
+
borderBottom: isLast ? "var(--border-width-25) solid var(--border-strong-100)" : "var(--border-width-25) solid var(--border-strong-100)",
|
|
209
|
+
borderTopLeftRadius: isFirst ? borderRadius : 0,
|
|
210
|
+
borderTopRightRadius: isFirst ? borderRadius : 0,
|
|
211
|
+
borderBottomLeftRadius: isLast ? borderRadius : 0,
|
|
212
|
+
borderBottomRightRadius: isLast ? borderRadius : 0,
|
|
213
|
+
backgroundColor: isSelected ? "var(--bg-primary-tonal)" : "var(--bg-page-primary)",
|
|
214
|
+
color: isSelected ? "var(--fg-primary-on-tonal)" : "var(--fg-neutral-tertiary)",
|
|
215
|
+
fontFamily: "var(--font-secondary)",
|
|
216
|
+
fontSize: size === "sm" || size === "md" ? "var(--body-extra-small-text-size)" : size === "lg" ? "var(--body-small-text-size)" : "var(--body-regular-text-size)",
|
|
217
|
+
lineHeight: size === "sm" || size === "md" ? "var(--body-extra-small-line-height)" : size === "lg" ? "var(--body-small-line-height)" : "var(--body-regular-line-height)",
|
|
218
|
+
transition: "background-color 0.15s ease, color 0.15s ease",
|
|
219
|
+
};
|
|
220
|
+
if (isHovered && !isSelected) {
|
|
221
|
+
baseStyles.backgroundColor = "var(--bg-page-secondary)";
|
|
222
|
+
}
|
|
223
|
+
return baseStyles;
|
|
224
|
+
};
|
|
225
|
+
const generatedId = useId();
|
|
226
|
+
const selectId = id || generatedId;
|
|
227
|
+
return (_jsxs("div", { ref: selectRef, style: {
|
|
228
|
+
display: "flex",
|
|
229
|
+
flexDirection: "column",
|
|
230
|
+
gap: "var(--spacing-100)",
|
|
231
|
+
width: fullWidth ? "100%" : "fit-content",
|
|
232
|
+
position: "relative",
|
|
233
|
+
}, children: [showLabel && label && (_jsx("label", { htmlFor: selectId, style: labelStyles, children: label })), _jsxs("button", { id: selectId, type: "button", onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: { ...containerStyles, ...style }, className: className, "aria-expanded": isOpen || status === "active", "aria-haspopup": "listbox", "aria-disabled": status === "disabled", "aria-labelledby": showLabel && label ? undefined : undefined, disabled: status === "disabled", ...rest, children: [showStartIcon && (_jsx("div", { style: {
|
|
234
|
+
color: status === "disabled" ? "var(--fg-disabled)" : "var(--fg-neutral)",
|
|
235
|
+
flexShrink: 0,
|
|
236
|
+
display: "flex",
|
|
237
|
+
alignItems: "center",
|
|
238
|
+
justifyContent: "center",
|
|
239
|
+
}, children: startIcon ? (React.isValidElement(startIcon)
|
|
240
|
+
? React.cloneElement(startIcon, { size: sizeConfig.iconSize })
|
|
241
|
+
: startIcon) : (_jsx(UserPersonIcon, { size: sizeConfig.iconSize })) })), _jsx("span", { style: textStyles, children: displayText }), showEndIcon && (_jsx("div", { style: {
|
|
242
|
+
color: status === "disabled" ? "var(--fg-disabled)" : "var(--fg-neutral-tertiary)",
|
|
243
|
+
flexShrink: 0,
|
|
244
|
+
display: "flex",
|
|
245
|
+
alignItems: "center",
|
|
246
|
+
justifyContent: "center",
|
|
247
|
+
transform: isOpen || status === "active" ? "rotate(180deg)" : "rotate(0deg)",
|
|
248
|
+
transition: "transform 0.15s ease",
|
|
249
|
+
}, children: endIcon ? (React.isValidElement(endIcon)
|
|
250
|
+
? React.cloneElement(endIcon, { size: sizeConfig.iconSize })
|
|
251
|
+
: endIcon) : (_jsx(ChevronDownIcon, { size: sizeConfig.iconSize })) }))] }), (isOpen || status === "active") && status !== "disabled" && options.length > 0 && (_jsx("div", { style: dropdownStyles, role: "listbox", children: options.map((option, index) => {
|
|
252
|
+
const isSelected = option.value === selectedValue;
|
|
253
|
+
const isHovered = hoveredOptionIndex === index;
|
|
254
|
+
const isLast = index === options.length - 1;
|
|
255
|
+
const isFirst = index === 0;
|
|
256
|
+
return (_jsxs("button", { type: "button", role: "option", "aria-selected": isSelected, style: getOptionStyles(isSelected, isHovered, isLast, isFirst), onClick: () => handleOptionClick(option.value), onMouseEnter: () => setHoveredOptionIndex(index), onMouseLeave: () => setHoveredOptionIndex(null), children: [option.icon && (_jsx("div", { style: {
|
|
257
|
+
display: "flex",
|
|
258
|
+
alignItems: "center",
|
|
259
|
+
justifyContent: "center",
|
|
260
|
+
...(typeof sizeConfig.iconSize === "number"
|
|
261
|
+
? { width: `${sizeConfig.iconSize}px`, height: `${sizeConfig.iconSize}px` }
|
|
262
|
+
: { width: `var(--icon-size-${sizeConfig.iconSize})`, height: `var(--icon-size-${sizeConfig.iconSize})` }),
|
|
263
|
+
flexShrink: 0,
|
|
264
|
+
color: isSelected ? "var(--fg-primary-on-tonal)" : "var(--fg-neutral-tertiary)",
|
|
265
|
+
}, children: option.icon })), _jsx("span", { style: { flex: "1 0 0", minWidth: 0, textAlign: "left" }, children: option.label }), isSelected && (_jsx("div", { style: {
|
|
266
|
+
display: "flex",
|
|
267
|
+
alignItems: "center",
|
|
268
|
+
justifyContent: "center",
|
|
269
|
+
...(typeof sizeConfig.iconSize === "number"
|
|
270
|
+
? { width: `${sizeConfig.iconSize}px`, height: `${sizeConfig.iconSize}px` }
|
|
271
|
+
: { width: `var(--icon-size-${sizeConfig.iconSize})`, height: `var(--icon-size-${sizeConfig.iconSize})` }),
|
|
272
|
+
flexShrink: 0,
|
|
273
|
+
color: "var(--fg-primary-on-tonal)",
|
|
274
|
+
}, children: _jsx(CheckIcon, { size: sizeConfig.iconSize }) }))] }, option.value));
|
|
275
|
+
}) }))] }));
|
|
276
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentPropsWithRef } from "react";
|
|
2
|
+
export type SliderStatus = "default" | "hover" | "active" | "disabled";
|
|
3
|
+
export interface SliderProps extends Omit<ComponentPropsWithRef<"div">, "onChange"> {
|
|
4
|
+
value?: number;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
range?: boolean;
|
|
9
|
+
rangeValue?: [number, number];
|
|
10
|
+
onChange?: (value: number | [number, number]) => void;
|
|
11
|
+
showTooltip?: boolean;
|
|
12
|
+
showSteps?: boolean;
|
|
13
|
+
stepCount?: number;
|
|
14
|
+
stepLabels?: string[];
|
|
15
|
+
showLabel?: boolean;
|
|
16
|
+
label?: string;
|
|
17
|
+
status?: SliderStatus;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function Slider({ value, min, max, step, range, rangeValue, onChange, showTooltip, showSteps, stepCount, stepLabels, showLabel, label, status: statusProp, disabled, className, style, onMouseEnter, onMouseLeave, onFocus, onBlur, ...rest }: SliderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=Slider.d.ts.map
|