@easy-editor/setters 0.1.2 → 0.1.4

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/index.js DELETED
@@ -1,3350 +0,0 @@
1
- /* @easy-editor/setters v0.1.1 */
2
- (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('react/jsx-runtime')) :
4
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'react/jsx-runtime'], factory) :
5
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.EasyEditorSetters = {}, global.React, global.ReactDOM, global.jsxRuntime));
6
- })(this, (function (exports, React$1, reactDom, jsxRuntime) { 'use strict';
7
-
8
- /**
9
- * Popover - 共享弹窗组件
10
- * - 使用 Portal 渲染到 document.body,避免被父容器遮挡
11
- * - 自动匹配触发器宽度
12
- */
13
- const Popover = props => {
14
- const {
15
- open,
16
- onClose,
17
- trigger,
18
- children,
19
- width = 'trigger'
20
- } = props;
21
- const triggerRef = React$1.useRef(null);
22
- const [position, setPosition] = React$1.useState({
23
- top: 0,
24
- left: 0
25
- });
26
- const [popoverWidth, setPopoverWidth] = React$1.useState(0);
27
-
28
- // 计算弹窗位置
29
- React$1.useEffect(() => {
30
- if (open && triggerRef.current) {
31
- const triggerRect = triggerRef.current.getBoundingClientRect();
32
- const triggerWidth = triggerRect.width;
33
-
34
- // 设置弹窗宽度
35
- if (width === 'trigger') {
36
- setPopoverWidth(triggerWidth);
37
- }
38
- setPosition({
39
- top: triggerRect.bottom + 4,
40
- left: triggerRect.left
41
- });
42
- }
43
- }, [open, width]);
44
-
45
- // 点击外部关闭
46
- React$1.useEffect(() => {
47
- const handleClickOutside = event => {
48
- const target = event.target;
49
- const popoverEl = document.querySelector('.es-popover-portal');
50
- if (popoverEl && !popoverEl.contains(target) && triggerRef.current && !triggerRef.current.contains(target)) {
51
- onClose();
52
- }
53
- };
54
- if (open) {
55
- document.addEventListener('mousedown', handleClickOutside);
56
- return () => document.removeEventListener('mousedown', handleClickOutside);
57
- }
58
- }, [open, onClose]);
59
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
60
- ref: triggerRef
61
- }, trigger), open ? /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement("div", {
62
- className: "es-popover-portal",
63
- style: {
64
- position: 'fixed',
65
- top: position.top,
66
- left: position.left,
67
- width: popoverWidth || 'auto',
68
- zIndex: 1000
69
- }
70
- }, children), document.body) : '');
71
- };
72
-
73
- function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
74
-
75
- function cn(...inputs) {
76
- return clsx(inputs);
77
- }
78
-
79
- /**
80
- * @license lucide-react v0.561.0 - ISC
81
- *
82
- * This source code is licensed under the ISC license.
83
- * See the LICENSE file in the root directory of this source tree.
84
- */
85
- const toKebabCase = string => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
86
- const toCamelCase = string => string.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase());
87
- const toPascalCase = string => {
88
- const camelCase = toCamelCase(string);
89
- return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
90
- };
91
- const mergeClasses = (...classes) => classes.filter((className, index, array) => {
92
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
93
- }).join(" ").trim();
94
- const hasA11yProp = props => {
95
- for (const prop in props) {
96
- if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
97
- return true;
98
- }
99
- }
100
- };
101
-
102
- /**
103
- * @license lucide-react v0.561.0 - ISC
104
- *
105
- * This source code is licensed under the ISC license.
106
- * See the LICENSE file in the root directory of this source tree.
107
- */
108
- var defaultAttributes = {
109
- xmlns: "http://www.w3.org/2000/svg",
110
- width: 24,
111
- height: 24,
112
- viewBox: "0 0 24 24",
113
- fill: "none",
114
- stroke: "currentColor",
115
- strokeWidth: 2,
116
- strokeLinecap: "round",
117
- strokeLinejoin: "round"
118
- };
119
-
120
- /**
121
- * @license lucide-react v0.561.0 - ISC
122
- *
123
- * This source code is licensed under the ISC license.
124
- * See the LICENSE file in the root directory of this source tree.
125
- */
126
- const Icon = /*#__PURE__*/React$1.forwardRef(({
127
- color = "currentColor",
128
- size = 24,
129
- strokeWidth = 2,
130
- absoluteStrokeWidth,
131
- className = "",
132
- children,
133
- iconNode,
134
- ...rest
135
- }, ref) => /*#__PURE__*/React$1.createElement("svg", {
136
- ref,
137
- ...defaultAttributes,
138
- width: size,
139
- height: size,
140
- stroke: color,
141
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
142
- className: mergeClasses("lucide", className),
143
- ...(!children && !hasA11yProp(rest) && {
144
- "aria-hidden": "true"
145
- }),
146
- ...rest
147
- }, [...iconNode.map(([tag, attrs]) => /*#__PURE__*/React$1.createElement(tag, attrs)), ...(Array.isArray(children) ? children : [children])]));
148
-
149
- /**
150
- * @license lucide-react v0.561.0 - ISC
151
- *
152
- * This source code is licensed under the ISC license.
153
- * See the LICENSE file in the root directory of this source tree.
154
- */
155
- const createLucideIcon = (iconName, iconNode) => {
156
- const Component = /*#__PURE__*/React$1.forwardRef(({
157
- className,
158
- ...props
159
- }, ref) => /*#__PURE__*/React$1.createElement(Icon, {
160
- ref,
161
- iconNode,
162
- className: mergeClasses(`lucide-${toKebabCase(toPascalCase(iconName))}`, `lucide-${iconName}`, className),
163
- ...props
164
- }));
165
- Component.displayName = toPascalCase(iconName);
166
- return Component;
167
- };
168
-
169
- /**
170
- * @license lucide-react v0.561.0 - ISC
171
- *
172
- * This source code is licensed under the ISC license.
173
- * See the LICENSE file in the root directory of this source tree.
174
- */
175
- const __iconNode$m = [["rect", {
176
- width: "6",
177
- height: "16",
178
- x: "4",
179
- y: "2",
180
- rx: "2",
181
- key: "z5wdxg"
182
- }], ["rect", {
183
- width: "6",
184
- height: "9",
185
- x: "14",
186
- y: "9",
187
- rx: "2",
188
- key: "um7a8w"
189
- }], ["path", {
190
- d: "M22 22H2",
191
- key: "19qnx5"
192
- }]];
193
- const AlignEndHorizontal = createLucideIcon("align-end-horizontal", __iconNode$m);
194
-
195
- /**
196
- * @license lucide-react v0.561.0 - ISC
197
- *
198
- * This source code is licensed under the ISC license.
199
- * See the LICENSE file in the root directory of this source tree.
200
- */
201
- const __iconNode$l = [["rect", {
202
- width: "16",
203
- height: "6",
204
- x: "2",
205
- y: "4",
206
- rx: "2",
207
- key: "10wcwx"
208
- }], ["rect", {
209
- width: "9",
210
- height: "6",
211
- x: "9",
212
- y: "14",
213
- rx: "2",
214
- key: "4p5bwg"
215
- }], ["path", {
216
- d: "M22 22V2",
217
- key: "12ipfv"
218
- }]];
219
- const AlignEndVertical = createLucideIcon("align-end-vertical", __iconNode$l);
220
-
221
- /**
222
- * @license lucide-react v0.561.0 - ISC
223
- *
224
- * This source code is licensed under the ISC license.
225
- * See the LICENSE file in the root directory of this source tree.
226
- */
227
- const __iconNode$k = [["rect", {
228
- width: "6",
229
- height: "14",
230
- x: "4",
231
- y: "5",
232
- rx: "2",
233
- key: "1wwnby"
234
- }], ["rect", {
235
- width: "6",
236
- height: "10",
237
- x: "14",
238
- y: "7",
239
- rx: "2",
240
- key: "1fe6j6"
241
- }], ["path", {
242
- d: "M17 22v-5",
243
- key: "4b6g73"
244
- }], ["path", {
245
- d: "M17 7V2",
246
- key: "hnrr36"
247
- }], ["path", {
248
- d: "M7 22v-3",
249
- key: "1r4jpn"
250
- }], ["path", {
251
- d: "M7 5V2",
252
- key: "liy1u9"
253
- }]];
254
- const AlignHorizontalDistributeCenter = createLucideIcon("align-horizontal-distribute-center", __iconNode$k);
255
-
256
- /**
257
- * @license lucide-react v0.561.0 - ISC
258
- *
259
- * This source code is licensed under the ISC license.
260
- * See the LICENSE file in the root directory of this source tree.
261
- */
262
- const __iconNode$j = [["rect", {
263
- width: "6",
264
- height: "16",
265
- x: "4",
266
- y: "6",
267
- rx: "2",
268
- key: "1n4dg1"
269
- }], ["rect", {
270
- width: "6",
271
- height: "9",
272
- x: "14",
273
- y: "6",
274
- rx: "2",
275
- key: "17khns"
276
- }], ["path", {
277
- d: "M22 2H2",
278
- key: "fhrpnj"
279
- }]];
280
- const AlignStartHorizontal = createLucideIcon("align-start-horizontal", __iconNode$j);
281
-
282
- /**
283
- * @license lucide-react v0.561.0 - ISC
284
- *
285
- * This source code is licensed under the ISC license.
286
- * See the LICENSE file in the root directory of this source tree.
287
- */
288
- const __iconNode$i = [["rect", {
289
- width: "9",
290
- height: "6",
291
- x: "6",
292
- y: "14",
293
- rx: "2",
294
- key: "lpm2y7"
295
- }], ["rect", {
296
- width: "16",
297
- height: "6",
298
- x: "6",
299
- y: "4",
300
- rx: "2",
301
- key: "rdj6ps"
302
- }], ["path", {
303
- d: "M2 2v20",
304
- key: "1ivd8o"
305
- }]];
306
- const AlignStartVertical = createLucideIcon("align-start-vertical", __iconNode$i);
307
-
308
- /**
309
- * @license lucide-react v0.561.0 - ISC
310
- *
311
- * This source code is licensed under the ISC license.
312
- * See the LICENSE file in the root directory of this source tree.
313
- */
314
- const __iconNode$h = [["path", {
315
- d: "M22 17h-3",
316
- key: "1lwga1"
317
- }], ["path", {
318
- d: "M22 7h-5",
319
- key: "o2endc"
320
- }], ["path", {
321
- d: "M5 17H2",
322
- key: "1gx9xc"
323
- }], ["path", {
324
- d: "M7 7H2",
325
- key: "6bq26l"
326
- }], ["rect", {
327
- x: "5",
328
- y: "14",
329
- width: "14",
330
- height: "6",
331
- rx: "2",
332
- key: "1qrzuf"
333
- }], ["rect", {
334
- x: "7",
335
- y: "4",
336
- width: "10",
337
- height: "6",
338
- rx: "2",
339
- key: "we8e9z"
340
- }]];
341
- const AlignVerticalDistributeCenter = createLucideIcon("align-vertical-distribute-center", __iconNode$h);
342
-
343
- /**
344
- * @license lucide-react v0.561.0 - ISC
345
- *
346
- * This source code is licensed under the ISC license.
347
- * See the LICENSE file in the root directory of this source tree.
348
- */
349
- const __iconNode$g = [["path", {
350
- d: "M5 12h14",
351
- key: "1ays0h"
352
- }], ["path", {
353
- d: "m12 5 7 7-7 7",
354
- key: "xquz4c"
355
- }]];
356
- const ArrowRight = createLucideIcon("arrow-right", __iconNode$g);
357
-
358
- /**
359
- * @license lucide-react v0.561.0 - ISC
360
- *
361
- * This source code is licensed under the ISC license.
362
- * See the LICENSE file in the root directory of this source tree.
363
- */
364
- const __iconNode$f = [["path", {
365
- d: "M20 6 9 17l-5-5",
366
- key: "1gmf2c"
367
- }]];
368
- const Check = createLucideIcon("check", __iconNode$f);
369
-
370
- /**
371
- * @license lucide-react v0.561.0 - ISC
372
- *
373
- * This source code is licensed under the ISC license.
374
- * See the LICENSE file in the root directory of this source tree.
375
- */
376
- const __iconNode$e = [["path", {
377
- d: "m6 9 6 6 6-6",
378
- key: "qrunsl"
379
- }]];
380
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$e);
381
-
382
- /**
383
- * @license lucide-react v0.561.0 - ISC
384
- *
385
- * This source code is licensed under the ISC license.
386
- * See the LICENSE file in the root directory of this source tree.
387
- */
388
- const __iconNode$d = [["path", {
389
- d: "m7 15 5 5 5-5",
390
- key: "1hf1tw"
391
- }], ["path", {
392
- d: "m7 9 5-5 5 5",
393
- key: "sgt6xg"
394
- }]];
395
- const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$d);
396
-
397
- /**
398
- * @license lucide-react v0.561.0 - ISC
399
- *
400
- * This source code is licensed under the ISC license.
401
- * See the LICENSE file in the root directory of this source tree.
402
- */
403
- const __iconNode$c = [["path", {
404
- d: "m16 18 6-6-6-6",
405
- key: "eg8j8"
406
- }], ["path", {
407
- d: "m8 6-6 6 6 6",
408
- key: "ppft3o"
409
- }]];
410
- const Code = createLucideIcon("code", __iconNode$c);
411
-
412
- /**
413
- * @license lucide-react v0.561.0 - ISC
414
- *
415
- * This source code is licensed under the ISC license.
416
- * See the LICENSE file in the root directory of this source tree.
417
- */
418
- const __iconNode$b = [["ellipse", {
419
- cx: "12",
420
- cy: "5",
421
- rx: "9",
422
- ry: "3",
423
- key: "msslwz"
424
- }], ["path", {
425
- d: "M3 5V19A9 3 0 0 0 21 19V5",
426
- key: "1wlel7"
427
- }], ["path", {
428
- d: "M3 12A9 3 0 0 0 21 12",
429
- key: "mv7ke4"
430
- }]];
431
- const Database = createLucideIcon("database", __iconNode$b);
432
-
433
- /**
434
- * @license lucide-react v0.561.0 - ISC
435
- *
436
- * This source code is licensed under the ISC license.
437
- * See the LICENSE file in the root directory of this source tree.
438
- */
439
- const __iconNode$a = [["path", {
440
- d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
441
- key: "1oefj6"
442
- }], ["path", {
443
- d: "M14 2v5a1 1 0 0 0 1 1h5",
444
- key: "wfsgrz"
445
- }], ["path", {
446
- d: "M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",
447
- key: "1oajmo"
448
- }], ["path", {
449
- d: "M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",
450
- key: "mpwhp6"
451
- }]];
452
- const FileBraces = createLucideIcon("file-braces", __iconNode$a);
453
-
454
- /**
455
- * @license lucide-react v0.561.0 - ISC
456
- *
457
- * This source code is licensed under the ISC license.
458
- * See the LICENSE file in the root directory of this source tree.
459
- */
460
- const __iconNode$9 = [["circle", {
461
- cx: "9",
462
- cy: "12",
463
- r: "1",
464
- key: "1vctgf"
465
- }], ["circle", {
466
- cx: "9",
467
- cy: "5",
468
- r: "1",
469
- key: "hp0tcf"
470
- }], ["circle", {
471
- cx: "9",
472
- cy: "19",
473
- r: "1",
474
- key: "fkjjf6"
475
- }], ["circle", {
476
- cx: "15",
477
- cy: "12",
478
- r: "1",
479
- key: "1tmaij"
480
- }], ["circle", {
481
- cx: "15",
482
- cy: "5",
483
- r: "1",
484
- key: "19l28e"
485
- }], ["circle", {
486
- cx: "15",
487
- cy: "19",
488
- r: "1",
489
- key: "f4zoj3"
490
- }]];
491
- const GripVertical = createLucideIcon("grip-vertical", __iconNode$9);
492
-
493
- /**
494
- * @license lucide-react v0.561.0 - ISC
495
- *
496
- * This source code is licensed under the ISC license.
497
- * See the LICENSE file in the root directory of this source tree.
498
- */
499
- const __iconNode$8 = [["path", {
500
- d: "M9 17H7A5 5 0 0 1 7 7h2",
501
- key: "8i5ue5"
502
- }], ["path", {
503
- d: "M15 7h2a5 5 0 1 1 0 10h-2",
504
- key: "1b9ql8"
505
- }], ["line", {
506
- x1: "8",
507
- x2: "16",
508
- y1: "12",
509
- y2: "12",
510
- key: "1jonct"
511
- }]];
512
- const Link2 = createLucideIcon("link-2", __iconNode$8);
513
-
514
- /**
515
- * @license lucide-react v0.561.0 - ISC
516
- *
517
- * This source code is licensed under the ISC license.
518
- * See the LICENSE file in the root directory of this source tree.
519
- */
520
- const __iconNode$7 = [["path", {
521
- d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",
522
- key: "1cjeqo"
523
- }], ["path", {
524
- d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",
525
- key: "19qd67"
526
- }]];
527
- const Link = createLucideIcon("link", __iconNode$7);
528
-
529
- /**
530
- * @license lucide-react v0.561.0 - ISC
531
- *
532
- * This source code is licensed under the ISC license.
533
- * See the LICENSE file in the root directory of this source tree.
534
- */
535
- const __iconNode$6 = [["path", {
536
- d: "M15 3h6v6",
537
- key: "1q9fwt"
538
- }], ["path", {
539
- d: "m21 3-7 7",
540
- key: "1l2asr"
541
- }], ["path", {
542
- d: "m3 21 7-7",
543
- key: "tjx5ai"
544
- }], ["path", {
545
- d: "M9 21H3v-6",
546
- key: "wtvkvv"
547
- }]];
548
- const Maximize2 = createLucideIcon("maximize-2", __iconNode$6);
549
-
550
- /**
551
- * @license lucide-react v0.561.0 - ISC
552
- *
553
- * This source code is licensed under the ISC license.
554
- * See the LICENSE file in the root directory of this source tree.
555
- */
556
- const __iconNode$5 = [["path", {
557
- d: "M5 12h14",
558
- key: "1ays0h"
559
- }], ["path", {
560
- d: "M12 5v14",
561
- key: "s699le"
562
- }]];
563
- const Plus = createLucideIcon("plus", __iconNode$5);
564
-
565
- /**
566
- * @license lucide-react v0.561.0 - ISC
567
- *
568
- * This source code is licensed under the ISC license.
569
- * See the LICENSE file in the root directory of this source tree.
570
- */
571
- const __iconNode$4 = [["path", {
572
- d: "M14 17H5",
573
- key: "gfn3mx"
574
- }], ["path", {
575
- d: "M19 7h-9",
576
- key: "6i9tg"
577
- }], ["circle", {
578
- cx: "17",
579
- cy: "17",
580
- r: "3",
581
- key: "18b49y"
582
- }], ["circle", {
583
- cx: "7",
584
- cy: "7",
585
- r: "3",
586
- key: "dfmy0x"
587
- }]];
588
- const Settings2 = createLucideIcon("settings-2", __iconNode$4);
589
-
590
- /**
591
- * @license lucide-react v0.561.0 - ISC
592
- *
593
- * This source code is licensed under the ISC license.
594
- * See the LICENSE file in the root directory of this source tree.
595
- */
596
- const __iconNode$3 = [["path", {
597
- d: "M10 11v6",
598
- key: "nco0om"
599
- }], ["path", {
600
- d: "M14 11v6",
601
- key: "outv1u"
602
- }], ["path", {
603
- d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",
604
- key: "miytrc"
605
- }], ["path", {
606
- d: "M3 6h18",
607
- key: "d0wm0j"
608
- }], ["path", {
609
- d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",
610
- key: "e791ji"
611
- }]];
612
- const Trash2 = createLucideIcon("trash-2", __iconNode$3);
613
-
614
- /**
615
- * @license lucide-react v0.561.0 - ISC
616
- *
617
- * This source code is licensed under the ISC license.
618
- * See the LICENSE file in the root directory of this source tree.
619
- */
620
- const __iconNode$2 = [["path", {
621
- d: "m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",
622
- key: "yqzxt4"
623
- }], ["path", {
624
- d: "m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",
625
- key: "4qinb0"
626
- }], ["line", {
627
- x1: "8",
628
- x2: "8",
629
- y1: "2",
630
- y2: "5",
631
- key: "1041cp"
632
- }], ["line", {
633
- x1: "2",
634
- x2: "5",
635
- y1: "8",
636
- y2: "8",
637
- key: "14m1p5"
638
- }], ["line", {
639
- x1: "16",
640
- x2: "16",
641
- y1: "19",
642
- y2: "22",
643
- key: "rzdirn"
644
- }], ["line", {
645
- x1: "19",
646
- x2: "22",
647
- y1: "16",
648
- y2: "16",
649
- key: "ox905f"
650
- }]];
651
- const Unlink = createLucideIcon("unlink", __iconNode$2);
652
-
653
- /**
654
- * @license lucide-react v0.561.0 - ISC
655
- *
656
- * This source code is licensed under the ISC license.
657
- * See the LICENSE file in the root directory of this source tree.
658
- */
659
- const __iconNode$1 = [["path", {
660
- d: "M12 3v12",
661
- key: "1x0j5s"
662
- }], ["path", {
663
- d: "m17 8-5-5-5 5",
664
- key: "7q97r8"
665
- }], ["path", {
666
- d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
667
- key: "ih7n3h"
668
- }]];
669
- const Upload = createLucideIcon("upload", __iconNode$1);
670
-
671
- /**
672
- * @license lucide-react v0.561.0 - ISC
673
- *
674
- * This source code is licensed under the ISC license.
675
- * See the LICENSE file in the root directory of this source tree.
676
- */
677
- const __iconNode = [["path", {
678
- d: "M18 6 6 18",
679
- key: "1bl5f8"
680
- }], ["path", {
681
- d: "m6 6 12 12",
682
- key: "d8bk6v"
683
- }]];
684
- const X = createLucideIcon("x", __iconNode);
685
-
686
- var styles$j = {"container":"es-container-K2hFq","visualWrapper":"es-visualWrapper-4dHVX","previewBox":"es-previewBox-LDujZ","previewElement":"es-previewElement-Bu8GM","grid":"es-grid-BmRRU","gridButton":"es-gridButton-6Vtr7","gridButtonSelected":"es-gridButtonSelected-fOpOm","section":"es-section-SaHDo","sectionLabel":"es-sectionLabel-hDWO0","buttonGroup":"es-buttonGroup-Nj258","alignButton":"es-alignButton-zAvz2","alignButtonSelected":"es-alignButtonSelected-kGGHJ","alignIcon":"es-alignIcon-mFjSX","alignIconRotated":"es-alignIconRotated-z4AwW"};
687
-
688
- const defaultValue$3 = {
689
- horizontal: 'left',
690
- vertical: 'top'
691
- };
692
- const horizontalOptions = [{
693
- value: 'left',
694
- icon: AlignStartVertical,
695
- label: '左对齐'
696
- }, {
697
- value: 'center',
698
- icon: AlignVerticalDistributeCenter,
699
- label: '水平居中'
700
- }, {
701
- value: 'right',
702
- icon: AlignEndVertical,
703
- label: '右对齐'
704
- }, {
705
- value: 'stretch',
706
- icon: Maximize2,
707
- label: '水平拉伸'
708
- }];
709
- const verticalOptions = [{
710
- value: 'top',
711
- icon: AlignStartHorizontal,
712
- label: '顶部对齐'
713
- }, {
714
- value: 'center',
715
- icon: AlignHorizontalDistributeCenter,
716
- label: '垂直居中'
717
- }, {
718
- value: 'bottom',
719
- icon: AlignEndHorizontal,
720
- label: '底部对齐'
721
- }, {
722
- value: 'stretch',
723
- icon: Maximize2,
724
- label: '垂直拉伸'
725
- }];
726
-
727
- // 9宫格位置映射
728
- const gridPositions = [{
729
- h: 'left',
730
- v: 'top'
731
- }, {
732
- h: 'center',
733
- v: 'top'
734
- }, {
735
- h: 'right',
736
- v: 'top'
737
- }, {
738
- h: 'left',
739
- v: 'center'
740
- }, {
741
- h: 'center',
742
- v: 'center'
743
- }, {
744
- h: 'right',
745
- v: 'center'
746
- }, {
747
- h: 'left',
748
- v: 'bottom'
749
- }, {
750
- h: 'center',
751
- v: 'bottom'
752
- }, {
753
- h: 'right',
754
- v: 'bottom'
755
- }];
756
-
757
- // 获取元素在容器中的位置样式
758
- const getElementPosition = (h, v) => {
759
- const style = {
760
- position: 'absolute'
761
- };
762
-
763
- // 水平位置
764
- if (h === 'left') {
765
- style.left = '4px';
766
- style.width = '30%';
767
- } else if (h === 'center') {
768
- style.left = '50%';
769
- style.transform = 'translateX(-50%)';
770
- style.width = '30%';
771
- } else if (h === 'right') {
772
- style.right = '4px';
773
- style.width = '30%';
774
- } else {
775
- style.left = '4px';
776
- style.right = '4px';
777
- style.width = 'auto';
778
- }
779
-
780
- // 垂直位置
781
- if (v === 'top') {
782
- style.top = '4px';
783
- style.height = '30%';
784
- } else if (v === 'center') {
785
- style.top = '50%';
786
- style.transform = h === 'center' ? 'translate(-50%, -50%)' : 'translateY(-50%)';
787
- style.height = '30%';
788
- } else if (v === 'bottom') {
789
- style.bottom = '4px';
790
- style.height = '30%';
791
- } else {
792
- style.top = '4px';
793
- style.bottom = '4px';
794
- style.height = 'auto';
795
- }
796
- return style;
797
- };
798
- const AlignSetter = props => {
799
- const {
800
- value,
801
- initialValue,
802
- onChange,
803
- showHorizontal = true,
804
- showVertical = true
805
- } = props;
806
- const currentValue = value ?? initialValue ?? defaultValue$3;
807
- const updateAlign = React$1.useCallback(updates => {
808
- onChange({
809
- ...currentValue,
810
- ...updates
811
- });
812
- }, [currentValue, onChange]);
813
- const handleGridClick = React$1.useCallback((h, v) => {
814
- onChange({
815
- horizontal: h,
816
- vertical: v
817
- });
818
- }, [onChange]);
819
- const isGridSelected = (h, v) => currentValue.horizontal === h && currentValue.vertical === v;
820
- return /*#__PURE__*/React.createElement("div", {
821
- className: styles$j.container
822
- }, showHorizontal === true && showVertical === true ? /*#__PURE__*/React.createElement("div", {
823
- className: styles$j.visualWrapper
824
- }, /*#__PURE__*/React.createElement("div", {
825
- className: styles$j.previewBox
826
- }, /*#__PURE__*/React.createElement("div", {
827
- className: styles$j.previewElement,
828
- style: getElementPosition(currentValue.horizontal, currentValue.vertical)
829
- })), /*#__PURE__*/React.createElement("div", {
830
- className: styles$j.grid
831
- }, gridPositions.map(pos => /*#__PURE__*/React.createElement("button", {
832
- "aria-label": `Align ${pos.h} ${pos.v}`,
833
- className: cn(styles$j.gridButton, isGridSelected(pos.h, pos.v) ? styles$j.gridButtonSelected : ''),
834
- key: `${pos.h}-${pos.v}`,
835
- onClick: () => handleGridClick(pos.h, pos.v),
836
- type: "button"
837
- })))) : null, showHorizontal === true ? /*#__PURE__*/React.createElement("div", {
838
- className: styles$j.section
839
- }, /*#__PURE__*/React.createElement("span", {
840
- className: styles$j.sectionLabel
841
- }, "\u6C34\u5E73\u5BF9\u9F50"), /*#__PURE__*/React.createElement("div", {
842
- className: styles$j.buttonGroup
843
- }, horizontalOptions.map(option => {
844
- const Icon = option.icon;
845
- const isRotated = option.value === 'stretch';
846
- return /*#__PURE__*/React.createElement("button", {
847
- "aria-label": option.label,
848
- className: cn(styles$j.alignButton, currentValue.horizontal === option.value ? styles$j.alignButtonSelected : ''),
849
- key: option.value,
850
- onClick: () => updateAlign({
851
- horizontal: option.value
852
- }),
853
- title: option.label,
854
- type: "button"
855
- }, /*#__PURE__*/React.createElement(Icon, {
856
- className: cn(styles$j.alignIcon, isRotated ? styles$j.alignIconRotated : '')
857
- }));
858
- }))) : null, showVertical === true ? /*#__PURE__*/React.createElement("div", {
859
- className: styles$j.section
860
- }, /*#__PURE__*/React.createElement("span", {
861
- className: styles$j.sectionLabel
862
- }, "\u5782\u76F4\u5BF9\u9F50"), /*#__PURE__*/React.createElement("div", {
863
- className: styles$j.buttonGroup
864
- }, verticalOptions.map(option => {
865
- const Icon = option.icon;
866
- return /*#__PURE__*/React.createElement("button", {
867
- "aria-label": option.label,
868
- className: cn(styles$j.alignButton, currentValue.vertical === option.value ? styles$j.alignButtonSelected : ''),
869
- key: option.value,
870
- onClick: () => updateAlign({
871
- vertical: option.value
872
- }),
873
- title: option.label,
874
- type: "button"
875
- }, /*#__PURE__*/React.createElement(Icon, {
876
- className: styles$j.alignIcon
877
- }));
878
- }))) : null);
879
- };
880
-
881
- var styles$i = {"container":"es-container-KSlB-","item":"es-item-xDCpZ","dragHandle":"es-dragHandle-lOaFv","input":"es-input-ItzPT","removeButton":"es-removeButton-ymAlo","removeIcon":"es-removeIcon-ld51f","addButton":"es-addButton-U1VQX","addIcon":"es-addIcon-6qJub"};
882
-
883
- const ArraySetter = props => {
884
- const {
885
- value,
886
- initialValue,
887
- itemSetter = 'string',
888
- maxItems,
889
- minItems = 0,
890
- placeholder,
891
- addButtonText = '添加项',
892
- onChange
893
- } = props;
894
- const items = value ?? initialValue ?? [];
895
- const handleAdd = React$1.useCallback(() => {
896
- if (maxItems && items.length >= maxItems) {
897
- return;
898
- }
899
- const newItem = itemSetter === 'number' ? 0 : '';
900
- onChange([...items, newItem]);
901
- }, [items, maxItems, itemSetter, onChange]);
902
- const handleRemove = React$1.useCallback(index => {
903
- if (items.length <= minItems) {
904
- return;
905
- }
906
- const newItems = items.filter((_, i) => i !== index);
907
- onChange(newItems);
908
- }, [items, minItems, onChange]);
909
- const handleChange = React$1.useCallback((index, newValue) => {
910
- const newItems = [...items];
911
- newItems[index] = newValue;
912
- onChange(newItems);
913
- }, [items, onChange]);
914
- const canAdd = !maxItems || items.length < maxItems;
915
- const canRemove = items.length > minItems;
916
- return /*#__PURE__*/React.createElement("div", {
917
- className: styles$i.container
918
- }, items.map((item, index) => /*#__PURE__*/React.createElement("div", {
919
- className: styles$i.item,
920
- key: `item-${String(item)}-${index}`
921
- }, /*#__PURE__*/React.createElement(GripVertical, {
922
- className: styles$i.dragHandle
923
- }), /*#__PURE__*/React.createElement("input", {
924
- className: styles$i.input,
925
- onChange: e => {
926
- const val = itemSetter === 'number' ? +e.target.value : e.target.value;
927
- handleChange(index, val);
928
- },
929
- placeholder: placeholder,
930
- type: itemSetter === 'number' ? 'number' : 'text',
931
- value: item
932
- }), /*#__PURE__*/React.createElement("button", {
933
- className: styles$i.removeButton,
934
- disabled: !canRemove,
935
- onClick: () => handleRemove(index),
936
- type: "button"
937
- }, /*#__PURE__*/React.createElement(Trash2, {
938
- className: styles$i.removeIcon
939
- })))), /*#__PURE__*/React.createElement("button", {
940
- className: styles$i.addButton,
941
- disabled: !canAdd,
942
- onClick: handleAdd,
943
- type: "button"
944
- }, /*#__PURE__*/React.createElement(Plus, {
945
- className: styles$i.addIcon
946
- }), addButtonText));
947
- };
948
-
949
- function _extends() {
950
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
951
- for (var e = 1; e < arguments.length; e++) {
952
- var t = arguments[e];
953
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
954
- }
955
- return n;
956
- }, _extends.apply(null, arguments);
957
- }
958
-
959
- function _objectWithoutPropertiesLoose(r, e) {
960
- if (null == r) return {};
961
- var t = {};
962
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
963
- if (-1 !== e.indexOf(n)) continue;
964
- t[n] = r[n];
965
- }
966
- return t;
967
- }
968
-
969
- var RGB_MAX = 255;
970
- var SV_MAX = 100;
971
- var rgbaToHsva = _ref => {
972
- var {
973
- r,
974
- g,
975
- b,
976
- a
977
- } = _ref;
978
- var max = Math.max(r, g, b);
979
- var delta = max - Math.min(r, g, b);
980
- var hh = delta ? max === r ? (g - b) / delta : max === g ? 2 + (b - r) / delta : 4 + (r - g) / delta : 0;
981
- return {
982
- h: 60 * (hh < 0 ? hh + 6 : hh),
983
- s: max ? delta / max * SV_MAX : 0,
984
- v: max / RGB_MAX * SV_MAX,
985
- a
986
- };
987
- };
988
- var hsvaToHslaString = hsva => {
989
- var {
990
- h,
991
- s,
992
- l,
993
- a
994
- } = hsvaToHsla(hsva);
995
- return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")";
996
- };
997
- var hsvaToHsla = _ref5 => {
998
- var {
999
- h,
1000
- s,
1001
- v,
1002
- a
1003
- } = _ref5;
1004
- var hh = (200 - s) * v / SV_MAX;
1005
- return {
1006
- h,
1007
- s: hh > 0 && hh < 200 ? s * v / SV_MAX / (hh <= SV_MAX ? hh : 200 - hh) * SV_MAX : 0,
1008
- l: hh / 2,
1009
- a
1010
- };
1011
- };
1012
- var rgbToHex = _ref7 => {
1013
- var {
1014
- r,
1015
- g,
1016
- b
1017
- } = _ref7;
1018
- var bin = r << 16 | g << 8 | b;
1019
- return "#" + (h => new Array(7 - h.length).join('0') + h)(bin.toString(16));
1020
- };
1021
- var rgbaToHexa = _ref8 => {
1022
- var {
1023
- r,
1024
- g,
1025
- b,
1026
- a
1027
- } = _ref8;
1028
- var alpha = typeof a === 'number' && (a * 255 | 1 << 8).toString(16).slice(1);
1029
- return "" + rgbToHex({
1030
- r,
1031
- g,
1032
- b
1033
- }) + (alpha ? alpha : '');
1034
- };
1035
- var hexToHsva = hex => rgbaToHsva(hexToRgba(hex));
1036
- var hexToRgba = hex => {
1037
- var htemp = hex.replace('#', '');
1038
- if (/^#?/.test(hex) && htemp.length === 3) {
1039
- hex = "#" + htemp.charAt(0) + htemp.charAt(0) + htemp.charAt(1) + htemp.charAt(1) + htemp.charAt(2) + htemp.charAt(2);
1040
- }
1041
- var reg = new RegExp("[A-Za-z0-9]{2}", 'g');
1042
- var [r, g, b = 0, a] = hex.match(reg).map(v => parseInt(v, 16));
1043
- return {
1044
- r,
1045
- g,
1046
- b,
1047
- a: (a != null ? a : 255) / RGB_MAX
1048
- };
1049
- };
1050
- var hsvaToRgba = _ref9 => {
1051
- var {
1052
- h,
1053
- s,
1054
- v,
1055
- a
1056
- } = _ref9;
1057
- var _h = h / 60,
1058
- _s = s / SV_MAX,
1059
- _v = v / SV_MAX,
1060
- hi = Math.floor(_h) % 6;
1061
- var f = _h - Math.floor(_h),
1062
- _p = RGB_MAX * _v * (1 - _s),
1063
- _q = RGB_MAX * _v * (1 - _s * f),
1064
- _t = RGB_MAX * _v * (1 - _s * (1 - f));
1065
- _v *= RGB_MAX;
1066
- var rgba = {};
1067
- switch (hi) {
1068
- case 0:
1069
- rgba.r = _v;
1070
- rgba.g = _t;
1071
- rgba.b = _p;
1072
- break;
1073
- case 1:
1074
- rgba.r = _q;
1075
- rgba.g = _v;
1076
- rgba.b = _p;
1077
- break;
1078
- case 2:
1079
- rgba.r = _p;
1080
- rgba.g = _v;
1081
- rgba.b = _t;
1082
- break;
1083
- case 3:
1084
- rgba.r = _p;
1085
- rgba.g = _q;
1086
- rgba.b = _v;
1087
- break;
1088
- case 4:
1089
- rgba.r = _t;
1090
- rgba.g = _p;
1091
- rgba.b = _v;
1092
- break;
1093
- case 5:
1094
- rgba.r = _v;
1095
- rgba.g = _p;
1096
- rgba.b = _q;
1097
- break;
1098
- }
1099
- rgba.r = Math.round(rgba.r);
1100
- rgba.g = Math.round(rgba.g);
1101
- rgba.b = Math.round(rgba.b);
1102
- return _extends({}, rgba, {
1103
- a
1104
- });
1105
- };
1106
- var hsvaToRgbaString = hsva => {
1107
- var {
1108
- r,
1109
- g,
1110
- b,
1111
- a
1112
- } = hsvaToRgba(hsva);
1113
- return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
1114
- };
1115
- var rgbaToRgb = _ref0 => {
1116
- var {
1117
- r,
1118
- g,
1119
- b
1120
- } = _ref0;
1121
- return {
1122
- r,
1123
- g,
1124
- b
1125
- };
1126
- };
1127
- var hslaToHsl = _ref1 => {
1128
- var {
1129
- h,
1130
- s,
1131
- l
1132
- } = _ref1;
1133
- return {
1134
- h,
1135
- s,
1136
- l
1137
- };
1138
- };
1139
- var hsvaToHex = hsva => rgbToHex(hsvaToRgba(hsva));
1140
- var hsvaToHsv = _ref10 => {
1141
- var {
1142
- h,
1143
- s,
1144
- v
1145
- } = _ref10;
1146
- return {
1147
- h,
1148
- s,
1149
- v
1150
- };
1151
- };
1152
- var rgbToXY = _ref12 => {
1153
- var {
1154
- r,
1155
- g,
1156
- b
1157
- } = _ref12;
1158
- var translateColor = function translateColor(color) {
1159
- return color <= 0.04045 ? color / 12.92 : Math.pow((color + 0.055) / 1.055, 2.4);
1160
- };
1161
- var red = translateColor(r / 255);
1162
- var green = translateColor(g / 255);
1163
- var blue = translateColor(b / 255);
1164
- var xyz = {};
1165
- xyz.x = red * 0.4124 + green * 0.3576 + blue * 0.1805;
1166
- xyz.y = red * 0.2126 + green * 0.7152 + blue * 0.0722;
1167
- xyz.bri = red * 0.0193 + green * 0.1192 + blue * 0.9505;
1168
- return xyz;
1169
- };
1170
- var color = str => {
1171
- var rgb;
1172
- var hsl;
1173
- var hsv;
1174
- var rgba;
1175
- var hsla;
1176
- var hsva;
1177
- var xy;
1178
- var hex;
1179
- var hexa;
1180
- if (typeof str === 'string' && validHex$1(str)) {
1181
- hsva = hexToHsva(str);
1182
- hex = str;
1183
- } else if (typeof str !== 'string') {
1184
- hsva = str;
1185
- }
1186
- if (hsva) {
1187
- hsv = hsvaToHsv(hsva);
1188
- hsla = hsvaToHsla(hsva);
1189
- rgba = hsvaToRgba(hsva);
1190
- hexa = rgbaToHexa(rgba);
1191
- hex = hsvaToHex(hsva);
1192
- hsl = hslaToHsl(hsla);
1193
- rgb = rgbaToRgb(rgba);
1194
- xy = rgbToXY(rgb);
1195
- }
1196
- return {
1197
- rgb,
1198
- hsl,
1199
- hsv,
1200
- rgba,
1201
- hsla,
1202
- hsva,
1203
- hex,
1204
- hexa,
1205
- xy
1206
- };
1207
- };
1208
- var validHex$1 = hex => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
1209
-
1210
- function useEventCallback(handler) {
1211
- var callbackRef = React$1.useRef(handler);
1212
- React$1.useEffect(() => {
1213
- callbackRef.current = handler;
1214
- });
1215
- return React$1.useCallback((value, event) => callbackRef.current && callbackRef.current(value, event), []);
1216
- }
1217
- var isTouch = event => 'touches' in event;
1218
- var preventDefaultMove = event => {
1219
- !isTouch(event) && event.preventDefault && event.preventDefault();
1220
- };
1221
- var clamp = function clamp(number, min, max) {
1222
- if (min === void 0) {
1223
- min = 0;
1224
- }
1225
- if (max === void 0) {
1226
- max = 1;
1227
- }
1228
- return number > max ? max : number < min ? min : number;
1229
- };
1230
- var getRelativePosition = (node, event) => {
1231
- var rect = node.getBoundingClientRect();
1232
- var pointer = isTouch(event) ? event.touches[0] : event;
1233
- return {
1234
- left: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
1235
- top: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height),
1236
- width: rect.width,
1237
- height: rect.height,
1238
- x: pointer.pageX - (rect.left + window.pageXOffset),
1239
- y: pointer.pageY - (rect.top + window.pageYOffset)
1240
- };
1241
- };
1242
-
1243
- var _excluded$8 = ["prefixCls", "className", "onMove", "onDown"];
1244
- var Interactive = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1245
- var {
1246
- prefixCls = 'w-color-interactive',
1247
- className,
1248
- onMove,
1249
- onDown
1250
- } = props,
1251
- reset = _objectWithoutPropertiesLoose(props, _excluded$8);
1252
- var container = React$1.useRef(null);
1253
- var hasTouched = React$1.useRef(false);
1254
- var [isDragging, setDragging] = React$1.useState(false);
1255
- var onMoveCallback = useEventCallback(onMove);
1256
- var onKeyCallback = useEventCallback(onDown);
1257
- var isValid = event => {
1258
- if (hasTouched.current && !isTouch(event)) return false;
1259
- hasTouched.current = isTouch(event);
1260
- return true;
1261
- };
1262
- var handleMove = React$1.useCallback(event => {
1263
- preventDefaultMove(event);
1264
- if (!container.current) return;
1265
- var isDown = isTouch(event) ? event.touches.length > 0 : event.buttons > 0;
1266
- if (!isDown) {
1267
- setDragging(false);
1268
- return;
1269
- }
1270
- onMoveCallback == null || onMoveCallback(getRelativePosition(container.current, event), event);
1271
- }, [onMoveCallback]);
1272
- var handleMoveEnd = React$1.useCallback(() => setDragging(false), []);
1273
- var toggleDocumentEvents = React$1.useCallback(state => {
1274
- if (state) {
1275
- window.addEventListener(hasTouched.current ? 'touchmove' : 'mousemove', handleMove);
1276
- window.addEventListener(hasTouched.current ? 'touchend' : 'mouseup', handleMoveEnd);
1277
- } else {
1278
- window.removeEventListener('mousemove', handleMove);
1279
- window.removeEventListener('mouseup', handleMoveEnd);
1280
- window.removeEventListener('touchmove', handleMove);
1281
- window.removeEventListener('touchend', handleMoveEnd);
1282
- }
1283
- }, [handleMove, handleMoveEnd]);
1284
- React$1.useEffect(() => {
1285
- toggleDocumentEvents(isDragging);
1286
- return () => {
1287
- toggleDocumentEvents(false);
1288
- };
1289
- }, [isDragging, handleMove, handleMoveEnd, toggleDocumentEvents]);
1290
- var handleMoveStart = React$1.useCallback(event => {
1291
- var activeEl = document.activeElement;
1292
- activeEl == null || activeEl.blur();
1293
- preventDefaultMove(event.nativeEvent);
1294
- if (!isValid(event.nativeEvent)) return;
1295
- if (!container.current) return;
1296
- onKeyCallback == null || onKeyCallback(getRelativePosition(container.current, event.nativeEvent), event.nativeEvent);
1297
- setDragging(true);
1298
- }, [onKeyCallback]);
1299
- return /*#__PURE__*/jsxRuntime.jsx("div", _extends({}, reset, {
1300
- className: [prefixCls, className || ''].filter(Boolean).join(' '),
1301
- style: _extends({}, reset.style, {
1302
- touchAction: 'none'
1303
- }),
1304
- ref: container,
1305
- tabIndex: 0,
1306
- onMouseDown: handleMoveStart,
1307
- onTouchStart: handleMoveStart
1308
- }));
1309
- });
1310
- Interactive.displayName = 'Interactive';
1311
-
1312
- var Pointer$1 = _ref => {
1313
- var {
1314
- className,
1315
- color,
1316
- left,
1317
- top,
1318
- prefixCls
1319
- } = _ref;
1320
- var style = {
1321
- position: 'absolute',
1322
- top,
1323
- left
1324
- };
1325
- var stylePointer = {
1326
- '--saturation-pointer-box-shadow': 'rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px',
1327
- width: 6,
1328
- height: 6,
1329
- transform: 'translate(-3px, -3px)',
1330
- boxShadow: 'var(--saturation-pointer-box-shadow)',
1331
- borderRadius: '50%',
1332
- backgroundColor: color
1333
- };
1334
- return React$1.useMemo(() => /*#__PURE__*/jsxRuntime.jsx("div", {
1335
- className: prefixCls + "-pointer " + (className || ''),
1336
- style: style,
1337
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
1338
- className: prefixCls + "-fill",
1339
- style: stylePointer
1340
- })
1341
- }), [top, left, color, className, prefixCls]);
1342
- };
1343
-
1344
- var _excluded$7 = ["prefixCls", "radius", "pointer", "className", "hue", "style", "hsva", "onChange"];
1345
- var Saturation = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1346
- var _hsva$h;
1347
- var {
1348
- prefixCls = 'w-color-saturation',
1349
- radius = 0,
1350
- pointer,
1351
- className,
1352
- hue = 0,
1353
- style,
1354
- hsva,
1355
- onChange
1356
- } = props,
1357
- other = _objectWithoutPropertiesLoose(props, _excluded$7);
1358
- var containerStyle = _extends({
1359
- width: 200,
1360
- height: 200,
1361
- borderRadius: radius
1362
- }, style, {
1363
- position: 'relative'
1364
- });
1365
- var handleChange = (interaction, event) => {
1366
- onChange && hsva && onChange({
1367
- h: hsva.h,
1368
- s: interaction.left * 100,
1369
- v: (1 - interaction.top) * 100,
1370
- a: hsva.a
1371
- });
1372
- };
1373
- var handleKeyDown = React$1.useCallback(event => {
1374
- if (!hsva || !onChange) return;
1375
- var step = 1;
1376
- var newS = hsva.s;
1377
- var newV = hsva.v;
1378
- var changed = false;
1379
- switch (event.key) {
1380
- case 'ArrowLeft':
1381
- newS = Math.max(0, hsva.s - step);
1382
- changed = true;
1383
- event.preventDefault();
1384
- break;
1385
- case 'ArrowRight':
1386
- newS = Math.min(100, hsva.s + step);
1387
- changed = true;
1388
- event.preventDefault();
1389
- break;
1390
- case 'ArrowUp':
1391
- newV = Math.min(100, hsva.v + step);
1392
- changed = true;
1393
- event.preventDefault();
1394
- break;
1395
- case 'ArrowDown':
1396
- newV = Math.max(0, hsva.v - step);
1397
- changed = true;
1398
- event.preventDefault();
1399
- break;
1400
- default:
1401
- return;
1402
- }
1403
- if (changed) {
1404
- onChange({
1405
- h: hsva.h,
1406
- s: newS,
1407
- v: newV,
1408
- a: hsva.a
1409
- });
1410
- }
1411
- }, [hsva, onChange]);
1412
- var pointerElement = React$1.useMemo(() => {
1413
- if (!hsva) return null;
1414
- var comProps = {
1415
- top: 100 - hsva.v + "%",
1416
- left: hsva.s + "%",
1417
- color: hsvaToHslaString(hsva)
1418
- };
1419
- if (pointer && typeof pointer === 'function') {
1420
- return pointer(_extends({
1421
- prefixCls
1422
- }, comProps));
1423
- }
1424
- return /*#__PURE__*/jsxRuntime.jsx(Pointer$1, _extends({
1425
- prefixCls: prefixCls
1426
- }, comProps));
1427
- }, [hsva, pointer, prefixCls]);
1428
- var handleClick = React$1.useCallback(event => {
1429
- event.target.focus();
1430
- }, []);
1431
- return /*#__PURE__*/jsxRuntime.jsx(Interactive, _extends({
1432
- className: [prefixCls, className || ''].filter(Boolean).join(' ')
1433
- }, other, {
1434
- style: _extends({
1435
- position: 'absolute',
1436
- inset: 0,
1437
- cursor: 'crosshair',
1438
- backgroundImage: "linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl(" + ((_hsva$h = hsva == null ? void 0 : hsva.h) != null ? _hsva$h : hue) + ", 100%, 50%))"
1439
- }, containerStyle, {
1440
- outline: 'none'
1441
- }),
1442
- ref: ref,
1443
- onMove: handleChange,
1444
- onDown: handleChange,
1445
- onKeyDown: handleKeyDown,
1446
- onClick: handleClick,
1447
- children: pointerElement
1448
- }));
1449
- });
1450
- Saturation.displayName = 'Saturation';
1451
-
1452
- var _excluded$6 = ["className", "prefixCls", "left", "top", "style", "fillProps"];
1453
- var Pointer = _ref => {
1454
- var {
1455
- className,
1456
- prefixCls,
1457
- left,
1458
- top,
1459
- style,
1460
- fillProps
1461
- } = _ref,
1462
- reset = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1463
- var styleWrapper = _extends({}, style, {
1464
- position: 'absolute',
1465
- left,
1466
- top
1467
- });
1468
- var stylePointer = _extends({
1469
- width: 18,
1470
- height: 18,
1471
- boxShadow: 'var(--alpha-pointer-box-shadow)',
1472
- borderRadius: '50%',
1473
- backgroundColor: 'var(--alpha-pointer-background-color)'
1474
- }, fillProps == null ? void 0 : fillProps.style, {
1475
- transform: left ? 'translate(-9px, -1px)' : 'translate(-1px, -9px)'
1476
- });
1477
- return /*#__PURE__*/jsxRuntime.jsx("div", _extends({
1478
- className: prefixCls + "-pointer " + (className || ''),
1479
- style: styleWrapper
1480
- }, reset, {
1481
- children: /*#__PURE__*/jsxRuntime.jsx("div", _extends({
1482
- className: prefixCls + "-fill"
1483
- }, fillProps, {
1484
- style: stylePointer
1485
- }))
1486
- }));
1487
- };
1488
-
1489
- var _excluded$5 = ["prefixCls", "className", "hsva", "background", "bgProps", "innerProps", "pointerProps", "radius", "width", "height", "direction", "style", "onChange", "pointer"];
1490
- var BACKGROUND_IMG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==';
1491
- var Alpha = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1492
- var {
1493
- prefixCls = 'w-color-alpha',
1494
- className,
1495
- hsva,
1496
- background,
1497
- bgProps = {},
1498
- innerProps = {},
1499
- pointerProps = {},
1500
- radius = 0,
1501
- width,
1502
- height = 16,
1503
- direction = 'horizontal',
1504
- style,
1505
- onChange,
1506
- pointer
1507
- } = props,
1508
- other = _objectWithoutPropertiesLoose(props, _excluded$5);
1509
- var handleChange = offset => {
1510
- onChange && onChange(_extends({}, hsva, {
1511
- a: direction === 'horizontal' ? offset.left : offset.top
1512
- }), offset);
1513
- };
1514
- var colorTo = hsvaToHslaString(Object.assign({}, hsva, {
1515
- a: 1
1516
- }));
1517
- var innerBackground = "linear-gradient(to " + (direction === 'horizontal' ? 'right' : 'bottom') + ", rgba(244, 67, 54, 0) 0%, " + colorTo + " 100%)";
1518
- var comProps = {};
1519
- if (direction === 'horizontal') {
1520
- comProps.left = hsva.a * 100 + "%";
1521
- } else {
1522
- comProps.top = hsva.a * 100 + "%";
1523
- }
1524
- var styleWrapper = _extends({
1525
- '--alpha-background-color': '#fff',
1526
- '--alpha-pointer-background-color': 'rgb(248, 248, 248)',
1527
- '--alpha-pointer-box-shadow': 'rgb(0 0 0 / 37%) 0px 1px 4px 0px',
1528
- borderRadius: radius,
1529
- background: "url(" + BACKGROUND_IMG + ") left center",
1530
- backgroundColor: 'var(--alpha-background-color)'
1531
- }, {
1532
- width,
1533
- height
1534
- }, style, {
1535
- position: 'relative'
1536
- });
1537
- var handleKeyDown = React$1.useCallback(event => {
1538
- var step = 0.01;
1539
- var currentAlpha = hsva.a;
1540
- var newAlpha = currentAlpha;
1541
- switch (event.key) {
1542
- case 'ArrowLeft':
1543
- if (direction === 'horizontal') {
1544
- newAlpha = Math.max(0, currentAlpha - step);
1545
- event.preventDefault();
1546
- }
1547
- break;
1548
- case 'ArrowRight':
1549
- if (direction === 'horizontal') {
1550
- newAlpha = Math.min(1, currentAlpha + step);
1551
- event.preventDefault();
1552
- }
1553
- break;
1554
- case 'ArrowUp':
1555
- if (direction === 'vertical') {
1556
- newAlpha = Math.max(0, currentAlpha - step);
1557
- event.preventDefault();
1558
- }
1559
- break;
1560
- case 'ArrowDown':
1561
- if (direction === 'vertical') {
1562
- newAlpha = Math.min(1, currentAlpha + step);
1563
- event.preventDefault();
1564
- }
1565
- break;
1566
- default:
1567
- return;
1568
- }
1569
- if (newAlpha !== currentAlpha) {
1570
- var syntheticOffset = {
1571
- left: direction === 'horizontal' ? newAlpha : hsva.a,
1572
- top: direction === 'vertical' ? newAlpha : hsva.a,
1573
- width: 0,
1574
- height: 0,
1575
- x: 0,
1576
- y: 0
1577
- };
1578
- onChange && onChange(_extends({}, hsva, {
1579
- a: newAlpha
1580
- }), syntheticOffset);
1581
- }
1582
- }, [hsva, direction, onChange]);
1583
- var handleClick = React$1.useCallback(event => {
1584
- event.target.focus();
1585
- }, []);
1586
- var pointerElement = pointer && typeof pointer === 'function' ? pointer(_extends({
1587
- prefixCls
1588
- }, pointerProps, comProps)) : /*#__PURE__*/jsxRuntime.jsx(Pointer, _extends({}, pointerProps, {
1589
- prefixCls: prefixCls
1590
- }, comProps));
1591
- return /*#__PURE__*/jsxRuntime.jsxs("div", _extends({}, other, {
1592
- className: [prefixCls, prefixCls + "-" + direction, className || ''].filter(Boolean).join(' '),
1593
- style: styleWrapper,
1594
- ref: ref,
1595
- children: [/*#__PURE__*/jsxRuntime.jsx("div", _extends({}, bgProps, {
1596
- style: _extends({
1597
- inset: 0,
1598
- position: 'absolute',
1599
- background: background || innerBackground,
1600
- borderRadius: radius
1601
- }, bgProps.style)
1602
- })), /*#__PURE__*/jsxRuntime.jsx(Interactive, _extends({}, innerProps, {
1603
- style: _extends({}, innerProps.style, {
1604
- inset: 0,
1605
- zIndex: 1,
1606
- position: 'absolute',
1607
- outline: 'none'
1608
- }),
1609
- onMove: handleChange,
1610
- onDown: handleChange,
1611
- onClick: handleClick,
1612
- onKeyDown: handleKeyDown,
1613
- children: pointerElement
1614
- }))]
1615
- }));
1616
- });
1617
- Alpha.displayName = 'Alpha';
1618
-
1619
- var _excluded$4 = ["prefixCls", "placement", "label", "value", "className", "style", "labelStyle", "inputStyle", "onChange", "onBlur", "renderInput"];
1620
- var validHex = hex => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
1621
- var getNumberValue = value => Number(String(value).replace(/%/g, ''));
1622
- var EditableInput = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1623
- var {
1624
- prefixCls = 'w-color-editable-input',
1625
- placement = 'bottom',
1626
- label,
1627
- value: initValue,
1628
- className,
1629
- style,
1630
- labelStyle,
1631
- inputStyle,
1632
- onChange,
1633
- onBlur,
1634
- renderInput
1635
- } = props,
1636
- other = _objectWithoutPropertiesLoose(props, _excluded$4);
1637
- var [value, setValue] = React$1.useState(initValue);
1638
- var isFocus = React$1.useRef(false);
1639
- React$1.useEffect(() => {
1640
- if (props.value !== value) {
1641
- if (!isFocus.current) {
1642
- setValue(props.value);
1643
- }
1644
- }
1645
- }, [props.value]);
1646
- function handleChange(evn, valInit) {
1647
- var value = (valInit || evn.target.value).trim().replace(/^#/, '');
1648
- if (validHex(value)) {
1649
- onChange && onChange(evn, value);
1650
- }
1651
- var val = getNumberValue(value);
1652
- if (!isNaN(val)) {
1653
- onChange && onChange(evn, val);
1654
- }
1655
- setValue(value);
1656
- }
1657
- function handleBlur(evn) {
1658
- isFocus.current = false;
1659
- setValue(props.value);
1660
- onBlur && onBlur(evn);
1661
- }
1662
- var placementStyle = {};
1663
- if (placement === 'bottom') {
1664
- placementStyle['flexDirection'] = 'column';
1665
- }
1666
- if (placement === 'top') {
1667
- placementStyle['flexDirection'] = 'column-reverse';
1668
- }
1669
- if (placement === 'left') {
1670
- placementStyle['flexDirection'] = 'row-reverse';
1671
- }
1672
- var wrapperStyle = _extends({
1673
- '--editable-input-label-color': 'rgb(153, 153, 153)',
1674
- '--editable-input-box-shadow': 'rgb(204 204 204) 0px 0px 0px 1px inset',
1675
- '--editable-input-color': '#666',
1676
- position: 'relative',
1677
- alignItems: 'center',
1678
- display: 'flex',
1679
- fontSize: 11
1680
- }, placementStyle, style);
1681
- var editableStyle = _extends({
1682
- width: '100%',
1683
- paddingTop: 2,
1684
- paddingBottom: 2,
1685
- paddingLeft: 3,
1686
- paddingRight: 3,
1687
- fontSize: 11,
1688
- background: 'transparent',
1689
- boxSizing: 'border-box',
1690
- border: 'none',
1691
- color: 'var(--editable-input-color)',
1692
- boxShadow: 'var(--editable-input-box-shadow)'
1693
- }, inputStyle);
1694
- var inputProps = _extends({
1695
- value,
1696
- onChange: handleChange,
1697
- onBlur: handleBlur,
1698
- autoComplete: 'off',
1699
- onFocus: () => isFocus.current = true
1700
- }, other, {
1701
- style: editableStyle,
1702
- onFocusCapture: e => {
1703
- var elm = e.target;
1704
- elm.setSelectionRange(elm.value.length, elm.value.length);
1705
- }
1706
- });
1707
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1708
- className: [prefixCls, className || ''].filter(Boolean).join(' '),
1709
- style: wrapperStyle,
1710
- children: [renderInput ? renderInput(inputProps, ref) : /*#__PURE__*/jsxRuntime.jsx("input", _extends({
1711
- ref: ref
1712
- }, inputProps)), label && /*#__PURE__*/jsxRuntime.jsx("span", {
1713
- style: _extends({
1714
- color: 'var(--editable-input-label-color)',
1715
- textTransform: 'capitalize'
1716
- }, labelStyle),
1717
- children: label
1718
- })]
1719
- });
1720
- });
1721
- EditableInput.displayName = 'EditableInput';
1722
-
1723
- var _excluded$3 = ["prefixCls", "hsva", "placement", "rProps", "gProps", "bProps", "aProps", "className", "style", "onChange"];
1724
- var EditableInputRGBA = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1725
- var {
1726
- prefixCls = 'w-color-editable-input-rgba',
1727
- hsva,
1728
- placement = 'bottom',
1729
- rProps = {},
1730
- gProps = {},
1731
- bProps = {},
1732
- aProps = {},
1733
- className,
1734
- style,
1735
- onChange
1736
- } = props,
1737
- other = _objectWithoutPropertiesLoose(props, _excluded$3);
1738
- var rgba = hsva ? hsvaToRgba(hsva) : {};
1739
- function handleBlur(evn) {
1740
- var value = Number(evn.target.value);
1741
- if (value && value > 255) {
1742
- evn.target.value = '255';
1743
- }
1744
- if (value && value < 0) {
1745
- evn.target.value = '0';
1746
- }
1747
- }
1748
- var handleAlphaBlur = evn => {
1749
- var value = Number(evn.target.value);
1750
- if (value && value > 100) {
1751
- evn.target.value = '100';
1752
- }
1753
- if (value && value < 0) {
1754
- evn.target.value = '0';
1755
- }
1756
- };
1757
- var handleChange = (value, type, evn) => {
1758
- if (typeof value === 'number') {
1759
- if (type === 'a') {
1760
- if (value < 0) value = 0;
1761
- if (value > 100) value = 100;
1762
- onChange && onChange(color(rgbaToHsva(_extends({}, rgba, {
1763
- a: value / 100
1764
- }))));
1765
- }
1766
- if (value > 255) {
1767
- value = 255;
1768
- evn.target.value = '255';
1769
- }
1770
- if (value < 0) {
1771
- value = 0;
1772
- evn.target.value = '0';
1773
- }
1774
- if (type === 'r') {
1775
- onChange && onChange(color(rgbaToHsva(_extends({}, rgba, {
1776
- r: value
1777
- }))));
1778
- }
1779
- if (type === 'g') {
1780
- onChange && onChange(color(rgbaToHsva(_extends({}, rgba, {
1781
- g: value
1782
- }))));
1783
- }
1784
- if (type === 'b') {
1785
- onChange && onChange(color(rgbaToHsva(_extends({}, rgba, {
1786
- b: value
1787
- }))));
1788
- }
1789
- }
1790
- };
1791
- var roundedAlpha = rgba.a ? Math.round(rgba.a * 100) / 100 : 0;
1792
- return /*#__PURE__*/jsxRuntime.jsxs("div", _extends({
1793
- ref: ref,
1794
- className: [prefixCls, className || ''].filter(Boolean).join(' ')
1795
- }, other, {
1796
- style: _extends({
1797
- fontSize: 11,
1798
- display: 'flex'
1799
- }, style),
1800
- children: [/*#__PURE__*/jsxRuntime.jsx(EditableInput, _extends({
1801
- label: "R",
1802
- value: rgba.r || 0,
1803
- onBlur: handleBlur,
1804
- placement: placement,
1805
- onChange: (evn, val) => handleChange(val, 'r', evn)
1806
- }, rProps, {
1807
- style: _extends({}, rProps.style)
1808
- })), /*#__PURE__*/jsxRuntime.jsx(EditableInput, _extends({
1809
- label: "G",
1810
- value: rgba.g || 0,
1811
- onBlur: handleBlur,
1812
- placement: placement,
1813
- onChange: (evn, val) => handleChange(val, 'g', evn)
1814
- }, gProps, {
1815
- style: _extends({
1816
- marginLeft: 5
1817
- }, rProps.style)
1818
- })), /*#__PURE__*/jsxRuntime.jsx(EditableInput, _extends({
1819
- label: "B",
1820
- value: rgba.b || 0,
1821
- onBlur: handleBlur,
1822
- placement: placement,
1823
- onChange: (evn, val) => handleChange(val, 'b', evn)
1824
- }, bProps, {
1825
- style: _extends({
1826
- marginLeft: 5
1827
- }, bProps.style)
1828
- })), aProps && /*#__PURE__*/jsxRuntime.jsx(EditableInput, _extends({
1829
- label: "A",
1830
- value: parseInt(String(roundedAlpha * 100), 10),
1831
- onBlur: handleAlphaBlur,
1832
- placement: placement,
1833
- onChange: (evn, val) => handleChange(val, 'a', evn)
1834
- }, aProps, {
1835
- style: _extends({
1836
- marginLeft: 5
1837
- }, aProps.style)
1838
- }))]
1839
- }));
1840
- });
1841
- EditableInputRGBA.displayName = 'EditableInputRGBA';
1842
-
1843
- var _excluded$2 = ["prefixCls", "className", "hue", "onChange", "direction"];
1844
- var Hue = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1845
- var {
1846
- prefixCls = 'w-color-hue',
1847
- className,
1848
- hue = 0,
1849
- onChange: _onChange,
1850
- direction = 'horizontal'
1851
- } = props,
1852
- other = _objectWithoutPropertiesLoose(props, _excluded$2);
1853
- return /*#__PURE__*/jsxRuntime.jsx(Alpha, _extends({
1854
- ref: ref,
1855
- className: prefixCls + " " + (className || '')
1856
- }, other, {
1857
- direction: direction,
1858
- background: "linear-gradient(to " + (direction === 'horizontal' ? 'right' : 'bottom') + ", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",
1859
- hsva: {
1860
- h: hue,
1861
- s: 100,
1862
- v: 100,
1863
- a: hue / 360
1864
- },
1865
- onChange: (_, interaction) => {
1866
- _onChange && _onChange({
1867
- h: direction === 'horizontal' ? 360 * interaction.left : 360 * interaction.top
1868
- });
1869
- }
1870
- }));
1871
- });
1872
- Hue.displayName = 'Hue';
1873
-
1874
- var _excluded$1 = ["prefixCls", "className", "color", "colors", "style", "rectProps", "onChange", "addonAfter", "addonBefore", "rectRender"];
1875
- var Swatch = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1876
- var {
1877
- prefixCls = 'w-color-swatch',
1878
- className,
1879
- color: color$1,
1880
- colors = [],
1881
- style,
1882
- rectProps = {},
1883
- onChange,
1884
- addonAfter,
1885
- addonBefore,
1886
- rectRender
1887
- } = props,
1888
- other = _objectWithoutPropertiesLoose(props, _excluded$1);
1889
- var rectStyle = _extends({
1890
- '--swatch-background-color': 'rgb(144, 19, 254)',
1891
- background: 'var(--swatch-background-color)',
1892
- height: 15,
1893
- width: 15,
1894
- marginRight: 5,
1895
- marginBottom: 5,
1896
- cursor: 'pointer',
1897
- position: 'relative',
1898
- outline: 'none',
1899
- borderRadius: 2
1900
- }, rectProps.style);
1901
- var handleClick = (hex, evn) => {
1902
- onChange && onChange(hexToHsva(hex), color(hexToHsva(hex)), evn);
1903
- };
1904
- return /*#__PURE__*/jsxRuntime.jsxs("div", _extends({
1905
- ref: ref
1906
- }, other, {
1907
- className: [prefixCls, className || ''].filter(Boolean).join(' '),
1908
- style: _extends({
1909
- display: 'flex',
1910
- flexWrap: 'wrap',
1911
- position: 'relative'
1912
- }, style),
1913
- children: [addonBefore && /*#__PURE__*/React$1.isValidElement(addonBefore) && addonBefore, colors && Array.isArray(colors) && colors.map((item, idx) => {
1914
- var title = '';
1915
- var background = '';
1916
- if (typeof item === 'string') {
1917
- title = item;
1918
- background = item;
1919
- }
1920
- if (typeof item === 'object' && item.color) {
1921
- title = item.title || item.color;
1922
- background = item.color;
1923
- }
1924
- var checked = color$1 && color$1.toLocaleLowerCase() === background.toLocaleLowerCase();
1925
- var render = rectRender && rectRender({
1926
- title,
1927
- color: background,
1928
- checked: !!checked,
1929
- style: _extends({}, rectStyle, {
1930
- background
1931
- }),
1932
- onClick: evn => handleClick(background, evn)
1933
- });
1934
- if (render) {
1935
- return /*#__PURE__*/jsxRuntime.jsx(React$1.Fragment, {
1936
- children: render
1937
- }, idx);
1938
- }
1939
- var child = rectProps.children && /*#__PURE__*/React$1.isValidElement(rectProps.children) ? /*#__PURE__*/React$1.cloneElement(rectProps.children, {
1940
- color: background,
1941
- checked
1942
- }) : null;
1943
- return /*#__PURE__*/jsxRuntime.jsx("div", _extends({
1944
- tabIndex: 0,
1945
- title: title,
1946
- onClick: evn => handleClick(background, evn)
1947
- }, rectProps, {
1948
- children: child,
1949
- style: _extends({}, rectStyle, {
1950
- background
1951
- })
1952
- }), idx);
1953
- }), addonAfter && /*#__PURE__*/React$1.isValidElement(addonAfter) && addonAfter]
1954
- }));
1955
- });
1956
- Swatch.displayName = 'Swatch';
1957
-
1958
- var _excluded = ["prefixCls", "className", "onChange", "width", "presetColors", "color", "editableDisable", "disableAlpha", "style"];
1959
- var PRESET_COLORS = ['#D0021B', '#F5A623', '#f8e61b', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF'];
1960
- var Bar = props => /*#__PURE__*/jsxRuntime.jsx("div", {
1961
- style: {
1962
- boxShadow: 'rgb(0 0 0 / 60%) 0px 0px 2px',
1963
- width: 4,
1964
- top: 1,
1965
- bottom: 1,
1966
- left: props.left,
1967
- borderRadius: 1,
1968
- position: 'absolute',
1969
- backgroundColor: '#fff'
1970
- }
1971
- });
1972
- var Sketch = /*#__PURE__*/React$1.forwardRef((props, ref) => {
1973
- var {
1974
- prefixCls = 'w-color-sketch',
1975
- className,
1976
- onChange,
1977
- width = 218,
1978
- presetColors = PRESET_COLORS,
1979
- color: color$1,
1980
- editableDisable = true,
1981
- disableAlpha = false,
1982
- style
1983
- } = props,
1984
- other = _objectWithoutPropertiesLoose(props, _excluded);
1985
- var [hsva, setHsva] = React$1.useState({
1986
- h: 209,
1987
- s: 36,
1988
- v: 90,
1989
- a: 1
1990
- });
1991
- React$1.useEffect(() => {
1992
- if (typeof color$1 === 'string' && validHex$1(color$1)) {
1993
- setHsva(hexToHsva(color$1));
1994
- }
1995
- if (typeof color$1 === 'object') {
1996
- setHsva(color$1);
1997
- }
1998
- }, [color$1]);
1999
- var handleChange = hsv => {
2000
- setHsva(hsv);
2001
- onChange && onChange(color(hsv));
2002
- };
2003
- var handleHex = (value, evn) => {
2004
- if (typeof value === 'string' && validHex$1(value) && /(3|6)/.test(String(value.length))) {
2005
- handleChange(hexToHsva(value));
2006
- }
2007
- };
2008
- var handleAlphaChange = newAlpha => handleChange(_extends({}, hsva, {
2009
- a: newAlpha.a
2010
- }));
2011
- var handleSaturationChange = newColor => handleChange(_extends({}, hsva, newColor, {
2012
- a: hsva.a
2013
- }));
2014
- var styleMain = _extends({
2015
- '--sketch-background': 'rgb(255, 255, 255)',
2016
- '--sketch-box-shadow': 'rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px',
2017
- '--sketch-swatch-box-shadow': 'rgb(0 0 0 / 15%) 0px 0px 0px 1px inset',
2018
- '--sketch-alpha-box-shadow': 'rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset',
2019
- '--sketch-swatch-border-top': '1px solid rgb(238, 238, 238)',
2020
- background: 'var(--sketch-background)',
2021
- borderRadius: 4,
2022
- boxShadow: 'var(--sketch-box-shadow)',
2023
- width
2024
- }, style);
2025
- var styleAlpha = {
2026
- borderRadius: 2,
2027
- background: hsvaToRgbaString(hsva),
2028
- boxShadow: 'var(--sketch-alpha-box-shadow)'
2029
- };
2030
- var styleSwatch = {
2031
- borderTop: 'var(--sketch-swatch-border-top)',
2032
- paddingTop: 10,
2033
- paddingLeft: 10
2034
- };
2035
- var styleSwatchRect = {
2036
- marginRight: 10,
2037
- marginBottom: 10,
2038
- borderRadius: 3,
2039
- boxShadow: 'var(--sketch-swatch-box-shadow)'
2040
- };
2041
- return /*#__PURE__*/jsxRuntime.jsxs("div", _extends({}, other, {
2042
- className: prefixCls + " " + (className || ''),
2043
- ref: ref,
2044
- style: styleMain,
2045
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2046
- style: {
2047
- padding: '10px 10px 8px'
2048
- },
2049
- children: [/*#__PURE__*/jsxRuntime.jsx(Saturation, {
2050
- hsva: hsva,
2051
- style: {
2052
- width: 'auto',
2053
- height: 150
2054
- },
2055
- onChange: handleSaturationChange
2056
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2057
- style: {
2058
- display: 'flex',
2059
- marginTop: 4
2060
- },
2061
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2062
- style: {
2063
- flex: 1
2064
- },
2065
- children: [/*#__PURE__*/jsxRuntime.jsx(Hue, {
2066
- width: "auto",
2067
- height: 10,
2068
- hue: hsva.h,
2069
- pointer: Bar,
2070
- innerProps: {
2071
- style: {
2072
- marginLeft: 1,
2073
- marginRight: 5
2074
- }
2075
- },
2076
- onChange: newHue => handleChange(_extends({}, hsva, newHue))
2077
- }), !disableAlpha && /*#__PURE__*/jsxRuntime.jsx(Alpha, {
2078
- width: "auto",
2079
- height: 10,
2080
- hsva: hsva,
2081
- pointer: Bar,
2082
- style: {
2083
- marginTop: 4
2084
- },
2085
- innerProps: {
2086
- style: {
2087
- marginLeft: 1,
2088
- marginRight: 5
2089
- }
2090
- },
2091
- onChange: handleAlphaChange
2092
- })]
2093
- }), !disableAlpha && /*#__PURE__*/jsxRuntime.jsx(Alpha, {
2094
- width: 24,
2095
- height: 24,
2096
- hsva: hsva,
2097
- radius: 2,
2098
- style: {
2099
- marginLeft: 4
2100
- },
2101
- bgProps: {
2102
- style: {
2103
- background: 'transparent'
2104
- }
2105
- },
2106
- innerProps: {
2107
- style: styleAlpha
2108
- },
2109
- pointer: () => /*#__PURE__*/jsxRuntime.jsx(React$1.Fragment, {})
2110
- })]
2111
- })]
2112
- }), editableDisable && /*#__PURE__*/jsxRuntime.jsxs("div", {
2113
- style: {
2114
- display: 'flex',
2115
- margin: '0 10px 3px 10px'
2116
- },
2117
- children: [/*#__PURE__*/jsxRuntime.jsx(EditableInput, {
2118
- label: "Hex",
2119
- value: hsvaToHex(hsva).replace(/^#/, '').toLocaleUpperCase(),
2120
- onChange: (evn, val) => handleHex(val),
2121
- style: {
2122
- minWidth: 58
2123
- }
2124
- }), /*#__PURE__*/jsxRuntime.jsx(EditableInputRGBA, {
2125
- hsva: hsva,
2126
- style: {
2127
- marginLeft: 6
2128
- },
2129
- aProps: !disableAlpha ? {} : false,
2130
- onChange: result => handleChange(result.hsva)
2131
- })]
2132
- }), presetColors && presetColors.length > 0 && /*#__PURE__*/jsxRuntime.jsx(Swatch, {
2133
- style: styleSwatch,
2134
- colors: presetColors,
2135
- color: hsvaToHex(hsva),
2136
- onChange: hsvColor => handleChange(hsvColor),
2137
- rectProps: {
2138
- style: styleSwatchRect
2139
- }
2140
- })]
2141
- }));
2142
- });
2143
- Sketch.displayName = 'Sketch';
2144
-
2145
- var styles$h = {"trigger":"es-trigger-w-aUi","colorPreview":"es-colorPreview-SUgiJ","colorValue":"es-colorValue-cYdRP","popover":"es-popover-SfIUB"};
2146
-
2147
- const ColorSetter = props => {
2148
- const {
2149
- value,
2150
- initialValue,
2151
- onChange,
2152
- disableAlpha = false
2153
- } = props;
2154
- const [open, setOpen] = React$1.useState(false);
2155
- return /*#__PURE__*/React.createElement(Popover, {
2156
- onClose: () => setOpen(false),
2157
- open: open,
2158
- trigger: /*#__PURE__*/React.createElement("button", {
2159
- "aria-label": "Select color",
2160
- className: styles$h.trigger,
2161
- onClick: () => setOpen(true),
2162
- type: "button"
2163
- }, /*#__PURE__*/React.createElement("div", {
2164
- "aria-label": "Current color",
2165
- className: styles$h.colorPreview,
2166
- style: {
2167
- backgroundColor: value ?? initialValue
2168
- }
2169
- }), /*#__PURE__*/React.createElement("span", {
2170
- className: styles$h.colorValue
2171
- }, value ?? initialValue))
2172
- }, /*#__PURE__*/React.createElement("div", {
2173
- className: styles$h.popover
2174
- }, /*#__PURE__*/React.createElement(Sketch, {
2175
- color: value,
2176
- disableAlpha: disableAlpha,
2177
- onChange: res => onChange(res.hexa),
2178
- presetColors: []
2179
- })));
2180
- };
2181
-
2182
- var styles$g = {"trigger":"es-trigger-fTNvQ","triggerIcon":"es-triggerIcon-1mdQ0","triggerIconPrimary":"es-triggerIconPrimary-opifh","triggerIconMuted":"es-triggerIconMuted-CWgDl","triggerText":"es-triggerText-WeQRu","popoverContent":"es-popoverContent-6qE--","tabsList":"es-tabsList-liSeY","tabTrigger":"es-tabTrigger-6j7K-","tabTriggerActive":"es-tabTriggerActive-g6hcl","tabTriggerIcon":"es-tabTriggerIcon-dRSAp","tabContent":"es-tabContent--H166","tabContentActive":"es-tabContentActive-Fjdu5","section":"es-section-eDYxd","sectionLabel":"es-sectionLabel--LHE8","input":"es-input--OymK","inputMono":"es-inputMono-pCJz3","textarea":"es-textarea-iurkc","booleanButtons":"es-booleanButtons-0bM8P","booleanButton":"es-booleanButton-3fXcB","booleanButtonActive":"es-booleanButtonActive-zGWrZ","datasourceList":"es-datasourceList-VIRXb","datasourceButton":"es-datasourceButton-giz6D","datasourceButtonActive":"es-datasourceButtonActive-m5WPP","datasourceIcon":"es-datasourceIcon-q9Omt","emptyState":"es-emptyState-rI2si","hint":"es-hint-zfWLZ","preview":"es-preview-tUInw"};
2183
-
2184
- const defaultValue$2 = {
2185
- type: 'static',
2186
- staticValue: ''
2187
- };
2188
- const DataBindingSetter = props => {
2189
- const {
2190
- value,
2191
- initialValue,
2192
- onChange,
2193
- dataType = 'any',
2194
- showPreview = true,
2195
- dataSources = []
2196
- } = props;
2197
- const currentValue = value ?? initialValue ?? defaultValue$2;
2198
- const [open, setOpen] = React$1.useState(false);
2199
- const [activeTab, setActiveTab] = React$1.useState(currentValue.type);
2200
- const updateBinding = React$1.useCallback(updates => {
2201
- onChange({
2202
- ...currentValue,
2203
- ...updates
2204
- });
2205
- }, [currentValue, onChange]);
2206
- const handleTypeChange = React$1.useCallback(type => {
2207
- setActiveTab(type);
2208
- updateBinding({
2209
- type
2210
- });
2211
- }, [updateBinding]);
2212
- const handleStaticValueChange = React$1.useCallback(staticValue => {
2213
- updateBinding({
2214
- staticValue
2215
- });
2216
- }, [updateBinding]);
2217
- const handleDatasourceChange = React$1.useCallback(datasourceId => {
2218
- updateBinding({
2219
- datasourceId,
2220
- datasourcePath: ''
2221
- });
2222
- }, [updateBinding]);
2223
- const handlePathChange = React$1.useCallback(datasourcePath => {
2224
- updateBinding({
2225
- datasourcePath
2226
- });
2227
- }, [updateBinding]);
2228
-
2229
- // 渲染静态值输入
2230
- const renderStaticInput = React$1.useMemo(() => {
2231
- switch (dataType) {
2232
- case 'number':
2233
- return /*#__PURE__*/React.createElement("input", {
2234
- className: styles$g.input,
2235
- onChange: e => handleStaticValueChange(Number(e.target.value)),
2236
- placeholder: "\u8F93\u5165\u6570\u503C",
2237
- type: "number",
2238
- value: currentValue.staticValue ?? ''
2239
- });
2240
- case 'boolean':
2241
- return /*#__PURE__*/React.createElement("div", {
2242
- className: styles$g.booleanButtons
2243
- }, /*#__PURE__*/React.createElement("button", {
2244
- className: cn(styles$g.booleanButton, currentValue.staticValue === true ? styles$g.booleanButtonActive : ''),
2245
- onClick: () => handleStaticValueChange(true),
2246
- type: "button"
2247
- }, "True"), /*#__PURE__*/React.createElement("button", {
2248
- className: cn(styles$g.booleanButton, currentValue.staticValue === false ? styles$g.booleanButtonActive : ''),
2249
- onClick: () => handleStaticValueChange(false),
2250
- type: "button"
2251
- }, "False"));
2252
- case 'array':
2253
- case 'object':
2254
- return /*#__PURE__*/React.createElement("textarea", {
2255
- className: styles$g.textarea,
2256
- onChange: e => {
2257
- try {
2258
- const parsed = JSON.parse(e.target.value);
2259
- handleStaticValueChange(parsed);
2260
- } catch {
2261
- handleStaticValueChange(e.target.value);
2262
- }
2263
- },
2264
- placeholder: dataType === 'array' ? '["item1", "item2"]' : '{"key": "value"}',
2265
- value: typeof currentValue.staticValue === 'string' ? currentValue.staticValue : JSON.stringify(currentValue.staticValue, null, 2) ?? ''
2266
- });
2267
- default:
2268
- return /*#__PURE__*/React.createElement("input", {
2269
- className: styles$g.input,
2270
- onChange: e => handleStaticValueChange(e.target.value),
2271
- placeholder: "\u8F93\u5165\u503C",
2272
- type: "text",
2273
- value: currentValue.staticValue ?? ''
2274
- });
2275
- }
2276
- }, [dataType, currentValue.staticValue, handleStaticValueChange]);
2277
-
2278
- // 绑定状态显示
2279
- const bindingStatus = React$1.useMemo(() => {
2280
- if (currentValue.type === 'datasource' && currentValue.datasourceId) {
2281
- const ds = dataSources.find(d => d.id === currentValue.datasourceId);
2282
- return {
2283
- icon: /*#__PURE__*/React.createElement(Link2, {
2284
- className: cn(styles$g.triggerIcon, styles$g.triggerIconPrimary)
2285
- }),
2286
- text: `${ds?.name ?? currentValue.datasourceId}${currentValue.datasourcePath ? `.${currentValue.datasourcePath}` : ''}`
2287
- };
2288
- }
2289
- return {
2290
- icon: /*#__PURE__*/React.createElement(FileBraces, {
2291
- className: cn(styles$g.triggerIcon, styles$g.triggerIconMuted)
2292
- }),
2293
- text: '静态数据'
2294
- };
2295
- }, [currentValue, dataSources]);
2296
- return /*#__PURE__*/React.createElement(Popover, {
2297
- onClose: () => setOpen(false),
2298
- open: open,
2299
- trigger: /*#__PURE__*/React.createElement("button", {
2300
- "aria-label": "Data binding",
2301
- className: styles$g.trigger,
2302
- onClick: () => setOpen(true),
2303
- type: "button"
2304
- }, bindingStatus.icon, /*#__PURE__*/React.createElement("span", {
2305
- className: styles$g.triggerText
2306
- }, bindingStatus.text)),
2307
- width: 300
2308
- }, /*#__PURE__*/React.createElement("div", {
2309
- className: styles$g.popoverContent
2310
- }, /*#__PURE__*/React.createElement("div", {
2311
- className: styles$g.tabsList,
2312
- role: "tablist"
2313
- }, /*#__PURE__*/React.createElement("button", {
2314
- "aria-selected": activeTab === 'static',
2315
- className: cn(styles$g.tabTrigger, activeTab === 'static' ? styles$g.tabTriggerActive : ''),
2316
- onClick: () => handleTypeChange('static'),
2317
- role: "tab",
2318
- type: "button"
2319
- }, /*#__PURE__*/React.createElement(FileBraces, {
2320
- className: styles$g.tabTriggerIcon
2321
- }), "\u9759\u6001\u6570\u636E"), /*#__PURE__*/React.createElement("button", {
2322
- "aria-selected": activeTab === 'datasource',
2323
- className: cn(styles$g.tabTrigger, activeTab === 'datasource' ? styles$g.tabTriggerActive : ''),
2324
- onClick: () => handleTypeChange('datasource'),
2325
- role: "tab",
2326
- type: "button"
2327
- }, /*#__PURE__*/React.createElement(Database, {
2328
- className: styles$g.tabTriggerIcon
2329
- }), "\u6570\u636E\u6E90")), /*#__PURE__*/React.createElement("div", {
2330
- className: cn(styles$g.tabContent, activeTab === 'static' ? styles$g.tabContentActive : ''),
2331
- role: "tabpanel"
2332
- }, /*#__PURE__*/React.createElement("div", {
2333
- className: styles$g.section
2334
- }, /*#__PURE__*/React.createElement("span", {
2335
- className: styles$g.sectionLabel
2336
- }, "\u503C (", dataType, ")"), renderStaticInput)), /*#__PURE__*/React.createElement("div", {
2337
- className: cn(styles$g.tabContent, activeTab === 'datasource' ? styles$g.tabContentActive : ''),
2338
- role: "tabpanel"
2339
- }, /*#__PURE__*/React.createElement("div", {
2340
- className: styles$g.section
2341
- }, /*#__PURE__*/React.createElement("span", {
2342
- className: styles$g.sectionLabel
2343
- }, "\u6570\u636E\u6E90"), dataSources.length > 0 ? /*#__PURE__*/React.createElement("div", {
2344
- className: styles$g.datasourceList
2345
- }, dataSources.map(ds => /*#__PURE__*/React.createElement("button", {
2346
- className: cn(styles$g.datasourceButton, currentValue.datasourceId === ds.id ? styles$g.datasourceButtonActive : ''),
2347
- key: ds.id,
2348
- onClick: () => handleDatasourceChange(ds.id),
2349
- type: "button"
2350
- }, /*#__PURE__*/React.createElement(Database, {
2351
- className: styles$g.datasourceIcon
2352
- }), ds.name))) : /*#__PURE__*/React.createElement("div", {
2353
- className: styles$g.emptyState
2354
- }, "\u6682\u65E0\u53EF\u7528\u6570\u636E\u6E90"), currentValue.datasourceId ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
2355
- className: styles$g.sectionLabel
2356
- }, "\u6570\u636E\u8DEF\u5F84"), /*#__PURE__*/React.createElement("input", {
2357
- className: cn(styles$g.input, styles$g.inputMono),
2358
- onChange: e => handlePathChange(e.target.value),
2359
- placeholder: "data.list[0].name",
2360
- type: "text",
2361
- value: currentValue.datasourcePath ?? ''
2362
- }), /*#__PURE__*/React.createElement("span", {
2363
- className: styles$g.hint
2364
- }, "\u4F7F\u7528\u70B9\u53F7\u8BBF\u95EE\u5D4C\u5957\u5C5E\u6027\uFF0C\u5982: data.items[0].value")) : null, showPreview === true && currentValue.datasourceId ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
2365
- className: styles$g.sectionLabel
2366
- }, "\u6570\u636E\u9884\u89C8"), /*#__PURE__*/React.createElement("div", {
2367
- className: styles$g.preview
2368
- }, "\u7ED1\u5B9A\u540E\u53EF\u5728\u9884\u89C8\u6A21\u5F0F\u67E5\u770B\u6570\u636E")) : null))));
2369
- };
2370
-
2371
- var styles$f = {"trigger":"es-trigger-rmYLl","triggerIcon":"es-triggerIcon-ktlTS","triggerText":"es-triggerText-B63By","popoverContent":"es-popoverContent-IIcFY","header":"es-header-VoKF3","headerTitle":"es-headerTitle-vDZR8","headerCount":"es-headerCount-stTlN","mappingList":"es-mappingList-SLqhN","mappingItem":"es-mappingItem-xtRLl","mappingHeader":"es-mappingHeader-LwKiY","mappingTitle":"es-mappingTitle-IMhzw","mappingRequired":"es-mappingRequired-tP6L-","mappingType":"es-mappingType-nyqrh","mappingRow":"es-mappingRow-lFfhT","select":"es-select-R4pIl","input":"es-input--LohJ","arrowIcon":"es-arrowIcon-QqWMM","targetField":"es-targetField-gSvGk","transformRow":"es-transformRow-O6MAG","transformIcon":"es-transformIcon-beXzy","transformInput":"es-transformInput-SyN2q","clearButton":"es-clearButton-Pm-uP","helpText":"es-helpText-IHqjo"};
2372
-
2373
- const defaultValue$1 = {
2374
- mappings: []
2375
- };
2376
- const DataMappingSetter = props => {
2377
- const {
2378
- value,
2379
- initialValue,
2380
- onChange,
2381
- targetFields,
2382
- sourceFields = []
2383
- } = props;
2384
- const currentValue = value ?? initialValue ?? defaultValue$1;
2385
- const [open, setOpen] = React$1.useState(false);
2386
-
2387
- // 获取字段的映射
2388
- const getMapping = React$1.useCallback(targetField => currentValue.mappings.find(m => m.targetField === targetField), [currentValue.mappings]);
2389
-
2390
- // 更新映射
2391
- const updateMapping = React$1.useCallback((targetField, updates) => {
2392
- const existingIndex = currentValue.mappings.findIndex(m => m.targetField === targetField);
2393
- const newMappings = [...currentValue.mappings];
2394
- if (existingIndex >= 0) {
2395
- newMappings[existingIndex] = {
2396
- ...newMappings[existingIndex],
2397
- ...updates
2398
- };
2399
- } else {
2400
- newMappings.push({
2401
- targetField,
2402
- sourceField: updates.sourceField ?? '',
2403
- transform: updates.transform
2404
- });
2405
- }
2406
- onChange({
2407
- mappings: newMappings
2408
- });
2409
- }, [currentValue.mappings, onChange]);
2410
-
2411
- // 清除映射
2412
- const clearMapping = React$1.useCallback(targetField => {
2413
- const newMappings = currentValue.mappings.filter(m => m.targetField !== targetField);
2414
- onChange({
2415
- mappings: newMappings
2416
- });
2417
- }, [currentValue.mappings, onChange]);
2418
-
2419
- // 统计已映射字段数
2420
- const mappedCount = currentValue.mappings.filter(m => m.sourceField).length;
2421
- return /*#__PURE__*/React.createElement(Popover, {
2422
- onClose: () => setOpen(false),
2423
- open: open,
2424
- trigger: /*#__PURE__*/React.createElement("button", {
2425
- "aria-label": "Data mapping",
2426
- className: styles$f.trigger,
2427
- onClick: () => setOpen(true),
2428
- type: "button"
2429
- }, /*#__PURE__*/React.createElement(Settings2, {
2430
- className: styles$f.triggerIcon
2431
- }), /*#__PURE__*/React.createElement("span", {
2432
- className: styles$f.triggerText
2433
- }, "\u5B57\u6BB5\u6620\u5C04 (", mappedCount, "/", targetFields.length, ")")),
2434
- width: 320
2435
- }, /*#__PURE__*/React.createElement("div", {
2436
- className: styles$f.popoverContent
2437
- }, /*#__PURE__*/React.createElement("div", {
2438
- className: styles$f.header
2439
- }, /*#__PURE__*/React.createElement("span", {
2440
- className: styles$f.headerTitle
2441
- }, "\u5B57\u6BB5\u6620\u5C04\u914D\u7F6E"), /*#__PURE__*/React.createElement("span", {
2442
- className: styles$f.headerCount
2443
- }, mappedCount, "/", targetFields.length, " \u5DF2\u6620\u5C04")), /*#__PURE__*/React.createElement("div", {
2444
- className: styles$f.mappingList
2445
- }, targetFields.map(field => {
2446
- const mapping = getMapping(field.name);
2447
- return /*#__PURE__*/React.createElement("div", {
2448
- className: styles$f.mappingItem,
2449
- key: field.name
2450
- }, /*#__PURE__*/React.createElement("div", {
2451
- className: styles$f.mappingHeader
2452
- }, /*#__PURE__*/React.createElement("span", {
2453
- className: styles$f.mappingTitle
2454
- }, field.label, field.required ? /*#__PURE__*/React.createElement("span", {
2455
- className: styles$f.mappingRequired
2456
- }, "*") : null), /*#__PURE__*/React.createElement("span", {
2457
- className: styles$f.mappingType
2458
- }, field.type)), /*#__PURE__*/React.createElement("div", {
2459
- className: styles$f.mappingRow
2460
- }, sourceFields.length > 0 ? /*#__PURE__*/React.createElement("select", {
2461
- className: styles$f.select,
2462
- onChange: e => updateMapping(field.name, {
2463
- sourceField: e.target.value
2464
- }),
2465
- value: mapping?.sourceField ?? ''
2466
- }, /*#__PURE__*/React.createElement("option", {
2467
- value: ""
2468
- }, "\u9009\u62E9\u5B57\u6BB5"), sourceFields.map(sf => /*#__PURE__*/React.createElement("option", {
2469
- key: sf,
2470
- value: sf
2471
- }, sf))) : /*#__PURE__*/React.createElement("input", {
2472
- className: styles$f.input,
2473
- onChange: e => updateMapping(field.name, {
2474
- sourceField: e.target.value
2475
- }),
2476
- placeholder: "\u6E90\u5B57\u6BB5\u8DEF\u5F84",
2477
- type: "text",
2478
- value: mapping?.sourceField ?? ''
2479
- }), /*#__PURE__*/React.createElement(ArrowRight, {
2480
- className: styles$f.arrowIcon
2481
- }), /*#__PURE__*/React.createElement("div", {
2482
- className: styles$f.targetField
2483
- }, field.name)), mapping?.sourceField ? /*#__PURE__*/React.createElement("div", {
2484
- className: styles$f.transformRow
2485
- }, /*#__PURE__*/React.createElement(Code, {
2486
- className: styles$f.transformIcon
2487
- }), /*#__PURE__*/React.createElement("input", {
2488
- className: styles$f.transformInput,
2489
- onChange: e => updateMapping(field.name, {
2490
- transform: e.target.value
2491
- }),
2492
- placeholder: "\u8F6C\u6362\u8868\u8FBE\u5F0F (\u53EF\u9009)",
2493
- type: "text",
2494
- value: mapping?.transform ?? ''
2495
- })) : null, mapping?.sourceField ? /*#__PURE__*/React.createElement("button", {
2496
- className: styles$f.clearButton,
2497
- onClick: () => clearMapping(field.name),
2498
- type: "button"
2499
- }, "\u6E05\u9664\u6620\u5C04") : null);
2500
- })), /*#__PURE__*/React.createElement("div", {
2501
- className: styles$f.helpText
2502
- }, /*#__PURE__*/React.createElement("p", null, "\u2022 \u6E90\u5B57\u6BB5: \u6570\u636E\u6E90\u4E2D\u7684\u5B57\u6BB5\u8DEF\u5F84"), /*#__PURE__*/React.createElement("p", null, "\u2022 \u8F6C\u6362\u8868\u8FBE\u5F0F: \u5982 value * 100, value.toFixed(2)"))));
2503
- };
2504
-
2505
- var styles$e = {"container":"es-container-CUmyq","textarea":"es-textarea-hn1hD","textareaError":"es-textareaError-O2GWs","error":"es-error-wjKcS"};
2506
-
2507
- const JsonSetter = props => {
2508
- const {
2509
- value,
2510
- initialValue,
2511
- placeholder,
2512
- rows = 6,
2513
- onChange
2514
- } = props;
2515
- const [text, setText] = React$1.useState('');
2516
- const [error, setError] = React$1.useState(null);
2517
-
2518
- // Sync value to text
2519
- React$1.useEffect(() => {
2520
- const currentValue = value ?? initialValue;
2521
- if (currentValue !== undefined) {
2522
- try {
2523
- setText(JSON.stringify(currentValue, null, 2));
2524
- setError(null);
2525
- } catch {
2526
- setText(String(currentValue));
2527
- }
2528
- } else {
2529
- setText('');
2530
- }
2531
- }, [value, initialValue]);
2532
- const handleChange = React$1.useCallback(newText => {
2533
- setText(newText);
2534
- if (!newText.trim()) {
2535
- setError(null);
2536
- onChange(undefined);
2537
- return;
2538
- }
2539
- try {
2540
- const parsed = JSON.parse(newText);
2541
- setError(null);
2542
- onChange(parsed);
2543
- } catch (e) {
2544
- setError(e.message);
2545
- }
2546
- }, [onChange]);
2547
- const lineHeight = 1.5;
2548
- const minHeight = rows * lineHeight * 14; // 14px base font size
2549
-
2550
- return /*#__PURE__*/React.createElement("div", {
2551
- className: styles$e.container
2552
- }, /*#__PURE__*/React.createElement("textarea", {
2553
- className: cn(styles$e.textarea, error ? styles$e.textareaError : null),
2554
- onChange: e => handleChange(e.target.value),
2555
- placeholder: placeholder || '输入 JSON 数据',
2556
- spellCheck: false,
2557
- style: {
2558
- minHeight
2559
- },
2560
- value: text
2561
- }), error ? /*#__PURE__*/React.createElement("div", {
2562
- className: styles$e.error
2563
- }, error) : null);
2564
- };
2565
-
2566
- var styles$d = {"container":"es-container-som8X","id":"es-id-VnRzV","title":"es-title-B-JkN"};
2567
-
2568
- const NodeIdSetter = props => {
2569
- const {
2570
- selected
2571
- } = props;
2572
- return /*#__PURE__*/React.createElement("div", {
2573
- className: styles$d.container
2574
- }, /*#__PURE__*/React.createElement("p", {
2575
- className: styles$d.id
2576
- }, selected.id), /*#__PURE__*/React.createElement("p", {
2577
- className: styles$d.title
2578
- }, selected.componentMeta.title));
2579
- };
2580
-
2581
- var styles$c = {"container":"es-container-d6iPo","input":"es-input-hzqco","inputWithSuffix":"es-inputWithSuffix-dzHIR","suffix":"es-suffix--jLoo"};
2582
-
2583
- const NumberSetter = props => {
2584
- const {
2585
- value,
2586
- initialValue,
2587
- placeholder,
2588
- onChange,
2589
- suffix
2590
- } = props;
2591
- return /*#__PURE__*/React.createElement("div", {
2592
- className: styles$c.container
2593
- }, /*#__PURE__*/React.createElement("input", {
2594
- className: cn(styles$c.input, suffix ? styles$c.inputWithSuffix : ''),
2595
- onChange: e => onChange(+e.target.value),
2596
- placeholder: placeholder || '',
2597
- type: "number",
2598
- value: value ?? initialValue ?? ''
2599
- }), suffix ? /*#__PURE__*/React.createElement("span", {
2600
- "aria-label": `Unit: ${suffix}`,
2601
- className: styles$c.suffix
2602
- }, suffix) : null);
2603
- };
2604
-
2605
- var styles$b = {"container":"es-container-RzrEe","field":"es-field-AaNu3","label":"es-label-zWfmB","input":"es-input-fv7wH","customField":"es-customField-hV2yY","customFieldInputs":"es-customFieldInputs-efA5X","keyInput":"es-keyInput-MXoPV","removeButton":"es-removeButton-s7K9l","removeIcon":"es-removeIcon-Ostpz","addButton":"es-addButton-Wgly5","addIcon":"es-addIcon-61nc3"};
2606
-
2607
- const ObjectSetter = props => {
2608
- const {
2609
- value,
2610
- initialValue,
2611
- fields = [],
2612
- allowCustomFields = false,
2613
- addFieldText = '添加字段',
2614
- onChange
2615
- } = props;
2616
- const currentValue = value ?? initialValue ?? {};
2617
- const handleFieldChange = React$1.useCallback((key, newValue) => {
2618
- onChange({
2619
- ...currentValue,
2620
- [key]: newValue
2621
- });
2622
- }, [currentValue, onChange]);
2623
- const handleAddField = React$1.useCallback(() => {
2624
- const newKey = `field_${Date.now()}`;
2625
- onChange({
2626
- ...currentValue,
2627
- [newKey]: ''
2628
- });
2629
- }, [currentValue, onChange]);
2630
- const handleRemoveField = React$1.useCallback(key => {
2631
- const newValue = {
2632
- ...currentValue
2633
- };
2634
- delete newValue[key];
2635
- onChange(newValue);
2636
- }, [currentValue, onChange]);
2637
-
2638
- // Get all keys: defined fields + custom fields
2639
- const definedKeys = fields.map(f => f.key);
2640
- const customKeys = Object.keys(currentValue).filter(k => !definedKeys.includes(k));
2641
- return /*#__PURE__*/React.createElement("div", {
2642
- className: styles$b.container
2643
- }, fields.map(field => /*#__PURE__*/React.createElement("div", {
2644
- className: styles$b.field,
2645
- key: field.key
2646
- }, /*#__PURE__*/React.createElement("span", {
2647
- className: styles$b.label
2648
- }, field.label), /*#__PURE__*/React.createElement("input", {
2649
- className: styles$b.input,
2650
- onChange: e => {
2651
- const val = field.type === 'number' ? +e.target.value : e.target.value;
2652
- handleFieldChange(field.key, val);
2653
- },
2654
- placeholder: field.placeholder,
2655
- type: field.type === 'number' ? 'number' : 'text',
2656
- value: currentValue[field.key] ?? ''
2657
- }))), customKeys.map(key => /*#__PURE__*/React.createElement("div", {
2658
- className: styles$b.customField,
2659
- key: key
2660
- }, /*#__PURE__*/React.createElement("div", {
2661
- className: styles$b.customFieldInputs
2662
- }, /*#__PURE__*/React.createElement("input", {
2663
- className: styles$b.keyInput,
2664
- onChange: e => {
2665
- const newKey = e.target.value;
2666
- if (newKey && newKey !== key) {
2667
- const newValue = {
2668
- ...currentValue
2669
- };
2670
- newValue[newKey] = newValue[key];
2671
- delete newValue[key];
2672
- onChange(newValue);
2673
- }
2674
- },
2675
- placeholder: "\u5B57\u6BB5\u540D",
2676
- type: "text",
2677
- value: key
2678
- }), /*#__PURE__*/React.createElement("input", {
2679
- className: styles$b.input,
2680
- onChange: e => handleFieldChange(key, e.target.value),
2681
- placeholder: "\u503C",
2682
- type: "text",
2683
- value: currentValue[key] ?? ''
2684
- })), /*#__PURE__*/React.createElement("button", {
2685
- className: styles$b.removeButton,
2686
- onClick: () => handleRemoveField(key),
2687
- type: "button"
2688
- }, /*#__PURE__*/React.createElement(Trash2, {
2689
- className: styles$b.removeIcon
2690
- })))), allowCustomFields ? /*#__PURE__*/React.createElement("button", {
2691
- className: styles$b.addButton,
2692
- onClick: handleAddField,
2693
- type: "button"
2694
- }, /*#__PURE__*/React.createElement(Plus, {
2695
- className: styles$b.addIcon
2696
- }), addFieldText) : null);
2697
- };
2698
-
2699
- var styles$a = {"container":"es-container-YWSlG","inputWrapper":"es-inputWrapper-B2wKI","input":"es-input--qUrU","suffix":"es-suffix-2c3Cd"};
2700
-
2701
- const RectSetter = props => {
2702
- const {
2703
- value,
2704
- onChange
2705
- } = props;
2706
- const handleChange = (key, newValue) => {
2707
- onChange({
2708
- ...value,
2709
- [key]: newValue
2710
- });
2711
- };
2712
- return /*#__PURE__*/React.createElement("div", {
2713
- className: styles$a.container
2714
- }, /*#__PURE__*/React.createElement("div", {
2715
- className: styles$a.inputWrapper
2716
- }, /*#__PURE__*/React.createElement("input", {
2717
- className: styles$a.input,
2718
- onChange: e => handleChange('x', Number(e.target.value)),
2719
- type: "number",
2720
- value: formatDecimal(value.x)
2721
- }), /*#__PURE__*/React.createElement("span", {
2722
- "aria-label": "Unit: X",
2723
- className: styles$a.suffix
2724
- }, "X")), /*#__PURE__*/React.createElement("div", {
2725
- className: styles$a.inputWrapper
2726
- }, /*#__PURE__*/React.createElement("input", {
2727
- className: styles$a.input,
2728
- onChange: e => handleChange('y', Number(e.target.value)),
2729
- type: "number",
2730
- value: formatDecimal(value.y)
2731
- }), /*#__PURE__*/React.createElement("span", {
2732
- "aria-label": "Unit: Y",
2733
- className: styles$a.suffix
2734
- }, "Y")), /*#__PURE__*/React.createElement("div", {
2735
- className: styles$a.inputWrapper
2736
- }, /*#__PURE__*/React.createElement("input", {
2737
- className: styles$a.input,
2738
- onChange: e => handleChange('width', Number(e.target.value)),
2739
- type: "number",
2740
- value: formatDecimal(value.width)
2741
- }), /*#__PURE__*/React.createElement("span", {
2742
- "aria-label": "Unit: W",
2743
- className: styles$a.suffix
2744
- }, "W")), /*#__PURE__*/React.createElement("div", {
2745
- className: styles$a.inputWrapper
2746
- }, /*#__PURE__*/React.createElement("input", {
2747
- className: styles$a.input,
2748
- onChange: e => handleChange('height', Number(e.target.value)),
2749
- type: "number",
2750
- value: formatDecimal(value.height)
2751
- }), /*#__PURE__*/React.createElement("span", {
2752
- "aria-label": "Unit: H",
2753
- className: styles$a.suffix
2754
- }, "H")));
2755
- };
2756
- const decimalRegex = /(\.\d{2})\d+$/;
2757
- const formatDecimal = num => num.toString().replace(decimalRegex, '$1');
2758
-
2759
- var styles$9 = {"container":"es-container-lamwH","containerSm":"es-containerSm-mndNj","segment":"es-segment-JmKWl","segmentSelected":"es-segmentSelected-fumXM","segmentDisabled":"es-segmentDisabled-Md5LF"};
2760
-
2761
- /**
2762
- * SegmentedSetter - 分段控制器
2763
- * 用于在多个选项之间切换,类似于 iOS 的 UISegmentedControl
2764
- */
2765
- const SegmentedSetter = props => {
2766
- const {
2767
- value,
2768
- initialValue,
2769
- options = [],
2770
- onChange,
2771
- size = 'md'
2772
- } = props;
2773
- const currentValue = value ?? initialValue ?? options[0]?.value ?? '';
2774
- return /*#__PURE__*/React.createElement("div", {
2775
- className: cn(styles$9.container, size === 'sm' ? styles$9.containerSm : '')
2776
- }, options.map(option => /*#__PURE__*/React.createElement("button", {
2777
- className: cn(styles$9.segment, currentValue === option.value ? styles$9.segmentSelected : '', option.disabled === true ? styles$9.segmentDisabled : ''),
2778
- disabled: option.disabled,
2779
- key: option.value,
2780
- onClick: () => !option.disabled && onChange(option.value),
2781
- type: "button"
2782
- }, option.label)));
2783
- };
2784
-
2785
- var styles$8 = {"trigger":"es-trigger-YRz9p","triggerValue":"es-triggerValue-k-g2-","placeholder":"es-placeholder-F8-XP","chevron":"es-chevron-UbZv-","chevronOpen":"es-chevronOpen-Yui-r","dropdown":"es-dropdown-l2sra","option":"es-option-cv-7C","optionSelected":"es-optionSelected-K4e5h","optionDisabled":"es-optionDisabled-72jrC"};
2786
-
2787
- const SelectSetter = props => {
2788
- const {
2789
- value,
2790
- initialValue,
2791
- options = [],
2792
- placeholder,
2793
- onChange
2794
- } = props;
2795
- const [open, setOpen] = React$1.useState(false);
2796
- const currentValue = value ?? initialValue ?? '';
2797
- const selectedOption = options.find(opt => opt.value === currentValue);
2798
- const handleSelect = (optionValue, disabled) => {
2799
- if (disabled) {
2800
- return;
2801
- }
2802
- onChange(optionValue);
2803
- setOpen(false);
2804
- };
2805
- return /*#__PURE__*/React.createElement(Popover, {
2806
- onClose: () => setOpen(false),
2807
- open: open,
2808
- trigger: /*#__PURE__*/React.createElement("button", {
2809
- "aria-expanded": open,
2810
- "aria-haspopup": "listbox",
2811
- className: styles$8.trigger,
2812
- onClick: () => setOpen(true),
2813
- type: "button"
2814
- }, /*#__PURE__*/React.createElement("span", {
2815
- className: cn(styles$8.triggerValue, selectedOption ? '' : styles$8.placeholder)
2816
- }, selectedOption?.label || placeholder || '请选择'), /*#__PURE__*/React.createElement(ChevronDown, {
2817
- className: cn(styles$8.chevron, open ? styles$8.chevronOpen : '')
2818
- }))
2819
- }, /*#__PURE__*/React.createElement("div", {
2820
- className: styles$8.dropdown,
2821
- role: "listbox"
2822
- }, options.map(option => /*#__PURE__*/React.createElement("button", {
2823
- "aria-selected": option.value === currentValue,
2824
- className: cn(styles$8.option, option.value === currentValue ? styles$8.optionSelected : '', option.disabled === true ? styles$8.optionDisabled : ''),
2825
- key: option.value,
2826
- onClick: () => handleSelect(option.value, option.disabled),
2827
- role: "option",
2828
- type: "button"
2829
- }, option.label))));
2830
- };
2831
-
2832
- var styles$7 = {"container":"es-container-PG1Uy","slider":"es-slider-pypb6","track":"es-track-X2NtH","range":"es-range-AVV8x","thumb":"es-thumb-YMQR-","value":"es-value-JiWPV"};
2833
-
2834
- const SliderSetter = props => {
2835
- const {
2836
- value,
2837
- initialValue,
2838
- min = 0,
2839
- max = 100,
2840
- step = 1,
2841
- showValue = true,
2842
- suffix,
2843
- onChange
2844
- } = props;
2845
- const currentValue = value ?? initialValue ?? min;
2846
- const trackRef = React$1.useRef(null);
2847
- const percentage = (currentValue - min) / (max - min) * 100;
2848
- const handleChange = React$1.useCallback(clientX => {
2849
- if (!trackRef.current) {
2850
- return;
2851
- }
2852
- const rect = trackRef.current.getBoundingClientRect();
2853
- const percent = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
2854
- const rawValue = min + percent * (max - min);
2855
- const steppedValue = Math.round(rawValue / step) * step;
2856
- const clampedValue = Math.max(min, Math.min(max, steppedValue));
2857
- onChange(clampedValue);
2858
- }, [min, max, step, onChange]);
2859
- const handleMouseDown = event => {
2860
- handleChange(event.clientX);
2861
- const handleMouseMove = moveEvent => {
2862
- handleChange(moveEvent.clientX);
2863
- };
2864
- const handleMouseUp = () => {
2865
- document.removeEventListener('mousemove', handleMouseMove);
2866
- document.removeEventListener('mouseup', handleMouseUp);
2867
- };
2868
- document.addEventListener('mousemove', handleMouseMove);
2869
- document.addEventListener('mouseup', handleMouseUp);
2870
- };
2871
- return /*#__PURE__*/React.createElement("div", {
2872
- className: styles$7.container
2873
- }, /*#__PURE__*/React.createElement("div", {
2874
- className: styles$7.slider
2875
- }, /*#__PURE__*/React.createElement("div", {
2876
- className: styles$7.track,
2877
- onMouseDown: handleMouseDown,
2878
- ref: trackRef,
2879
- role: "presentation"
2880
- }, /*#__PURE__*/React.createElement("div", {
2881
- className: styles$7.range,
2882
- style: {
2883
- width: `${percentage}%`
2884
- }
2885
- }), /*#__PURE__*/React.createElement("div", {
2886
- "aria-valuemax": max,
2887
- "aria-valuemin": min,
2888
- "aria-valuenow": currentValue,
2889
- className: styles$7.thumb,
2890
- role: "slider",
2891
- style: {
2892
- left: `${percentage}%`
2893
- },
2894
- tabIndex: 0
2895
- }))), showValue === true ? /*#__PURE__*/React.createElement("span", {
2896
- className: styles$7.value
2897
- }, currentValue, suffix) : null);
2898
- };
2899
-
2900
- var styles$6 = {"container":"es-container-XqQza","boxModel":"es-boxModel-8RFjI","inputTop":"es-inputTop-bqsmI","inputRight":"es-inputRight-TV3E-","inputBottom":"es-inputBottom-dP-wA","inputLeft":"es-inputLeft-sygc3","spacingInput":"es-spacingInput-KAWdK","linkButton":"es-linkButton-v1n0k","linkButtonActive":"es-linkButtonActive-Vge1n","linkIcon":"es-linkIcon-K0j9e","presets":"es-presets-CPVVc","presetButton":"es-presetButton-vUc7S","modeLabel":"es-modeLabel-Vh1Cf"};
2901
-
2902
- const defaultValue = {
2903
- top: 0,
2904
- right: 0,
2905
- bottom: 0,
2906
- left: 0
2907
- };
2908
- const presetValues = [0, 4, 8, 12, 16, 24, 32];
2909
- const SpacingSetter = props => {
2910
- const {
2911
- value,
2912
- initialValue,
2913
- onChange,
2914
- mode = 'padding',
2915
- linked: initialLinked = false,
2916
- min = 0,
2917
- max = 100
2918
- } = props;
2919
- const currentValue = value ?? initialValue ?? defaultValue;
2920
- const [isLinked, setIsLinked] = React$1.useState(initialLinked);
2921
- const updateSpacing = React$1.useCallback(updates => {
2922
- if (isLinked) {
2923
- const newValue = Object.values(updates)[0];
2924
- onChange({
2925
- top: newValue,
2926
- right: newValue,
2927
- bottom: newValue,
2928
- left: newValue
2929
- });
2930
- } else {
2931
- onChange({
2932
- ...currentValue,
2933
- ...updates
2934
- });
2935
- }
2936
- }, [currentValue, isLinked, onChange]);
2937
- const handlePresetClick = React$1.useCallback(presetValue => {
2938
- onChange({
2939
- top: presetValue,
2940
- right: presetValue,
2941
- bottom: presetValue,
2942
- left: presetValue
2943
- });
2944
- }, [onChange]);
2945
- const toggleLinked = React$1.useCallback(() => {
2946
- setIsLinked(prev => !prev);
2947
- }, []);
2948
- return /*#__PURE__*/React.createElement("div", {
2949
- className: styles$6.container
2950
- }, /*#__PURE__*/React.createElement("div", {
2951
- className: styles$6.boxModel
2952
- }, /*#__PURE__*/React.createElement("div", {
2953
- className: styles$6.inputTop
2954
- }, /*#__PURE__*/React.createElement("input", {
2955
- className: styles$6.spacingInput,
2956
- max: max,
2957
- min: min,
2958
- onChange: e => updateSpacing({
2959
- top: Number(e.target.value)
2960
- }),
2961
- type: "number",
2962
- value: currentValue.top
2963
- })), /*#__PURE__*/React.createElement("div", {
2964
- className: styles$6.inputRight
2965
- }, /*#__PURE__*/React.createElement("input", {
2966
- className: styles$6.spacingInput,
2967
- max: max,
2968
- min: min,
2969
- onChange: e => updateSpacing({
2970
- right: Number(e.target.value)
2971
- }),
2972
- type: "number",
2973
- value: currentValue.right
2974
- })), /*#__PURE__*/React.createElement("div", {
2975
- className: styles$6.inputBottom
2976
- }, /*#__PURE__*/React.createElement("input", {
2977
- className: styles$6.spacingInput,
2978
- max: max,
2979
- min: min,
2980
- onChange: e => updateSpacing({
2981
- bottom: Number(e.target.value)
2982
- }),
2983
- type: "number",
2984
- value: currentValue.bottom
2985
- })), /*#__PURE__*/React.createElement("div", {
2986
- className: styles$6.inputLeft
2987
- }, /*#__PURE__*/React.createElement("input", {
2988
- className: styles$6.spacingInput,
2989
- max: max,
2990
- min: min,
2991
- onChange: e => updateSpacing({
2992
- left: Number(e.target.value)
2993
- }),
2994
- type: "number",
2995
- value: currentValue.left
2996
- })), /*#__PURE__*/React.createElement("button", {
2997
- "aria-label": isLinked ? 'Unlink values' : 'Link values',
2998
- className: cn(styles$6.linkButton, isLinked ? styles$6.linkButtonActive : ''),
2999
- onClick: toggleLinked,
3000
- type: "button"
3001
- }, isLinked ? /*#__PURE__*/React.createElement(Link, {
3002
- className: styles$6.linkIcon
3003
- }) : /*#__PURE__*/React.createElement(Unlink, {
3004
- className: styles$6.linkIcon
3005
- }))), /*#__PURE__*/React.createElement("div", {
3006
- className: styles$6.presets
3007
- }, presetValues.map(presetValue => /*#__PURE__*/React.createElement("button", {
3008
- className: styles$6.presetButton,
3009
- key: presetValue,
3010
- onClick: () => handlePresetClick(presetValue),
3011
- type: "button"
3012
- }, presetValue))), /*#__PURE__*/React.createElement("div", {
3013
- className: styles$6.modeLabel
3014
- }, mode === 'padding' ? '内边距' : '外边距', " (px)"));
3015
- };
3016
-
3017
- var styles$5 = {"container":"es-container-weN0F","input":"es-input-C8N67","inputWithSuffix":"es-inputWithSuffix-tdJcI","suffix":"es-suffix-HGRiQ"};
3018
-
3019
- const StringSetter = props => {
3020
- const {
3021
- value,
3022
- initialValue,
3023
- placeholder,
3024
- onChange,
3025
- suffix
3026
- } = props;
3027
- return /*#__PURE__*/React.createElement("div", {
3028
- className: styles$5.container
3029
- }, /*#__PURE__*/React.createElement("input", {
3030
- className: cn(styles$5.input, suffix ? styles$5.inputWithSuffix : ''),
3031
- onChange: e => onChange(e.target.value),
3032
- placeholder: placeholder || '',
3033
- type: "text",
3034
- value: value || initialValue || ''
3035
- }), suffix ? /*#__PURE__*/React.createElement("span", {
3036
- "aria-label": `Unit: ${suffix}`,
3037
- className: styles$5.suffix
3038
- }, suffix) : null);
3039
- };
3040
-
3041
- var styles$4 = {"switch":"es-switch-2DV6T","switchChecked":"es-switchChecked-eI65V","switchThumb":"es-switchThumb-GDlBx","switchThumbChecked":"es-switchThumbChecked-uA5kV","checkboxWrapper":"es-checkboxWrapper-l-KtW","checkboxInput":"es-checkboxInput-4Z9KK","checkbox":"es-checkbox-G1P36","checkboxChecked":"es-checkboxChecked-7XJoC","checkIcon":"es-checkIcon-3KIBH","segmented":"es-segmented-IaxAM","segmentedButton":"es-segmentedButton-mbZ5z","segmentedButtonSelected":"es-segmentedButtonSelected-u4m2T"};
3042
-
3043
- /**
3044
- * SwitchSetter - 布尔值设置器
3045
- * 提供多种 UI 模式:switch(开关)、checkbox(复选框)、segmented(分段)
3046
- */
3047
- const SwitchSetter = props => {
3048
- const {
3049
- value,
3050
- initialValue,
3051
- onChange,
3052
- mode = 'switch',
3053
- trueLabel = '是',
3054
- falseLabel = '否'
3055
- } = props;
3056
- const currentValue = value ?? initialValue ?? false;
3057
-
3058
- // 分段模式
3059
- if (mode === 'segmented') {
3060
- return /*#__PURE__*/React.createElement("div", {
3061
- className: styles$4.segmented
3062
- }, /*#__PURE__*/React.createElement("button", {
3063
- className: cn(styles$4.segmentedButton, currentValue === false ? styles$4.segmentedButtonSelected : ''),
3064
- onClick: () => onChange(false),
3065
- type: "button"
3066
- }, falseLabel), /*#__PURE__*/React.createElement("button", {
3067
- className: cn(styles$4.segmentedButton, currentValue === true ? styles$4.segmentedButtonSelected : ''),
3068
- onClick: () => onChange(true),
3069
- type: "button"
3070
- }, trueLabel));
3071
- }
3072
-
3073
- // 复选框模式
3074
- if (mode === 'checkbox') {
3075
- return /*#__PURE__*/React.createElement("label", {
3076
- className: styles$4.checkboxWrapper
3077
- }, /*#__PURE__*/React.createElement("input", {
3078
- checked: currentValue,
3079
- className: styles$4.checkboxInput,
3080
- onChange: e => onChange(e.target.checked),
3081
- type: "checkbox"
3082
- }), /*#__PURE__*/React.createElement("span", {
3083
- className: cn(styles$4.checkbox, currentValue ? styles$4.checkboxChecked : '')
3084
- }, currentValue ? /*#__PURE__*/React.createElement(Check, {
3085
- className: styles$4.checkIcon
3086
- }) : null));
3087
- }
3088
-
3089
- // 开关模式(默认)
3090
- return /*#__PURE__*/React.createElement("button", {
3091
- "aria-checked": currentValue,
3092
- className: cn(styles$4.switch, currentValue ? styles$4.switchChecked : ''),
3093
- onClick: () => onChange(!currentValue),
3094
- role: "switch",
3095
- type: "button"
3096
- }, /*#__PURE__*/React.createElement("span", {
3097
- className: cn(styles$4.switchThumb, currentValue ? styles$4.switchThumbChecked : '')
3098
- }));
3099
- };
3100
-
3101
- var styles$3 = {"container":"es-container-ftwPX","textarea":"es-textarea-sJPy9","counter":"es-counter-02NEu"};
3102
-
3103
- const TextAreaSetter = props => {
3104
- const {
3105
- value,
3106
- initialValue,
3107
- placeholder,
3108
- rows = 3,
3109
- maxLength,
3110
- onChange
3111
- } = props;
3112
- return /*#__PURE__*/React.createElement("div", {
3113
- className: styles$3.container
3114
- }, /*#__PURE__*/React.createElement("textarea", {
3115
- className: styles$3.textarea,
3116
- maxLength: maxLength,
3117
- onChange: e => onChange(e.target.value),
3118
- placeholder: placeholder || '',
3119
- rows: rows,
3120
- value: value ?? initialValue ?? ''
3121
- }), maxLength ? /*#__PURE__*/React.createElement("div", {
3122
- className: styles$3.counter
3123
- }, (value ?? initialValue ?? '').length, "/", maxLength) : null);
3124
- };
3125
-
3126
- var styles$2 = {"container":"es-container-EDh0-","row":"es-row-MOm-T","label":"es-label-1o-jT","hiddenInput":"es-hiddenInput-03Dx-","uploadArea":"es-uploadArea-1HYbh","uploadIcon":"es-uploadIcon-Ck7gF","clearButton":"es-clearButton-N-9cs","clearIcon":"es-clearIcon-LHlF6","fileInfo":"es-fileInfo-71Jtf","fileName":"es-fileName-B2hHy","fileSize":"es-fileSize-pINcz","error":"es-error-A8MID"};
3127
-
3128
- const UploadSetter = props => {
3129
- const {
3130
- value,
3131
- onChange,
3132
- accept = '.jpg,.jpeg,.png,.gif',
3133
- maxSize = 10 * 1024 * 1024
3134
- } = props;
3135
- const [error, setError] = React$1.useState('');
3136
- const inputRef = React$1.useRef(null);
3137
- const handleFileChange = async e => {
3138
- const file = e.target.files?.[0];
3139
- setError('');
3140
- if (!file) {
3141
- onChange(null);
3142
- return;
3143
- }
3144
- const ext = `.${file.name.split('.').pop()?.toLowerCase()}`;
3145
- if (!accept.includes(ext)) {
3146
- setError(`仅支持 ${accept} 格式文件`);
3147
- onChange(null);
3148
- return;
3149
- }
3150
- if (file.size > maxSize) {
3151
- setError(`文件大小不能超过 ${maxSize / 1024 / 1024}MB`);
3152
- onChange(null);
3153
- return;
3154
- }
3155
- try {
3156
- const [base64, dimensions] = await Promise.all([new Promise((resolve, reject) => {
3157
- const reader = new FileReader();
3158
- reader.onload = () => resolve(reader.result);
3159
- reader.onerror = err => reject(err);
3160
- reader.readAsDataURL(file);
3161
- }), new Promise((resolve, reject) => {
3162
- const img = new Image();
3163
- img.onload = () => resolve({
3164
- width: img.naturalWidth,
3165
- height: img.naturalHeight
3166
- });
3167
- img.onerror = reject;
3168
- img.src = URL.createObjectURL(file);
3169
- })]);
3170
- onChange({
3171
- raw: {
3172
- name: file.name,
3173
- size: file.size,
3174
- type: file.type,
3175
- width: dimensions.width,
3176
- height: dimensions.height
3177
- },
3178
- base64
3179
- });
3180
- } catch (_) {
3181
- setError('文件读取失败,请重试');
3182
- onChange(null);
3183
- }
3184
- };
3185
- const handleClear = () => {
3186
- onChange(null);
3187
- if (inputRef.current) {
3188
- inputRef.current.value = '';
3189
- }
3190
- };
3191
- return /*#__PURE__*/React.createElement("div", {
3192
- className: styles$2.container
3193
- }, /*#__PURE__*/React.createElement("div", {
3194
- className: styles$2.row
3195
- }, /*#__PURE__*/React.createElement("label", {
3196
- className: styles$2.label
3197
- }, /*#__PURE__*/React.createElement("input", {
3198
- accept: accept,
3199
- className: styles$2.hiddenInput,
3200
- onChange: handleFileChange,
3201
- ref: inputRef,
3202
- type: "file"
3203
- }), /*#__PURE__*/React.createElement("div", {
3204
- className: styles$2.uploadArea
3205
- }, /*#__PURE__*/React.createElement(Upload, {
3206
- className: styles$2.uploadIcon
3207
- }), /*#__PURE__*/React.createElement("span", null, value ? '更换文件' : '点击上传'))), value ? /*#__PURE__*/React.createElement("button", {
3208
- "aria-label": "\u6E05\u9664\u6587\u4EF6",
3209
- className: styles$2.clearButton,
3210
- onClick: handleClear,
3211
- type: "button"
3212
- }, /*#__PURE__*/React.createElement(X, {
3213
- className: styles$2.clearIcon
3214
- })) : null), value ? /*#__PURE__*/React.createElement("div", {
3215
- className: styles$2.fileInfo
3216
- }, /*#__PURE__*/React.createElement("span", {
3217
- className: styles$2.fileName
3218
- }, value.raw?.name), /*#__PURE__*/React.createElement("span", {
3219
- className: styles$2.fileSize
3220
- }, (value.raw?.size / 1024).toFixed(1), "KB")) : null, error ? /*#__PURE__*/React.createElement("p", {
3221
- className: styles$2.error,
3222
- role: "alert"
3223
- }, error) : null);
3224
- };
3225
-
3226
- var styles$1 = {"container":"es-container-gjha7","header":"es-header-iE--w","title":"es-title-qTdCp","toggleButton":"es-toggleButton-g6dI2","toggleIcon":"es-toggleIcon-cjnM4","content":"es-content-GYYgk","contentHidden":"es-contentHidden-WAYSW","srOnly":"es-srOnly-EI1Tc"};
3227
-
3228
- const CollapseSetter = props => {
3229
- const {
3230
- field,
3231
- children,
3232
- initialValue,
3233
- icon = true
3234
- } = props;
3235
- const [isOpen, setIsOpen] = React$1.useState(initialValue ?? true);
3236
- return /*#__PURE__*/React.createElement("div", {
3237
- className: styles$1.container
3238
- }, /*#__PURE__*/React.createElement("div", {
3239
- className: styles$1.header
3240
- }, /*#__PURE__*/React.createElement("h4", {
3241
- className: styles$1.title
3242
- }, field.title), icon ? /*#__PURE__*/React.createElement("button", {
3243
- "aria-expanded": isOpen,
3244
- className: styles$1.toggleButton,
3245
- onClick: () => setIsOpen(!isOpen),
3246
- type: "button"
3247
- }, /*#__PURE__*/React.createElement(ChevronsUpDown, {
3248
- className: styles$1.toggleIcon
3249
- }), /*#__PURE__*/React.createElement("span", {
3250
- className: styles$1.srOnly
3251
- }, "Toggle")) : null), /*#__PURE__*/React.createElement("div", {
3252
- className: cn(styles$1.content, isOpen === false ? styles$1.contentHidden : '')
3253
- }, children));
3254
- };
3255
-
3256
- var styles = {"container":"es-container-4LWRO","tabsList":"es-tabsList-L72im","tabTrigger":"es-tabTrigger-u3S3S","tabTriggerActive":"es-tabTriggerActive-xCpU6","tabContent":"es-tabContent-Pj2Us","tabContentActive":"es-tabContentActive-NJtXh"};
3257
-
3258
- const TabSetter = props => {
3259
- const {
3260
- tabs,
3261
- initialValue,
3262
- children
3263
- } = props;
3264
- const tabsList = React$1.useMemo(() => {
3265
- if (tabs) {
3266
- return tabs;
3267
- }
3268
- if (Array.isArray(children) && children.length > 0) {
3269
- return children.map(child => ({
3270
- label: child.props.field.config.title,
3271
- value: child.props.field.config.key
3272
- }));
3273
- }
3274
- throw new Error('TabSetter: children or tabs must be an array');
3275
- }, [tabs, children]);
3276
- const firstTabValue = React$1.useMemo(() => tabsList[0]?.value, [tabsList]);
3277
- const [activeTab, setActiveTab] = React$1.useState(initialValue ?? firstTabValue);
3278
- return /*#__PURE__*/React$1.createElement("div", {
3279
- className: styles.container
3280
- }, /*#__PURE__*/React$1.createElement("div", {
3281
- className: styles.tabsList,
3282
- role: "tablist",
3283
- style: {
3284
- gridTemplateColumns: `repeat(${tabsList.length}, minmax(0, 1fr))`
3285
- }
3286
- }, tabsList.map(tab => /*#__PURE__*/React$1.createElement("button", {
3287
- "aria-selected": activeTab === tab.value,
3288
- className: cn(styles.tabTrigger, activeTab === tab.value ? styles.tabTriggerActive : ''),
3289
- key: tab.value,
3290
- onClick: () => setActiveTab(tab.value),
3291
- role: "tab",
3292
- type: "button"
3293
- }, tab.label))), Array.isArray(children) ? children.map(child => /*#__PURE__*/React$1.createElement("div", {
3294
- className: cn(styles.tabContent, activeTab === child.props.field.config.key ? styles.tabContentActive : ''),
3295
- key: child.props.field.config.key,
3296
- role: "tabpanel"
3297
- }, child)) : null);
3298
- };
3299
-
3300
- const setterMap = {
3301
- ColorSetter,
3302
- NodeIdSetter,
3303
- NumberSetter,
3304
- RectSetter,
3305
- StringSetter,
3306
- SwitchSetter,
3307
- UploadSetter,
3308
- SegmentedSetter,
3309
- CollapseSetter,
3310
- TabSetter,
3311
- SpacingSetter,
3312
- AlignSetter,
3313
- DataBindingSetter,
3314
- DataMappingSetter,
3315
- SelectSetter,
3316
- SliderSetter,
3317
- TextAreaSetter,
3318
- ArraySetter,
3319
- JsonSetter,
3320
- ObjectSetter
3321
- };
3322
-
3323
- exports.AlignSetter = AlignSetter;
3324
- exports.ArraySetter = ArraySetter;
3325
- exports.CollapseSetter = CollapseSetter;
3326
- exports.ColorSetter = ColorSetter;
3327
- exports.DataBindingSetter = DataBindingSetter;
3328
- exports.DataMappingSetter = DataMappingSetter;
3329
- exports.JsonSetter = JsonSetter;
3330
- exports.NodeIdSetter = NodeIdSetter;
3331
- exports.NumberSetter = NumberSetter;
3332
- exports.ObjectSetter = ObjectSetter;
3333
- exports.Popover = Popover;
3334
- exports.RectSetter = RectSetter;
3335
- exports.SegmentedSetter = SegmentedSetter;
3336
- exports.SelectSetter = SelectSetter;
3337
- exports.SliderSetter = SliderSetter;
3338
- exports.SpacingSetter = SpacingSetter;
3339
- exports.StringSetter = StringSetter;
3340
- exports.SwitchSetter = SwitchSetter;
3341
- exports.TabSetter = TabSetter;
3342
- exports.TextAreaSetter = TextAreaSetter;
3343
- exports.UploadSetter = UploadSetter;
3344
- exports.default = setterMap;
3345
- exports.setterMap = setterMap;
3346
-
3347
- Object.defineProperty(exports, '__esModule', { value: true });
3348
-
3349
- }));
3350
- //# sourceMappingURL=index.js.map