@officesdk/design 0.1.6 → 0.1.9
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/dist/components/cjs/index.d.ts +436 -30
- package/dist/components/cjs/index.js +2548 -1129
- package/dist/components/cjs/index.js.map +1 -1
- package/dist/components/esm/index.d.ts +436 -30
- package/dist/components/esm/index.js +2465 -1046
- package/dist/components/esm/index.js.map +1 -1
- package/dist/theme/cjs/index.js +324 -221
- package/dist/theme/cjs/index.js.map +1 -1
- package/dist/theme/esm/index.js +324 -221
- package/dist/theme/esm/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,62 +1,595 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React3, { forwardRef, useState, createContext, useEffect, useRef, useCallback, useContext, useMemo } from 'react';
|
|
2
2
|
import baseStyled, { createGlobalStyle } from 'styled-components';
|
|
3
3
|
import RcTooltip from 'rc-tooltip';
|
|
4
4
|
import 'rc-tooltip/assets/bootstrap.css';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import RcMenu, { Divider as Divider$1, ItemGroup, SubMenu, MenuItem } from 'rc-menu';
|
|
6
|
+
import VirtualList from 'rc-virtual-list';
|
|
7
|
+
import 'rc-menu/assets/index.css';
|
|
8
|
+
import RcDropdown from 'rc-dropdown';
|
|
9
|
+
import 'rc-dropdown/assets/index.css';
|
|
10
|
+
import ReactDOM from 'react-dom';
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
16
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
20
|
};
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
var IconContext, IconProvider, useIconRegistry;
|
|
22
|
+
var init_IconProvider = __esm({
|
|
23
|
+
"src/Icon/IconProvider.tsx"() {
|
|
24
|
+
IconContext = createContext(null);
|
|
25
|
+
IconProvider = ({
|
|
26
|
+
icons,
|
|
27
|
+
children
|
|
28
|
+
}) => {
|
|
29
|
+
return /* @__PURE__ */ React3.createElement(IconContext.Provider, { value: icons }, children);
|
|
30
|
+
};
|
|
31
|
+
useIconRegistry = () => {
|
|
32
|
+
return useContext(IconContext);
|
|
33
|
+
};
|
|
34
|
+
IconProvider.displayName = "IconProvider";
|
|
19
35
|
}
|
|
20
|
-
};
|
|
36
|
+
});
|
|
37
|
+
var IconContainer, Icon;
|
|
38
|
+
var init_Icon = __esm({
|
|
39
|
+
"src/Icon/Icon.tsx"() {
|
|
40
|
+
init_styled();
|
|
41
|
+
init_IconProvider();
|
|
42
|
+
IconContainer = styled.span`
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
width: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
47
|
+
height: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
48
|
+
color: ${({ $color }) => $color};
|
|
49
|
+
flex-shrink: 0;
|
|
50
|
+
line-height: 1;
|
|
21
51
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
52
|
+
svg {
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
display: block;
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
Icon = ({
|
|
59
|
+
name,
|
|
60
|
+
src,
|
|
61
|
+
children,
|
|
62
|
+
size = 16,
|
|
63
|
+
color = "currentColor",
|
|
64
|
+
alt = "icon",
|
|
65
|
+
className,
|
|
66
|
+
style,
|
|
67
|
+
onClick
|
|
68
|
+
}) => {
|
|
69
|
+
const registry = useIconRegistry();
|
|
70
|
+
let iconElement = children;
|
|
71
|
+
if (!iconElement && src) {
|
|
72
|
+
iconElement = /* @__PURE__ */ React3.createElement(
|
|
73
|
+
"img",
|
|
74
|
+
{
|
|
75
|
+
src,
|
|
76
|
+
alt,
|
|
77
|
+
style: { width: "100%", height: "100%", display: "block" }
|
|
78
|
+
}
|
|
79
|
+
);
|
|
29
80
|
}
|
|
81
|
+
if (!iconElement && name && registry) {
|
|
82
|
+
const IconComponent = registry[name];
|
|
83
|
+
if (IconComponent) {
|
|
84
|
+
iconElement = /* @__PURE__ */ React3.createElement(IconComponent, null);
|
|
85
|
+
} else if (process.env.NODE_ENV !== "production") {
|
|
86
|
+
console.warn(`Icon "${name}" not found in registry. Make sure IconProvider is set up.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!iconElement) {
|
|
90
|
+
if (process.env.NODE_ENV !== "production" && !children && !name && !src) {
|
|
91
|
+
console.warn('Icon: one of "name", "src", or "children" must be provided');
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ React3.createElement(
|
|
96
|
+
IconContainer,
|
|
97
|
+
{
|
|
98
|
+
$size: size,
|
|
99
|
+
$color: color,
|
|
100
|
+
className,
|
|
101
|
+
style,
|
|
102
|
+
onClick
|
|
103
|
+
},
|
|
104
|
+
iconElement
|
|
105
|
+
);
|
|
30
106
|
};
|
|
107
|
+
Icon.displayName = "Icon";
|
|
31
108
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// src/Icon/index.ts
|
|
112
|
+
var init_Icon2 = __esm({
|
|
113
|
+
"src/Icon/index.ts"() {
|
|
114
|
+
init_Icon();
|
|
115
|
+
init_IconProvider();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
var ToastContainer, IconWrapper, ContentWrapper, Message, Description, ActionGroup, SuccessIcon, InfoIcon, ErrorIcon, WarnIcon, CloseIconSvg, Toast;
|
|
119
|
+
var init_Toast = __esm({
|
|
120
|
+
"src/Toast/Toast.tsx"() {
|
|
121
|
+
init_styled();
|
|
122
|
+
init_Icon2();
|
|
123
|
+
init_Button2();
|
|
124
|
+
init_context();
|
|
125
|
+
ToastContainer = styled.div`
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 8px;
|
|
129
|
+
border: 1px solid;
|
|
130
|
+
box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.08);
|
|
131
|
+
|
|
132
|
+
${({ theme: theme3 }) => {
|
|
133
|
+
const baseConfig = theme3.components.toast;
|
|
134
|
+
return `
|
|
135
|
+
padding: ${baseConfig.padding};
|
|
136
|
+
border-radius: ${baseConfig.borderRadius};
|
|
137
|
+
font-size: ${baseConfig.fontSize};
|
|
138
|
+
font-weight: ${baseConfig.fontWeight};
|
|
139
|
+
`;
|
|
140
|
+
}}
|
|
141
|
+
|
|
142
|
+
${({ $variant, theme: theme3 }) => {
|
|
143
|
+
const variantConfig = theme3.components.toast[$variant];
|
|
144
|
+
return `
|
|
145
|
+
background: ${variantConfig.background};
|
|
146
|
+
border-color: ${variantConfig.borderColor};
|
|
147
|
+
`;
|
|
148
|
+
}}
|
|
149
|
+
`;
|
|
150
|
+
IconWrapper = styled.div`
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: center;
|
|
154
|
+
flex-shrink: 0;
|
|
155
|
+
|
|
156
|
+
${({ $hasDescription }) => {
|
|
157
|
+
const size = $hasDescription ? "28px" : "18px";
|
|
158
|
+
return `
|
|
159
|
+
width: ${size};
|
|
160
|
+
height: ${size};
|
|
161
|
+
`;
|
|
162
|
+
}}
|
|
163
|
+
`;
|
|
164
|
+
ContentWrapper = styled.div`
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: ${({ $hasDescription }) => $hasDescription ? "column" : "row"};
|
|
167
|
+
align-items: ${({ $hasDescription }) => $hasDescription ? "flex-start" : "center"};
|
|
168
|
+
gap: ${({ $hasDescription }) => $hasDescription ? "2px" : "0"};
|
|
169
|
+
flex: 1;
|
|
170
|
+
`;
|
|
171
|
+
Message = styled.span`
|
|
172
|
+
font-size: 13px;
|
|
173
|
+
line-height: 20px;
|
|
174
|
+
color: ${({ theme: theme3 }) => theme3.colors.palettes.gray["100"]};
|
|
175
|
+
`;
|
|
176
|
+
Description = styled.span`
|
|
177
|
+
font-size: 12px;
|
|
178
|
+
line-height: 20px;
|
|
179
|
+
color: ${({ theme: theme3 }) => theme3.colors.palettes.transparency["60"]};
|
|
180
|
+
`;
|
|
181
|
+
ActionGroup = styled.div`
|
|
182
|
+
display: flex;
|
|
183
|
+
gap: 2px;
|
|
184
|
+
align-items: center;
|
|
185
|
+
`;
|
|
186
|
+
SuccessIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#4ea44b" }), /* @__PURE__ */ React3.createElement("path", { d: "M6 10L9 13L14 7", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
187
|
+
InfoIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#5ba0e7" }), /* @__PURE__ */ React3.createElement("path", { d: "M10 9V14M10 6H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
188
|
+
ErrorIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#e95555" }), /* @__PURE__ */ React3.createElement("path", { d: "M7 7L13 13M13 7L7 13", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
189
|
+
WarnIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#ebe361" }), /* @__PURE__ */ React3.createElement("path", { d: "M10 6V11M10 14H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
190
|
+
CloseIconSvg = () => /* @__PURE__ */ React3.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("path", { d: "M9 3L3 9M3 3L9 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }));
|
|
191
|
+
Toast = ({
|
|
192
|
+
variant = "info",
|
|
193
|
+
message,
|
|
194
|
+
description,
|
|
195
|
+
mainButtonText,
|
|
196
|
+
onMainButtonClick,
|
|
197
|
+
secondaryButtonText,
|
|
198
|
+
onSecondaryButtonClick,
|
|
199
|
+
closable = false,
|
|
200
|
+
onClose,
|
|
201
|
+
duration = 0,
|
|
202
|
+
icon,
|
|
203
|
+
showIcon = true,
|
|
204
|
+
className,
|
|
205
|
+
style
|
|
206
|
+
}) => {
|
|
207
|
+
const [visible, setVisible] = useState(true);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (duration > 0) {
|
|
210
|
+
const timer = setTimeout(() => {
|
|
211
|
+
setVisible(false);
|
|
212
|
+
onClose?.();
|
|
213
|
+
}, duration);
|
|
214
|
+
return () => clearTimeout(timer);
|
|
215
|
+
}
|
|
216
|
+
}, [duration, onClose]);
|
|
217
|
+
const handleClose = () => {
|
|
218
|
+
setVisible(false);
|
|
219
|
+
onClose?.();
|
|
220
|
+
};
|
|
221
|
+
if (!visible) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const getIconElement = () => {
|
|
225
|
+
if (icon) {
|
|
226
|
+
return icon;
|
|
227
|
+
}
|
|
228
|
+
const theme3 = getGlobalTheme();
|
|
229
|
+
const themeIconUrl = theme3?.components?.toast?.[variant]?.icon?.url;
|
|
230
|
+
if (themeIconUrl) {
|
|
231
|
+
return /* @__PURE__ */ React3.createElement(Icon, { src: themeIconUrl });
|
|
232
|
+
}
|
|
233
|
+
const defaultIcons = {
|
|
234
|
+
success: /* @__PURE__ */ React3.createElement(SuccessIcon, null),
|
|
235
|
+
info: /* @__PURE__ */ React3.createElement(InfoIcon, null),
|
|
236
|
+
error: /* @__PURE__ */ React3.createElement(ErrorIcon, null),
|
|
237
|
+
warn: /* @__PURE__ */ React3.createElement(WarnIcon, null)
|
|
238
|
+
};
|
|
239
|
+
return defaultIcons[variant];
|
|
240
|
+
};
|
|
241
|
+
const iconElement = getIconElement();
|
|
242
|
+
const hasDescription = !!description;
|
|
243
|
+
const hasActions = !!(mainButtonText || secondaryButtonText || closable);
|
|
244
|
+
return /* @__PURE__ */ React3.createElement(
|
|
245
|
+
ToastContainer,
|
|
246
|
+
{
|
|
247
|
+
$variant: variant,
|
|
248
|
+
className,
|
|
249
|
+
style,
|
|
250
|
+
role: "alert",
|
|
251
|
+
"aria-live": "polite"
|
|
252
|
+
},
|
|
253
|
+
showIcon && /* @__PURE__ */ React3.createElement(IconWrapper, { $variant: variant, $hasDescription: hasDescription }, iconElement),
|
|
254
|
+
/* @__PURE__ */ React3.createElement(ContentWrapper, { $hasDescription: hasDescription }, /* @__PURE__ */ React3.createElement(Message, null, message), description && /* @__PURE__ */ React3.createElement(Description, null, description)),
|
|
255
|
+
hasActions && /* @__PURE__ */ React3.createElement(ActionGroup, null, mainButtonText && onMainButtonClick && /* @__PURE__ */ React3.createElement(
|
|
256
|
+
Button,
|
|
257
|
+
{
|
|
258
|
+
variant: "text",
|
|
259
|
+
colorType: "guidance",
|
|
260
|
+
size: "small",
|
|
261
|
+
onClick: onMainButtonClick
|
|
262
|
+
},
|
|
263
|
+
mainButtonText
|
|
264
|
+
), secondaryButtonText && onSecondaryButtonClick && /* @__PURE__ */ React3.createElement(
|
|
265
|
+
Button,
|
|
266
|
+
{
|
|
267
|
+
variant: "text",
|
|
268
|
+
colorType: "default",
|
|
269
|
+
size: "small",
|
|
270
|
+
onClick: onSecondaryButtonClick
|
|
271
|
+
},
|
|
272
|
+
secondaryButtonText
|
|
273
|
+
), closable && /* @__PURE__ */ React3.createElement(
|
|
274
|
+
Button,
|
|
275
|
+
{
|
|
276
|
+
variant: "icon",
|
|
277
|
+
colorType: "default",
|
|
278
|
+
size: "small",
|
|
279
|
+
onClick: handleClose,
|
|
280
|
+
"aria-label": "Close",
|
|
281
|
+
icon: /* @__PURE__ */ React3.createElement(CloseIconSvg, null),
|
|
282
|
+
iconBordered: false
|
|
283
|
+
}
|
|
284
|
+
))
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
Toast.displayName = "Toast";
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// src/Toast/toastManager.tsx
|
|
292
|
+
var toastManager_exports = {};
|
|
293
|
+
__export(toastManager_exports, {
|
|
294
|
+
toast: () => toast,
|
|
295
|
+
toastManager: () => toastManager
|
|
296
|
+
});
|
|
297
|
+
var ToastWrapper, ToastManager, toastManager, toast;
|
|
298
|
+
var init_toastManager = __esm({
|
|
299
|
+
"src/Toast/toastManager.tsx"() {
|
|
300
|
+
init_Toast();
|
|
301
|
+
init_styled();
|
|
302
|
+
ToastWrapper = styled.div`
|
|
303
|
+
position: fixed;
|
|
304
|
+
z-index: 9999;
|
|
305
|
+
display: flex;
|
|
306
|
+
flex-direction: column;
|
|
307
|
+
gap: 12px;
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
|
|
310
|
+
> * {
|
|
311
|
+
pointer-events: auto;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
${({ $placement, theme: theme3 }) => {
|
|
315
|
+
const offset = theme3.components?.toast?.offset || { vertical: "24px", horizontal: "24px" };
|
|
316
|
+
const vertical = offset.vertical || "24px";
|
|
317
|
+
const horizontal = offset.horizontal || "24px";
|
|
318
|
+
const styles = {
|
|
319
|
+
"top-right": `
|
|
320
|
+
top: ${vertical};
|
|
321
|
+
right: ${horizontal};
|
|
322
|
+
`,
|
|
323
|
+
"top-left": `
|
|
324
|
+
top: ${vertical};
|
|
325
|
+
left: ${horizontal};
|
|
326
|
+
`,
|
|
327
|
+
"top-center": `
|
|
328
|
+
top: ${vertical};
|
|
329
|
+
left: 50%;
|
|
330
|
+
transform: translateX(-50%);
|
|
331
|
+
`,
|
|
332
|
+
"bottom-right": `
|
|
333
|
+
bottom: ${vertical};
|
|
334
|
+
right: ${horizontal};
|
|
335
|
+
`,
|
|
336
|
+
"bottom-left": `
|
|
337
|
+
bottom: ${vertical};
|
|
338
|
+
left: ${horizontal};
|
|
339
|
+
`,
|
|
340
|
+
"bottom-center": `
|
|
341
|
+
bottom: ${vertical};
|
|
342
|
+
left: 50%;
|
|
343
|
+
transform: translateX(-50%);
|
|
344
|
+
`
|
|
345
|
+
};
|
|
346
|
+
return styles[$placement] || styles["top-right"];
|
|
347
|
+
}}
|
|
348
|
+
`;
|
|
349
|
+
ToastManager = class {
|
|
350
|
+
constructor() {
|
|
351
|
+
this.toasts = [];
|
|
352
|
+
this.container = null;
|
|
353
|
+
this.renderFunc = null;
|
|
354
|
+
this.config = {
|
|
355
|
+
placement: "top-right",
|
|
356
|
+
maxCount: 5,
|
|
357
|
+
defaultDuration: 3e3
|
|
358
|
+
};
|
|
359
|
+
this.tryGetRenderFunction();
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Try to get render function from global context
|
|
363
|
+
*/
|
|
364
|
+
tryGetRenderFunction() {
|
|
365
|
+
if (typeof window !== "undefined") {
|
|
366
|
+
Promise.resolve().then(() => (init_context(), context_exports)).then(({ getGlobalRenderFunction: getGlobalRenderFunction2 }) => {
|
|
367
|
+
const renderFunc = getGlobalRenderFunction2();
|
|
368
|
+
if (renderFunc) {
|
|
369
|
+
this.renderFunc = renderFunc;
|
|
370
|
+
}
|
|
371
|
+
}).catch(() => {
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Set render function (from registerGlobalContext)
|
|
377
|
+
*/
|
|
378
|
+
setRenderFunction(renderFunc) {
|
|
379
|
+
this.renderFunc = renderFunc;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Initialize the toast container
|
|
383
|
+
*/
|
|
384
|
+
initialize() {
|
|
385
|
+
if (this.container) return;
|
|
386
|
+
if (!this.renderFunc) {
|
|
387
|
+
console.warn("Toast render function not set. Please call registerGlobalContext first.");
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
this.container = document.createElement("div");
|
|
391
|
+
this.container.id = "officesdk-toast-container";
|
|
392
|
+
document.body.appendChild(this.container);
|
|
393
|
+
this.render();
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Render toasts to DOM
|
|
397
|
+
*/
|
|
398
|
+
render() {
|
|
399
|
+
if (!this.container || !this.renderFunc) return;
|
|
400
|
+
const element = /* @__PURE__ */ React3.createElement(React3.Fragment, null, this.toasts.map((toast2) => {
|
|
401
|
+
return /* @__PURE__ */ React3.createElement(ToastWrapper, { key: toast2.id, $placement: toast2.placement || "top-center" }, /* @__PURE__ */ React3.createElement(Toast, { ...toast2, onClose: () => this.hide(toast2.id) }));
|
|
402
|
+
}));
|
|
403
|
+
this.renderFunc(element, this.container);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Configure toast container
|
|
407
|
+
*/
|
|
408
|
+
configure(config) {
|
|
409
|
+
this.config = { ...this.config, ...config };
|
|
410
|
+
this.render();
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Show a toast
|
|
414
|
+
*/
|
|
415
|
+
show(props) {
|
|
416
|
+
this.initialize();
|
|
417
|
+
const id = `toast-${Date.now()}-${Math.random()}`;
|
|
418
|
+
const newToast = {
|
|
419
|
+
...props,
|
|
420
|
+
id,
|
|
421
|
+
duration: props.duration ?? this.config.defaultDuration
|
|
422
|
+
};
|
|
423
|
+
this.toasts = [...this.toasts, newToast].slice(-(this.config.maxCount || 5));
|
|
424
|
+
this.render();
|
|
425
|
+
return id;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Hide a toast by id
|
|
429
|
+
*/
|
|
430
|
+
hide(id) {
|
|
431
|
+
this.toasts = this.toasts.filter((toast2) => toast2.id !== id);
|
|
432
|
+
this.render();
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Hide all toasts
|
|
436
|
+
*/
|
|
437
|
+
hideAll() {
|
|
438
|
+
this.toasts = [];
|
|
439
|
+
this.render();
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Show success toast
|
|
443
|
+
*/
|
|
444
|
+
success(message, options) {
|
|
445
|
+
return this.show({ ...options, variant: "success", message });
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Show info toast
|
|
449
|
+
*/
|
|
450
|
+
info(message, options) {
|
|
451
|
+
return this.show({ ...options, variant: "info", message });
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Show error toast
|
|
455
|
+
*/
|
|
456
|
+
error(message, options) {
|
|
457
|
+
return this.show({ ...options, variant: "error", message });
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Show warning toast
|
|
461
|
+
*/
|
|
462
|
+
warn(message, options) {
|
|
463
|
+
return this.show({ ...options, variant: "warn", message });
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Destroy the toast container
|
|
467
|
+
*/
|
|
468
|
+
destroy() {
|
|
469
|
+
if (this.container) {
|
|
470
|
+
if (this.renderFunc) {
|
|
471
|
+
this.renderFunc(/* @__PURE__ */ React3.createElement(React3.Fragment, null), this.container);
|
|
472
|
+
}
|
|
473
|
+
if (this.container.parentNode) {
|
|
474
|
+
this.container.parentNode.removeChild(this.container);
|
|
475
|
+
}
|
|
476
|
+
this.container = null;
|
|
477
|
+
}
|
|
478
|
+
this.toasts = [];
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Get current toasts
|
|
482
|
+
*/
|
|
483
|
+
getToasts() {
|
|
484
|
+
return this.toasts;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Clear all toasts (for testing)
|
|
488
|
+
*/
|
|
489
|
+
clear() {
|
|
490
|
+
this.toasts = [];
|
|
491
|
+
this.render();
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
toastManager = new ToastManager();
|
|
495
|
+
toast = {
|
|
496
|
+
configure: (config) => toastManager.configure(config),
|
|
497
|
+
show: (props) => toastManager.show(props),
|
|
498
|
+
hide: (id) => toastManager.hide(id),
|
|
499
|
+
hideAll: () => toastManager.hideAll(),
|
|
500
|
+
success: (message, options) => toastManager.success(message, options),
|
|
501
|
+
info: (message, options) => toastManager.info(message, options),
|
|
502
|
+
error: (message, options) => toastManager.error(message, options),
|
|
503
|
+
warn: (message, options) => toastManager.warn(message, options),
|
|
504
|
+
destroy: () => toastManager.destroy()
|
|
44
505
|
};
|
|
45
506
|
}
|
|
46
507
|
});
|
|
47
|
-
var styled = styledWithBase;
|
|
48
508
|
|
|
49
|
-
// src/
|
|
50
|
-
var
|
|
509
|
+
// src/utils/context.ts
|
|
510
|
+
var context_exports = {};
|
|
511
|
+
__export(context_exports, {
|
|
512
|
+
getGlobalRenderFunction: () => getGlobalRenderFunction,
|
|
513
|
+
getGlobalTheme: () => getGlobalTheme,
|
|
514
|
+
registerGlobalContext: () => registerGlobalContext
|
|
515
|
+
});
|
|
516
|
+
var globalTheme, registerGlobalTheme, getGlobalTheme, globalRenderFunction, getGlobalRenderFunction, registerGlobalContext;
|
|
517
|
+
var init_context = __esm({
|
|
518
|
+
"src/utils/context.ts"() {
|
|
519
|
+
globalTheme = {};
|
|
520
|
+
registerGlobalTheme = (theme3) => {
|
|
521
|
+
Object.assign(globalTheme, { ...globalTheme, ...theme3 });
|
|
522
|
+
};
|
|
523
|
+
getGlobalTheme = () => {
|
|
524
|
+
return globalTheme;
|
|
525
|
+
};
|
|
526
|
+
globalRenderFunction = null;
|
|
527
|
+
getGlobalRenderFunction = () => globalRenderFunction;
|
|
528
|
+
registerGlobalContext = (context) => {
|
|
529
|
+
if (context.theme) {
|
|
530
|
+
registerGlobalTheme(context.theme);
|
|
531
|
+
}
|
|
532
|
+
if (context.render) {
|
|
533
|
+
globalRenderFunction = context.render;
|
|
534
|
+
if (typeof window !== "undefined") {
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
Promise.resolve().then(() => (init_toastManager(), toastManager_exports)).then(({ toastManager: toastManager2 }) => {
|
|
537
|
+
toastManager2.setRenderFunction(context.render);
|
|
538
|
+
}).catch(() => {
|
|
539
|
+
});
|
|
540
|
+
}, 0);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
var wrapWithTheme, styledFunction, styledWithBase, styled;
|
|
547
|
+
var init_styled = __esm({
|
|
548
|
+
"src/utils/styled.ts"() {
|
|
549
|
+
init_context();
|
|
550
|
+
wrapWithTheme = (component) => {
|
|
551
|
+
if (component && typeof component === "object") {
|
|
552
|
+
component.defaultProps = {
|
|
553
|
+
...component.defaultProps,
|
|
554
|
+
get theme() {
|
|
555
|
+
return getGlobalTheme();
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
return component;
|
|
560
|
+
};
|
|
561
|
+
styledFunction = (tag) => {
|
|
562
|
+
return wrapWithTheme(baseStyled(tag));
|
|
563
|
+
};
|
|
564
|
+
styledWithBase = Object.assign(styledFunction, baseStyled);
|
|
565
|
+
Object.keys(baseStyled).forEach((key) => {
|
|
566
|
+
const originalMethod = baseStyled[key];
|
|
567
|
+
if (typeof originalMethod === "function") {
|
|
568
|
+
styledWithBase[key] = (...args) => {
|
|
569
|
+
const component = originalMethod(...args);
|
|
570
|
+
return wrapWithTheme(component);
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
styled = styledWithBase;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
var IconWrapper2, TextWrapper, IconOnlyWrapper, StyledButton, Button;
|
|
578
|
+
var init_Button = __esm({
|
|
579
|
+
"src/Button/Button.tsx"() {
|
|
580
|
+
init_styled();
|
|
581
|
+
init_Icon2();
|
|
582
|
+
IconWrapper2 = styled.span`
|
|
51
583
|
display: inline-flex;
|
|
52
584
|
align-items: center;
|
|
53
585
|
justify-content: center;
|
|
54
586
|
flex-shrink: 0;
|
|
55
587
|
|
|
56
|
-
${({ $size, $
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
588
|
+
${({ $size, $iconPlacement, theme: theme3 }) => {
|
|
589
|
+
const buttonConfig = theme3.components.button[$size || "medium"];
|
|
590
|
+
const sizeConfig = buttonConfig?.withIcon || buttonConfig;
|
|
591
|
+
const marginSide = $iconPlacement === "before" ? "margin-right" : "margin-left";
|
|
592
|
+
return `
|
|
60
593
|
width: ${sizeConfig.iconSize.width};
|
|
61
594
|
height: ${sizeConfig.iconSize.height};
|
|
62
595
|
${marginSide}: ${sizeConfig.iconGap};
|
|
@@ -67,9 +600,39 @@ var IconWrapper = styled.span`
|
|
|
67
600
|
display: block;
|
|
68
601
|
}
|
|
69
602
|
`;
|
|
70
|
-
}}
|
|
603
|
+
}}
|
|
604
|
+
`;
|
|
605
|
+
TextWrapper = styled.span`
|
|
606
|
+
${({ $size, theme: theme3 }) => {
|
|
607
|
+
const buttonConfig = theme3.components.button[$size || "medium"];
|
|
608
|
+
const sizeConfig = buttonConfig?.withIcon || buttonConfig;
|
|
609
|
+
return `
|
|
610
|
+
padding: ${sizeConfig.textPadding || "0"};
|
|
611
|
+
`;
|
|
612
|
+
}}
|
|
613
|
+
`;
|
|
614
|
+
IconOnlyWrapper = styled.span`
|
|
615
|
+
display: inline-flex;
|
|
616
|
+
align-items: center;
|
|
617
|
+
justify-content: center;
|
|
618
|
+
flex-shrink: 0;
|
|
619
|
+
|
|
620
|
+
${({ $size, theme: theme3 }) => {
|
|
621
|
+
const buttonConfig = theme3.components.button[$size || "medium"];
|
|
622
|
+
const sizeConfig = buttonConfig?.onlyIcon || buttonConfig;
|
|
623
|
+
return `
|
|
624
|
+
width: ${sizeConfig.iconSize?.width || "14px"};
|
|
625
|
+
height: ${sizeConfig.iconSize?.height || "14px"};
|
|
626
|
+
|
|
627
|
+
svg, img {
|
|
628
|
+
width: 100%;
|
|
629
|
+
height: 100%;
|
|
630
|
+
display: block;
|
|
631
|
+
}
|
|
632
|
+
`;
|
|
633
|
+
}}
|
|
71
634
|
`;
|
|
72
|
-
|
|
635
|
+
StyledButton = styled.button`
|
|
73
636
|
display: inline-flex;
|
|
74
637
|
align-items: center;
|
|
75
638
|
justify-content: center;
|
|
@@ -79,31 +642,32 @@ var StyledButton = styled.button`
|
|
|
79
642
|
width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
|
|
80
643
|
|
|
81
644
|
/* Size variants */
|
|
82
|
-
${({ $size, $
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
border-radius: ${
|
|
645
|
+
${({ $size, $variant, theme: theme3 }) => {
|
|
646
|
+
const sizeName = $size || "medium";
|
|
647
|
+
const buttonConfig = theme3.components.button[sizeName];
|
|
648
|
+
if ($variant === "icon") {
|
|
649
|
+
const sizeConfig2 = buttonConfig?.onlyIcon || buttonConfig;
|
|
650
|
+
return `
|
|
651
|
+
padding: ${sizeConfig2.padding || "7px"};
|
|
652
|
+
border-radius: ${sizeConfig2.borderRadius || theme3.borderRadius.small};
|
|
90
653
|
`;
|
|
91
|
-
|
|
92
|
-
|
|
654
|
+
}
|
|
655
|
+
const sizeConfig = buttonConfig?.withIcon || buttonConfig;
|
|
656
|
+
return `
|
|
93
657
|
padding: ${sizeConfig.padding};
|
|
94
658
|
font-size: ${sizeConfig.fontSize};
|
|
95
659
|
line-height: ${sizeConfig.lineHeight};
|
|
96
660
|
border-radius: ${sizeConfig.borderRadius};
|
|
97
661
|
min-height: ${sizeConfig.height};
|
|
98
662
|
`;
|
|
99
|
-
}}
|
|
663
|
+
}}
|
|
100
664
|
|
|
101
665
|
/* Variant and color type styles */
|
|
102
|
-
${({ $variant, $colorType, $
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
666
|
+
${({ $variant, $colorType, $iconBordered, theme: theme3 }) => {
|
|
667
|
+
if ($variant === "icon") {
|
|
668
|
+
const baseVariant = $iconBordered ? "outlined" : "text";
|
|
669
|
+
const styles2 = theme3.components.button[baseVariant]["default"];
|
|
670
|
+
return `
|
|
107
671
|
background: ${styles2.background};
|
|
108
672
|
color: ${styles2.color};
|
|
109
673
|
border: 1px solid ${styles2.borderColor};
|
|
@@ -131,17 +695,17 @@ var StyledButton = styled.button`
|
|
|
131
695
|
cursor: not-allowed;
|
|
132
696
|
}
|
|
133
697
|
`;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
698
|
+
}
|
|
699
|
+
const variant = $variant || "solid";
|
|
700
|
+
const colorType = $colorType || "default";
|
|
701
|
+
if (colorType === "status" && variant !== "text") {
|
|
702
|
+
console.warn(
|
|
703
|
+
`colorType 'status' is only available for 'text' variant. Falling back to 'default'.`
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
const effectiveColorType = colorType === "status" && variant !== "text" ? "default" : colorType;
|
|
707
|
+
const styles = theme3.components.button[variant][effectiveColorType];
|
|
708
|
+
return `
|
|
145
709
|
background: ${styles.background};
|
|
146
710
|
color: ${styles.color};
|
|
147
711
|
border: 1px solid ${styles.borderColor};
|
|
@@ -170,40 +734,46 @@ var StyledButton = styled.button`
|
|
|
170
734
|
cursor: not-allowed;
|
|
171
735
|
}
|
|
172
736
|
`;
|
|
173
|
-
}}
|
|
737
|
+
}}
|
|
174
738
|
`;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
...rest
|
|
187
|
-
}) => {
|
|
188
|
-
const isIconOnly = variant === "icon" || !children && !!(iconBefore || iconAfter);
|
|
189
|
-
const iconOnlyContent = iconBefore || iconAfter;
|
|
190
|
-
return /* @__PURE__ */ React12.createElement(
|
|
191
|
-
StyledButton,
|
|
192
|
-
{
|
|
193
|
-
$variant: variant,
|
|
194
|
-
$colorType: colorType,
|
|
195
|
-
$size: size,
|
|
196
|
-
$fullWidth: fullWidth,
|
|
197
|
-
$isIconOnly: isIconOnly,
|
|
198
|
-
$iconBordered: iconBordered,
|
|
199
|
-
disabled: disabled || loading,
|
|
739
|
+
Button = ({
|
|
740
|
+
variant = "solid",
|
|
741
|
+
colorType = "default",
|
|
742
|
+
size = "medium",
|
|
743
|
+
disabled = false,
|
|
744
|
+
loading = false,
|
|
745
|
+
fullWidth = false,
|
|
746
|
+
icon,
|
|
747
|
+
iconPlacement = "before",
|
|
748
|
+
iconBordered = false,
|
|
749
|
+
children,
|
|
200
750
|
...rest
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
751
|
+
}) => {
|
|
752
|
+
return /* @__PURE__ */ React3.createElement(
|
|
753
|
+
StyledButton,
|
|
754
|
+
{
|
|
755
|
+
$variant: variant,
|
|
756
|
+
$colorType: colorType,
|
|
757
|
+
$size: size,
|
|
758
|
+
$fullWidth: fullWidth,
|
|
759
|
+
$iconBordered: iconBordered,
|
|
760
|
+
disabled: disabled || loading,
|
|
761
|
+
...rest
|
|
762
|
+
},
|
|
763
|
+
loading ? /* @__PURE__ */ React3.createElement(TextWrapper, { $size: size }, "Loading...") : variant === "icon" ? (
|
|
764
|
+
// Icon variant: render icon with onlyIcon wrapper (uses onlyIcon config)
|
|
765
|
+
/* @__PURE__ */ React3.createElement(IconOnlyWrapper, { $size: size }, typeof icon === "string" ? /* @__PURE__ */ React3.createElement(Icon, { src: icon }) : icon || children)
|
|
766
|
+
) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, icon && iconPlacement === "before" && /* @__PURE__ */ React3.createElement(IconWrapper2, { $size: size, $iconPlacement: "before" }, typeof icon === "string" ? /* @__PURE__ */ React3.createElement(Icon, { src: icon }) : icon), /* @__PURE__ */ React3.createElement(TextWrapper, { $size: size }, children), icon && iconPlacement === "after" && /* @__PURE__ */ React3.createElement(IconWrapper2, { $size: size, $iconPlacement: "after" }, typeof icon === "string" ? /* @__PURE__ */ React3.createElement(Icon, { src: icon }) : icon))
|
|
767
|
+
);
|
|
768
|
+
};
|
|
769
|
+
Button.displayName = "Button";
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
var SliderContainer, SliderTrack, SliderFill, SliderThumb, Slider;
|
|
773
|
+
var init_Slider = __esm({
|
|
774
|
+
"src/Slider/Slider.tsx"() {
|
|
775
|
+
init_styled();
|
|
776
|
+
SliderContainer = styled.div`
|
|
207
777
|
position: relative;
|
|
208
778
|
display: flex;
|
|
209
779
|
align-items: center;
|
|
@@ -212,17 +782,17 @@ var SliderContainer = styled.div`
|
|
|
212
782
|
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
213
783
|
user-select: none;
|
|
214
784
|
`;
|
|
215
|
-
|
|
785
|
+
SliderTrack = styled.div`
|
|
216
786
|
position: absolute;
|
|
217
787
|
left: 0;
|
|
218
788
|
right: 0;
|
|
219
789
|
height: 2px;
|
|
220
|
-
background: ${({ theme:
|
|
790
|
+
background: ${({ theme: theme3 }) => theme3.colors.palettes.transparency["20"]};
|
|
221
791
|
border-radius: 1000px;
|
|
222
792
|
top: 50%;
|
|
223
793
|
transform: translateY(-50%);
|
|
224
794
|
`;
|
|
225
|
-
|
|
795
|
+
SliderFill = styled.div`
|
|
226
796
|
position: absolute;
|
|
227
797
|
left: 0;
|
|
228
798
|
height: 2px;
|
|
@@ -230,14 +800,14 @@ var SliderFill = styled.div`
|
|
|
230
800
|
top: 50%;
|
|
231
801
|
transform: translateY(-50%);
|
|
232
802
|
width: ${({ $percentage }) => $percentage}%;
|
|
233
|
-
background: ${({ $disabled, theme:
|
|
803
|
+
background: ${({ $disabled, theme: theme3 }) => $disabled ? theme3.colors.palettes.transparency["10"] : theme3.colors.palettes.gray["100"]};
|
|
234
804
|
`;
|
|
235
|
-
|
|
805
|
+
SliderThumb = styled.div`
|
|
236
806
|
position: absolute;
|
|
237
807
|
width: 10px;
|
|
238
808
|
height: 10px;
|
|
239
809
|
border-radius: 50%;
|
|
240
|
-
background: ${({ $disabled, theme:
|
|
810
|
+
background: ${({ $disabled, theme: theme3 }) => $disabled ? theme3.colors.palettes.transparency["30"] : theme3.colors.palettes.blue["5"]};
|
|
241
811
|
left: ${({ $percentage }) => $percentage}%;
|
|
242
812
|
top: 50%;
|
|
243
813
|
transform: translate(-50%, -50%);
|
|
@@ -256,131 +826,144 @@ var SliderThumb = styled.div`
|
|
|
256
826
|
}
|
|
257
827
|
`}
|
|
258
828
|
`;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
className,
|
|
270
|
-
style
|
|
271
|
-
}) => {
|
|
272
|
-
const [internalValue, setInternalValue] = useState(
|
|
273
|
-
controlledValue ?? defaultValue
|
|
274
|
-
);
|
|
275
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
276
|
-
const containerRef = useRef(null);
|
|
277
|
-
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
278
|
-
const percentage = (value - min) / (max - min) * 100;
|
|
279
|
-
const updateValue = useCallback(
|
|
280
|
-
(clientX) => {
|
|
281
|
-
if (!containerRef.current || disabled) return;
|
|
282
|
-
const rect = containerRef.current.getBoundingClientRect();
|
|
283
|
-
const offsetX = clientX - rect.left;
|
|
284
|
-
const newPercentage = Math.max(0, Math.min(100, offsetX / rect.width * 100));
|
|
285
|
-
const rawValue = newPercentage / 100 * (max - min) + min;
|
|
286
|
-
const steppedValue = Math.round(rawValue / step) * step;
|
|
287
|
-
const clampedValue = Math.max(min, Math.min(max, steppedValue));
|
|
288
|
-
if (controlledValue === void 0) {
|
|
289
|
-
setInternalValue(clampedValue);
|
|
290
|
-
}
|
|
291
|
-
onChange?.(clampedValue);
|
|
292
|
-
},
|
|
293
|
-
[min, max, step, disabled, controlledValue, onChange]
|
|
294
|
-
);
|
|
295
|
-
const handleMouseDown = useCallback(
|
|
296
|
-
(e) => {
|
|
297
|
-
if (disabled) return;
|
|
298
|
-
e.preventDefault();
|
|
299
|
-
setIsDragging(true);
|
|
300
|
-
onDragStart?.();
|
|
301
|
-
updateValue(e.clientX);
|
|
302
|
-
},
|
|
303
|
-
[disabled, onDragStart, updateValue]
|
|
304
|
-
);
|
|
305
|
-
useEffect(() => {
|
|
306
|
-
if (!isDragging) return;
|
|
307
|
-
const handleMouseMove = (e) => {
|
|
308
|
-
updateValue(e.clientX);
|
|
309
|
-
};
|
|
310
|
-
const handleMouseUp = () => {
|
|
311
|
-
setIsDragging(false);
|
|
312
|
-
onDragEnd?.();
|
|
313
|
-
};
|
|
314
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
315
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
316
|
-
return () => {
|
|
317
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
318
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
319
|
-
};
|
|
320
|
-
}, [isDragging, updateValue, onDragEnd]);
|
|
321
|
-
const handleKeyDown = useCallback(
|
|
322
|
-
(e) => {
|
|
323
|
-
if (disabled) return;
|
|
324
|
-
let newValue = value;
|
|
325
|
-
switch (e.key) {
|
|
326
|
-
case "ArrowLeft":
|
|
327
|
-
case "ArrowDown":
|
|
328
|
-
e.preventDefault();
|
|
329
|
-
newValue = Math.max(min, value - step);
|
|
330
|
-
break;
|
|
331
|
-
case "ArrowRight":
|
|
332
|
-
case "ArrowUp":
|
|
333
|
-
e.preventDefault();
|
|
334
|
-
newValue = Math.min(max, value + step);
|
|
335
|
-
break;
|
|
336
|
-
case "Home":
|
|
337
|
-
e.preventDefault();
|
|
338
|
-
newValue = min;
|
|
339
|
-
break;
|
|
340
|
-
case "End":
|
|
341
|
-
e.preventDefault();
|
|
342
|
-
newValue = max;
|
|
343
|
-
break;
|
|
344
|
-
default:
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (controlledValue === void 0) {
|
|
348
|
-
setInternalValue(newValue);
|
|
349
|
-
}
|
|
350
|
-
onChange?.(newValue);
|
|
351
|
-
},
|
|
352
|
-
[disabled, value, min, max, step, controlledValue, onChange]
|
|
353
|
-
);
|
|
354
|
-
return /* @__PURE__ */ React12.createElement(
|
|
355
|
-
SliderContainer,
|
|
356
|
-
{
|
|
357
|
-
ref: containerRef,
|
|
358
|
-
$disabled: disabled,
|
|
829
|
+
Slider = ({
|
|
830
|
+
value: controlledValue,
|
|
831
|
+
defaultValue = 0,
|
|
832
|
+
min = 0,
|
|
833
|
+
max = 100,
|
|
834
|
+
step = 1,
|
|
835
|
+
disabled = false,
|
|
836
|
+
onChange,
|
|
837
|
+
onDragStart,
|
|
838
|
+
onDragEnd,
|
|
359
839
|
className,
|
|
360
|
-
style
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
840
|
+
style
|
|
841
|
+
}) => {
|
|
842
|
+
const [internalValue, setInternalValue] = useState(
|
|
843
|
+
controlledValue ?? defaultValue
|
|
844
|
+
);
|
|
845
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
846
|
+
const containerRef = useRef(null);
|
|
847
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
848
|
+
const percentage = (value - min) / (max - min) * 100;
|
|
849
|
+
const updateValue = useCallback(
|
|
850
|
+
(clientX) => {
|
|
851
|
+
if (!containerRef.current || disabled) return;
|
|
852
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
853
|
+
const offsetX = clientX - rect.left;
|
|
854
|
+
const newPercentage = Math.max(0, Math.min(100, offsetX / rect.width * 100));
|
|
855
|
+
const rawValue = newPercentage / 100 * (max - min) + min;
|
|
856
|
+
const steppedValue = Math.round(rawValue / step) * step;
|
|
857
|
+
const clampedValue = Math.max(min, Math.min(max, steppedValue));
|
|
858
|
+
if (controlledValue === void 0) {
|
|
859
|
+
setInternalValue(clampedValue);
|
|
860
|
+
}
|
|
861
|
+
onChange?.(clampedValue);
|
|
862
|
+
},
|
|
863
|
+
[min, max, step, disabled, controlledValue, onChange]
|
|
864
|
+
);
|
|
865
|
+
const handleMouseDown = useCallback(
|
|
866
|
+
(e) => {
|
|
867
|
+
if (disabled) return;
|
|
868
|
+
e.preventDefault();
|
|
869
|
+
setIsDragging(true);
|
|
870
|
+
onDragStart?.();
|
|
871
|
+
updateValue(e.clientX);
|
|
872
|
+
},
|
|
873
|
+
[disabled, onDragStart, updateValue]
|
|
874
|
+
);
|
|
875
|
+
useEffect(() => {
|
|
876
|
+
if (!isDragging) return;
|
|
877
|
+
const handleMouseMove = (e) => {
|
|
878
|
+
updateValue(e.clientX);
|
|
879
|
+
};
|
|
880
|
+
const handleMouseUp = () => {
|
|
881
|
+
setIsDragging(false);
|
|
882
|
+
onDragEnd?.();
|
|
883
|
+
};
|
|
884
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
885
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
886
|
+
return () => {
|
|
887
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
888
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
889
|
+
};
|
|
890
|
+
}, [isDragging, updateValue, onDragEnd]);
|
|
891
|
+
const handleKeyDown = useCallback(
|
|
892
|
+
(e) => {
|
|
893
|
+
if (disabled) return;
|
|
894
|
+
let newValue = value;
|
|
895
|
+
switch (e.key) {
|
|
896
|
+
case "ArrowLeft":
|
|
897
|
+
case "ArrowDown":
|
|
898
|
+
e.preventDefault();
|
|
899
|
+
newValue = Math.max(min, value - step);
|
|
900
|
+
break;
|
|
901
|
+
case "ArrowRight":
|
|
902
|
+
case "ArrowUp":
|
|
903
|
+
e.preventDefault();
|
|
904
|
+
newValue = Math.min(max, value + step);
|
|
905
|
+
break;
|
|
906
|
+
case "Home":
|
|
907
|
+
e.preventDefault();
|
|
908
|
+
newValue = min;
|
|
909
|
+
break;
|
|
910
|
+
case "End":
|
|
911
|
+
e.preventDefault();
|
|
912
|
+
newValue = max;
|
|
913
|
+
break;
|
|
914
|
+
default:
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
if (controlledValue === void 0) {
|
|
918
|
+
setInternalValue(newValue);
|
|
919
|
+
}
|
|
920
|
+
onChange?.(newValue);
|
|
921
|
+
},
|
|
922
|
+
[disabled, value, min, max, step, controlledValue, onChange]
|
|
923
|
+
);
|
|
924
|
+
return /* @__PURE__ */ React3.createElement(
|
|
925
|
+
SliderContainer,
|
|
926
|
+
{
|
|
927
|
+
ref: containerRef,
|
|
928
|
+
$disabled: disabled,
|
|
929
|
+
className,
|
|
930
|
+
style,
|
|
931
|
+
onMouseDown: handleMouseDown,
|
|
932
|
+
onKeyDown: handleKeyDown,
|
|
933
|
+
tabIndex: disabled ? -1 : 0,
|
|
934
|
+
role: "slider",
|
|
935
|
+
"aria-valuemin": min,
|
|
936
|
+
"aria-valuemax": max,
|
|
937
|
+
"aria-valuenow": value,
|
|
938
|
+
"aria-disabled": disabled
|
|
939
|
+
},
|
|
940
|
+
/* @__PURE__ */ React3.createElement(SliderTrack, { $disabled: disabled }),
|
|
941
|
+
/* @__PURE__ */ React3.createElement(SliderFill, { $percentage: percentage, $disabled: disabled }),
|
|
942
|
+
/* @__PURE__ */ React3.createElement(
|
|
943
|
+
SliderThumb,
|
|
944
|
+
{
|
|
945
|
+
$percentage: percentage,
|
|
946
|
+
$disabled: disabled,
|
|
947
|
+
$isDragging: isDragging
|
|
948
|
+
}
|
|
949
|
+
)
|
|
950
|
+
);
|
|
951
|
+
};
|
|
952
|
+
Slider.displayName = "Slider";
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
// src/Slider/index.ts
|
|
957
|
+
var init_Slider2 = __esm({
|
|
958
|
+
"src/Slider/index.ts"() {
|
|
959
|
+
init_Slider();
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
var NumberInputContainer, InputWrapper, UnitText, StyledInput, ButtonGroup, StepButton, UpArrow, DownArrow, NumberInput;
|
|
963
|
+
var init_NumberInput = __esm({
|
|
964
|
+
"src/NumberInput/NumberInput.tsx"() {
|
|
965
|
+
init_styled();
|
|
966
|
+
NumberInputContainer = styled.div`
|
|
384
967
|
display: inline-flex;
|
|
385
968
|
align-items: center;
|
|
386
969
|
background: white;
|
|
@@ -396,35 +979,35 @@ var NumberInputContainer = styled.div`
|
|
|
396
979
|
width: 80px;
|
|
397
980
|
`}
|
|
398
981
|
|
|
399
|
-
${({ $disabled, $alert, $isFocused, theme:
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
border-color: ${
|
|
982
|
+
${({ $disabled, $alert, $isFocused, theme: theme3 }) => {
|
|
983
|
+
if ($disabled) {
|
|
984
|
+
return `
|
|
985
|
+
border-color: ${theme3.colors.palettes.transparency["10"]};
|
|
403
986
|
cursor: not-allowed;
|
|
404
987
|
`;
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
border-color: ${
|
|
988
|
+
}
|
|
989
|
+
if ($alert) {
|
|
990
|
+
return `
|
|
991
|
+
border-color: ${theme3.colors.palettes.red["6"]};
|
|
409
992
|
`;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
border-color: ${
|
|
993
|
+
}
|
|
994
|
+
if ($isFocused) {
|
|
995
|
+
return `
|
|
996
|
+
border-color: ${theme3.colors.palettes.transparency["30"]};
|
|
414
997
|
box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.04);
|
|
415
998
|
`;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
border-color: ${
|
|
999
|
+
}
|
|
1000
|
+
return `
|
|
1001
|
+
border-color: ${theme3.colors.palettes.transparency["10"]};
|
|
419
1002
|
|
|
420
1003
|
&:hover {
|
|
421
|
-
border-color: ${
|
|
1004
|
+
border-color: ${theme3.colors.palettes.transparency["20"]};
|
|
422
1005
|
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.04);
|
|
423
1006
|
}
|
|
424
1007
|
`;
|
|
425
|
-
}}
|
|
1008
|
+
}}
|
|
426
1009
|
`;
|
|
427
|
-
|
|
1010
|
+
InputWrapper = styled.div`
|
|
428
1011
|
flex: 1;
|
|
429
1012
|
display: flex;
|
|
430
1013
|
align-items: center;
|
|
@@ -432,7 +1015,7 @@ var InputWrapper = styled.div`
|
|
|
432
1015
|
min-width: 0;
|
|
433
1016
|
gap: 4px;
|
|
434
1017
|
`;
|
|
435
|
-
|
|
1018
|
+
UnitText = styled.span`
|
|
436
1019
|
flex-shrink: 0;
|
|
437
1020
|
font-family: 'PingFang SC', sans-serif;
|
|
438
1021
|
font-weight: 400;
|
|
@@ -444,13 +1027,13 @@ var UnitText = styled.span`
|
|
|
444
1027
|
font-size: 13px;
|
|
445
1028
|
`}
|
|
446
1029
|
|
|
447
|
-
${({ $disabled, theme:
|
|
448
|
-
color: ${
|
|
1030
|
+
${({ $disabled, theme: theme3 }) => $disabled ? `
|
|
1031
|
+
color: ${theme3.colors.palettes.transparency["30"]};
|
|
449
1032
|
` : `
|
|
450
|
-
color: ${
|
|
1033
|
+
color: ${theme3.colors.palettes.gray["120"]};
|
|
451
1034
|
`}
|
|
452
1035
|
`;
|
|
453
|
-
|
|
1036
|
+
StyledInput = styled.input`
|
|
454
1037
|
width: 100%;
|
|
455
1038
|
border: none;
|
|
456
1039
|
outline: none;
|
|
@@ -467,15 +1050,15 @@ var StyledInput = styled.input`
|
|
|
467
1050
|
font-size: 13px;
|
|
468
1051
|
`}
|
|
469
1052
|
|
|
470
|
-
${({ $disabled, theme:
|
|
471
|
-
color: ${
|
|
1053
|
+
${({ $disabled, theme: theme3 }) => $disabled ? `
|
|
1054
|
+
color: ${theme3.colors.palettes.transparency["30"]};
|
|
472
1055
|
cursor: not-allowed;
|
|
473
1056
|
` : `
|
|
474
|
-
color: ${
|
|
1057
|
+
color: ${theme3.colors.palettes.gray["120"]};
|
|
475
1058
|
`}
|
|
476
1059
|
|
|
477
1060
|
&::placeholder {
|
|
478
|
-
color: ${({ theme:
|
|
1061
|
+
color: ${({ theme: theme3 }) => theme3.colors.palettes.transparency["30"]};
|
|
479
1062
|
}
|
|
480
1063
|
|
|
481
1064
|
/* Remove number input arrows */
|
|
@@ -490,24 +1073,24 @@ var StyledInput = styled.input`
|
|
|
490
1073
|
-moz-appearance: textfield;
|
|
491
1074
|
}
|
|
492
1075
|
`;
|
|
493
|
-
|
|
1076
|
+
ButtonGroup = styled.div`
|
|
494
1077
|
display: flex;
|
|
495
1078
|
flex-direction: column;
|
|
496
1079
|
height: 100%;
|
|
497
1080
|
border-left: 1px solid;
|
|
498
1081
|
flex-shrink: 0;
|
|
499
1082
|
|
|
500
|
-
${({ $disabled, $alert, theme:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}}
|
|
1083
|
+
${({ $disabled, $alert, theme: theme3 }) => {
|
|
1084
|
+
if ($disabled) {
|
|
1085
|
+
return `border-color: ${theme3.colors.palettes.transparency["10"]};`;
|
|
1086
|
+
}
|
|
1087
|
+
if ($alert) {
|
|
1088
|
+
return `border-color: ${theme3.colors.palettes.red["6"]};`;
|
|
1089
|
+
}
|
|
1090
|
+
return `border-color: ${theme3.colors.palettes.transparency["10"]};`;
|
|
1091
|
+
}}
|
|
509
1092
|
`;
|
|
510
|
-
|
|
1093
|
+
StepButton = styled.button`
|
|
511
1094
|
flex: 1 1 50%;
|
|
512
1095
|
display: flex;
|
|
513
1096
|
align-items: center;
|
|
@@ -520,206 +1103,219 @@ var StepButton = styled.button`
|
|
|
520
1103
|
min-height: 0;
|
|
521
1104
|
overflow: hidden;
|
|
522
1105
|
|
|
523
|
-
${({ $position, $alert, $disabled, theme:
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
border-bottom: 1px solid ${$disabled ?
|
|
1106
|
+
${({ $position, $alert, $disabled, theme: theme3 }) => {
|
|
1107
|
+
if ($position === "up") {
|
|
1108
|
+
return `
|
|
1109
|
+
border-bottom: 1px solid ${$disabled ? theme3.colors.palettes.transparency["10"] : $alert ? theme3.colors.palettes.red["6"] : theme3.colors.palettes.transparency["10"]};
|
|
527
1110
|
`;
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}}
|
|
1111
|
+
}
|
|
1112
|
+
return "";
|
|
1113
|
+
}}
|
|
531
1114
|
|
|
532
|
-
${({ $disabled, theme:
|
|
533
|
-
|
|
534
|
-
|
|
1115
|
+
${({ $disabled, theme: theme3 }) => {
|
|
1116
|
+
if ($disabled) {
|
|
1117
|
+
return `
|
|
535
1118
|
cursor: not-allowed;
|
|
536
1119
|
opacity: 0.4;
|
|
537
1120
|
`;
|
|
538
|
-
|
|
539
|
-
|
|
1121
|
+
}
|
|
1122
|
+
return `
|
|
540
1123
|
&:hover {
|
|
541
|
-
background-color: ${
|
|
1124
|
+
background-color: ${theme3.colors.palettes.transparency["5"]};
|
|
542
1125
|
}
|
|
543
1126
|
|
|
544
1127
|
&:active {
|
|
545
|
-
background-color: ${
|
|
1128
|
+
background-color: ${theme3.colors.palettes.transparency["10"]};
|
|
546
1129
|
}
|
|
547
1130
|
`;
|
|
548
|
-
}}
|
|
1131
|
+
}}
|
|
549
1132
|
|
|
550
1133
|
svg {
|
|
551
1134
|
width: 14px;
|
|
552
1135
|
height: 14px;
|
|
553
|
-
fill: ${({ $disabled, theme:
|
|
1136
|
+
fill: ${({ $disabled, theme: theme3 }) => $disabled ? theme3.colors.palettes.transparency["30"] : theme3.colors.palettes.gray["120"]};
|
|
554
1137
|
}
|
|
555
1138
|
`;
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
className,
|
|
573
|
-
style
|
|
574
|
-
}) => {
|
|
575
|
-
const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
|
|
576
|
-
const [displayValue, setDisplayValue] = useState("");
|
|
577
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
578
|
-
const inputRef = useRef(null);
|
|
579
|
-
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
580
|
-
const formatValue = useCallback(
|
|
581
|
-
(val) => {
|
|
582
|
-
if (formatter) {
|
|
583
|
-
return formatter(val);
|
|
584
|
-
}
|
|
585
|
-
if (precision !== void 0) {
|
|
586
|
-
return val.toFixed(precision);
|
|
587
|
-
}
|
|
588
|
-
return String(val);
|
|
589
|
-
},
|
|
590
|
-
[formatter, precision]
|
|
591
|
-
);
|
|
592
|
-
const parseValue = useCallback(
|
|
593
|
-
(displayVal) => {
|
|
594
|
-
if (parser) {
|
|
595
|
-
return parser(displayVal);
|
|
596
|
-
}
|
|
597
|
-
const parsed = parseFloat(displayVal);
|
|
598
|
-
return isNaN(parsed) ? null : parsed;
|
|
599
|
-
},
|
|
600
|
-
[parser]
|
|
601
|
-
);
|
|
602
|
-
useEffect(() => {
|
|
603
|
-
if (!isFocused) {
|
|
604
|
-
setDisplayValue(formatValue(value));
|
|
605
|
-
}
|
|
606
|
-
}, [value, isFocused, formatValue]);
|
|
607
|
-
const clampValue = useCallback(
|
|
608
|
-
(val) => {
|
|
609
|
-
return Math.max(min, Math.min(max, val));
|
|
610
|
-
},
|
|
611
|
-
[min, max]
|
|
612
|
-
);
|
|
613
|
-
const handleValueChange = useCallback(
|
|
614
|
-
(newValue) => {
|
|
615
|
-
const clampedValue = clampValue(newValue);
|
|
616
|
-
if (controlledValue === void 0) {
|
|
617
|
-
setInternalValue(clampedValue);
|
|
618
|
-
}
|
|
619
|
-
onChange?.(clampedValue);
|
|
620
|
-
},
|
|
621
|
-
[clampValue, controlledValue, onChange]
|
|
622
|
-
);
|
|
623
|
-
const increment = useCallback(() => {
|
|
624
|
-
if (disabled) return;
|
|
625
|
-
handleValueChange(value + step);
|
|
626
|
-
}, [disabled, value, step, handleValueChange]);
|
|
627
|
-
const decrement = useCallback(() => {
|
|
628
|
-
if (disabled) return;
|
|
629
|
-
handleValueChange(value - step);
|
|
630
|
-
}, [disabled, value, step, handleValueChange]);
|
|
631
|
-
const handleInputChange = useCallback((e) => {
|
|
632
|
-
setDisplayValue(e.target.value);
|
|
633
|
-
}, []);
|
|
634
|
-
const handleBlur = useCallback(() => {
|
|
635
|
-
setIsFocused(false);
|
|
636
|
-
const parsed = parseValue(displayValue);
|
|
637
|
-
if (parsed !== null) {
|
|
638
|
-
handleValueChange(parsed);
|
|
639
|
-
} else {
|
|
640
|
-
setDisplayValue(formatValue(value));
|
|
641
|
-
}
|
|
642
|
-
}, [displayValue, parseValue, handleValueChange, value, formatValue]);
|
|
643
|
-
const handleFocus = useCallback(() => {
|
|
644
|
-
setIsFocused(true);
|
|
645
|
-
setDisplayValue(String(value));
|
|
646
|
-
}, [value]);
|
|
647
|
-
const handleKeyDown = useCallback(
|
|
648
|
-
(e) => {
|
|
649
|
-
if (e.key === "ArrowUp") {
|
|
650
|
-
e.preventDefault();
|
|
651
|
-
increment();
|
|
652
|
-
} else if (e.key === "ArrowDown") {
|
|
653
|
-
e.preventDefault();
|
|
654
|
-
decrement();
|
|
655
|
-
} else if (e.key === "Enter") {
|
|
656
|
-
inputRef.current?.blur();
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
[increment, decrement]
|
|
660
|
-
);
|
|
661
|
-
return /* @__PURE__ */ React12.createElement(
|
|
662
|
-
NumberInputContainer,
|
|
663
|
-
{
|
|
664
|
-
$size: size,
|
|
665
|
-
$disabled: disabled,
|
|
666
|
-
$alert: alert,
|
|
667
|
-
$isFocused: isFocused,
|
|
1139
|
+
UpArrow = () => /* @__PURE__ */ React3.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("path", { d: "M7 4.5L10.5 8.5H3.5L7 4.5Z", fill: "currentColor" }));
|
|
1140
|
+
DownArrow = () => /* @__PURE__ */ React3.createElement("svg", { viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React3.createElement("path", { d: "M7 9.5L3.5 5.5H10.5L7 9.5Z", fill: "currentColor" }));
|
|
1141
|
+
NumberInput = ({
|
|
1142
|
+
value: controlledValue,
|
|
1143
|
+
defaultValue = 0,
|
|
1144
|
+
min = -Infinity,
|
|
1145
|
+
max = Infinity,
|
|
1146
|
+
step = 1,
|
|
1147
|
+
size = "large",
|
|
1148
|
+
disabled = false,
|
|
1149
|
+
alert = false,
|
|
1150
|
+
precision,
|
|
1151
|
+
formatter,
|
|
1152
|
+
parser,
|
|
1153
|
+
unit,
|
|
1154
|
+
onChange,
|
|
668
1155
|
className,
|
|
669
1156
|
style
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
1157
|
+
}) => {
|
|
1158
|
+
const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
|
|
1159
|
+
const [displayValue, setDisplayValue] = useState("");
|
|
1160
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
1161
|
+
const inputRef = useRef(null);
|
|
1162
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
1163
|
+
const formatValue = useCallback(
|
|
1164
|
+
(val) => {
|
|
1165
|
+
if (formatter) {
|
|
1166
|
+
return formatter(val);
|
|
1167
|
+
}
|
|
1168
|
+
if (precision !== void 0) {
|
|
1169
|
+
return val.toFixed(precision);
|
|
1170
|
+
}
|
|
1171
|
+
return String(val);
|
|
1172
|
+
},
|
|
1173
|
+
[formatter, precision]
|
|
1174
|
+
);
|
|
1175
|
+
const parseValue = useCallback(
|
|
1176
|
+
(displayVal) => {
|
|
1177
|
+
if (parser) {
|
|
1178
|
+
return parser(displayVal);
|
|
1179
|
+
}
|
|
1180
|
+
const parsed = parseFloat(displayVal);
|
|
1181
|
+
return isNaN(parsed) ? null : parsed;
|
|
1182
|
+
},
|
|
1183
|
+
[parser]
|
|
1184
|
+
);
|
|
1185
|
+
useEffect(() => {
|
|
1186
|
+
if (!isFocused) {
|
|
1187
|
+
setDisplayValue(formatValue(value));
|
|
1188
|
+
}
|
|
1189
|
+
}, [value, isFocused, formatValue]);
|
|
1190
|
+
const clampValue = useCallback(
|
|
1191
|
+
(val) => {
|
|
1192
|
+
return Math.max(min, Math.min(max, val));
|
|
1193
|
+
},
|
|
1194
|
+
[min, max]
|
|
1195
|
+
);
|
|
1196
|
+
const handleValueChange = useCallback(
|
|
1197
|
+
(newValue) => {
|
|
1198
|
+
const clampedValue = clampValue(newValue);
|
|
1199
|
+
if (controlledValue === void 0) {
|
|
1200
|
+
setInternalValue(clampedValue);
|
|
1201
|
+
}
|
|
1202
|
+
onChange?.(clampedValue);
|
|
1203
|
+
},
|
|
1204
|
+
[clampValue, controlledValue, onChange]
|
|
1205
|
+
);
|
|
1206
|
+
const increment = useCallback(() => {
|
|
1207
|
+
if (disabled) return;
|
|
1208
|
+
handleValueChange(value + step);
|
|
1209
|
+
}, [disabled, value, step, handleValueChange]);
|
|
1210
|
+
const decrement = useCallback(() => {
|
|
1211
|
+
if (disabled) return;
|
|
1212
|
+
handleValueChange(value - step);
|
|
1213
|
+
}, [disabled, value, step, handleValueChange]);
|
|
1214
|
+
const handleInputChange = useCallback((e) => {
|
|
1215
|
+
setDisplayValue(e.target.value);
|
|
1216
|
+
}, []);
|
|
1217
|
+
const handleBlur = useCallback(() => {
|
|
1218
|
+
setIsFocused(false);
|
|
1219
|
+
const parsed = parseValue(displayValue);
|
|
1220
|
+
if (parsed !== null) {
|
|
1221
|
+
handleValueChange(parsed);
|
|
1222
|
+
} else {
|
|
1223
|
+
setDisplayValue(formatValue(value));
|
|
1224
|
+
}
|
|
1225
|
+
}, [displayValue, parseValue, handleValueChange, value, formatValue]);
|
|
1226
|
+
const handleFocus = useCallback(() => {
|
|
1227
|
+
setIsFocused(true);
|
|
1228
|
+
setDisplayValue(String(value));
|
|
1229
|
+
}, [value]);
|
|
1230
|
+
const handleKeyDown = useCallback(
|
|
1231
|
+
(e) => {
|
|
1232
|
+
if (e.key === "ArrowUp") {
|
|
1233
|
+
e.preventDefault();
|
|
1234
|
+
increment();
|
|
1235
|
+
} else if (e.key === "ArrowDown") {
|
|
1236
|
+
e.preventDefault();
|
|
1237
|
+
decrement();
|
|
1238
|
+
} else if (e.key === "Enter") {
|
|
1239
|
+
inputRef.current?.blur();
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
[increment, decrement]
|
|
1243
|
+
);
|
|
1244
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1245
|
+
NumberInputContainer,
|
|
1246
|
+
{
|
|
1247
|
+
$size: size,
|
|
1248
|
+
$disabled: disabled,
|
|
1249
|
+
$alert: alert,
|
|
1250
|
+
$isFocused: isFocused,
|
|
1251
|
+
className,
|
|
1252
|
+
style
|
|
1253
|
+
},
|
|
1254
|
+
/* @__PURE__ */ React3.createElement(InputWrapper, null, /* @__PURE__ */ React3.createElement(
|
|
1255
|
+
StyledInput,
|
|
1256
|
+
{
|
|
1257
|
+
ref: inputRef,
|
|
1258
|
+
type: "text",
|
|
1259
|
+
value: displayValue,
|
|
1260
|
+
onChange: handleInputChange,
|
|
1261
|
+
onFocus: handleFocus,
|
|
1262
|
+
onBlur: handleBlur,
|
|
1263
|
+
onKeyDown: handleKeyDown,
|
|
1264
|
+
disabled,
|
|
1265
|
+
$size: size,
|
|
1266
|
+
$disabled: disabled
|
|
1267
|
+
}
|
|
1268
|
+
), unit && /* @__PURE__ */ React3.createElement(UnitText, { $size: size, $disabled: disabled }, unit)),
|
|
1269
|
+
/* @__PURE__ */ React3.createElement(ButtonGroup, { $alert: alert, $disabled: disabled }, /* @__PURE__ */ React3.createElement(
|
|
1270
|
+
StepButton,
|
|
1271
|
+
{
|
|
1272
|
+
type: "button",
|
|
1273
|
+
$position: "up",
|
|
1274
|
+
$alert: alert,
|
|
1275
|
+
$disabled: disabled,
|
|
1276
|
+
onClick: increment,
|
|
1277
|
+
disabled,
|
|
1278
|
+
tabIndex: -1
|
|
1279
|
+
},
|
|
1280
|
+
/* @__PURE__ */ React3.createElement(UpArrow, null)
|
|
1281
|
+
), /* @__PURE__ */ React3.createElement(
|
|
1282
|
+
StepButton,
|
|
1283
|
+
{
|
|
1284
|
+
type: "button",
|
|
1285
|
+
$position: "down",
|
|
1286
|
+
$alert: alert,
|
|
1287
|
+
$disabled: disabled,
|
|
1288
|
+
onClick: decrement,
|
|
1289
|
+
disabled,
|
|
1290
|
+
tabIndex: -1
|
|
1291
|
+
},
|
|
1292
|
+
/* @__PURE__ */ React3.createElement(DownArrow, null)
|
|
1293
|
+
))
|
|
1294
|
+
);
|
|
1295
|
+
};
|
|
1296
|
+
NumberInput.displayName = "NumberInput";
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
714
1299
|
|
|
715
|
-
// src/
|
|
716
|
-
var
|
|
1300
|
+
// src/NumberInput/index.ts
|
|
1301
|
+
var init_NumberInput2 = __esm({
|
|
1302
|
+
"src/NumberInput/index.ts"() {
|
|
1303
|
+
init_NumberInput();
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
var SpinButtonWrapper, SliderWrapper, SpinButton;
|
|
1307
|
+
var init_SpinButton = __esm({
|
|
1308
|
+
"src/Button/SpinButton.tsx"() {
|
|
1309
|
+
init_styled();
|
|
1310
|
+
init_Slider2();
|
|
1311
|
+
init_NumberInput2();
|
|
1312
|
+
SpinButtonWrapper = styled.div`
|
|
717
1313
|
display: inline-flex;
|
|
718
1314
|
align-items: center;
|
|
719
1315
|
gap: ${({ $showSlider }) => $showSlider ? "0" : "0"};
|
|
720
1316
|
width: ${({ $showSlider }) => $showSlider ? "100%" : "auto"};
|
|
721
1317
|
`;
|
|
722
|
-
|
|
1318
|
+
SliderWrapper = styled.div`
|
|
723
1319
|
flex: 1;
|
|
724
1320
|
display: flex;
|
|
725
1321
|
align-items: center;
|
|
@@ -727,70 +1323,86 @@ var SliderWrapper = styled.div`
|
|
|
727
1323
|
padding-right: ${({ $size }) => $size === "small" ? "83px" : "72px"};
|
|
728
1324
|
min-width: 0;
|
|
729
1325
|
`;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
precision,
|
|
741
|
-
formatter,
|
|
742
|
-
parser,
|
|
743
|
-
onChange,
|
|
744
|
-
className,
|
|
745
|
-
style
|
|
746
|
-
}) => {
|
|
747
|
-
const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
|
|
748
|
-
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
749
|
-
const handleValueChange = useCallback(
|
|
750
|
-
(newValue) => {
|
|
751
|
-
if (newValue === null) return;
|
|
752
|
-
if (controlledValue === void 0) {
|
|
753
|
-
setInternalValue(newValue);
|
|
754
|
-
}
|
|
755
|
-
onChange?.(newValue);
|
|
756
|
-
},
|
|
757
|
-
[controlledValue, onChange]
|
|
758
|
-
);
|
|
759
|
-
return /* @__PURE__ */ React12.createElement(SpinButtonWrapper, { $showSlider: showSlider, className, style }, showSlider && /* @__PURE__ */ React12.createElement(SliderWrapper, { $size: size }, /* @__PURE__ */ React12.createElement(
|
|
760
|
-
Slider,
|
|
761
|
-
{
|
|
762
|
-
value,
|
|
763
|
-
min,
|
|
764
|
-
max,
|
|
765
|
-
step,
|
|
766
|
-
disabled,
|
|
767
|
-
onChange: handleValueChange
|
|
768
|
-
}
|
|
769
|
-
)), /* @__PURE__ */ React12.createElement(
|
|
770
|
-
NumberInput,
|
|
771
|
-
{
|
|
772
|
-
value,
|
|
773
|
-
min,
|
|
774
|
-
max,
|
|
775
|
-
step,
|
|
776
|
-
size,
|
|
777
|
-
disabled,
|
|
778
|
-
alert,
|
|
1326
|
+
SpinButton = ({
|
|
1327
|
+
value: controlledValue,
|
|
1328
|
+
defaultValue = 0,
|
|
1329
|
+
min = -Infinity,
|
|
1330
|
+
max = Infinity,
|
|
1331
|
+
step = 1,
|
|
1332
|
+
size = "large",
|
|
1333
|
+
disabled = false,
|
|
1334
|
+
alert = false,
|
|
1335
|
+
showSlider = false,
|
|
779
1336
|
precision,
|
|
780
1337
|
formatter,
|
|
781
1338
|
parser,
|
|
782
|
-
onChange
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
|
|
1339
|
+
onChange,
|
|
1340
|
+
className,
|
|
1341
|
+
style
|
|
1342
|
+
}) => {
|
|
1343
|
+
const [internalValue, setInternalValue] = useState(controlledValue ?? defaultValue);
|
|
1344
|
+
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
1345
|
+
const handleValueChange = useCallback(
|
|
1346
|
+
(newValue) => {
|
|
1347
|
+
if (newValue === null) return;
|
|
1348
|
+
if (controlledValue === void 0) {
|
|
1349
|
+
setInternalValue(newValue);
|
|
1350
|
+
}
|
|
1351
|
+
onChange?.(newValue);
|
|
1352
|
+
},
|
|
1353
|
+
[controlledValue, onChange]
|
|
1354
|
+
);
|
|
1355
|
+
return /* @__PURE__ */ React3.createElement(SpinButtonWrapper, { $showSlider: showSlider, className, style }, showSlider && /* @__PURE__ */ React3.createElement(SliderWrapper, { $size: size }, /* @__PURE__ */ React3.createElement(
|
|
1356
|
+
Slider,
|
|
1357
|
+
{
|
|
1358
|
+
value,
|
|
1359
|
+
min,
|
|
1360
|
+
max,
|
|
1361
|
+
step,
|
|
1362
|
+
disabled,
|
|
1363
|
+
onChange: handleValueChange
|
|
1364
|
+
}
|
|
1365
|
+
)), /* @__PURE__ */ React3.createElement(
|
|
1366
|
+
NumberInput,
|
|
1367
|
+
{
|
|
1368
|
+
value,
|
|
1369
|
+
min,
|
|
1370
|
+
max,
|
|
1371
|
+
step,
|
|
1372
|
+
size,
|
|
1373
|
+
disabled,
|
|
1374
|
+
alert,
|
|
1375
|
+
precision,
|
|
1376
|
+
formatter,
|
|
1377
|
+
parser,
|
|
1378
|
+
onChange: handleValueChange
|
|
1379
|
+
}
|
|
1380
|
+
));
|
|
1381
|
+
};
|
|
1382
|
+
SpinButton.displayName = "SpinButton";
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
// src/Button/index.ts
|
|
1387
|
+
var init_Button2 = __esm({
|
|
1388
|
+
"src/Button/index.ts"() {
|
|
1389
|
+
init_Button();
|
|
1390
|
+
init_SpinButton();
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
|
|
1394
|
+
// src/index.ts
|
|
1395
|
+
init_Button2();
|
|
1396
|
+
|
|
1397
|
+
// src/Switch/Switch.tsx
|
|
1398
|
+
init_styled();
|
|
787
1399
|
var SwitchContainer = styled.label`
|
|
788
1400
|
position: relative;
|
|
789
1401
|
display: inline-block;
|
|
790
1402
|
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
791
1403
|
|
|
792
|
-
${({ $size, theme:
|
|
793
|
-
const sizeConfig =
|
|
1404
|
+
${({ $size, theme: theme3 }) => {
|
|
1405
|
+
const sizeConfig = theme3.components.switch[$size];
|
|
794
1406
|
return `
|
|
795
1407
|
width: ${sizeConfig.container.width};
|
|
796
1408
|
height: ${sizeConfig.container.height};
|
|
@@ -810,10 +1422,10 @@ var Track = styled.div`
|
|
|
810
1422
|
top: 50%;
|
|
811
1423
|
left: 50%;
|
|
812
1424
|
transform: translate(-50%, -50%);
|
|
813
|
-
transition: ${({ theme:
|
|
1425
|
+
transition: ${({ theme: theme3 }) => theme3.components.switch.transition || "all 0.2s ease"};
|
|
814
1426
|
|
|
815
|
-
${({ $size, theme:
|
|
816
|
-
const sizeConfig =
|
|
1427
|
+
${({ $size, theme: theme3 }) => {
|
|
1428
|
+
const sizeConfig = theme3.components.switch[$size];
|
|
817
1429
|
return `
|
|
818
1430
|
border-radius: ${sizeConfig.track.borderRadius};
|
|
819
1431
|
width: ${sizeConfig.track.width};
|
|
@@ -821,8 +1433,8 @@ var Track = styled.div`
|
|
|
821
1433
|
`;
|
|
822
1434
|
}}
|
|
823
1435
|
|
|
824
|
-
${({ $checked, $disabled, theme:
|
|
825
|
-
const stateConfig = $checked ?
|
|
1436
|
+
${({ $checked, $disabled, theme: theme3 }) => {
|
|
1437
|
+
const stateConfig = $checked ? theme3.components.switch.on : theme3.components.switch.off;
|
|
826
1438
|
if ($disabled) {
|
|
827
1439
|
return `
|
|
828
1440
|
background: ${stateConfig.track.backgroundDisabled};
|
|
@@ -835,9 +1447,9 @@ var Track = styled.div`
|
|
|
835
1447
|
`;
|
|
836
1448
|
}}
|
|
837
1449
|
|
|
838
|
-
${({ $disabled, $checked, theme:
|
|
1450
|
+
${({ $disabled, $checked, theme: theme3 }) => {
|
|
839
1451
|
if ($disabled) return "";
|
|
840
|
-
const stateConfig = $checked ?
|
|
1452
|
+
const stateConfig = $checked ? theme3.components.switch.on : theme3.components.switch.off;
|
|
841
1453
|
return `
|
|
842
1454
|
:hover {
|
|
843
1455
|
background: ${stateConfig.track.backgroundHover};
|
|
@@ -852,10 +1464,10 @@ var Thumb = styled.div`
|
|
|
852
1464
|
transform: translateY(-50%);
|
|
853
1465
|
border-style: solid;
|
|
854
1466
|
box-sizing: border-box;
|
|
855
|
-
transition: ${({ theme:
|
|
1467
|
+
transition: ${({ theme: theme3 }) => theme3.components.switch.transition || "all 0.2s ease"};
|
|
856
1468
|
|
|
857
|
-
${({ $size, $checked, theme:
|
|
858
|
-
const sizeConfig =
|
|
1469
|
+
${({ $size, $checked, theme: theme3 }) => {
|
|
1470
|
+
const sizeConfig = theme3.components.switch[$size];
|
|
859
1471
|
const thumbSize = sizeConfig.thumb.size;
|
|
860
1472
|
const thumbOffset = sizeConfig.thumb.offset;
|
|
861
1473
|
const thumbBorderRadius = sizeConfig.thumb.borderRadius;
|
|
@@ -869,8 +1481,8 @@ var Thumb = styled.div`
|
|
|
869
1481
|
`;
|
|
870
1482
|
}}
|
|
871
1483
|
|
|
872
|
-
${({ $checked, $disabled, theme:
|
|
873
|
-
const stateConfig = $checked ?
|
|
1484
|
+
${({ $checked, $disabled, theme: theme3 }) => {
|
|
1485
|
+
const stateConfig = $checked ? theme3.components.switch.on : theme3.components.switch.off;
|
|
874
1486
|
if ($disabled) {
|
|
875
1487
|
return `
|
|
876
1488
|
background: ${stateConfig.thumb.backgroundDisabled};
|
|
@@ -885,9 +1497,9 @@ var Thumb = styled.div`
|
|
|
885
1497
|
`;
|
|
886
1498
|
}}
|
|
887
1499
|
|
|
888
|
-
${({ $disabled, $checked, theme:
|
|
1500
|
+
${({ $disabled, $checked, theme: theme3 }) => {
|
|
889
1501
|
if ($disabled) return "";
|
|
890
|
-
const stateConfig = $checked ?
|
|
1502
|
+
const stateConfig = $checked ? theme3.components.switch.on : theme3.components.switch.off;
|
|
891
1503
|
return `
|
|
892
1504
|
:hover & {
|
|
893
1505
|
background: ${stateConfig.thumb.backgroundHover};
|
|
@@ -928,7 +1540,7 @@ var Switch = ({
|
|
|
928
1540
|
const handleBlur = useCallback(() => {
|
|
929
1541
|
setIsFocused(false);
|
|
930
1542
|
}, []);
|
|
931
|
-
return /* @__PURE__ */
|
|
1543
|
+
return /* @__PURE__ */ React3.createElement(
|
|
932
1544
|
SwitchContainer,
|
|
933
1545
|
{
|
|
934
1546
|
$size: size,
|
|
@@ -937,7 +1549,7 @@ var Switch = ({
|
|
|
937
1549
|
className,
|
|
938
1550
|
style
|
|
939
1551
|
},
|
|
940
|
-
/* @__PURE__ */
|
|
1552
|
+
/* @__PURE__ */ React3.createElement(
|
|
941
1553
|
HiddenInput,
|
|
942
1554
|
{
|
|
943
1555
|
type: "checkbox",
|
|
@@ -948,7 +1560,7 @@ var Switch = ({
|
|
|
948
1560
|
disabled
|
|
949
1561
|
}
|
|
950
1562
|
),
|
|
951
|
-
/* @__PURE__ */
|
|
1563
|
+
/* @__PURE__ */ React3.createElement(
|
|
952
1564
|
Track,
|
|
953
1565
|
{
|
|
954
1566
|
$size: size,
|
|
@@ -957,7 +1569,7 @@ var Switch = ({
|
|
|
957
1569
|
$isFocused: isFocused
|
|
958
1570
|
}
|
|
959
1571
|
),
|
|
960
|
-
/* @__PURE__ */
|
|
1572
|
+
/* @__PURE__ */ React3.createElement(
|
|
961
1573
|
Thumb,
|
|
962
1574
|
{
|
|
963
1575
|
$size: size,
|
|
@@ -969,13 +1581,16 @@ var Switch = ({
|
|
|
969
1581
|
);
|
|
970
1582
|
};
|
|
971
1583
|
Switch.displayName = "Switch";
|
|
1584
|
+
|
|
1585
|
+
// src/Radio/Radio.tsx
|
|
1586
|
+
init_styled();
|
|
972
1587
|
var RadioContainer = styled.label`
|
|
973
1588
|
position: relative;
|
|
974
1589
|
display: inline-block;
|
|
975
1590
|
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
976
1591
|
|
|
977
|
-
${({ theme:
|
|
978
|
-
const sizeConfig =
|
|
1592
|
+
${({ theme: theme3 }) => {
|
|
1593
|
+
const sizeConfig = theme3.components.radio.small;
|
|
979
1594
|
return `
|
|
980
1595
|
width: ${sizeConfig.size};
|
|
981
1596
|
height: ${sizeConfig.size};
|
|
@@ -996,31 +1611,31 @@ var RadioOuter = styled.div`
|
|
|
996
1611
|
border: 1px solid;
|
|
997
1612
|
transition: all 0.2s ease;
|
|
998
1613
|
|
|
999
|
-
${({ $checked, $disabled, theme:
|
|
1614
|
+
${({ $checked, $disabled, theme: theme3 }) => {
|
|
1000
1615
|
if ($disabled) {
|
|
1001
|
-
const stateConfig = $checked ?
|
|
1616
|
+
const stateConfig = $checked ? theme3.components.radio.checked : theme3.components.radio.unchecked;
|
|
1002
1617
|
return `
|
|
1003
1618
|
background: ${stateConfig.backgroundDisabled};
|
|
1004
1619
|
border-color: ${stateConfig.borderColorDisabled};
|
|
1005
1620
|
`;
|
|
1006
1621
|
}
|
|
1007
1622
|
if ($checked) {
|
|
1008
|
-
const checkedConfig =
|
|
1623
|
+
const checkedConfig = theme3.components.radio.checked;
|
|
1009
1624
|
return `
|
|
1010
1625
|
background: ${checkedConfig.background};
|
|
1011
1626
|
border-color: ${checkedConfig.borderColor};
|
|
1012
1627
|
`;
|
|
1013
1628
|
}
|
|
1014
|
-
const uncheckedConfig =
|
|
1629
|
+
const uncheckedConfig = theme3.components.radio.unchecked;
|
|
1015
1630
|
return `
|
|
1016
1631
|
background: ${uncheckedConfig.background};
|
|
1017
1632
|
border-color: ${uncheckedConfig.borderColor};
|
|
1018
1633
|
`;
|
|
1019
1634
|
}}
|
|
1020
1635
|
|
|
1021
|
-
${({ $disabled, $checked, theme:
|
|
1636
|
+
${({ $disabled, $checked, theme: theme3 }) => {
|
|
1022
1637
|
if ($disabled) return "";
|
|
1023
|
-
const stateConfig = $checked ?
|
|
1638
|
+
const stateConfig = $checked ? theme3.components.radio.checked : theme3.components.radio.unchecked;
|
|
1024
1639
|
return `
|
|
1025
1640
|
${RadioContainer}:hover & {
|
|
1026
1641
|
background: ${stateConfig.backgroundHover};
|
|
@@ -1043,8 +1658,8 @@ var RadioInner = styled.div`
|
|
|
1043
1658
|
opacity: ${({ $checked }) => $checked ? 1 : 0};
|
|
1044
1659
|
transition: opacity 0.2s ease;
|
|
1045
1660
|
|
|
1046
|
-
${({ theme:
|
|
1047
|
-
const dotSize =
|
|
1661
|
+
${({ theme: theme3 }) => {
|
|
1662
|
+
const dotSize = theme3.components.radio.small.dotSize;
|
|
1048
1663
|
return `
|
|
1049
1664
|
width: ${dotSize};
|
|
1050
1665
|
height: ${dotSize};
|
|
@@ -1084,14 +1699,14 @@ var Radio = ({
|
|
|
1084
1699
|
const handleBlur = useCallback(() => {
|
|
1085
1700
|
setIsFocused(false);
|
|
1086
1701
|
}, []);
|
|
1087
|
-
return /* @__PURE__ */
|
|
1702
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1088
1703
|
RadioContainer,
|
|
1089
1704
|
{
|
|
1090
1705
|
$disabled: disabled,
|
|
1091
1706
|
className,
|
|
1092
1707
|
style
|
|
1093
1708
|
},
|
|
1094
|
-
/* @__PURE__ */
|
|
1709
|
+
/* @__PURE__ */ React3.createElement(
|
|
1095
1710
|
HiddenInput2,
|
|
1096
1711
|
{
|
|
1097
1712
|
type: "radio",
|
|
@@ -1105,7 +1720,7 @@ var Radio = ({
|
|
|
1105
1720
|
disabled
|
|
1106
1721
|
}
|
|
1107
1722
|
),
|
|
1108
|
-
/* @__PURE__ */
|
|
1723
|
+
/* @__PURE__ */ React3.createElement(
|
|
1109
1724
|
RadioOuter,
|
|
1110
1725
|
{
|
|
1111
1726
|
$checked: checked,
|
|
@@ -1113,7 +1728,7 @@ var Radio = ({
|
|
|
1113
1728
|
$isFocused: isFocused
|
|
1114
1729
|
}
|
|
1115
1730
|
),
|
|
1116
|
-
/* @__PURE__ */
|
|
1731
|
+
/* @__PURE__ */ React3.createElement(
|
|
1117
1732
|
RadioInner,
|
|
1118
1733
|
{
|
|
1119
1734
|
$checked: checked,
|
|
@@ -1123,13 +1738,16 @@ var Radio = ({
|
|
|
1123
1738
|
);
|
|
1124
1739
|
};
|
|
1125
1740
|
Radio.displayName = "Radio";
|
|
1741
|
+
|
|
1742
|
+
// src/Checkbox/Checkbox.tsx
|
|
1743
|
+
init_styled();
|
|
1126
1744
|
var CheckboxContainer = styled.label`
|
|
1127
1745
|
position: relative;
|
|
1128
1746
|
display: inline-block;
|
|
1129
1747
|
cursor: ${({ $disabled }) => $disabled ? "not-allowed" : "pointer"};
|
|
1130
1748
|
|
|
1131
|
-
${({ theme:
|
|
1132
|
-
const sizeConfig =
|
|
1749
|
+
${({ theme: theme3 }) => {
|
|
1750
|
+
const sizeConfig = theme3.components.checkbox.small;
|
|
1133
1751
|
return `
|
|
1134
1752
|
width: ${sizeConfig.size};
|
|
1135
1753
|
height: ${sizeConfig.size};
|
|
@@ -1149,45 +1767,45 @@ var CheckboxBox = styled.div`
|
|
|
1149
1767
|
border: 1px solid;
|
|
1150
1768
|
transition: all 0.2s ease;
|
|
1151
1769
|
|
|
1152
|
-
${({ theme:
|
|
1153
|
-
const sizeConfig =
|
|
1770
|
+
${({ theme: theme3 }) => {
|
|
1771
|
+
const sizeConfig = theme3.components.checkbox.small;
|
|
1154
1772
|
return `
|
|
1155
1773
|
border-radius: ${sizeConfig.borderRadius};
|
|
1156
1774
|
`;
|
|
1157
1775
|
}}
|
|
1158
1776
|
|
|
1159
|
-
${({ $checked, $indeterminate, $disabled, theme:
|
|
1777
|
+
${({ $checked, $indeterminate, $disabled, theme: theme3 }) => {
|
|
1160
1778
|
if ($disabled) {
|
|
1161
|
-
const stateConfig = $checked || $indeterminate ?
|
|
1779
|
+
const stateConfig = $checked || $indeterminate ? theme3.components.checkbox.checked : theme3.components.checkbox.unchecked;
|
|
1162
1780
|
return `
|
|
1163
1781
|
background: ${stateConfig.backgroundDisabled};
|
|
1164
1782
|
border-color: ${stateConfig.borderColorDisabled};
|
|
1165
1783
|
`;
|
|
1166
1784
|
}
|
|
1167
1785
|
if ($checked) {
|
|
1168
|
-
const checkedConfig =
|
|
1786
|
+
const checkedConfig = theme3.components.checkbox.checked;
|
|
1169
1787
|
return `
|
|
1170
1788
|
background: ${checkedConfig.background};
|
|
1171
1789
|
border-color: ${checkedConfig.borderColor};
|
|
1172
1790
|
`;
|
|
1173
1791
|
}
|
|
1174
1792
|
if ($indeterminate) {
|
|
1175
|
-
const indeterminateConfig =
|
|
1793
|
+
const indeterminateConfig = theme3.components.checkbox.indeterminate;
|
|
1176
1794
|
return `
|
|
1177
1795
|
background: ${indeterminateConfig.background};
|
|
1178
1796
|
border-color: ${indeterminateConfig.borderColor};
|
|
1179
1797
|
`;
|
|
1180
1798
|
}
|
|
1181
|
-
const uncheckedConfig =
|
|
1799
|
+
const uncheckedConfig = theme3.components.checkbox.unchecked;
|
|
1182
1800
|
return `
|
|
1183
1801
|
background: ${uncheckedConfig.background};
|
|
1184
1802
|
border-color: ${uncheckedConfig.borderColor};
|
|
1185
1803
|
`;
|
|
1186
1804
|
}}
|
|
1187
1805
|
|
|
1188
|
-
${({ $disabled, $checked, $indeterminate, theme:
|
|
1806
|
+
${({ $disabled, $checked, $indeterminate, theme: theme3 }) => {
|
|
1189
1807
|
if ($disabled) return "";
|
|
1190
|
-
const stateConfig = $checked || $indeterminate ?
|
|
1808
|
+
const stateConfig = $checked || $indeterminate ? theme3.components.checkbox.checked : theme3.components.checkbox.unchecked;
|
|
1191
1809
|
return `
|
|
1192
1810
|
${CheckboxContainer}:hover & {
|
|
1193
1811
|
background: ${stateConfig.backgroundHover};
|
|
@@ -1200,7 +1818,7 @@ var CheckboxBox = styled.div`
|
|
|
1200
1818
|
`;
|
|
1201
1819
|
}}
|
|
1202
1820
|
`;
|
|
1203
|
-
var
|
|
1821
|
+
var IconWrapper3 = styled.div`
|
|
1204
1822
|
position: absolute;
|
|
1205
1823
|
left: 50%;
|
|
1206
1824
|
top: 50%;
|
|
@@ -1212,8 +1830,8 @@ var IconWrapper2 = styled.div`
|
|
|
1212
1830
|
align-items: center;
|
|
1213
1831
|
justify-content: center;
|
|
1214
1832
|
|
|
1215
|
-
${({ theme:
|
|
1216
|
-
const iconSize =
|
|
1833
|
+
${({ theme: theme3 }) => {
|
|
1834
|
+
const iconSize = theme3.components.checkbox.small.iconSize;
|
|
1217
1835
|
return `
|
|
1218
1836
|
width: ${iconSize.width};
|
|
1219
1837
|
height: ${iconSize.height};
|
|
@@ -1269,14 +1887,14 @@ var Checkbox = ({
|
|
|
1269
1887
|
const handleBlur = useCallback(() => {
|
|
1270
1888
|
setIsFocused(false);
|
|
1271
1889
|
}, []);
|
|
1272
|
-
return /* @__PURE__ */
|
|
1890
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1273
1891
|
CheckboxContainer,
|
|
1274
1892
|
{
|
|
1275
1893
|
$disabled: disabled,
|
|
1276
1894
|
className,
|
|
1277
1895
|
style
|
|
1278
1896
|
},
|
|
1279
|
-
/* @__PURE__ */
|
|
1897
|
+
/* @__PURE__ */ React3.createElement(
|
|
1280
1898
|
HiddenInput3,
|
|
1281
1899
|
{
|
|
1282
1900
|
ref: inputRef,
|
|
@@ -1291,7 +1909,7 @@ var Checkbox = ({
|
|
|
1291
1909
|
disabled
|
|
1292
1910
|
}
|
|
1293
1911
|
),
|
|
1294
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ React3.createElement(
|
|
1295
1913
|
CheckboxBox,
|
|
1296
1914
|
{
|
|
1297
1915
|
$checked: checked,
|
|
@@ -1300,33 +1918,62 @@ var Checkbox = ({
|
|
|
1300
1918
|
$isFocused: isFocused
|
|
1301
1919
|
}
|
|
1302
1920
|
),
|
|
1303
|
-
!indeterminate && /* @__PURE__ */
|
|
1304
|
-
indeterminate && /* @__PURE__ */
|
|
1921
|
+
!indeterminate && /* @__PURE__ */ React3.createElement(IconWrapper3, { $visible: checked }, /* @__PURE__ */ React3.createElement("svg", { width: 10, height: 8, viewBox: "0 0 10 8", fill: "#fff" }, /* @__PURE__ */ React3.createElement("path", { d: "M1.05426 3.16164L0 4.27945L3.50904 8L10 1.11781L8.94573 0L3.50904 5.76438L1.05426 3.16164Z" }))),
|
|
1922
|
+
indeterminate && /* @__PURE__ */ React3.createElement(IconWrapper3, { $visible: indeterminate }, /* @__PURE__ */ React3.createElement(DefaultIndeterminateIcon, null))
|
|
1305
1923
|
);
|
|
1306
1924
|
};
|
|
1307
1925
|
Checkbox.displayName = "Checkbox";
|
|
1926
|
+
|
|
1927
|
+
// src/index.ts
|
|
1928
|
+
init_Slider2();
|
|
1929
|
+
|
|
1930
|
+
// src/Input/Input.tsx
|
|
1931
|
+
init_styled();
|
|
1932
|
+
var InputContainer = styled.div`
|
|
1933
|
+
display: inline-flex;
|
|
1934
|
+
flex-direction: column;
|
|
1935
|
+
width: 100%;
|
|
1936
|
+
box-sizing: border-box;
|
|
1937
|
+
position: relative;
|
|
1938
|
+
|
|
1939
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
1940
|
+
const size = $size || "medium";
|
|
1941
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
1942
|
+
const sizeConfig = typeConfig?.[size];
|
|
1943
|
+
if (!sizeConfig) return "";
|
|
1944
|
+
return `
|
|
1945
|
+
height: ${sizeConfig.height};
|
|
1946
|
+
`;
|
|
1947
|
+
}}
|
|
1948
|
+
`;
|
|
1308
1949
|
var InputWrapper2 = styled.div`
|
|
1309
1950
|
display: inline-flex;
|
|
1310
1951
|
align-items: center;
|
|
1311
1952
|
width: 100%;
|
|
1312
1953
|
box-sizing: border-box;
|
|
1313
1954
|
position: relative;
|
|
1955
|
+
flex: 1;
|
|
1314
1956
|
transition: all 0.2s ease;
|
|
1315
1957
|
|
|
1316
|
-
${({ $size, theme:
|
|
1958
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
1317
1959
|
const size = $size || "medium";
|
|
1318
|
-
const
|
|
1960
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
1961
|
+
const sizeConfig = typeConfig?.[size];
|
|
1962
|
+
if (!sizeConfig) return "";
|
|
1319
1963
|
return `
|
|
1320
1964
|
height: ${sizeConfig.height};
|
|
1321
|
-
border-radius: ${sizeConfig.borderRadius};
|
|
1322
1965
|
padding: ${sizeConfig.padding};
|
|
1323
|
-
|
|
1324
|
-
|
|
1966
|
+
gap: ${sizeConfig.gap || "4px"};
|
|
1967
|
+
${$lineType === "outlined" ? `
|
|
1968
|
+
border-radius: ${sizeConfig.borderRadius};
|
|
1969
|
+
` : ""}
|
|
1325
1970
|
`;
|
|
1326
1971
|
}}
|
|
1327
1972
|
|
|
1328
|
-
${({ $error, $disabled, $readOnly, $isFocused, theme:
|
|
1329
|
-
const
|
|
1973
|
+
${({ $error, $disabled, $readOnly, $isFocused, $lineType, theme: theme3, $size }) => {
|
|
1974
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
1975
|
+
const stateConfig = typeConfig?.state;
|
|
1976
|
+
if (!stateConfig) return "";
|
|
1330
1977
|
let borderColor = stateConfig.borderColor;
|
|
1331
1978
|
let background = stateConfig.background;
|
|
1332
1979
|
let boxShadow = "none";
|
|
@@ -1334,36 +1981,69 @@ var InputWrapper2 = styled.div`
|
|
|
1334
1981
|
borderColor = stateConfig.borderColorDisabled;
|
|
1335
1982
|
background = stateConfig.backgroundDisabled;
|
|
1336
1983
|
} else if ($readOnly) {
|
|
1337
|
-
borderColor = stateConfig.borderColorReadonly;
|
|
1338
|
-
background = stateConfig.backgroundReadonly;
|
|
1984
|
+
borderColor = stateConfig.borderColorReadonly || stateConfig.borderColor;
|
|
1985
|
+
background = stateConfig.backgroundReadonly || stateConfig.background;
|
|
1339
1986
|
} else if ($error) {
|
|
1340
1987
|
borderColor = stateConfig.borderColorError;
|
|
1341
|
-
background = stateConfig.backgroundActive;
|
|
1988
|
+
background = $lineType === "outlined" ? stateConfig.backgroundActive : stateConfig.background;
|
|
1342
1989
|
} else if ($isFocused) {
|
|
1343
1990
|
borderColor = stateConfig.borderColorActive;
|
|
1344
1991
|
background = stateConfig.backgroundActive;
|
|
1345
|
-
|
|
1346
|
-
|
|
1992
|
+
if ($lineType === "outlined") {
|
|
1993
|
+
const size = $size || "medium";
|
|
1994
|
+
const sizeConfig = typeConfig?.[size];
|
|
1995
|
+
boxShadow = sizeConfig?.boxShadowActive || "none";
|
|
1996
|
+
}
|
|
1347
1997
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1998
|
+
if ($lineType === "outlined") {
|
|
1999
|
+
return `
|
|
2000
|
+
border: 1px solid ${borderColor};
|
|
2001
|
+
background: ${background};
|
|
2002
|
+
box-shadow: ${boxShadow};
|
|
1352
2003
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
2004
|
+
&:hover:not(:disabled) {
|
|
2005
|
+
${!$disabled && !$readOnly && !$isFocused ? `
|
|
2006
|
+
border-color: ${stateConfig.borderColorHover};
|
|
2007
|
+
background: ${stateConfig.backgroundHover};
|
|
2008
|
+
` : ""}
|
|
2009
|
+
}
|
|
2010
|
+
`;
|
|
2011
|
+
} else {
|
|
2012
|
+
return `
|
|
2013
|
+
background: ${background};
|
|
2014
|
+
border-bottom: 1px solid ${$error ? borderColor : $isFocused ? borderColor : "transparent"};
|
|
2015
|
+
|
|
2016
|
+
&:hover:not(:disabled) {
|
|
2017
|
+
${!$disabled && !$isFocused && !$error ? `
|
|
2018
|
+
border-bottom-color: ${stateConfig.borderColorHover};
|
|
2019
|
+
` : ""}
|
|
2020
|
+
}
|
|
2021
|
+
`;
|
|
2022
|
+
}
|
|
1360
2023
|
}}
|
|
1361
2024
|
|
|
1362
2025
|
${({ $disabled }) => $disabled && `
|
|
1363
2026
|
cursor: not-allowed;
|
|
1364
|
-
opacity: 1;
|
|
2027
|
+
opacity: ${$disabled ? "0.6" : "1"};
|
|
1365
2028
|
`}
|
|
1366
2029
|
`;
|
|
2030
|
+
var ContentBlock = styled.div`
|
|
2031
|
+
display: flex;
|
|
2032
|
+
align-items: center;
|
|
2033
|
+
flex: 1;
|
|
2034
|
+
min-width: 0;
|
|
2035
|
+
|
|
2036
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
2037
|
+
const size = $size || "medium";
|
|
2038
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2039
|
+
const sizeConfig = typeConfig?.[size];
|
|
2040
|
+
if (!sizeConfig) return "";
|
|
2041
|
+
return `
|
|
2042
|
+
padding: ${sizeConfig.contentPadding || "0"};
|
|
2043
|
+
gap: ${sizeConfig.gap || "4px"};
|
|
2044
|
+
`;
|
|
2045
|
+
}}
|
|
2046
|
+
`;
|
|
1367
2047
|
var StyledInput2 = styled.input`
|
|
1368
2048
|
flex: 1;
|
|
1369
2049
|
border: none;
|
|
@@ -1373,24 +2053,31 @@ var StyledInput2 = styled.input`
|
|
|
1373
2053
|
padding: 0;
|
|
1374
2054
|
margin: 0;
|
|
1375
2055
|
font-family: inherit;
|
|
1376
|
-
color: ${({ theme: theme2 }) => theme2.components.input.outlined.state.borderColorActive};
|
|
1377
2056
|
|
|
1378
|
-
${({ $size, theme:
|
|
2057
|
+
${({ $size, $lineType, $disabled, theme: theme3 }) => {
|
|
1379
2058
|
const size = $size || "medium";
|
|
1380
|
-
const
|
|
2059
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2060
|
+
const sizeConfig = typeConfig?.[size];
|
|
2061
|
+
const stateConfig = typeConfig?.state;
|
|
2062
|
+
if (!sizeConfig || !stateConfig) return "";
|
|
2063
|
+
const textColor = $disabled ? stateConfig.textColorDisabled : stateConfig.textColorNormal;
|
|
1381
2064
|
return `
|
|
1382
2065
|
font-size: ${sizeConfig.fontSize};
|
|
1383
2066
|
line-height: ${sizeConfig.lineHeight};
|
|
2067
|
+
color: ${textColor};
|
|
1384
2068
|
`;
|
|
1385
2069
|
}}
|
|
1386
2070
|
|
|
1387
2071
|
&::placeholder {
|
|
1388
|
-
color: ${({ theme:
|
|
2072
|
+
color: ${({ $isFocused, $lineType, theme: theme3 }) => {
|
|
2073
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2074
|
+
const stateConfig = typeConfig?.state;
|
|
2075
|
+
return $isFocused ? stateConfig?.placeholderColorHover || "rgba(65, 70, 75, 0.3)" : stateConfig?.placeholderColorNormal || "rgba(65, 70, 75, 0.3)";
|
|
2076
|
+
}};
|
|
1389
2077
|
}
|
|
1390
2078
|
|
|
1391
|
-
${({ $disabled
|
|
2079
|
+
${({ $disabled }) => $disabled && `
|
|
1392
2080
|
cursor: not-allowed;
|
|
1393
|
-
color: ${theme2.colors.palettes.transparency["30"]};
|
|
1394
2081
|
`}
|
|
1395
2082
|
|
|
1396
2083
|
${({ $readOnly }) => $readOnly && `
|
|
@@ -1401,11 +2088,12 @@ var PrefixNode = styled.div`
|
|
|
1401
2088
|
display: inline-flex;
|
|
1402
2089
|
align-items: center;
|
|
1403
2090
|
flex-shrink: 0;
|
|
1404
|
-
margin-right: 4px;
|
|
1405
2091
|
|
|
1406
|
-
${({ $size, theme:
|
|
2092
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
1407
2093
|
const size = $size || "medium";
|
|
1408
|
-
const
|
|
2094
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2095
|
+
const sizeConfig = typeConfig?.[size];
|
|
2096
|
+
if (!sizeConfig) return "";
|
|
1409
2097
|
return `
|
|
1410
2098
|
svg, img {
|
|
1411
2099
|
width: ${sizeConfig.iconSize.width};
|
|
@@ -1418,11 +2106,12 @@ var SuffixNode = styled.div`
|
|
|
1418
2106
|
display: inline-flex;
|
|
1419
2107
|
align-items: center;
|
|
1420
2108
|
flex-shrink: 0;
|
|
1421
|
-
margin-left: 4px;
|
|
1422
2109
|
|
|
1423
|
-
${({ $size, theme:
|
|
2110
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
1424
2111
|
const size = $size || "medium";
|
|
1425
|
-
const
|
|
2112
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2113
|
+
const sizeConfig = typeConfig?.[size];
|
|
2114
|
+
if (!sizeConfig) return "";
|
|
1426
2115
|
return `
|
|
1427
2116
|
svg, img {
|
|
1428
2117
|
width: ${sizeConfig.iconSize.width};
|
|
@@ -1431,21 +2120,87 @@ var SuffixNode = styled.div`
|
|
|
1431
2120
|
`;
|
|
1432
2121
|
}}
|
|
1433
2122
|
`;
|
|
2123
|
+
var ClearButton = styled.button`
|
|
2124
|
+
display: inline-flex;
|
|
2125
|
+
align-items: center;
|
|
2126
|
+
justify-content: center;
|
|
2127
|
+
flex-shrink: 0;
|
|
2128
|
+
border: none;
|
|
2129
|
+
background: transparent;
|
|
2130
|
+
cursor: pointer;
|
|
2131
|
+
padding: 0;
|
|
2132
|
+
margin: 0;
|
|
2133
|
+
outline: none;
|
|
2134
|
+
transition: opacity 0.2s ease;
|
|
2135
|
+
|
|
2136
|
+
${({ $size, $lineType, theme: theme3 }) => {
|
|
2137
|
+
const size = $size || "medium";
|
|
2138
|
+
const typeConfig = $lineType === "underlined" ? theme3.components?.input?.underlined : theme3.components?.input?.outlined;
|
|
2139
|
+
const sizeConfig = typeConfig?.[size];
|
|
2140
|
+
const clearIconSize = sizeConfig?.clearIcon?.size;
|
|
2141
|
+
if (!clearIconSize) return "";
|
|
2142
|
+
return `
|
|
2143
|
+
width: ${clearIconSize.width};
|
|
2144
|
+
height: ${clearIconSize.height};
|
|
2145
|
+
|
|
2146
|
+
svg {
|
|
2147
|
+
width: ${clearIconSize.width};
|
|
2148
|
+
height: ${clearIconSize.height};
|
|
2149
|
+
}
|
|
2150
|
+
`;
|
|
2151
|
+
}}
|
|
2152
|
+
|
|
2153
|
+
&:hover {
|
|
2154
|
+
opacity: 0.7;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
&:active {
|
|
2158
|
+
opacity: 0.5;
|
|
2159
|
+
}
|
|
2160
|
+
`;
|
|
2161
|
+
var AlertLine = styled.div`
|
|
2162
|
+
position: absolute;
|
|
2163
|
+
bottom: -1px;
|
|
2164
|
+
left: 0;
|
|
2165
|
+
right: 0;
|
|
2166
|
+
height: 1px;
|
|
2167
|
+
background-color: ${({ theme: theme3 }) => theme3.colors?.palettes?.red?.["6"] || "#E95555"};
|
|
2168
|
+
`;
|
|
2169
|
+
var DefaultClearIcon = () => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
2170
|
+
"path",
|
|
2171
|
+
{
|
|
2172
|
+
d: "M8.00148 8.56042L11.3306 11.8884L11.8961 11.3226L8.56774 7.99531L11.8641 4.70566L11.299 4.1394L8.00196 7.42971L4.70055 4.12939L4.13495 4.69517L7.4357 7.99483L4.10889 11.3149L4.674 11.8812L8.00148 8.56042Z",
|
|
2173
|
+
fill: "#41464B",
|
|
2174
|
+
fillOpacity: "0.6"
|
|
2175
|
+
}
|
|
2176
|
+
));
|
|
1434
2177
|
var Input = forwardRef(
|
|
1435
2178
|
({
|
|
2179
|
+
lineType = "outlined",
|
|
1436
2180
|
size = "medium",
|
|
1437
2181
|
error = false,
|
|
1438
2182
|
disabled = false,
|
|
1439
2183
|
readOnly = false,
|
|
1440
2184
|
prefixNode,
|
|
1441
2185
|
suffixNode,
|
|
2186
|
+
clearable = false,
|
|
2187
|
+
onClear,
|
|
2188
|
+
clearIcon,
|
|
1442
2189
|
className,
|
|
1443
2190
|
style,
|
|
1444
2191
|
onFocus,
|
|
1445
2192
|
onBlur,
|
|
2193
|
+
value,
|
|
2194
|
+
onChange,
|
|
1446
2195
|
...rest
|
|
1447
2196
|
}, ref) => {
|
|
1448
2197
|
const [isFocused, setIsFocused] = useState(false);
|
|
2198
|
+
const [internalValue, setInternalValue] = useState(
|
|
2199
|
+
value !== void 0 ? value : rest.defaultValue || ""
|
|
2200
|
+
);
|
|
2201
|
+
const isControlled = value !== void 0;
|
|
2202
|
+
const currentValue = isControlled ? value : internalValue;
|
|
2203
|
+
const hasValue = !!currentValue && String(currentValue).length > 0;
|
|
1449
2204
|
const handleFocus = (e) => {
|
|
1450
2205
|
setIsFocused(true);
|
|
1451
2206
|
onFocus?.(e);
|
|
@@ -1454,435 +2209,151 @@ var Input = forwardRef(
|
|
|
1454
2209
|
setIsFocused(false);
|
|
1455
2210
|
onBlur?.(e);
|
|
1456
2211
|
};
|
|
1457
|
-
|
|
2212
|
+
const handleChange = (e) => {
|
|
2213
|
+
if (!isControlled) {
|
|
2214
|
+
setInternalValue(e.target.value);
|
|
2215
|
+
}
|
|
2216
|
+
onChange?.(e);
|
|
2217
|
+
};
|
|
2218
|
+
const handleClear = (e) => {
|
|
2219
|
+
e.preventDefault();
|
|
2220
|
+
e.stopPropagation();
|
|
2221
|
+
if (!isControlled) {
|
|
2222
|
+
setInternalValue("");
|
|
2223
|
+
}
|
|
2224
|
+
if (onChange && ref && "current" in ref && ref.current) {
|
|
2225
|
+
const syntheticEvent = {
|
|
2226
|
+
target: { ...ref.current, value: "" },
|
|
2227
|
+
currentTarget: ref.current
|
|
2228
|
+
};
|
|
2229
|
+
onChange(syntheticEvent);
|
|
2230
|
+
}
|
|
2231
|
+
onClear?.();
|
|
2232
|
+
};
|
|
2233
|
+
const shouldShowClearButton = clearable && hasValue && !disabled && !readOnly;
|
|
2234
|
+
const clearButtonNode = shouldShowClearButton ? /* @__PURE__ */ React3.createElement(
|
|
2235
|
+
ClearButton,
|
|
2236
|
+
{
|
|
2237
|
+
type: "button",
|
|
2238
|
+
$size: size,
|
|
2239
|
+
$lineType: lineType,
|
|
2240
|
+
onClick: handleClear,
|
|
2241
|
+
"aria-label": "Clear",
|
|
2242
|
+
tabIndex: -1
|
|
2243
|
+
},
|
|
2244
|
+
clearIcon || /* @__PURE__ */ React3.createElement(DefaultClearIcon, null)
|
|
2245
|
+
) : null;
|
|
2246
|
+
return /* @__PURE__ */ React3.createElement(InputContainer, { $size: size, $lineType: lineType, className, style }, /* @__PURE__ */ React3.createElement(
|
|
1458
2247
|
InputWrapper2,
|
|
1459
2248
|
{
|
|
1460
2249
|
$size: size,
|
|
2250
|
+
$lineType: lineType,
|
|
1461
2251
|
$error: error,
|
|
1462
2252
|
$disabled: !!disabled,
|
|
1463
2253
|
$readOnly: !!readOnly,
|
|
1464
|
-
$isFocused: isFocused
|
|
1465
|
-
className,
|
|
1466
|
-
style
|
|
2254
|
+
$isFocused: isFocused
|
|
1467
2255
|
},
|
|
1468
|
-
prefixNode && /* @__PURE__ */
|
|
1469
|
-
/* @__PURE__ */
|
|
2256
|
+
prefixNode && /* @__PURE__ */ React3.createElement(PrefixNode, { $size: size, $lineType: lineType }, prefixNode),
|
|
2257
|
+
/* @__PURE__ */ React3.createElement(ContentBlock, { $size: size, $lineType: lineType }, /* @__PURE__ */ React3.createElement(
|
|
1470
2258
|
StyledInput2,
|
|
1471
2259
|
{
|
|
1472
2260
|
ref,
|
|
1473
2261
|
$size: size,
|
|
2262
|
+
$lineType: lineType,
|
|
1474
2263
|
$disabled: !!disabled,
|
|
1475
2264
|
$readOnly: !!readOnly,
|
|
2265
|
+
$isFocused: isFocused,
|
|
1476
2266
|
disabled,
|
|
1477
2267
|
readOnly,
|
|
2268
|
+
value: currentValue,
|
|
2269
|
+
onChange: handleChange,
|
|
1478
2270
|
onFocus: handleFocus,
|
|
1479
2271
|
onBlur: handleBlur,
|
|
1480
2272
|
...rest
|
|
1481
2273
|
}
|
|
1482
|
-
),
|
|
1483
|
-
suffixNode && /* @__PURE__ */
|
|
1484
|
-
);
|
|
2274
|
+
), clearButtonNode),
|
|
2275
|
+
suffixNode && /* @__PURE__ */ React3.createElement(SuffixNode, { $size: size, $lineType: lineType }, suffixNode)
|
|
2276
|
+
), lineType === "underlined" && error && /* @__PURE__ */ React3.createElement(AlertLine, null));
|
|
1485
2277
|
}
|
|
1486
2278
|
);
|
|
1487
2279
|
Input.displayName = "Input";
|
|
2280
|
+
|
|
2281
|
+
// src/Input/SearchInput.tsx
|
|
2282
|
+
init_styled();
|
|
2283
|
+
init_Icon2();
|
|
2284
|
+
init_context();
|
|
1488
2285
|
var SearchIconWrapper = styled.div`
|
|
1489
2286
|
display: inline-flex;
|
|
1490
2287
|
align-items: center;
|
|
1491
2288
|
justify-content: center;
|
|
1492
2289
|
flex-shrink: 0;
|
|
1493
2290
|
|
|
1494
|
-
${({ $size, theme: theme2 }) => {
|
|
1495
|
-
const sizeConfig = theme2.components.input.outlined[$size === "extraLarge" ? "extraLarge" : "large"];
|
|
1496
|
-
return `
|
|
1497
|
-
width: ${sizeConfig.iconSize.width};
|
|
1498
|
-
height: ${sizeConfig.iconSize.height};
|
|
1499
|
-
`;
|
|
1500
|
-
}}
|
|
1501
|
-
|
|
1502
2291
|
svg {
|
|
1503
2292
|
width: 100%;
|
|
1504
2293
|
height: 100%;
|
|
1505
|
-
color: ${({ theme:
|
|
2294
|
+
color: ${({ theme: theme3 }) => theme3.colors?.palettes?.transparency?.["100"] || "#41464b"};
|
|
1506
2295
|
}
|
|
1507
2296
|
`;
|
|
1508
|
-
var
|
|
1509
|
-
display: inline-flex;
|
|
1510
|
-
align-items: center;
|
|
1511
|
-
justify-content: center;
|
|
1512
|
-
flex-shrink: 0;
|
|
1513
|
-
border: none;
|
|
1514
|
-
background: transparent;
|
|
1515
|
-
cursor: pointer;
|
|
1516
|
-
padding: 0;
|
|
1517
|
-
margin: 0;
|
|
1518
|
-
outline: none;
|
|
1519
|
-
transition: opacity 0.2s ease;
|
|
1520
|
-
|
|
1521
|
-
${({ $size, theme: theme2 }) => {
|
|
1522
|
-
const sizeConfig = theme2.components.input.outlined[$size === "extraLarge" ? "extraLarge" : "large"];
|
|
1523
|
-
return `
|
|
1524
|
-
width: ${sizeConfig.iconSize.width};
|
|
1525
|
-
height: ${sizeConfig.iconSize.height};
|
|
1526
|
-
`;
|
|
1527
|
-
}}
|
|
1528
|
-
|
|
1529
|
-
svg {
|
|
1530
|
-
width: 100%;
|
|
1531
|
-
height: 100%;
|
|
1532
|
-
color: ${({ theme: theme2 }) => theme2.colors.palettes.transparency["100"]};
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
&:hover {
|
|
1536
|
-
opacity: 0.7;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
&:active {
|
|
1540
|
-
opacity: 0.5;
|
|
1541
|
-
}
|
|
1542
|
-
`;
|
|
1543
|
-
var DefaultSearchIcon = () => /* @__PURE__ */ React12.createElement("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement(
|
|
1544
|
-
"path",
|
|
1545
|
-
{
|
|
1546
|
-
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",
|
|
1547
|
-
stroke: "currentColor",
|
|
1548
|
-
strokeWidth: "1.5",
|
|
1549
|
-
strokeLinecap: "round",
|
|
1550
|
-
strokeLinejoin: "round"
|
|
1551
|
-
}
|
|
1552
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1553
|
-
"path",
|
|
1554
|
-
{
|
|
1555
|
-
d: "M14 14L11.1 11.1",
|
|
1556
|
-
stroke: "currentColor",
|
|
1557
|
-
strokeWidth: "1.5",
|
|
1558
|
-
strokeLinecap: "round",
|
|
1559
|
-
strokeLinejoin: "round"
|
|
1560
|
-
}
|
|
1561
|
-
));
|
|
1562
|
-
var DefaultCloseIcon = () => /* @__PURE__ */ React12.createElement("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement(
|
|
1563
|
-
"path",
|
|
1564
|
-
{
|
|
1565
|
-
d: "M12 4L4 12",
|
|
1566
|
-
stroke: "currentColor",
|
|
1567
|
-
strokeWidth: "1.5",
|
|
1568
|
-
strokeLinecap: "round",
|
|
1569
|
-
strokeLinejoin: "round"
|
|
1570
|
-
}
|
|
1571
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1572
|
-
"path",
|
|
1573
|
-
{
|
|
1574
|
-
d: "M4 4L12 12",
|
|
1575
|
-
stroke: "currentColor",
|
|
1576
|
-
strokeWidth: "1.5",
|
|
1577
|
-
strokeLinecap: "round",
|
|
1578
|
-
strokeLinejoin: "round"
|
|
1579
|
-
}
|
|
1580
|
-
));
|
|
2297
|
+
var DefaultSearchIcon = () => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React3.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M7.92359 14.0468C9.40656 14.0468 10.7664 13.5197 11.826 12.6426L13.0034 13.8199C12.8604 14.2604 12.9638 14.7635 13.3138 15.1134L14.4012 16.2008C14.8981 16.6977 15.7036 16.6977 16.2004 16.2008C16.6973 15.704 16.6973 14.8985 16.2004 14.4017L15.113 13.3143C14.7549 12.9562 14.2364 12.8562 13.7887 13.0143L12.6234 11.849C13.5122 10.7862 14.0471 9.41727 14.0471 7.92343C14.0471 4.54158 11.3055 1.80005 7.92359 1.80005C4.54165 1.80005 1.80005 4.54158 1.80005 7.92343C1.80005 11.3053 4.54165 14.0468 7.92359 14.0468ZM7.92359 12.6968C10.56 12.6968 12.6971 10.5597 12.6971 7.92343C12.6971 5.2872 10.56 3.15005 7.92359 3.15005C5.2872 3.15005 3.15005 5.2872 3.15005 7.92343C3.15005 10.5597 5.2872 12.6968 7.92359 12.6968Z", fill: "#41464B" }));
|
|
1581
2298
|
var SearchInput = forwardRef(
|
|
1582
2299
|
({
|
|
1583
|
-
|
|
2300
|
+
lineType = "outlined",
|
|
2301
|
+
size = "medium",
|
|
1584
2302
|
clearable = true,
|
|
1585
2303
|
onClear,
|
|
1586
2304
|
searchIcon,
|
|
1587
|
-
value,
|
|
1588
|
-
defaultValue,
|
|
1589
|
-
onChange,
|
|
1590
|
-
disabled,
|
|
1591
|
-
readOnly,
|
|
1592
2305
|
...rest
|
|
1593
2306
|
}, ref) => {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
2307
|
+
const getSearchIconElement = () => {
|
|
2308
|
+
if (searchIcon !== void 0) {
|
|
2309
|
+
if (typeof searchIcon === "string") {
|
|
2310
|
+
return /* @__PURE__ */ React3.createElement(Icon, { src: searchIcon });
|
|
2311
|
+
}
|
|
2312
|
+
return searchIcon;
|
|
1600
2313
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
setInternalValue("");
|
|
2314
|
+
const theme3 = getGlobalTheme();
|
|
2315
|
+
const themeIconUrl = theme3?.components?.inputSearch?.searchIcon?.url;
|
|
2316
|
+
if (themeIconUrl) {
|
|
2317
|
+
return /* @__PURE__ */ React3.createElement(Icon, { src: themeIconUrl });
|
|
1606
2318
|
}
|
|
1607
|
-
|
|
2319
|
+
return /* @__PURE__ */ React3.createElement(DefaultSearchIcon, null);
|
|
1608
2320
|
};
|
|
1609
|
-
const prefixNode = /* @__PURE__ */
|
|
1610
|
-
|
|
1611
|
-
ClearButton,
|
|
1612
|
-
{
|
|
1613
|
-
$size: size,
|
|
1614
|
-
onClick: handleClear,
|
|
1615
|
-
type: "button",
|
|
1616
|
-
tabIndex: -1
|
|
1617
|
-
},
|
|
1618
|
-
/* @__PURE__ */ React12.createElement(DefaultCloseIcon, null)
|
|
1619
|
-
) : null;
|
|
1620
|
-
return /* @__PURE__ */ React12.createElement(
|
|
2321
|
+
const prefixNode = /* @__PURE__ */ React3.createElement(SearchIconWrapper, null, getSearchIconElement());
|
|
2322
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1621
2323
|
Input,
|
|
1622
2324
|
{
|
|
1623
2325
|
ref,
|
|
2326
|
+
lineType,
|
|
1624
2327
|
size,
|
|
1625
2328
|
prefixNode,
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
onChange: handleChange,
|
|
1629
|
-
disabled,
|
|
1630
|
-
readOnly,
|
|
2329
|
+
clearable,
|
|
2330
|
+
onClear,
|
|
1631
2331
|
...rest
|
|
1632
2332
|
}
|
|
1633
2333
|
);
|
|
1634
2334
|
}
|
|
1635
2335
|
);
|
|
1636
2336
|
SearchInput.displayName = "SearchInput";
|
|
1637
|
-
var
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
children
|
|
1641
|
-
}) => {
|
|
1642
|
-
return /* @__PURE__ */ React12.createElement(IconContext.Provider, { value: icons }, children);
|
|
1643
|
-
};
|
|
1644
|
-
var useIconRegistry = () => {
|
|
1645
|
-
return useContext(IconContext);
|
|
1646
|
-
};
|
|
1647
|
-
IconProvider.displayName = "IconProvider";
|
|
1648
|
-
|
|
1649
|
-
// src/Icon/Icon.tsx
|
|
1650
|
-
var IconContainer = styled.span`
|
|
1651
|
-
display: inline-flex;
|
|
1652
|
-
align-items: center;
|
|
1653
|
-
justify-content: center;
|
|
1654
|
-
width: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
1655
|
-
height: ${({ $size }) => typeof $size === "number" ? `${$size}px` : $size};
|
|
1656
|
-
color: ${({ $color }) => $color};
|
|
1657
|
-
flex-shrink: 0;
|
|
1658
|
-
line-height: 1;
|
|
1659
|
-
|
|
1660
|
-
svg {
|
|
1661
|
-
width: 100%;
|
|
1662
|
-
height: 100%;
|
|
1663
|
-
display: block;
|
|
1664
|
-
}
|
|
1665
|
-
`;
|
|
1666
|
-
var Icon = ({
|
|
1667
|
-
name,
|
|
1668
|
-
src,
|
|
1669
|
-
children,
|
|
1670
|
-
size = 16,
|
|
1671
|
-
color = "currentColor",
|
|
1672
|
-
alt = "icon",
|
|
1673
|
-
className,
|
|
1674
|
-
style,
|
|
1675
|
-
onClick
|
|
1676
|
-
}) => {
|
|
1677
|
-
const registry = useIconRegistry();
|
|
1678
|
-
let iconElement = children;
|
|
1679
|
-
if (!iconElement && src) {
|
|
1680
|
-
iconElement = /* @__PURE__ */ React12.createElement(
|
|
1681
|
-
"img",
|
|
1682
|
-
{
|
|
1683
|
-
src,
|
|
1684
|
-
alt,
|
|
1685
|
-
style: { width: "100%", height: "100%", display: "block" }
|
|
1686
|
-
}
|
|
1687
|
-
);
|
|
1688
|
-
}
|
|
1689
|
-
if (!iconElement && name && registry) {
|
|
1690
|
-
const IconComponent = registry[name];
|
|
1691
|
-
if (IconComponent) {
|
|
1692
|
-
iconElement = /* @__PURE__ */ React12.createElement(IconComponent, null);
|
|
1693
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
1694
|
-
console.warn(`Icon "${name}" not found in registry. Make sure IconProvider is set up.`);
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
if (!iconElement) {
|
|
1698
|
-
if (process.env.NODE_ENV !== "production" && !children && !name && !src) {
|
|
1699
|
-
console.warn('Icon: one of "name", "src", or "children" must be provided');
|
|
1700
|
-
}
|
|
1701
|
-
return null;
|
|
1702
|
-
}
|
|
1703
|
-
return /* @__PURE__ */ React12.createElement(
|
|
1704
|
-
IconContainer,
|
|
1705
|
-
{
|
|
1706
|
-
$size: size,
|
|
1707
|
-
$color: color,
|
|
1708
|
-
className,
|
|
1709
|
-
style,
|
|
1710
|
-
onClick
|
|
1711
|
-
},
|
|
1712
|
-
iconElement
|
|
1713
|
-
);
|
|
1714
|
-
};
|
|
1715
|
-
Icon.displayName = "Icon";
|
|
1716
|
-
var ToastContainer = styled.div`
|
|
1717
|
-
display: inline-flex;
|
|
1718
|
-
align-items: center;
|
|
1719
|
-
gap: 8px;
|
|
1720
|
-
border: 1px solid;
|
|
1721
|
-
box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.08);
|
|
1722
|
-
|
|
1723
|
-
${({ theme: theme2 }) => {
|
|
1724
|
-
const baseConfig = theme2.components.toast;
|
|
1725
|
-
return `
|
|
1726
|
-
padding: ${baseConfig.padding};
|
|
1727
|
-
border-radius: ${baseConfig.borderRadius};
|
|
1728
|
-
font-size: ${baseConfig.fontSize};
|
|
1729
|
-
font-weight: ${baseConfig.fontWeight};
|
|
1730
|
-
`;
|
|
1731
|
-
}}
|
|
1732
|
-
|
|
1733
|
-
${({ $variant, theme: theme2 }) => {
|
|
1734
|
-
const variantConfig = theme2.components.toast[$variant];
|
|
1735
|
-
return `
|
|
1736
|
-
background: ${variantConfig.background};
|
|
1737
|
-
border-color: ${variantConfig.borderColor};
|
|
1738
|
-
`;
|
|
1739
|
-
}}
|
|
1740
|
-
`;
|
|
1741
|
-
var IconWrapper3 = styled.div`
|
|
1742
|
-
display: flex;
|
|
1743
|
-
align-items: center;
|
|
1744
|
-
justify-content: center;
|
|
1745
|
-
flex-shrink: 0;
|
|
1746
|
-
|
|
1747
|
-
${({ $variant, theme: theme2 }) => {
|
|
1748
|
-
const iconConfig = theme2.components.toast[$variant].icon;
|
|
1749
|
-
return `
|
|
1750
|
-
width: ${iconConfig.size.width};
|
|
1751
|
-
height: ${iconConfig.size.height};
|
|
1752
|
-
`;
|
|
1753
|
-
}}
|
|
1754
|
-
`;
|
|
1755
|
-
var Message = styled.span`
|
|
1756
|
-
flex: 1;
|
|
1757
|
-
line-height: 20px;
|
|
1758
|
-
color: ${({ theme: theme2 }) => theme2.colors.palettes.gray["120"]};
|
|
1759
|
-
`;
|
|
1760
|
-
var ActionButton = styled.button`
|
|
1761
|
-
background: transparent;
|
|
1762
|
-
border: none;
|
|
1763
|
-
cursor: pointer;
|
|
1764
|
-
padding: 0;
|
|
1765
|
-
outline: none;
|
|
1766
|
-
|
|
1767
|
-
${({ $variant, theme: theme2 }) => {
|
|
1768
|
-
const buttonConfig = theme2.components.toast[$variant].button;
|
|
1769
|
-
return `
|
|
1770
|
-
font-size: ${buttonConfig.fontSize};
|
|
1771
|
-
font-weight: ${buttonConfig.fontWeight};
|
|
1772
|
-
color: ${buttonConfig.color};
|
|
1773
|
-
margin-left: ${buttonConfig.gap};
|
|
1774
|
-
`;
|
|
1775
|
-
}}
|
|
1776
|
-
|
|
1777
|
-
&:hover {
|
|
1778
|
-
opacity: 0.8;
|
|
2337
|
+
var UnderlinedInput = forwardRef(
|
|
2338
|
+
(props, ref) => {
|
|
2339
|
+
return /* @__PURE__ */ React3.createElement(Input, { ...props, lineType: "underlined", ref });
|
|
1779
2340
|
}
|
|
2341
|
+
);
|
|
2342
|
+
UnderlinedInput.displayName = "UnderlinedInput";
|
|
1780
2343
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
`;
|
|
1785
|
-
var CloseButton = styled.button`
|
|
1786
|
-
background: transparent;
|
|
1787
|
-
border: none;
|
|
1788
|
-
cursor: pointer;
|
|
1789
|
-
padding: 0;
|
|
1790
|
-
width: 16px;
|
|
1791
|
-
height: 16px;
|
|
1792
|
-
display: flex;
|
|
1793
|
-
align-items: center;
|
|
1794
|
-
justify-content: center;
|
|
1795
|
-
color: ${({ theme: theme2 }) => theme2.colors.palettes.gray["60"]};
|
|
1796
|
-
flex-shrink: 0;
|
|
1797
|
-
outline: none;
|
|
2344
|
+
// src/index.ts
|
|
2345
|
+
init_NumberInput2();
|
|
2346
|
+
init_Icon2();
|
|
1798
2347
|
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
}
|
|
2348
|
+
// src/Toast/index.ts
|
|
2349
|
+
init_Toast();
|
|
1802
2350
|
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
`;
|
|
1807
|
-
var SuccessIcon = () => /* @__PURE__ */ React12.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#4ea44b" }), /* @__PURE__ */ React12.createElement("path", { d: "M6 10L9 13L14 7", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
1808
|
-
var InfoIcon = () => /* @__PURE__ */ React12.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#5ba0e7" }), /* @__PURE__ */ React12.createElement("path", { d: "M10 9V14M10 6H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1809
|
-
var ErrorIcon = () => /* @__PURE__ */ React12.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#e95555" }), /* @__PURE__ */ React12.createElement("path", { d: "M7 7L13 13M13 7L7 13", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1810
|
-
var WarnIcon = () => /* @__PURE__ */ React12.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("circle", { cx: "10", cy: "10", r: "8", fill: "#ebe361" }), /* @__PURE__ */ React12.createElement("path", { d: "M10 6V11M10 14H10.01", stroke: "white", strokeWidth: "2", strokeLinecap: "round" }));
|
|
1811
|
-
var CloseIconSvg = () => /* @__PURE__ */ React12.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React12.createElement("path", { d: "M9 3L3 9M3 3L9 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }));
|
|
1812
|
-
var Toast = ({
|
|
1813
|
-
variant = "info",
|
|
1814
|
-
message,
|
|
1815
|
-
actionText,
|
|
1816
|
-
onAction,
|
|
1817
|
-
closable = false,
|
|
1818
|
-
onClose,
|
|
1819
|
-
duration = 0,
|
|
1820
|
-
icon,
|
|
1821
|
-
showIcon = true,
|
|
1822
|
-
className,
|
|
1823
|
-
style
|
|
1824
|
-
}) => {
|
|
1825
|
-
const [visible, setVisible] = useState(true);
|
|
1826
|
-
useEffect(() => {
|
|
1827
|
-
if (duration > 0) {
|
|
1828
|
-
const timer = setTimeout(() => {
|
|
1829
|
-
setVisible(false);
|
|
1830
|
-
onClose?.();
|
|
1831
|
-
}, duration);
|
|
1832
|
-
return () => clearTimeout(timer);
|
|
1833
|
-
}
|
|
1834
|
-
}, [duration, onClose]);
|
|
1835
|
-
const handleClose = () => {
|
|
1836
|
-
setVisible(false);
|
|
1837
|
-
onClose?.();
|
|
1838
|
-
};
|
|
1839
|
-
if (!visible) {
|
|
1840
|
-
return null;
|
|
1841
|
-
}
|
|
1842
|
-
const defaultIcons = {
|
|
1843
|
-
success: /* @__PURE__ */ React12.createElement(SuccessIcon, null),
|
|
1844
|
-
info: /* @__PURE__ */ React12.createElement(InfoIcon, null),
|
|
1845
|
-
error: /* @__PURE__ */ React12.createElement(ErrorIcon, null),
|
|
1846
|
-
warn: /* @__PURE__ */ React12.createElement(WarnIcon, null)
|
|
1847
|
-
};
|
|
1848
|
-
const iconElement = icon || defaultIcons[variant];
|
|
1849
|
-
return /* @__PURE__ */ React12.createElement(
|
|
1850
|
-
ToastContainer,
|
|
1851
|
-
{
|
|
1852
|
-
$variant: variant,
|
|
1853
|
-
className,
|
|
1854
|
-
style,
|
|
1855
|
-
role: "alert",
|
|
1856
|
-
"aria-live": "polite"
|
|
1857
|
-
},
|
|
1858
|
-
showIcon && /* @__PURE__ */ React12.createElement(IconWrapper3, { $variant: variant }, iconElement),
|
|
1859
|
-
/* @__PURE__ */ React12.createElement(Message, null, message),
|
|
1860
|
-
actionText && onAction && /* @__PURE__ */ React12.createElement(
|
|
1861
|
-
ActionButton,
|
|
1862
|
-
{
|
|
1863
|
-
$variant: variant,
|
|
1864
|
-
onClick: onAction,
|
|
1865
|
-
type: "button"
|
|
1866
|
-
},
|
|
1867
|
-
actionText
|
|
1868
|
-
),
|
|
1869
|
-
closable && /* @__PURE__ */ React12.createElement(
|
|
1870
|
-
CloseButton,
|
|
1871
|
-
{
|
|
1872
|
-
onClick: handleClose,
|
|
1873
|
-
type: "button",
|
|
1874
|
-
"aria-label": "Close"
|
|
1875
|
-
},
|
|
1876
|
-
/* @__PURE__ */ React12.createElement(CloseIconSvg, null)
|
|
1877
|
-
)
|
|
1878
|
-
);
|
|
1879
|
-
};
|
|
1880
|
-
Toast.displayName = "Toast";
|
|
2351
|
+
// src/Toast/ToastContainer.tsx
|
|
2352
|
+
init_styled();
|
|
2353
|
+
init_Toast();
|
|
1881
2354
|
var ToastContext = createContext(null);
|
|
1882
|
-
var
|
|
2355
|
+
var ToastWrapper2 = styled.div`
|
|
1883
2356
|
position: fixed;
|
|
1884
|
-
top: 24px;
|
|
1885
|
-
right: 24px;
|
|
1886
2357
|
z-index: 9999;
|
|
1887
2358
|
display: flex;
|
|
1888
2359
|
flex-direction: column;
|
|
@@ -1892,8 +2363,44 @@ var ToastWrapper = styled.div`
|
|
|
1892
2363
|
> * {
|
|
1893
2364
|
pointer-events: auto;
|
|
1894
2365
|
}
|
|
2366
|
+
|
|
2367
|
+
${({ $placement, theme: theme3 }) => {
|
|
2368
|
+
const offset = theme3.components?.toast?.offset || { vertical: "24px", horizontal: "24px" };
|
|
2369
|
+
const vertical = offset.vertical || "24px";
|
|
2370
|
+
const horizontal = offset.horizontal || "24px";
|
|
2371
|
+
const styles = {
|
|
2372
|
+
"top-right": `
|
|
2373
|
+
top: ${vertical};
|
|
2374
|
+
right: ${horizontal};
|
|
2375
|
+
`,
|
|
2376
|
+
"top-left": `
|
|
2377
|
+
top: ${vertical};
|
|
2378
|
+
left: ${horizontal};
|
|
2379
|
+
`,
|
|
2380
|
+
"top-center": `
|
|
2381
|
+
top: ${vertical};
|
|
2382
|
+
left: 50%;
|
|
2383
|
+
transform: translateX(-50%);
|
|
2384
|
+
`,
|
|
2385
|
+
"bottom-right": `
|
|
2386
|
+
bottom: ${vertical};
|
|
2387
|
+
right: ${horizontal};
|
|
2388
|
+
`,
|
|
2389
|
+
"bottom-left": `
|
|
2390
|
+
bottom: ${vertical};
|
|
2391
|
+
left: ${horizontal};
|
|
2392
|
+
`,
|
|
2393
|
+
"bottom-center": `
|
|
2394
|
+
bottom: ${vertical};
|
|
2395
|
+
left: 50%;
|
|
2396
|
+
transform: translateX(-50%);
|
|
2397
|
+
`
|
|
2398
|
+
};
|
|
2399
|
+
return styles[$placement] || styles["top-right"];
|
|
2400
|
+
}}
|
|
1895
2401
|
`;
|
|
1896
2402
|
var ToastContainer2 = ({
|
|
2403
|
+
placement = "top-right",
|
|
1897
2404
|
maxCount = 5,
|
|
1898
2405
|
defaultDuration = 3e3,
|
|
1899
2406
|
children
|
|
@@ -1913,7 +2420,7 @@ var ToastContainer2 = ({
|
|
|
1913
2420
|
return id;
|
|
1914
2421
|
}, [maxCount, defaultDuration]);
|
|
1915
2422
|
const hideToast = useCallback((id) => {
|
|
1916
|
-
setToasts((prev) => prev.filter((
|
|
2423
|
+
setToasts((prev) => prev.filter((toast2) => toast2.id !== id));
|
|
1917
2424
|
}, []);
|
|
1918
2425
|
const success = useCallback((message, options) => {
|
|
1919
2426
|
return showToast({ ...options, variant: "success", message });
|
|
@@ -1935,12 +2442,12 @@ var ToastContainer2 = ({
|
|
|
1935
2442
|
error,
|
|
1936
2443
|
warn
|
|
1937
2444
|
};
|
|
1938
|
-
return /* @__PURE__ */
|
|
2445
|
+
return /* @__PURE__ */ React3.createElement(ToastContext.Provider, { value: contextValue }, children, /* @__PURE__ */ React3.createElement(ToastWrapper2, { $placement: placement }, toasts.map((toast2) => /* @__PURE__ */ React3.createElement(
|
|
1939
2446
|
Toast,
|
|
1940
2447
|
{
|
|
1941
|
-
key:
|
|
1942
|
-
...
|
|
1943
|
-
onClose: () => hideToast(
|
|
2448
|
+
key: toast2.id,
|
|
2449
|
+
...toast2,
|
|
2450
|
+
onClose: () => hideToast(toast2.id)
|
|
1944
2451
|
}
|
|
1945
2452
|
))));
|
|
1946
2453
|
};
|
|
@@ -1952,6 +2459,12 @@ var useToast = () => {
|
|
|
1952
2459
|
return context;
|
|
1953
2460
|
};
|
|
1954
2461
|
ToastContainer2.displayName = "ToastContainer";
|
|
2462
|
+
|
|
2463
|
+
// src/Toast/index.ts
|
|
2464
|
+
init_toastManager();
|
|
2465
|
+
|
|
2466
|
+
// src/Tabs/Tabs.tsx
|
|
2467
|
+
init_styled();
|
|
1955
2468
|
var TabContainer = styled.div`
|
|
1956
2469
|
display: flex;
|
|
1957
2470
|
flex-direction: column;
|
|
@@ -1961,8 +2474,8 @@ var TabList = styled.div`
|
|
|
1961
2474
|
align-items: center;
|
|
1962
2475
|
position: relative;
|
|
1963
2476
|
|
|
1964
|
-
${({ $variant, theme:
|
|
1965
|
-
const variantConfig =
|
|
2477
|
+
${({ $variant, theme: theme3 }) => {
|
|
2478
|
+
const variantConfig = theme3.components.tab[$variant];
|
|
1966
2479
|
return `
|
|
1967
2480
|
gap: ${variantConfig.layout.gap};
|
|
1968
2481
|
`;
|
|
@@ -1989,8 +2502,8 @@ var TabItem = styled.button`
|
|
|
1989
2502
|
position: relative;
|
|
1990
2503
|
white-space: nowrap;
|
|
1991
2504
|
|
|
1992
|
-
${({ theme:
|
|
1993
|
-
const sizeConfig =
|
|
2505
|
+
${({ theme: theme3 }) => {
|
|
2506
|
+
const sizeConfig = theme3.components.tab.large;
|
|
1994
2507
|
return `
|
|
1995
2508
|
height: ${sizeConfig.height};
|
|
1996
2509
|
padding: ${sizeConfig.padding};
|
|
@@ -2001,8 +2514,8 @@ var TabItem = styled.button`
|
|
|
2001
2514
|
`;
|
|
2002
2515
|
}}
|
|
2003
2516
|
|
|
2004
|
-
${({ $variant, $active, $disabled, theme:
|
|
2005
|
-
const variantConfig =
|
|
2517
|
+
${({ $variant, $active, $disabled, theme: theme3 }) => {
|
|
2518
|
+
const variantConfig = theme3.components.tab[$variant];
|
|
2006
2519
|
const itemConfig = variantConfig.item;
|
|
2007
2520
|
if ($disabled) {
|
|
2008
2521
|
return `
|
|
@@ -2025,9 +2538,9 @@ var TabItem = styled.button`
|
|
|
2025
2538
|
`;
|
|
2026
2539
|
}}
|
|
2027
2540
|
|
|
2028
|
-
${({ $variant, $disabled, theme:
|
|
2541
|
+
${({ $variant, $disabled, theme: theme3 }) => {
|
|
2029
2542
|
if ($disabled) return "";
|
|
2030
|
-
const variantConfig =
|
|
2543
|
+
const variantConfig = theme3.components.tab[$variant];
|
|
2031
2544
|
const itemConfig = variantConfig.item;
|
|
2032
2545
|
return `
|
|
2033
2546
|
&:hover {
|
|
@@ -2089,7 +2602,7 @@ var Tabs = ({
|
|
|
2089
2602
|
},
|
|
2090
2603
|
[controlledActiveKey, onChange]
|
|
2091
2604
|
);
|
|
2092
|
-
return /* @__PURE__ */
|
|
2605
|
+
return /* @__PURE__ */ React3.createElement(TabContainer, { className, style }, /* @__PURE__ */ React3.createElement(TabList, { $variant: variant, role: "tablist" }, items.map((item) => /* @__PURE__ */ React3.createElement(
|
|
2093
2606
|
TabItem,
|
|
2094
2607
|
{
|
|
2095
2608
|
key: item.key,
|
|
@@ -2103,7 +2616,7 @@ var Tabs = ({
|
|
|
2103
2616
|
disabled: item.disabled,
|
|
2104
2617
|
type: "button"
|
|
2105
2618
|
},
|
|
2106
|
-
item.icon && /* @__PURE__ */
|
|
2619
|
+
item.icon && /* @__PURE__ */ React3.createElement("span", null, item.icon),
|
|
2107
2620
|
item.label
|
|
2108
2621
|
))));
|
|
2109
2622
|
};
|
|
@@ -2120,7 +2633,7 @@ var Tooltip = ({
|
|
|
2120
2633
|
getPopupContainer,
|
|
2121
2634
|
...rest
|
|
2122
2635
|
}) => {
|
|
2123
|
-
const overlayContent =
|
|
2636
|
+
const overlayContent = React3.useMemo(() => /* @__PURE__ */ React3.createElement("div", null, content), [content]);
|
|
2124
2637
|
const variantClass = `tooltip-variant-${variant}`;
|
|
2125
2638
|
const sizeClass = variant === "white" ? `tooltip-size-${size}` : "";
|
|
2126
2639
|
const combinedClassName = [variantClass, sizeClass, overlayClassName].filter(Boolean).join(" ");
|
|
@@ -2133,9 +2646,12 @@ var Tooltip = ({
|
|
|
2133
2646
|
...getPopupContainer && { getPopupContainer },
|
|
2134
2647
|
...rest
|
|
2135
2648
|
};
|
|
2136
|
-
return /* @__PURE__ */
|
|
2649
|
+
return /* @__PURE__ */ React3.createElement(RcTooltip, { ...tooltipProps, prefixCls: "od-tooltip" }, children);
|
|
2137
2650
|
};
|
|
2138
2651
|
Tooltip.displayName = "Tooltip";
|
|
2652
|
+
|
|
2653
|
+
// src/Tooltip/globalStyle.ts
|
|
2654
|
+
init_context();
|
|
2139
2655
|
var theme = getGlobalTheme();
|
|
2140
2656
|
var arrowSize = 5;
|
|
2141
2657
|
var paddingDistance = `${arrowSize}px`;
|
|
@@ -2465,6 +2981,9 @@ var TooltipGlobalStyles = createGlobalStyle`
|
|
|
2465
2981
|
border-bottom-color: ${() => theme.components.tooltip.white.large.background};
|
|
2466
2982
|
}
|
|
2467
2983
|
`;
|
|
2984
|
+
|
|
2985
|
+
// src/ToolbarButton/ToolbarButton.tsx
|
|
2986
|
+
init_styled();
|
|
2468
2987
|
var ToolbarButtonContainer = styled.div`
|
|
2469
2988
|
display: inline-flex;
|
|
2470
2989
|
align-items: center;
|
|
@@ -2473,8 +2992,8 @@ var ToolbarButtonContainer = styled.div`
|
|
|
2473
2992
|
transition: border-color 0.15s ease;
|
|
2474
2993
|
box-sizing: border-box;
|
|
2475
2994
|
|
|
2476
|
-
${({ $disabled, $active, theme:
|
|
2477
|
-
const config =
|
|
2995
|
+
${({ $disabled, $active, theme: theme3 }) => {
|
|
2996
|
+
const config = theme3.components.toolbarButton;
|
|
2478
2997
|
if ($disabled) {
|
|
2479
2998
|
return `
|
|
2480
2999
|
border-color: ${config.border.borderColorDisabled};
|
|
@@ -2518,16 +3037,16 @@ var MainButton = styled.button`
|
|
|
2518
3037
|
outline: none;
|
|
2519
3038
|
transition: background-color 0.15s ease;
|
|
2520
3039
|
|
|
2521
|
-
${({ $hasLabel, theme:
|
|
2522
|
-
const config =
|
|
3040
|
+
${({ $hasLabel, theme: theme3 }) => {
|
|
3041
|
+
const config = theme3.components.toolbarButton;
|
|
2523
3042
|
return `
|
|
2524
3043
|
height: ${config.layout.height};
|
|
2525
3044
|
padding: ${$hasLabel ? config.layout.content.padding : config.layout.padding};
|
|
2526
3045
|
`;
|
|
2527
3046
|
}}
|
|
2528
3047
|
|
|
2529
|
-
${({ $disabled, $active, theme:
|
|
2530
|
-
const config =
|
|
3048
|
+
${({ $disabled, $active, theme: theme3 }) => {
|
|
3049
|
+
const config = theme3.components.toolbarButton;
|
|
2531
3050
|
if ($disabled) {
|
|
2532
3051
|
return `
|
|
2533
3052
|
cursor: not-allowed;
|
|
@@ -2558,16 +3077,16 @@ var IconWrapper4 = styled.span`
|
|
|
2558
3077
|
justify-content: center;
|
|
2559
3078
|
flex-shrink: 0;
|
|
2560
3079
|
|
|
2561
|
-
${({ theme:
|
|
2562
|
-
const config =
|
|
3080
|
+
${({ theme: theme3 }) => {
|
|
3081
|
+
const config = theme3.components.toolbarButton;
|
|
2563
3082
|
return `
|
|
2564
3083
|
width: ${config.layout.content.iconSize.width};
|
|
2565
3084
|
height: ${config.layout.content.iconSize.height};
|
|
2566
3085
|
`;
|
|
2567
3086
|
}}
|
|
2568
3087
|
|
|
2569
|
-
${({ $disabled, theme:
|
|
2570
|
-
const config =
|
|
3088
|
+
${({ $disabled, theme: theme3 }) => {
|
|
3089
|
+
const config = theme3.components.toolbarButton;
|
|
2571
3090
|
return $disabled ? `
|
|
2572
3091
|
color: ${config.color.colorDisabled};
|
|
2573
3092
|
` : `
|
|
@@ -2585,8 +3104,8 @@ var LabelText = styled.span`
|
|
|
2585
3104
|
font-family: 'PingFang SC', sans-serif;
|
|
2586
3105
|
white-space: nowrap;
|
|
2587
3106
|
|
|
2588
|
-
${({ theme:
|
|
2589
|
-
const config =
|
|
3107
|
+
${({ theme: theme3 }) => {
|
|
3108
|
+
const config = theme3.components.toolbarButton;
|
|
2590
3109
|
return `
|
|
2591
3110
|
font-size: ${config.typography.fontSize};
|
|
2592
3111
|
font-weight: ${config.typography.fontWeight};
|
|
@@ -2595,8 +3114,8 @@ var LabelText = styled.span`
|
|
|
2595
3114
|
`;
|
|
2596
3115
|
}}
|
|
2597
3116
|
|
|
2598
|
-
${({ $disabled, theme:
|
|
2599
|
-
const config =
|
|
3117
|
+
${({ $disabled, theme: theme3 }) => {
|
|
3118
|
+
const config = theme3.components.toolbarButton;
|
|
2600
3119
|
return $disabled ? `
|
|
2601
3120
|
color: ${config.color.colorDisabled};
|
|
2602
3121
|
` : `
|
|
@@ -2613,16 +3132,16 @@ var DropdownButton = styled.button`
|
|
|
2613
3132
|
border: none;
|
|
2614
3133
|
transition: background-color 0.15s ease;
|
|
2615
3134
|
|
|
2616
|
-
${({ theme:
|
|
2617
|
-
const config =
|
|
3135
|
+
${({ theme: theme3 }) => {
|
|
3136
|
+
const config = theme3.components.toolbarButton;
|
|
2618
3137
|
return `
|
|
2619
3138
|
height: ${config.layout.height};
|
|
2620
3139
|
padding: 5px 0;
|
|
2621
3140
|
`;
|
|
2622
3141
|
}}
|
|
2623
3142
|
|
|
2624
|
-
${({ $disabled, theme:
|
|
2625
|
-
const config =
|
|
3143
|
+
${({ $disabled, theme: theme3 }) => {
|
|
3144
|
+
const config = theme3.components.toolbarButton;
|
|
2626
3145
|
if ($disabled) {
|
|
2627
3146
|
return `
|
|
2628
3147
|
cursor: not-allowed;
|
|
@@ -2648,16 +3167,16 @@ var DropdownArrow = styled.span`
|
|
|
2648
3167
|
justify-content: center;
|
|
2649
3168
|
flex-shrink: 0;
|
|
2650
3169
|
|
|
2651
|
-
${({ theme:
|
|
2652
|
-
const config =
|
|
3170
|
+
${({ theme: theme3 }) => {
|
|
3171
|
+
const config = theme3.components.toolbarButton;
|
|
2653
3172
|
return `
|
|
2654
3173
|
width: ${config.layout.dropdown.iconSize.width};
|
|
2655
3174
|
height: ${config.layout.dropdown.iconSize.height};
|
|
2656
3175
|
`;
|
|
2657
3176
|
}}
|
|
2658
3177
|
|
|
2659
|
-
${({ $disabled, theme:
|
|
2660
|
-
const config =
|
|
3178
|
+
${({ $disabled, theme: theme3 }) => {
|
|
3179
|
+
const config = theme3.components.toolbarButton;
|
|
2661
3180
|
return $disabled ? `
|
|
2662
3181
|
color: ${config.color.colorDisabled};
|
|
2663
3182
|
` : `
|
|
@@ -2672,15 +3191,15 @@ var Divider = styled.div`
|
|
|
2672
3191
|
width: 1px;
|
|
2673
3192
|
transition: background-color 0.15s ease;
|
|
2674
3193
|
|
|
2675
|
-
${({ theme:
|
|
2676
|
-
const config =
|
|
3194
|
+
${({ theme: theme3 }) => {
|
|
3195
|
+
const config = theme3.components.toolbarButton;
|
|
2677
3196
|
return `
|
|
2678
3197
|
height: ${config.layout.height};
|
|
2679
3198
|
`;
|
|
2680
3199
|
}}
|
|
2681
3200
|
|
|
2682
|
-
${({ $disabled, $active, theme:
|
|
2683
|
-
const config =
|
|
3201
|
+
${({ $disabled, $active, theme: theme3 }) => {
|
|
3202
|
+
const config = theme3.components.toolbarButton;
|
|
2684
3203
|
if ($disabled) {
|
|
2685
3204
|
return `
|
|
2686
3205
|
background-color: ${config.border.borderColorDisabled};
|
|
@@ -2696,7 +3215,7 @@ var Divider = styled.div`
|
|
|
2696
3215
|
`;
|
|
2697
3216
|
}}
|
|
2698
3217
|
`;
|
|
2699
|
-
var ArrowIcon = () => /* @__PURE__ */
|
|
3218
|
+
var ArrowIcon = () => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
2700
3219
|
"path",
|
|
2701
3220
|
{
|
|
2702
3221
|
d: "M8.1858 9.79353C8.08649 9.90387 7.91346 9.90387 7.81415 9.79353L4.77549 6.41724C4.6307 6.25636 4.74487 6 4.96132 6L11.0386 6C11.2551 6 11.3693 6.25636 11.2245 6.41724L8.1858 9.79353Z",
|
|
@@ -2726,7 +3245,7 @@ var ToolbarButton = ({
|
|
|
2726
3245
|
onDropdownClick?.(e);
|
|
2727
3246
|
};
|
|
2728
3247
|
if (!splitDropdown && hasDropdown) {
|
|
2729
|
-
return /* @__PURE__ */
|
|
3248
|
+
return /* @__PURE__ */ React3.createElement(
|
|
2730
3249
|
ToolbarButtonContainer,
|
|
2731
3250
|
{
|
|
2732
3251
|
className,
|
|
@@ -2734,7 +3253,7 @@ var ToolbarButton = ({
|
|
|
2734
3253
|
$disabled: disabled,
|
|
2735
3254
|
$active: active
|
|
2736
3255
|
},
|
|
2737
|
-
/* @__PURE__ */
|
|
3256
|
+
/* @__PURE__ */ React3.createElement(
|
|
2738
3257
|
MainButton,
|
|
2739
3258
|
{
|
|
2740
3259
|
$disabled: disabled,
|
|
@@ -2743,14 +3262,14 @@ var ToolbarButton = ({
|
|
|
2743
3262
|
onClick: handleMainClick,
|
|
2744
3263
|
disabled
|
|
2745
3264
|
},
|
|
2746
|
-
icon && /* @__PURE__ */
|
|
2747
|
-
label && /* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */
|
|
3265
|
+
icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
|
|
3266
|
+
label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label),
|
|
3267
|
+
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(ArrowIcon, null))
|
|
2749
3268
|
)
|
|
2750
3269
|
);
|
|
2751
3270
|
}
|
|
2752
3271
|
if (splitDropdown && hasDropdown) {
|
|
2753
|
-
return /* @__PURE__ */
|
|
3272
|
+
return /* @__PURE__ */ React3.createElement(
|
|
2754
3273
|
ToolbarButtonContainer,
|
|
2755
3274
|
{
|
|
2756
3275
|
className,
|
|
@@ -2758,7 +3277,7 @@ var ToolbarButton = ({
|
|
|
2758
3277
|
$disabled: disabled,
|
|
2759
3278
|
$active: active
|
|
2760
3279
|
},
|
|
2761
|
-
/* @__PURE__ */
|
|
3280
|
+
/* @__PURE__ */ React3.createElement(
|
|
2762
3281
|
MainButton,
|
|
2763
3282
|
{
|
|
2764
3283
|
$disabled: disabled,
|
|
@@ -2767,11 +3286,11 @@ var ToolbarButton = ({
|
|
|
2767
3286
|
onClick: handleMainClick,
|
|
2768
3287
|
disabled
|
|
2769
3288
|
},
|
|
2770
|
-
icon && /* @__PURE__ */
|
|
2771
|
-
label && /* @__PURE__ */
|
|
3289
|
+
icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
|
|
3290
|
+
label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label)
|
|
2772
3291
|
),
|
|
2773
|
-
/* @__PURE__ */
|
|
2774
|
-
/* @__PURE__ */
|
|
3292
|
+
/* @__PURE__ */ React3.createElement(Divider, { $disabled: disabled, $active: active }),
|
|
3293
|
+
/* @__PURE__ */ React3.createElement(
|
|
2775
3294
|
DropdownButton,
|
|
2776
3295
|
{
|
|
2777
3296
|
$disabled: disabled,
|
|
@@ -2780,11 +3299,11 @@ var ToolbarButton = ({
|
|
|
2780
3299
|
onClick: handleDropdownClick,
|
|
2781
3300
|
disabled
|
|
2782
3301
|
},
|
|
2783
|
-
/* @__PURE__ */
|
|
3302
|
+
/* @__PURE__ */ React3.createElement(DropdownArrow, { $disabled: disabled }, /* @__PURE__ */ React3.createElement(ArrowIcon, null))
|
|
2784
3303
|
)
|
|
2785
3304
|
);
|
|
2786
3305
|
}
|
|
2787
|
-
return /* @__PURE__ */
|
|
3306
|
+
return /* @__PURE__ */ React3.createElement(
|
|
2788
3307
|
ToolbarButtonContainer,
|
|
2789
3308
|
{
|
|
2790
3309
|
className,
|
|
@@ -2792,7 +3311,7 @@ var ToolbarButton = ({
|
|
|
2792
3311
|
$disabled: disabled,
|
|
2793
3312
|
$active: active
|
|
2794
3313
|
},
|
|
2795
|
-
/* @__PURE__ */
|
|
3314
|
+
/* @__PURE__ */ React3.createElement(
|
|
2796
3315
|
MainButton,
|
|
2797
3316
|
{
|
|
2798
3317
|
$disabled: disabled,
|
|
@@ -2801,43 +3320,939 @@ var ToolbarButton = ({
|
|
|
2801
3320
|
onClick: handleMainClick,
|
|
2802
3321
|
disabled
|
|
2803
3322
|
},
|
|
2804
|
-
icon && /* @__PURE__ */
|
|
2805
|
-
label && /* @__PURE__ */
|
|
3323
|
+
icon && /* @__PURE__ */ React3.createElement(IconWrapper4, { $disabled: disabled }, icon),
|
|
3324
|
+
label && /* @__PURE__ */ React3.createElement(LabelText, { $disabled: disabled }, label)
|
|
2806
3325
|
)
|
|
2807
3326
|
);
|
|
2808
3327
|
};
|
|
2809
3328
|
ToolbarButton.displayName = "ToolbarButton";
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
3329
|
+
|
|
3330
|
+
// src/dropdown/DropdownButton.tsx
|
|
3331
|
+
init_styled();
|
|
3332
|
+
init_Icon2();
|
|
3333
|
+
var DropdownButtonContainer = styled.button`
|
|
3334
|
+
display: inline-flex;
|
|
3335
|
+
align-items: center;
|
|
3336
|
+
cursor: pointer;
|
|
3337
|
+
border: none;
|
|
3338
|
+
outline: none;
|
|
3339
|
+
box-sizing: border-box;
|
|
3340
|
+
transition: all 0.2s ease;
|
|
3341
|
+
font-family: 'PingFang SC', sans-serif;
|
|
3342
|
+
|
|
3343
|
+
${({ $size, theme: theme3 }) => {
|
|
3344
|
+
const config = theme3.components?.dropdownButton;
|
|
3345
|
+
const sizeConfig = config?.size?.[$size];
|
|
3346
|
+
if (!sizeConfig) return "";
|
|
3347
|
+
return `
|
|
3348
|
+
height: ${sizeConfig.height};
|
|
3349
|
+
padding: ${sizeConfig.padding};
|
|
3350
|
+
gap: ${sizeConfig.gap};
|
|
3351
|
+
font-size: ${sizeConfig.fontSize};
|
|
3352
|
+
`;
|
|
3353
|
+
}}
|
|
3354
|
+
|
|
3355
|
+
${({ $variant, $disabled, $error, theme: theme3 }) => {
|
|
3356
|
+
const config = theme3.components?.dropdownButton;
|
|
3357
|
+
if (!config) return "";
|
|
3358
|
+
let background = config.background.normal;
|
|
3359
|
+
if ($disabled) {
|
|
3360
|
+
background = config.background.disabled;
|
|
2832
3361
|
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
3362
|
+
let border = "none";
|
|
3363
|
+
const borderRadius = config.borderRadius || "4px";
|
|
3364
|
+
if ($variant === "framed") {
|
|
3365
|
+
const borderColor = $error ? theme3.colors?.palettes?.red?.["6"] : theme3.colors?.palettes?.transparency?.["10"];
|
|
3366
|
+
border = `1px solid ${borderColor}`;
|
|
3367
|
+
}
|
|
3368
|
+
const color = $disabled ? config.color.disabled : config.color.normal;
|
|
3369
|
+
return `
|
|
3370
|
+
background: ${background};
|
|
3371
|
+
border: ${border};
|
|
3372
|
+
border-radius: ${borderRadius};
|
|
3373
|
+
color: ${color};
|
|
2836
3374
|
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
3375
|
+
&:hover:not(:disabled) {
|
|
3376
|
+
background: ${config.background.hover};
|
|
3377
|
+
${$variant === "framed" && !$error ? `
|
|
3378
|
+
border-color: ${theme3.colors?.palettes?.transparency?.["20"]};
|
|
3379
|
+
` : ""}
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
&:active:not(:disabled) {
|
|
3383
|
+
background: ${config.background.active};
|
|
3384
|
+
${$variant === "framed" && !$error ? `
|
|
3385
|
+
border-color: ${theme3.colors?.palettes?.transparency?.["30"]};
|
|
3386
|
+
` : ""}
|
|
3387
|
+
}
|
|
3388
|
+
`;
|
|
3389
|
+
}}
|
|
3390
|
+
|
|
3391
|
+
${({ $disabled }) => $disabled && `
|
|
3392
|
+
cursor: not-allowed;
|
|
3393
|
+
`}
|
|
3394
|
+
`;
|
|
3395
|
+
var IconWrapper5 = styled.div`
|
|
3396
|
+
display: flex;
|
|
3397
|
+
align-items: center;
|
|
3398
|
+
justify-content: center;
|
|
3399
|
+
flex-shrink: 0;
|
|
3400
|
+
|
|
3401
|
+
${({ $size, theme: theme3 }) => {
|
|
3402
|
+
const config = theme3.components?.dropdownButton;
|
|
3403
|
+
const sizeConfig = config?.size?.[$size];
|
|
3404
|
+
if (!sizeConfig) return "";
|
|
3405
|
+
return `
|
|
3406
|
+
width: ${sizeConfig.iconSize.width};
|
|
3407
|
+
height: ${sizeConfig.iconSize.height};
|
|
3408
|
+
|
|
3409
|
+
svg, img {
|
|
3410
|
+
width: ${sizeConfig.iconSize.width};
|
|
3411
|
+
height: ${sizeConfig.iconSize.height};
|
|
3412
|
+
}
|
|
3413
|
+
`;
|
|
3414
|
+
}}
|
|
3415
|
+
|
|
3416
|
+
${({ theme: theme3 }) => {
|
|
3417
|
+
const config = theme3.components?.dropdownButton;
|
|
3418
|
+
return `
|
|
3419
|
+
color: ${config?.color?.normal || "#41464b"};
|
|
3420
|
+
`;
|
|
3421
|
+
}}
|
|
3422
|
+
`;
|
|
3423
|
+
var TextContent = styled.div`
|
|
3424
|
+
flex: 1;
|
|
3425
|
+
min-width: 0; /* Important: allows flex item to shrink below content size */
|
|
3426
|
+
overflow: hidden;
|
|
3427
|
+
text-overflow: ellipsis;
|
|
3428
|
+
white-space: nowrap;
|
|
3429
|
+
text-align: left;
|
|
3430
|
+
line-height: 20px;
|
|
3431
|
+
|
|
3432
|
+
${({ $hasValue, $disabled, theme: theme3 }) => {
|
|
3433
|
+
const config = theme3.components?.dropdownButton;
|
|
3434
|
+
const color = $disabled ? config?.color?.disabled : config?.color?.normal;
|
|
3435
|
+
return `
|
|
3436
|
+
color: ${color};
|
|
3437
|
+
${!$hasValue ? `opacity: 0.3;` : ""}
|
|
3438
|
+
`;
|
|
3439
|
+
}}
|
|
3440
|
+
`;
|
|
3441
|
+
var IndicatorWrapper = styled.div`
|
|
3442
|
+
display: flex;
|
|
3443
|
+
align-items: center;
|
|
3444
|
+
justify-content: center;
|
|
3445
|
+
flex-shrink: 0;
|
|
3446
|
+
transition: transform 0.2s ease;
|
|
3447
|
+
|
|
3448
|
+
${({ $size, theme: theme3 }) => {
|
|
3449
|
+
const config = theme3.components?.dropdownButton;
|
|
3450
|
+
const sizeConfig = config?.size?.[$size];
|
|
3451
|
+
if (!sizeConfig) return "";
|
|
3452
|
+
return `
|
|
3453
|
+
width: ${sizeConfig.indicatorSize.width};
|
|
3454
|
+
height: ${sizeConfig.indicatorSize.height};
|
|
3455
|
+
`;
|
|
3456
|
+
}}
|
|
3457
|
+
|
|
3458
|
+
${({ $open, theme: theme3 }) => {
|
|
3459
|
+
const config = theme3.components?.dropdownButton?.indicator;
|
|
3460
|
+
const rotate = config?.rotate || "90deg";
|
|
3461
|
+
return `
|
|
3462
|
+
transform: rotate(${$open ? rotate : 0});
|
|
3463
|
+
`;
|
|
3464
|
+
}}
|
|
3465
|
+
|
|
3466
|
+
${({ $disabled, theme: theme3 }) => {
|
|
3467
|
+
const config = theme3.components?.dropdownButton?.indicator?.opacity;
|
|
3468
|
+
const opacity = $disabled ? config?.disabled || "0.3" : config?.normal || "1";
|
|
3469
|
+
return `
|
|
3470
|
+
opacity: ${opacity};
|
|
3471
|
+
color: ${theme3.components?.dropdownButton?.color?.normal || "#41464b"};
|
|
3472
|
+
`;
|
|
3473
|
+
}}
|
|
3474
|
+
`;
|
|
3475
|
+
var DefaultArrowIcon = () => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
3476
|
+
"path",
|
|
3477
|
+
{
|
|
3478
|
+
d: "M11.5975 8.81186C11.7113 8.91146 11.7113 9.08854 11.5975 9.18814L7.72713 12.5747C7.56548 12.7161 7.3125 12.6013 7.3125 12.3866L7.3125 5.61344C7.3125 5.39865 7.56548 5.28386 7.72713 5.4253L11.5975 8.81186Z",
|
|
3479
|
+
fill: "#41464B"
|
|
3480
|
+
}
|
|
3481
|
+
));
|
|
3482
|
+
var DropdownButton2 = forwardRef(
|
|
3483
|
+
({
|
|
3484
|
+
variant = "framed",
|
|
3485
|
+
size,
|
|
3486
|
+
value,
|
|
3487
|
+
placeholder = "Select...",
|
|
3488
|
+
icon,
|
|
3489
|
+
indicatorIcon,
|
|
3490
|
+
open = false,
|
|
3491
|
+
disabled = false,
|
|
3492
|
+
error = false,
|
|
3493
|
+
className,
|
|
3494
|
+
style,
|
|
3495
|
+
textStyle,
|
|
3496
|
+
onClick,
|
|
3497
|
+
...rest
|
|
3498
|
+
}, ref) => {
|
|
3499
|
+
const effectiveSize = size || (variant === "framed" ? "large" : "medium");
|
|
3500
|
+
const hasValue = !!value;
|
|
3501
|
+
const getIconElement = () => {
|
|
3502
|
+
if (!icon) return null;
|
|
3503
|
+
if (typeof icon === "string") {
|
|
3504
|
+
return /* @__PURE__ */ React3.createElement(Icon, { src: icon });
|
|
3505
|
+
}
|
|
3506
|
+
return icon;
|
|
3507
|
+
};
|
|
3508
|
+
const iconElement = getIconElement();
|
|
3509
|
+
return /* @__PURE__ */ React3.createElement(
|
|
3510
|
+
DropdownButtonContainer,
|
|
3511
|
+
{
|
|
3512
|
+
ref,
|
|
3513
|
+
type: "button",
|
|
3514
|
+
$variant: variant,
|
|
3515
|
+
$size: effectiveSize,
|
|
3516
|
+
$disabled: disabled,
|
|
3517
|
+
$open: open,
|
|
3518
|
+
$error: error,
|
|
3519
|
+
disabled,
|
|
3520
|
+
onClick,
|
|
3521
|
+
className,
|
|
3522
|
+
style,
|
|
3523
|
+
...rest
|
|
3524
|
+
},
|
|
3525
|
+
iconElement && /* @__PURE__ */ React3.createElement(IconWrapper5, { $size: effectiveSize }, iconElement),
|
|
3526
|
+
/* @__PURE__ */ React3.createElement(TextContent, { $disabled: disabled, $hasValue: hasValue, style: textStyle }, value || placeholder),
|
|
3527
|
+
/* @__PURE__ */ React3.createElement(IndicatorWrapper, { $size: effectiveSize, $open: open, $disabled: disabled }, indicatorIcon || /* @__PURE__ */ React3.createElement(DefaultArrowIcon, null))
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
);
|
|
3531
|
+
DropdownButton2.displayName = "DropdownButton";
|
|
3532
|
+
|
|
3533
|
+
// src/dropdown/Menu.tsx
|
|
3534
|
+
init_styled();
|
|
3535
|
+
init_Icon2();
|
|
3536
|
+
var MenuContainer = styled.div`
|
|
3537
|
+
display: flex;
|
|
3538
|
+
flex-direction: column;
|
|
3539
|
+
box-sizing: border-box;
|
|
3540
|
+
min-width: 220px;
|
|
3541
|
+
|
|
3542
|
+
${({ theme: theme3 }) => {
|
|
3543
|
+
const dropdownConfig = theme3.components?.dropdown;
|
|
3544
|
+
const menuConfig = theme3.components?.menu;
|
|
3545
|
+
return `
|
|
3546
|
+
background: ${dropdownConfig?.background || "#fff"};
|
|
3547
|
+
border: ${menuConfig?.border?.width || "1px"} solid ${menuConfig?.border?.color || "rgba(65, 70, 75, 0.1)"};
|
|
3548
|
+
border-radius: ${menuConfig?.border?.radius || "4px"};
|
|
3549
|
+
box-shadow: ${dropdownConfig?.boxShadow || "0 2px 8px rgba(0, 0, 0, 0.15)"};
|
|
3550
|
+
`;
|
|
3551
|
+
}}
|
|
3552
|
+
|
|
3553
|
+
/* Ensure virtual list container has proper width */
|
|
3554
|
+
.rc-virtual-list {
|
|
3555
|
+
width: 100%;
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
.rc-virtual-list-holder {
|
|
3559
|
+
width: 100%;
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
.rc-virtual-list-holder-inner {
|
|
3563
|
+
width: 100%;
|
|
3564
|
+
}
|
|
3565
|
+
`;
|
|
3566
|
+
var SearchBoxContainer = styled.div`
|
|
3567
|
+
padding: 8px 12px;
|
|
3568
|
+
border-bottom: 1px solid ${({ theme: theme3 }) => theme3.colors?.palettes?.transparency?.["10"]};
|
|
3569
|
+
`;
|
|
3570
|
+
var SearchIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
3571
|
+
"path",
|
|
3572
|
+
{
|
|
3573
|
+
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",
|
|
3574
|
+
stroke: "currentColor",
|
|
3575
|
+
strokeWidth: "1.5",
|
|
3576
|
+
strokeLinecap: "round",
|
|
3577
|
+
strokeLinejoin: "round"
|
|
3578
|
+
}
|
|
3579
|
+
), /* @__PURE__ */ React3.createElement(
|
|
3580
|
+
"path",
|
|
3581
|
+
{
|
|
3582
|
+
d: "M14 14L11.1 11.1",
|
|
3583
|
+
stroke: "currentColor",
|
|
3584
|
+
strokeWidth: "1.5",
|
|
3585
|
+
strokeLinecap: "round",
|
|
3586
|
+
strokeLinejoin: "round"
|
|
3587
|
+
}
|
|
3588
|
+
));
|
|
3589
|
+
var MenuItemContent = styled.div`
|
|
3590
|
+
display: flex;
|
|
3591
|
+
align-items: center;
|
|
3592
|
+
width: 100%;
|
|
3593
|
+
|
|
3594
|
+
${({ theme: theme3 }) => {
|
|
3595
|
+
const config = theme3.components?.menu?.menuItem;
|
|
3596
|
+
return `
|
|
3597
|
+
gap: ${config?.layout?.gap || "8px"};
|
|
3598
|
+
`;
|
|
3599
|
+
}}
|
|
3600
|
+
`;
|
|
3601
|
+
var IconContainer2 = styled.div`
|
|
3602
|
+
display: flex;
|
|
3603
|
+
align-items: center;
|
|
3604
|
+
justify-content: center;
|
|
3605
|
+
flex-shrink: 0;
|
|
3606
|
+
|
|
3607
|
+
${({ theme: theme3 }) => {
|
|
3608
|
+
const iconSize = theme3.components?.menu?.menuItem?.icon?.size;
|
|
3609
|
+
return `
|
|
3610
|
+
width: ${iconSize?.width || "18px"};
|
|
3611
|
+
height: ${iconSize?.height || "18px"};
|
|
3612
|
+
|
|
3613
|
+
svg, img {
|
|
3614
|
+
width: 100%;
|
|
3615
|
+
height: 100%;
|
|
3616
|
+
}
|
|
3617
|
+
`;
|
|
3618
|
+
}}
|
|
3619
|
+
`;
|
|
3620
|
+
var ContentBlock2 = styled.div`
|
|
3621
|
+
display: flex;
|
|
3622
|
+
flex: 1;
|
|
3623
|
+
align-items: center;
|
|
3624
|
+
justify-content: space-between;
|
|
3625
|
+
gap: 16px;
|
|
3626
|
+
min-width: 0;
|
|
3627
|
+
`;
|
|
3628
|
+
var LabelText2 = styled.div`
|
|
3629
|
+
flex: 1;
|
|
3630
|
+
min-width: 0;
|
|
3631
|
+
overflow: hidden;
|
|
3632
|
+
text-overflow: ellipsis;
|
|
3633
|
+
white-space: nowrap;
|
|
3634
|
+
line-height: 20px;
|
|
3635
|
+
|
|
3636
|
+
${({ $size, $disabled, theme: theme3 }) => {
|
|
3637
|
+
const config = theme3.components?.menu?.menuItem;
|
|
3638
|
+
const sizeConfig = config?.size?.[$size];
|
|
3639
|
+
const colorConfig = config?.label?.color;
|
|
3640
|
+
const fontSize = sizeConfig?.label?.fontSize || "13px";
|
|
3641
|
+
const color = $disabled ? colorConfig?.disabled || "rgba(65, 70, 75, 0.3)" : colorConfig?.normal || "#41464b";
|
|
3642
|
+
return `
|
|
3643
|
+
font-size: ${fontSize};
|
|
3644
|
+
color: ${color};
|
|
3645
|
+
`;
|
|
3646
|
+
}}
|
|
3647
|
+
`;
|
|
3648
|
+
var DescriptionText = styled.div`
|
|
3649
|
+
flex: 0 0 auto;
|
|
3650
|
+
white-space: nowrap;
|
|
3651
|
+
line-height: 20px;
|
|
3652
|
+
text-align: right;
|
|
3653
|
+
|
|
3654
|
+
${({ $size, $disabled, theme: theme3 }) => {
|
|
3655
|
+
const config = theme3.components?.menu?.menuItem;
|
|
3656
|
+
const sizeConfig = config?.size?.[$size];
|
|
3657
|
+
const colorConfig = config?.description?.color;
|
|
3658
|
+
const fontSize = sizeConfig?.description?.fontSize || "10px";
|
|
3659
|
+
const color = $disabled ? colorConfig?.disabled || "rgba(65, 70, 75, 0.3)" : colorConfig?.normal || "rgba(65, 70, 75, 0.6)";
|
|
3660
|
+
return `
|
|
3661
|
+
font-size: ${fontSize};
|
|
3662
|
+
color: ${color};
|
|
3663
|
+
`;
|
|
3664
|
+
}}
|
|
3665
|
+
`;
|
|
3666
|
+
var ActiveIconContainer = styled.div`
|
|
3667
|
+
display: flex;
|
|
3668
|
+
align-items: center;
|
|
3669
|
+
justify-content: center;
|
|
3670
|
+
flex-shrink: 0;
|
|
3671
|
+
|
|
3672
|
+
${({ $size, theme: theme3 }) => {
|
|
3673
|
+
const sizeConfig = theme3.components?.menu?.menuItem?.size?.[$size];
|
|
3674
|
+
const iconSize = sizeConfig?.activeIcon?.size;
|
|
3675
|
+
return `
|
|
3676
|
+
width: ${iconSize?.width || "18px"};
|
|
3677
|
+
height: ${iconSize?.height || "18px"};
|
|
3678
|
+
`;
|
|
3679
|
+
}}
|
|
3680
|
+
|
|
3681
|
+
${({ $visible, $placeholder }) => {
|
|
3682
|
+
if (!$visible && !$placeholder) {
|
|
3683
|
+
return "display: none;";
|
|
3684
|
+
}
|
|
3685
|
+
if ($placeholder && !$visible) {
|
|
3686
|
+
return "visibility: hidden;";
|
|
3687
|
+
}
|
|
3688
|
+
return "";
|
|
3689
|
+
}}
|
|
3690
|
+
`;
|
|
3691
|
+
var NextLevelIconContainer = styled.div`
|
|
3692
|
+
display: flex;
|
|
3693
|
+
align-items: center;
|
|
3694
|
+
justify-content: center;
|
|
3695
|
+
flex-shrink: 0;
|
|
3696
|
+
|
|
3697
|
+
${({ $size, theme: theme3 }) => {
|
|
3698
|
+
const sizeConfig = theme3.components?.menu?.menuItem?.size?.[$size];
|
|
3699
|
+
const iconSize = sizeConfig?.nextLevelIcon?.size;
|
|
3700
|
+
return `
|
|
3701
|
+
width: ${iconSize?.width || "18px"};
|
|
3702
|
+
height: ${iconSize?.height || "18px"};
|
|
3703
|
+
`;
|
|
3704
|
+
}}
|
|
3705
|
+
`;
|
|
3706
|
+
var CheckmarkIcon = () => /* @__PURE__ */ React3.createElement("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
3707
|
+
"path",
|
|
3708
|
+
{
|
|
3709
|
+
d: "M14.25 5.25L7.125 12.375L3.75 9",
|
|
3710
|
+
stroke: "#41464B",
|
|
3711
|
+
strokeWidth: "1.5",
|
|
3712
|
+
strokeLinecap: "round",
|
|
3713
|
+
strokeLinejoin: "round"
|
|
3714
|
+
}
|
|
3715
|
+
));
|
|
3716
|
+
var ArrowIcon2 = () => /* @__PURE__ */ React3.createElement("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none" }, /* @__PURE__ */ React3.createElement(
|
|
3717
|
+
"path",
|
|
3718
|
+
{
|
|
3719
|
+
d: "M6.75 4.5L11.25 9L6.75 13.5",
|
|
3720
|
+
stroke: "#41464B",
|
|
3721
|
+
strokeWidth: "1.5",
|
|
3722
|
+
strokeLinecap: "round",
|
|
3723
|
+
strokeLinejoin: "round"
|
|
3724
|
+
}
|
|
3725
|
+
));
|
|
3726
|
+
var Menu = ({
|
|
3727
|
+
items,
|
|
3728
|
+
selectedKeys = [],
|
|
3729
|
+
openKeys,
|
|
3730
|
+
size = "large",
|
|
3731
|
+
searchable = false,
|
|
3732
|
+
searchPlaceholder = "Enter search content",
|
|
3733
|
+
maxHeight = 300,
|
|
3734
|
+
virtual = false,
|
|
3735
|
+
reserveActiveIconSpace = true,
|
|
3736
|
+
onSelect,
|
|
3737
|
+
onSearch,
|
|
3738
|
+
onOpenChange,
|
|
3739
|
+
className,
|
|
3740
|
+
style
|
|
3741
|
+
}) => {
|
|
3742
|
+
const [searchValue, setSearchValue] = useState("");
|
|
3743
|
+
const handleSearch = (value) => {
|
|
3744
|
+
setSearchValue(value);
|
|
3745
|
+
onSearch?.(value);
|
|
3746
|
+
};
|
|
3747
|
+
const filteredItems = useMemo(() => {
|
|
3748
|
+
if (!searchValue) return items;
|
|
3749
|
+
const searchLower = searchValue.toLowerCase();
|
|
3750
|
+
const filterMenuItem = (item) => {
|
|
3751
|
+
if (item.label.toLowerCase().includes(searchLower) || item.description?.toLowerCase().includes(searchLower)) {
|
|
3752
|
+
return item;
|
|
3753
|
+
}
|
|
3754
|
+
if (item.children && item.children.length > 0) {
|
|
3755
|
+
const filteredChildren = item.children.map((child) => filterMenuItem(child)).filter(Boolean);
|
|
3756
|
+
if (filteredChildren.length > 0) {
|
|
3757
|
+
return { ...item, children: filteredChildren };
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
return null;
|
|
3761
|
+
};
|
|
3762
|
+
const filterItem = (item) => {
|
|
3763
|
+
if (item.type === "divider") return null;
|
|
3764
|
+
if (item.type === "group") {
|
|
3765
|
+
const filteredChildren = item.children.map((child) => filterMenuItem(child)).filter(Boolean);
|
|
3766
|
+
if (filteredChildren.length > 0) {
|
|
3767
|
+
return { ...item, children: filteredChildren };
|
|
3768
|
+
}
|
|
3769
|
+
return null;
|
|
3770
|
+
}
|
|
3771
|
+
return filterMenuItem(item);
|
|
3772
|
+
};
|
|
3773
|
+
return items.map((item) => filterItem(item)).filter(Boolean);
|
|
3774
|
+
}, [items, searchValue]);
|
|
3775
|
+
const renderMenuItemContent = (item, reserveSpace) => {
|
|
3776
|
+
const isSelected = item.selected || selectedKeys.includes(item.key);
|
|
3777
|
+
const isSelectable = item.selectable !== false;
|
|
3778
|
+
const shouldShowActiveIcon = isSelectable && isSelected;
|
|
3779
|
+
const shouldReserveSpace = reserveSpace || isSelectable;
|
|
3780
|
+
const iconElement = item.icon ? /* @__PURE__ */ React3.createElement(IconContainer2, { $size: size }, typeof item.icon === "string" ? /* @__PURE__ */ React3.createElement(Icon, { src: item.icon }) : item.icon) : null;
|
|
3781
|
+
return /* @__PURE__ */ React3.createElement(MenuItemContent, { $size: size }, iconElement, /* @__PURE__ */ React3.createElement(ContentBlock2, null, /* @__PURE__ */ React3.createElement(LabelText2, { $size: size, $disabled: !!item.disabled }, item.label), item.description && /* @__PURE__ */ React3.createElement(DescriptionText, { $size: size, $disabled: !!item.disabled }, item.description)), /* @__PURE__ */ React3.createElement(
|
|
3782
|
+
ActiveIconContainer,
|
|
3783
|
+
{
|
|
3784
|
+
$size: size,
|
|
3785
|
+
$visible: shouldShowActiveIcon,
|
|
3786
|
+
$placeholder: shouldReserveSpace && !shouldShowActiveIcon
|
|
3787
|
+
},
|
|
3788
|
+
shouldShowActiveIcon && /* @__PURE__ */ React3.createElement(CheckmarkIcon, null)
|
|
3789
|
+
), item.children && item.children.length > 0 && /* @__PURE__ */ React3.createElement(NextLevelIconContainer, { $size: size }, /* @__PURE__ */ React3.createElement(ArrowIcon2, null)));
|
|
3790
|
+
};
|
|
3791
|
+
const renderItem = (item) => {
|
|
3792
|
+
if (item.type === "divider") {
|
|
3793
|
+
return /* @__PURE__ */ React3.createElement(Divider$1, { key: item.key });
|
|
3794
|
+
}
|
|
3795
|
+
if (item.type === "group") {
|
|
3796
|
+
return /* @__PURE__ */ React3.createElement(ItemGroup, { key: item.key, title: item.label }, item.children.map((child) => renderMenuItem(child)));
|
|
3797
|
+
}
|
|
3798
|
+
return renderMenuItem(item);
|
|
3799
|
+
};
|
|
3800
|
+
const renderMenuItem = (item) => {
|
|
3801
|
+
if (item.children && item.children.length > 0) {
|
|
3802
|
+
return /* @__PURE__ */ React3.createElement(
|
|
3803
|
+
SubMenu,
|
|
3804
|
+
{
|
|
3805
|
+
key: item.key,
|
|
3806
|
+
title: renderMenuItemContent(item, reserveActiveIconSpace),
|
|
3807
|
+
disabled: item.disabled,
|
|
3808
|
+
popupOffset: [5, 0]
|
|
3809
|
+
},
|
|
3810
|
+
item.children.map((child) => renderMenuItem(child))
|
|
3811
|
+
);
|
|
3812
|
+
}
|
|
3813
|
+
return /* @__PURE__ */ React3.createElement(
|
|
3814
|
+
MenuItem,
|
|
3815
|
+
{
|
|
3816
|
+
key: item.key,
|
|
3817
|
+
disabled: item.disabled,
|
|
3818
|
+
onClick: () => {
|
|
3819
|
+
item.onClick?.(item.key);
|
|
3820
|
+
onSelect?.(item.key);
|
|
3821
|
+
}
|
|
3822
|
+
},
|
|
3823
|
+
renderMenuItemContent(item, reserveActiveIconSpace)
|
|
3824
|
+
);
|
|
3825
|
+
};
|
|
3826
|
+
const itemHeight = size === "medium" ? 28 : 36;
|
|
3827
|
+
const menuKey = openKeys?.join(",") || "menu";
|
|
3828
|
+
return /* @__PURE__ */ React3.createElement(MenuContainer, { className, style }, searchable && /* @__PURE__ */ React3.createElement(SearchBoxContainer, null, /* @__PURE__ */ React3.createElement(
|
|
3829
|
+
Input,
|
|
3830
|
+
{
|
|
3831
|
+
lineType: "underlined",
|
|
3832
|
+
size: "small",
|
|
3833
|
+
placeholder: searchPlaceholder,
|
|
3834
|
+
value: searchValue,
|
|
3835
|
+
onChange: (e) => handleSearch(e.target.value),
|
|
3836
|
+
clearable: true,
|
|
3837
|
+
onClear: () => handleSearch(""),
|
|
3838
|
+
prefixNode: /* @__PURE__ */ React3.createElement(SearchIcon, null)
|
|
3839
|
+
}
|
|
3840
|
+
)), virtual && filteredItems.length > 10 ? /* @__PURE__ */ React3.createElement(
|
|
3841
|
+
VirtualList,
|
|
3842
|
+
{
|
|
3843
|
+
data: filteredItems,
|
|
3844
|
+
height: maxHeight,
|
|
3845
|
+
itemHeight,
|
|
3846
|
+
itemKey: "key",
|
|
3847
|
+
fullHeight: false,
|
|
3848
|
+
style: { width: "100%" }
|
|
3849
|
+
},
|
|
3850
|
+
(item) => /* @__PURE__ */ React3.createElement(
|
|
3851
|
+
RcMenu,
|
|
3852
|
+
{
|
|
3853
|
+
key: menuKey,
|
|
3854
|
+
prefixCls: "od-menu",
|
|
3855
|
+
mode: "vertical",
|
|
3856
|
+
selectedKeys,
|
|
3857
|
+
openKeys,
|
|
3858
|
+
onOpenChange,
|
|
3859
|
+
triggerSubMenuAction: "hover",
|
|
3860
|
+
expandIcon: null,
|
|
3861
|
+
style: {
|
|
3862
|
+
border: "none",
|
|
3863
|
+
background: "transparent",
|
|
3864
|
+
padding: 0
|
|
3865
|
+
}
|
|
3866
|
+
},
|
|
3867
|
+
renderItem(item)
|
|
3868
|
+
)
|
|
3869
|
+
) : /* @__PURE__ */ React3.createElement(
|
|
3870
|
+
RcMenu,
|
|
3871
|
+
{
|
|
3872
|
+
key: menuKey,
|
|
3873
|
+
prefixCls: "od-menu",
|
|
3874
|
+
mode: "vertical",
|
|
3875
|
+
selectedKeys,
|
|
3876
|
+
openKeys,
|
|
3877
|
+
onOpenChange,
|
|
3878
|
+
triggerSubMenuAction: "hover",
|
|
3879
|
+
expandIcon: null,
|
|
3880
|
+
style: {
|
|
3881
|
+
border: "none",
|
|
3882
|
+
background: "transparent"
|
|
3883
|
+
}
|
|
3884
|
+
},
|
|
3885
|
+
filteredItems.map(renderItem)
|
|
3886
|
+
));
|
|
3887
|
+
};
|
|
3888
|
+
Menu.displayName = "Menu";
|
|
3889
|
+
var Dropdown = ({
|
|
3890
|
+
overlay,
|
|
3891
|
+
trigger = ["click"],
|
|
3892
|
+
placement = "bottomLeft",
|
|
3893
|
+
visible: controlledVisible,
|
|
3894
|
+
defaultVisible = false,
|
|
3895
|
+
onVisibleChange,
|
|
3896
|
+
children,
|
|
3897
|
+
overlayClassName,
|
|
3898
|
+
getPopupContainer,
|
|
3899
|
+
...rest
|
|
3900
|
+
}) => {
|
|
3901
|
+
const [internalVisible, setInternalVisible] = useState(defaultVisible);
|
|
3902
|
+
const isControlled = controlledVisible !== void 0;
|
|
3903
|
+
const isVisible = isControlled ? controlledVisible : internalVisible;
|
|
3904
|
+
const handleVisibleChange = (visible) => {
|
|
3905
|
+
if (!isControlled) {
|
|
3906
|
+
setInternalVisible(visible);
|
|
3907
|
+
}
|
|
3908
|
+
onVisibleChange?.(visible);
|
|
3909
|
+
};
|
|
3910
|
+
return /* @__PURE__ */ React3.createElement(
|
|
3911
|
+
RcDropdown,
|
|
3912
|
+
{
|
|
3913
|
+
overlay: overlay || /* @__PURE__ */ React3.createElement("div", null),
|
|
3914
|
+
trigger,
|
|
3915
|
+
placement,
|
|
3916
|
+
visible: isVisible,
|
|
3917
|
+
onVisibleChange: handleVisibleChange,
|
|
3918
|
+
prefixCls: "od-dropdown",
|
|
3919
|
+
overlayClassName,
|
|
3920
|
+
getPopupContainer,
|
|
3921
|
+
...rest
|
|
3922
|
+
},
|
|
3923
|
+
children
|
|
3924
|
+
);
|
|
3925
|
+
};
|
|
3926
|
+
Dropdown.displayName = "Dropdown";
|
|
3927
|
+
|
|
3928
|
+
// src/dropdown/globalStyle.ts
|
|
3929
|
+
init_context();
|
|
3930
|
+
var theme2 = getGlobalTheme();
|
|
3931
|
+
var DropdownGlobalStyles = createGlobalStyle`
|
|
3932
|
+
/* Dropdown container */
|
|
3933
|
+
.od-dropdown {
|
|
3934
|
+
position: absolute;
|
|
3935
|
+
z-index: 1050;
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
.od-dropdown-hidden {
|
|
3939
|
+
display: none;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
/* Dropdown slide animations */
|
|
3943
|
+
.od-dropdown-slide-up-enter,
|
|
3944
|
+
.od-dropdown-slide-up-appear {
|
|
3945
|
+
animation-duration: 0.2s;
|
|
3946
|
+
animation-fill-mode: both;
|
|
3947
|
+
animation-play-state: paused;
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
.od-dropdown-slide-up-leave {
|
|
3951
|
+
animation-duration: 0.2s;
|
|
3952
|
+
animation-fill-mode: both;
|
|
3953
|
+
animation-play-state: paused;
|
|
3954
|
+
}
|
|
3955
|
+
|
|
3956
|
+
.od-dropdown-slide-up-enter.od-dropdown-slide-up-enter-active,
|
|
3957
|
+
.od-dropdown-slide-up-appear.od-dropdown-slide-up-appear-active {
|
|
3958
|
+
animation-name: rcDropdownSlideUpIn;
|
|
3959
|
+
animation-play-state: running;
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
.od-dropdown-slide-up-leave.od-dropdown-slide-up-leave-active {
|
|
3963
|
+
animation-name: rcDropdownSlideUpOut;
|
|
3964
|
+
animation-play-state: running;
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
@keyframes rcDropdownSlideUpIn {
|
|
3968
|
+
0% {
|
|
3969
|
+
opacity: 0;
|
|
3970
|
+
transform: scaleY(0.8);
|
|
3971
|
+
}
|
|
3972
|
+
100% {
|
|
3973
|
+
opacity: 1;
|
|
3974
|
+
transform: scaleY(1);
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
@keyframes rcDropdownSlideUpOut {
|
|
3979
|
+
0% {
|
|
3980
|
+
opacity: 1;
|
|
3981
|
+
transform: scaleY(1);
|
|
3982
|
+
}
|
|
3983
|
+
100% {
|
|
3984
|
+
opacity: 0;
|
|
3985
|
+
transform: scaleY(0.8);
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
`;
|
|
3989
|
+
var MenuGlobalStyles = createGlobalStyle`
|
|
3990
|
+
/* Base menu container */
|
|
3991
|
+
.od-menu {
|
|
3992
|
+
margin: 0;
|
|
3993
|
+
padding: ${() => theme2.components?.dropdown?.padding || "4px 0"};
|
|
3994
|
+
list-style: none;
|
|
3995
|
+
outline: none;
|
|
3996
|
+
box-shadow: none;
|
|
3997
|
+
background: transparent;
|
|
3998
|
+
border: none;
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
.od-menu-hidden {
|
|
4002
|
+
display: none;
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
/* Menu item */
|
|
4006
|
+
.od-menu-item {
|
|
4007
|
+
position: relative;
|
|
4008
|
+
display: flex;
|
|
4009
|
+
align-items: center;
|
|
4010
|
+
margin: 0;
|
|
4011
|
+
cursor: pointer;
|
|
4012
|
+
transition: background-color 0.15s ease;
|
|
4013
|
+
user-select: none;
|
|
4014
|
+
list-style: none;
|
|
4015
|
+
|
|
4016
|
+
${() => {
|
|
4017
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4018
|
+
return `
|
|
4019
|
+
padding: ${config?.layout?.padding || "6px 12px"};
|
|
4020
|
+
background: ${config?.background?.normal || "transparent"};
|
|
4021
|
+
`;
|
|
4022
|
+
}}
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
.od-menu-item:hover {
|
|
4026
|
+
${() => {
|
|
4027
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4028
|
+
return `
|
|
4029
|
+
background: ${config?.background?.hover || "rgba(65, 70, 75, 0.05)"};
|
|
4030
|
+
`;
|
|
4031
|
+
}}
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
.od-menu-item-active,
|
|
4035
|
+
.od-menu-item-selected {
|
|
4036
|
+
${() => {
|
|
4037
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4038
|
+
return `
|
|
4039
|
+
background: ${config?.background?.active || "rgba(65, 70, 75, 0.1)"};
|
|
4040
|
+
`;
|
|
4041
|
+
}}
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
.od-menu-item-disabled {
|
|
4045
|
+
cursor: not-allowed;
|
|
4046
|
+
${() => {
|
|
4047
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4048
|
+
return `
|
|
4049
|
+
background: ${config?.background?.disabled || "transparent"};
|
|
4050
|
+
`;
|
|
4051
|
+
}}
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
.od-menu-item-disabled:hover {
|
|
4055
|
+
${() => {
|
|
4056
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4057
|
+
return `
|
|
4058
|
+
background: ${config?.background?.disabled || "transparent"};
|
|
4059
|
+
`;
|
|
4060
|
+
}}
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4063
|
+
/* SubMenu */
|
|
4064
|
+
.od-menu-submenu {
|
|
4065
|
+
position: relative;
|
|
4066
|
+
list-style: none;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
.od-menu-submenu-title {
|
|
4070
|
+
position: relative;
|
|
4071
|
+
display: flex;
|
|
4072
|
+
align-items: center;
|
|
4073
|
+
margin: 0;
|
|
4074
|
+
cursor: pointer;
|
|
4075
|
+
transition: background-color 0.15s ease;
|
|
4076
|
+
user-select: none;
|
|
4077
|
+
|
|
4078
|
+
${() => {
|
|
4079
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4080
|
+
return `
|
|
4081
|
+
padding: ${config?.layout?.padding || "6px 12px"};
|
|
4082
|
+
background: ${config?.background?.normal || "transparent"};
|
|
4083
|
+
`;
|
|
4084
|
+
}}
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
.od-menu-submenu-title:hover {
|
|
4088
|
+
${() => {
|
|
4089
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4090
|
+
return `
|
|
4091
|
+
background: ${config?.background?.hover || "rgba(65, 70, 75, 0.05)"};
|
|
4092
|
+
`;
|
|
4093
|
+
}}
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
.od-menu-submenu-open > .od-menu-submenu-title {
|
|
4097
|
+
${() => {
|
|
4098
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4099
|
+
return `
|
|
4100
|
+
background: ${config?.background?.active || "rgba(65, 70, 75, 0.1)"};
|
|
4101
|
+
`;
|
|
4102
|
+
}}
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
.od-menu-submenu-disabled .od-menu-submenu-title {
|
|
4106
|
+
cursor: not-allowed;
|
|
4107
|
+
${() => {
|
|
4108
|
+
const config = theme2.components?.menu?.menuItem;
|
|
4109
|
+
return `
|
|
4110
|
+
background: ${config?.background?.disabled || "transparent"};
|
|
4111
|
+
`;
|
|
4112
|
+
}}
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
/* Submenu popup */
|
|
4116
|
+
.od-menu-submenu-popup {
|
|
4117
|
+
position: absolute;
|
|
4118
|
+
z-index: 1050;
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4121
|
+
/* Submenu popup positioning - add 5px gap */
|
|
4122
|
+
.od-menu-submenu-placement-rightTop,
|
|
4123
|
+
.od-menu-submenu-placement-rightBottom {
|
|
4124
|
+
padding-left: 5px;
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
.od-menu-submenu-placement-leftTop,
|
|
4128
|
+
.od-menu-submenu-placement-leftBottom {
|
|
4129
|
+
padding-right: 5px;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
.od-menu-submenu > .od-menu {
|
|
4133
|
+
${() => {
|
|
4134
|
+
const dropdownConfig = theme2.components?.dropdown;
|
|
4135
|
+
const menuConfig = theme2.components?.menu;
|
|
4136
|
+
return `
|
|
4137
|
+
background: ${dropdownConfig?.background || "#fff"};
|
|
4138
|
+
border: ${menuConfig?.border?.width || "1px"} solid ${menuConfig?.border?.color || "rgba(65, 70, 75, 0.1)"};
|
|
4139
|
+
border-radius: ${menuConfig?.border?.radius || "4px"};
|
|
4140
|
+
box-shadow: ${dropdownConfig?.boxShadow || "0 2px 8px rgba(0, 0, 0, 0.15)"};
|
|
4141
|
+
`;
|
|
4142
|
+
}}
|
|
4143
|
+
}
|
|
4144
|
+
|
|
4145
|
+
/* Item Group */
|
|
4146
|
+
.od-menu-item-group-title {
|
|
4147
|
+
padding: 8px 12px 4px;
|
|
4148
|
+
user-select: none;
|
|
4149
|
+
list-style: none;
|
|
4150
|
+
|
|
4151
|
+
${() => {
|
|
4152
|
+
const config = theme2.components?.menu?.groupTitle;
|
|
4153
|
+
return `
|
|
4154
|
+
font-size: ${config?.fontSize || "12px"};
|
|
4155
|
+
font-weight: ${config?.fontWeight || "500"};
|
|
4156
|
+
color: ${config?.color || "rgba(65, 70, 75, 0.6)"};
|
|
4157
|
+
line-height: 20px;
|
|
4158
|
+
`;
|
|
4159
|
+
}}
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
.od-menu-item-group-list {
|
|
4163
|
+
margin: 0;
|
|
4164
|
+
padding: 0;
|
|
4165
|
+
list-style: none;
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
/* Divider */
|
|
4169
|
+
.od-menu-item-divider {
|
|
4170
|
+
overflow: hidden;
|
|
4171
|
+
line-height: 0;
|
|
4172
|
+
list-style: none;
|
|
4173
|
+
|
|
4174
|
+
${() => {
|
|
4175
|
+
const config = theme2.components?.menu?.divider;
|
|
4176
|
+
return `
|
|
4177
|
+
height: ${config?.height || "1px"};
|
|
4178
|
+
background: ${config?.background || "rgba(65, 70, 75, 0.1)"};
|
|
4179
|
+
margin: ${config?.margin || "4px 0"};
|
|
4180
|
+
`;
|
|
4181
|
+
}}
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4184
|
+
/* Animation */
|
|
4185
|
+
.od-menu-submenu-inline {
|
|
4186
|
+
border: 0;
|
|
4187
|
+
box-shadow: none;
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
.od-menu-submenu-inline > .od-menu {
|
|
4191
|
+
padding: 0;
|
|
4192
|
+
border: 0;
|
|
4193
|
+
box-shadow: none;
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
/* Collapse animation */
|
|
4197
|
+
.od-menu-submenu-inline-collapsed {
|
|
4198
|
+
max-height: 0;
|
|
4199
|
+
overflow: hidden;
|
|
4200
|
+
transition: max-height 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
.od-menu-submenu-inline-collapsed-active {
|
|
4204
|
+
max-height: 1000px;
|
|
4205
|
+
}
|
|
4206
|
+
`;
|
|
4207
|
+
|
|
4208
|
+
// src/UIConfigProvider/UIConfigProvider.tsx
|
|
4209
|
+
init_IconProvider();
|
|
4210
|
+
init_context();
|
|
4211
|
+
var UIConfigContext = createContext(null);
|
|
4212
|
+
var UIConfigProvider = ({ config, children }) => {
|
|
4213
|
+
const { icons = {}, toast: toast2 = {} } = config;
|
|
4214
|
+
const renderFunction = (element, container) => {
|
|
4215
|
+
if ("createRoot" in ReactDOM) {
|
|
4216
|
+
const { createRoot } = ReactDOM;
|
|
4217
|
+
const root = createRoot(container);
|
|
4218
|
+
root.render(element);
|
|
4219
|
+
} else {
|
|
4220
|
+
ReactDOM.render(element, container);
|
|
4221
|
+
}
|
|
4222
|
+
};
|
|
4223
|
+
registerGlobalContext({
|
|
4224
|
+
theme: config.theme,
|
|
4225
|
+
render: renderFunction
|
|
4226
|
+
});
|
|
4227
|
+
const toastConfig = {
|
|
4228
|
+
maxCount: toast2.maxCount ?? 5,
|
|
4229
|
+
defaultDuration: toast2.defaultDuration ?? 3e3
|
|
4230
|
+
};
|
|
4231
|
+
const TooltipStyles = TooltipGlobalStyles;
|
|
4232
|
+
const MenuStyles = MenuGlobalStyles;
|
|
4233
|
+
const DropdownStyles = DropdownGlobalStyles;
|
|
4234
|
+
return /* @__PURE__ */ React3.createElement(UIConfigContext.Provider, { value: config }, /* @__PURE__ */ React3.createElement(TooltipStyles, null), /* @__PURE__ */ React3.createElement(MenuStyles, null), /* @__PURE__ */ React3.createElement(DropdownStyles, null), /* @__PURE__ */ React3.createElement(IconProvider, { icons }, /* @__PURE__ */ React3.createElement(
|
|
4235
|
+
ToastContainer2,
|
|
4236
|
+
{
|
|
4237
|
+
maxCount: toastConfig.maxCount,
|
|
4238
|
+
defaultDuration: toastConfig.defaultDuration
|
|
4239
|
+
},
|
|
4240
|
+
children
|
|
4241
|
+
)));
|
|
4242
|
+
};
|
|
4243
|
+
var useUIConfig = () => {
|
|
4244
|
+
const context = useContext(UIConfigContext);
|
|
4245
|
+
if (!context) {
|
|
4246
|
+
throw new Error("useUIConfig must be used within UIConfigProvider");
|
|
4247
|
+
}
|
|
4248
|
+
return context;
|
|
4249
|
+
};
|
|
4250
|
+
UIConfigProvider.displayName = "UIConfigProvider";
|
|
4251
|
+
|
|
4252
|
+
// src/UIConfigProvider/createUIConfig.ts
|
|
4253
|
+
var createUIConfig = (config) => {
|
|
4254
|
+
return {
|
|
4255
|
+
// Theme is required
|
|
2841
4256
|
theme: config.theme,
|
|
2842
4257
|
// Icons with default
|
|
2843
4258
|
icons: config.icons ?? {},
|
|
@@ -2901,6 +4316,10 @@ var mergeUIConfig = (baseConfig, ...configs) => {
|
|
|
2901
4316
|
return merged;
|
|
2902
4317
|
};
|
|
2903
4318
|
|
|
2904
|
-
|
|
4319
|
+
// src/index.ts
|
|
4320
|
+
init_styled();
|
|
4321
|
+
init_context();
|
|
4322
|
+
|
|
4323
|
+
export { Button, Checkbox, Dropdown, DropdownButton2 as DropdownButton, DropdownGlobalStyles, Icon, IconProvider, Input, Menu, MenuGlobalStyles, NumberInput, Radio, SearchInput, Slider, SpinButton, Switch, Tabs, Toast, ToastContainer2 as ToastContainer, ToolbarButton, Tooltip, UIConfigProvider, UnderlinedInput, createUIConfig, getGlobalTheme, mergeUIConfig, styled, toast, useIconRegistry, useToast, useUIConfig };
|
|
2905
4324
|
//# sourceMappingURL=index.js.map
|
|
2906
4325
|
//# sourceMappingURL=index.js.map
|