@festo-ui/react 3.0.0-pre-20220111.1 → 3.1.0-pre-20220203.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/README.md +3 -2
- package/{react.esm.css → index.esm.css} +0 -0
- package/{react.esm.js → index.esm.js} +913 -1202
- package/{react.umd.css → index.umd.css} +0 -0
- package/{react.umd.js → index.umd.js} +106 -100
- package/lib/components/chips/chip/Chip.d.ts +1 -1
- package/lib/forms/color-picker/ColorPicker.d.ts +1 -1
- package/lib/forms/radio/RadioButton.d.ts +1 -1
- package/lib/forms/radio/RadioGroup.d.ts +1 -1
- package/lib/forms/slider/Slider.d.ts +1 -1
- package/lib/forms/text-editor/TextEditor.d.ts +1 -1
- package/package.json +5 -5
|
@@ -49,50 +49,49 @@ function useForkRef(refA, refB) {
|
|
|
49
49
|
* This means react will call the old forkRef with `null` and the new forkRef
|
|
50
50
|
* with the ref. Cleanup naturally emerges from this behavior
|
|
51
51
|
*/
|
|
52
|
-
return React.useMemo(
|
|
52
|
+
return React.useMemo(() => {
|
|
53
53
|
if (refA == null && refB == null) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
return
|
|
57
|
+
return instance => {
|
|
58
58
|
setRef(refA, instance);
|
|
59
59
|
setRef(refB, instance);
|
|
60
60
|
};
|
|
61
61
|
}, [refA, refB]);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
const Modal = /*#__PURE__*/forwardRef(({
|
|
65
|
+
head,
|
|
66
|
+
isOpen,
|
|
67
|
+
body,
|
|
68
|
+
onClose,
|
|
69
|
+
className,
|
|
70
|
+
children
|
|
71
|
+
}, ref) => {
|
|
72
|
+
const backdropRef = useRef(null);
|
|
73
|
+
const modalRef = useRef(null);
|
|
74
|
+
const combinedRef = useForkRef(ref, modalRef);
|
|
74
75
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CSSTransition, {
|
|
75
76
|
nodeRef: backdropRef,
|
|
76
77
|
unmountOnExit: true,
|
|
77
78
|
timeout: {
|
|
78
79
|
exit: 600
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
+
in: isOpen,
|
|
81
82
|
classNames: "fr-modal-backdrop",
|
|
82
83
|
appear: true
|
|
83
84
|
}, /*#__PURE__*/React.createElement("div", {
|
|
84
85
|
ref: backdropRef,
|
|
85
86
|
className: "fr-modal-backdrop fwe-modal-backdrop"
|
|
86
87
|
})), /*#__PURE__*/React.createElement(OutsideClickHandler, {
|
|
87
|
-
onOutsideClick:
|
|
88
|
-
return onClose ? onClose() : undefined;
|
|
89
|
-
}
|
|
88
|
+
onOutsideClick: () => onClose ? onClose() : undefined
|
|
90
89
|
}, /*#__PURE__*/React.createElement(CSSTransition, {
|
|
91
90
|
ref: modalRef,
|
|
92
91
|
unmountOnExit: true,
|
|
93
92
|
classNames: "fr-modal",
|
|
94
93
|
appear: true,
|
|
95
|
-
|
|
94
|
+
in: isOpen,
|
|
96
95
|
timeout: {
|
|
97
96
|
exit: 600
|
|
98
97
|
}
|
|
@@ -118,10 +117,11 @@ var Modal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
118
117
|
}, body), children))));
|
|
119
118
|
});
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
const ModalFooter = /*#__PURE__*/forwardRef(({
|
|
121
|
+
fullWidth,
|
|
122
|
+
children,
|
|
123
|
+
className
|
|
124
|
+
}, ref) => {
|
|
125
125
|
return /*#__PURE__*/React.createElement("div", {
|
|
126
126
|
ref: ref,
|
|
127
127
|
className: classNames('fwe-modal-footer', className)
|
|
@@ -133,16 +133,18 @@ var ModalFooter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
function AlertModal(_a) {
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
var {
|
|
137
|
+
alertType,
|
|
138
|
+
title,
|
|
139
|
+
className,
|
|
140
|
+
body,
|
|
141
|
+
strong,
|
|
142
|
+
subtitle,
|
|
143
|
+
cancel,
|
|
144
|
+
ok,
|
|
145
|
+
onCancel,
|
|
146
|
+
onOk
|
|
147
|
+
} = _a,
|
|
146
148
|
props = __rest(_a, ["alertType", "title", "className", "body", "strong", "subtitle", "cancel", "ok", "onCancel", "onOk"]);
|
|
147
149
|
|
|
148
150
|
return /*#__PURE__*/React.createElement(Modal, Object.assign({
|
|
@@ -193,13 +195,14 @@ function AlertModal(_a) {
|
|
|
193
195
|
* Breadcrumb navigation can be used on pages with multiple navigation levels.
|
|
194
196
|
*/
|
|
195
197
|
|
|
196
|
-
function Breadcrumb(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
function Breadcrumb({
|
|
199
|
+
locations,
|
|
200
|
+
onClick,
|
|
201
|
+
children,
|
|
202
|
+
className
|
|
203
|
+
}) {
|
|
204
|
+
const childrenList = [];
|
|
205
|
+
React.Children.forEach(children, element => {
|
|
203
206
|
if ( /*#__PURE__*/React.isValidElement(element)) {
|
|
204
207
|
childrenList.push(Object.assign(Object.assign({}, element), {
|
|
205
208
|
props: Object.assign(Object.assign({}, element.props), {
|
|
@@ -210,41 +213,32 @@ function Breadcrumb(_ref) {
|
|
|
210
213
|
});
|
|
211
214
|
return /*#__PURE__*/React.createElement("div", {
|
|
212
215
|
className: classNames('fwe-breadcrumb', className)
|
|
213
|
-
}, locations ? locations.map(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
})
|
|
226
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
227
|
-
key: child.props.children
|
|
228
|
-
}, child, " ", index + 1 < childrenList.length && /*#__PURE__*/React.createElement("i", {
|
|
229
|
-
className: "fwe-icon fwe-icon-arrows-right-2"
|
|
230
|
-
}));
|
|
231
|
-
}));
|
|
216
|
+
}, locations ? locations.map((location, index) => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
217
|
+
key: location.url
|
|
218
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
219
|
+
className: "fr-breadcrumb-location",
|
|
220
|
+
href: location.url,
|
|
221
|
+
onClick: e => onClick ? onClick(e) : undefined
|
|
222
|
+
}, location.label), index + 1 < locations.length && /*#__PURE__*/React.createElement("i", {
|
|
223
|
+
className: "fwe-icon fwe-icon-arrows-right-2"
|
|
224
|
+
}))) : childrenList.map((child, index) => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
225
|
+
key: child.props.children
|
|
226
|
+
}, child, " ", index + 1 < childrenList.length && /*#__PURE__*/React.createElement("i", {
|
|
227
|
+
className: "fwe-icon fwe-icon-arrows-right-2"
|
|
228
|
+
}))));
|
|
232
229
|
}
|
|
233
230
|
|
|
234
|
-
function Button(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
className = _ref.className,
|
|
246
|
-
children = _ref.children;
|
|
247
|
-
var classes = classNames('fwe-btn', {
|
|
231
|
+
function Button({
|
|
232
|
+
icon,
|
|
233
|
+
disabled = false,
|
|
234
|
+
iconOnly = false,
|
|
235
|
+
large = false,
|
|
236
|
+
onClick,
|
|
237
|
+
primary = false,
|
|
238
|
+
className,
|
|
239
|
+
children
|
|
240
|
+
}) {
|
|
241
|
+
const classes = classNames('fwe-btn', {
|
|
248
242
|
'fwe-btn-icon': iconOnly
|
|
249
243
|
}, {
|
|
250
244
|
'fwe-disabled': disabled
|
|
@@ -259,24 +253,26 @@ function Button(_ref) {
|
|
|
259
253
|
className: classes,
|
|
260
254
|
disabled: disabled
|
|
261
255
|
}, icon && /*#__PURE__*/React.createElement("i", {
|
|
262
|
-
className:
|
|
256
|
+
className: `fwe-icon fwe-icon-${icon}`
|
|
263
257
|
}), !iconOnly && /*#__PURE__*/React.createElement("div", {
|
|
264
258
|
className: "fr-button-text"
|
|
265
259
|
}, children));
|
|
266
260
|
}
|
|
267
261
|
|
|
268
|
-
function Card(
|
|
269
|
-
|
|
270
|
-
|
|
262
|
+
function Card({
|
|
263
|
+
children,
|
|
264
|
+
className
|
|
265
|
+
}) {
|
|
271
266
|
return /*#__PURE__*/React.createElement("div", {
|
|
272
267
|
className: classNames('fwe-card', className)
|
|
273
268
|
}, children);
|
|
274
269
|
}
|
|
275
270
|
|
|
276
|
-
function CardBody(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
271
|
+
function CardBody({
|
|
272
|
+
children,
|
|
273
|
+
text,
|
|
274
|
+
className
|
|
275
|
+
}) {
|
|
280
276
|
return /*#__PURE__*/React.createElement("div", {
|
|
281
277
|
className: classNames('fwe-card-body', className)
|
|
282
278
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -284,11 +280,12 @@ function CardBody(_ref) {
|
|
|
284
280
|
}, text), children);
|
|
285
281
|
}
|
|
286
282
|
|
|
287
|
-
function CardHeader(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
283
|
+
function CardHeader({
|
|
284
|
+
title,
|
|
285
|
+
subtitle,
|
|
286
|
+
action,
|
|
287
|
+
className
|
|
288
|
+
}) {
|
|
292
289
|
return /*#__PURE__*/React.createElement("div", {
|
|
293
290
|
className: classNames('fwe-card-header', className)
|
|
294
291
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -296,16 +293,17 @@ function CardHeader(_ref) {
|
|
|
296
293
|
}, /*#__PURE__*/React.createElement("h5", null, title), subtitle && /*#__PURE__*/React.createElement("p", null, subtitle)), action);
|
|
297
294
|
}
|
|
298
295
|
|
|
299
|
-
function CardNotification(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
function CardNotification({
|
|
297
|
+
iconName,
|
|
298
|
+
className,
|
|
299
|
+
title,
|
|
300
|
+
message
|
|
301
|
+
}) {
|
|
302
|
+
const classes = classNames('fwe-card-notification', className);
|
|
305
303
|
return /*#__PURE__*/React.createElement("div", {
|
|
306
304
|
className: classes
|
|
307
305
|
}, /*#__PURE__*/React.createElement("i", {
|
|
308
|
-
className:
|
|
306
|
+
className: `fwe-icon fwe-icon-${iconName} fwe-icon-lg`
|
|
309
307
|
}), /*#__PURE__*/React.createElement("div", {
|
|
310
308
|
className: "fwe-card-title"
|
|
311
309
|
}, /*#__PURE__*/React.createElement("h6", null, title), message && /*#__PURE__*/React.createElement("p", null, message)));
|
|
@@ -321,20 +319,17 @@ var ChipType;
|
|
|
321
319
|
ChipType[ChipType["Readonly"] = 4] = "Readonly";
|
|
322
320
|
})(ChipType || (ChipType = {}));
|
|
323
321
|
|
|
324
|
-
function Chip(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
_onClick = _ref.onClick,
|
|
336
|
-
className = _ref.className;
|
|
337
|
-
var classes = classNames('fr-chip', 'fwe-chip', {
|
|
322
|
+
function Chip({
|
|
323
|
+
type = ChipType.Choice,
|
|
324
|
+
selected = false,
|
|
325
|
+
disabled = false,
|
|
326
|
+
large = false,
|
|
327
|
+
icon,
|
|
328
|
+
children,
|
|
329
|
+
onClick,
|
|
330
|
+
className
|
|
331
|
+
}) {
|
|
332
|
+
const classes = classNames('fr-chip', 'fwe-chip', {
|
|
338
333
|
'fwe-selected': selected
|
|
339
334
|
}, {
|
|
340
335
|
'fwe-disabled': disabled
|
|
@@ -350,24 +345,20 @@ function Chip(_ref) {
|
|
|
350
345
|
return /*#__PURE__*/React.createElement("div", {
|
|
351
346
|
className: classes
|
|
352
347
|
}, icon && /*#__PURE__*/React.createElement("i", {
|
|
353
|
-
onClick:
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
className: "fwe-icon fwe-icon-" + icon
|
|
348
|
+
onClick: e => onClick ? onClick(e) : undefined,
|
|
349
|
+
className: `fwe-icon fwe-icon-${icon}`
|
|
357
350
|
}), children, type === ChipType.Category && /*#__PURE__*/React.createElement("i", {
|
|
358
|
-
onClick:
|
|
359
|
-
return _onClick ? _onClick(e) : undefined;
|
|
360
|
-
},
|
|
351
|
+
onClick: e => onClick ? onClick(e) : undefined,
|
|
361
352
|
className: "fwe-icon fwe-icon-menu-close"
|
|
362
353
|
}));
|
|
363
354
|
}
|
|
364
355
|
|
|
365
|
-
function ChipContainer(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
356
|
+
function ChipContainer({
|
|
357
|
+
large = false,
|
|
358
|
+
children,
|
|
359
|
+
className
|
|
360
|
+
}) {
|
|
361
|
+
const classes = classNames('fwe-chip-container', {
|
|
371
362
|
'fwe-chip-container-lg': large
|
|
372
363
|
}, className);
|
|
373
364
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -375,43 +366,32 @@ function ChipContainer(_ref) {
|
|
|
375
366
|
}, children);
|
|
376
367
|
}
|
|
377
368
|
|
|
378
|
-
function Popover(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
var referenceElement = useRef(null);
|
|
400
|
-
|
|
401
|
-
var _useState2 = useState(null),
|
|
402
|
-
popperElement = _useState2[0],
|
|
403
|
-
setPopperElement = _useState2[1];
|
|
404
|
-
|
|
405
|
-
var _useState3 = useState(null),
|
|
406
|
-
arrowElement = _useState3[0],
|
|
407
|
-
setArrowElement = _useState3[1];
|
|
408
|
-
|
|
409
|
-
var classes = classNames(className);
|
|
410
|
-
useEffect(function () {
|
|
369
|
+
function Popover({
|
|
370
|
+
popoverContent,
|
|
371
|
+
children,
|
|
372
|
+
position,
|
|
373
|
+
fallbackPositions,
|
|
374
|
+
open = false,
|
|
375
|
+
onStatusChange,
|
|
376
|
+
wrapper,
|
|
377
|
+
className,
|
|
378
|
+
flip = true,
|
|
379
|
+
containerClassName,
|
|
380
|
+
stopPropagation,
|
|
381
|
+
arrow = true
|
|
382
|
+
}) {
|
|
383
|
+
const [showPopper, setShowPopper] = useState(open);
|
|
384
|
+
const referenceElement = useRef(null);
|
|
385
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
386
|
+
const [arrowElement, setArrowElement] = useState(null);
|
|
387
|
+
const classes = classNames(className);
|
|
388
|
+
useEffect(() => {
|
|
411
389
|
setShowPopper(open);
|
|
412
390
|
}, [open]);
|
|
413
|
-
|
|
414
|
-
|
|
391
|
+
const {
|
|
392
|
+
styles,
|
|
393
|
+
attributes
|
|
394
|
+
} = usePopper(referenceElement.current, popperElement, {
|
|
415
395
|
placement: position,
|
|
416
396
|
modifiers: [{
|
|
417
397
|
name: 'arrow',
|
|
@@ -429,11 +409,9 @@ function Popover(_ref) {
|
|
|
429
409
|
fallbackPlacements: flip ? fallbackPositions : [position || 'auto']
|
|
430
410
|
}
|
|
431
411
|
}]
|
|
432
|
-
})
|
|
433
|
-
styles = _usePopper.styles,
|
|
434
|
-
attributes = _usePopper.attributes;
|
|
412
|
+
});
|
|
435
413
|
|
|
436
|
-
|
|
414
|
+
const handleChange = (e, status) => {
|
|
437
415
|
if (stopPropagation) {
|
|
438
416
|
e.stopPropagation();
|
|
439
417
|
}
|
|
@@ -445,25 +423,19 @@ function Popover(_ref) {
|
|
|
445
423
|
}
|
|
446
424
|
};
|
|
447
425
|
|
|
448
|
-
|
|
426
|
+
const childrenWrapper = /*#__PURE__*/React.createElement("div", {
|
|
449
427
|
className: classes,
|
|
450
428
|
style: {
|
|
451
429
|
display: 'inline'
|
|
452
430
|
},
|
|
453
431
|
ref: referenceElement,
|
|
454
|
-
onClick:
|
|
455
|
-
return handleChange(e, !showPopper);
|
|
456
|
-
}
|
|
432
|
+
onClick: e => handleChange(e, !showPopper)
|
|
457
433
|
}, children);
|
|
458
434
|
return /*#__PURE__*/React.createElement(OutsideClickHandler, {
|
|
459
435
|
display: "inline",
|
|
460
|
-
onOutsideClick:
|
|
461
|
-
return handleChange(e, false);
|
|
462
|
-
}
|
|
436
|
+
onOutsideClick: e => handleChange(e, false)
|
|
463
437
|
}, wrapper ? wrapper(childrenWrapper) : childrenWrapper, showPopper && /*#__PURE__*/React.createElement("div", Object.assign({
|
|
464
|
-
onClick:
|
|
465
|
-
return e.stopPropagation();
|
|
466
|
-
},
|
|
438
|
+
onClick: e => e.stopPropagation(),
|
|
467
439
|
className: classNames('fwe-popover-container', containerClassName),
|
|
468
440
|
ref: setPopperElement,
|
|
469
441
|
style: styles.popper
|
|
@@ -476,20 +448,17 @@ function Popover(_ref) {
|
|
|
476
448
|
})));
|
|
477
449
|
}
|
|
478
450
|
|
|
479
|
-
function ColorIndicator(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
var _useState = useState(false),
|
|
491
|
-
isEditorOpen = _useState[0],
|
|
492
|
-
setEditorOpen = _useState[1];
|
|
451
|
+
function ColorIndicator({
|
|
452
|
+
text,
|
|
453
|
+
label,
|
|
454
|
+
color,
|
|
455
|
+
className,
|
|
456
|
+
showPopOver = false,
|
|
457
|
+
children,
|
|
458
|
+
disabled
|
|
459
|
+
}) {
|
|
460
|
+
const classes = classNames('fwe-color-indicator', className, disabled);
|
|
461
|
+
const [isEditorOpen, setEditorOpen] = useState(false);
|
|
493
462
|
|
|
494
463
|
function getBorderColor() {
|
|
495
464
|
if (!color || color.toUpperCase() === '#FFFFFF' || color.toUpperCase() === '#F2F3F5') {
|
|
@@ -499,7 +468,7 @@ function ColorIndicator(_ref) {
|
|
|
499
468
|
return color;
|
|
500
469
|
}
|
|
501
470
|
|
|
502
|
-
|
|
471
|
+
const colorBox = /*#__PURE__*/React.createElement("div", {
|
|
503
472
|
className: "fwe-color-box",
|
|
504
473
|
style: {
|
|
505
474
|
background: color,
|
|
@@ -557,25 +526,19 @@ function ColorIndicator(_ref) {
|
|
|
557
526
|
strokeWidth: "0"
|
|
558
527
|
})));
|
|
559
528
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}, label), /*#__PURE__*/React.createElement("div", {
|
|
574
|
-
className: "fwe-color-container"
|
|
575
|
-
}, wrapperChildren, " ", text && /*#__PURE__*/React.createElement("div", {
|
|
576
|
-
className: "fwe-color-indicator-text"
|
|
577
|
-
}, text), ' '));
|
|
578
|
-
};
|
|
529
|
+
const wrapper = wrapperChildren => /*#__PURE__*/React.createElement("div", {
|
|
530
|
+
className: classes,
|
|
531
|
+
onClick: () => setEditorOpen(prevOpen => showPopOver ? !prevOpen : prevOpen)
|
|
532
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
533
|
+
style: {
|
|
534
|
+
opacity: isEditorOpen ? 0 : 1
|
|
535
|
+
},
|
|
536
|
+
className: "fwe-color-label"
|
|
537
|
+
}, label), /*#__PURE__*/React.createElement("div", {
|
|
538
|
+
className: "fwe-color-container"
|
|
539
|
+
}, wrapperChildren, " ", text && /*#__PURE__*/React.createElement("div", {
|
|
540
|
+
className: "fwe-color-indicator-text"
|
|
541
|
+
}, text), ' '));
|
|
579
542
|
|
|
580
543
|
return showPopOver ? /*#__PURE__*/React.createElement(Popover, {
|
|
581
544
|
containerClassName: "fwe-popover-container--color-indicator",
|
|
@@ -589,24 +552,22 @@ function ColorIndicator(_ref) {
|
|
|
589
552
|
}, colorBox) : /*#__PURE__*/React.createElement(React.Fragment, null, wrapper(colorBox));
|
|
590
553
|
}
|
|
591
554
|
|
|
592
|
-
|
|
593
|
-
function ColorHelper() {}
|
|
594
|
-
|
|
555
|
+
class ColorHelper {
|
|
595
556
|
// based on: https://gist.github.com/mjackson/5311256
|
|
596
|
-
|
|
557
|
+
static rgbToHsv(rgb) {
|
|
597
558
|
if (!rgb) {
|
|
598
559
|
return undefined;
|
|
599
560
|
}
|
|
600
561
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
562
|
+
const r = this.limitToByte(rgb.r) / 255;
|
|
563
|
+
const g = this.limitToByte(rgb.g) / 255;
|
|
564
|
+
const b = this.limitToByte(rgb.b) / 255;
|
|
565
|
+
const max = Math.max(r, g, b);
|
|
566
|
+
const min = Math.min(r, g, b);
|
|
567
|
+
let h = max;
|
|
568
|
+
let s = max;
|
|
569
|
+
const v = max;
|
|
570
|
+
const d = max - min;
|
|
610
571
|
s = max === 0 ? 0 : d / max;
|
|
611
572
|
|
|
612
573
|
if (max === min) {
|
|
@@ -631,26 +592,26 @@ var ColorHelper = /*#__PURE__*/function () {
|
|
|
631
592
|
}
|
|
632
593
|
|
|
633
594
|
return {
|
|
634
|
-
h
|
|
635
|
-
s
|
|
636
|
-
v
|
|
595
|
+
h,
|
|
596
|
+
s,
|
|
597
|
+
v
|
|
637
598
|
};
|
|
638
599
|
} // based on: https://gist.github.com/mjackson/5311256
|
|
639
|
-
;
|
|
640
600
|
|
|
641
|
-
|
|
642
|
-
|
|
601
|
+
|
|
602
|
+
static hsvToRgb(_hsv) {
|
|
603
|
+
const hsv = _hsv;
|
|
643
604
|
hsv.h = this.limitToOne(_hsv.h);
|
|
644
605
|
hsv.s = this.limitToOne(_hsv.s);
|
|
645
606
|
hsv.v = this.limitToOne(_hsv.v);
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
607
|
+
let r = 0;
|
|
608
|
+
let g = 0;
|
|
609
|
+
let b = 0;
|
|
610
|
+
const i = Math.floor(hsv.h * 6);
|
|
611
|
+
const f = hsv.h * 6 - i;
|
|
612
|
+
const p = hsv.v * (1 - hsv.s);
|
|
613
|
+
const q = hsv.v * (1 - f * hsv.s);
|
|
614
|
+
const t = hsv.v * (1 - (1 - f) * hsv.s);
|
|
654
615
|
|
|
655
616
|
switch (i % 6) {
|
|
656
617
|
case 0:
|
|
@@ -696,9 +657,9 @@ var ColorHelper = /*#__PURE__*/function () {
|
|
|
696
657
|
g: this.limitToByte(g * 255),
|
|
697
658
|
b: this.limitToByte(b * 255)
|
|
698
659
|
};
|
|
699
|
-
}
|
|
660
|
+
}
|
|
700
661
|
|
|
701
|
-
|
|
662
|
+
static limitToByte(num) {
|
|
702
663
|
if (num <= 0) {
|
|
703
664
|
return 0;
|
|
704
665
|
}
|
|
@@ -708,9 +669,9 @@ var ColorHelper = /*#__PURE__*/function () {
|
|
|
708
669
|
}
|
|
709
670
|
|
|
710
671
|
return num;
|
|
711
|
-
}
|
|
672
|
+
}
|
|
712
673
|
|
|
713
|
-
|
|
674
|
+
static limitToOne(num) {
|
|
714
675
|
if (num <= 0) {
|
|
715
676
|
return 0;
|
|
716
677
|
}
|
|
@@ -720,105 +681,71 @@ var ColorHelper = /*#__PURE__*/function () {
|
|
|
720
681
|
}
|
|
721
682
|
|
|
722
683
|
return num;
|
|
723
|
-
}
|
|
684
|
+
}
|
|
724
685
|
|
|
725
|
-
|
|
726
|
-
|
|
686
|
+
static numberToHex(rgb) {
|
|
687
|
+
let hex = Math.round(rgb).toString(16);
|
|
727
688
|
|
|
728
689
|
if (hex.length < 2) {
|
|
729
|
-
hex =
|
|
690
|
+
hex = `0${hex}`;
|
|
730
691
|
}
|
|
731
692
|
|
|
732
693
|
return hex.toUpperCase();
|
|
733
|
-
}
|
|
694
|
+
}
|
|
734
695
|
|
|
735
|
-
|
|
736
|
-
|
|
696
|
+
static rgbToHex(_rgb) {
|
|
697
|
+
const rgb = _rgb;
|
|
737
698
|
rgb.r = this.limitToByte(rgb.r);
|
|
738
699
|
rgb.g = this.limitToByte(rgb.g);
|
|
739
700
|
rgb.b = this.limitToByte(rgb.b);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
return
|
|
744
|
-
}
|
|
701
|
+
const red = this.numberToHex(rgb.r);
|
|
702
|
+
const green = this.numberToHex(rgb.g);
|
|
703
|
+
const blue = this.numberToHex(rgb.b);
|
|
704
|
+
return `#${red}${green}${blue}`;
|
|
705
|
+
}
|
|
745
706
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
707
|
+
static hexToRgb(hexString) {
|
|
708
|
+
const numbersOnly = hexString.substring(1);
|
|
709
|
+
const aRgbHex = numbersOnly.match(/.{1,2}/g);
|
|
749
710
|
return aRgbHex ? {
|
|
750
711
|
r: parseInt(aRgbHex[0], 16),
|
|
751
712
|
g: parseInt(aRgbHex[1], 16),
|
|
752
713
|
b: parseInt(aRgbHex[2], 16)
|
|
753
714
|
} : undefined;
|
|
754
|
-
}
|
|
715
|
+
}
|
|
755
716
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
className = _ref.className;
|
|
774
|
-
var baseSize = 184;
|
|
775
|
-
var initialRgb = ColorHelper.hexToRgb(color);
|
|
776
|
-
var defaultHsv = {
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
const PREDEFINED_COLORS = ['#0091dc', '#333333', '#ffffff', '#f2f3f5', '#e5e8eb', '#d8dce1', '#b6bec6', '#80ca3d', '#ffd600', '#ff9600', '#d50000'];
|
|
720
|
+
|
|
721
|
+
function ColorPicker({
|
|
722
|
+
palette = PREDEFINED_COLORS,
|
|
723
|
+
useAlpha = false,
|
|
724
|
+
alpha = 100,
|
|
725
|
+
paletteOnly,
|
|
726
|
+
color = '#FFFFFF',
|
|
727
|
+
onChange,
|
|
728
|
+
onAlphaChange,
|
|
729
|
+
className
|
|
730
|
+
}) {
|
|
731
|
+
const baseSize = 184;
|
|
732
|
+
const initialRgb = ColorHelper.hexToRgb(color);
|
|
733
|
+
const defaultHsv = {
|
|
777
734
|
h: 0,
|
|
778
735
|
s: 0,
|
|
779
736
|
v: 1
|
|
780
737
|
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
redInput = _useState3[0],
|
|
793
|
-
setRedInput = _useState3[1];
|
|
794
|
-
|
|
795
|
-
var _useState4 = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.g) || 255),
|
|
796
|
-
greenInput = _useState4[0],
|
|
797
|
-
setGreenInput = _useState4[1];
|
|
798
|
-
|
|
799
|
-
var _useState5 = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.b) || 255),
|
|
800
|
-
blueInput = _useState5[0],
|
|
801
|
-
setBlueInput = _useState5[1];
|
|
802
|
-
|
|
803
|
-
var _useState6 = useState(color),
|
|
804
|
-
hexInputColor = _useState6[0],
|
|
805
|
-
setHexInputColor = _useState6[1];
|
|
806
|
-
|
|
807
|
-
var _useState7 = useState('RGB'),
|
|
808
|
-
inputType = _useState7[0],
|
|
809
|
-
setInputType = _useState7[1];
|
|
810
|
-
|
|
811
|
-
var _useState8 = useState(false),
|
|
812
|
-
selectOpen = _useState8[0],
|
|
813
|
-
setSelectOpen = _useState8[1];
|
|
814
|
-
|
|
815
|
-
var _useState9 = useState(alpha),
|
|
816
|
-
innerAlpha = _useState9[0],
|
|
817
|
-
setInnerAlpha = _useState9[1];
|
|
818
|
-
|
|
819
|
-
var _useState10 = useState(true),
|
|
820
|
-
changeColor = _useState10[0],
|
|
821
|
-
setChangeColor = _useState10[1];
|
|
738
|
+
const initialHsv = initialRgb ? ColorHelper.rgbToHsv(initialRgb) || defaultHsv : defaultHsv;
|
|
739
|
+
const [hsv, setHsv] = useState(initialHsv);
|
|
740
|
+
const [innerColor, setInnerColor] = useState(color);
|
|
741
|
+
const [redInput, setRedInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.r) || 255);
|
|
742
|
+
const [greenInput, setGreenInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.g) || 255);
|
|
743
|
+
const [blueInput, setBlueInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.b) || 255);
|
|
744
|
+
const [hexInputColor, setHexInputColor] = useState(color);
|
|
745
|
+
const [inputType, setInputType] = useState('RGB');
|
|
746
|
+
const [selectOpen, setSelectOpen] = useState(false);
|
|
747
|
+
const [innerAlpha, setInnerAlpha] = useState(alpha);
|
|
748
|
+
const [changeColor, setChangeColor] = useState(true);
|
|
822
749
|
|
|
823
750
|
function limitAlpha() {
|
|
824
751
|
if (innerAlpha > 100) {
|
|
@@ -832,18 +759,18 @@ function ColorPicker(_ref) {
|
|
|
832
759
|
return innerAlpha;
|
|
833
760
|
}
|
|
834
761
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
762
|
+
const hueKnobOffset = hsv.h * baseSize - 14 - baseSize;
|
|
763
|
+
const saturationKnobOffset = hsv.s * baseSize;
|
|
764
|
+
const valueKnobOffset = (1 - hsv.v) * baseSize;
|
|
765
|
+
const alphaKnobOffset = (100 - limitAlpha()) / 100 * baseSize;
|
|
839
766
|
|
|
840
767
|
function getSaturationGradient() {
|
|
841
|
-
return
|
|
768
|
+
return `linear-gradient(to right, white, hsl(${hsv.h * 360}, 100%, 50%) )`;
|
|
842
769
|
}
|
|
843
770
|
|
|
844
771
|
function updateInputs(hexColor) {
|
|
845
772
|
setHexInputColor(hexColor);
|
|
846
|
-
|
|
773
|
+
const rgb = ColorHelper.hexToRgb(hexColor);
|
|
847
774
|
|
|
848
775
|
if (rgb) {
|
|
849
776
|
setRedInput(rgb.r);
|
|
@@ -852,19 +779,19 @@ function ColorPicker(_ref) {
|
|
|
852
779
|
}
|
|
853
780
|
}
|
|
854
781
|
|
|
855
|
-
useEffect(
|
|
782
|
+
useEffect(() => {
|
|
856
783
|
if (onChange) {
|
|
857
784
|
onChange(innerColor);
|
|
858
785
|
}
|
|
859
786
|
}, [onChange, innerColor]);
|
|
860
|
-
useEffect(
|
|
787
|
+
useEffect(() => {
|
|
861
788
|
if (onAlphaChange && innerAlpha) {
|
|
862
789
|
onAlphaChange(innerAlpha);
|
|
863
790
|
}
|
|
864
791
|
}, [onAlphaChange, innerAlpha]);
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
792
|
+
const updateColorHsv = useCallback((_hsv, _changeColor) => {
|
|
793
|
+
const rgb = ColorHelper.hsvToRgb(_hsv);
|
|
794
|
+
const hex = ColorHelper.rgbToHex(rgb);
|
|
868
795
|
|
|
869
796
|
if (_changeColor) {
|
|
870
797
|
setInnerColor(hex);
|
|
@@ -872,18 +799,16 @@ function ColorPicker(_ref) {
|
|
|
872
799
|
|
|
873
800
|
updateInputs(hex);
|
|
874
801
|
}, []);
|
|
875
|
-
useEffect(
|
|
802
|
+
useEffect(() => {
|
|
876
803
|
updateColorHsv(hsv, changeColor);
|
|
877
804
|
}, [updateColorHsv, hsv, changeColor]);
|
|
878
805
|
|
|
879
806
|
function updateGradient(x, y) {
|
|
880
807
|
setChangeColor(true);
|
|
881
|
-
setHsv(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
});
|
|
886
|
-
});
|
|
808
|
+
setHsv(prevHsv => Object.assign(Object.assign({}, prevHsv), {
|
|
809
|
+
s: Math.floor(x) / baseSize,
|
|
810
|
+
v: (baseSize - y) / baseSize
|
|
811
|
+
}));
|
|
887
812
|
}
|
|
888
813
|
|
|
889
814
|
function onGradientDrag(e, data) {
|
|
@@ -892,13 +817,11 @@ function ColorPicker(_ref) {
|
|
|
892
817
|
}
|
|
893
818
|
|
|
894
819
|
function updateHue(y) {
|
|
895
|
-
|
|
820
|
+
const newHue = y / baseSize;
|
|
896
821
|
setChangeColor(true);
|
|
897
|
-
setHsv(
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
});
|
|
901
|
-
});
|
|
822
|
+
setHsv(prevHsv => Object.assign(Object.assign({}, prevHsv), {
|
|
823
|
+
h: newHue
|
|
824
|
+
}));
|
|
902
825
|
}
|
|
903
826
|
|
|
904
827
|
function onHueDrag(e, data) {
|
|
@@ -915,14 +838,14 @@ function ColorPicker(_ref) {
|
|
|
915
838
|
updateAlpha(data.y);
|
|
916
839
|
}
|
|
917
840
|
|
|
918
|
-
|
|
919
|
-
|
|
841
|
+
const updateColorRgb = newColor => {
|
|
842
|
+
const currentColor = newColor || '#FFFFFF';
|
|
920
843
|
updateInputs(currentColor);
|
|
921
|
-
|
|
844
|
+
const rgb = ColorHelper.hexToRgb(currentColor);
|
|
922
845
|
setChangeColor(false);
|
|
923
846
|
|
|
924
847
|
if (rgb) {
|
|
925
|
-
|
|
848
|
+
const newHsv = ColorHelper.rgbToHsv(rgb);
|
|
926
849
|
|
|
927
850
|
if (newHsv) {
|
|
928
851
|
setHsv(newHsv);
|
|
@@ -932,12 +855,10 @@ function ColorPicker(_ref) {
|
|
|
932
855
|
setInnerColor(newColor);
|
|
933
856
|
};
|
|
934
857
|
|
|
935
|
-
|
|
936
|
-
return /^#[0-9A-F]{6}$/i.test(_color);
|
|
937
|
-
};
|
|
858
|
+
const isHexColor = _color => /^#[0-9A-F]{6}$/i.test(_color);
|
|
938
859
|
|
|
939
860
|
function onHexInput(event) {
|
|
940
|
-
|
|
861
|
+
const newHexInputColor = event.target.value;
|
|
941
862
|
setHexInputColor(newHexInputColor.toUpperCase());
|
|
942
863
|
|
|
943
864
|
if (isHexColor(newHexInputColor)) {
|
|
@@ -953,7 +874,7 @@ function ColorPicker(_ref) {
|
|
|
953
874
|
}
|
|
954
875
|
|
|
955
876
|
function onRgbBlur(channel) {
|
|
956
|
-
|
|
877
|
+
let currentInput = '';
|
|
957
878
|
|
|
958
879
|
switch (channel) {
|
|
959
880
|
case 'r':
|
|
@@ -971,17 +892,17 @@ function ColorPicker(_ref) {
|
|
|
971
892
|
}
|
|
972
893
|
|
|
973
894
|
if (typeof currentInput !== 'number' || typeof currentInput === 'number' && currentInput > 255 && currentInput < 0) {
|
|
974
|
-
|
|
895
|
+
const rgb = ColorHelper.hexToRgb(innerColor || '#FFFFFF');
|
|
975
896
|
|
|
976
897
|
if (rgb) {
|
|
977
|
-
|
|
898
|
+
const newHexColor = ColorHelper.rgbToHex(rgb);
|
|
978
899
|
updateInputs(newHexColor);
|
|
979
900
|
}
|
|
980
901
|
}
|
|
981
902
|
}
|
|
982
903
|
|
|
983
904
|
function onRgbInput(_value, channel) {
|
|
984
|
-
|
|
905
|
+
const numberValue = Number.parseInt(_value, 10);
|
|
985
906
|
|
|
986
907
|
switch (channel) {
|
|
987
908
|
case 'r':
|
|
@@ -999,11 +920,11 @@ function ColorPicker(_ref) {
|
|
|
999
920
|
}
|
|
1000
921
|
|
|
1001
922
|
if (numberValue <= 255 && numberValue >= 0) {
|
|
1002
|
-
|
|
923
|
+
const rgb = ColorHelper.hexToRgb(innerColor || '#FFFFFF');
|
|
1003
924
|
|
|
1004
925
|
if (rgb) {
|
|
1005
926
|
rgb[channel] = numberValue;
|
|
1006
|
-
|
|
927
|
+
const newHexColor = ColorHelper.rgbToHex(rgb);
|
|
1007
928
|
setInnerColor(newHexColor);
|
|
1008
929
|
updateColorRgb(newHexColor);
|
|
1009
930
|
}
|
|
@@ -1011,7 +932,7 @@ function ColorPicker(_ref) {
|
|
|
1011
932
|
}
|
|
1012
933
|
|
|
1013
934
|
function onAlphaInput(_alpha) {
|
|
1014
|
-
|
|
935
|
+
const numberValue = Number.parseInt(_alpha, 10);
|
|
1015
936
|
setInnerAlpha(numberValue);
|
|
1016
937
|
}
|
|
1017
938
|
|
|
@@ -1019,7 +940,7 @@ function ColorPicker(_ref) {
|
|
|
1019
940
|
setInnerAlpha(limitAlpha());
|
|
1020
941
|
}
|
|
1021
942
|
|
|
1022
|
-
|
|
943
|
+
const onChangeType = type => {
|
|
1023
944
|
setInputType(type);
|
|
1024
945
|
setSelectOpen(false);
|
|
1025
946
|
};
|
|
@@ -1046,21 +967,19 @@ function ColorPicker(_ref) {
|
|
|
1046
967
|
backgroundImage: getSaturationGradient()
|
|
1047
968
|
}
|
|
1048
969
|
}), /*#__PURE__*/React.createElement("div", {
|
|
1049
|
-
onClick:
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
},
|
|
970
|
+
onClick: ({
|
|
971
|
+
nativeEvent: {
|
|
972
|
+
offsetX,
|
|
973
|
+
offsetY
|
|
974
|
+
}
|
|
975
|
+
}) => updateGradient(offsetX, offsetY),
|
|
1055
976
|
className: "fwe-brightness-gradient"
|
|
1056
977
|
}), /*#__PURE__*/React.createElement(Draggable, {
|
|
1057
978
|
position: {
|
|
1058
979
|
x: saturationKnobOffset,
|
|
1059
980
|
y: valueKnobOffset
|
|
1060
981
|
},
|
|
1061
|
-
onDrag:
|
|
1062
|
-
return onGradientDrag(e, data);
|
|
1063
|
-
},
|
|
982
|
+
onDrag: (e, data) => onGradientDrag(e, data),
|
|
1064
983
|
bounds: "parent"
|
|
1065
984
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1066
985
|
className: "fwe-knob"
|
|
@@ -1068,23 +987,22 @@ function ColorPicker(_ref) {
|
|
|
1068
987
|
className: "fwe-hue-picker"
|
|
1069
988
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1070
989
|
className: "fwe-picker-background",
|
|
1071
|
-
onClick:
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
990
|
+
onClick: ({
|
|
991
|
+
nativeEvent: {
|
|
992
|
+
offsetY
|
|
993
|
+
}
|
|
994
|
+
}) => updateHue(offsetY)
|
|
1075
995
|
}), /*#__PURE__*/React.createElement(Draggable, {
|
|
1076
996
|
position: {
|
|
1077
997
|
x: 3,
|
|
1078
998
|
y: hueKnobOffset
|
|
1079
999
|
},
|
|
1080
|
-
onDrag:
|
|
1081
|
-
return onHueDrag(e, data);
|
|
1082
|
-
},
|
|
1000
|
+
onDrag: (e, data) => onHueDrag(e, data),
|
|
1083
1001
|
bounds: "parent"
|
|
1084
1002
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1085
1003
|
className: "fwe-knob",
|
|
1086
1004
|
style: {
|
|
1087
|
-
background:
|
|
1005
|
+
background: `hsl(${hsv.h * 360}, 100%, 50%)`
|
|
1088
1006
|
}
|
|
1089
1007
|
}))), useAlpha && /*#__PURE__*/React.createElement("div", {
|
|
1090
1008
|
className: "fwe-alpha-picker"
|
|
@@ -1139,22 +1057,21 @@ function ColorPicker(_ref) {
|
|
|
1139
1057
|
fill: "url(#bwsquare2px)",
|
|
1140
1058
|
strokeWidth: "0"
|
|
1141
1059
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1142
|
-
onClick:
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1060
|
+
onClick: ({
|
|
1061
|
+
nativeEvent: {
|
|
1062
|
+
offsetY
|
|
1063
|
+
}
|
|
1064
|
+
}) => updateAlpha(offsetY),
|
|
1146
1065
|
className: "fwe-picker-background",
|
|
1147
1066
|
style: {
|
|
1148
|
-
backgroundImage:
|
|
1067
|
+
backgroundImage: `linear-gradient( ${innerColor}, transparent)`
|
|
1149
1068
|
}
|
|
1150
1069
|
}), /*#__PURE__*/React.createElement(Draggable, {
|
|
1151
1070
|
position: {
|
|
1152
1071
|
x: 3,
|
|
1153
1072
|
y: alphaKnobOffset
|
|
1154
1073
|
},
|
|
1155
|
-
onDrag:
|
|
1156
|
-
return onAlphaDrag(e, data);
|
|
1157
|
-
},
|
|
1074
|
+
onDrag: (e, data) => onAlphaDrag(e, data),
|
|
1158
1075
|
bounds: "parent"
|
|
1159
1076
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1160
1077
|
className: "fwe-knob"
|
|
@@ -1164,11 +1081,7 @@ function ColorPicker(_ref) {
|
|
|
1164
1081
|
className: "fwe-type-select"
|
|
1165
1082
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1166
1083
|
className: "fwe-type-indicator",
|
|
1167
|
-
onClick:
|
|
1168
|
-
return setSelectOpen(function (prevOpen) {
|
|
1169
|
-
return !prevOpen;
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1084
|
+
onClick: () => setSelectOpen(prevOpen => !prevOpen)
|
|
1172
1085
|
}, /*#__PURE__*/React.createElement("span", {
|
|
1173
1086
|
className: "fwe-input-type"
|
|
1174
1087
|
}, inputType), /*#__PURE__*/React.createElement("i", {
|
|
@@ -1179,18 +1092,14 @@ function ColorPicker(_ref) {
|
|
|
1179
1092
|
className: classNames('fwe-type-item', {
|
|
1180
1093
|
'fwe-selected': inputType === 'HEX'
|
|
1181
1094
|
}),
|
|
1182
|
-
onClick:
|
|
1183
|
-
return onChangeType('HEX');
|
|
1184
|
-
}
|
|
1095
|
+
onClick: () => onChangeType('HEX')
|
|
1185
1096
|
}, /*#__PURE__*/React.createElement("i", {
|
|
1186
1097
|
className: "fwe-icon fwe-icon-menu-check"
|
|
1187
1098
|
}), " HEX"), /*#__PURE__*/React.createElement("div", {
|
|
1188
1099
|
className: classNames('fwe-type-item', {
|
|
1189
1100
|
'fwe-selected': inputType === 'RGB'
|
|
1190
1101
|
}),
|
|
1191
|
-
onClick:
|
|
1192
|
-
return onChangeType('RGB');
|
|
1193
|
-
}
|
|
1102
|
+
onClick: () => onChangeType('RGB')
|
|
1194
1103
|
}, /*#__PURE__*/React.createElement("i", {
|
|
1195
1104
|
className: "fwe-icon fwe-icon-menu-check"
|
|
1196
1105
|
}), " RGB"))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -1207,34 +1116,22 @@ function ColorPicker(_ref) {
|
|
|
1207
1116
|
}, /*#__PURE__*/React.createElement("input", {
|
|
1208
1117
|
type: "text",
|
|
1209
1118
|
value: redInput,
|
|
1210
|
-
onBlur:
|
|
1211
|
-
|
|
1212
|
-
},
|
|
1213
|
-
onChange: function onChange(e) {
|
|
1214
|
-
return onRgbInput(e.target.value, 'r');
|
|
1215
|
-
}
|
|
1119
|
+
onBlur: () => onRgbBlur('r'),
|
|
1120
|
+
onChange: e => onRgbInput(e.target.value, 'r')
|
|
1216
1121
|
})), /*#__PURE__*/React.createElement("label", {
|
|
1217
1122
|
className: "fwe-input-text fwe-green-input"
|
|
1218
1123
|
}, /*#__PURE__*/React.createElement("input", {
|
|
1219
1124
|
type: "text",
|
|
1220
1125
|
value: greenInput,
|
|
1221
|
-
onBlur:
|
|
1222
|
-
|
|
1223
|
-
},
|
|
1224
|
-
onChange: function onChange(e) {
|
|
1225
|
-
return onRgbInput(e.target.value, 'g');
|
|
1226
|
-
}
|
|
1126
|
+
onBlur: () => onRgbBlur('g'),
|
|
1127
|
+
onChange: e => onRgbInput(e.target.value, 'g')
|
|
1227
1128
|
})), /*#__PURE__*/React.createElement("label", {
|
|
1228
1129
|
className: "fwe-input-text fwe-green-input"
|
|
1229
1130
|
}, /*#__PURE__*/React.createElement("input", {
|
|
1230
1131
|
type: "text",
|
|
1231
1132
|
value: blueInput,
|
|
1232
|
-
onBlur:
|
|
1233
|
-
|
|
1234
|
-
},
|
|
1235
|
-
onChange: function onChange(e) {
|
|
1236
|
-
return onRgbInput(e.target.value, 'b');
|
|
1237
|
-
}
|
|
1133
|
+
onBlur: () => onRgbBlur('b'),
|
|
1134
|
+
onChange: e => onRgbInput(e.target.value, 'b')
|
|
1238
1135
|
}))), useAlpha && /*#__PURE__*/React.createElement("label", {
|
|
1239
1136
|
className: "fwe-input-text fwe-alpha-input fwe-ml-auto"
|
|
1240
1137
|
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("input", {
|
|
@@ -1242,12 +1139,8 @@ function ColorPicker(_ref) {
|
|
|
1242
1139
|
min: "0",
|
|
1243
1140
|
max: "100",
|
|
1244
1141
|
value: innerAlpha,
|
|
1245
|
-
onBlur:
|
|
1246
|
-
|
|
1247
|
-
},
|
|
1248
|
-
onChange: function onChange(e) {
|
|
1249
|
-
return onAlphaInput(e.target.value);
|
|
1250
|
-
}
|
|
1142
|
+
onBlur: () => onAlphaBlur(),
|
|
1143
|
+
onChange: e => onAlphaInput(e.target.value)
|
|
1251
1144
|
}), /*#__PURE__*/React.createElement("span", {
|
|
1252
1145
|
className: "fwe-percent-char"
|
|
1253
1146
|
}, "%"))))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -1309,8 +1202,8 @@ function ColorPicker(_ref) {
|
|
|
1309
1202
|
className: classNames('fwe-icon fwe-icon-menu-check', {
|
|
1310
1203
|
'fwe-color-text': !innerColor
|
|
1311
1204
|
})
|
|
1312
|
-
})), palette.map(
|
|
1313
|
-
|
|
1205
|
+
})), palette.map(colorItem => {
|
|
1206
|
+
const itemClasses = classNames('fwe-color-item', {
|
|
1314
1207
|
'fwe-white-item': colorItem.toUpperCase() === '#FFFFFF'
|
|
1315
1208
|
});
|
|
1316
1209
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1319,9 +1212,7 @@ function ColorPicker(_ref) {
|
|
|
1319
1212
|
style: {
|
|
1320
1213
|
background: colorItem
|
|
1321
1214
|
},
|
|
1322
|
-
onClick:
|
|
1323
|
-
return updateColorRgb(colorItem.toUpperCase());
|
|
1324
|
-
}
|
|
1215
|
+
onClick: () => updateColorRgb(colorItem.toUpperCase())
|
|
1325
1216
|
}, innerColor === colorItem.toUpperCase() && /*#__PURE__*/React.createElement("i", {
|
|
1326
1217
|
className: "fwe-icon fwe-icon-menu-check"
|
|
1327
1218
|
}));
|
|
@@ -1329,27 +1220,26 @@ function ColorPicker(_ref) {
|
|
|
1329
1220
|
}
|
|
1330
1221
|
|
|
1331
1222
|
function ConfirmModal(_a) {
|
|
1332
|
-
var
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1223
|
+
var {
|
|
1224
|
+
title,
|
|
1225
|
+
subtitle,
|
|
1226
|
+
body,
|
|
1227
|
+
className,
|
|
1228
|
+
cancel,
|
|
1229
|
+
ok,
|
|
1230
|
+
onCancel,
|
|
1231
|
+
onOk,
|
|
1232
|
+
isOpen
|
|
1233
|
+
} = _a,
|
|
1341
1234
|
props = __rest(_a, ["title", "subtitle", "body", "className", "cancel", "ok", "onCancel", "onOk", "isOpen"]);
|
|
1342
1235
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
setScrollableContent = _useState[1];
|
|
1346
|
-
|
|
1347
|
-
var ref = useCallback(function (node) {
|
|
1236
|
+
const [hasScrollableContent, setScrollableContent] = useState(false);
|
|
1237
|
+
const ref = useCallback(node => {
|
|
1348
1238
|
if (node !== null) {
|
|
1349
1239
|
setScrollableContent(node.scrollHeight > node.getBoundingClientRect().height);
|
|
1350
1240
|
}
|
|
1351
1241
|
}, []);
|
|
1352
|
-
useEffect(
|
|
1242
|
+
useEffect(() => {
|
|
1353
1243
|
if (!isOpen) {
|
|
1354
1244
|
setScrollableContent(false);
|
|
1355
1245
|
}
|
|
@@ -1381,33 +1271,25 @@ function ConfirmModal(_a) {
|
|
|
1381
1271
|
}, ok)));
|
|
1382
1272
|
}
|
|
1383
1273
|
|
|
1384
|
-
function DatePicker(
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
open = _useState[0],
|
|
1401
|
-
setOpen = _useState[1];
|
|
1402
|
-
|
|
1403
|
-
var _useState2 = useState(null),
|
|
1404
|
-
calendar = _useState2[0],
|
|
1405
|
-
setCalendar = _useState2[1];
|
|
1406
|
-
|
|
1407
|
-
var innerDefaultValue = value || defaultValue;
|
|
1274
|
+
function DatePicker({
|
|
1275
|
+
children,
|
|
1276
|
+
className,
|
|
1277
|
+
disabled,
|
|
1278
|
+
required,
|
|
1279
|
+
error,
|
|
1280
|
+
hint,
|
|
1281
|
+
value,
|
|
1282
|
+
defaultValue = new Date(),
|
|
1283
|
+
formatDate = Intl.DateTimeFormat().format,
|
|
1284
|
+
options,
|
|
1285
|
+
onChange
|
|
1286
|
+
}) {
|
|
1287
|
+
const [open, setOpen] = useState(false);
|
|
1288
|
+
const [calendar, setCalendar] = useState(null);
|
|
1289
|
+
const innerDefaultValue = value || defaultValue;
|
|
1408
1290
|
|
|
1409
1291
|
function toggle() {
|
|
1410
|
-
|
|
1292
|
+
const newOpen = !open;
|
|
1411
1293
|
setOpen(newOpen);
|
|
1412
1294
|
|
|
1413
1295
|
if (newOpen) {
|
|
@@ -1417,19 +1299,18 @@ function DatePicker(_ref) {
|
|
|
1417
1299
|
}
|
|
1418
1300
|
}
|
|
1419
1301
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
useEffect(function () {
|
|
1302
|
+
const datePickerRef = useRef(null);
|
|
1303
|
+
const {
|
|
1304
|
+
keepOpenOnDateChange,
|
|
1305
|
+
maxDate,
|
|
1306
|
+
minDate
|
|
1307
|
+
} = options || {};
|
|
1308
|
+
useEffect(() => {
|
|
1428
1309
|
if (calendar !== null && value !== undefined) {
|
|
1429
1310
|
calendar.setDate(value);
|
|
1430
1311
|
}
|
|
1431
1312
|
}, [calendar, value]);
|
|
1432
|
-
useEffect(
|
|
1313
|
+
useEffect(() => {
|
|
1433
1314
|
var _a;
|
|
1434
1315
|
|
|
1435
1316
|
function handleChange(date) {
|
|
@@ -1448,25 +1329,21 @@ function DatePicker(_ref) {
|
|
|
1448
1329
|
if (datePickerRef.current && calendar === null) {
|
|
1449
1330
|
setCalendar(flatpickr(datePickerRef.current, {
|
|
1450
1331
|
defaultDate: innerDefaultValue,
|
|
1451
|
-
onChange:
|
|
1452
|
-
return handleChange(v[0]);
|
|
1453
|
-
},
|
|
1332
|
+
onChange: v => handleChange(v[0]),
|
|
1454
1333
|
onClose: handleClose,
|
|
1455
1334
|
position: 'below center',
|
|
1456
|
-
formatDate
|
|
1335
|
+
formatDate,
|
|
1457
1336
|
closeOnSelect: (_a = !keepOpenOnDateChange) !== null && _a !== void 0 ? _a : true,
|
|
1458
1337
|
clickOpens: false,
|
|
1459
|
-
minDate
|
|
1460
|
-
maxDate
|
|
1338
|
+
minDate,
|
|
1339
|
+
maxDate
|
|
1461
1340
|
}));
|
|
1462
1341
|
}
|
|
1463
1342
|
}, [datePickerRef, calendar, maxDate, minDate, onChange, innerDefaultValue, formatDate, keepOpenOnDateChange]);
|
|
1464
|
-
useEffect(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1343
|
+
useEffect(() => () => {
|
|
1344
|
+
if (calendar !== null) {
|
|
1345
|
+
calendar.destroy();
|
|
1346
|
+
}
|
|
1470
1347
|
}, [calendar]);
|
|
1471
1348
|
return /*#__PURE__*/React.createElement("label", {
|
|
1472
1349
|
className: classNames('fwe-input-text fwe-input-text-icon', className),
|
|
@@ -1495,29 +1372,23 @@ function DatePicker(_ref) {
|
|
|
1495
1372
|
}, error));
|
|
1496
1373
|
}
|
|
1497
1374
|
|
|
1498
|
-
function DateRangePicker(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
open = _useState[0],
|
|
1513
|
-
setOpen = _useState[1];
|
|
1514
|
-
|
|
1515
|
-
var _useState2 = useState(null),
|
|
1516
|
-
calendar = _useState2[0],
|
|
1517
|
-
setCalendar = _useState2[1];
|
|
1375
|
+
function DateRangePicker({
|
|
1376
|
+
children,
|
|
1377
|
+
className,
|
|
1378
|
+
disabled,
|
|
1379
|
+
error,
|
|
1380
|
+
formatDate,
|
|
1381
|
+
hint,
|
|
1382
|
+
onChange,
|
|
1383
|
+
options,
|
|
1384
|
+
required,
|
|
1385
|
+
defaultValue = new Date()
|
|
1386
|
+
}) {
|
|
1387
|
+
const [open, setOpen] = useState(false);
|
|
1388
|
+
const [calendar, setCalendar] = useState(null);
|
|
1518
1389
|
|
|
1519
1390
|
function toggle() {
|
|
1520
|
-
|
|
1391
|
+
const newOpen = !open;
|
|
1521
1392
|
setOpen(newOpen);
|
|
1522
1393
|
|
|
1523
1394
|
if (newOpen) {
|
|
@@ -1527,10 +1398,10 @@ function DateRangePicker(_ref) {
|
|
|
1527
1398
|
}
|
|
1528
1399
|
}
|
|
1529
1400
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
useEffect(
|
|
1401
|
+
const inputRef = useRef(null);
|
|
1402
|
+
const input2Ref = useRef(null);
|
|
1403
|
+
const containerRef = useRef(null);
|
|
1404
|
+
useEffect(() => {
|
|
1534
1405
|
var _a;
|
|
1535
1406
|
|
|
1536
1407
|
function handleChange(dates) {
|
|
@@ -1551,12 +1422,10 @@ function DateRangePicker(_ref) {
|
|
|
1551
1422
|
plugins: [rangePlugin({
|
|
1552
1423
|
input: input2Ref.current
|
|
1553
1424
|
})],
|
|
1554
|
-
onChange:
|
|
1555
|
-
return handleChange(v);
|
|
1556
|
-
},
|
|
1425
|
+
onChange: v => handleChange(v),
|
|
1557
1426
|
position: 'below center',
|
|
1558
1427
|
positionElement: containerRef.current,
|
|
1559
|
-
formatDate
|
|
1428
|
+
formatDate,
|
|
1560
1429
|
closeOnSelect: (_a = !(options === null || options === void 0 ? void 0 : options.keepOpenOnDateChange)) !== null && _a !== void 0 ? _a : true,
|
|
1561
1430
|
clickOpens: false,
|
|
1562
1431
|
onClose: handleClose,
|
|
@@ -1565,12 +1434,10 @@ function DateRangePicker(_ref) {
|
|
|
1565
1434
|
}));
|
|
1566
1435
|
}
|
|
1567
1436
|
}, [inputRef, input2Ref, containerRef, formatDate, options, onChange, calendar, defaultValue]);
|
|
1568
|
-
useEffect(
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
}
|
|
1573
|
-
};
|
|
1437
|
+
useEffect(() => () => {
|
|
1438
|
+
if (calendar !== null) {
|
|
1439
|
+
calendar.destroy();
|
|
1440
|
+
}
|
|
1574
1441
|
}, [calendar]);
|
|
1575
1442
|
return /*#__PURE__*/React.createElement("div", {
|
|
1576
1443
|
className: classNames('fr-date-range-picker', className),
|
|
@@ -1616,16 +1483,15 @@ function DateRangePicker(_ref) {
|
|
|
1616
1483
|
}, error)));
|
|
1617
1484
|
}
|
|
1618
1485
|
|
|
1619
|
-
function LinkButton(
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
var classes = classNames('fwe-btn', 'fwe-btn-link', {
|
|
1486
|
+
function LinkButton({
|
|
1487
|
+
icon,
|
|
1488
|
+
onClick,
|
|
1489
|
+
disabled = false,
|
|
1490
|
+
children,
|
|
1491
|
+
iconOnly = false,
|
|
1492
|
+
className
|
|
1493
|
+
}) {
|
|
1494
|
+
const classes = classNames('fwe-btn', 'fwe-btn-link', {
|
|
1629
1495
|
'fwe-disabled': disabled
|
|
1630
1496
|
}, className);
|
|
1631
1497
|
return /*#__PURE__*/React.createElement("button", {
|
|
@@ -1634,16 +1500,16 @@ function LinkButton(_ref) {
|
|
|
1634
1500
|
className: classes,
|
|
1635
1501
|
disabled: disabled
|
|
1636
1502
|
}, /*#__PURE__*/React.createElement("i", {
|
|
1637
|
-
className:
|
|
1503
|
+
className: `fwe-icon fwe-icon-${icon}`
|
|
1638
1504
|
}), !iconOnly && children);
|
|
1639
1505
|
}
|
|
1640
1506
|
|
|
1641
|
-
function LoadingIndicator(
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1507
|
+
function LoadingIndicator({
|
|
1508
|
+
size = 'large',
|
|
1509
|
+
children,
|
|
1510
|
+
className
|
|
1511
|
+
}) {
|
|
1512
|
+
const classes = classNames('fwe-waiting-indicator', {
|
|
1647
1513
|
'fwe-waiting-indicator-md': size === 'medium'
|
|
1648
1514
|
}, {
|
|
1649
1515
|
'fwe-waiting-indicator-sm': size === 'small'
|
|
@@ -1670,22 +1536,18 @@ var PaginationType;
|
|
|
1670
1536
|
})(PaginationType || (PaginationType = {}));
|
|
1671
1537
|
|
|
1672
1538
|
function Pagination(props) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
setInnerPageCurrent = _useState[1];
|
|
1686
|
-
|
|
1687
|
-
var dotArray = Array.from(new Array(pageMax).keys());
|
|
1688
|
-
useEffect(function () {
|
|
1539
|
+
const {
|
|
1540
|
+
pageMax,
|
|
1541
|
+
onChange,
|
|
1542
|
+
pageCurrent,
|
|
1543
|
+
defaultPageCurrent = 1,
|
|
1544
|
+
type = PaginationType.Numeric,
|
|
1545
|
+
className
|
|
1546
|
+
} = props;
|
|
1547
|
+
const controlled = pageCurrent !== undefined;
|
|
1548
|
+
const [innerPageCurrent, setInnerPageCurrent] = useState(controlled ? pageCurrent : defaultPageCurrent);
|
|
1549
|
+
const dotArray = Array.from(new Array(pageMax).keys());
|
|
1550
|
+
useEffect(() => {
|
|
1689
1551
|
if (controlled) {
|
|
1690
1552
|
setInnerPageCurrent(pageCurrent);
|
|
1691
1553
|
}
|
|
@@ -1703,20 +1565,20 @@ function Pagination(props) {
|
|
|
1703
1565
|
|
|
1704
1566
|
function onBtnDown() {
|
|
1705
1567
|
if (innerPageCurrent > 1) {
|
|
1706
|
-
|
|
1568
|
+
const newPageCurrent = innerPageCurrent - 1;
|
|
1707
1569
|
handleChange(newPageCurrent);
|
|
1708
1570
|
}
|
|
1709
1571
|
}
|
|
1710
1572
|
|
|
1711
1573
|
function onBtnUp() {
|
|
1712
1574
|
if (innerPageCurrent < pageMax) {
|
|
1713
|
-
|
|
1575
|
+
const newPageCurrent = innerPageCurrent + 1;
|
|
1714
1576
|
handleChange(newPageCurrent);
|
|
1715
1577
|
}
|
|
1716
1578
|
}
|
|
1717
1579
|
|
|
1718
1580
|
function onDotClick(index) {
|
|
1719
|
-
|
|
1581
|
+
const newPageCurrent = index + 1;
|
|
1720
1582
|
handleChange(newPageCurrent);
|
|
1721
1583
|
}
|
|
1722
1584
|
|
|
@@ -1755,33 +1617,26 @@ function Pagination(props) {
|
|
|
1755
1617
|
}, className)
|
|
1756
1618
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1757
1619
|
className: "fwe-pagination"
|
|
1758
|
-
}, dotArray.map(
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
"aria-label": "page-dot",
|
|
1770
|
-
onKeyPress: function onKeyPress(e) {
|
|
1771
|
-
return handleKeyPress(e, index);
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
}))));
|
|
1620
|
+
}, dotArray.map(index => /*#__PURE__*/React.createElement("span", {
|
|
1621
|
+
tabIndex: 0,
|
|
1622
|
+
role: "button",
|
|
1623
|
+
key: index,
|
|
1624
|
+
className: classNames('fwe-page-dot', {
|
|
1625
|
+
'fwe-selected': index + 1 === innerPageCurrent
|
|
1626
|
+
}),
|
|
1627
|
+
onClick: () => onDotClick(index),
|
|
1628
|
+
"aria-label": "page-dot",
|
|
1629
|
+
onKeyPress: e => handleKeyPress(e, index)
|
|
1630
|
+
})))));
|
|
1775
1631
|
}
|
|
1776
1632
|
|
|
1777
|
-
function Progress(
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
var classes = classNames('fwe-progress-bar', {
|
|
1633
|
+
function Progress({
|
|
1634
|
+
background = 'white',
|
|
1635
|
+
error = false,
|
|
1636
|
+
progress,
|
|
1637
|
+
className
|
|
1638
|
+
}) {
|
|
1639
|
+
const classes = classNames('fwe-progress-bar', {
|
|
1785
1640
|
'fwe-bg-red': error
|
|
1786
1641
|
}, {
|
|
1787
1642
|
'fwe-progress-bar-black': background === 'black'
|
|
@@ -1794,7 +1649,7 @@ function Progress(_ref) {
|
|
|
1794
1649
|
className: classes,
|
|
1795
1650
|
role: "progressbar",
|
|
1796
1651
|
style: {
|
|
1797
|
-
width: progress
|
|
1652
|
+
width: `${progress}%`
|
|
1798
1653
|
},
|
|
1799
1654
|
"aria-valuenow": progress,
|
|
1800
1655
|
"aria-valuemin": 0,
|
|
@@ -1803,16 +1658,16 @@ function Progress(_ref) {
|
|
|
1803
1658
|
}));
|
|
1804
1659
|
}
|
|
1805
1660
|
|
|
1806
|
-
function Tabs(
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1661
|
+
function Tabs({
|
|
1662
|
+
config,
|
|
1663
|
+
children,
|
|
1664
|
+
className,
|
|
1665
|
+
onChange
|
|
1666
|
+
}) {
|
|
1812
1667
|
var _a, _b, _c;
|
|
1813
1668
|
|
|
1814
|
-
|
|
1815
|
-
React.Children.forEach(children,
|
|
1669
|
+
let activeId = '';
|
|
1670
|
+
React.Children.forEach(children, element => {
|
|
1816
1671
|
if ( /*#__PURE__*/React.isValidElement(element)) {
|
|
1817
1672
|
if (activeId === '') {
|
|
1818
1673
|
activeId = element.props.id;
|
|
@@ -1821,12 +1676,8 @@ function Tabs(_ref) {
|
|
|
1821
1676
|
}
|
|
1822
1677
|
}
|
|
1823
1678
|
});
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
currentId = _useState[0],
|
|
1827
|
-
setId = _useState[1];
|
|
1828
|
-
|
|
1829
|
-
var tabListClasses = classNames('fwe-tab-bar', {
|
|
1679
|
+
const [currentId, setId] = useState(activeId);
|
|
1680
|
+
const tabListClasses = classNames('fwe-tab-bar', {
|
|
1830
1681
|
'fwe-tab-bar-full-width': (_a = config.tabBar) === null || _a === void 0 ? void 0 : _a.fullWidth
|
|
1831
1682
|
}, {
|
|
1832
1683
|
'fwe-tab-items-equal-width': ((_b = config.tabItems) === null || _b === void 0 ? void 0 : _b.appearance) === 'equal'
|
|
@@ -1834,7 +1685,7 @@ function Tabs(_ref) {
|
|
|
1834
1685
|
'fwe-tab-items-fill': ((_c = config.tabItems) === null || _c === void 0 ? void 0 : _c.appearance) === 'fill'
|
|
1835
1686
|
});
|
|
1836
1687
|
|
|
1837
|
-
|
|
1688
|
+
const showTabPane = id => {
|
|
1838
1689
|
if (onChange) {
|
|
1839
1690
|
onChange({
|
|
1840
1691
|
previous: currentId,
|
|
@@ -1845,7 +1696,7 @@ function Tabs(_ref) {
|
|
|
1845
1696
|
setId(id);
|
|
1846
1697
|
};
|
|
1847
1698
|
|
|
1848
|
-
|
|
1699
|
+
const innerChildren = React.Children.map(children, element => {
|
|
1849
1700
|
if ( /*#__PURE__*/isValidElement(element)) {
|
|
1850
1701
|
return /*#__PURE__*/React.cloneElement(element, {
|
|
1851
1702
|
isVisible: element.props.id === currentId,
|
|
@@ -1860,27 +1711,26 @@ function Tabs(_ref) {
|
|
|
1860
1711
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
1861
1712
|
role: "tablist",
|
|
1862
1713
|
className: tabListClasses
|
|
1863
|
-
}, innerChildren.map(
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1714
|
+
}, innerChildren.map(child => {
|
|
1715
|
+
const {
|
|
1716
|
+
id,
|
|
1717
|
+
active,
|
|
1718
|
+
icon,
|
|
1719
|
+
name
|
|
1720
|
+
} = child.props;
|
|
1869
1721
|
return /*#__PURE__*/React.createElement("li", {
|
|
1870
1722
|
key: id,
|
|
1871
1723
|
className: classNames('fwe-tab-item', {
|
|
1872
1724
|
'fwe-active': active
|
|
1873
1725
|
}),
|
|
1874
|
-
onClick:
|
|
1875
|
-
return showTabPane(id);
|
|
1876
|
-
}
|
|
1726
|
+
onClick: () => showTabPane(id)
|
|
1877
1727
|
}, child.props.icon ? /*#__PURE__*/React.createElement("a", {
|
|
1878
1728
|
className: "fwe-tab-link",
|
|
1879
1729
|
role: "tab",
|
|
1880
1730
|
"aria-controls": id,
|
|
1881
1731
|
"aria-selected": active
|
|
1882
1732
|
}, /*#__PURE__*/React.createElement("i", {
|
|
1883
|
-
className:
|
|
1733
|
+
className: `fwe-icon ${icon}`
|
|
1884
1734
|
}), /*#__PURE__*/React.createElement("span", null, name)) : /*#__PURE__*/React.createElement("a", {
|
|
1885
1735
|
className: "fwe-tab-link",
|
|
1886
1736
|
role: "tab",
|
|
@@ -1892,12 +1742,12 @@ function Tabs(_ref) {
|
|
|
1892
1742
|
}, innerChildren));
|
|
1893
1743
|
}
|
|
1894
1744
|
|
|
1895
|
-
function TabPane(
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1745
|
+
function TabPane({
|
|
1746
|
+
isVisible = false,
|
|
1747
|
+
children,
|
|
1748
|
+
className
|
|
1749
|
+
}) {
|
|
1750
|
+
const tabPaneClasses = classNames({
|
|
1901
1751
|
'fr-show': isVisible
|
|
1902
1752
|
}, {
|
|
1903
1753
|
'fr-hide': !isVisible
|
|
@@ -1908,40 +1758,31 @@ function TabPane(_ref) {
|
|
|
1908
1758
|
}
|
|
1909
1759
|
|
|
1910
1760
|
function Checkbox(_a) {
|
|
1911
|
-
var
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
indeterminate = _a$indeterminate === void 0 ? false : _a$indeterminate,
|
|
1926
|
-
children = _a.children,
|
|
1927
|
-
className = _a.className,
|
|
1761
|
+
var {
|
|
1762
|
+
id,
|
|
1763
|
+
checked,
|
|
1764
|
+
onChange,
|
|
1765
|
+
name,
|
|
1766
|
+
large = false,
|
|
1767
|
+
valid = true,
|
|
1768
|
+
labelPosition = 'after',
|
|
1769
|
+
required,
|
|
1770
|
+
disabled = false,
|
|
1771
|
+
indeterminate = false,
|
|
1772
|
+
children,
|
|
1773
|
+
className
|
|
1774
|
+
} = _a,
|
|
1928
1775
|
props = __rest(_a, ["id", "checked", "onChange", "name", "large", "valid", "labelPosition", "required", "disabled", "indeterminate", "children", "className"]);
|
|
1929
1776
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
var _useState2 = useState(indeterminate),
|
|
1935
|
-
isIndeterminate = _useState2[0],
|
|
1936
|
-
setIndeterminate = _useState2[1];
|
|
1937
|
-
|
|
1938
|
-
useEffect(function () {
|
|
1777
|
+
const [isChecked, setChecked] = useState(checked);
|
|
1778
|
+
const [isIndeterminate, setIndeterminate] = useState(indeterminate);
|
|
1779
|
+
useEffect(() => {
|
|
1939
1780
|
setChecked(checked);
|
|
1940
1781
|
setIndeterminate(indeterminate);
|
|
1941
1782
|
}, [checked, indeterminate]);
|
|
1942
1783
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1784
|
+
const handleChange = () => {
|
|
1785
|
+
const newChecked = !isChecked;
|
|
1945
1786
|
|
|
1946
1787
|
if (indeterminate) {
|
|
1947
1788
|
setIndeterminate(false);
|
|
@@ -1951,7 +1792,7 @@ function Checkbox(_a) {
|
|
|
1951
1792
|
onChange(newChecked);
|
|
1952
1793
|
};
|
|
1953
1794
|
|
|
1954
|
-
|
|
1795
|
+
const containerClasses = classNames('fwe-checkbox-container', {
|
|
1955
1796
|
'fr-checkbox-large': large
|
|
1956
1797
|
}, {
|
|
1957
1798
|
'fr-checkbox-invalid': !valid || required
|
|
@@ -1974,9 +1815,7 @@ function Checkbox(_a) {
|
|
|
1974
1815
|
type: "checkbox",
|
|
1975
1816
|
id: id,
|
|
1976
1817
|
disabled: disabled,
|
|
1977
|
-
onChange:
|
|
1978
|
-
return handleChange();
|
|
1979
|
-
}
|
|
1818
|
+
onChange: () => handleChange()
|
|
1980
1819
|
}, props)), /*#__PURE__*/React.createElement("div", {
|
|
1981
1820
|
className: "fwe-checkbox-indicator-container"
|
|
1982
1821
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -2001,35 +1840,31 @@ function Checkbox(_a) {
|
|
|
2001
1840
|
}, children));
|
|
2002
1841
|
}
|
|
2003
1842
|
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
function RadioButton(
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
groupValue = _useContext.value;
|
|
2030
|
-
|
|
2031
|
-
var innerLabelPosition = groupLabelPosition || labelPosition;
|
|
2032
|
-
var classes = classNames('fwe-radio', {
|
|
1843
|
+
const RadioGroupContext = /*#__PURE__*/createContext({});
|
|
1844
|
+
|
|
1845
|
+
function RadioButton({
|
|
1846
|
+
id,
|
|
1847
|
+
onChange,
|
|
1848
|
+
value,
|
|
1849
|
+
name,
|
|
1850
|
+
checked,
|
|
1851
|
+
labelPosition = 'after',
|
|
1852
|
+
large = false,
|
|
1853
|
+
disabled = false,
|
|
1854
|
+
required = false,
|
|
1855
|
+
children,
|
|
1856
|
+
className
|
|
1857
|
+
}) {
|
|
1858
|
+
const {
|
|
1859
|
+
disabled: groupDisabled,
|
|
1860
|
+
labelPosition: groupLabelPosition,
|
|
1861
|
+
large: groupLarge,
|
|
1862
|
+
name: groupName,
|
|
1863
|
+
required: groupRequired,
|
|
1864
|
+
value: groupValue
|
|
1865
|
+
} = useContext(RadioGroupContext);
|
|
1866
|
+
const innerLabelPosition = groupLabelPosition || labelPosition;
|
|
1867
|
+
const classes = classNames('fwe-radio', {
|
|
2033
1868
|
'fwe-radio-label-below': innerLabelPosition === 'below'
|
|
2034
1869
|
}, {
|
|
2035
1870
|
'fwe-radio-label-before': innerLabelPosition === 'before'
|
|
@@ -2045,9 +1880,7 @@ function RadioButton(_ref) {
|
|
|
2045
1880
|
id: id,
|
|
2046
1881
|
name: groupName || name,
|
|
2047
1882
|
value: value || groupValue,
|
|
2048
|
-
onChange:
|
|
2049
|
-
return _onChange(value);
|
|
2050
|
-
},
|
|
1883
|
+
onChange: () => onChange(value),
|
|
2051
1884
|
disabled: disabled || groupDisabled,
|
|
2052
1885
|
required: required || groupRequired
|
|
2053
1886
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -2057,21 +1890,23 @@ function RadioButton(_ref) {
|
|
|
2057
1890
|
}, children));
|
|
2058
1891
|
}
|
|
2059
1892
|
|
|
2060
|
-
|
|
1893
|
+
const defaultConfig$1 = {
|
|
2061
1894
|
outline: true,
|
|
2062
1895
|
iconOnly: true
|
|
2063
1896
|
};
|
|
2064
1897
|
function Segment(props) {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
1898
|
+
const {
|
|
1899
|
+
children,
|
|
1900
|
+
legend,
|
|
1901
|
+
config,
|
|
1902
|
+
onChange,
|
|
1903
|
+
className
|
|
1904
|
+
} = props;
|
|
1905
|
+
const innerConfig = Object.assign(Object.assign({}, defaultConfig$1), config);
|
|
1906
|
+
let useIcon = false;
|
|
1907
|
+
let useIconAndText = false;
|
|
1908
|
+
let tmpValue = '';
|
|
1909
|
+
React.Children.forEach(children, (child, index) => {
|
|
2075
1910
|
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
2076
1911
|
return null;
|
|
2077
1912
|
}
|
|
@@ -2090,12 +1925,9 @@ function Segment(props) {
|
|
|
2090
1925
|
|
|
2091
1926
|
return null;
|
|
2092
1927
|
});
|
|
1928
|
+
const [value, setValue] = useState(tmpValue);
|
|
2093
1929
|
|
|
2094
|
-
|
|
2095
|
-
value = _useState[0],
|
|
2096
|
-
setValue = _useState[1];
|
|
2097
|
-
|
|
2098
|
-
var handleChange = function handleChange(event, _value) {
|
|
1930
|
+
const handleChange = (event, _value) => {
|
|
2099
1931
|
if (onChange) {
|
|
2100
1932
|
onChange(event, _value);
|
|
2101
1933
|
}
|
|
@@ -2111,15 +1943,15 @@ function Segment(props) {
|
|
|
2111
1943
|
}, className)
|
|
2112
1944
|
}, /*#__PURE__*/React.createElement("legend", null, legend), /*#__PURE__*/React.createElement("div", {
|
|
2113
1945
|
className: "fwe-segment-group"
|
|
2114
|
-
}, React.Children.map(children,
|
|
1946
|
+
}, React.Children.map(children, child => {
|
|
2115
1947
|
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
2116
1948
|
return null;
|
|
2117
1949
|
}
|
|
2118
1950
|
|
|
2119
|
-
|
|
1951
|
+
const id = (Math.random() * Date.now()).toString().replace('.', '-');
|
|
2120
1952
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
2121
1953
|
key: id,
|
|
2122
|
-
id
|
|
1954
|
+
id,
|
|
2123
1955
|
onChange: handleChange,
|
|
2124
1956
|
iconOnly: innerConfig.iconOnly,
|
|
2125
1957
|
checked: child.props.value === value
|
|
@@ -2128,24 +1960,25 @@ function Segment(props) {
|
|
|
2128
1960
|
}
|
|
2129
1961
|
|
|
2130
1962
|
function SegmentControl(props) {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
1963
|
+
const {
|
|
1964
|
+
label,
|
|
1965
|
+
checked,
|
|
1966
|
+
disabled,
|
|
1967
|
+
name,
|
|
1968
|
+
value,
|
|
1969
|
+
icon,
|
|
1970
|
+
onChange,
|
|
1971
|
+
iconOnly,
|
|
1972
|
+
id = (Math.random() * Date.now()).toString().replace('.', '-'),
|
|
1973
|
+
className
|
|
1974
|
+
} = props;
|
|
1975
|
+
let viewMode = 'text';
|
|
2143
1976
|
|
|
2144
1977
|
if (icon) {
|
|
2145
1978
|
viewMode = iconOnly ? 'icon' : 'icon-text';
|
|
2146
1979
|
}
|
|
2147
1980
|
|
|
2148
|
-
|
|
1981
|
+
const handleChange = event => {
|
|
2149
1982
|
if (onChange) {
|
|
2150
1983
|
onChange(event, value);
|
|
2151
1984
|
}
|
|
@@ -2159,9 +1992,7 @@ function SegmentControl(props) {
|
|
|
2159
1992
|
value: value,
|
|
2160
1993
|
checked: checked,
|
|
2161
1994
|
disabled: disabled,
|
|
2162
|
-
onChange:
|
|
2163
|
-
return handleChange(e);
|
|
2164
|
-
}
|
|
1995
|
+
onChange: e => handleChange(e)
|
|
2165
1996
|
}), /*#__PURE__*/React.createElement("label", {
|
|
2166
1997
|
className: classNames('fwe-segment-label', className),
|
|
2167
1998
|
htmlFor: id
|
|
@@ -2169,16 +2000,18 @@ function SegmentControl(props) {
|
|
|
2169
2000
|
className: "fwe-sr-only"
|
|
2170
2001
|
}, label), /*#__PURE__*/React.createElement("i", {
|
|
2171
2002
|
"aria-hidden": "true",
|
|
2172
|
-
className: classNames('fwe-icon',
|
|
2003
|
+
className: classNames('fwe-icon', `fwe-icon-${icon}`)
|
|
2173
2004
|
})), viewMode === 'text' && label, viewMode === 'icon-text' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
2174
2005
|
"aria-hidden": "true",
|
|
2175
|
-
className: classNames('fwe-icon',
|
|
2006
|
+
className: classNames('fwe-icon', `fwe-icon-${icon}`)
|
|
2176
2007
|
}), label)));
|
|
2177
2008
|
}
|
|
2178
2009
|
|
|
2179
|
-
|
|
2180
|
-
var
|
|
2181
|
-
|
|
2010
|
+
const SelectOption = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
2011
|
+
var {
|
|
2012
|
+
children,
|
|
2013
|
+
className
|
|
2014
|
+
} = _a,
|
|
2182
2015
|
props = __rest(_a, ["children", "className"]);
|
|
2183
2016
|
|
|
2184
2017
|
return /*#__PURE__*/React.createElement("span", Object.assign({
|
|
@@ -2188,8 +2021,8 @@ var SelectOption = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2188
2021
|
});
|
|
2189
2022
|
|
|
2190
2023
|
function calcVirtualScrollHeight(config, itemLength) {
|
|
2191
|
-
|
|
2192
|
-
|
|
2024
|
+
const defaultHeight = 48;
|
|
2025
|
+
let height = defaultHeight;
|
|
2193
2026
|
|
|
2194
2027
|
if (itemLength === 2) {
|
|
2195
2028
|
height = defaultHeight * 2;
|
|
@@ -2208,40 +2041,34 @@ function calcVirtualScrollHeight(config, itemLength) {
|
|
|
2208
2041
|
return height;
|
|
2209
2042
|
}
|
|
2210
2043
|
|
|
2211
|
-
|
|
2212
|
-
var
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2044
|
+
const Select = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
2045
|
+
var {
|
|
2046
|
+
defaultValue,
|
|
2047
|
+
value,
|
|
2048
|
+
label,
|
|
2049
|
+
options,
|
|
2050
|
+
onChange,
|
|
2051
|
+
required = false,
|
|
2052
|
+
config,
|
|
2053
|
+
disabled,
|
|
2054
|
+
className,
|
|
2055
|
+
name,
|
|
2056
|
+
id,
|
|
2057
|
+
children,
|
|
2058
|
+
hint,
|
|
2059
|
+
error
|
|
2060
|
+
} = _a,
|
|
2227
2061
|
props = __rest(_a, ["defaultValue", "value", "label", "options", "onChange", "required", "config", "disabled", "className", "name", "id", "children", "hint", "error"]);
|
|
2228
2062
|
|
|
2229
|
-
|
|
2063
|
+
const [optionsWrapper, setOptionsWrapper] = useState({
|
|
2230
2064
|
isFocused: false,
|
|
2231
2065
|
action: ''
|
|
2232
|
-
})
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
var _useState2 = useState(controlled ? value : defaultValue),
|
|
2239
|
-
innerValue = _useState2[0],
|
|
2240
|
-
setInnerValue = _useState2[1];
|
|
2241
|
-
|
|
2242
|
-
var buttonEl = useRef(null);
|
|
2243
|
-
var childrenList = [];
|
|
2244
|
-
React.Children.forEach(children, function (element) {
|
|
2066
|
+
});
|
|
2067
|
+
const controlled = value !== undefined;
|
|
2068
|
+
const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
|
|
2069
|
+
const buttonEl = useRef(null);
|
|
2070
|
+
const childrenList = [];
|
|
2071
|
+
React.Children.forEach(children, element => {
|
|
2245
2072
|
if ( /*#__PURE__*/React.isValidElement(element)) {
|
|
2246
2073
|
childrenList.push(Object.assign(Object.assign({}, element), {
|
|
2247
2074
|
props: Object.assign(Object.assign({}, element.props), {
|
|
@@ -2250,31 +2077,25 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2250
2077
|
}));
|
|
2251
2078
|
}
|
|
2252
2079
|
});
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
});
|
|
2256
|
-
var listItemRef = useRef(Array.from({
|
|
2080
|
+
const usedOptions = options !== null && options !== void 0 ? options : childrenList.map(child => child.props.option);
|
|
2081
|
+
const listItemRef = useRef(Array.from({
|
|
2257
2082
|
length: usedOptions.length
|
|
2258
|
-
},
|
|
2259
|
-
|
|
2260
|
-
}));
|
|
2261
|
-
useEffect(function () {
|
|
2083
|
+
}, () => /*#__PURE__*/React.createRef()));
|
|
2084
|
+
useEffect(() => {
|
|
2262
2085
|
if (controlled) {
|
|
2263
2086
|
setInnerValue(value);
|
|
2264
2087
|
}
|
|
2265
2088
|
}, [value, controlled]);
|
|
2266
|
-
|
|
2089
|
+
const getSelectedOptionLabel = useCallback(() => {
|
|
2267
2090
|
var _a;
|
|
2268
2091
|
|
|
2269
2092
|
if (innerValue !== undefined) {
|
|
2270
|
-
return (_a = usedOptions.find(
|
|
2271
|
-
return option.data === innerValue;
|
|
2272
|
-
})) === null || _a === void 0 ? void 0 : _a.label;
|
|
2093
|
+
return (_a = usedOptions.find(option => option.data === innerValue)) === null || _a === void 0 ? void 0 : _a.label;
|
|
2273
2094
|
}
|
|
2274
2095
|
|
|
2275
2096
|
return undefined;
|
|
2276
2097
|
}, [usedOptions, innerValue]);
|
|
2277
|
-
|
|
2098
|
+
const scroll = config === null || config === void 0 ? void 0 : config.scroll;
|
|
2278
2099
|
|
|
2279
2100
|
function handleButtonFocus(blur) {
|
|
2280
2101
|
if (buttonEl && buttonEl.current) {
|
|
@@ -2286,9 +2107,9 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2286
2107
|
}
|
|
2287
2108
|
}
|
|
2288
2109
|
|
|
2289
|
-
|
|
2110
|
+
const focusNextElement = nextIndex => {
|
|
2290
2111
|
if (listItemRef && listItemRef.current) {
|
|
2291
|
-
|
|
2112
|
+
const nextItem = listItemRef.current[nextIndex].current;
|
|
2292
2113
|
|
|
2293
2114
|
if (nextItem !== null) {
|
|
2294
2115
|
nextItem.focus();
|
|
@@ -2296,12 +2117,10 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2296
2117
|
}
|
|
2297
2118
|
};
|
|
2298
2119
|
|
|
2299
|
-
useEffect(
|
|
2120
|
+
useEffect(() => {
|
|
2300
2121
|
if (optionsWrapper.isFocused) {
|
|
2301
2122
|
if (optionsWrapper.action === 'key') {
|
|
2302
|
-
|
|
2303
|
-
return option.label === getSelectedOptionLabel();
|
|
2304
|
-
});
|
|
2123
|
+
const index = usedOptions.findIndex(option => option.label === getSelectedOptionLabel());
|
|
2305
2124
|
|
|
2306
2125
|
if (index >= 0) {
|
|
2307
2126
|
focusNextElement(index);
|
|
@@ -2312,7 +2131,7 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2312
2131
|
}
|
|
2313
2132
|
}, [optionsWrapper, usedOptions, innerValue, getSelectedOptionLabel]);
|
|
2314
2133
|
|
|
2315
|
-
|
|
2134
|
+
const handleOptionChange = newOption => {
|
|
2316
2135
|
if (!controlled) {
|
|
2317
2136
|
setInnerValue(newOption.data);
|
|
2318
2137
|
}
|
|
@@ -2321,20 +2140,18 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2321
2140
|
onChange(newOption.data);
|
|
2322
2141
|
}
|
|
2323
2142
|
|
|
2324
|
-
setOptionsWrapper(
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
});
|
|
2328
|
-
});
|
|
2143
|
+
setOptionsWrapper(prevOptionsWrapper => Object.assign(Object.assign({}, prevOptionsWrapper), {
|
|
2144
|
+
isFocused: false
|
|
2145
|
+
}));
|
|
2329
2146
|
|
|
2330
2147
|
if (buttonEl && buttonEl.current) {
|
|
2331
2148
|
buttonEl.current.focus();
|
|
2332
2149
|
}
|
|
2333
2150
|
};
|
|
2334
2151
|
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2152
|
+
const handleListKeyDown = (event, option, index) => {
|
|
2153
|
+
const arrowKeys = ['ArrowDown', 'ArrowUp'];
|
|
2154
|
+
const validKeys = ['Enter', ' '];
|
|
2338
2155
|
|
|
2339
2156
|
if (arrowKeys.concat(validKeys).includes(event.key)) {
|
|
2340
2157
|
event.preventDefault();
|
|
@@ -2346,7 +2163,7 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2346
2163
|
|
|
2347
2164
|
if (event.key === 'ArrowUp') {
|
|
2348
2165
|
event.preventDefault();
|
|
2349
|
-
|
|
2166
|
+
let nextIndex = (index - 1) % usedOptions.length;
|
|
2350
2167
|
|
|
2351
2168
|
if (nextIndex < 0) {
|
|
2352
2169
|
nextIndex += usedOptions.length;
|
|
@@ -2361,47 +2178,41 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2361
2178
|
}
|
|
2362
2179
|
|
|
2363
2180
|
if (event.key === 'Escape') {
|
|
2364
|
-
setOptionsWrapper(
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
});
|
|
2368
|
-
});
|
|
2181
|
+
setOptionsWrapper(prevOptionsWrapper => Object.assign(Object.assign({}, prevOptionsWrapper), {
|
|
2182
|
+
isFocused: false
|
|
2183
|
+
}));
|
|
2369
2184
|
handleButtonFocus();
|
|
2370
2185
|
}
|
|
2371
2186
|
};
|
|
2372
2187
|
|
|
2373
|
-
|
|
2374
|
-
|
|
2188
|
+
const handleKeyPress = event => {
|
|
2189
|
+
const validKeys = ['Enter', ' ', 'ArrowUp', 'ArrowDown'];
|
|
2375
2190
|
|
|
2376
2191
|
if (validKeys.includes(event.key)) {
|
|
2377
2192
|
event.preventDefault();
|
|
2378
2193
|
|
|
2379
2194
|
if (!disabled) {
|
|
2380
|
-
setOptionsWrapper(
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
};
|
|
2385
|
-
});
|
|
2195
|
+
setOptionsWrapper(prevOptionsWrapper => ({
|
|
2196
|
+
action: 'key',
|
|
2197
|
+
isFocused: !prevOptionsWrapper.isFocused
|
|
2198
|
+
}));
|
|
2386
2199
|
}
|
|
2387
2200
|
}
|
|
2388
2201
|
};
|
|
2389
2202
|
|
|
2390
|
-
|
|
2203
|
+
const handleClick = e => {
|
|
2391
2204
|
e.stopPropagation();
|
|
2392
2205
|
|
|
2393
2206
|
if (!disabled) {
|
|
2394
|
-
setOptionsWrapper(
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
};
|
|
2399
|
-
});
|
|
2207
|
+
setOptionsWrapper(prevOptionsWrapper => ({
|
|
2208
|
+
action: '',
|
|
2209
|
+
isFocused: !prevOptionsWrapper.isFocused
|
|
2210
|
+
}));
|
|
2400
2211
|
}
|
|
2401
2212
|
};
|
|
2402
2213
|
|
|
2403
|
-
|
|
2404
|
-
|
|
2214
|
+
const selectedOptionLabel = getSelectedOptionLabel();
|
|
2215
|
+
const selectClassName = classNames('fwe-select', {
|
|
2405
2216
|
'fwe-focus': optionsWrapper.isFocused
|
|
2406
2217
|
}, {
|
|
2407
2218
|
'fwe-empty': selectedOptionLabel === undefined && !optionsWrapper.isFocused
|
|
@@ -2414,56 +2225,46 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2414
2225
|
});
|
|
2415
2226
|
|
|
2416
2227
|
function renderOptions() {
|
|
2417
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, options && options.map(
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
}), childrenList.map(function (child, i) {
|
|
2437
|
-
var _a = child.props,
|
|
2438
|
-
option = _a.option,
|
|
2439
|
-
propsWithoutOption = __rest(_a, ["option"]);
|
|
2228
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, options && options.map((option, i) => /*#__PURE__*/React.createElement("li", {
|
|
2229
|
+
ref: listItemRef.current[i],
|
|
2230
|
+
role: "option",
|
|
2231
|
+
"aria-selected": option.label === selectedOptionLabel,
|
|
2232
|
+
key: option.data,
|
|
2233
|
+
onClick: () => handleOptionChange(option),
|
|
2234
|
+
className: classNames('fwe-select-option', {
|
|
2235
|
+
'fwe-empty': !option.label
|
|
2236
|
+
}),
|
|
2237
|
+
onKeyDown: e => handleListKeyDown(e, option, i),
|
|
2238
|
+
tabIndex: 0
|
|
2239
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2240
|
+
className: "fwe-select-option-content"
|
|
2241
|
+
}, option.label))), childrenList.map((child, i) => {
|
|
2242
|
+
const _a = child.props,
|
|
2243
|
+
{
|
|
2244
|
+
option
|
|
2245
|
+
} = _a,
|
|
2246
|
+
propsWithoutOption = __rest(_a, ["option"]);
|
|
2440
2247
|
|
|
2441
2248
|
return /*#__PURE__*/React.createElement("li", {
|
|
2442
2249
|
ref: listItemRef.current[i],
|
|
2443
2250
|
role: "option",
|
|
2444
2251
|
"aria-selected": option.label === selectedOptionLabel,
|
|
2445
2252
|
key: option.data,
|
|
2446
|
-
onClick:
|
|
2447
|
-
return handleOptionChange(option);
|
|
2448
|
-
},
|
|
2253
|
+
onClick: () => handleOptionChange(option),
|
|
2449
2254
|
className: classNames('fwe-select-option', {
|
|
2450
2255
|
'fwe-empty': !option.label
|
|
2451
2256
|
}),
|
|
2452
|
-
onKeyDown:
|
|
2453
|
-
return handleListKeyDown(e, option, i);
|
|
2454
|
-
},
|
|
2257
|
+
onKeyDown: e => handleListKeyDown(e, option, i),
|
|
2455
2258
|
tabIndex: 0
|
|
2456
2259
|
}, /*#__PURE__*/React.createElement(SelectOption, Object.assign({}, propsWithoutOption)));
|
|
2457
2260
|
}));
|
|
2458
2261
|
}
|
|
2459
2262
|
|
|
2460
2263
|
return /*#__PURE__*/React.createElement(OutsideClickHandler, {
|
|
2461
|
-
onOutsideClick:
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2264
|
+
onOutsideClick: () => setOptionsWrapper({
|
|
2265
|
+
action: '',
|
|
2266
|
+
isFocused: false
|
|
2267
|
+
})
|
|
2467
2268
|
}, /*#__PURE__*/React.createElement("div", Object.assign({
|
|
2468
2269
|
ref: ref,
|
|
2469
2270
|
className: classNames('fwe-select-wrapper', className)
|
|
@@ -2475,18 +2276,14 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2475
2276
|
"aria-label": label,
|
|
2476
2277
|
disabled: disabled,
|
|
2477
2278
|
required: required
|
|
2478
|
-
}, usedOptions.map(
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
}, option.label);
|
|
2483
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
2279
|
+
}, usedOptions.map(option => /*#__PURE__*/React.createElement("option", {
|
|
2280
|
+
key: option.data,
|
|
2281
|
+
value: option.data
|
|
2282
|
+
}, option.label))), /*#__PURE__*/React.createElement("div", {
|
|
2484
2283
|
role: "button",
|
|
2485
2284
|
tabIndex: 0,
|
|
2486
2285
|
className: selectClassName,
|
|
2487
|
-
onClick:
|
|
2488
|
-
return handleClick(e);
|
|
2489
|
-
},
|
|
2286
|
+
onClick: e => handleClick(e),
|
|
2490
2287
|
ref: buttonEl,
|
|
2491
2288
|
onKeyDown: handleKeyPress
|
|
2492
2289
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -2503,7 +2300,7 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2503
2300
|
}, hint), error && /*#__PURE__*/React.createElement("div", {
|
|
2504
2301
|
className: "fwe-select-invalid"
|
|
2505
2302
|
}, " ", error, " "), /*#__PURE__*/React.createElement("ul", {
|
|
2506
|
-
className:
|
|
2303
|
+
className: `fwe-select-options-container${optionsWrapper.isFocused ? '' : ' fwe-d-none'}`
|
|
2507
2304
|
}, (scroll === null || scroll === void 0 ? void 0 : scroll.enabled) ? /*#__PURE__*/React.createElement("div", {
|
|
2508
2305
|
className: "fr-select-scroll",
|
|
2509
2306
|
style: {
|
|
@@ -2512,57 +2309,48 @@ var Select = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
2512
2309
|
}, renderOptions()) : renderOptions())));
|
|
2513
2310
|
});
|
|
2514
2311
|
|
|
2515
|
-
function Slider(
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
innerValue = _useState[0],
|
|
2533
|
-
setInnerValue = _useState[1];
|
|
2534
|
-
|
|
2535
|
-
var _useState2 = useState(null),
|
|
2536
|
-
left = _useState2[0],
|
|
2537
|
-
setLeft = _useState2[1];
|
|
2538
|
-
|
|
2539
|
-
var labelEl = useRef(null);
|
|
2540
|
-
var classes = classNames('fwe-slider', {
|
|
2312
|
+
function Slider({
|
|
2313
|
+
disabled = false,
|
|
2314
|
+
label,
|
|
2315
|
+
large = false,
|
|
2316
|
+
max,
|
|
2317
|
+
min,
|
|
2318
|
+
onChange,
|
|
2319
|
+
onChangeCommitted,
|
|
2320
|
+
step,
|
|
2321
|
+
value,
|
|
2322
|
+
showValue = true,
|
|
2323
|
+
className
|
|
2324
|
+
}) {
|
|
2325
|
+
const [innerValue, setInnerValue] = useState(value);
|
|
2326
|
+
const [left, setLeft] = useState(null);
|
|
2327
|
+
const labelEl = useRef(null);
|
|
2328
|
+
const classes = classNames('fwe-slider', {
|
|
2541
2329
|
'fwe-slider-lg': large
|
|
2542
2330
|
}, {
|
|
2543
2331
|
'fr-slider-label': label !== null && showValue
|
|
2544
2332
|
}, className);
|
|
2545
|
-
useEffect(
|
|
2333
|
+
useEffect(() => {
|
|
2546
2334
|
setInnerValue(value);
|
|
2547
2335
|
}, [value]);
|
|
2548
|
-
|
|
2336
|
+
const updateValuePosition = useCallback(() => {
|
|
2549
2337
|
if (labelEl.current) {
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2338
|
+
const {
|
|
2339
|
+
width
|
|
2340
|
+
} = labelEl.current.getBoundingClientRect();
|
|
2341
|
+
const diff = max - min;
|
|
2554
2342
|
setLeft((innerValue - min) / diff * (width - 16));
|
|
2555
2343
|
}
|
|
2556
2344
|
}, [innerValue, max, min]);
|
|
2557
2345
|
|
|
2558
|
-
|
|
2346
|
+
const handleAfterChange = () => {
|
|
2559
2347
|
if (onChangeCommitted) {
|
|
2560
2348
|
onChangeCommitted(innerValue);
|
|
2561
2349
|
}
|
|
2562
2350
|
};
|
|
2563
2351
|
|
|
2564
|
-
|
|
2565
|
-
|
|
2352
|
+
const handleChange = e => {
|
|
2353
|
+
const newValue = Number.parseFloat(e.target.value);
|
|
2566
2354
|
setInnerValue(newValue);
|
|
2567
2355
|
|
|
2568
2356
|
if (onChange) {
|
|
@@ -2570,7 +2358,7 @@ function Slider(_ref) {
|
|
|
2570
2358
|
}
|
|
2571
2359
|
};
|
|
2572
2360
|
|
|
2573
|
-
useEffect(
|
|
2361
|
+
useEffect(() => {
|
|
2574
2362
|
function handleResize() {
|
|
2575
2363
|
updateValuePosition();
|
|
2576
2364
|
}
|
|
@@ -2578,9 +2366,7 @@ function Slider(_ref) {
|
|
|
2578
2366
|
window.addEventListener('resize', handleResize);
|
|
2579
2367
|
handleResize(); // Remove event listener on cleanup
|
|
2580
2368
|
|
|
2581
|
-
return
|
|
2582
|
-
return window.removeEventListener('resize', handleResize);
|
|
2583
|
-
};
|
|
2369
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
2584
2370
|
}, [updateValuePosition]);
|
|
2585
2371
|
return /*#__PURE__*/React.createElement("label", {
|
|
2586
2372
|
ref: labelEl,
|
|
@@ -2600,35 +2386,30 @@ function Slider(_ref) {
|
|
|
2600
2386
|
}), showValue && left !== null && /*#__PURE__*/React.createElement("span", {
|
|
2601
2387
|
className: "fr-slider-value",
|
|
2602
2388
|
style: {
|
|
2603
|
-
left: left
|
|
2389
|
+
left: `${left}px`
|
|
2604
2390
|
}
|
|
2605
2391
|
}, innerValue));
|
|
2606
2392
|
}
|
|
2607
2393
|
|
|
2608
2394
|
function Snackbar(props) {
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
var nodeRef = useRef(null);
|
|
2620
|
-
useEffect(function () {
|
|
2621
|
-
var disappearAfter = 5000;
|
|
2395
|
+
const {
|
|
2396
|
+
data,
|
|
2397
|
+
onAction,
|
|
2398
|
+
onClose,
|
|
2399
|
+
first = false
|
|
2400
|
+
} = props;
|
|
2401
|
+
const [show, setShow] = useState(true);
|
|
2402
|
+
const nodeRef = useRef(null);
|
|
2403
|
+
useEffect(() => {
|
|
2404
|
+
let disappearAfter = 5000;
|
|
2622
2405
|
|
|
2623
2406
|
if ((data === null || data === void 0 ? void 0 : data.disappearAfter) !== null) {
|
|
2624
2407
|
if ((data === null || data === void 0 ? void 0 : data.disappearAfter) && (data === null || data === void 0 ? void 0 : data.disappearAfter) > 0) {
|
|
2625
2408
|
disappearAfter = data === null || data === void 0 ? void 0 : data.disappearAfter;
|
|
2626
2409
|
}
|
|
2627
2410
|
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
}, disappearAfter);
|
|
2631
|
-
return function () {
|
|
2411
|
+
const timer = setTimeout(() => setShow(false), disappearAfter);
|
|
2412
|
+
return () => {
|
|
2632
2413
|
clearTimeout(timer);
|
|
2633
2414
|
};
|
|
2634
2415
|
}
|
|
@@ -2640,17 +2421,15 @@ function Snackbar(props) {
|
|
|
2640
2421
|
setShow(false);
|
|
2641
2422
|
}
|
|
2642
2423
|
|
|
2643
|
-
|
|
2424
|
+
const classes = first ? 'fr-snackbar-wrapper--first' : 'fr-snackbar-wrapper';
|
|
2644
2425
|
return /*#__PURE__*/React.createElement(CSSTransition, {
|
|
2645
2426
|
nodeRef: nodeRef,
|
|
2646
|
-
onExited:
|
|
2647
|
-
return onClose ? onClose() : undefined;
|
|
2648
|
-
},
|
|
2427
|
+
onExited: () => onClose ? onClose() : undefined,
|
|
2649
2428
|
unmountOnExit: true,
|
|
2650
2429
|
timeout: {
|
|
2651
2430
|
exit: 600
|
|
2652
2431
|
},
|
|
2653
|
-
|
|
2432
|
+
in: show,
|
|
2654
2433
|
classNames: classes,
|
|
2655
2434
|
appear: true
|
|
2656
2435
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -2677,9 +2456,7 @@ function Snackbar(props) {
|
|
|
2677
2456
|
"aria-label": "UserAction",
|
|
2678
2457
|
type: "button",
|
|
2679
2458
|
className: "fwe-btn fwe-btn-link",
|
|
2680
|
-
onClick:
|
|
2681
|
-
return onAction ? onAction() : undefined;
|
|
2682
|
-
}
|
|
2459
|
+
onClick: () => onAction ? onAction() : undefined
|
|
2683
2460
|
}, data === null || data === void 0 ? void 0 : data.action), (data === null || data === void 0 ? void 0 : data.showClose) && /*#__PURE__*/React.createElement("button", {
|
|
2684
2461
|
"aria-label": "Close",
|
|
2685
2462
|
type: "button",
|
|
@@ -2696,36 +2473,28 @@ function Snackbar(props) {
|
|
|
2696
2473
|
var SnackbarContext = /*#__PURE__*/React.createContext({});
|
|
2697
2474
|
|
|
2698
2475
|
function SnackbarProvider(props) {
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
snacks = _useState[0],
|
|
2708
|
-
setSnacks = _useState[1];
|
|
2476
|
+
const {
|
|
2477
|
+
config = {
|
|
2478
|
+
darkBackground: true
|
|
2479
|
+
},
|
|
2480
|
+
children,
|
|
2481
|
+
className
|
|
2482
|
+
} = props;
|
|
2483
|
+
const [snacks, setSnacks] = useState([]);
|
|
2709
2484
|
|
|
2710
2485
|
function addSnackbar(snackData, onAction, onClose) {
|
|
2711
|
-
setSnacks(
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
}].concat(prevSnacks);
|
|
2719
|
-
});
|
|
2486
|
+
setSnacks(prevSnacks => [{
|
|
2487
|
+
data: Object.assign(Object.assign({}, config), snackData),
|
|
2488
|
+
onAction,
|
|
2489
|
+
onClose,
|
|
2490
|
+
key: new Date().getTime() + Math.random(),
|
|
2491
|
+
first: prevSnacks.length === 0
|
|
2492
|
+
}, ...prevSnacks]);
|
|
2720
2493
|
}
|
|
2721
2494
|
|
|
2722
2495
|
function closeSnackbar(key) {
|
|
2723
2496
|
if (key) {
|
|
2724
|
-
setSnacks(
|
|
2725
|
-
return prevSnacks.filter(function (snack) {
|
|
2726
|
-
return snack.key !== key;
|
|
2727
|
-
});
|
|
2728
|
-
});
|
|
2497
|
+
setSnacks(prevSnacks => prevSnacks.filter(snack => snack.key !== key));
|
|
2729
2498
|
}
|
|
2730
2499
|
}
|
|
2731
2500
|
|
|
@@ -2737,60 +2506,46 @@ function SnackbarProvider(props) {
|
|
|
2737
2506
|
}
|
|
2738
2507
|
}
|
|
2739
2508
|
|
|
2740
|
-
|
|
2741
|
-
addSnackbar
|
|
2742
|
-
closeSnackbar
|
|
2509
|
+
const contextValue = {
|
|
2510
|
+
addSnackbar,
|
|
2511
|
+
closeSnackbar
|
|
2743
2512
|
};
|
|
2744
2513
|
return /*#__PURE__*/React.createElement(SnackbarContext.Provider, {
|
|
2745
2514
|
value: contextValue
|
|
2746
2515
|
}, children, /*#__PURE__*/React.createElement("div", {
|
|
2747
2516
|
className: classNames('fwe-snackbar-container', className)
|
|
2748
|
-
}, snacks.map(
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
onClose: function onClose() {
|
|
2756
|
-
return handleClose(snack);
|
|
2757
|
-
},
|
|
2758
|
-
first: snack.first
|
|
2759
|
-
});
|
|
2760
|
-
})));
|
|
2517
|
+
}, snacks.map(snack => /*#__PURE__*/React.createElement(Snackbar, {
|
|
2518
|
+
key: snack.key,
|
|
2519
|
+
data: snack.data,
|
|
2520
|
+
onAction: () => snack.onAction ? snack.onAction() : undefined,
|
|
2521
|
+
onClose: () => handleClose(snack),
|
|
2522
|
+
first: snack.first
|
|
2523
|
+
}))));
|
|
2761
2524
|
}
|
|
2762
2525
|
|
|
2763
|
-
var useSnackbar = (
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
2778
|
-
onChange = _ref.onChange,
|
|
2779
|
-
className = _ref.className;
|
|
2780
|
-
var labelClassName = classNames('fwe-switch', (_classNames = {}, _classNames["fwe-switch-label-" + labelPosition] = true, _classNames), {
|
|
2526
|
+
var useSnackbar = (() => useContext(SnackbarContext));
|
|
2527
|
+
|
|
2528
|
+
function Switch({
|
|
2529
|
+
labelPosition = 'before',
|
|
2530
|
+
large = false,
|
|
2531
|
+
title,
|
|
2532
|
+
value,
|
|
2533
|
+
disabled = false,
|
|
2534
|
+
onChange,
|
|
2535
|
+
className
|
|
2536
|
+
}) {
|
|
2537
|
+
const labelClassName = classNames('fwe-switch', {
|
|
2538
|
+
[`fwe-switch-label-${labelPosition}`]: true
|
|
2539
|
+
}, {
|
|
2781
2540
|
'fwe-switch-lg': large
|
|
2782
2541
|
}, className);
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
currentValue = _useState[0],
|
|
2786
|
-
setCurrentValue = _useState[1];
|
|
2787
|
-
|
|
2788
|
-
useEffect(function () {
|
|
2542
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
2543
|
+
useEffect(() => {
|
|
2789
2544
|
setCurrentValue(value);
|
|
2790
2545
|
}, [value]);
|
|
2791
2546
|
|
|
2792
|
-
|
|
2793
|
-
|
|
2547
|
+
const handleChange = () => {
|
|
2548
|
+
const newValue = !currentValue;
|
|
2794
2549
|
setCurrentValue(newValue);
|
|
2795
2550
|
|
|
2796
2551
|
if (onChange) {
|
|
@@ -2804,9 +2559,7 @@ function Switch(_ref) {
|
|
|
2804
2559
|
type: "checkbox",
|
|
2805
2560
|
disabled: disabled,
|
|
2806
2561
|
checked: currentValue,
|
|
2807
|
-
onChange:
|
|
2808
|
-
return handleChange();
|
|
2809
|
-
}
|
|
2562
|
+
onChange: () => handleChange()
|
|
2810
2563
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2811
2564
|
className: "fwe-switch-track"
|
|
2812
2565
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -2814,7 +2567,7 @@ function Switch(_ref) {
|
|
|
2814
2567
|
}, title));
|
|
2815
2568
|
}
|
|
2816
2569
|
|
|
2817
|
-
|
|
2570
|
+
const TableHeaderCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
2818
2571
|
function handleClick(event) {
|
|
2819
2572
|
if (props.onClick) {
|
|
2820
2573
|
props.onClick(event);
|
|
@@ -2832,48 +2585,41 @@ var TableHeaderCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
2832
2585
|
}));
|
|
2833
2586
|
});
|
|
2834
2587
|
|
|
2835
|
-
function TextArea(
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
var ref = React.useRef(null);
|
|
2860
|
-
|
|
2861
|
-
var _useState2 = useState(null),
|
|
2862
|
-
height = _useState2[0],
|
|
2863
|
-
setHeight = _useState2[1];
|
|
2864
|
-
|
|
2865
|
-
useEffect(function () {
|
|
2588
|
+
function TextArea({
|
|
2589
|
+
disabled,
|
|
2590
|
+
onBlur,
|
|
2591
|
+
onChange,
|
|
2592
|
+
onFocus,
|
|
2593
|
+
onInput,
|
|
2594
|
+
readonly,
|
|
2595
|
+
required,
|
|
2596
|
+
label,
|
|
2597
|
+
error,
|
|
2598
|
+
hint,
|
|
2599
|
+
value,
|
|
2600
|
+
rows,
|
|
2601
|
+
maxLength,
|
|
2602
|
+
className,
|
|
2603
|
+
defaultValue
|
|
2604
|
+
}) {
|
|
2605
|
+
const controlled = value !== undefined;
|
|
2606
|
+
const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
|
|
2607
|
+
const hintClasses = classNames('fwe-input-text-info');
|
|
2608
|
+
const shadowRef = React.useRef(null);
|
|
2609
|
+
const ref = React.useRef(null);
|
|
2610
|
+
const [height, setHeight] = useState(null);
|
|
2611
|
+
useEffect(() => {
|
|
2866
2612
|
if (controlled) {
|
|
2867
2613
|
setInnerValue(value);
|
|
2868
2614
|
}
|
|
2869
2615
|
}, [value, controlled]);
|
|
2870
|
-
useEffect(
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2616
|
+
useEffect(() => {
|
|
2617
|
+
const input = ref.current;
|
|
2618
|
+
const shadow = shadowRef.current;
|
|
2619
|
+
const minRows = 2;
|
|
2874
2620
|
shadow.value = input.value || 'x';
|
|
2875
|
-
shadow.style.width =
|
|
2876
|
-
|
|
2621
|
+
shadow.style.width = `${input.clientWidth}`;
|
|
2622
|
+
const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
|
|
2877
2623
|
setHeight(newHeight + 4 + 4 + 1);
|
|
2878
2624
|
}, [innerValue]);
|
|
2879
2625
|
|
|
@@ -2891,11 +2637,11 @@ function TextArea(_ref) {
|
|
|
2891
2637
|
className: classNames('fwe-input-text', className)
|
|
2892
2638
|
}, /*#__PURE__*/React.createElement("textarea", {
|
|
2893
2639
|
style: Object.assign({}, !rows && {
|
|
2894
|
-
height
|
|
2640
|
+
height,
|
|
2895
2641
|
overflow: 'hidden'
|
|
2896
2642
|
}),
|
|
2897
2643
|
ref: ref,
|
|
2898
|
-
className: classNames('fr-textarea',
|
|
2644
|
+
className: classNames('fr-textarea', `fwe-row-${rows}`),
|
|
2899
2645
|
disabled: disabled,
|
|
2900
2646
|
readOnly: readonly,
|
|
2901
2647
|
required: required,
|
|
@@ -2931,38 +2677,35 @@ function TextArea(_ref) {
|
|
|
2931
2677
|
}, innerValue.length, " /", maxLength));
|
|
2932
2678
|
}
|
|
2933
2679
|
|
|
2934
|
-
function TextEditorButton(
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
var _useState = useState(false),
|
|
2948
|
-
active = _useState[0],
|
|
2949
|
-
setActive = _useState[1];
|
|
2950
|
-
|
|
2951
|
-
var btnRef = useRef(null);
|
|
2680
|
+
function TextEditorButton({
|
|
2681
|
+
disabled,
|
|
2682
|
+
label,
|
|
2683
|
+
type,
|
|
2684
|
+
className,
|
|
2685
|
+
icon,
|
|
2686
|
+
list,
|
|
2687
|
+
value,
|
|
2688
|
+
noAction,
|
|
2689
|
+
category
|
|
2690
|
+
}) {
|
|
2691
|
+
const [active, setActive] = useState(false);
|
|
2692
|
+
const btnRef = useRef(null);
|
|
2952
2693
|
|
|
2953
2694
|
function handleClick() {
|
|
2954
|
-
|
|
2955
|
-
setActive(
|
|
2956
|
-
return !prevActive;
|
|
2957
|
-
});
|
|
2695
|
+
const btn = btnRef.current;
|
|
2696
|
+
setActive(prevActive => !prevActive);
|
|
2958
2697
|
btn.click();
|
|
2959
2698
|
}
|
|
2960
2699
|
|
|
2961
|
-
useEffect(
|
|
2700
|
+
useEffect(() => {
|
|
2962
2701
|
function callback(mutationRecords) {
|
|
2963
|
-
mutationRecords.forEach(
|
|
2964
|
-
|
|
2965
|
-
|
|
2702
|
+
mutationRecords.forEach(mutationRecord => {
|
|
2703
|
+
const {
|
|
2704
|
+
classList
|
|
2705
|
+
} = mutationRecord.target;
|
|
2706
|
+
const {
|
|
2707
|
+
oldValue
|
|
2708
|
+
} = mutationRecord;
|
|
2966
2709
|
|
|
2967
2710
|
if (classList.contains('ql-active')) {
|
|
2968
2711
|
setActive(true);
|
|
@@ -2975,7 +2718,7 @@ function TextEditorButton(_ref) {
|
|
|
2975
2718
|
}
|
|
2976
2719
|
|
|
2977
2720
|
if (btnRef.current && !noAction) {
|
|
2978
|
-
|
|
2721
|
+
const observer = new MutationObserver(callback);
|
|
2979
2722
|
observer.observe(btnRef.current, {
|
|
2980
2723
|
attributes: true,
|
|
2981
2724
|
attributeFilter: ['class'],
|
|
@@ -2986,9 +2729,13 @@ function TextEditorButton(_ref) {
|
|
|
2986
2729
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
2987
2730
|
ref: btnRef,
|
|
2988
2731
|
type: "button",
|
|
2989
|
-
className: classNames(
|
|
2732
|
+
className: classNames({
|
|
2733
|
+
[`ql-${category || type}`]: !list
|
|
2734
|
+
}, {
|
|
2990
2735
|
'ql-list': list
|
|
2991
|
-
}, 'fwe-d-none',
|
|
2736
|
+
}, 'fwe-d-none', {
|
|
2737
|
+
[`action-${type}`]: !noAction
|
|
2738
|
+
}),
|
|
2992
2739
|
"aria-hidden": "true",
|
|
2993
2740
|
value: value
|
|
2994
2741
|
}), /*#__PURE__*/React.createElement("button", {
|
|
@@ -2998,20 +2745,18 @@ function TextEditorButton(_ref) {
|
|
|
2998
2745
|
}, 'fr-button', className, {
|
|
2999
2746
|
'fwe-active': active && !noAction
|
|
3000
2747
|
}),
|
|
3001
|
-
onClick:
|
|
3002
|
-
return handleClick();
|
|
3003
|
-
},
|
|
2748
|
+
onClick: () => handleClick(),
|
|
3004
2749
|
disabled: disabled
|
|
3005
2750
|
}, label && /*#__PURE__*/React.createElement("div", {
|
|
3006
|
-
className:
|
|
2751
|
+
className: `fr-button-text fwe-text-${type}`
|
|
3007
2752
|
}, label), icon && /*#__PURE__*/React.createElement("i", {
|
|
3008
|
-
className: classNames('fwe-icon fwe-icon-toolbar-list',
|
|
2753
|
+
className: classNames('fwe-icon fwe-icon-toolbar-list', `fwe-icon-${icon}`, 'fwe-pr-0')
|
|
3009
2754
|
})));
|
|
3010
2755
|
}
|
|
3011
2756
|
|
|
3012
|
-
|
|
2757
|
+
const xss = require('xss');
|
|
3013
2758
|
|
|
3014
|
-
|
|
2759
|
+
const defaultConfig = {
|
|
3015
2760
|
toolbar: {
|
|
3016
2761
|
bold: true,
|
|
3017
2762
|
italic: true,
|
|
@@ -3024,51 +2769,38 @@ var defaultConfig = {
|
|
|
3024
2769
|
link: true
|
|
3025
2770
|
}
|
|
3026
2771
|
};
|
|
3027
|
-
function TextEditor(
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
onChange = _ref.onChange,
|
|
3040
|
-
className = _ref.className,
|
|
3041
|
-
configProps = _ref.config;
|
|
3042
|
-
|
|
2772
|
+
function TextEditor({
|
|
2773
|
+
disabled = false,
|
|
2774
|
+
label,
|
|
2775
|
+
maxLength,
|
|
2776
|
+
value,
|
|
2777
|
+
hint,
|
|
2778
|
+
error,
|
|
2779
|
+
readOnly = false,
|
|
2780
|
+
onChange,
|
|
2781
|
+
className,
|
|
2782
|
+
config: configProps
|
|
2783
|
+
}) {
|
|
3043
2784
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
3044
2785
|
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
var _useState2 = useState((Math.random() * Date.now()).toString().replace('.', '-')),
|
|
3052
|
-
id = _useState2[0];
|
|
3053
|
-
|
|
3054
|
-
var _useState3 = useState(value),
|
|
3055
|
-
innerValue = _useState3[0],
|
|
3056
|
-
setInnerValue = _useState3[1];
|
|
3057
|
-
|
|
3058
|
-
var config = {
|
|
2786
|
+
const editorRef = useRef(null);
|
|
2787
|
+
const [editor, setEditor] = useState(null);
|
|
2788
|
+
const [id] = useState((Math.random() * Date.now()).toString().replace('.', '-'));
|
|
2789
|
+
const [innerValue, setInnerValue] = useState(value);
|
|
2790
|
+
const config = {
|
|
3059
2791
|
toolbar: Object.assign(Object.assign({}, defaultConfig.toolbar), configProps === null || configProps === void 0 ? void 0 : configProps.toolbar)
|
|
3060
2792
|
};
|
|
3061
|
-
useEffect(
|
|
2793
|
+
useEffect(() => {
|
|
3062
2794
|
if (editorRef && editor === null) {
|
|
3063
|
-
|
|
2795
|
+
const newEditor = new Quill(editorRef.current, {
|
|
3064
2796
|
modules: {
|
|
3065
|
-
toolbar:
|
|
2797
|
+
toolbar: `#editor-toolbar-${id}`
|
|
3066
2798
|
},
|
|
3067
2799
|
theme: 'snow',
|
|
3068
|
-
scrollingContainer:
|
|
2800
|
+
scrollingContainer: `#editor-container-${id}`
|
|
3069
2801
|
});
|
|
3070
2802
|
newEditor.root.setAttribute('role', 'textbox');
|
|
3071
|
-
newEditor.root.setAttribute('aria-labelledby',
|
|
2803
|
+
newEditor.root.setAttribute('aria-labelledby', `editor-label-${id}`);
|
|
3072
2804
|
newEditor.root.setAttribute('aria-multiline', 'true');
|
|
3073
2805
|
newEditor.enable(!readOnly);
|
|
3074
2806
|
|
|
@@ -3079,23 +2811,23 @@ function TextEditor(_ref) {
|
|
|
3079
2811
|
} // set up a matcher that does allow/disallow to paste images corresponding to config settings
|
|
3080
2812
|
|
|
3081
2813
|
|
|
3082
|
-
newEditor.clipboard.addMatcher('img',
|
|
2814
|
+
newEditor.clipboard.addMatcher('img', (_node, delta) => {
|
|
3083
2815
|
// allowed, passthru delta
|
|
3084
2816
|
if (config.toolbar.image === true) {
|
|
3085
2817
|
return delta;
|
|
3086
2818
|
} // not allowed, remove image by setting up a new delta
|
|
3087
2819
|
|
|
3088
2820
|
|
|
3089
|
-
|
|
2821
|
+
const Delta = Quill.import('quill-delta');
|
|
3090
2822
|
return new Delta().insert('');
|
|
3091
2823
|
});
|
|
3092
2824
|
setEditor(newEditor);
|
|
3093
2825
|
}
|
|
3094
2826
|
}, [editorRef, editor, disabled, readOnly, className, id, config.toolbar.image]);
|
|
3095
|
-
useEffect(
|
|
2827
|
+
useEffect(() => {
|
|
3096
2828
|
if (editor) {
|
|
3097
|
-
editor.on('text-change',
|
|
3098
|
-
|
|
2829
|
+
editor.on('text-change', () => {
|
|
2830
|
+
let html = editor.root.innerHTML;
|
|
3099
2831
|
|
|
3100
2832
|
if (html === '<p><br></p>' || html === '<div><br></div>' || html === undefined) {
|
|
3101
2833
|
html = null;
|
|
@@ -3109,15 +2841,15 @@ function TextEditor(_ref) {
|
|
|
3109
2841
|
});
|
|
3110
2842
|
}
|
|
3111
2843
|
}, [editor, onChange]);
|
|
3112
|
-
useEffect(
|
|
2844
|
+
useEffect(() => {
|
|
3113
2845
|
if (editor) {
|
|
3114
|
-
|
|
3115
|
-
a: [
|
|
2846
|
+
const whiteList = Object.assign(Object.assign({}, xss.whiteList), {
|
|
2847
|
+
a: [...xss.whiteList.a, 'rel']
|
|
3116
2848
|
});
|
|
3117
|
-
|
|
3118
|
-
whiteList
|
|
2849
|
+
const sanitizedValue = xss(value, {
|
|
2850
|
+
whiteList
|
|
3119
2851
|
});
|
|
3120
|
-
|
|
2852
|
+
const content = editor.clipboard.convert(sanitizedValue);
|
|
3121
2853
|
editor.setContents(content, 'silent');
|
|
3122
2854
|
}
|
|
3123
2855
|
}, [editor, value]);
|
|
@@ -3127,10 +2859,10 @@ function TextEditor(_ref) {
|
|
|
3127
2859
|
}
|
|
3128
2860
|
|
|
3129
2861
|
function hideDivider(name) {
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
2862
|
+
const linkOrImage = config.toolbar.image || config.toolbar.link;
|
|
2863
|
+
const lists = config.toolbar.bulletList || config.toolbar.orderedList;
|
|
2864
|
+
const typos = config.toolbar.bold || config.toolbar.italic || config.toolbar.underline;
|
|
2865
|
+
const textAlign = config.toolbar.alignCenter || config.toolbar.alignRight;
|
|
3134
2866
|
|
|
3135
2867
|
switch (name) {
|
|
3136
2868
|
case 'typo':
|
|
@@ -3151,11 +2883,13 @@ function TextEditor(_ref) {
|
|
|
3151
2883
|
|
|
3152
2884
|
return /*#__PURE__*/React.createElement("label", {
|
|
3153
2885
|
className: classNames('fwe-input-text', {
|
|
3154
|
-
disabled
|
|
2886
|
+
disabled
|
|
3155
2887
|
})
|
|
3156
2888
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3157
|
-
className: classNames('fwe-editor-toolbar',
|
|
3158
|
-
|
|
2889
|
+
className: classNames('fwe-editor-toolbar', {
|
|
2890
|
+
[`fwe-editor-toolbar-${className}`]: className
|
|
2891
|
+
}),
|
|
2892
|
+
id: `editor-toolbar-${id}`
|
|
3159
2893
|
}, /*#__PURE__*/React.createElement("span", {
|
|
3160
2894
|
className: "ql-formats fwe-d-none"
|
|
3161
2895
|
}, /*#__PURE__*/React.createElement("select", {
|
|
@@ -3244,52 +2978,51 @@ function TextEditor(_ref) {
|
|
|
3244
2978
|
className: classNames('fwe-editor-container', {
|
|
3245
2979
|
'fwe-editor-container--error': error
|
|
3246
2980
|
}),
|
|
3247
|
-
id:
|
|
2981
|
+
id: `editor-container-${id}`
|
|
3248
2982
|
}, /*#__PURE__*/React.createElement("div", {
|
|
3249
2983
|
className: "fwe-editor",
|
|
3250
2984
|
ref: editorRef
|
|
3251
2985
|
})), /*#__PURE__*/React.createElement("span", {
|
|
3252
2986
|
className: "fwe-input-text-label",
|
|
3253
|
-
id:
|
|
2987
|
+
id: `editor-label-${id}`
|
|
3254
2988
|
}, label), error && /*#__PURE__*/React.createElement("span", {
|
|
3255
2989
|
className: "fwe-text-editor-invalid"
|
|
3256
2990
|
}, error), hint && /*#__PURE__*/React.createElement("span", {
|
|
3257
2991
|
className: "fwe-text-editor-info"
|
|
3258
2992
|
}, hint), maxLength && maxLength > 0 && value != null && /*#__PURE__*/React.createElement("span", {
|
|
3259
2993
|
className: "fwe-input-text-count"
|
|
3260
|
-
}, currentLength()
|
|
2994
|
+
}, `${currentLength()} / ${maxLength}`));
|
|
3261
2995
|
}
|
|
3262
2996
|
|
|
3263
|
-
|
|
3264
|
-
var
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
2997
|
+
const TextInput = _a => {
|
|
2998
|
+
var {
|
|
2999
|
+
disabled,
|
|
3000
|
+
required,
|
|
3001
|
+
readonly,
|
|
3002
|
+
placeholder,
|
|
3003
|
+
max,
|
|
3004
|
+
min,
|
|
3005
|
+
onBlur,
|
|
3006
|
+
onFocus,
|
|
3007
|
+
onInput,
|
|
3008
|
+
step,
|
|
3009
|
+
type,
|
|
3010
|
+
value,
|
|
3011
|
+
error,
|
|
3012
|
+
hint,
|
|
3013
|
+
label,
|
|
3014
|
+
labelClassName
|
|
3015
|
+
} = _a,
|
|
3280
3016
|
props = __rest(_a, ["disabled", "required", "readonly", "placeholder", "max", "min", "onBlur", "onFocus", "onInput", "step", "type", "value", "error", "hint", "label", "labelClassName"]);
|
|
3281
3017
|
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
setInnerValue = _useState[1];
|
|
3285
|
-
|
|
3286
|
-
useEffect(function () {
|
|
3018
|
+
const [innerValue, setInnerValue] = useState(value);
|
|
3019
|
+
useEffect(() => {
|
|
3287
3020
|
setInnerValue(value);
|
|
3288
3021
|
}, [value]);
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3022
|
+
const supported = ['text', 'number', 'password', 'datetime-local'];
|
|
3023
|
+
const innerType = type && supported.indexOf(type) !== -1 ? type : 'text';
|
|
3024
|
+
const labelClasses = classNames('fwe-input-text', labelClassName);
|
|
3025
|
+
const hintClasses = classNames('fwe-input-text-info');
|
|
3293
3026
|
|
|
3294
3027
|
function handleChange(e) {
|
|
3295
3028
|
setInnerValue(e.target.value);
|
|
@@ -3326,23 +3059,22 @@ var TextInput = function TextInput(_a) {
|
|
|
3326
3059
|
};
|
|
3327
3060
|
|
|
3328
3061
|
function Prompt(_a) {
|
|
3329
|
-
var
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3062
|
+
var {
|
|
3063
|
+
title,
|
|
3064
|
+
subtitle,
|
|
3065
|
+
hint,
|
|
3066
|
+
label,
|
|
3067
|
+
value,
|
|
3068
|
+
onChange,
|
|
3069
|
+
onOk,
|
|
3070
|
+
onCancel,
|
|
3071
|
+
cancel,
|
|
3072
|
+
ok
|
|
3073
|
+
} = _a,
|
|
3339
3074
|
props = __rest(_a, ["title", "subtitle", "hint", "label", "value", "onChange", "onOk", "onCancel", "cancel", "ok"]);
|
|
3340
3075
|
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
setInnerValue = _useState[1];
|
|
3344
|
-
|
|
3345
|
-
useEffect(function () {
|
|
3076
|
+
const [innerValue, setInnerValue] = useState(value);
|
|
3077
|
+
useEffect(() => {
|
|
3346
3078
|
setInnerValue(value);
|
|
3347
3079
|
}, [value]);
|
|
3348
3080
|
|
|
@@ -3375,23 +3107,21 @@ function Prompt(_a) {
|
|
|
3375
3107
|
type: "button",
|
|
3376
3108
|
"aria-label": "Ok",
|
|
3377
3109
|
className: "fwe-btn fwe-btn-hero",
|
|
3378
|
-
onClick:
|
|
3379
|
-
return onOk(innerValue);
|
|
3380
|
-
}
|
|
3110
|
+
onClick: () => onOk(innerValue)
|
|
3381
3111
|
}, ok)));
|
|
3382
3112
|
}
|
|
3383
3113
|
|
|
3384
3114
|
function PopoverMenu(_a) {
|
|
3385
|
-
var
|
|
3386
|
-
|
|
3387
|
-
|
|
3115
|
+
var {
|
|
3116
|
+
icon,
|
|
3117
|
+
menu,
|
|
3118
|
+
className
|
|
3119
|
+
} = _a,
|
|
3388
3120
|
props = __rest(_a, ["icon", "menu", "className"]);
|
|
3389
3121
|
|
|
3390
|
-
|
|
3391
|
-
showPopper = _useState[0],
|
|
3392
|
-
setShowPopper = _useState[1];
|
|
3122
|
+
const [showPopper, setShowPopper] = useState(false);
|
|
3393
3123
|
|
|
3394
|
-
|
|
3124
|
+
const handleClick = item => {
|
|
3395
3125
|
if (item.action) {
|
|
3396
3126
|
item.action(item.data);
|
|
3397
3127
|
}
|
|
@@ -3399,22 +3129,18 @@ function PopoverMenu(_a) {
|
|
|
3399
3129
|
setShowPopper(false);
|
|
3400
3130
|
};
|
|
3401
3131
|
|
|
3402
|
-
|
|
3132
|
+
const content = /*#__PURE__*/React.createElement("ul", {
|
|
3403
3133
|
className: "fwe-list-group"
|
|
3404
|
-
}, menu.map(
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
}, /*#__PURE__*/React.createElement("i", {
|
|
3415
|
-
className: "fwe-icon fwe-pr-0 " + item.icon
|
|
3416
|
-
}), /*#__PURE__*/React.createElement("span", null, item.text)));
|
|
3417
|
-
}));
|
|
3134
|
+
}, menu.map(item => /*#__PURE__*/React.createElement("li", {
|
|
3135
|
+
key: item.icon + item.text,
|
|
3136
|
+
className: "fwe-list-group-item"
|
|
3137
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
3138
|
+
type: "button",
|
|
3139
|
+
className: "fwe-btn fwe-btn-link fwe-dark",
|
|
3140
|
+
onClick: () => handleClick(item)
|
|
3141
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
3142
|
+
className: `fwe-icon fwe-pr-0 ${item.icon}`
|
|
3143
|
+
}), /*#__PURE__*/React.createElement("span", null, item.text)))));
|
|
3418
3144
|
return /*#__PURE__*/React.createElement("div", {
|
|
3419
3145
|
className: classNames('fwe-popover-menu', className)
|
|
3420
3146
|
}, /*#__PURE__*/React.createElement(Popover, Object.assign({
|
|
@@ -3426,32 +3152,24 @@ function PopoverMenu(_a) {
|
|
|
3426
3152
|
type: "button",
|
|
3427
3153
|
className: "fwe-btn fwe-btn-link fwe-dark origin"
|
|
3428
3154
|
}, /*#__PURE__*/React.createElement("i", {
|
|
3429
|
-
className:
|
|
3155
|
+
className: `fwe-icon fwe-pr-0 ${icon}`
|
|
3430
3156
|
}))));
|
|
3431
3157
|
}
|
|
3432
3158
|
|
|
3433
|
-
function Tooltip(
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
popperElement = _useState2[0],
|
|
3448
|
-
setPopperElement = _useState2[1];
|
|
3449
|
-
|
|
3450
|
-
var _useState3 = useState(null),
|
|
3451
|
-
arrowElement = _useState3[0],
|
|
3452
|
-
setArrowElement = _useState3[1];
|
|
3453
|
-
|
|
3454
|
-
var _usePopper = usePopper(referenceElement.current, popperElement, {
|
|
3159
|
+
function Tooltip({
|
|
3160
|
+
children,
|
|
3161
|
+
className,
|
|
3162
|
+
title,
|
|
3163
|
+
position = 'bottom'
|
|
3164
|
+
}) {
|
|
3165
|
+
const [showPopper, setShowPopper] = useState(false);
|
|
3166
|
+
const referenceElement = useRef(null);
|
|
3167
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
3168
|
+
const [arrowElement, setArrowElement] = useState(null);
|
|
3169
|
+
const {
|
|
3170
|
+
styles,
|
|
3171
|
+
attributes
|
|
3172
|
+
} = usePopper(referenceElement.current, popperElement, {
|
|
3455
3173
|
placement: position,
|
|
3456
3174
|
modifiers: [{
|
|
3457
3175
|
name: 'arrow',
|
|
@@ -3469,19 +3187,12 @@ function Tooltip(_ref) {
|
|
|
3469
3187
|
fallbackPlacements: ['right', 'left', 'top']
|
|
3470
3188
|
}
|
|
3471
3189
|
}]
|
|
3472
|
-
})
|
|
3473
|
-
styles = _usePopper.styles,
|
|
3474
|
-
attributes = _usePopper.attributes;
|
|
3475
|
-
|
|
3190
|
+
});
|
|
3476
3191
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
3477
3192
|
className: classNames('fr-tooltip-container', className),
|
|
3478
3193
|
ref: referenceElement,
|
|
3479
|
-
onMouseEnter:
|
|
3480
|
-
|
|
3481
|
-
},
|
|
3482
|
-
onMouseLeave: function onMouseLeave() {
|
|
3483
|
-
return setShowPopper(false);
|
|
3484
|
-
}
|
|
3194
|
+
onMouseEnter: () => setShowPopper(true),
|
|
3195
|
+
onMouseLeave: () => setShowPopper(false)
|
|
3485
3196
|
}, children), showPopper && /*#__PURE__*/React.createElement("div", Object.assign({
|
|
3486
3197
|
className: "fwe-popover-container",
|
|
3487
3198
|
id: "tooltip",
|