@officesdk/design 0.2.0 → 0.2.2

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