@officesdk/design 0.1.0
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/README.md +54 -0
- package/dist/components/index.d.mts +936 -0
- package/dist/components/index.d.ts +936 -0
- package/dist/components/index.js +2320 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +2293 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/icons/index.d.mts +93 -0
- package/dist/icons/index.d.ts +93 -0
- package/dist/icons/index.js +293 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/index.mjs +224 -0
- package/dist/icons/index.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/theme/index.d.mts +9 -0
- package/dist/theme/index.d.ts +9 -0
- package/dist/theme/index.js +1264 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.mjs +1261 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +18 -0
- package/dist/utils/index.d.ts +18 -0
- package/dist/utils/index.js +54 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +49 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,2293 @@
|
|
|
1
|
+
import React11, { forwardRef, useState, createContext, useRef, useCallback, useEffect, useContext } from 'react';
|
|
2
|
+
import styled3, { createGlobalStyle, ThemeProvider } from 'styled-components';
|
|
3
|
+
import RcTooltip from 'rc-tooltip';
|
|
4
|
+
import 'rc-tooltip/assets/bootstrap.css';
|
|
5
|
+
|
|
6
|
+
// src/Button/Button.tsx
|
|
7
|
+
var IconWrapper = styled3.span`
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
|
|
13
|
+
${({ $size, $position, theme }) => {
|
|
14
|
+
const sizeConfig = theme.components.button[$size || "medium"];
|
|
15
|
+
const marginSide = $position === "before" ? "margin-right" : "margin-left";
|
|
16
|
+
return `
|
|
17
|
+
width: ${sizeConfig.iconSize.width};
|
|
18
|
+
height: ${sizeConfig.iconSize.height};
|
|
19
|
+
${marginSide}: ${sizeConfig.iconGap};
|
|
20
|
+
|
|
21
|
+
svg, img {
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
display: block;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
}}
|
|
28
|
+
`;
|
|
29
|
+
var StyledButton = styled3.button`
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
outline: none;
|
|
35
|
+
border: none;
|
|
36
|
+
width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
|
|
37
|
+
|
|
38
|
+
/* Size variants */
|
|
39
|
+
${({ $size, $isIconOnly, theme }) => {
|
|
40
|
+
const sizeConfig = theme.components.button[$size || "medium"];
|
|
41
|
+
if ($isIconOnly) {
|
|
42
|
+
return `
|
|
43
|
+
padding: 0;
|
|
44
|
+
width: ${sizeConfig.height};
|
|
45
|
+
height: ${sizeConfig.height};
|
|
46
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
return `
|
|
50
|
+
padding: ${sizeConfig.padding};
|
|
51
|
+
font-size: ${sizeConfig.fontSize};
|
|
52
|
+
line-height: ${sizeConfig.lineHeight};
|
|
53
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
54
|
+
min-height: ${sizeConfig.height};
|
|
55
|
+
`;
|
|
56
|
+
}}
|
|
57
|
+
|
|
58
|
+
/* Variant and color type styles */
|
|
59
|
+
${({ $variant, $colorType, $isIconOnly, $iconBordered, theme }) => {
|
|
60
|
+
if ($variant === "icon" || $isIconOnly) {
|
|
61
|
+
const baseVariant = $iconBordered ? "outlined" : "text";
|
|
62
|
+
const styles2 = theme.components.button[baseVariant]["default"];
|
|
63
|
+
return `
|
|
64
|
+
background: ${styles2.background};
|
|
65
|
+
color: ${styles2.color};
|
|
66
|
+
border: 1px solid ${styles2.borderColor};
|
|
67
|
+
box-shadow: ${styles2.boxShadow};
|
|
68
|
+
|
|
69
|
+
&:hover:not(:disabled) {
|
|
70
|
+
background: ${styles2.backgroundHover};
|
|
71
|
+
color: ${styles2.colorHover};
|
|
72
|
+
border-color: ${styles2.borderColorHover};
|
|
73
|
+
box-shadow: ${styles2.boxShadowHover};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:active:not(:disabled) {
|
|
77
|
+
background: ${styles2.backgroundActive};
|
|
78
|
+
color: ${styles2.colorActive};
|
|
79
|
+
border-color: ${styles2.borderColorActive};
|
|
80
|
+
box-shadow: ${styles2.boxShadowActive};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:disabled {
|
|
84
|
+
background: ${styles2.backgroundDisabled};
|
|
85
|
+
color: ${styles2.colorDisabled};
|
|
86
|
+
border-color: ${styles2.borderColorDisabled};
|
|
87
|
+
box-shadow: ${styles2.boxShadowDisabled};
|
|
88
|
+
cursor: not-allowed;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
const variant = $variant || "solid";
|
|
93
|
+
const colorType = $colorType || "default";
|
|
94
|
+
if (colorType === "status" && variant !== "text") {
|
|
95
|
+
console.warn(`colorType 'status' is only available for 'text' variant. Falling back to 'default'.`);
|
|
96
|
+
}
|
|
97
|
+
const effectiveColorType = colorType === "status" && variant !== "text" ? "default" : colorType;
|
|
98
|
+
const styles = theme.components.button[variant][effectiveColorType];
|
|
99
|
+
return `
|
|
100
|
+
background: ${styles.background};
|
|
101
|
+
color: ${styles.color};
|
|
102
|
+
border: 1px solid ${styles.borderColor};
|
|
103
|
+
box-shadow: ${styles.boxShadow};
|
|
104
|
+
font-weight: ${styles.fontWeight};
|
|
105
|
+
|
|
106
|
+
&:hover:not(:disabled) {
|
|
107
|
+
background: ${styles.backgroundHover};
|
|
108
|
+
color: ${styles.colorHover};
|
|
109
|
+
border-color: ${styles.borderColorHover};
|
|
110
|
+
box-shadow: ${styles.boxShadowHover};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&:active:not(:disabled) {
|
|
114
|
+
background: ${styles.backgroundActive};
|
|
115
|
+
color: ${styles.colorActive};
|
|
116
|
+
border-color: ${styles.borderColorActive};
|
|
117
|
+
box-shadow: ${styles.boxShadowActive};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&:disabled {
|
|
121
|
+
background: ${styles.backgroundDisabled};
|
|
122
|
+
color: ${styles.colorDisabled};
|
|
123
|
+
border-color: ${styles.borderColorDisabled};
|
|
124
|
+
box-shadow: ${styles.boxShadowDisabled};
|
|
125
|
+
cursor: not-allowed;
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
}}
|
|
129
|
+
`;
|
|
130
|
+
var Button = ({
|
|
131
|
+
variant = "solid",
|
|
132
|
+
colorType = "default",
|
|
133
|
+
size = "medium",
|
|
134
|
+
disabled = false,
|
|
135
|
+
loading = false,
|
|
136
|
+
fullWidth = false,
|
|
137
|
+
iconBefore,
|
|
138
|
+
iconAfter,
|
|
139
|
+
iconBordered = false,
|
|
140
|
+
onClick,
|
|
141
|
+
children,
|
|
142
|
+
className,
|
|
143
|
+
style
|
|
144
|
+
}) => {
|
|
145
|
+
const isIconOnly = variant === "icon" || !children && !!(iconBefore || iconAfter);
|
|
146
|
+
const iconOnlyContent = iconBefore || iconAfter;
|
|
147
|
+
return /* @__PURE__ */ React11.createElement(
|
|
148
|
+
StyledButton,
|
|
149
|
+
{
|
|
150
|
+
$variant: variant,
|
|
151
|
+
$colorType: colorType,
|
|
152
|
+
$size: size,
|
|
153
|
+
$fullWidth: fullWidth,
|
|
154
|
+
$isIconOnly: isIconOnly,
|
|
155
|
+
$iconBordered: iconBordered,
|
|
156
|
+
disabled: disabled || loading,
|
|
157
|
+
onClick,
|
|
158
|
+
className,
|
|
159
|
+
style
|
|
160
|
+
},
|
|
161
|
+
loading ? /* @__PURE__ */ React11.createElement(React11.Fragment, null, "Loading...") : isIconOnly ? iconOnlyContent : /* @__PURE__ */ React11.createElement(React11.Fragment, null, iconBefore && /* @__PURE__ */ React11.createElement(IconWrapper, { $size: size, $position: "before" }, iconBefore), children, iconAfter && /* @__PURE__ */ React11.createElement(IconWrapper, { $size: size, $position: "after" }, iconAfter))
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
Button.displayName = "Button";
|
|
165
|
+
var SliderContainer = styled3.div`
|
|
166
|
+
position: relative;
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
width: 100%;
|
|
170
|
+
height: 18px;
|
|
171
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
172
|
+
user-select: none;
|
|
173
|
+
`;
|
|
174
|
+
var SliderTrack = styled3.div`
|
|
175
|
+
position: absolute;
|
|
176
|
+
left: 0;
|
|
177
|
+
right: 0;
|
|
178
|
+
height: 2px;
|
|
179
|
+
background: ${({ theme }) => theme.colors.palettes.transparency["20"]};
|
|
180
|
+
border-radius: 1000px;
|
|
181
|
+
top: 50%;
|
|
182
|
+
transform: translateY(-50%);
|
|
183
|
+
`;
|
|
184
|
+
var SliderFill = styled3.div`
|
|
185
|
+
position: absolute;
|
|
186
|
+
left: 0;
|
|
187
|
+
height: 2px;
|
|
188
|
+
border-radius: 1px;
|
|
189
|
+
top: 50%;
|
|
190
|
+
transform: translateY(-50%);
|
|
191
|
+
width: ${({ $percentage }) => $percentage}%;
|
|
192
|
+
background: ${({ $disabled, theme }) => $disabled ? theme.colors.palettes.transparency["10"] : theme.colors.palettes.gray["100"]};
|
|
193
|
+
`;
|
|
194
|
+
var SliderThumb = styled3.div`
|
|
195
|
+
position: absolute;
|
|
196
|
+
width: 10px;
|
|
197
|
+
height: 10px;
|
|
198
|
+
border-radius: 50%;
|
|
199
|
+
background: ${({ $disabled, theme }) => $disabled ? theme.colors.palettes.transparency["30"] : theme.colors.palettes.blue["5"]};
|
|
200
|
+
left: ${({ $percentage }) => $percentage}%;
|
|
201
|
+
top: 50%;
|
|
202
|
+
transform: translate(-50%, -50%);
|
|
203
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "grab"};
|
|
204
|
+
transition: ${({ $isDragging }) => $isDragging ? "none" : "left 0.1s ease"};
|
|
205
|
+
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
|
|
206
|
+
|
|
207
|
+
${({ $disabled }) => !$disabled && `
|
|
208
|
+
&:hover {
|
|
209
|
+
box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.15);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
&:active {
|
|
213
|
+
cursor: grabbing;
|
|
214
|
+
box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.2);
|
|
215
|
+
}
|
|
216
|
+
`}
|
|
217
|
+
`;
|
|
218
|
+
var Slider = ({
|
|
219
|
+
value: controlledValue,
|
|
220
|
+
defaultValue = 0,
|
|
221
|
+
min = 0,
|
|
222
|
+
max = 100,
|
|
223
|
+
step = 1,
|
|
224
|
+
disabled = false,
|
|
225
|
+
onChange,
|
|
226
|
+
onDragStart,
|
|
227
|
+
onDragEnd,
|
|
228
|
+
className,
|
|
229
|
+
style
|
|
230
|
+
}) => {
|
|
231
|
+
const [internalValue, setInternalValue] = useState(
|
|
232
|
+
controlledValue ?? defaultValue
|
|
233
|
+
);
|
|
234
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
235
|
+
const containerRef = useRef(null);
|
|
236
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
237
|
+
const percentage = (value - min) / (max - min) * 100;
|
|
238
|
+
const updateValue = useCallback(
|
|
239
|
+
(clientX) => {
|
|
240
|
+
if (!containerRef.current || disabled) return;
|
|
241
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
242
|
+
const offsetX = clientX - rect.left;
|
|
243
|
+
const newPercentage = Math.max(0, Math.min(100, offsetX / rect.width * 100));
|
|
244
|
+
const rawValue = newPercentage / 100 * (max - min) + min;
|
|
245
|
+
const steppedValue = Math.round(rawValue / step) * step;
|
|
246
|
+
const clampedValue = Math.max(min, Math.min(max, steppedValue));
|
|
247
|
+
if (controlledValue === void 0) {
|
|
248
|
+
setInternalValue(clampedValue);
|
|
249
|
+
}
|
|
250
|
+
onChange?.(clampedValue);
|
|
251
|
+
},
|
|
252
|
+
[min, max, step, disabled, controlledValue, onChange]
|
|
253
|
+
);
|
|
254
|
+
const handleMouseDown = useCallback(
|
|
255
|
+
(e) => {
|
|
256
|
+
if (disabled) return;
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
setIsDragging(true);
|
|
259
|
+
onDragStart?.();
|
|
260
|
+
updateValue(e.clientX);
|
|
261
|
+
},
|
|
262
|
+
[disabled, onDragStart, updateValue]
|
|
263
|
+
);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (!isDragging) return;
|
|
266
|
+
const handleMouseMove = (e) => {
|
|
267
|
+
updateValue(e.clientX);
|
|
268
|
+
};
|
|
269
|
+
const handleMouseUp = () => {
|
|
270
|
+
setIsDragging(false);
|
|
271
|
+
onDragEnd?.();
|
|
272
|
+
};
|
|
273
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
274
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
275
|
+
return () => {
|
|
276
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
277
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
278
|
+
};
|
|
279
|
+
}, [isDragging, updateValue, onDragEnd]);
|
|
280
|
+
const handleKeyDown = useCallback(
|
|
281
|
+
(e) => {
|
|
282
|
+
if (disabled) return;
|
|
283
|
+
let newValue = value;
|
|
284
|
+
switch (e.key) {
|
|
285
|
+
case "ArrowLeft":
|
|
286
|
+
case "ArrowDown":
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
newValue = Math.max(min, value - step);
|
|
289
|
+
break;
|
|
290
|
+
case "ArrowRight":
|
|
291
|
+
case "ArrowUp":
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
newValue = Math.min(max, value + step);
|
|
294
|
+
break;
|
|
295
|
+
case "Home":
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
newValue = min;
|
|
298
|
+
break;
|
|
299
|
+
case "End":
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
newValue = max;
|
|
302
|
+
break;
|
|
303
|
+
default:
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (controlledValue === void 0) {
|
|
307
|
+
setInternalValue(newValue);
|
|
308
|
+
}
|
|
309
|
+
onChange?.(newValue);
|
|
310
|
+
},
|
|
311
|
+
[disabled, value, min, max, step, controlledValue, onChange]
|
|
312
|
+
);
|
|
313
|
+
return /* @__PURE__ */ React11.createElement(
|
|
314
|
+
SliderContainer,
|
|
315
|
+
{
|
|
316
|
+
ref: containerRef,
|
|
317
|
+
$disabled: disabled,
|
|
318
|
+
className,
|
|
319
|
+
style,
|
|
320
|
+
onMouseDown: handleMouseDown,
|
|
321
|
+
onKeyDown: handleKeyDown,
|
|
322
|
+
tabIndex: disabled ? -1 : 0,
|
|
323
|
+
role: "slider",
|
|
324
|
+
"aria-valuemin": min,
|
|
325
|
+
"aria-valuemax": max,
|
|
326
|
+
"aria-valuenow": value,
|
|
327
|
+
"aria-disabled": disabled
|
|
328
|
+
},
|
|
329
|
+
/* @__PURE__ */ React11.createElement(SliderTrack, { $disabled: disabled }),
|
|
330
|
+
/* @__PURE__ */ React11.createElement(SliderFill, { $percentage: percentage, $disabled: disabled }),
|
|
331
|
+
/* @__PURE__ */ React11.createElement(
|
|
332
|
+
SliderThumb,
|
|
333
|
+
{
|
|
334
|
+
$percentage: percentage,
|
|
335
|
+
$disabled: disabled,
|
|
336
|
+
$isDragging: isDragging
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
);
|
|
340
|
+
};
|
|
341
|
+
Slider.displayName = "Slider";
|
|
342
|
+
|
|
343
|
+
// src/Button/SpinButton.tsx
|
|
344
|
+
var SpinButtonWrapper = styled3.div`
|
|
345
|
+
display: inline-flex;
|
|
346
|
+
align-items: center;
|
|
347
|
+
gap: ${({ $showSlider }) => $showSlider ? "0" : "0"};
|
|
348
|
+
width: ${({ $showSlider }) => $showSlider ? "100%" : "auto"};
|
|
349
|
+
`;
|
|
350
|
+
var SliderWrapper = styled3.div`
|
|
351
|
+
flex: 1;
|
|
352
|
+
display: flex;
|
|
353
|
+
align-items: center;
|
|
354
|
+
padding: ${({ $size }) => $size === "small" ? "7px 0" : "7px 0"};
|
|
355
|
+
padding-right: ${({ $size }) => $size === "small" ? "83px" : "72px"};
|
|
356
|
+
min-width: 0;
|
|
357
|
+
`;
|
|
358
|
+
var SpinButtonContainer = styled3.div`
|
|
359
|
+
display: inline-flex;
|
|
360
|
+
align-items: center;
|
|
361
|
+
background: white;
|
|
362
|
+
border: 1px solid;
|
|
363
|
+
border-radius: 2px;
|
|
364
|
+
flex-shrink: 0;
|
|
365
|
+
|
|
366
|
+
${({ $size }) => $size === "small" ? `
|
|
367
|
+
height: 24px;
|
|
368
|
+
width: 72px;
|
|
369
|
+
` : `
|
|
370
|
+
height: 32px;
|
|
371
|
+
width: 80px;
|
|
372
|
+
`}
|
|
373
|
+
|
|
374
|
+
${({ $disabled, $alert, $isFocused, theme }) => {
|
|
375
|
+
if ($disabled) {
|
|
376
|
+
return `
|
|
377
|
+
border-color: ${theme.colors.palettes.transparency["10"]};
|
|
378
|
+
cursor: not-allowed;
|
|
379
|
+
`;
|
|
380
|
+
}
|
|
381
|
+
if ($alert) {
|
|
382
|
+
return `
|
|
383
|
+
border-color: ${theme.colors.palettes.red["6"]};
|
|
384
|
+
`;
|
|
385
|
+
}
|
|
386
|
+
if ($isFocused) {
|
|
387
|
+
return `
|
|
388
|
+
border-color: ${theme.colors.palettes.transparency["30"]};
|
|
389
|
+
box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.04);
|
|
390
|
+
`;
|
|
391
|
+
}
|
|
392
|
+
return `
|
|
393
|
+
border-color: ${theme.colors.palettes.transparency["10"]};
|
|
394
|
+
|
|
395
|
+
&:hover {
|
|
396
|
+
border-color: ${theme.colors.palettes.transparency["20"]};
|
|
397
|
+
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.04);
|
|
398
|
+
}
|
|
399
|
+
`;
|
|
400
|
+
}}
|
|
401
|
+
`;
|
|
402
|
+
var InputWrapper = styled3.div`
|
|
403
|
+
flex: 1;
|
|
404
|
+
display: flex;
|
|
405
|
+
align-items: center;
|
|
406
|
+
padding: 0 8px;
|
|
407
|
+
min-width: 0;
|
|
408
|
+
`;
|
|
409
|
+
var StyledInput = styled3.input`
|
|
410
|
+
width: 100%;
|
|
411
|
+
border: none;
|
|
412
|
+
outline: none;
|
|
413
|
+
background: transparent;
|
|
414
|
+
font-family: 'PingFang SC', sans-serif;
|
|
415
|
+
font-weight: 400;
|
|
416
|
+
line-height: 20px;
|
|
417
|
+
padding: 0;
|
|
418
|
+
margin: 0;
|
|
419
|
+
|
|
420
|
+
${({ $size }) => $size === "small" ? `
|
|
421
|
+
font-size: 12px;
|
|
422
|
+
` : `
|
|
423
|
+
font-size: 13px;
|
|
424
|
+
`}
|
|
425
|
+
|
|
426
|
+
${({ $disabled, theme }) => $disabled ? `
|
|
427
|
+
color: ${theme.colors.palettes.transparency["30"]};
|
|
428
|
+
cursor: not-allowed;
|
|
429
|
+
` : `
|
|
430
|
+
color: ${theme.colors.palettes.gray["120"]};
|
|
431
|
+
`}
|
|
432
|
+
|
|
433
|
+
&::placeholder {
|
|
434
|
+
color: ${({ theme }) => theme.colors.palettes.transparency["30"]};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* Remove number input arrows */
|
|
438
|
+
&::-webkit-inner-spin-button,
|
|
439
|
+
&::-webkit-outer-spin-button {
|
|
440
|
+
-webkit-appearance: none;
|
|
441
|
+
margin: 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
&[type='number'] {
|
|
445
|
+
-moz-appearance: textfield;
|
|
446
|
+
}
|
|
447
|
+
`;
|
|
448
|
+
var ButtonGroup = styled3.div`
|
|
449
|
+
display: flex;
|
|
450
|
+
flex-direction: column;
|
|
451
|
+
height: 100%;
|
|
452
|
+
border-left: 1px solid;
|
|
453
|
+
flex-shrink: 0;
|
|
454
|
+
|
|
455
|
+
${({ $disabled, $alert, theme }) => {
|
|
456
|
+
if ($disabled) {
|
|
457
|
+
return `border-color: ${theme.colors.palettes.transparency["10"]};`;
|
|
458
|
+
}
|
|
459
|
+
if ($alert) {
|
|
460
|
+
return `border-color: ${theme.colors.palettes.red["6"]};`;
|
|
461
|
+
}
|
|
462
|
+
return `border-color: ${theme.colors.palettes.transparency["10"]};`;
|
|
463
|
+
}}
|
|
464
|
+
`;
|
|
465
|
+
var StepButton = styled3.button`
|
|
466
|
+
flex: 1 1 50%;
|
|
467
|
+
display: flex;
|
|
468
|
+
align-items: center;
|
|
469
|
+
justify-content: center;
|
|
470
|
+
border: none;
|
|
471
|
+
background: transparent;
|
|
472
|
+
cursor: pointer;
|
|
473
|
+
padding: 1px 8px;
|
|
474
|
+
outline: none;
|
|
475
|
+
min-height: 0;
|
|
476
|
+
overflow: hidden;
|
|
477
|
+
|
|
478
|
+
${({ $position, $alert, $disabled, theme }) => {
|
|
479
|
+
if ($position === "up") {
|
|
480
|
+
return `
|
|
481
|
+
border-bottom: 1px solid ${$disabled ? theme.colors.palettes.transparency["10"] : $alert ? theme.colors.palettes.red["6"] : theme.colors.palettes.transparency["10"]};
|
|
482
|
+
`;
|
|
483
|
+
}
|
|
484
|
+
return "";
|
|
485
|
+
}}
|
|
486
|
+
|
|
487
|
+
${({ $disabled, theme }) => {
|
|
488
|
+
if ($disabled) {
|
|
489
|
+
return `
|
|
490
|
+
cursor: not-allowed;
|
|
491
|
+
opacity: 0.4;
|
|
492
|
+
`;
|
|
493
|
+
}
|
|
494
|
+
return `
|
|
495
|
+
&:hover {
|
|
496
|
+
background-color: ${theme.colors.palettes.transparency["5"]};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
&:active {
|
|
500
|
+
background-color: ${theme.colors.palettes.transparency["10"]};
|
|
501
|
+
}
|
|
502
|
+
`;
|
|
503
|
+
}}
|
|
504
|
+
|
|
505
|
+
svg {
|
|
506
|
+
width: 14px;
|
|
507
|
+
height: 14px;
|
|
508
|
+
fill: ${({ $disabled, theme }) => $disabled ? theme.colors.palettes.transparency["30"] : theme.colors.palettes.gray["120"]};
|
|
509
|
+
}
|
|
510
|
+
`;
|
|
511
|
+
var UpArrow = () => /* @__PURE__ */ React11.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("path", { d: "M7 4.5L10.5 8.5H3.5L7 4.5Z", fill: "currentColor" }));
|
|
512
|
+
var DownArrow = () => /* @__PURE__ */ React11.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("path", { d: "M7 9.5L3.5 5.5H10.5L7 9.5Z", fill: "currentColor" }));
|
|
513
|
+
var SpinButton = ({
|
|
514
|
+
value: controlledValue,
|
|
515
|
+
defaultValue = 0,
|
|
516
|
+
min = -Infinity,
|
|
517
|
+
max = Infinity,
|
|
518
|
+
step = 1,
|
|
519
|
+
size = "large",
|
|
520
|
+
disabled = false,
|
|
521
|
+
alert = false,
|
|
522
|
+
showSlider = false,
|
|
523
|
+
precision,
|
|
524
|
+
formatter,
|
|
525
|
+
parser,
|
|
526
|
+
onChange,
|
|
527
|
+
className,
|
|
528
|
+
style
|
|
529
|
+
}) => {
|
|
530
|
+
const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
|
|
531
|
+
const [displayValue, setDisplayValue] = useState("");
|
|
532
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
533
|
+
const inputRef = useRef(null);
|
|
534
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
535
|
+
const formatValue = useCallback(
|
|
536
|
+
(val) => {
|
|
537
|
+
if (formatter) {
|
|
538
|
+
return formatter(val);
|
|
539
|
+
}
|
|
540
|
+
if (precision !== void 0) {
|
|
541
|
+
return val.toFixed(precision);
|
|
542
|
+
}
|
|
543
|
+
return String(val);
|
|
544
|
+
},
|
|
545
|
+
[formatter, precision]
|
|
546
|
+
);
|
|
547
|
+
const parseValue = useCallback(
|
|
548
|
+
(displayVal) => {
|
|
549
|
+
if (parser) {
|
|
550
|
+
return parser(displayVal);
|
|
551
|
+
}
|
|
552
|
+
const parsed = parseFloat(displayVal);
|
|
553
|
+
return isNaN(parsed) ? null : parsed;
|
|
554
|
+
},
|
|
555
|
+
[parser]
|
|
556
|
+
);
|
|
557
|
+
useEffect(() => {
|
|
558
|
+
if (!isFocused) {
|
|
559
|
+
setDisplayValue(formatValue(value));
|
|
560
|
+
}
|
|
561
|
+
}, [value, isFocused, formatValue]);
|
|
562
|
+
const clampValue = useCallback(
|
|
563
|
+
(val) => {
|
|
564
|
+
return Math.max(min, Math.min(max, val));
|
|
565
|
+
},
|
|
566
|
+
[min, max]
|
|
567
|
+
);
|
|
568
|
+
const handleValueChange = useCallback(
|
|
569
|
+
(newValue) => {
|
|
570
|
+
const clampedValue = clampValue(newValue);
|
|
571
|
+
if (controlledValue === void 0) {
|
|
572
|
+
setInternalValue(clampedValue);
|
|
573
|
+
}
|
|
574
|
+
onChange?.(clampedValue);
|
|
575
|
+
},
|
|
576
|
+
[clampValue, controlledValue, onChange]
|
|
577
|
+
);
|
|
578
|
+
const increment = useCallback(() => {
|
|
579
|
+
if (disabled) return;
|
|
580
|
+
handleValueChange(value + step);
|
|
581
|
+
}, [disabled, value, step, handleValueChange]);
|
|
582
|
+
const decrement = useCallback(() => {
|
|
583
|
+
if (disabled) return;
|
|
584
|
+
handleValueChange(value - step);
|
|
585
|
+
}, [disabled, value, step, handleValueChange]);
|
|
586
|
+
const handleInputChange = useCallback((e) => {
|
|
587
|
+
setDisplayValue(e.target.value);
|
|
588
|
+
}, []);
|
|
589
|
+
const handleBlur = useCallback(() => {
|
|
590
|
+
setIsFocused(false);
|
|
591
|
+
const parsed = parseValue(displayValue);
|
|
592
|
+
if (parsed !== null) {
|
|
593
|
+
handleValueChange(parsed);
|
|
594
|
+
} else {
|
|
595
|
+
setDisplayValue(formatValue(value));
|
|
596
|
+
}
|
|
597
|
+
}, [displayValue, parseValue, handleValueChange, value, formatValue]);
|
|
598
|
+
const handleFocus = useCallback(() => {
|
|
599
|
+
setIsFocused(true);
|
|
600
|
+
setDisplayValue(String(value));
|
|
601
|
+
}, [value]);
|
|
602
|
+
const handleKeyDown = useCallback(
|
|
603
|
+
(e) => {
|
|
604
|
+
if (e.key === "ArrowUp") {
|
|
605
|
+
e.preventDefault();
|
|
606
|
+
increment();
|
|
607
|
+
} else if (e.key === "ArrowDown") {
|
|
608
|
+
e.preventDefault();
|
|
609
|
+
decrement();
|
|
610
|
+
} else if (e.key === "Enter") {
|
|
611
|
+
inputRef.current?.blur();
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
[increment, decrement]
|
|
615
|
+
);
|
|
616
|
+
return /* @__PURE__ */ React11.createElement(SpinButtonWrapper, { $showSlider: showSlider, className, style }, showSlider && /* @__PURE__ */ React11.createElement(SliderWrapper, { $size: size }, /* @__PURE__ */ React11.createElement(
|
|
617
|
+
Slider,
|
|
618
|
+
{
|
|
619
|
+
value,
|
|
620
|
+
min,
|
|
621
|
+
max,
|
|
622
|
+
step,
|
|
623
|
+
disabled,
|
|
624
|
+
onChange: (val) => handleValueChange(val)
|
|
625
|
+
}
|
|
626
|
+
)), /* @__PURE__ */ React11.createElement(SpinButtonContainer, { $size: size, $disabled: disabled, $alert: alert, $isFocused: isFocused }, /* @__PURE__ */ React11.createElement(InputWrapper, null, /* @__PURE__ */ React11.createElement(
|
|
627
|
+
StyledInput,
|
|
628
|
+
{
|
|
629
|
+
ref: inputRef,
|
|
630
|
+
type: "text",
|
|
631
|
+
value: displayValue,
|
|
632
|
+
onChange: handleInputChange,
|
|
633
|
+
onFocus: handleFocus,
|
|
634
|
+
onBlur: handleBlur,
|
|
635
|
+
onKeyDown: handleKeyDown,
|
|
636
|
+
disabled,
|
|
637
|
+
$size: size,
|
|
638
|
+
$disabled: disabled
|
|
639
|
+
}
|
|
640
|
+
)), /* @__PURE__ */ React11.createElement(ButtonGroup, { $alert: alert, $disabled: disabled }, /* @__PURE__ */ React11.createElement(
|
|
641
|
+
StepButton,
|
|
642
|
+
{
|
|
643
|
+
type: "button",
|
|
644
|
+
$position: "up",
|
|
645
|
+
$alert: alert,
|
|
646
|
+
$disabled: disabled,
|
|
647
|
+
onClick: increment,
|
|
648
|
+
disabled,
|
|
649
|
+
tabIndex: -1
|
|
650
|
+
},
|
|
651
|
+
/* @__PURE__ */ React11.createElement(UpArrow, null)
|
|
652
|
+
), /* @__PURE__ */ React11.createElement(
|
|
653
|
+
StepButton,
|
|
654
|
+
{
|
|
655
|
+
type: "button",
|
|
656
|
+
$position: "down",
|
|
657
|
+
$alert: alert,
|
|
658
|
+
$disabled: disabled,
|
|
659
|
+
onClick: decrement,
|
|
660
|
+
disabled,
|
|
661
|
+
tabIndex: -1
|
|
662
|
+
},
|
|
663
|
+
/* @__PURE__ */ React11.createElement(DownArrow, null)
|
|
664
|
+
))));
|
|
665
|
+
};
|
|
666
|
+
SpinButton.displayName = "SpinButton";
|
|
667
|
+
var SwitchContainer = styled3.label`
|
|
668
|
+
position: relative;
|
|
669
|
+
display: inline-block;
|
|
670
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
671
|
+
|
|
672
|
+
${({ $size, theme }) => {
|
|
673
|
+
const sizeConfig = theme.components.switch[$size];
|
|
674
|
+
return `
|
|
675
|
+
width: ${sizeConfig.container.width};
|
|
676
|
+
height: ${sizeConfig.container.height};
|
|
677
|
+
`;
|
|
678
|
+
}}
|
|
679
|
+
`;
|
|
680
|
+
var HiddenInput = styled3.input`
|
|
681
|
+
position: absolute;
|
|
682
|
+
opacity: 0;
|
|
683
|
+
width: 0;
|
|
684
|
+
height: 0;
|
|
685
|
+
pointer-events: none;
|
|
686
|
+
`;
|
|
687
|
+
var Track = styled3.div`
|
|
688
|
+
position: absolute;
|
|
689
|
+
inset: 0;
|
|
690
|
+
top: 50%;
|
|
691
|
+
left: 50%;
|
|
692
|
+
transform: translate(-50%, -50%);
|
|
693
|
+
transition: ${({ theme }) => theme.components.switch.transition || "all 0.2s ease"};
|
|
694
|
+
|
|
695
|
+
${({ $size, theme }) => {
|
|
696
|
+
const sizeConfig = theme.components.switch[$size];
|
|
697
|
+
return `
|
|
698
|
+
border-radius: ${sizeConfig.track.borderRadius};
|
|
699
|
+
width: ${sizeConfig.track.width};
|
|
700
|
+
height: ${sizeConfig.track.height};
|
|
701
|
+
`;
|
|
702
|
+
}}
|
|
703
|
+
|
|
704
|
+
${({ $checked, $disabled, theme }) => {
|
|
705
|
+
const stateConfig = $checked ? theme.components.switch.on : theme.components.switch.off;
|
|
706
|
+
if ($disabled) {
|
|
707
|
+
return `
|
|
708
|
+
background: ${stateConfig.track.backgroundDisabled};
|
|
709
|
+
box-shadow: ${stateConfig.track.boxShadowDisabled};
|
|
710
|
+
`;
|
|
711
|
+
}
|
|
712
|
+
return `
|
|
713
|
+
background: ${stateConfig.track.background};
|
|
714
|
+
box-shadow: ${stateConfig.track.boxShadow};
|
|
715
|
+
`;
|
|
716
|
+
}}
|
|
717
|
+
|
|
718
|
+
${({ $disabled, $checked, theme }) => {
|
|
719
|
+
if ($disabled) return "";
|
|
720
|
+
const stateConfig = $checked ? theme.components.switch.on : theme.components.switch.off;
|
|
721
|
+
return `
|
|
722
|
+
:hover {
|
|
723
|
+
background: ${stateConfig.track.backgroundHover};
|
|
724
|
+
box-shadow: ${stateConfig.track.boxShadowHover};
|
|
725
|
+
}
|
|
726
|
+
`;
|
|
727
|
+
}}
|
|
728
|
+
`;
|
|
729
|
+
var Thumb = styled3.div`
|
|
730
|
+
position: absolute;
|
|
731
|
+
top: 50%;
|
|
732
|
+
transform: translateY(-50%);
|
|
733
|
+
border-style: solid;
|
|
734
|
+
box-sizing: border-box;
|
|
735
|
+
transition: ${({ theme }) => theme.components.switch.transition || "all 0.2s ease"};
|
|
736
|
+
|
|
737
|
+
${({ $size, $checked, theme }) => {
|
|
738
|
+
const sizeConfig = theme.components.switch[$size];
|
|
739
|
+
const thumbSize = sizeConfig.thumb.size;
|
|
740
|
+
const thumbOffset = sizeConfig.thumb.offset;
|
|
741
|
+
const thumbBorderRadius = sizeConfig.thumb.borderRadius;
|
|
742
|
+
const thumbBorderWidth = sizeConfig.thumb.borderWidth;
|
|
743
|
+
return `
|
|
744
|
+
width: ${thumbSize};
|
|
745
|
+
height: ${thumbSize};
|
|
746
|
+
border-radius: ${thumbBorderRadius};
|
|
747
|
+
border-width: ${thumbBorderWidth};
|
|
748
|
+
${$checked ? "right" : "left"}: ${thumbOffset};
|
|
749
|
+
`;
|
|
750
|
+
}}
|
|
751
|
+
|
|
752
|
+
${({ $checked, $disabled, theme }) => {
|
|
753
|
+
const stateConfig = $checked ? theme.components.switch.on : theme.components.switch.off;
|
|
754
|
+
if ($disabled) {
|
|
755
|
+
return `
|
|
756
|
+
background: ${stateConfig.thumb.backgroundDisabled};
|
|
757
|
+
border-color: ${stateConfig.thumb.borderColorDisabled};
|
|
758
|
+
box-shadow: ${stateConfig.thumb.boxShadowDisabled};
|
|
759
|
+
`;
|
|
760
|
+
}
|
|
761
|
+
return `
|
|
762
|
+
background: ${stateConfig.thumb.background};
|
|
763
|
+
border-color: ${stateConfig.thumb.borderColor};
|
|
764
|
+
box-shadow: ${stateConfig.thumb.boxShadow};
|
|
765
|
+
`;
|
|
766
|
+
}}
|
|
767
|
+
|
|
768
|
+
${({ $disabled, $checked, theme }) => {
|
|
769
|
+
if ($disabled) return "";
|
|
770
|
+
const stateConfig = $checked ? theme.components.switch.on : theme.components.switch.off;
|
|
771
|
+
return `
|
|
772
|
+
:hover & {
|
|
773
|
+
background: ${stateConfig.thumb.backgroundHover};
|
|
774
|
+
border-color: ${stateConfig.thumb.borderColorHover};
|
|
775
|
+
box-shadow: ${stateConfig.thumb.boxShadowHover};
|
|
776
|
+
}
|
|
777
|
+
`;
|
|
778
|
+
}}
|
|
779
|
+
`;
|
|
780
|
+
var Switch = ({
|
|
781
|
+
checked: controlledChecked,
|
|
782
|
+
defaultChecked = false,
|
|
783
|
+
size = "large",
|
|
784
|
+
disabled = false,
|
|
785
|
+
onChange,
|
|
786
|
+
className,
|
|
787
|
+
style
|
|
788
|
+
}) => {
|
|
789
|
+
const [internalChecked, setInternalChecked] = useState(
|
|
790
|
+
controlledChecked ?? defaultChecked
|
|
791
|
+
);
|
|
792
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
793
|
+
const checked = controlledChecked !== void 0 ? controlledChecked : internalChecked;
|
|
794
|
+
const handleChange = useCallback(
|
|
795
|
+
(e) => {
|
|
796
|
+
if (disabled) return;
|
|
797
|
+
const newChecked = e.target.checked;
|
|
798
|
+
if (controlledChecked === void 0) {
|
|
799
|
+
setInternalChecked(newChecked);
|
|
800
|
+
}
|
|
801
|
+
onChange?.(newChecked);
|
|
802
|
+
},
|
|
803
|
+
[disabled, controlledChecked, onChange]
|
|
804
|
+
);
|
|
805
|
+
const handleFocus = useCallback(() => {
|
|
806
|
+
setIsFocused(true);
|
|
807
|
+
}, []);
|
|
808
|
+
const handleBlur = useCallback(() => {
|
|
809
|
+
setIsFocused(false);
|
|
810
|
+
}, []);
|
|
811
|
+
return /* @__PURE__ */ React11.createElement(
|
|
812
|
+
SwitchContainer,
|
|
813
|
+
{
|
|
814
|
+
$size: size,
|
|
815
|
+
$checked: checked,
|
|
816
|
+
$disabled: disabled,
|
|
817
|
+
className,
|
|
818
|
+
style
|
|
819
|
+
},
|
|
820
|
+
/* @__PURE__ */ React11.createElement(
|
|
821
|
+
HiddenInput,
|
|
822
|
+
{
|
|
823
|
+
type: "checkbox",
|
|
824
|
+
checked,
|
|
825
|
+
onChange: handleChange,
|
|
826
|
+
onFocus: handleFocus,
|
|
827
|
+
onBlur: handleBlur,
|
|
828
|
+
disabled
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
/* @__PURE__ */ React11.createElement(
|
|
832
|
+
Track,
|
|
833
|
+
{
|
|
834
|
+
$size: size,
|
|
835
|
+
$checked: checked,
|
|
836
|
+
$disabled: disabled,
|
|
837
|
+
$isFocused: isFocused
|
|
838
|
+
}
|
|
839
|
+
),
|
|
840
|
+
/* @__PURE__ */ React11.createElement(
|
|
841
|
+
Thumb,
|
|
842
|
+
{
|
|
843
|
+
$size: size,
|
|
844
|
+
$checked: checked,
|
|
845
|
+
$disabled: disabled,
|
|
846
|
+
$isFocused: isFocused
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
);
|
|
850
|
+
};
|
|
851
|
+
Switch.displayName = "Switch";
|
|
852
|
+
var RadioContainer = styled3.label`
|
|
853
|
+
position: relative;
|
|
854
|
+
display: inline-block;
|
|
855
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
856
|
+
|
|
857
|
+
${({ theme }) => {
|
|
858
|
+
const sizeConfig = theme.components.radio.small;
|
|
859
|
+
return `
|
|
860
|
+
width: ${sizeConfig.size};
|
|
861
|
+
height: ${sizeConfig.size};
|
|
862
|
+
`;
|
|
863
|
+
}}
|
|
864
|
+
`;
|
|
865
|
+
var HiddenInput2 = styled3.input`
|
|
866
|
+
position: absolute;
|
|
867
|
+
opacity: 0;
|
|
868
|
+
width: 0;
|
|
869
|
+
height: 0;
|
|
870
|
+
pointer-events: none;
|
|
871
|
+
`;
|
|
872
|
+
var RadioOuter = styled3.div`
|
|
873
|
+
position: absolute;
|
|
874
|
+
inset: 0;
|
|
875
|
+
border-radius: 50%;
|
|
876
|
+
border: 1px solid;
|
|
877
|
+
transition: all 0.2s ease;
|
|
878
|
+
|
|
879
|
+
${({ $checked, $disabled, theme }) => {
|
|
880
|
+
if ($disabled) {
|
|
881
|
+
const stateConfig = $checked ? theme.components.radio.checked : theme.components.radio.unchecked;
|
|
882
|
+
return `
|
|
883
|
+
background: ${stateConfig.backgroundDisabled};
|
|
884
|
+
border-color: ${stateConfig.borderColorDisabled};
|
|
885
|
+
`;
|
|
886
|
+
}
|
|
887
|
+
if ($checked) {
|
|
888
|
+
const checkedConfig = theme.components.radio.checked;
|
|
889
|
+
return `
|
|
890
|
+
background: ${checkedConfig.background};
|
|
891
|
+
border-color: ${checkedConfig.borderColor};
|
|
892
|
+
`;
|
|
893
|
+
}
|
|
894
|
+
const uncheckedConfig = theme.components.radio.unchecked;
|
|
895
|
+
return `
|
|
896
|
+
background: ${uncheckedConfig.background};
|
|
897
|
+
border-color: ${uncheckedConfig.borderColor};
|
|
898
|
+
`;
|
|
899
|
+
}}
|
|
900
|
+
|
|
901
|
+
${({ $disabled, $checked, theme }) => {
|
|
902
|
+
if ($disabled) return "";
|
|
903
|
+
const stateConfig = $checked ? theme.components.radio.checked : theme.components.radio.unchecked;
|
|
904
|
+
return `
|
|
905
|
+
${RadioContainer}:hover & {
|
|
906
|
+
background: ${stateConfig.backgroundHover};
|
|
907
|
+
border-color: ${stateConfig.borderColorHover};
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
${RadioContainer}:active & {
|
|
911
|
+
border-color: ${stateConfig.borderColorActive};
|
|
912
|
+
}
|
|
913
|
+
`;
|
|
914
|
+
}}
|
|
915
|
+
`;
|
|
916
|
+
var RadioInner = styled3.div`
|
|
917
|
+
position: absolute;
|
|
918
|
+
left: 50%;
|
|
919
|
+
top: 50%;
|
|
920
|
+
transform: translate(-50%, -50%);
|
|
921
|
+
border-radius: 50%;
|
|
922
|
+
background: white;
|
|
923
|
+
opacity: ${({ $checked }) => $checked ? 1 : 0};
|
|
924
|
+
transition: opacity 0.2s ease;
|
|
925
|
+
|
|
926
|
+
${({ theme }) => {
|
|
927
|
+
const dotSize = theme.components.radio.small.dotSize;
|
|
928
|
+
return `
|
|
929
|
+
width: ${dotSize};
|
|
930
|
+
height: ${dotSize};
|
|
931
|
+
`;
|
|
932
|
+
}}
|
|
933
|
+
`;
|
|
934
|
+
var Radio = ({
|
|
935
|
+
checked: controlledChecked,
|
|
936
|
+
defaultChecked = false,
|
|
937
|
+
disabled = false,
|
|
938
|
+
value,
|
|
939
|
+
name,
|
|
940
|
+
id,
|
|
941
|
+
onChange,
|
|
942
|
+
className,
|
|
943
|
+
style
|
|
944
|
+
}) => {
|
|
945
|
+
const [internalChecked, setInternalChecked] = useState(
|
|
946
|
+
controlledChecked ?? defaultChecked
|
|
947
|
+
);
|
|
948
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
949
|
+
const checked = controlledChecked !== void 0 ? controlledChecked : internalChecked;
|
|
950
|
+
const handleChange = useCallback(
|
|
951
|
+
(e) => {
|
|
952
|
+
if (disabled) return;
|
|
953
|
+
const newChecked = e.target.checked;
|
|
954
|
+
if (controlledChecked === void 0) {
|
|
955
|
+
setInternalChecked(newChecked);
|
|
956
|
+
}
|
|
957
|
+
onChange?.(e);
|
|
958
|
+
},
|
|
959
|
+
[disabled, controlledChecked, onChange]
|
|
960
|
+
);
|
|
961
|
+
const handleFocus = useCallback(() => {
|
|
962
|
+
setIsFocused(true);
|
|
963
|
+
}, []);
|
|
964
|
+
const handleBlur = useCallback(() => {
|
|
965
|
+
setIsFocused(false);
|
|
966
|
+
}, []);
|
|
967
|
+
return /* @__PURE__ */ React11.createElement(
|
|
968
|
+
RadioContainer,
|
|
969
|
+
{
|
|
970
|
+
$disabled: disabled,
|
|
971
|
+
className,
|
|
972
|
+
style
|
|
973
|
+
},
|
|
974
|
+
/* @__PURE__ */ React11.createElement(
|
|
975
|
+
HiddenInput2,
|
|
976
|
+
{
|
|
977
|
+
type: "radio",
|
|
978
|
+
id,
|
|
979
|
+
checked,
|
|
980
|
+
value,
|
|
981
|
+
name,
|
|
982
|
+
onChange: handleChange,
|
|
983
|
+
onFocus: handleFocus,
|
|
984
|
+
onBlur: handleBlur,
|
|
985
|
+
disabled
|
|
986
|
+
}
|
|
987
|
+
),
|
|
988
|
+
/* @__PURE__ */ React11.createElement(
|
|
989
|
+
RadioOuter,
|
|
990
|
+
{
|
|
991
|
+
$checked: checked,
|
|
992
|
+
$disabled: disabled,
|
|
993
|
+
$isFocused: isFocused
|
|
994
|
+
}
|
|
995
|
+
),
|
|
996
|
+
/* @__PURE__ */ React11.createElement(
|
|
997
|
+
RadioInner,
|
|
998
|
+
{
|
|
999
|
+
$checked: checked,
|
|
1000
|
+
$disabled: disabled
|
|
1001
|
+
}
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
};
|
|
1005
|
+
Radio.displayName = "Radio";
|
|
1006
|
+
var CheckboxContainer = styled3.label`
|
|
1007
|
+
position: relative;
|
|
1008
|
+
display: inline-block;
|
|
1009
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
1010
|
+
|
|
1011
|
+
${({ theme }) => {
|
|
1012
|
+
const sizeConfig = theme.components.checkbox.small;
|
|
1013
|
+
return `
|
|
1014
|
+
width: ${sizeConfig.size};
|
|
1015
|
+
height: ${sizeConfig.size};
|
|
1016
|
+
`;
|
|
1017
|
+
}}
|
|
1018
|
+
`;
|
|
1019
|
+
var HiddenInput3 = styled3.input`
|
|
1020
|
+
position: absolute;
|
|
1021
|
+
opacity: 0;
|
|
1022
|
+
width: 0;
|
|
1023
|
+
height: 0;
|
|
1024
|
+
pointer-events: none;
|
|
1025
|
+
`;
|
|
1026
|
+
var CheckboxBox = styled3.div`
|
|
1027
|
+
position: absolute;
|
|
1028
|
+
inset: 1px;
|
|
1029
|
+
border: 1px solid;
|
|
1030
|
+
transition: all 0.2s ease;
|
|
1031
|
+
|
|
1032
|
+
${({ theme }) => {
|
|
1033
|
+
const sizeConfig = theme.components.checkbox.small;
|
|
1034
|
+
return `
|
|
1035
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
1036
|
+
`;
|
|
1037
|
+
}}
|
|
1038
|
+
|
|
1039
|
+
${({ $checked, $indeterminate, $disabled, theme }) => {
|
|
1040
|
+
if ($disabled) {
|
|
1041
|
+
const stateConfig = $checked || $indeterminate ? theme.components.checkbox.checked : theme.components.checkbox.unchecked;
|
|
1042
|
+
return `
|
|
1043
|
+
background: ${stateConfig.backgroundDisabled};
|
|
1044
|
+
border-color: ${stateConfig.borderColorDisabled};
|
|
1045
|
+
`;
|
|
1046
|
+
}
|
|
1047
|
+
if ($checked) {
|
|
1048
|
+
const checkedConfig = theme.components.checkbox.checked;
|
|
1049
|
+
return `
|
|
1050
|
+
background: ${checkedConfig.background};
|
|
1051
|
+
border-color: ${checkedConfig.borderColor};
|
|
1052
|
+
`;
|
|
1053
|
+
}
|
|
1054
|
+
if ($indeterminate) {
|
|
1055
|
+
const indeterminateConfig = theme.components.checkbox.indeterminate;
|
|
1056
|
+
return `
|
|
1057
|
+
background: ${indeterminateConfig.background};
|
|
1058
|
+
border-color: ${indeterminateConfig.borderColor};
|
|
1059
|
+
`;
|
|
1060
|
+
}
|
|
1061
|
+
const uncheckedConfig = theme.components.checkbox.unchecked;
|
|
1062
|
+
return `
|
|
1063
|
+
background: ${uncheckedConfig.background};
|
|
1064
|
+
border-color: ${uncheckedConfig.borderColor};
|
|
1065
|
+
`;
|
|
1066
|
+
}}
|
|
1067
|
+
|
|
1068
|
+
${({ $disabled, $checked, $indeterminate, theme }) => {
|
|
1069
|
+
if ($disabled) return "";
|
|
1070
|
+
const stateConfig = $checked || $indeterminate ? theme.components.checkbox.checked : theme.components.checkbox.unchecked;
|
|
1071
|
+
return `
|
|
1072
|
+
${CheckboxContainer}:hover & {
|
|
1073
|
+
background: ${stateConfig.backgroundHover};
|
|
1074
|
+
border-color: ${stateConfig.borderColorHover};
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
${CheckboxContainer}:active & {
|
|
1078
|
+
border-color: ${stateConfig.borderColorActive};
|
|
1079
|
+
}
|
|
1080
|
+
`;
|
|
1081
|
+
}}
|
|
1082
|
+
`;
|
|
1083
|
+
var IconWrapper2 = styled3.div`
|
|
1084
|
+
position: absolute;
|
|
1085
|
+
left: 50%;
|
|
1086
|
+
top: 50%;
|
|
1087
|
+
transform: translate(-50%, -50%);
|
|
1088
|
+
opacity: ${({ $visible }) => $visible ? 1 : 0};
|
|
1089
|
+
transition: opacity 0.2s ease;
|
|
1090
|
+
pointer-events: none;
|
|
1091
|
+
display: flex;
|
|
1092
|
+
align-items: center;
|
|
1093
|
+
justify-content: center;
|
|
1094
|
+
|
|
1095
|
+
${({ theme }) => {
|
|
1096
|
+
const iconSize = theme.components.checkbox.small.iconSize;
|
|
1097
|
+
return `
|
|
1098
|
+
width: ${iconSize.width};
|
|
1099
|
+
height: ${iconSize.height};
|
|
1100
|
+
`;
|
|
1101
|
+
}}
|
|
1102
|
+
|
|
1103
|
+
svg, img {
|
|
1104
|
+
display: block;
|
|
1105
|
+
}
|
|
1106
|
+
`;
|
|
1107
|
+
var DefaultIndeterminateIcon = styled3.div`
|
|
1108
|
+
width: 8px;
|
|
1109
|
+
height: 2px;
|
|
1110
|
+
background: white;
|
|
1111
|
+
`;
|
|
1112
|
+
var Checkbox = ({
|
|
1113
|
+
checked: controlledChecked,
|
|
1114
|
+
defaultChecked = false,
|
|
1115
|
+
indeterminate = false,
|
|
1116
|
+
disabled = false,
|
|
1117
|
+
value,
|
|
1118
|
+
name,
|
|
1119
|
+
id,
|
|
1120
|
+
onChange,
|
|
1121
|
+
className,
|
|
1122
|
+
style
|
|
1123
|
+
}) => {
|
|
1124
|
+
const [internalChecked, setInternalChecked] = useState(
|
|
1125
|
+
controlledChecked ?? defaultChecked
|
|
1126
|
+
);
|
|
1127
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
1128
|
+
const inputRef = useRef(null);
|
|
1129
|
+
const checked = controlledChecked !== void 0 ? controlledChecked : internalChecked;
|
|
1130
|
+
useEffect(() => {
|
|
1131
|
+
if (inputRef.current) {
|
|
1132
|
+
inputRef.current.indeterminate = indeterminate;
|
|
1133
|
+
}
|
|
1134
|
+
}, [indeterminate]);
|
|
1135
|
+
const handleChange = useCallback(
|
|
1136
|
+
(e) => {
|
|
1137
|
+
if (disabled) return;
|
|
1138
|
+
const newChecked = e.target.checked;
|
|
1139
|
+
if (controlledChecked === void 0) {
|
|
1140
|
+
setInternalChecked(newChecked);
|
|
1141
|
+
}
|
|
1142
|
+
onChange?.(e);
|
|
1143
|
+
},
|
|
1144
|
+
[disabled, controlledChecked, onChange]
|
|
1145
|
+
);
|
|
1146
|
+
const handleFocus = useCallback(() => {
|
|
1147
|
+
setIsFocused(true);
|
|
1148
|
+
}, []);
|
|
1149
|
+
const handleBlur = useCallback(() => {
|
|
1150
|
+
setIsFocused(false);
|
|
1151
|
+
}, []);
|
|
1152
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1153
|
+
CheckboxContainer,
|
|
1154
|
+
{
|
|
1155
|
+
$disabled: disabled,
|
|
1156
|
+
className,
|
|
1157
|
+
style
|
|
1158
|
+
},
|
|
1159
|
+
/* @__PURE__ */ React11.createElement(
|
|
1160
|
+
HiddenInput3,
|
|
1161
|
+
{
|
|
1162
|
+
ref: inputRef,
|
|
1163
|
+
type: "checkbox",
|
|
1164
|
+
id,
|
|
1165
|
+
checked,
|
|
1166
|
+
value,
|
|
1167
|
+
name,
|
|
1168
|
+
onChange: handleChange,
|
|
1169
|
+
onFocus: handleFocus,
|
|
1170
|
+
onBlur: handleBlur,
|
|
1171
|
+
disabled
|
|
1172
|
+
}
|
|
1173
|
+
),
|
|
1174
|
+
/* @__PURE__ */ React11.createElement(
|
|
1175
|
+
CheckboxBox,
|
|
1176
|
+
{
|
|
1177
|
+
$checked: checked,
|
|
1178
|
+
$indeterminate: indeterminate,
|
|
1179
|
+
$disabled: disabled,
|
|
1180
|
+
$isFocused: isFocused
|
|
1181
|
+
}
|
|
1182
|
+
),
|
|
1183
|
+
!indeterminate && /* @__PURE__ */ React11.createElement(IconWrapper2, { $visible: checked }, /* @__PURE__ */ React11.createElement("svg", { width: 10, height: 8, viewBox: "0 0 10 8", fill: "#fff" }, /* @__PURE__ */ React11.createElement("path", { d: "M1.05426 3.16164L0 4.27945L3.50904 8L10 1.11781L8.94573 0L3.50904 5.76438L1.05426 3.16164Z" }))),
|
|
1184
|
+
indeterminate && /* @__PURE__ */ React11.createElement(IconWrapper2, { $visible: indeterminate }, /* @__PURE__ */ React11.createElement(DefaultIndeterminateIcon, null))
|
|
1185
|
+
);
|
|
1186
|
+
};
|
|
1187
|
+
Checkbox.displayName = "Checkbox";
|
|
1188
|
+
var InputWrapper2 = styled3.div`
|
|
1189
|
+
display: inline-flex;
|
|
1190
|
+
align-items: center;
|
|
1191
|
+
width: 100%;
|
|
1192
|
+
box-sizing: border-box;
|
|
1193
|
+
position: relative;
|
|
1194
|
+
transition: all 0.2s ease;
|
|
1195
|
+
|
|
1196
|
+
${({ $size, theme }) => {
|
|
1197
|
+
const size = $size || "medium";
|
|
1198
|
+
const sizeConfig = theme.components.input.outlined[size];
|
|
1199
|
+
return `
|
|
1200
|
+
height: ${sizeConfig.height};
|
|
1201
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
1202
|
+
padding: ${sizeConfig.padding};
|
|
1203
|
+
font-size: ${sizeConfig.fontSize};
|
|
1204
|
+
line-height: ${sizeConfig.lineHeight};
|
|
1205
|
+
`;
|
|
1206
|
+
}}
|
|
1207
|
+
|
|
1208
|
+
${({ $error, $disabled, $readOnly, $isFocused, theme, $size }) => {
|
|
1209
|
+
const stateConfig = theme.components.input.outlined.state;
|
|
1210
|
+
let borderColor = stateConfig.borderColor;
|
|
1211
|
+
let background = stateConfig.background;
|
|
1212
|
+
let boxShadow = "none";
|
|
1213
|
+
if ($disabled) {
|
|
1214
|
+
borderColor = stateConfig.borderColorDisabled;
|
|
1215
|
+
background = stateConfig.backgroundDisabled;
|
|
1216
|
+
} else if ($readOnly) {
|
|
1217
|
+
borderColor = stateConfig.borderColorReadonly;
|
|
1218
|
+
background = stateConfig.backgroundReadonly;
|
|
1219
|
+
} else if ($error) {
|
|
1220
|
+
borderColor = stateConfig.borderColorError;
|
|
1221
|
+
background = stateConfig.backgroundActive;
|
|
1222
|
+
} else if ($isFocused) {
|
|
1223
|
+
borderColor = stateConfig.borderColorActive;
|
|
1224
|
+
background = stateConfig.backgroundActive;
|
|
1225
|
+
const size = $size || "medium";
|
|
1226
|
+
boxShadow = theme.components.input.outlined[size].boxShadowActive;
|
|
1227
|
+
}
|
|
1228
|
+
return `
|
|
1229
|
+
border: 1px solid ${borderColor};
|
|
1230
|
+
background: ${background};
|
|
1231
|
+
box-shadow: ${boxShadow};
|
|
1232
|
+
|
|
1233
|
+
&:hover:not(:disabled) {
|
|
1234
|
+
${!$disabled && !$readOnly && !$isFocused ? `
|
|
1235
|
+
border-color: ${stateConfig.borderColorHover};
|
|
1236
|
+
background: ${stateConfig.backgroundHover};
|
|
1237
|
+
` : ""}
|
|
1238
|
+
}
|
|
1239
|
+
`;
|
|
1240
|
+
}}
|
|
1241
|
+
|
|
1242
|
+
${({ $disabled }) => $disabled && `
|
|
1243
|
+
cursor: not-allowed;
|
|
1244
|
+
opacity: 1;
|
|
1245
|
+
`}
|
|
1246
|
+
`;
|
|
1247
|
+
var StyledInput2 = styled3.input`
|
|
1248
|
+
flex: 1;
|
|
1249
|
+
border: none;
|
|
1250
|
+
outline: none;
|
|
1251
|
+
background: transparent;
|
|
1252
|
+
min-width: 0;
|
|
1253
|
+
padding: 0;
|
|
1254
|
+
margin: 0;
|
|
1255
|
+
font-family: inherit;
|
|
1256
|
+
color: ${({ theme }) => theme.components.input.outlined.state.borderColorActive};
|
|
1257
|
+
|
|
1258
|
+
${({ $size, theme }) => {
|
|
1259
|
+
const size = $size || "medium";
|
|
1260
|
+
const sizeConfig = theme.components.input.outlined[size];
|
|
1261
|
+
return `
|
|
1262
|
+
font-size: ${sizeConfig.fontSize};
|
|
1263
|
+
line-height: ${sizeConfig.lineHeight};
|
|
1264
|
+
`;
|
|
1265
|
+
}}
|
|
1266
|
+
|
|
1267
|
+
&::placeholder {
|
|
1268
|
+
color: ${({ theme }) => theme.colors.palettes.transparency["30"]};
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
${({ $disabled, theme }) => $disabled && `
|
|
1272
|
+
cursor: not-allowed;
|
|
1273
|
+
color: ${theme.colors.palettes.transparency["30"]};
|
|
1274
|
+
`}
|
|
1275
|
+
|
|
1276
|
+
${({ $readOnly }) => $readOnly && `
|
|
1277
|
+
cursor: default;
|
|
1278
|
+
`}
|
|
1279
|
+
`;
|
|
1280
|
+
var PrefixNode = styled3.div`
|
|
1281
|
+
display: inline-flex;
|
|
1282
|
+
align-items: center;
|
|
1283
|
+
flex-shrink: 0;
|
|
1284
|
+
margin-right: 4px;
|
|
1285
|
+
|
|
1286
|
+
${({ $size, theme }) => {
|
|
1287
|
+
const size = $size || "medium";
|
|
1288
|
+
const sizeConfig = theme.components.input.outlined[size];
|
|
1289
|
+
return `
|
|
1290
|
+
svg, img {
|
|
1291
|
+
width: ${sizeConfig.iconSize.width};
|
|
1292
|
+
height: ${sizeConfig.iconSize.height};
|
|
1293
|
+
}
|
|
1294
|
+
`;
|
|
1295
|
+
}}
|
|
1296
|
+
`;
|
|
1297
|
+
var SuffixNode = styled3.div`
|
|
1298
|
+
display: inline-flex;
|
|
1299
|
+
align-items: center;
|
|
1300
|
+
flex-shrink: 0;
|
|
1301
|
+
margin-left: 4px;
|
|
1302
|
+
|
|
1303
|
+
${({ $size, theme }) => {
|
|
1304
|
+
const size = $size || "medium";
|
|
1305
|
+
const sizeConfig = theme.components.input.outlined[size];
|
|
1306
|
+
return `
|
|
1307
|
+
svg, img {
|
|
1308
|
+
width: ${sizeConfig.iconSize.width};
|
|
1309
|
+
height: ${sizeConfig.iconSize.height};
|
|
1310
|
+
}
|
|
1311
|
+
`;
|
|
1312
|
+
}}
|
|
1313
|
+
`;
|
|
1314
|
+
var Input = forwardRef(
|
|
1315
|
+
({
|
|
1316
|
+
size = "medium",
|
|
1317
|
+
error = false,
|
|
1318
|
+
disabled = false,
|
|
1319
|
+
readOnly = false,
|
|
1320
|
+
prefixNode,
|
|
1321
|
+
suffixNode,
|
|
1322
|
+
className,
|
|
1323
|
+
style,
|
|
1324
|
+
onFocus,
|
|
1325
|
+
onBlur,
|
|
1326
|
+
...rest
|
|
1327
|
+
}, ref) => {
|
|
1328
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
1329
|
+
const handleFocus = (e) => {
|
|
1330
|
+
setIsFocused(true);
|
|
1331
|
+
onFocus?.(e);
|
|
1332
|
+
};
|
|
1333
|
+
const handleBlur = (e) => {
|
|
1334
|
+
setIsFocused(false);
|
|
1335
|
+
onBlur?.(e);
|
|
1336
|
+
};
|
|
1337
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1338
|
+
InputWrapper2,
|
|
1339
|
+
{
|
|
1340
|
+
$size: size,
|
|
1341
|
+
$error: error,
|
|
1342
|
+
$disabled: !!disabled,
|
|
1343
|
+
$readOnly: !!readOnly,
|
|
1344
|
+
$isFocused: isFocused,
|
|
1345
|
+
className,
|
|
1346
|
+
style
|
|
1347
|
+
},
|
|
1348
|
+
prefixNode && /* @__PURE__ */ React11.createElement(PrefixNode, { $size: size }, prefixNode),
|
|
1349
|
+
/* @__PURE__ */ React11.createElement(
|
|
1350
|
+
StyledInput2,
|
|
1351
|
+
{
|
|
1352
|
+
ref,
|
|
1353
|
+
$size: size,
|
|
1354
|
+
$disabled: !!disabled,
|
|
1355
|
+
$readOnly: !!readOnly,
|
|
1356
|
+
disabled,
|
|
1357
|
+
readOnly,
|
|
1358
|
+
onFocus: handleFocus,
|
|
1359
|
+
onBlur: handleBlur,
|
|
1360
|
+
...rest
|
|
1361
|
+
}
|
|
1362
|
+
),
|
|
1363
|
+
suffixNode && /* @__PURE__ */ React11.createElement(SuffixNode, { $size: size }, suffixNode)
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
1366
|
+
);
|
|
1367
|
+
Input.displayName = "Input";
|
|
1368
|
+
var SearchIconWrapper = styled3.div`
|
|
1369
|
+
display: inline-flex;
|
|
1370
|
+
align-items: center;
|
|
1371
|
+
justify-content: center;
|
|
1372
|
+
flex-shrink: 0;
|
|
1373
|
+
|
|
1374
|
+
${({ $size, theme }) => {
|
|
1375
|
+
const sizeConfig = theme.components.input.outlined[$size === "extraLarge" ? "extraLarge" : "large"];
|
|
1376
|
+
return `
|
|
1377
|
+
width: ${sizeConfig.iconSize.width};
|
|
1378
|
+
height: ${sizeConfig.iconSize.height};
|
|
1379
|
+
`;
|
|
1380
|
+
}}
|
|
1381
|
+
|
|
1382
|
+
svg {
|
|
1383
|
+
width: 100%;
|
|
1384
|
+
height: 100%;
|
|
1385
|
+
color: ${({ theme }) => theme.colors.palettes.transparency["100"]};
|
|
1386
|
+
}
|
|
1387
|
+
`;
|
|
1388
|
+
var ClearButton = styled3.button`
|
|
1389
|
+
display: inline-flex;
|
|
1390
|
+
align-items: center;
|
|
1391
|
+
justify-content: center;
|
|
1392
|
+
flex-shrink: 0;
|
|
1393
|
+
border: none;
|
|
1394
|
+
background: transparent;
|
|
1395
|
+
cursor: pointer;
|
|
1396
|
+
padding: 0;
|
|
1397
|
+
margin: 0;
|
|
1398
|
+
outline: none;
|
|
1399
|
+
transition: opacity 0.2s ease;
|
|
1400
|
+
|
|
1401
|
+
${({ $size, theme }) => {
|
|
1402
|
+
const sizeConfig = theme.components.input.outlined[$size === "extraLarge" ? "extraLarge" : "large"];
|
|
1403
|
+
return `
|
|
1404
|
+
width: ${sizeConfig.iconSize.width};
|
|
1405
|
+
height: ${sizeConfig.iconSize.height};
|
|
1406
|
+
`;
|
|
1407
|
+
}}
|
|
1408
|
+
|
|
1409
|
+
svg {
|
|
1410
|
+
width: 100%;
|
|
1411
|
+
height: 100%;
|
|
1412
|
+
color: ${({ theme }) => theme.colors.palettes.transparency["100"]};
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
&:hover {
|
|
1416
|
+
opacity: 0.7;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
&:active {
|
|
1420
|
+
opacity: 0.5;
|
|
1421
|
+
}
|
|
1422
|
+
`;
|
|
1423
|
+
var DefaultSearchIcon = () => /* @__PURE__ */ React11.createElement("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement(
|
|
1424
|
+
"path",
|
|
1425
|
+
{
|
|
1426
|
+
d: "M7.33333 12.6667C10.2789 12.6667 12.6667 10.2789 12.6667 7.33333C12.6667 4.38781 10.2789 2 7.33333 2C4.38781 2 2 4.38781 2 7.33333C2 10.2789 4.38781 12.6667 7.33333 12.6667Z",
|
|
1427
|
+
stroke: "currentColor",
|
|
1428
|
+
strokeWidth: "1.5",
|
|
1429
|
+
strokeLinecap: "round",
|
|
1430
|
+
strokeLinejoin: "round"
|
|
1431
|
+
}
|
|
1432
|
+
), /* @__PURE__ */ React11.createElement(
|
|
1433
|
+
"path",
|
|
1434
|
+
{
|
|
1435
|
+
d: "M14 14L11.1 11.1",
|
|
1436
|
+
stroke: "currentColor",
|
|
1437
|
+
strokeWidth: "1.5",
|
|
1438
|
+
strokeLinecap: "round",
|
|
1439
|
+
strokeLinejoin: "round"
|
|
1440
|
+
}
|
|
1441
|
+
));
|
|
1442
|
+
var DefaultCloseIcon = () => /* @__PURE__ */ React11.createElement("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement(
|
|
1443
|
+
"path",
|
|
1444
|
+
{
|
|
1445
|
+
d: "M12 4L4 12",
|
|
1446
|
+
stroke: "currentColor",
|
|
1447
|
+
strokeWidth: "1.5",
|
|
1448
|
+
strokeLinecap: "round",
|
|
1449
|
+
strokeLinejoin: "round"
|
|
1450
|
+
}
|
|
1451
|
+
), /* @__PURE__ */ React11.createElement(
|
|
1452
|
+
"path",
|
|
1453
|
+
{
|
|
1454
|
+
d: "M4 4L12 12",
|
|
1455
|
+
stroke: "currentColor",
|
|
1456
|
+
strokeWidth: "1.5",
|
|
1457
|
+
strokeLinecap: "round",
|
|
1458
|
+
strokeLinejoin: "round"
|
|
1459
|
+
}
|
|
1460
|
+
));
|
|
1461
|
+
var SearchInput = forwardRef(
|
|
1462
|
+
({
|
|
1463
|
+
size = "extraLarge",
|
|
1464
|
+
clearable = true,
|
|
1465
|
+
onClear,
|
|
1466
|
+
searchIcon,
|
|
1467
|
+
value,
|
|
1468
|
+
defaultValue,
|
|
1469
|
+
onChange,
|
|
1470
|
+
disabled,
|
|
1471
|
+
readOnly,
|
|
1472
|
+
...rest
|
|
1473
|
+
}, ref) => {
|
|
1474
|
+
const [internalValue, setInternalValue] = useState(defaultValue || "");
|
|
1475
|
+
const isControlled = value !== void 0;
|
|
1476
|
+
const currentValue = isControlled ? value : internalValue;
|
|
1477
|
+
const handleChange = (e) => {
|
|
1478
|
+
if (!isControlled) {
|
|
1479
|
+
setInternalValue(e.target.value);
|
|
1480
|
+
}
|
|
1481
|
+
onChange?.(e);
|
|
1482
|
+
};
|
|
1483
|
+
const handleClear = () => {
|
|
1484
|
+
if (!isControlled) {
|
|
1485
|
+
setInternalValue("");
|
|
1486
|
+
}
|
|
1487
|
+
onClear?.();
|
|
1488
|
+
};
|
|
1489
|
+
const prefixNode = /* @__PURE__ */ React11.createElement(SearchIconWrapper, { $size: size }, searchIcon || /* @__PURE__ */ React11.createElement(DefaultSearchIcon, null));
|
|
1490
|
+
const suffixNode = clearable && currentValue && !disabled && !readOnly ? /* @__PURE__ */ React11.createElement(
|
|
1491
|
+
ClearButton,
|
|
1492
|
+
{
|
|
1493
|
+
$size: size,
|
|
1494
|
+
onClick: handleClear,
|
|
1495
|
+
type: "button",
|
|
1496
|
+
tabIndex: -1
|
|
1497
|
+
},
|
|
1498
|
+
/* @__PURE__ */ React11.createElement(DefaultCloseIcon, null)
|
|
1499
|
+
) : null;
|
|
1500
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1501
|
+
Input,
|
|
1502
|
+
{
|
|
1503
|
+
ref,
|
|
1504
|
+
size,
|
|
1505
|
+
prefixNode,
|
|
1506
|
+
suffixNode,
|
|
1507
|
+
value: isControlled ? value : internalValue,
|
|
1508
|
+
onChange: handleChange,
|
|
1509
|
+
disabled,
|
|
1510
|
+
readOnly,
|
|
1511
|
+
...rest
|
|
1512
|
+
}
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
);
|
|
1516
|
+
SearchInput.displayName = "SearchInput";
|
|
1517
|
+
var IconContext = createContext(null);
|
|
1518
|
+
var IconProvider = ({
|
|
1519
|
+
icons,
|
|
1520
|
+
children
|
|
1521
|
+
}) => {
|
|
1522
|
+
return /* @__PURE__ */ React11.createElement(IconContext.Provider, { value: icons }, children);
|
|
1523
|
+
};
|
|
1524
|
+
var useIconRegistry = () => {
|
|
1525
|
+
return useContext(IconContext);
|
|
1526
|
+
};
|
|
1527
|
+
IconProvider.displayName = "IconProvider";
|
|
1528
|
+
|
|
1529
|
+
// src/Icon/Icon.tsx
|
|
1530
|
+
var IconContainer = styled3.span`
|
|
1531
|
+
display: inline-flex;
|
|
1532
|
+
align-items: center;
|
|
1533
|
+
justify-content: center;
|
|
1534
|
+
width: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
1535
|
+
height: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
1536
|
+
color: ${({ $color }) => $color};
|
|
1537
|
+
flex-shrink: 0;
|
|
1538
|
+
line-height: 1;
|
|
1539
|
+
|
|
1540
|
+
svg {
|
|
1541
|
+
width: 100%;
|
|
1542
|
+
height: 100%;
|
|
1543
|
+
display: block;
|
|
1544
|
+
}
|
|
1545
|
+
`;
|
|
1546
|
+
var Icon = ({
|
|
1547
|
+
name,
|
|
1548
|
+
src,
|
|
1549
|
+
children,
|
|
1550
|
+
size = 16,
|
|
1551
|
+
color = "currentColor",
|
|
1552
|
+
alt = "icon",
|
|
1553
|
+
className,
|
|
1554
|
+
style,
|
|
1555
|
+
onClick
|
|
1556
|
+
}) => {
|
|
1557
|
+
const registry = useIconRegistry();
|
|
1558
|
+
let iconElement = children;
|
|
1559
|
+
if (!iconElement && src) {
|
|
1560
|
+
iconElement = /* @__PURE__ */ React11.createElement(
|
|
1561
|
+
"img",
|
|
1562
|
+
{
|
|
1563
|
+
src,
|
|
1564
|
+
alt,
|
|
1565
|
+
style: { width: "100%", height: "100%", display: "block" }
|
|
1566
|
+
}
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
if (!iconElement && name && registry) {
|
|
1570
|
+
const IconComponent = registry[name];
|
|
1571
|
+
if (IconComponent) {
|
|
1572
|
+
iconElement = /* @__PURE__ */ React11.createElement(IconComponent, null);
|
|
1573
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
1574
|
+
console.warn(`Icon "${name}" not found in registry. Make sure IconProvider is set up.`);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (!iconElement) {
|
|
1578
|
+
if (process.env.NODE_ENV !== "production" && !children && !name && !src) {
|
|
1579
|
+
console.warn('Icon: one of "name", "src", or "children" must be provided');
|
|
1580
|
+
}
|
|
1581
|
+
return null;
|
|
1582
|
+
}
|
|
1583
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1584
|
+
IconContainer,
|
|
1585
|
+
{
|
|
1586
|
+
$size: size,
|
|
1587
|
+
$color: color,
|
|
1588
|
+
className,
|
|
1589
|
+
style,
|
|
1590
|
+
onClick
|
|
1591
|
+
},
|
|
1592
|
+
iconElement
|
|
1593
|
+
);
|
|
1594
|
+
};
|
|
1595
|
+
Icon.displayName = "Icon";
|
|
1596
|
+
var ToastContainer = styled3.div`
|
|
1597
|
+
display: inline-flex;
|
|
1598
|
+
align-items: center;
|
|
1599
|
+
gap: 8px;
|
|
1600
|
+
border: 1px solid;
|
|
1601
|
+
box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.08);
|
|
1602
|
+
|
|
1603
|
+
${({ theme }) => {
|
|
1604
|
+
const baseConfig = theme.components.toast;
|
|
1605
|
+
return `
|
|
1606
|
+
padding: ${baseConfig.padding};
|
|
1607
|
+
border-radius: ${baseConfig.borderRadius};
|
|
1608
|
+
font-size: ${baseConfig.fontSize};
|
|
1609
|
+
font-weight: ${baseConfig.fontWeight};
|
|
1610
|
+
`;
|
|
1611
|
+
}}
|
|
1612
|
+
|
|
1613
|
+
${({ $variant, theme }) => {
|
|
1614
|
+
const variantConfig = theme.components.toast[$variant];
|
|
1615
|
+
return `
|
|
1616
|
+
background: ${variantConfig.background};
|
|
1617
|
+
border-color: ${variantConfig.borderColor};
|
|
1618
|
+
`;
|
|
1619
|
+
}}
|
|
1620
|
+
`;
|
|
1621
|
+
var IconWrapper3 = styled3.div`
|
|
1622
|
+
display: flex;
|
|
1623
|
+
align-items: center;
|
|
1624
|
+
justify-content: center;
|
|
1625
|
+
flex-shrink: 0;
|
|
1626
|
+
|
|
1627
|
+
${({ $variant, theme }) => {
|
|
1628
|
+
const iconConfig = theme.components.toast[$variant].icon;
|
|
1629
|
+
return `
|
|
1630
|
+
width: ${iconConfig.size.width};
|
|
1631
|
+
height: ${iconConfig.size.height};
|
|
1632
|
+
`;
|
|
1633
|
+
}}
|
|
1634
|
+
`;
|
|
1635
|
+
var Message = styled3.span`
|
|
1636
|
+
flex: 1;
|
|
1637
|
+
line-height: 20px;
|
|
1638
|
+
color: ${({ theme }) => theme.colors.palettes.gray["120"]};
|
|
1639
|
+
`;
|
|
1640
|
+
var ActionButton = styled3.button`
|
|
1641
|
+
background: transparent;
|
|
1642
|
+
border: none;
|
|
1643
|
+
cursor: pointer;
|
|
1644
|
+
padding: 0;
|
|
1645
|
+
outline: none;
|
|
1646
|
+
|
|
1647
|
+
${({ $variant, theme }) => {
|
|
1648
|
+
const buttonConfig = theme.components.toast[$variant].button;
|
|
1649
|
+
return `
|
|
1650
|
+
font-size: ${buttonConfig.fontSize};
|
|
1651
|
+
font-weight: ${buttonConfig.fontWeight};
|
|
1652
|
+
color: ${buttonConfig.color};
|
|
1653
|
+
margin-left: ${buttonConfig.gap};
|
|
1654
|
+
`;
|
|
1655
|
+
}}
|
|
1656
|
+
|
|
1657
|
+
&:hover {
|
|
1658
|
+
opacity: 0.8;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
&:active {
|
|
1662
|
+
opacity: 0.6;
|
|
1663
|
+
}
|
|
1664
|
+
`;
|
|
1665
|
+
var CloseButton = styled3.button`
|
|
1666
|
+
background: transparent;
|
|
1667
|
+
border: none;
|
|
1668
|
+
cursor: pointer;
|
|
1669
|
+
padding: 0;
|
|
1670
|
+
width: 16px;
|
|
1671
|
+
height: 16px;
|
|
1672
|
+
display: flex;
|
|
1673
|
+
align-items: center;
|
|
1674
|
+
justify-content: center;
|
|
1675
|
+
color: ${({ theme }) => theme.colors.palettes.gray["60"]};
|
|
1676
|
+
flex-shrink: 0;
|
|
1677
|
+
outline: none;
|
|
1678
|
+
|
|
1679
|
+
&:hover {
|
|
1680
|
+
color: ${({ theme }) => theme.colors.palettes.gray["100"]};
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
&:active {
|
|
1684
|
+
color: ${({ theme }) => theme.colors.palettes.gray["120"]};
|
|
1685
|
+
}
|
|
1686
|
+
`;
|
|
1687
|
+
var SuccessIcon = () => /* @__PURE__ */ React11.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#4ea44b" }), /* @__PURE__ */ React11.createElement("path", { d: "M6 10L9 13L14 7", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
1688
|
+
var InfoIcon = () => /* @__PURE__ */ React11.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#5ba0e7" }), /* @__PURE__ */ React11.createElement("path", { d: "M10 9V14M10 6H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1689
|
+
var ErrorIcon = () => /* @__PURE__ */ React11.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#e95555" }), /* @__PURE__ */ React11.createElement("path", { d: "M7 7L13 13M13 7L7 13", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1690
|
+
var WarnIcon = () => /* @__PURE__ */ React11.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#ebe361" }), /* @__PURE__ */ React11.createElement("path", { d: "M10 6V11M10 14H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1691
|
+
var CloseIconSvg = () => /* @__PURE__ */ React11.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React11.createElement("path", { d: "M9 3L3 9M3 3L9 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }));
|
|
1692
|
+
var Toast = ({
|
|
1693
|
+
variant = "info",
|
|
1694
|
+
message,
|
|
1695
|
+
actionText,
|
|
1696
|
+
onAction,
|
|
1697
|
+
closable = false,
|
|
1698
|
+
onClose,
|
|
1699
|
+
duration = 0,
|
|
1700
|
+
icon,
|
|
1701
|
+
showIcon = true,
|
|
1702
|
+
className,
|
|
1703
|
+
style
|
|
1704
|
+
}) => {
|
|
1705
|
+
const [visible, setVisible] = useState(true);
|
|
1706
|
+
useEffect(() => {
|
|
1707
|
+
if (duration > 0) {
|
|
1708
|
+
const timer = setTimeout(() => {
|
|
1709
|
+
setVisible(false);
|
|
1710
|
+
onClose?.();
|
|
1711
|
+
}, duration);
|
|
1712
|
+
return () => clearTimeout(timer);
|
|
1713
|
+
}
|
|
1714
|
+
}, [duration, onClose]);
|
|
1715
|
+
const handleClose = () => {
|
|
1716
|
+
setVisible(false);
|
|
1717
|
+
onClose?.();
|
|
1718
|
+
};
|
|
1719
|
+
if (!visible) {
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
const defaultIcons = {
|
|
1723
|
+
success: /* @__PURE__ */ React11.createElement(SuccessIcon, null),
|
|
1724
|
+
info: /* @__PURE__ */ React11.createElement(InfoIcon, null),
|
|
1725
|
+
error: /* @__PURE__ */ React11.createElement(ErrorIcon, null),
|
|
1726
|
+
warn: /* @__PURE__ */ React11.createElement(WarnIcon, null)
|
|
1727
|
+
};
|
|
1728
|
+
const iconElement = icon || defaultIcons[variant];
|
|
1729
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1730
|
+
ToastContainer,
|
|
1731
|
+
{
|
|
1732
|
+
$variant: variant,
|
|
1733
|
+
className,
|
|
1734
|
+
style,
|
|
1735
|
+
role: "alert",
|
|
1736
|
+
"aria-live": "polite"
|
|
1737
|
+
},
|
|
1738
|
+
showIcon && /* @__PURE__ */ React11.createElement(IconWrapper3, { $variant: variant }, iconElement),
|
|
1739
|
+
/* @__PURE__ */ React11.createElement(Message, null, message),
|
|
1740
|
+
actionText && onAction && /* @__PURE__ */ React11.createElement(
|
|
1741
|
+
ActionButton,
|
|
1742
|
+
{
|
|
1743
|
+
$variant: variant,
|
|
1744
|
+
onClick: onAction,
|
|
1745
|
+
type: "button"
|
|
1746
|
+
},
|
|
1747
|
+
actionText
|
|
1748
|
+
),
|
|
1749
|
+
closable && /* @__PURE__ */ React11.createElement(
|
|
1750
|
+
CloseButton,
|
|
1751
|
+
{
|
|
1752
|
+
onClick: handleClose,
|
|
1753
|
+
type: "button",
|
|
1754
|
+
"aria-label": "Close"
|
|
1755
|
+
},
|
|
1756
|
+
/* @__PURE__ */ React11.createElement(CloseIconSvg, null)
|
|
1757
|
+
)
|
|
1758
|
+
);
|
|
1759
|
+
};
|
|
1760
|
+
Toast.displayName = "Toast";
|
|
1761
|
+
var ToastContext = createContext(null);
|
|
1762
|
+
var ToastWrapper = styled3.div`
|
|
1763
|
+
position: fixed;
|
|
1764
|
+
top: 24px;
|
|
1765
|
+
right: 24px;
|
|
1766
|
+
z-index: 9999;
|
|
1767
|
+
display: flex;
|
|
1768
|
+
flex-direction: column;
|
|
1769
|
+
gap: 12px;
|
|
1770
|
+
pointer-events: none;
|
|
1771
|
+
|
|
1772
|
+
> * {
|
|
1773
|
+
pointer-events: auto;
|
|
1774
|
+
}
|
|
1775
|
+
`;
|
|
1776
|
+
var ToastContainer2 = ({
|
|
1777
|
+
maxCount = 5,
|
|
1778
|
+
defaultDuration = 3e3,
|
|
1779
|
+
children
|
|
1780
|
+
}) => {
|
|
1781
|
+
const [toasts, setToasts] = useState([]);
|
|
1782
|
+
const showToast = useCallback((props) => {
|
|
1783
|
+
const id = `toast-${Date.now()}-${Math.random()}`;
|
|
1784
|
+
const newToast = {
|
|
1785
|
+
...props,
|
|
1786
|
+
id,
|
|
1787
|
+
duration: props.duration ?? defaultDuration
|
|
1788
|
+
};
|
|
1789
|
+
setToasts((prev) => {
|
|
1790
|
+
const updated = [...prev, newToast];
|
|
1791
|
+
return updated.slice(-maxCount);
|
|
1792
|
+
});
|
|
1793
|
+
return id;
|
|
1794
|
+
}, [maxCount, defaultDuration]);
|
|
1795
|
+
const hideToast = useCallback((id) => {
|
|
1796
|
+
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
1797
|
+
}, []);
|
|
1798
|
+
const success = useCallback((message, options) => {
|
|
1799
|
+
return showToast({ ...options, variant: "success", message });
|
|
1800
|
+
}, [showToast]);
|
|
1801
|
+
const info = useCallback((message, options) => {
|
|
1802
|
+
return showToast({ ...options, variant: "info", message });
|
|
1803
|
+
}, [showToast]);
|
|
1804
|
+
const error = useCallback((message, options) => {
|
|
1805
|
+
return showToast({ ...options, variant: "error", message });
|
|
1806
|
+
}, [showToast]);
|
|
1807
|
+
const warn = useCallback((message, options) => {
|
|
1808
|
+
return showToast({ ...options, variant: "warn", message });
|
|
1809
|
+
}, [showToast]);
|
|
1810
|
+
const contextValue = {
|
|
1811
|
+
showToast,
|
|
1812
|
+
hideToast,
|
|
1813
|
+
success,
|
|
1814
|
+
info,
|
|
1815
|
+
error,
|
|
1816
|
+
warn
|
|
1817
|
+
};
|
|
1818
|
+
return /* @__PURE__ */ React11.createElement(ToastContext.Provider, { value: contextValue }, children, /* @__PURE__ */ React11.createElement(ToastWrapper, null, toasts.map((toast) => /* @__PURE__ */ React11.createElement(
|
|
1819
|
+
Toast,
|
|
1820
|
+
{
|
|
1821
|
+
key: toast.id,
|
|
1822
|
+
...toast,
|
|
1823
|
+
onClose: () => hideToast(toast.id)
|
|
1824
|
+
}
|
|
1825
|
+
))));
|
|
1826
|
+
};
|
|
1827
|
+
var useToast = () => {
|
|
1828
|
+
const context = useContext(ToastContext);
|
|
1829
|
+
if (!context) {
|
|
1830
|
+
throw new Error("useToast must be used within ToastContainer");
|
|
1831
|
+
}
|
|
1832
|
+
return context;
|
|
1833
|
+
};
|
|
1834
|
+
ToastContainer2.displayName = "ToastContainer";
|
|
1835
|
+
var TabContainer = styled3.div`
|
|
1836
|
+
display: flex;
|
|
1837
|
+
flex-direction: column;
|
|
1838
|
+
`;
|
|
1839
|
+
var TabList = styled3.div`
|
|
1840
|
+
display: flex;
|
|
1841
|
+
align-items: center;
|
|
1842
|
+
position: relative;
|
|
1843
|
+
|
|
1844
|
+
${({ $variant, theme }) => {
|
|
1845
|
+
const variantConfig = theme.components.tab[$variant];
|
|
1846
|
+
return `
|
|
1847
|
+
gap: ${variantConfig.layout.gap};
|
|
1848
|
+
`;
|
|
1849
|
+
}}
|
|
1850
|
+
|
|
1851
|
+
${({ $variant }) => {
|
|
1852
|
+
if ($variant === "line") {
|
|
1853
|
+
return `
|
|
1854
|
+
border-bottom: 2px solid rgba(65, 70, 75, 0.1);
|
|
1855
|
+
`;
|
|
1856
|
+
}
|
|
1857
|
+
return "";
|
|
1858
|
+
}}
|
|
1859
|
+
`;
|
|
1860
|
+
var TabItem = styled3.button`
|
|
1861
|
+
display: inline-flex;
|
|
1862
|
+
align-items: center;
|
|
1863
|
+
justify-content: center;
|
|
1864
|
+
gap: 6px;
|
|
1865
|
+
border: none;
|
|
1866
|
+
outline: none;
|
|
1867
|
+
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
1868
|
+
transition: all 0.2s ease;
|
|
1869
|
+
position: relative;
|
|
1870
|
+
white-space: nowrap;
|
|
1871
|
+
|
|
1872
|
+
${({ theme }) => {
|
|
1873
|
+
const sizeConfig = theme.components.tab.large;
|
|
1874
|
+
return `
|
|
1875
|
+
height: ${sizeConfig.height};
|
|
1876
|
+
padding: ${sizeConfig.padding};
|
|
1877
|
+
font-size: ${sizeConfig.fontSize};
|
|
1878
|
+
line-height: ${sizeConfig.lineHeight};
|
|
1879
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
1880
|
+
font-weight: ${sizeConfig.fontWeight};
|
|
1881
|
+
`;
|
|
1882
|
+
}}
|
|
1883
|
+
|
|
1884
|
+
${({ $variant, $active, $disabled, theme }) => {
|
|
1885
|
+
const variantConfig = theme.components.tab[$variant];
|
|
1886
|
+
const itemConfig = variantConfig.item;
|
|
1887
|
+
if ($disabled) {
|
|
1888
|
+
return `
|
|
1889
|
+
background: ${itemConfig.backgroundDisabled};
|
|
1890
|
+
border-color: ${itemConfig.borderColorDisabled};
|
|
1891
|
+
color: ${itemConfig.colorDisabled};
|
|
1892
|
+
`;
|
|
1893
|
+
}
|
|
1894
|
+
if ($active) {
|
|
1895
|
+
return `
|
|
1896
|
+
background: ${itemConfig.backgroundActive};
|
|
1897
|
+
border-color: ${itemConfig.borderColorActive};
|
|
1898
|
+
color: ${itemConfig.colorActive};
|
|
1899
|
+
`;
|
|
1900
|
+
}
|
|
1901
|
+
return `
|
|
1902
|
+
background: ${itemConfig.background};
|
|
1903
|
+
border-color: ${itemConfig.borderColor};
|
|
1904
|
+
color: ${itemConfig.color};
|
|
1905
|
+
`;
|
|
1906
|
+
}}
|
|
1907
|
+
|
|
1908
|
+
${({ $variant, $disabled, theme }) => {
|
|
1909
|
+
if ($disabled) return "";
|
|
1910
|
+
const variantConfig = theme.components.tab[$variant];
|
|
1911
|
+
const itemConfig = variantConfig.item;
|
|
1912
|
+
return `
|
|
1913
|
+
&:hover {
|
|
1914
|
+
background: ${itemConfig.backgroundHover};
|
|
1915
|
+
border-color: ${itemConfig.borderColorHover};
|
|
1916
|
+
color: ${itemConfig.colorHover};
|
|
1917
|
+
}
|
|
1918
|
+
`;
|
|
1919
|
+
}}
|
|
1920
|
+
|
|
1921
|
+
${({ $variant, $active }) => {
|
|
1922
|
+
if ($variant === "line" && $active) {
|
|
1923
|
+
return `
|
|
1924
|
+
&::after {
|
|
1925
|
+
content: '';
|
|
1926
|
+
position: absolute;
|
|
1927
|
+
bottom: -2px;
|
|
1928
|
+
left: 0;
|
|
1929
|
+
right: 0;
|
|
1930
|
+
height: 2px;
|
|
1931
|
+
background: currentColor;
|
|
1932
|
+
}
|
|
1933
|
+
`;
|
|
1934
|
+
}
|
|
1935
|
+
if ($variant === "card") {
|
|
1936
|
+
return `
|
|
1937
|
+
border: 1px solid;
|
|
1938
|
+
${$active ? `
|
|
1939
|
+
border-bottom-color: transparent;
|
|
1940
|
+
margin-bottom: -1px;
|
|
1941
|
+
` : ""}
|
|
1942
|
+
`;
|
|
1943
|
+
}
|
|
1944
|
+
return "";
|
|
1945
|
+
}}
|
|
1946
|
+
`;
|
|
1947
|
+
var Tabs = ({
|
|
1948
|
+
items,
|
|
1949
|
+
activeKey: controlledActiveKey,
|
|
1950
|
+
defaultActiveKey,
|
|
1951
|
+
variant = "line",
|
|
1952
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1953
|
+
size: _size = "large",
|
|
1954
|
+
onChange,
|
|
1955
|
+
className,
|
|
1956
|
+
style
|
|
1957
|
+
}) => {
|
|
1958
|
+
const [internalActiveKey, setInternalActiveKey] = useState(
|
|
1959
|
+
controlledActiveKey ?? defaultActiveKey ?? items[0]?.key ?? ""
|
|
1960
|
+
);
|
|
1961
|
+
const activeKey = controlledActiveKey !== void 0 ? controlledActiveKey : internalActiveKey;
|
|
1962
|
+
const handleTabClick = useCallback(
|
|
1963
|
+
(key, disabled) => {
|
|
1964
|
+
if (disabled) return;
|
|
1965
|
+
if (controlledActiveKey === void 0) {
|
|
1966
|
+
setInternalActiveKey(key);
|
|
1967
|
+
}
|
|
1968
|
+
onChange?.(key);
|
|
1969
|
+
},
|
|
1970
|
+
[controlledActiveKey, onChange]
|
|
1971
|
+
);
|
|
1972
|
+
return /* @__PURE__ */ React11.createElement(TabContainer, { className, style }, /* @__PURE__ */ React11.createElement(TabList, { $variant: variant, role: "tablist" }, items.map((item) => /* @__PURE__ */ React11.createElement(
|
|
1973
|
+
TabItem,
|
|
1974
|
+
{
|
|
1975
|
+
key: item.key,
|
|
1976
|
+
$variant: variant,
|
|
1977
|
+
$active: activeKey === item.key,
|
|
1978
|
+
$disabled: item.disabled || false,
|
|
1979
|
+
onClick: () => handleTabClick(item.key, item.disabled),
|
|
1980
|
+
role: "tab",
|
|
1981
|
+
"aria-selected": activeKey === item.key,
|
|
1982
|
+
"aria-disabled": item.disabled,
|
|
1983
|
+
disabled: item.disabled,
|
|
1984
|
+
type: "button"
|
|
1985
|
+
},
|
|
1986
|
+
item.icon && /* @__PURE__ */ React11.createElement("span", null, item.icon),
|
|
1987
|
+
item.label
|
|
1988
|
+
))));
|
|
1989
|
+
};
|
|
1990
|
+
Tabs.displayName = "Tab";
|
|
1991
|
+
var TooltipGlobalStyles = createGlobalStyle`
|
|
1992
|
+
.rc-tooltip {
|
|
1993
|
+
position: absolute;
|
|
1994
|
+
z-index: 1070;
|
|
1995
|
+
display: block;
|
|
1996
|
+
visibility: visible;
|
|
1997
|
+
font-size: 12px;
|
|
1998
|
+
line-height: 1.5;
|
|
1999
|
+
opacity: 0;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
.rc-tooltip-hidden {
|
|
2003
|
+
display: none;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
.rc-tooltip-placement-top,
|
|
2007
|
+
.rc-tooltip-placement-topLeft,
|
|
2008
|
+
.rc-tooltip-placement-topRight {
|
|
2009
|
+
padding-bottom: 8px;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
.rc-tooltip-placement-right,
|
|
2013
|
+
.rc-tooltip-placement-rightTop,
|
|
2014
|
+
.rc-tooltip-placement-rightBottom {
|
|
2015
|
+
padding-left: 8px;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
.rc-tooltip-placement-bottom,
|
|
2019
|
+
.rc-tooltip-placement-bottomLeft,
|
|
2020
|
+
.rc-tooltip-placement-bottomRight {
|
|
2021
|
+
padding-top: 8px;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
.rc-tooltip-placement-left,
|
|
2025
|
+
.rc-tooltip-placement-leftTop,
|
|
2026
|
+
.rc-tooltip-placement-leftBottom {
|
|
2027
|
+
padding-right: 8px;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
.rc-tooltip-inner {
|
|
2031
|
+
/* istanbul ignore next - styled-components CSS generation */
|
|
2032
|
+
${({ $variant, $size, theme }) => {
|
|
2033
|
+
if ($variant === "black") {
|
|
2034
|
+
const config = theme.components.tooltip.black;
|
|
2035
|
+
return `
|
|
2036
|
+
background: ${config.background};
|
|
2037
|
+
border: 1px solid ${config.borderColor};
|
|
2038
|
+
color: ${config.color};
|
|
2039
|
+
border-radius: ${config.borderRadius};
|
|
2040
|
+
padding: ${config.padding};
|
|
2041
|
+
box-shadow: ${config.boxShadow};
|
|
2042
|
+
font-size: ${config.fontSize};
|
|
2043
|
+
line-height: ${config.lineHeight};
|
|
2044
|
+
font-weight: ${config.fontWeight};
|
|
2045
|
+
max-width: ${config.maxWidth};
|
|
2046
|
+
text-align: left;
|
|
2047
|
+
text-decoration: none;
|
|
2048
|
+
word-wrap: break-word;
|
|
2049
|
+
`;
|
|
2050
|
+
} else {
|
|
2051
|
+
const sizeConfig = theme.components.tooltip.white[$size || "small"];
|
|
2052
|
+
return `
|
|
2053
|
+
background: ${sizeConfig.background};
|
|
2054
|
+
border: 1px solid ${sizeConfig.borderColor};
|
|
2055
|
+
color: ${sizeConfig.color};
|
|
2056
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
2057
|
+
padding: ${sizeConfig.padding};
|
|
2058
|
+
box-shadow: ${sizeConfig.boxShadow};
|
|
2059
|
+
font-size: ${sizeConfig.fontSize};
|
|
2060
|
+
line-height: ${sizeConfig.lineHeight};
|
|
2061
|
+
font-weight: ${sizeConfig.fontWeight};
|
|
2062
|
+
text-align: left;
|
|
2063
|
+
text-decoration: none;
|
|
2064
|
+
word-wrap: break-word;
|
|
2065
|
+
`;
|
|
2066
|
+
}
|
|
2067
|
+
}}
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
.rc-tooltip-arrow {
|
|
2071
|
+
position: absolute;
|
|
2072
|
+
width: 0;
|
|
2073
|
+
height: 0;
|
|
2074
|
+
border-color: transparent;
|
|
2075
|
+
border-style: solid;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
/* istanbul ignore next - styled-components CSS generation */
|
|
2079
|
+
${({ $variant, theme }) => {
|
|
2080
|
+
const bgColor = $variant === "black" ? theme.components?.tooltip?.black?.background : theme.components?.tooltip?.white?.small?.background;
|
|
2081
|
+
return `
|
|
2082
|
+
.rc-tooltip-placement-top .rc-tooltip-arrow,
|
|
2083
|
+
.rc-tooltip-placement-topLeft .rc-tooltip-arrow,
|
|
2084
|
+
.rc-tooltip-placement-topRight .rc-tooltip-arrow {
|
|
2085
|
+
bottom: 3px;
|
|
2086
|
+
margin-left: -5px;
|
|
2087
|
+
border-width: 5px 5px 0;
|
|
2088
|
+
border-top-color: ${bgColor};
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
.rc-tooltip-placement-right .rc-tooltip-arrow,
|
|
2092
|
+
.rc-tooltip-placement-rightTop .rc-tooltip-arrow,
|
|
2093
|
+
.rc-tooltip-placement-rightBottom .rc-tooltip-arrow {
|
|
2094
|
+
left: 3px;
|
|
2095
|
+
margin-top: -5px;
|
|
2096
|
+
border-width: 5px 5px 5px 0;
|
|
2097
|
+
border-right-color: ${bgColor};
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
.rc-tooltip-placement-left .rc-tooltip-arrow,
|
|
2101
|
+
.rc-tooltip-placement-leftTop .rc-tooltip-arrow,
|
|
2102
|
+
.rc-tooltip-placement-leftBottom .rc-tooltip-arrow {
|
|
2103
|
+
right: 3px;
|
|
2104
|
+
margin-top: -5px;
|
|
2105
|
+
border-width: 5px 0 5px 5px;
|
|
2106
|
+
border-left-color: ${bgColor};
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
.rc-tooltip-placement-bottom .rc-tooltip-arrow,
|
|
2110
|
+
.rc-tooltip-placement-bottomLeft .rc-tooltip-arrow,
|
|
2111
|
+
.rc-tooltip-placement-bottomRight .rc-tooltip-arrow {
|
|
2112
|
+
top: 3px;
|
|
2113
|
+
margin-left: -5px;
|
|
2114
|
+
border-width: 0 5px 5px;
|
|
2115
|
+
border-bottom-color: ${bgColor};
|
|
2116
|
+
}
|
|
2117
|
+
`;
|
|
2118
|
+
}}
|
|
2119
|
+
|
|
2120
|
+
.rc-tooltip.rc-tooltip-zoom-enter,
|
|
2121
|
+
.rc-tooltip.rc-tooltip-zoom-leave {
|
|
2122
|
+
display: block;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
.rc-tooltip-zoom-enter,
|
|
2126
|
+
.rc-tooltip-zoom-appear {
|
|
2127
|
+
opacity: 0;
|
|
2128
|
+
animation-duration: 0.3s;
|
|
2129
|
+
animation-fill-mode: both;
|
|
2130
|
+
animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
|
|
2131
|
+
animation-play-state: paused;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
.rc-tooltip-zoom-leave {
|
|
2135
|
+
animation-duration: 0.3s;
|
|
2136
|
+
animation-fill-mode: both;
|
|
2137
|
+
animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05);
|
|
2138
|
+
animation-play-state: paused;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
.rc-tooltip-zoom-enter.rc-tooltip-zoom-enter-active,
|
|
2142
|
+
.rc-tooltip-zoom-appear.rc-tooltip-zoom-appear-active {
|
|
2143
|
+
animation-name: rcToolTipZoomIn;
|
|
2144
|
+
animation-play-state: running;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
.rc-tooltip-zoom-leave.rc-tooltip-zoom-leave-active {
|
|
2148
|
+
animation-name: rcToolTipZoomOut;
|
|
2149
|
+
animation-play-state: running;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
@keyframes rcToolTipZoomIn {
|
|
2153
|
+
0% {
|
|
2154
|
+
opacity: 0;
|
|
2155
|
+
transform-origin: 50% 50%;
|
|
2156
|
+
transform: scale(0, 0);
|
|
2157
|
+
}
|
|
2158
|
+
100% {
|
|
2159
|
+
opacity: 1;
|
|
2160
|
+
transform-origin: 50% 50%;
|
|
2161
|
+
transform: scale(1, 1);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
@keyframes rcToolTipZoomOut {
|
|
2166
|
+
0% {
|
|
2167
|
+
opacity: 1;
|
|
2168
|
+
transform-origin: 50% 50%;
|
|
2169
|
+
transform: scale(1, 1);
|
|
2170
|
+
}
|
|
2171
|
+
100% {
|
|
2172
|
+
opacity: 0;
|
|
2173
|
+
transform-origin: 50% 50%;
|
|
2174
|
+
transform: scale(0, 0);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
`;
|
|
2178
|
+
var Tooltip = ({
|
|
2179
|
+
content,
|
|
2180
|
+
variant = "black",
|
|
2181
|
+
size = "small",
|
|
2182
|
+
children,
|
|
2183
|
+
placement = "top",
|
|
2184
|
+
trigger = ["hover"],
|
|
2185
|
+
...rest
|
|
2186
|
+
}) => {
|
|
2187
|
+
const GlobalStyles = TooltipGlobalStyles;
|
|
2188
|
+
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(GlobalStyles, { $variant: variant, $size: size }), /* @__PURE__ */ React11.createElement(RcTooltip, { overlay: /* @__PURE__ */ React11.createElement("div", null, content), placement, trigger, ...rest }, children));
|
|
2189
|
+
};
|
|
2190
|
+
Tooltip.displayName = "Tooltip";
|
|
2191
|
+
var UIConfigContext = createContext(null);
|
|
2192
|
+
var UIConfigProvider = ({
|
|
2193
|
+
config,
|
|
2194
|
+
children
|
|
2195
|
+
}) => {
|
|
2196
|
+
const {
|
|
2197
|
+
theme,
|
|
2198
|
+
icons = {},
|
|
2199
|
+
toast = {}
|
|
2200
|
+
} = config;
|
|
2201
|
+
const toastConfig = {
|
|
2202
|
+
maxCount: toast.maxCount ?? 5,
|
|
2203
|
+
defaultDuration: toast.defaultDuration ?? 3e3
|
|
2204
|
+
};
|
|
2205
|
+
const Provider = ThemeProvider;
|
|
2206
|
+
return /* @__PURE__ */ React11.createElement(UIConfigContext.Provider, { value: config }, /* @__PURE__ */ React11.createElement(Provider, { theme }, /* @__PURE__ */ React11.createElement(IconProvider, { icons }, /* @__PURE__ */ React11.createElement(
|
|
2207
|
+
ToastContainer2,
|
|
2208
|
+
{
|
|
2209
|
+
maxCount: toastConfig.maxCount,
|
|
2210
|
+
defaultDuration: toastConfig.defaultDuration
|
|
2211
|
+
},
|
|
2212
|
+
children
|
|
2213
|
+
))));
|
|
2214
|
+
};
|
|
2215
|
+
var useUIConfig = () => {
|
|
2216
|
+
const context = useContext(UIConfigContext);
|
|
2217
|
+
if (!context) {
|
|
2218
|
+
throw new Error("useUIConfig must be used within UIConfigProvider");
|
|
2219
|
+
}
|
|
2220
|
+
return context;
|
|
2221
|
+
};
|
|
2222
|
+
UIConfigProvider.displayName = "UIConfigProvider";
|
|
2223
|
+
|
|
2224
|
+
// src/UIConfigProvider/createUIConfig.ts
|
|
2225
|
+
var createUIConfig = (config) => {
|
|
2226
|
+
return {
|
|
2227
|
+
// Theme is required
|
|
2228
|
+
theme: config.theme,
|
|
2229
|
+
// Icons with default
|
|
2230
|
+
icons: config.icons ?? {},
|
|
2231
|
+
// Toast with defaults
|
|
2232
|
+
toast: {
|
|
2233
|
+
maxCount: config.toast?.maxCount ?? 5,
|
|
2234
|
+
defaultDuration: config.toast?.defaultDuration ?? 3e3,
|
|
2235
|
+
position: config.toast?.position ?? "top-right",
|
|
2236
|
+
offset: {
|
|
2237
|
+
x: config.toast?.offset?.x ?? 24,
|
|
2238
|
+
y: config.toast?.offset?.y ?? 24
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
// Locale with default
|
|
2242
|
+
locale: config.locale ?? "en-US",
|
|
2243
|
+
// I18n with defaults
|
|
2244
|
+
i18n: {
|
|
2245
|
+
toast: {
|
|
2246
|
+
closeLabel: config.i18n?.toast?.closeLabel ?? "Close"
|
|
2247
|
+
},
|
|
2248
|
+
button: {
|
|
2249
|
+
loadingText: config.i18n?.button?.loadingText ?? "Loading..."
|
|
2250
|
+
},
|
|
2251
|
+
common: {
|
|
2252
|
+
confirm: config.i18n?.common?.confirm ?? "Confirm",
|
|
2253
|
+
cancel: config.i18n?.common?.cancel ?? "Cancel",
|
|
2254
|
+
ok: config.i18n?.common?.ok ?? "OK"
|
|
2255
|
+
}
|
|
2256
|
+
},
|
|
2257
|
+
// Z-index with defaults
|
|
2258
|
+
zIndex: {
|
|
2259
|
+
toast: config.zIndex?.toast ?? 9999,
|
|
2260
|
+
modal: config.zIndex?.modal ?? 1e4,
|
|
2261
|
+
dropdown: config.zIndex?.dropdown ?? 1e3,
|
|
2262
|
+
tooltip: config.zIndex?.tooltip ?? 1001
|
|
2263
|
+
},
|
|
2264
|
+
// Animation with defaults
|
|
2265
|
+
animation: {
|
|
2266
|
+
duration: config.animation?.duration ?? 200,
|
|
2267
|
+
easing: config.animation?.easing ?? "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
2268
|
+
disabled: config.animation?.disabled ?? false
|
|
2269
|
+
},
|
|
2270
|
+
// A11y with defaults
|
|
2271
|
+
a11y: {
|
|
2272
|
+
announceMessages: config.a11y?.announceMessages ?? true,
|
|
2273
|
+
focusVisible: config.a11y?.focusVisible ?? true,
|
|
2274
|
+
reduceMotion: config.a11y?.reduceMotion ?? false
|
|
2275
|
+
}
|
|
2276
|
+
};
|
|
2277
|
+
};
|
|
2278
|
+
var mergeUIConfig = (baseConfig, ...configs) => {
|
|
2279
|
+
const merged = configs.reduce((acc, config) => ({
|
|
2280
|
+
...acc,
|
|
2281
|
+
...config,
|
|
2282
|
+
toast: { ...acc.toast, ...config.toast },
|
|
2283
|
+
i18n: { ...acc.i18n, ...config.i18n },
|
|
2284
|
+
zIndex: { ...acc.zIndex, ...config.zIndex },
|
|
2285
|
+
animation: { ...acc.animation, ...config.animation },
|
|
2286
|
+
a11y: { ...acc.a11y, ...config.a11y }
|
|
2287
|
+
}), baseConfig);
|
|
2288
|
+
return merged;
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
export { Button, Checkbox, Icon, IconProvider, Input, Radio, SearchInput, Slider, SpinButton, Switch, Tabs, Toast, ToastContainer2 as ToastContainer, Tooltip, UIConfigProvider, createUIConfig, mergeUIConfig, useIconRegistry, useToast, useUIConfig };
|
|
2292
|
+
//# sourceMappingURL=index.mjs.map
|
|
2293
|
+
//# sourceMappingURL=index.mjs.map
|