@festo-ui/react 3.1.0 → 3.2.1-pre-20220624.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +4 -3
  2. package/index.d.ts +27 -18
  3. package/{react.esm.css → index.esm.css} +812 -488
  4. package/index.esm.js +4778 -0
  5. package/{react.umd.css → index.umd.css} +812 -488
  6. package/index.umd.js +5211 -0
  7. package/lib/components/accordion/Accordion.d.ts +9 -0
  8. package/lib/components/accordion/AccordionContext.d.ts +11 -0
  9. package/lib/components/accordion/accordion-header/AccordionHeader.d.ts +4 -0
  10. package/lib/components/accordion/accordion-item/AccordionItem.d.ts +9 -0
  11. package/lib/components/accordion/accordion-item/AccordionItemContext.d.ts +8 -0
  12. package/lib/components/accordion/accordion-item/accordion-item-body/AccordionItemBody.d.ts +4 -0
  13. package/lib/components/accordion/accordion-item/accordion-item-header/AccordionItemHeader.d.ts +4 -0
  14. package/lib/components/chips/chip/Chip.d.ts +1 -1
  15. package/lib/components/modals/ConfirmModal.d.ts +2 -1
  16. package/lib/components/modals/ModalFooter.d.ts +1 -4
  17. package/lib/components/stepper-horizontal/StepperHorizontal.d.ts +7 -0
  18. package/lib/components/stepper-horizontal/step-horizontal/StepHorizontal.d.ts +7 -0
  19. package/lib/components/stepper-vertical/StepperVertical.d.ts +7 -0
  20. package/lib/components/stepper-vertical/step-vertical/StepVertical.d.ts +12 -0
  21. package/lib/components/tab/Tabs.d.ts +7 -5
  22. package/lib/components/tab/tab-pane/TabPane.d.ts +3 -2
  23. package/lib/components/tab/useTabScroll.d.ts +24 -0
  24. package/lib/forms/color-picker/ColorPicker.d.ts +1 -1
  25. package/lib/forms/radio/RadioButton.d.ts +1 -1
  26. package/lib/forms/radio/RadioGroup.d.ts +1 -1
  27. package/lib/forms/slider/Slider.d.ts +1 -1
  28. package/lib/forms/text-editor/TextEditor.d.ts +1 -1
  29. package/lib/forms/time-picker/TimePicker.d.ts +18 -0
  30. package/lib/forms/time-picker/time-picker-dropdown/TimePickerDropdown.d.ts +12 -0
  31. package/lib/helper/useControlled.d.ts +6 -0
  32. package/lib/helper/useOnClickOutside.d.ts +2 -0
  33. package/package.json +6 -6
  34. package/react.esm.js +0 -3499
  35. package/react.umd.js +0 -3562
package/index.esm.js ADDED
@@ -0,0 +1,4778 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import classNames from 'classnames';
3
+ import React, { createContext, forwardRef, useRef, useState, useContext, useCallback, useMemo, useEffect, isValidElement } from 'react';
4
+ import { Transition, CSSTransition } from 'react-transition-group';
5
+ import OutsideClickHandler from 'react-outside-click-handler';
6
+ import { usePopper } from 'react-popper';
7
+ import Draggable from 'react-draggable';
8
+ import flatpickr from 'flatpickr';
9
+ import rangePlugin from 'flatpickr/dist/plugins/rangePlugin';
10
+ import Quill from 'quill';
11
+ import ReactDOM from 'react-dom';
12
+
13
+ /*! *****************************************************************************
14
+ Copyright (c) Microsoft Corporation.
15
+
16
+ Permission to use, copy, modify, and/or distribute this software for any
17
+ purpose with or without fee is hereby granted.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
+ PERFORMANCE OF THIS SOFTWARE.
26
+ ***************************************************************************** */
27
+
28
+ function __rest(s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ }
39
+
40
+ const AccordionContext$1 = /*#__PURE__*/createContext({});
41
+
42
+ let nextId$2 = 0;
43
+ const Accordion = /*#__PURE__*/forwardRef((_a, ref) => {
44
+ var {
45
+ children,
46
+ showMore = 'Show more',
47
+ showLess = 'Show less',
48
+ keepItemsOpen = true,
49
+ className
50
+ } = _a,
51
+ props = __rest(_a, ["children", "showMore", "showLess", "keepItemsOpen", "className"]);
52
+
53
+ const componentId = useRef(`accordion-${++nextId$2}`);
54
+ const [expanded, setExpanded] = useState(false);
55
+
56
+ const handleChange = (id, newExpanded) => {
57
+ setExpanded(newExpanded ? id : false);
58
+ };
59
+
60
+ const contextValue = {
61
+ showMore,
62
+ showLess,
63
+ parentId: componentId.current,
64
+ keepItemsOpen,
65
+ expanded: expanded,
66
+ toggle: handleChange
67
+ };
68
+ return jsx(AccordionContext$1.Provider, Object.assign({
69
+ value: contextValue
70
+ }, {
71
+ children: jsx("div", Object.assign({
72
+ ref: ref,
73
+ className: classNames('fr-accordion', className)
74
+ }, props, {
75
+ children: children
76
+ }), void 0)
77
+ }), void 0);
78
+ });
79
+
80
+ const AccordionHeader = /*#__PURE__*/forwardRef((_a, ref) => {
81
+ var {
82
+ children,
83
+ className
84
+ } = _a,
85
+ props = __rest(_a, ["children", "className"]);
86
+
87
+ return jsx("div", Object.assign({
88
+ ref: ref,
89
+ className: classNames('fr-accordion-header', className)
90
+ }, props, {
91
+ children: children
92
+ }), void 0);
93
+ });
94
+
95
+ function setRef(ref, value) {
96
+ if (typeof ref === 'function') {
97
+ ref(value);
98
+ } else if (ref !== null) {
99
+ ref.current = value;
100
+ }
101
+ }
102
+
103
+ function useForkRef(refA, refB) {
104
+ /**
105
+ * This will create a new function if the ref props change and are defined.
106
+ * This means react will call the old forkRef with `null` and the new forkRef
107
+ * with the ref. Cleanup naturally emerges from this behavior
108
+ */
109
+ return React.useMemo(() => {
110
+ if (refA == null && refB == null) {
111
+ return null;
112
+ }
113
+
114
+ return instance => {
115
+ setRef(refA, instance);
116
+ setRef(refB, instance);
117
+ };
118
+ }, [refA, refB]);
119
+ }
120
+
121
+ const AccordionContext = /*#__PURE__*/createContext({});
122
+
123
+ const AccordionItemBody = /*#__PURE__*/forwardRef((_a, ref) => {
124
+ var {
125
+ children,
126
+ className
127
+ } = _a,
128
+ props = __rest(_a, ["children", "className"]);
129
+
130
+ const {
131
+ expanded,
132
+ id
133
+ } = useContext(AccordionContext);
134
+ const innerRef = useRef(null);
135
+ const element = innerRef.current;
136
+ const combinedRef = useForkRef(ref, innerRef);
137
+ const initialHeight = useRef(expanded ? 'auto' : 0);
138
+
139
+ const handleEntering = () => {
140
+ const itemHeight = element.scrollHeight;
141
+ element.style.height = `${itemHeight}px`;
142
+ };
143
+
144
+ const handleEntered = () => {
145
+ element.style.height = 'auto';
146
+ };
147
+
148
+ const handleExit = () => {
149
+ const itemHeight = element.scrollHeight;
150
+ element.style.height = `${itemHeight}px`;
151
+ };
152
+
153
+ const handleExiting = () => {
154
+ setTimeout(() => {
155
+ element.style.height = '0px';
156
+ });
157
+ };
158
+
159
+ return jsx(Transition, Object.assign({
160
+ in: expanded,
161
+ nodeRef: innerRef,
162
+ timeout: 300,
163
+ onExit: handleExit,
164
+ onExiting: handleExiting,
165
+ onEntering: handleEntering,
166
+ onEntered: handleEntered
167
+ }, {
168
+ children: jsxs("div", Object.assign({
169
+ ref: combinedRef,
170
+ role: "region",
171
+ id: `${id}-body`,
172
+ "aria-labelledby": `${id}-header`,
173
+ className: classNames('fr-accordion-item-body', className),
174
+ style: {
175
+ height: initialHeight.current,
176
+ minHeight: 0
177
+ }
178
+ }, props, {
179
+ children: [children, jsx("div", {
180
+ className: "fr-accordion-item-body-spacer-bottom"
181
+ }, void 0)]
182
+ }), void 0)
183
+ }), void 0);
184
+ });
185
+
186
+ const AccordionItemHeader = /*#__PURE__*/forwardRef((_a, ref) => {
187
+ var {
188
+ children,
189
+ className
190
+ } = _a,
191
+ props = __rest(_a, ["children", "className"]);
192
+
193
+ const {
194
+ toggle,
195
+ id
196
+ } = useContext(AccordionContext);
197
+ return jsx("div", Object.assign({
198
+ ref: ref,
199
+ className: classNames("fr-accordion-item-header", className),
200
+ role: "button",
201
+ tabIndex: 0,
202
+ id: `${id}-header`,
203
+ "aria-controls": `${id}-body`,
204
+ onClick: toggle
205
+ }, props, {
206
+ children: children
207
+ }), void 0);
208
+ });
209
+
210
+ function useControlled({
211
+ controlled,
212
+ default: defaultValue
213
+ }) {
214
+ const {
215
+ current: isControlled
216
+ } = useRef(controlled !== undefined);
217
+ const [valueState, setValue] = useState(defaultValue);
218
+ const value = isControlled ? controlled : valueState;
219
+ const setValueIfUncontrolled = useCallback(newValue => {
220
+ if (!isControlled) {
221
+ setValue(newValue);
222
+ }
223
+ }, [isControlled]);
224
+ return [value, setValueIfUncontrolled];
225
+ }
226
+
227
+ let nextId$1 = 0;
228
+ const AccordionItem = /*#__PURE__*/forwardRef((_a, ref) => {
229
+ var {
230
+ expanded: expandedProp,
231
+ defaultExpanded = false,
232
+ children,
233
+ onChange,
234
+ className
235
+ } = _a,
236
+ props = __rest(_a, ["expanded", "defaultExpanded", "children", "onChange", "className"]);
237
+
238
+ const {
239
+ showLess,
240
+ showMore,
241
+ parentId,
242
+ keepItemsOpen,
243
+ expanded: expandedContext,
244
+ toggle: accordionToggle
245
+ } = useContext(AccordionContext$1);
246
+ const componentId = useRef(`accordion-item-${++nextId$1}`);
247
+ const id = `${parentId}-${componentId.current}`;
248
+ const controlledExpanded = keepItemsOpen ? expandedProp : expandedContext === id;
249
+ const [expanded, setExpanded] = useControlled({
250
+ controlled: controlledExpanded,
251
+ default: defaultExpanded
252
+ });
253
+ const linkText = expanded ? showLess : showMore;
254
+ const handleChange = useCallback(event => {
255
+ if (onChange) {
256
+ onChange(event, !expanded);
257
+ }
258
+
259
+ if (!keepItemsOpen) {
260
+ accordionToggle(id, !expanded);
261
+ }
262
+
263
+ setExpanded(!expanded);
264
+ }, [accordionToggle, expanded, id, keepItemsOpen, onChange, setExpanded]);
265
+ const contextValue = useMemo(() => ({
266
+ expanded,
267
+ toggle: handleChange,
268
+ id
269
+ }), [expanded, handleChange, id]);
270
+ return jsx(AccordionContext.Provider, Object.assign({
271
+ value: contextValue
272
+ }, {
273
+ children: jsxs("div", Object.assign({
274
+ ref: ref,
275
+ className: classNames('fr-accordion-item', {
276
+ 'fr-accordion-item--collapsed': !expanded,
277
+ 'fr-accordion-item--expanded': expanded
278
+ }, className)
279
+ }, props, {
280
+ children: [children, jsx("div", Object.assign({
281
+ className: "fr-accordion-item-link"
282
+ }, {
283
+ children: linkText
284
+ }), void 0)]
285
+ }), void 0)
286
+ }), void 0);
287
+ });
288
+
289
+ /**
290
+ * Breadcrumb navigation can be used on pages with multiple navigation levels.
291
+ */
292
+
293
+ function Breadcrumb({
294
+ locations,
295
+ onClick,
296
+ children,
297
+ className
298
+ }) {
299
+ const childrenList = [];
300
+ React.Children.forEach(children, element => {
301
+ if ( /*#__PURE__*/React.isValidElement(element)) {
302
+ childrenList.push(Object.assign(Object.assign({}, element), {
303
+ props: Object.assign(Object.assign({}, element.props), {
304
+ className: 'fr-breadcrumb-location'
305
+ })
306
+ }));
307
+ }
308
+ });
309
+ return jsx("div", Object.assign({
310
+ className: classNames('fwe-breadcrumb', className)
311
+ }, {
312
+ children: locations ? locations.map((location, index) => jsxs(React.Fragment, {
313
+ children: [jsx("a", Object.assign({
314
+ className: "fr-breadcrumb-location",
315
+ href: location.url,
316
+ onClick: e => onClick ? onClick(e) : undefined
317
+ }, {
318
+ children: location.label
319
+ }), void 0), index + 1 < locations.length && jsx("i", {
320
+ className: "fwe-icon fwe-icon-arrows-right-2"
321
+ }, void 0)]
322
+ }, location.url)) : childrenList.map((child, index) => jsxs(React.Fragment, {
323
+ children: [child, " ", index + 1 < childrenList.length && jsx("i", {
324
+ className: "fwe-icon fwe-icon-arrows-right-2"
325
+ }, void 0)]
326
+ }, child.props.children))
327
+ }), void 0);
328
+ }
329
+
330
+ function Button({
331
+ icon,
332
+ disabled = false,
333
+ iconOnly = false,
334
+ large = false,
335
+ onClick,
336
+ primary = false,
337
+ className,
338
+ children
339
+ }) {
340
+ const classes = classNames('fwe-btn', 'fr-button', {
341
+ 'fwe-btn-icon': iconOnly
342
+ }, {
343
+ 'fwe-disabled': disabled
344
+ }, {
345
+ 'fwe-btn-hero': primary
346
+ }, {
347
+ 'fwe-btn-lg': large
348
+ }, className);
349
+ return jsxs("button", Object.assign({
350
+ type: "button",
351
+ onClick: onClick,
352
+ className: classes,
353
+ disabled: disabled
354
+ }, {
355
+ children: [icon && jsx("i", {
356
+ className: `fwe-icon fwe-icon-${icon}`
357
+ }, void 0), !iconOnly && jsx("div", {
358
+ children: children
359
+ }, void 0)]
360
+ }), void 0);
361
+ }
362
+
363
+ function Card({
364
+ children,
365
+ className
366
+ }) {
367
+ return jsx("div", Object.assign({
368
+ className: classNames('fwe-card', className)
369
+ }, {
370
+ children: children
371
+ }), void 0);
372
+ }
373
+
374
+ function CardBody({
375
+ children,
376
+ text,
377
+ className
378
+ }) {
379
+ return jsxs("div", Object.assign({
380
+ className: classNames('fwe-card-body', className)
381
+ }, {
382
+ children: [jsx("div", Object.assign({
383
+ className: "fwe-card-text"
384
+ }, {
385
+ children: text
386
+ }), void 0), children]
387
+ }), void 0);
388
+ }
389
+
390
+ function CardHeader({
391
+ title,
392
+ subtitle,
393
+ action,
394
+ className
395
+ }) {
396
+ return jsxs("div", Object.assign({
397
+ className: classNames('fwe-card-header', className)
398
+ }, {
399
+ children: [jsxs("div", Object.assign({
400
+ className: "fwe-card-title"
401
+ }, {
402
+ children: [jsx("h5", {
403
+ children: title
404
+ }, void 0), subtitle && jsx("p", {
405
+ children: subtitle
406
+ }, void 0)]
407
+ }), void 0), action]
408
+ }), void 0);
409
+ }
410
+
411
+ function CardNotification({
412
+ iconName,
413
+ className,
414
+ title,
415
+ message
416
+ }) {
417
+ const classes = classNames('fwe-card-notification', className);
418
+ return jsxs("div", Object.assign({
419
+ className: classes
420
+ }, {
421
+ children: [jsx("i", {
422
+ className: `fwe-icon fwe-icon-${iconName} fwe-icon-lg`
423
+ }, void 0), jsxs("div", Object.assign({
424
+ className: "fwe-card-title"
425
+ }, {
426
+ children: [jsx("h6", {
427
+ children: title
428
+ }, void 0), message && jsx("p", {
429
+ children: message
430
+ }, void 0)]
431
+ }), void 0)]
432
+ }), void 0);
433
+ }
434
+
435
+ function ChipContainer({
436
+ large = false,
437
+ children,
438
+ className
439
+ }) {
440
+ const classes = classNames('fwe-chip-container', {
441
+ 'fwe-chip-container-lg': large
442
+ }, className);
443
+ return jsx("div", Object.assign({
444
+ className: classes
445
+ }, {
446
+ children: children
447
+ }), void 0);
448
+ }
449
+
450
+ var ChipType;
451
+
452
+ (function (ChipType) {
453
+ ChipType[ChipType["Choice"] = 0] = "Choice";
454
+ ChipType[ChipType["Category"] = 1] = "Category";
455
+ ChipType[ChipType["Filter"] = 2] = "Filter";
456
+ ChipType[ChipType["Action"] = 3] = "Action";
457
+ ChipType[ChipType["Readonly"] = 4] = "Readonly";
458
+ })(ChipType || (ChipType = {}));
459
+
460
+ function Chip({
461
+ type = ChipType.Choice,
462
+ selected = false,
463
+ disabled = false,
464
+ large = false,
465
+ icon,
466
+ children,
467
+ onClick,
468
+ className
469
+ }) {
470
+ const classes = classNames('fr-chip', 'fwe-chip', {
471
+ 'fwe-selected': selected
472
+ }, {
473
+ 'fwe-disabled': disabled
474
+ }, {
475
+ 'fwe-chip-lg': large
476
+ }, {
477
+ 'fwe-category': type === ChipType.Category
478
+ }, {
479
+ 'fwe-filter': type === ChipType.Filter
480
+ }, {
481
+ 'fwe-readonly': type === ChipType.Readonly
482
+ }, className);
483
+ return jsxs("div", Object.assign({
484
+ className: classes
485
+ }, {
486
+ children: [icon && jsx("i", {
487
+ onClick: e => onClick ? onClick(e) : undefined,
488
+ className: `fwe-icon fwe-icon-${icon}`
489
+ }, void 0), children, type === ChipType.Category && jsx("i", {
490
+ onClick: e => onClick ? onClick(e) : undefined,
491
+ className: "fwe-icon fwe-icon-menu-close"
492
+ }, void 0)]
493
+ }), void 0);
494
+ }
495
+
496
+ function LinkButton({
497
+ icon,
498
+ onClick,
499
+ disabled = false,
500
+ children,
501
+ iconOnly = false,
502
+ className
503
+ }) {
504
+ const classes = classNames('fwe-btn', 'fwe-btn-link', {
505
+ 'fwe-disabled': disabled
506
+ }, className);
507
+ return jsxs("button", Object.assign({
508
+ onClick: onClick,
509
+ type: "button",
510
+ className: classes,
511
+ disabled: disabled
512
+ }, {
513
+ children: [jsx("i", {
514
+ className: `fwe-icon fwe-icon-${icon}`
515
+ }, void 0), !iconOnly && children]
516
+ }), void 0);
517
+ }
518
+
519
+ function LoadingIndicator({
520
+ size = 'large',
521
+ children,
522
+ className
523
+ }) {
524
+ const classes = classNames('fwe-waiting-indicator', {
525
+ 'fwe-waiting-indicator-md': size === 'medium'
526
+ }, {
527
+ 'fwe-waiting-indicator-sm': size === 'small'
528
+ }, className);
529
+ return jsxs("div", Object.assign({
530
+ className: "fr-waiting-container"
531
+ }, {
532
+ children: [jsxs("div", Object.assign({
533
+ className: classes
534
+ }, {
535
+ children: [jsx("div", {
536
+ className: "fwe-waiting-circle-1"
537
+ }, void 0), jsx("div", {
538
+ className: "fwe-waiting-circle-2"
539
+ }, void 0), jsx("div", {
540
+ className: "fwe-waiting-circle-3"
541
+ }, void 0)]
542
+ }), void 0), children]
543
+ }), void 0);
544
+ }
545
+
546
+ const Modal = /*#__PURE__*/forwardRef(({
547
+ head,
548
+ isOpen,
549
+ body,
550
+ onClose,
551
+ className,
552
+ children
553
+ }, ref) => {
554
+ const backdropRef = useRef(null);
555
+ const modalRef = useRef(null);
556
+ const combinedRef = useForkRef(ref, modalRef);
557
+ return jsxs(Fragment, {
558
+ children: [jsx(CSSTransition, Object.assign({
559
+ nodeRef: backdropRef,
560
+ unmountOnExit: true,
561
+ timeout: {
562
+ exit: 600
563
+ },
564
+ in: isOpen,
565
+ classNames: "fr-modal-backdrop",
566
+ appear: true
567
+ }, {
568
+ children: jsx("div", {
569
+ ref: backdropRef,
570
+ className: "fr-modal-backdrop fwe-modal-backdrop"
571
+ }, void 0)
572
+ }), void 0), jsx(OutsideClickHandler, Object.assign({
573
+ onOutsideClick: () => onClose ? onClose() : undefined
574
+ }, {
575
+ children: jsx(CSSTransition, Object.assign({
576
+ ref: modalRef,
577
+ unmountOnExit: true,
578
+ classNames: "fr-modal",
579
+ appear: true,
580
+ in: isOpen,
581
+ timeout: {
582
+ exit: 600
583
+ }
584
+ }, {
585
+ children: jsxs("div", Object.assign({
586
+ ref: combinedRef,
587
+ className: classNames('fr-modal fwe-modal', className)
588
+ }, {
589
+ children: [jsx("div", Object.assign({
590
+ className: "fwe-modal-close"
591
+ }, {
592
+ children: jsxs("button", Object.assign({
593
+ type: "button",
594
+ "aria-label": "Close",
595
+ className: "fwe-btn fwe-btn-link fwe-dark",
596
+ onClick: onClose
597
+ }, {
598
+ children: [jsx("i", {
599
+ "aria-hidden": "true",
600
+ className: "fwe-icon fwe-icon-close-small"
601
+ }, void 0), jsx("span", Object.assign({
602
+ className: "fwe-sr-only"
603
+ }, {
604
+ children: "Close"
605
+ }), void 0)]
606
+ }), void 0)
607
+ }), void 0), jsx("div", Object.assign({
608
+ className: "fwe-modal-header"
609
+ }, {
610
+ children: head
611
+ }), void 0), jsx("div", Object.assign({
612
+ className: "fwe-modal-body"
613
+ }, {
614
+ children: body
615
+ }), void 0), children]
616
+ }), void 0)
617
+ }), void 0)
618
+ }), void 0)]
619
+ }, void 0);
620
+ });
621
+
622
+ const ModalFooter = /*#__PURE__*/forwardRef(({
623
+ children,
624
+ className
625
+ }, ref) => {
626
+ return jsx("div", Object.assign({
627
+ ref: ref,
628
+ className: classNames('fwe-modal-footer', className)
629
+ }, {
630
+ children: jsx("div", Object.assign({
631
+ className: classNames('fwe-modal-buttons')
632
+ }, {
633
+ children: children
634
+ }), void 0)
635
+ }), void 0);
636
+ });
637
+
638
+ function AlertModal(_a) {
639
+ var {
640
+ alertType,
641
+ title,
642
+ className,
643
+ body,
644
+ strong,
645
+ subtitle,
646
+ cancel,
647
+ ok,
648
+ onCancel,
649
+ onOk
650
+ } = _a,
651
+ props = __rest(_a, ["alertType", "title", "className", "body", "strong", "subtitle", "cancel", "ok", "onCancel", "onOk"]);
652
+
653
+ return jsx(Modal, Object.assign({
654
+ className: classNames({
655
+ 'fwe-modal--with-indicator-bar': strong,
656
+ 'fwe-modal--warning': alertType === 'warning',
657
+ 'fwe-modal--error': alertType === 'error',
658
+ 'fwe-modal--info': alertType === 'info'
659
+ }, className),
660
+ head: jsxs(Fragment, {
661
+ children: [subtitle && jsxs("h2", Object.assign({
662
+ className: "fwe-modal-h2"
663
+ }, {
664
+ children: [jsx("i", {
665
+ className: classNames({
666
+ 'fwe-icon': true,
667
+ 'fwe-icon-status-warning': alertType === 'warning',
668
+ 'fwe-icon-status-failure': alertType === 'error',
669
+ 'fwe-icon-status-check-status': alertType === 'info'
670
+ })
671
+ }, void 0), subtitle]
672
+ }), void 0), jsxs("h1", Object.assign({
673
+ className: "fwe-modal-h1"
674
+ }, {
675
+ children: [jsx("i", {
676
+ className: classNames({
677
+ 'fwe-icon': true,
678
+ 'fwe-icon-status-warning': alertType === 'warning',
679
+ 'fwe-icon-status-failure': alertType === 'error',
680
+ 'fwe-icon-status-check-status': alertType === 'info'
681
+ })
682
+ }, void 0), title]
683
+ }), void 0)]
684
+ }, void 0),
685
+ body: jsx("p", {
686
+ children: body
687
+ }, void 0)
688
+ }, props, {
689
+ children: (cancel || ok) && jsxs(ModalFooter, {
690
+ children: [cancel && jsx("button", Object.assign({
691
+ type: "button",
692
+ "aria-label": "Cancel",
693
+ className: classNames('fwe-btn fwe-btn-lg', {
694
+ 'fwe-btn-link': strong
695
+ }),
696
+ onClick: onCancel
697
+ }, {
698
+ children: cancel
699
+ }), void 0), ok && jsx("button", Object.assign({
700
+ type: "button",
701
+ "aria-label": "Ok",
702
+ className: classNames('fwe-btn fwe-btn-lg', {
703
+ 'fwe-btn-hero': !strong
704
+ }),
705
+ onClick: onOk
706
+ }, {
707
+ children: ok
708
+ }), void 0)]
709
+ }, void 0)
710
+ }), void 0);
711
+ }
712
+
713
+ function ConfirmModal(_a) {
714
+ var {
715
+ title,
716
+ subtitle,
717
+ body,
718
+ className,
719
+ cancel,
720
+ ok,
721
+ onCancel,
722
+ onOk,
723
+ isOpen,
724
+ large
725
+ } = _a,
726
+ props = __rest(_a, ["title", "subtitle", "body", "className", "cancel", "ok", "onCancel", "onOk", "isOpen", "large"]);
727
+
728
+ return jsx(Modal, Object.assign({
729
+ className: classNames({
730
+ 'fwe-modal--large': large
731
+ }, className),
732
+ head: jsxs(Fragment, {
733
+ children: [subtitle && jsx("h2", Object.assign({
734
+ className: "fwe-modal-h2"
735
+ }, {
736
+ children: subtitle
737
+ }), void 0), jsx("h1", Object.assign({
738
+ className: "fwe-modal-h1"
739
+ }, {
740
+ children: title
741
+ }), void 0)]
742
+ }, void 0),
743
+ body: jsx("p", {
744
+ children: body
745
+ }, void 0),
746
+ isOpen: isOpen
747
+ }, props, {
748
+ children: (cancel || ok) && jsxs(ModalFooter, {
749
+ children: [cancel && jsx("button", Object.assign({
750
+ type: "button",
751
+ "aria-label": "Cancel",
752
+ className: "fwe-btn fwe-btn-lg",
753
+ onClick: onCancel
754
+ }, {
755
+ children: cancel
756
+ }), void 0), ok && jsx("button", Object.assign({
757
+ type: "button",
758
+ "aria-label": "Ok",
759
+ className: "fwe-btn fwe-btn-hero fwe-btn-lg",
760
+ onClick: onOk
761
+ }, {
762
+ children: ok
763
+ }), void 0)]
764
+ }, void 0)
765
+ }), void 0);
766
+ }
767
+
768
+ const TextInput = _a => {
769
+ var {
770
+ disabled,
771
+ required,
772
+ readonly,
773
+ placeholder,
774
+ max,
775
+ min,
776
+ onBlur,
777
+ onFocus,
778
+ onInput,
779
+ step,
780
+ type,
781
+ value,
782
+ error,
783
+ hint,
784
+ label,
785
+ labelClassName
786
+ } = _a,
787
+ props = __rest(_a, ["disabled", "required", "readonly", "placeholder", "max", "min", "onBlur", "onFocus", "onInput", "step", "type", "value", "error", "hint", "label", "labelClassName"]);
788
+
789
+ const [innerValue, setInnerValue] = useState(value);
790
+ useEffect(() => {
791
+ setInnerValue(value);
792
+ }, [value]);
793
+ const supported = ['text', 'number', 'password', 'datetime-local'];
794
+ const innerType = type && supported.indexOf(type) !== -1 ? type : 'text';
795
+ const labelClasses = classNames('fwe-input-text', labelClassName);
796
+ const hintClasses = classNames('fwe-input-text-info');
797
+
798
+ function handleChange(e) {
799
+ setInnerValue(e.target.value);
800
+
801
+ if (props.onChange) {
802
+ props.onChange(e);
803
+ }
804
+ }
805
+
806
+ return jsxs("label", Object.assign({
807
+ className: labelClasses
808
+ }, {
809
+ children: [jsx("input", Object.assign({
810
+ disabled: disabled,
811
+ required: required,
812
+ readOnly: readonly,
813
+ placeholder: placeholder,
814
+ autoComplete: "off",
815
+ min: min,
816
+ max: max,
817
+ step: step,
818
+ onChange: handleChange,
819
+ onBlur: onBlur,
820
+ onFocus: onFocus,
821
+ onInput: onInput,
822
+ type: innerType,
823
+ value: innerValue
824
+ }, props), void 0), jsx("span", Object.assign({
825
+ className: "fwe-input-text-label"
826
+ }, {
827
+ children: label
828
+ }), void 0), hint && jsx("span", Object.assign({
829
+ className: hintClasses
830
+ }, {
831
+ children: hint
832
+ }), void 0), error && jsx("span", Object.assign({
833
+ className: "fwe-input-text-invalid"
834
+ }, {
835
+ children: error
836
+ }), void 0)]
837
+ }), void 0);
838
+ };
839
+
840
+ function Prompt(_a) {
841
+ var {
842
+ title,
843
+ subtitle,
844
+ hint,
845
+ label,
846
+ value,
847
+ onChange,
848
+ onOk,
849
+ onCancel,
850
+ cancel,
851
+ ok
852
+ } = _a,
853
+ props = __rest(_a, ["title", "subtitle", "hint", "label", "value", "onChange", "onOk", "onCancel", "cancel", "ok"]);
854
+
855
+ const [innerValue, setInnerValue] = useState(value);
856
+ useEffect(() => {
857
+ setInnerValue(value);
858
+ }, [value]);
859
+
860
+ function handleChange(e) {
861
+ setInnerValue(e.target.value);
862
+
863
+ if (onChange) {
864
+ onChange(e);
865
+ }
866
+ }
867
+
868
+ return jsx(Modal, Object.assign({
869
+ head: jsxs(Fragment, {
870
+ children: [subtitle && jsx("h2", Object.assign({
871
+ className: "fwe-modal-h2"
872
+ }, {
873
+ children: subtitle
874
+ }), void 0), jsx("h1", Object.assign({
875
+ className: "fwe-modal-h1"
876
+ }, {
877
+ children: title
878
+ }), void 0)]
879
+ }, void 0),
880
+ body: jsx(TextInput, {
881
+ onChange: handleChange,
882
+ label: label,
883
+ hint: hint,
884
+ value: innerValue
885
+ }, void 0)
886
+ }, props, {
887
+ children: (cancel || ok) && jsxs(ModalFooter, {
888
+ children: [cancel && jsx("button", Object.assign({
889
+ type: "button",
890
+ "aria-label": "Cancel",
891
+ className: "fwe-btn",
892
+ onClick: onCancel
893
+ }, {
894
+ children: cancel
895
+ }), void 0), ok && jsx("button", Object.assign({
896
+ type: "button",
897
+ "aria-label": "Ok",
898
+ className: "fwe-btn fwe-btn-hero",
899
+ onClick: () => onOk(innerValue)
900
+ }, {
901
+ children: ok
902
+ }), void 0)]
903
+ }, void 0)
904
+ }), void 0);
905
+ }
906
+
907
+ var PaginationType;
908
+
909
+ (function (PaginationType) {
910
+ PaginationType["Simple"] = "SIMPLE";
911
+ PaginationType["Numeric"] = "NUMERIC";
912
+ PaginationType["Dots"] = "DOTS";
913
+ })(PaginationType || (PaginationType = {}));
914
+
915
+ function Pagination(props) {
916
+ const {
917
+ pageMax,
918
+ onChange,
919
+ pageCurrent,
920
+ defaultPageCurrent = 1,
921
+ type = PaginationType.Numeric,
922
+ className
923
+ } = props;
924
+ const controlled = pageCurrent !== undefined;
925
+ const [innerPageCurrent, setInnerPageCurrent] = useState(controlled ? pageCurrent : defaultPageCurrent);
926
+ const dotArray = Array.from(new Array(pageMax).keys());
927
+ useEffect(() => {
928
+ if (controlled) {
929
+ setInnerPageCurrent(pageCurrent);
930
+ }
931
+ }, [pageCurrent, controlled]);
932
+
933
+ function handleChange(newPage) {
934
+ if (!controlled) {
935
+ setInnerPageCurrent(newPage);
936
+ }
937
+
938
+ if (onChange) {
939
+ onChange(newPage);
940
+ }
941
+ }
942
+
943
+ function onBtnDown() {
944
+ if (innerPageCurrent > 1) {
945
+ const newPageCurrent = innerPageCurrent - 1;
946
+ handleChange(newPageCurrent);
947
+ }
948
+ }
949
+
950
+ function onBtnUp() {
951
+ if (innerPageCurrent < pageMax) {
952
+ const newPageCurrent = innerPageCurrent + 1;
953
+ handleChange(newPageCurrent);
954
+ }
955
+ }
956
+
957
+ function onDotClick(index) {
958
+ const newPageCurrent = index + 1;
959
+ handleChange(newPageCurrent);
960
+ }
961
+
962
+ function handleKeyPress(event, index) {
963
+ if (event.key === 'Enter' || event.key === ' ') {
964
+ onDotClick(index);
965
+ }
966
+ }
967
+
968
+ return jsxs(Fragment, {
969
+ children: [type !== PaginationType.Dots && jsxs("div", Object.assign({
970
+ className: classNames('fwe-pagination fwe-p-m', {
971
+ 'fwe-d-none': pageMax < 2
972
+ }, className)
973
+ }, {
974
+ children: [jsx("button", {
975
+ className: classNames('fwe-navigate-btn-down', {
976
+ 'fwe-disabled': innerPageCurrent <= 1
977
+ }),
978
+ onClick: onBtnDown,
979
+ type: "button",
980
+ "aria-label": "navigate-btn-down"
981
+ }, void 0), type === PaginationType.Numeric && jsxs(Fragment, {
982
+ children: [jsx("span", Object.assign({
983
+ className: "fwe-page-current"
984
+ }, {
985
+ children: innerPageCurrent
986
+ }), void 0), jsx("span", Object.assign({
987
+ className: "fwe-page-max"
988
+ }, {
989
+ children: pageMax
990
+ }), void 0)]
991
+ }, void 0), jsx("button", {
992
+ className: classNames('fwe-navigate-btn-up', {
993
+ 'fwe-disabled': innerPageCurrent >= pageMax,
994
+ 'fwe-ml-4': type === PaginationType.Simple
995
+ }),
996
+ onClick: onBtnUp,
997
+ type: "button",
998
+ "aria-label": "navigate-btn-up"
999
+ }, void 0)]
1000
+ }), void 0), type === PaginationType.Dots && jsx("div", Object.assign({
1001
+ className: classNames('fwe-p-m', {
1002
+ 'fwe-d-none': pageMax < 2
1003
+ }, className)
1004
+ }, {
1005
+ children: jsx("div", Object.assign({
1006
+ className: "fwe-pagination"
1007
+ }, {
1008
+ children: dotArray.map(index => jsx("span", {
1009
+ tabIndex: 0,
1010
+ role: "button",
1011
+ className: classNames('fwe-page-dot', {
1012
+ 'fwe-selected': index + 1 === innerPageCurrent
1013
+ }),
1014
+ onClick: () => onDotClick(index),
1015
+ "aria-label": "page-dot",
1016
+ onKeyPress: e => handleKeyPress(e, index)
1017
+ }, index))
1018
+ }), void 0)
1019
+ }), void 0)]
1020
+ }, void 0);
1021
+ }
1022
+
1023
+ function Popover({
1024
+ popoverContent,
1025
+ children,
1026
+ position,
1027
+ fallbackPositions,
1028
+ open = false,
1029
+ onStatusChange,
1030
+ wrapper,
1031
+ className,
1032
+ flip = true,
1033
+ containerClassName,
1034
+ stopPropagation,
1035
+ arrow = true
1036
+ }) {
1037
+ const [showPopper, setShowPopper] = useState(open);
1038
+ const referenceElement = useRef(null);
1039
+ const [popperElement, setPopperElement] = useState(null);
1040
+ const [arrowElement, setArrowElement] = useState(null);
1041
+ const classes = classNames(className);
1042
+ useEffect(() => {
1043
+ setShowPopper(open);
1044
+ }, [open]);
1045
+ const {
1046
+ styles,
1047
+ attributes
1048
+ } = usePopper(referenceElement.current, popperElement, {
1049
+ placement: position,
1050
+ modifiers: [{
1051
+ name: 'arrow',
1052
+ options: {
1053
+ element: arrowElement
1054
+ }
1055
+ }, {
1056
+ name: 'offset',
1057
+ options: {
1058
+ offset: [0, 24]
1059
+ }
1060
+ }, {
1061
+ name: 'flip',
1062
+ options: {
1063
+ fallbackPlacements: flip ? fallbackPositions : [position || 'auto']
1064
+ }
1065
+ }]
1066
+ });
1067
+
1068
+ const handleChange = (e, status) => {
1069
+ if (stopPropagation) {
1070
+ e.stopPropagation();
1071
+ }
1072
+
1073
+ setShowPopper(status);
1074
+
1075
+ if (onStatusChange) {
1076
+ onStatusChange(status);
1077
+ }
1078
+ };
1079
+
1080
+ const childrenWrapper = jsx("div", Object.assign({
1081
+ className: classes,
1082
+ style: {
1083
+ display: 'inline'
1084
+ },
1085
+ ref: referenceElement,
1086
+ onClick: e => handleChange(e, !showPopper)
1087
+ }, {
1088
+ children: children
1089
+ }), void 0);
1090
+
1091
+ return jsxs(OutsideClickHandler, Object.assign({
1092
+ display: "inline",
1093
+ onOutsideClick: e => handleChange(e, false)
1094
+ }, {
1095
+ children: [wrapper ? wrapper(childrenWrapper) : childrenWrapper, showPopper && jsxs("div", Object.assign({
1096
+ onClick: e => e.stopPropagation(),
1097
+ className: classNames('fwe-popover-container', containerClassName),
1098
+ ref: setPopperElement,
1099
+ style: styles.popper
1100
+ }, attributes.popper, {
1101
+ children: [jsx("div", Object.assign({
1102
+ className: "fwe-popover"
1103
+ }, {
1104
+ children: popoverContent
1105
+ }), void 0), arrow && jsx("div", {
1106
+ ref: setArrowElement,
1107
+ style: styles.arrow,
1108
+ id: "arrow"
1109
+ }, void 0)]
1110
+ }), void 0)]
1111
+ }), void 0);
1112
+ }
1113
+
1114
+ function PopoverMenu(_a) {
1115
+ var {
1116
+ icon,
1117
+ menu,
1118
+ className
1119
+ } = _a,
1120
+ props = __rest(_a, ["icon", "menu", "className"]);
1121
+
1122
+ const [showPopper, setShowPopper] = useState(false);
1123
+
1124
+ const handleClick = item => {
1125
+ if (item.action) {
1126
+ item.action(item.data);
1127
+ }
1128
+
1129
+ setShowPopper(false);
1130
+ };
1131
+
1132
+ const content = jsx("ul", Object.assign({
1133
+ className: "fwe-list-group"
1134
+ }, {
1135
+ children: menu.map(item => jsx("li", Object.assign({
1136
+ className: "fwe-list-group-item"
1137
+ }, {
1138
+ children: jsxs("button", Object.assign({
1139
+ type: "button",
1140
+ className: "fwe-btn fwe-btn-link fwe-dark",
1141
+ onClick: () => handleClick(item)
1142
+ }, {
1143
+ children: [jsx("i", {
1144
+ className: `fwe-icon fwe-pr-0 ${item.icon}`
1145
+ }, void 0), jsx("span", {
1146
+ children: item.text
1147
+ }, void 0)]
1148
+ }), void 0)
1149
+ }), item.icon + item.text))
1150
+ }), void 0);
1151
+
1152
+ return jsx("div", Object.assign({
1153
+ className: classNames('fwe-popover-menu', className)
1154
+ }, {
1155
+ children: jsx(Popover, Object.assign({
1156
+ popoverContent: content,
1157
+ position: "right",
1158
+ open: showPopper,
1159
+ onStatusChange: setShowPopper
1160
+ }, props, {
1161
+ children: jsx("button", Object.assign({
1162
+ type: "button",
1163
+ className: "fwe-btn fwe-btn-link fwe-dark origin"
1164
+ }, {
1165
+ children: jsx("i", {
1166
+ className: `fwe-icon fwe-pr-0 ${icon}`
1167
+ }, void 0)
1168
+ }), void 0)
1169
+ }), void 0)
1170
+ }), void 0);
1171
+ }
1172
+
1173
+ function Tooltip({
1174
+ children,
1175
+ className,
1176
+ title,
1177
+ position = 'bottom'
1178
+ }) {
1179
+ const [showPopper, setShowPopper] = useState(false);
1180
+ const referenceElement = useRef(null);
1181
+ const [popperElement, setPopperElement] = useState(null);
1182
+ const [arrowElement, setArrowElement] = useState(null);
1183
+ const {
1184
+ styles,
1185
+ attributes
1186
+ } = usePopper(referenceElement.current, popperElement, {
1187
+ placement: position,
1188
+ modifiers: [{
1189
+ name: 'arrow',
1190
+ options: {
1191
+ element: arrowElement
1192
+ }
1193
+ }, {
1194
+ name: 'offset',
1195
+ options: {
1196
+ offset: [0, 24]
1197
+ }
1198
+ }, {
1199
+ name: 'flip',
1200
+ options: {
1201
+ fallbackPlacements: ['right', 'left', 'top']
1202
+ }
1203
+ }]
1204
+ });
1205
+ return jsxs(Fragment, {
1206
+ children: [jsx("div", Object.assign({
1207
+ className: classNames('fr-tooltip-container', className),
1208
+ ref: referenceElement,
1209
+ onMouseEnter: () => setShowPopper(true),
1210
+ onMouseLeave: () => setShowPopper(false)
1211
+ }, {
1212
+ children: children
1213
+ }), void 0), showPopper && jsxs("div", Object.assign({
1214
+ className: "fwe-popover-container",
1215
+ id: "tooltip",
1216
+ ref: setPopperElement,
1217
+ style: styles.popper
1218
+ }, attributes.popper, {
1219
+ children: [jsx("div", {
1220
+ ref: setArrowElement,
1221
+ style: styles.arrow,
1222
+ id: "arrow"
1223
+ }, void 0), jsx("div", Object.assign({
1224
+ className: "fwe-popover"
1225
+ }, {
1226
+ children: title
1227
+ }), void 0)]
1228
+ }), void 0)]
1229
+ }, void 0);
1230
+ }
1231
+
1232
+ function Progress({
1233
+ background = 'white',
1234
+ error = false,
1235
+ progress,
1236
+ className
1237
+ }) {
1238
+ const classes = classNames('fwe-progress-bar', {
1239
+ 'fwe-bg-red': error
1240
+ }, {
1241
+ 'fwe-progress-bar-black': background === 'black'
1242
+ }, {
1243
+ 'fwe-progress-bar-background': background === 'background'
1244
+ });
1245
+ return jsx("div", Object.assign({
1246
+ className: classNames('fwe-progress', className)
1247
+ }, {
1248
+ children: jsx("div", {
1249
+ className: classes,
1250
+ role: "progressbar",
1251
+ style: {
1252
+ width: `${progress}%`
1253
+ },
1254
+ "aria-valuenow": progress,
1255
+ "aria-valuemin": 0,
1256
+ "aria-valuemax": 100,
1257
+ "aria-label": "progressbar"
1258
+ }, void 0)
1259
+ }), void 0);
1260
+ }
1261
+
1262
+ function Snackbar(props) {
1263
+ const {
1264
+ data,
1265
+ onAction,
1266
+ onClose,
1267
+ first = false
1268
+ } = props;
1269
+ const [show, setShow] = useState(true);
1270
+ const nodeRef = useRef(null);
1271
+ useEffect(() => {
1272
+ let disappearAfter = 5000;
1273
+
1274
+ if ((data === null || data === void 0 ? void 0 : data.disappearAfter) !== null) {
1275
+ if ((data === null || data === void 0 ? void 0 : data.disappearAfter) && (data === null || data === void 0 ? void 0 : data.disappearAfter) > 0) {
1276
+ disappearAfter = data === null || data === void 0 ? void 0 : data.disappearAfter;
1277
+ }
1278
+
1279
+ const timer = setTimeout(() => setShow(false), disappearAfter);
1280
+ return () => {
1281
+ clearTimeout(timer);
1282
+ };
1283
+ }
1284
+
1285
+ return undefined;
1286
+ }, [data]);
1287
+
1288
+ function handleClose() {
1289
+ setShow(false);
1290
+ }
1291
+
1292
+ const classes = first ? 'fr-snackbar-wrapper--first' : 'fr-snackbar-wrapper';
1293
+ return jsx(CSSTransition, Object.assign({
1294
+ nodeRef: nodeRef,
1295
+ onExited: () => onClose ? onClose() : undefined,
1296
+ unmountOnExit: true,
1297
+ timeout: {
1298
+ exit: 600
1299
+ },
1300
+ in: show,
1301
+ classNames: classes,
1302
+ appear: true
1303
+ }, {
1304
+ children: jsx("div", Object.assign({
1305
+ ref: nodeRef,
1306
+ className: classes
1307
+ }, {
1308
+ children: jsxs("div", Object.assign({
1309
+ className: classNames({
1310
+ 'fwe-snackbar': true,
1311
+ 'fwe-snackbar-b': (data === null || data === void 0 ? void 0 : data.variant) === 'b',
1312
+ 'fwe-snackbar-c': (data === null || data === void 0 ? void 0 : data.variant) === 'c',
1313
+ 'fwe-snackbar-warning': (data === null || data === void 0 ? void 0 : data.type) === 'warning',
1314
+ 'fwe-snackbar-error': (data === null || data === void 0 ? void 0 : data.type) === 'error',
1315
+ 'fwe-snackbar-shadow': data === null || data === void 0 ? void 0 : data.darkBackground
1316
+ }, data === null || data === void 0 ? void 0 : data.className)
1317
+ }, {
1318
+ children: [(data === null || data === void 0 ? void 0 : data.type) && jsx("i", {
1319
+ "aria-hidden": true,
1320
+ className: classNames({
1321
+ 'fwe-icon': true,
1322
+ 'fwe-icon-status-info': (data === null || data === void 0 ? void 0 : data.type) === 'info',
1323
+ 'fwe-icon-status-warning': (data === null || data === void 0 ? void 0 : data.type) === 'warning',
1324
+ 'fwe-icon-status-failure': (data === null || data === void 0 ? void 0 : data.type) === 'error'
1325
+ })
1326
+ }, void 0), jsx("span", {
1327
+ children: data === null || data === void 0 ? void 0 : data.text
1328
+ }, void 0), (data === null || data === void 0 ? void 0 : data.action) && jsx("button", Object.assign({
1329
+ "aria-label": "UserAction",
1330
+ type: "button",
1331
+ className: "fwe-btn fwe-btn-link",
1332
+ onClick: () => onAction ? onAction() : undefined
1333
+ }, {
1334
+ children: data === null || data === void 0 ? void 0 : data.action
1335
+ }), void 0), (data === null || data === void 0 ? void 0 : data.showClose) && jsxs("button", Object.assign({
1336
+ "aria-label": "Close",
1337
+ type: "button",
1338
+ className: "fwe-btn fwe-btn-link",
1339
+ onClick: handleClose
1340
+ }, {
1341
+ children: [jsx("i", {
1342
+ "aria-hidden": true,
1343
+ className: "fwe-icon fwe-icon-close-small"
1344
+ }, void 0), jsx("span", Object.assign({
1345
+ className: "fwe-sr-only"
1346
+ }, {
1347
+ children: "Close"
1348
+ }), void 0)]
1349
+ }), void 0)]
1350
+ }), void 0)
1351
+ }), void 0)
1352
+ }), void 0);
1353
+ }
1354
+
1355
+ var SnackbarContext = /*#__PURE__*/React.createContext({});
1356
+
1357
+ function SnackbarProvider(props) {
1358
+ const {
1359
+ config = {
1360
+ darkBackground: true
1361
+ },
1362
+ children,
1363
+ className
1364
+ } = props;
1365
+ const [snacks, setSnacks] = useState([]);
1366
+
1367
+ function addSnackbar(snackData, onAction, onClose) {
1368
+ setSnacks(prevSnacks => [{
1369
+ data: Object.assign(Object.assign({}, config), snackData),
1370
+ onAction,
1371
+ onClose,
1372
+ key: new Date().getTime() + Math.random(),
1373
+ first: prevSnacks.length === 0
1374
+ }, ...prevSnacks]);
1375
+ }
1376
+
1377
+ function closeSnackbar(key) {
1378
+ if (key) {
1379
+ setSnacks(prevSnacks => prevSnacks.filter(snack => snack.key !== key));
1380
+ }
1381
+ }
1382
+
1383
+ function handleClose(snack) {
1384
+ closeSnackbar(snack.key);
1385
+
1386
+ if (snack.onClose) {
1387
+ snack.onClose();
1388
+ }
1389
+ }
1390
+
1391
+ const contextValue = {
1392
+ addSnackbar,
1393
+ closeSnackbar
1394
+ };
1395
+ return jsxs(SnackbarContext.Provider, Object.assign({
1396
+ value: contextValue
1397
+ }, {
1398
+ children: [children, jsx("div", Object.assign({
1399
+ className: classNames('fwe-snackbar-container', className)
1400
+ }, {
1401
+ children: snacks.map(snack => jsx(Snackbar, {
1402
+ data: snack.data,
1403
+ onAction: () => snack.onAction ? snack.onAction() : undefined,
1404
+ onClose: () => handleClose(snack),
1405
+ first: snack.first
1406
+ }, snack.key))
1407
+ }), void 0)]
1408
+ }), void 0);
1409
+ }
1410
+
1411
+ var useSnackbar = (() => useContext(SnackbarContext));
1412
+
1413
+ const StepHorizontal = /*#__PURE__*/forwardRef((_a, ref) => {
1414
+ var {
1415
+ children,
1416
+ className,
1417
+ isActive
1418
+ } = _a,
1419
+ props = __rest(_a, ["children", "className", "isActive"]);
1420
+
1421
+ return jsx("div", Object.assign({
1422
+ ref: ref,
1423
+ className: classNames('overflow-hidden', {
1424
+ hidden: !isActive
1425
+ })
1426
+ }, props, {
1427
+ children: jsx("div", Object.assign({
1428
+ className: "fr-moving-container"
1429
+ }, {
1430
+ children: children
1431
+ }), void 0)
1432
+ }), void 0);
1433
+ });
1434
+
1435
+ const StepperHorizontal = /*#__PURE__*/forwardRef((_a, ref) => {
1436
+ var {
1437
+ children,
1438
+ className,
1439
+ stepIndex = 0,
1440
+ onChange
1441
+ } = _a,
1442
+ props = __rest(_a, ["children", "className", "stepIndex", "onChange"]);
1443
+
1444
+ const stepComponents = React.Children.map(children, (child, i) => {
1445
+ if ( /*#__PURE__*/React.isValidElement(child)) {
1446
+ return /*#__PURE__*/React.cloneElement(child, Object.assign(Object.assign({}, child.props), {
1447
+ isActive: i === stepIndex
1448
+ }));
1449
+ }
1450
+ });
1451
+
1452
+ function handleStepClick(index) {
1453
+ if (stepIndex > index && onChange) {
1454
+ onChange(index);
1455
+ }
1456
+ }
1457
+
1458
+ return jsxs(Fragment, {
1459
+ children: [jsx("div", Object.assign({
1460
+ className: "fwe-stepper-horizontal"
1461
+ }, {
1462
+ children: stepComponents && stepComponents.map((step, i) => jsx("div", Object.assign({
1463
+ ref: ref,
1464
+ className: classNames('fwe-step-container', {
1465
+ 'fwe-step-done': stepIndex > i,
1466
+ 'fwe-step-active': i === stepIndex
1467
+ }),
1468
+ onClick: () => handleStepClick(i)
1469
+ }, props, {
1470
+ children: jsxs("div", Object.assign({
1471
+ className: "fwe-step"
1472
+ }, {
1473
+ children: [jsx("div", Object.assign({
1474
+ className: "fwe-step-no"
1475
+ }, {
1476
+ children: i + 1
1477
+ }), void 0), jsx("div", Object.assign({
1478
+ className: "fwe-step-name"
1479
+ }, {
1480
+ children: step.props.title
1481
+ }), void 0)]
1482
+ }), void 0)
1483
+ }), i))
1484
+ }), void 0), stepComponents]
1485
+ }, void 0);
1486
+ });
1487
+
1488
+ const StepVertical = /*#__PURE__*/forwardRef((_a, ref) => {
1489
+ var {
1490
+ children,
1491
+ className,
1492
+ isActive,
1493
+ isLastElement,
1494
+ isDone,
1495
+ index,
1496
+ title,
1497
+ onStepClick
1498
+ } = _a,
1499
+ props = __rest(_a, ["children", "className", "isActive", "isLastElement", "isDone", "index", "title", "onStepClick"]);
1500
+
1501
+ const containerRef = useRef(null);
1502
+ const contentRef = useRef(null);
1503
+ useEffect(() => {
1504
+ if (isActive) {
1505
+ const itemHeight = contentRef.current.offsetHeight;
1506
+ containerRef.current.style.height = `${itemHeight}px`;
1507
+ } else {
1508
+ containerRef.current.style.height = '20px';
1509
+ }
1510
+ }, [isActive]);
1511
+
1512
+ function handleClick() {
1513
+ if (onStepClick) {
1514
+ onStepClick();
1515
+ }
1516
+ }
1517
+
1518
+ return jsxs("div", Object.assign({
1519
+ ref: ref,
1520
+ className: classNames('fwe-step-container', {
1521
+ 'fwe-last-element': isLastElement,
1522
+ 'fwe-step-active': isActive,
1523
+ 'fwe-step-done': isDone
1524
+ })
1525
+ }, props, {
1526
+ children: [jsxs("div", Object.assign({
1527
+ className: "fwe-step",
1528
+ onClick: handleClick
1529
+ }, {
1530
+ children: [jsx("div", Object.assign({
1531
+ className: "fwe-step-no"
1532
+ }, {
1533
+ children: index + 1
1534
+ }), void 0), jsx("div", Object.assign({
1535
+ className: "fwe-step-name"
1536
+ }, {
1537
+ children: title
1538
+ }), void 0)]
1539
+ }), void 0), jsx("div", Object.assign({
1540
+ ref: containerRef,
1541
+ className: "fwe-step-content-container"
1542
+ }, {
1543
+ children: jsx("div", Object.assign({
1544
+ ref: contentRef,
1545
+ className: "fwe-step-content"
1546
+ }, {
1547
+ children: children
1548
+ }), void 0)
1549
+ }), void 0)]
1550
+ }), void 0);
1551
+ });
1552
+
1553
+ const StepperVertical = /*#__PURE__*/forwardRef((_a, ref) => {
1554
+ var {
1555
+ children,
1556
+ className,
1557
+ stepIndex = 0,
1558
+ onChange
1559
+ } = _a,
1560
+ props = __rest(_a, ["children", "className", "stepIndex", "onChange"]);
1561
+
1562
+ function handleStepClick(index) {
1563
+ if (stepIndex > index && onChange) {
1564
+ onChange(index);
1565
+ }
1566
+ }
1567
+
1568
+ const stepComponents = React.Children.map(children, (child, i) => {
1569
+ if ( /*#__PURE__*/React.isValidElement(child)) {
1570
+ return /*#__PURE__*/React.cloneElement(child, Object.assign(Object.assign({}, child.props), {
1571
+ isActive: i === stepIndex,
1572
+ index: i,
1573
+ isDone: i < stepIndex,
1574
+ isLastElement: i === React.Children.count(children) - 1,
1575
+ onStepClick: () => handleStepClick(i)
1576
+ }));
1577
+ }
1578
+ });
1579
+ return jsx("div", Object.assign({
1580
+ ref: ref,
1581
+ className: classNames('fwe-stepper-vertical', className)
1582
+ }, props, {
1583
+ children: stepComponents
1584
+ }), void 0);
1585
+ });
1586
+
1587
+ function TabPane({
1588
+ isVisible = false,
1589
+ children,
1590
+ className,
1591
+ tabId,
1592
+ id
1593
+ }) {
1594
+ const tabPaneClasses = classNames({
1595
+ 'fr-show': isVisible
1596
+ }, {
1597
+ 'fr-hide': !isVisible
1598
+ }, className);
1599
+ return jsx("div", Object.assign({
1600
+ id: id,
1601
+ "aria-labelledby": tabId,
1602
+ className: tabPaneClasses
1603
+ }, {
1604
+ children: children
1605
+ }), void 0);
1606
+ }
1607
+
1608
+ const useTabScroll = (tabLength, componentId, refs) => {
1609
+ const {
1610
+ elRef,
1611
+ scrollContent,
1612
+ scrollArea
1613
+ } = refs;
1614
+ const [style, setStyle] = useState({});
1615
+ const [classes, setClasses] = useState('');
1616
+
1617
+ function getScrollContentStyleValue(propName) {
1618
+ return window.getComputedStyle(scrollContent.current).getPropertyValue(propName);
1619
+ }
1620
+
1621
+ function calculateCurrentTranslateX() {
1622
+ const transformValue = getScrollContentStyleValue('transform');
1623
+
1624
+ if (transformValue === 'none') {
1625
+ return 0;
1626
+ } // the transform value is in form of 'matrix(a, b, c, d, tx, ty)'
1627
+ // get all the parenthesized values
1628
+
1629
+
1630
+ const match = /\((.+?)\)/.exec(transformValue);
1631
+
1632
+ if (!match) {
1633
+ return 0;
1634
+ }
1635
+
1636
+ const matrixParams = match[1]; // we need value of tx -> translateX
1637
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1638
+
1639
+ const [a, b, c, d, tx, ty] = matrixParams.split(',');
1640
+ return parseFloat(tx);
1641
+ }
1642
+
1643
+ function getScrollPosition() {
1644
+ const currentTranslateX = calculateCurrentTranslateX();
1645
+ const scrollLeft = scrollArea.current.scrollLeft;
1646
+ return scrollLeft - currentTranslateX;
1647
+ }
1648
+
1649
+ function calculateScrollEdges() {
1650
+ const scrollContentWidth = scrollContent.current.offsetWidth;
1651
+ const scrollAreaWidth = scrollArea.current.offsetWidth;
1652
+ return {
1653
+ left: 0,
1654
+ right: scrollContentWidth - scrollAreaWidth
1655
+ };
1656
+ }
1657
+
1658
+ function clampScrollValue(scrollX) {
1659
+ const edges = calculateScrollEdges();
1660
+ return Math.min(Math.max(edges.left, scrollX), edges.right);
1661
+ }
1662
+
1663
+ function getIncrementScrollOperation(scrollX) {
1664
+ const currentScrollX = getScrollPosition();
1665
+ const targetScrollX = scrollX + currentScrollX;
1666
+ const safeScrollX = clampScrollValue(targetScrollX);
1667
+ const scrollDelta = safeScrollX - currentScrollX;
1668
+ return {
1669
+ finalScrollPosition: safeScrollX,
1670
+ scrollDelta
1671
+ };
1672
+ }
1673
+
1674
+ function getAnimatingScrollPosition() {
1675
+ const currentTranslateX = calculateCurrentTranslateX();
1676
+ const scrollLeft = scrollArea.current.scrollLeft;
1677
+ return scrollLeft - currentTranslateX;
1678
+ }
1679
+
1680
+ function stopScrollAnimation() {
1681
+ const currentScrollPosition = getAnimatingScrollPosition();
1682
+ setClasses('');
1683
+ setStyle({
1684
+ transform: 'translateX(0px)'
1685
+ });
1686
+ scrollArea.current.scrollLeft = currentScrollPosition;
1687
+ }
1688
+
1689
+ function animate(animation) {
1690
+ // no animation needed
1691
+ if (animation.scrollDelta === 0) {
1692
+ return;
1693
+ }
1694
+
1695
+ stopScrollAnimation(); // this animation uses the flip approach
1696
+ // https://aerotwist.com/blog/flip-your-animations/
1697
+ // https://css-tricks.com/animating-layouts-with-the-flip-technique/
1698
+
1699
+ scrollArea.current.scrollLeft = animation.finalScrollPosition;
1700
+ setStyle({
1701
+ transform: `translateX(${animation.scrollDelta}px)`
1702
+ }); // force repaint
1703
+
1704
+ scrollArea.current.getBoundingClientRect();
1705
+ requestAnimationFrame(() => {
1706
+ setClasses('fr-tab-scroller--animating');
1707
+ setStyle({
1708
+ transform: 'none'
1709
+ });
1710
+ });
1711
+ }
1712
+
1713
+ function incrementScroll(scrollXIncrement) {
1714
+ // no scroll needed
1715
+ if (scrollXIncrement === 0) {
1716
+ return;
1717
+ }
1718
+
1719
+ const scrollOperation = getIncrementScrollOperation(scrollXIncrement);
1720
+ animate(scrollOperation);
1721
+ }
1722
+
1723
+ function computeDimensions(tab) {
1724
+ const rootWidth = tab.offsetWidth;
1725
+ const rootLeft = tab.offsetLeft;
1726
+ const tabContent = tab.querySelector('.fr-tab-content');
1727
+ const contentWidth = tabContent.offsetWidth;
1728
+ const contentLeft = tabContent.offsetLeft;
1729
+ return {
1730
+ contentLeft: rootLeft + contentLeft,
1731
+ contentRight: rootLeft + contentLeft + contentWidth,
1732
+ rootLeft,
1733
+ rootRight: rootLeft + rootWidth
1734
+ };
1735
+ }
1736
+
1737
+ function calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth) {
1738
+ const nextTab = elRef.current.querySelector(`#${componentId}-tab-${nextIndex}`);
1739
+ const nextTabDimensions = computeDimensions(nextTab);
1740
+ const relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
1741
+ const relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
1742
+ const leftIncrement = relativeContentRight - 48;
1743
+ const rightIncrement = relativeContentLeft + 48;
1744
+
1745
+ if (nextIndex < index) {
1746
+ return Math.min(leftIncrement, 0);
1747
+ }
1748
+
1749
+ return Math.max(rightIncrement, 0);
1750
+ }
1751
+
1752
+ function findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth) {
1753
+ /**
1754
+ * tabs are laid out in the tab scroller like this:
1755
+ *
1756
+ * scroll position
1757
+ * +---+
1758
+ * | | bar width
1759
+ * | +-----------------------------------+
1760
+ * | | |
1761
+ * | v v
1762
+ * | +-----------------------------------+
1763
+ * v | tab scroller |
1764
+ * +------------+--------------+-------------------+
1765
+ * | tab | tab | tab |
1766
+ * +------------+--------------+-------------------+
1767
+ * | |
1768
+ * +-----------------------------------+
1769
+ *
1770
+ * to determine the next adjacent index, we look at the tab root left and
1771
+ * tab root right, both relative to the scroll position. if the tab root
1772
+ * left is less than 0, then we know it's out of view to the left. if the
1773
+ * tab root right minus the bar width is greater than 0, we know the tab is
1774
+ * out of view to the right. from there, we either increment or decrement
1775
+ * the index.
1776
+ */
1777
+ const relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
1778
+ const relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
1779
+ const relativeRootDelta = relativeRootLeft + relativeRootRight;
1780
+ const leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
1781
+ const rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
1782
+
1783
+ if (leftEdgeIsCloser) {
1784
+ return index - 1;
1785
+ }
1786
+
1787
+ if (rightEdgeIsCloser) {
1788
+ return index + 1;
1789
+ }
1790
+
1791
+ return -1;
1792
+ }
1793
+
1794
+ function indexIsInRange(index) {
1795
+ return index >= 0 && index < tabLength;
1796
+ }
1797
+
1798
+ function scrollIntoView(index, tab) {
1799
+ const scrollPosition = getScrollPosition();
1800
+ const barWidth = scrollArea.current.offsetWidth;
1801
+ const tabDimensions = computeDimensions(tab);
1802
+ const nextIndex = findAdjacentTabIndexClosestToEdge(index, tabDimensions, scrollPosition, barWidth);
1803
+
1804
+ if (!indexIsInRange(nextIndex)) {
1805
+ return;
1806
+ }
1807
+
1808
+ const scrollIncrement = calculateScrollIncrement(index, nextIndex, scrollPosition, barWidth);
1809
+ incrementScroll(scrollIncrement);
1810
+ }
1811
+
1812
+ function scrollTo(scrollX) {
1813
+ const currentScrollX = getScrollPosition();
1814
+ const safeScrollX = clampScrollValue(scrollX);
1815
+ const scrollDelta = safeScrollX - currentScrollX;
1816
+ animate({
1817
+ finalScrollPosition: safeScrollX,
1818
+ scrollDelta
1819
+ });
1820
+ }
1821
+
1822
+ function handleTabScroll(e, index) {
1823
+ const scrollContentWidth = scrollContent.current.offsetWidth;
1824
+ const scrollAreaWidth = scrollArea.current.offsetWidth; // check if no scroll is needed
1825
+
1826
+ if (scrollAreaWidth > scrollContentWidth) {
1827
+ return;
1828
+ } // check index
1829
+
1830
+
1831
+ if (!indexIsInRange(index)) {
1832
+ return;
1833
+ } // always scroll to 0 if scrolling to the first tab
1834
+
1835
+
1836
+ if (index === 0) {
1837
+ scrollTo(0);
1838
+ return;
1839
+ } // always scroll to the max value if scrolling to the last tab
1840
+
1841
+
1842
+ if (index === tabLength - 1) {
1843
+ scrollTo(scrollContent.current.offsetWidth);
1844
+ return;
1845
+ }
1846
+
1847
+ if (e.currentTarget instanceof HTMLElement) {
1848
+ const currentTab = e.currentTarget;
1849
+ scrollIntoView(index, currentTab);
1850
+ }
1851
+ }
1852
+
1853
+ return [handleTabScroll, classes, style];
1854
+ };
1855
+
1856
+ let nextId = 0;
1857
+ const Tabs = /*#__PURE__*/forwardRef((_a, ref) => {
1858
+ var _b, _c, _d;
1859
+
1860
+ var {
1861
+ config,
1862
+ children,
1863
+ className,
1864
+ onChange,
1865
+ viewType = 'responsive',
1866
+ showDivider = false
1867
+ } = _a,
1868
+ props = __rest(_a, ["config", "children", "className", "onChange", "viewType", "showDivider"]);
1869
+
1870
+ const [useCompactDensity, setCompactDensity] = useState(true);
1871
+ const componentId = useRef(`tabs-${++nextId}`);
1872
+ const elRef = useRef(null);
1873
+ const combinedRef = useForkRef(ref, elRef);
1874
+ const scrollContent = useRef(null);
1875
+ const scrollArea = useRef(null);
1876
+ const observer = useRef(null);
1877
+ let activeId = '';
1878
+ React.Children.forEach(children, (element, i) => {
1879
+ if ( /*#__PURE__*/React.isValidElement(element)) {
1880
+ if (activeId === '') {
1881
+ activeId = `${componentId.current}-tab-panel-${i}`;
1882
+ } else if (element.props.active) {
1883
+ activeId = `${componentId.current}-tab-panel-${i}`;
1884
+ }
1885
+ }
1886
+ });
1887
+ const [currentId, setId] = useState(activeId);
1888
+ const innerChildren = React.Children.map(children, (element, i) => {
1889
+ if ( /*#__PURE__*/isValidElement(element)) {
1890
+ const newId = `${componentId.current}-tab-panel-${i}`;
1891
+ return /*#__PURE__*/React.cloneElement(element, Object.assign({
1892
+ isVisible: newId === currentId,
1893
+ active: newId === currentId,
1894
+ id: newId,
1895
+ tabId: `${componentId.current}-tab-${i}`
1896
+ }, element.props));
1897
+ }
1898
+
1899
+ return undefined;
1900
+ });
1901
+ const [handleTabScroll, classes, style] = useTabScroll(innerChildren.length, componentId.current, {
1902
+ elRef,
1903
+ scrollContent,
1904
+ scrollArea
1905
+ });
1906
+ useEffect(() => {
1907
+ const current = scrollArea.current;
1908
+
1909
+ if (current) {
1910
+ const initialWidth = current.offsetWidth;
1911
+
1912
+ if (initialWidth > 768) {
1913
+ setCompactDensity(false);
1914
+ }
1915
+
1916
+ observer.current = new ResizeObserver(() => {
1917
+ const width = current.offsetWidth;
1918
+
1919
+ if (width > 768 && useCompactDensity) {
1920
+ setCompactDensity(false);
1921
+ } else if (width <= 768 && !useCompactDensity) {
1922
+ setCompactDensity(true);
1923
+ }
1924
+ });
1925
+
1926
+ if (current) {
1927
+ observer.current.observe(current);
1928
+ }
1929
+ }
1930
+
1931
+ return () => {
1932
+ if (observer && observer.current) {
1933
+ observer.current.unobserve(current);
1934
+ }
1935
+ };
1936
+ }, [useCompactDensity]);
1937
+
1938
+ const showTabPane = id => {
1939
+ if (onChange) {
1940
+ onChange({
1941
+ previous: currentId,
1942
+ current: id
1943
+ });
1944
+ }
1945
+
1946
+ setId(id);
1947
+ };
1948
+
1949
+ function handleClick(e, index, id) {
1950
+ handleTabScroll(e, index);
1951
+ showTabPane(id);
1952
+ }
1953
+
1954
+ return (// eslint-disable-next-line react/jsx-no-useless-fragment
1955
+ jsx(React.Fragment, {
1956
+ children: viewType === 'legacy' ? jsxs("div", Object.assign({
1957
+ className: classNames('fwe-legacy-tabs', className)
1958
+ }, {
1959
+ children: [jsx("ul", Object.assign({
1960
+ role: "tablist",
1961
+ className: classNames('fwe-legacy-tab-bar', {
1962
+ 'fwe-legacy-tab-bar-full-width': (_b = config === null || config === void 0 ? void 0 : config.tabBar) === null || _b === void 0 ? void 0 : _b.fullWidth
1963
+ }, {
1964
+ 'fwe-legacy-tab-items-equal-width': ((_c = config === null || config === void 0 ? void 0 : config.tabItems) === null || _c === void 0 ? void 0 : _c.appearance) === 'equal'
1965
+ }, {
1966
+ 'fwe-legacy-tab-items-fill': ((_d = config === null || config === void 0 ? void 0 : config.tabItems) === null || _d === void 0 ? void 0 : _d.appearance) === 'fill'
1967
+ })
1968
+ }, {
1969
+ children: innerChildren.map((child, i) => {
1970
+ const {
1971
+ active,
1972
+ icon,
1973
+ name,
1974
+ id,
1975
+ tabId
1976
+ } = child.props;
1977
+ return jsx("li", Object.assign({
1978
+ className: classNames('fwe-legacy-tab-item', {
1979
+ 'fwe-active': active
1980
+ }),
1981
+ onClick: () => showTabPane(id)
1982
+ }, {
1983
+ children: icon ? jsxs("a", Object.assign({
1984
+ id: tabId,
1985
+ className: classNames('fwe-legacy-tab-link', {
1986
+ 'fwe-can-swap-icon': innerChildren.length === 2 && i === 1
1987
+ }),
1988
+ role: "tab",
1989
+ "aria-controls": id,
1990
+ "aria-selected": active
1991
+ }, {
1992
+ children: [jsx("i", {
1993
+ className: `fwe-icon ${icon}`
1994
+ }, void 0), jsx("span", {
1995
+ children: name
1996
+ }, void 0)]
1997
+ }), void 0) : jsx("a", Object.assign({
1998
+ id: tabId,
1999
+ className: "fwe-legacy-tab-link",
2000
+ role: "tab",
2001
+ "aria-controls": id,
2002
+ "aria-selected": active
2003
+ }, {
2004
+ children: name
2005
+ }), void 0)
2006
+ }), tabId);
2007
+ })
2008
+ }), void 0), jsx("div", Object.assign({
2009
+ className: "fwe-legacy-tab-panel-content"
2010
+ }, {
2011
+ children: innerChildren
2012
+ }), void 0)]
2013
+ }), void 0) : jsxs("div", Object.assign({
2014
+ className: "fr-tab-bar",
2015
+ role: "tablist",
2016
+ ref: combinedRef
2017
+ }, props, {
2018
+ children: [jsx("div", Object.assign({
2019
+ className: classNames('fr-tab-scroller', classes)
2020
+ }, {
2021
+ children: jsx("div", Object.assign({
2022
+ className: classNames('fr-tab-scroller-scroll-area fr-tab-scroller-scroll-area--scroll', {
2023
+ 'fr-tab-scroller-scroll-area--compact': useCompactDensity
2024
+ }),
2025
+ ref: scrollArea
2026
+ }, {
2027
+ children: jsxs("div", Object.assign({
2028
+ className: classNames('fr-tab-scroller-scroll-content', {
2029
+ 'fr-tab-scroller-scroll-content--with-divider': showDivider
2030
+ }),
2031
+ ref: scrollContent,
2032
+ style: style
2033
+ }, {
2034
+ children: [innerChildren.map((child, i) => {
2035
+ const {
2036
+ active,
2037
+ name,
2038
+ id,
2039
+ tabId
2040
+ } = child.props;
2041
+ return jsxs("button", Object.assign({
2042
+ role: "tab",
2043
+ className: classNames('fr-tab', {
2044
+ 'fr-tab--active': active
2045
+ }),
2046
+ id: tabId,
2047
+ "aria-controls": id,
2048
+ "aria-selected": active,
2049
+ tabIndex: i === 0 ? 0 : 1,
2050
+ onClick: e => handleClick(e, i, id)
2051
+ }, {
2052
+ children: [jsx("span", Object.assign({
2053
+ className: "fr-tab-content"
2054
+ }, {
2055
+ children: jsx("span", Object.assign({
2056
+ className: "fr-tab-text-label"
2057
+ }, {
2058
+ children: name
2059
+ }), void 0)
2060
+ }), void 0), jsx("span", Object.assign({
2061
+ className: classNames('fr-tab-indicator', {
2062
+ 'fr-tab-indicator--active': active
2063
+ })
2064
+ }, {
2065
+ children: jsx("span", {
2066
+ className: "fr-tab-indicator-content fr-tab-indicator-content--underline"
2067
+ }, void 0)
2068
+ }), void 0)]
2069
+ }), tabId);
2070
+ }), jsx("div", {
2071
+ className: "fr-tab-scroller-divider-line"
2072
+ }, void 0)]
2073
+ }), void 0)
2074
+ }), void 0)
2075
+ }), void 0), jsx("div", Object.assign({
2076
+ className: "fr-tab-panel-content"
2077
+ }, {
2078
+ children: innerChildren
2079
+ }), void 0)]
2080
+ }), void 0)
2081
+ }, void 0)
2082
+ );
2083
+ });
2084
+
2085
+ const TableHeaderCell = /*#__PURE__*/React.forwardRef((props, ref) => {
2086
+ function handleClick(event) {
2087
+ if (props.onClick) {
2088
+ props.onClick(event);
2089
+ }
2090
+ }
2091
+
2092
+ return jsx("th", Object.assign({}, props, {
2093
+ className: classNames('fwe-table-order', {
2094
+ 'fwe-active': props.active
2095
+ }, {
2096
+ 'fwe-table-order-descending': !props.ascending
2097
+ }, props.className),
2098
+ onClick: handleClick,
2099
+ ref: ref
2100
+ }), void 0);
2101
+ });
2102
+
2103
+ function Checkbox(_a) {
2104
+ var {
2105
+ id,
2106
+ checked,
2107
+ onChange,
2108
+ name,
2109
+ large = false,
2110
+ valid = true,
2111
+ labelPosition = 'after',
2112
+ required,
2113
+ disabled = false,
2114
+ indeterminate = false,
2115
+ children,
2116
+ className
2117
+ } = _a,
2118
+ props = __rest(_a, ["id", "checked", "onChange", "name", "large", "valid", "labelPosition", "required", "disabled", "indeterminate", "children", "className"]);
2119
+
2120
+ const [isChecked, setChecked] = useState(checked);
2121
+ const [isIndeterminate, setIndeterminate] = useState(indeterminate);
2122
+ useEffect(() => {
2123
+ setChecked(checked);
2124
+ setIndeterminate(indeterminate);
2125
+ }, [checked, indeterminate]);
2126
+
2127
+ const handleChange = () => {
2128
+ const newChecked = !isChecked;
2129
+
2130
+ if (indeterminate) {
2131
+ setIndeterminate(false);
2132
+ }
2133
+
2134
+ setChecked(newChecked);
2135
+ onChange(newChecked);
2136
+ };
2137
+
2138
+ const containerClasses = classNames('fwe-checkbox-container', {
2139
+ 'fr-checkbox-large': large
2140
+ }, {
2141
+ 'fr-checkbox-invalid': !valid || required
2142
+ }, {
2143
+ 'fwe-disabled': disabled
2144
+ }, {
2145
+ 'fwe-checked': isChecked
2146
+ }, {
2147
+ 'fwe-label-below': labelPosition === 'below'
2148
+ }, {
2149
+ 'fwe-label-before': labelPosition === 'before'
2150
+ }, {
2151
+ 'fr-checkbox-indeterminate': isIndeterminate
2152
+ }, className);
2153
+ return jsxs("label", Object.assign({
2154
+ className: containerClasses,
2155
+ htmlFor: id
2156
+ }, {
2157
+ children: [jsx("input", Object.assign({
2158
+ name: name,
2159
+ type: "checkbox",
2160
+ id: id,
2161
+ disabled: disabled,
2162
+ onChange: () => handleChange()
2163
+ }, props), void 0), jsxs("div", Object.assign({
2164
+ className: "fwe-checkbox-indicator-container"
2165
+ }, {
2166
+ children: [jsx("div", {
2167
+ className: "fwe-checkbox-indicator-background"
2168
+ }, void 0), !isIndeterminate && isChecked && (large ? jsx("svg", Object.assign({
2169
+ width: "24px",
2170
+ height: "24px"
2171
+ }, {
2172
+ children: jsx("path", {
2173
+ d: "M17.5 7L10 14.5 7.501 12l-1.5 1.501L10 17.5l9-9z",
2174
+ fill: "#fff"
2175
+ }, void 0)
2176
+ }), void 0) : jsx("svg", Object.assign({
2177
+ xmlns: "http://www.w3.org/2000/svg",
2178
+ width: "16",
2179
+ height: "16"
2180
+ }, {
2181
+ children: jsx("path", {
2182
+ d: "M6 12L3 9l1.25-1.25L6 9.5l5.75-5.75L13 5l-7 7z",
2183
+ fill: "#fff"
2184
+ }, void 0)
2185
+ }), void 0)), isIndeterminate && !isChecked && jsx("div", {
2186
+ className: "fwe-indeterminate-indicator"
2187
+ }, void 0)]
2188
+ }), void 0), jsx("div", Object.assign({
2189
+ className: "fwe-checkbox-title"
2190
+ }, {
2191
+ children: children
2192
+ }), void 0)]
2193
+ }), void 0);
2194
+ }
2195
+
2196
+ function ColorIndicator({
2197
+ text,
2198
+ label,
2199
+ color,
2200
+ className,
2201
+ showPopOver = false,
2202
+ children,
2203
+ disabled
2204
+ }) {
2205
+ const classes = classNames('fwe-color-indicator', className, disabled);
2206
+ const [isEditorOpen, setEditorOpen] = useState(false);
2207
+
2208
+ function getBorderColor() {
2209
+ if (!color || color.toUpperCase() === '#FFFFFF' || color.toUpperCase() === '#F2F3F5') {
2210
+ return '#b6bec6'; // = $control-border
2211
+ }
2212
+
2213
+ return color;
2214
+ }
2215
+
2216
+ const colorBox = jsx("div", Object.assign({
2217
+ className: "fwe-color-box",
2218
+ style: {
2219
+ background: color,
2220
+ borderColor: getBorderColor()
2221
+ }
2222
+ }, {
2223
+ children: !color && jsxs("svg", Object.assign({
2224
+ className: "fwe-no-color-pattern",
2225
+ version: "1.1",
2226
+ xmlns: "http://www.w3.org/2000/svg",
2227
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
2228
+ id: "canvas1",
2229
+ width: "18",
2230
+ height: "18"
2231
+ }, {
2232
+ children: [jsx("defs", {
2233
+ children: jsxs("pattern", Object.assign({
2234
+ id: "bwsquare2px",
2235
+ width: "4",
2236
+ height: "4",
2237
+ patternUnits: "userSpaceOnUse"
2238
+ }, {
2239
+ children: [jsx("rect", {
2240
+ x: "0",
2241
+ y: "0",
2242
+ width: "2",
2243
+ height: "2",
2244
+ stroke: "none",
2245
+ fill: "#ffffff"
2246
+ }, void 0), jsx("rect", {
2247
+ x: "2",
2248
+ y: "0",
2249
+ width: "2",
2250
+ height: "2",
2251
+ stroke: "none",
2252
+ fill: "#e5e8eb"
2253
+ }, void 0), jsx("rect", {
2254
+ x: "0",
2255
+ y: "2",
2256
+ width: "2",
2257
+ height: "2",
2258
+ stroke: "none",
2259
+ fill: "#e5e8eb"
2260
+ }, void 0), jsx("rect", {
2261
+ x: "2",
2262
+ y: "2",
2263
+ width: "2",
2264
+ height: "2",
2265
+ stroke: "none",
2266
+ fill: "#ffffff"
2267
+ }, void 0)]
2268
+ }), void 0)
2269
+ }, void 0), jsx("rect", {
2270
+ x: "0",
2271
+ y: "0",
2272
+ rx: "0",
2273
+ ry: "0",
2274
+ width: "18",
2275
+ height: "18",
2276
+ fill: "url(#bwsquare2px)",
2277
+ strokeWidth: "0"
2278
+ }, void 0)]
2279
+ }), void 0)
2280
+ }), void 0);
2281
+
2282
+ const wrapper = wrapperChildren => jsxs("div", Object.assign({
2283
+ className: classes,
2284
+ onClick: () => setEditorOpen(prevOpen => showPopOver ? !prevOpen : prevOpen)
2285
+ }, {
2286
+ children: [jsx("div", Object.assign({
2287
+ style: {
2288
+ opacity: isEditorOpen ? 0 : 1
2289
+ },
2290
+ className: "fwe-color-label"
2291
+ }, {
2292
+ children: label
2293
+ }), void 0), jsxs("div", Object.assign({
2294
+ className: "fwe-color-container"
2295
+ }, {
2296
+ children: [wrapperChildren, " ", text && jsx("div", Object.assign({
2297
+ className: "fwe-color-indicator-text"
2298
+ }, {
2299
+ children: text
2300
+ }), void 0), ' ']
2301
+ }), void 0)]
2302
+ }), void 0);
2303
+
2304
+ return showPopOver ? jsx(Popover, Object.assign({
2305
+ containerClassName: "fwe-popover-container--color-indicator",
2306
+ position: "top",
2307
+ flip: false,
2308
+ wrapper: wrapper,
2309
+ popoverContent: children,
2310
+ open: isEditorOpen,
2311
+ onStatusChange: setEditorOpen,
2312
+ stopPropagation: true
2313
+ }, {
2314
+ children: colorBox
2315
+ }), void 0) : jsx(Fragment, {
2316
+ children: wrapper(colorBox)
2317
+ }, void 0);
2318
+ }
2319
+
2320
+ class ColorHelper {
2321
+ // based on: https://gist.github.com/mjackson/5311256
2322
+ static rgbToHsv(rgb) {
2323
+ if (!rgb) {
2324
+ return undefined;
2325
+ }
2326
+
2327
+ const r = this.limitToByte(rgb.r) / 255;
2328
+ const g = this.limitToByte(rgb.g) / 255;
2329
+ const b = this.limitToByte(rgb.b) / 255;
2330
+ const max = Math.max(r, g, b);
2331
+ const min = Math.min(r, g, b);
2332
+ let h = max;
2333
+ let s = max;
2334
+ const v = max;
2335
+ const d = max - min;
2336
+ s = max === 0 ? 0 : d / max;
2337
+
2338
+ if (max === min) {
2339
+ h = 0; // achromatic
2340
+ } else {
2341
+ switch (max) {
2342
+ case r:
2343
+ h = (g - b) / d + (g < b ? 6 : 0);
2344
+ break;
2345
+
2346
+ case g:
2347
+ h = (b - r) / d + 2;
2348
+ break;
2349
+
2350
+ case b:
2351
+ h = (r - g) / d + 4;
2352
+ break;
2353
+
2354
+ }
2355
+
2356
+ h /= 6;
2357
+ }
2358
+
2359
+ return {
2360
+ h,
2361
+ s,
2362
+ v
2363
+ };
2364
+ } // based on: https://gist.github.com/mjackson/5311256
2365
+
2366
+
2367
+ static hsvToRgb(_hsv) {
2368
+ const hsv = _hsv;
2369
+ hsv.h = this.limitToOne(_hsv.h);
2370
+ hsv.s = this.limitToOne(_hsv.s);
2371
+ hsv.v = this.limitToOne(_hsv.v);
2372
+ let r = 0;
2373
+ let g = 0;
2374
+ let b = 0;
2375
+ const i = Math.floor(hsv.h * 6);
2376
+ const f = hsv.h * 6 - i;
2377
+ const p = hsv.v * (1 - hsv.s);
2378
+ const q = hsv.v * (1 - f * hsv.s);
2379
+ const t = hsv.v * (1 - (1 - f) * hsv.s);
2380
+
2381
+ switch (i % 6) {
2382
+ case 0:
2383
+ r = hsv.v;
2384
+ g = t;
2385
+ b = p;
2386
+ break;
2387
+
2388
+ case 1:
2389
+ r = q;
2390
+ g = hsv.v;
2391
+ b = p;
2392
+ break;
2393
+
2394
+ case 2:
2395
+ r = p;
2396
+ g = hsv.v;
2397
+ b = t;
2398
+ break;
2399
+
2400
+ case 3:
2401
+ r = p;
2402
+ g = q;
2403
+ b = hsv.v;
2404
+ break;
2405
+
2406
+ case 4:
2407
+ r = t;
2408
+ g = p;
2409
+ b = hsv.v;
2410
+ break;
2411
+
2412
+ case 5:
2413
+ r = hsv.v;
2414
+ g = p;
2415
+ b = q;
2416
+ break;
2417
+
2418
+ }
2419
+
2420
+ return {
2421
+ r: this.limitToByte(r * 255),
2422
+ g: this.limitToByte(g * 255),
2423
+ b: this.limitToByte(b * 255)
2424
+ };
2425
+ }
2426
+
2427
+ static limitToByte(num) {
2428
+ if (num <= 0) {
2429
+ return 0;
2430
+ }
2431
+
2432
+ if (num >= 255) {
2433
+ return 255;
2434
+ }
2435
+
2436
+ return num;
2437
+ }
2438
+
2439
+ static limitToOne(num) {
2440
+ if (num <= 0) {
2441
+ return 0;
2442
+ }
2443
+
2444
+ if (num >= 1) {
2445
+ return 1;
2446
+ }
2447
+
2448
+ return num;
2449
+ }
2450
+
2451
+ static numberToHex(rgb) {
2452
+ let hex = Math.round(rgb).toString(16);
2453
+
2454
+ if (hex.length < 2) {
2455
+ hex = `0${hex}`;
2456
+ }
2457
+
2458
+ return hex.toUpperCase();
2459
+ }
2460
+
2461
+ static rgbToHex(_rgb) {
2462
+ const rgb = _rgb;
2463
+ rgb.r = this.limitToByte(rgb.r);
2464
+ rgb.g = this.limitToByte(rgb.g);
2465
+ rgb.b = this.limitToByte(rgb.b);
2466
+ const red = this.numberToHex(rgb.r);
2467
+ const green = this.numberToHex(rgb.g);
2468
+ const blue = this.numberToHex(rgb.b);
2469
+ return `#${red}${green}${blue}`;
2470
+ }
2471
+
2472
+ static hexToRgb(hexString) {
2473
+ const numbersOnly = hexString.substring(1);
2474
+ const aRgbHex = numbersOnly.match(/.{1,2}/g);
2475
+ return aRgbHex ? {
2476
+ r: parseInt(aRgbHex[0], 16),
2477
+ g: parseInt(aRgbHex[1], 16),
2478
+ b: parseInt(aRgbHex[2], 16)
2479
+ } : undefined;
2480
+ }
2481
+
2482
+ }
2483
+
2484
+ const PREDEFINED_COLORS = ['#0091dc', '#333333', '#ffffff', '#f2f3f5', '#e5e8eb', '#d8dce1', '#b6bec6', '#80ca3d', '#ffd600', '#ff9600', '#d50000'];
2485
+
2486
+ function ColorPicker({
2487
+ palette = PREDEFINED_COLORS,
2488
+ useAlpha = false,
2489
+ alpha = 100,
2490
+ paletteOnly,
2491
+ color = '#FFFFFF',
2492
+ onChange,
2493
+ onAlphaChange,
2494
+ className
2495
+ }) {
2496
+ const baseSize = 184;
2497
+ const initialRgb = ColorHelper.hexToRgb(color);
2498
+ const defaultHsv = {
2499
+ h: 0,
2500
+ s: 0,
2501
+ v: 1
2502
+ };
2503
+ const initialHsv = initialRgb ? ColorHelper.rgbToHsv(initialRgb) || defaultHsv : defaultHsv;
2504
+ const [hsv, setHsv] = useState(initialHsv);
2505
+ const [innerColor, setInnerColor] = useState(color);
2506
+ const [redInput, setRedInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.r) || 255);
2507
+ const [greenInput, setGreenInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.g) || 255);
2508
+ const [blueInput, setBlueInput] = useState((initialRgb === null || initialRgb === void 0 ? void 0 : initialRgb.b) || 255);
2509
+ const [hexInputColor, setHexInputColor] = useState(color);
2510
+ const [inputType, setInputType] = useState('RGB');
2511
+ const [selectOpen, setSelectOpen] = useState(false);
2512
+ const [innerAlpha, setInnerAlpha] = useState(alpha);
2513
+ const [changeColor, setChangeColor] = useState(true);
2514
+
2515
+ function limitAlpha() {
2516
+ if (innerAlpha > 100) {
2517
+ return 100;
2518
+ }
2519
+
2520
+ if (innerAlpha < 0) {
2521
+ return 0;
2522
+ }
2523
+
2524
+ return innerAlpha;
2525
+ }
2526
+
2527
+ const hueKnobOffset = hsv.h * baseSize - 14 - baseSize;
2528
+ const saturationKnobOffset = hsv.s * baseSize;
2529
+ const valueKnobOffset = (1 - hsv.v) * baseSize;
2530
+ const alphaKnobOffset = (100 - limitAlpha()) / 100 * baseSize;
2531
+
2532
+ function getSaturationGradient() {
2533
+ return `linear-gradient(to right, white, hsl(${hsv.h * 360}, 100%, 50%) )`;
2534
+ }
2535
+
2536
+ function updateInputs(hexColor) {
2537
+ setHexInputColor(hexColor);
2538
+ const rgb = ColorHelper.hexToRgb(hexColor);
2539
+
2540
+ if (rgb) {
2541
+ setRedInput(rgb.r);
2542
+ setGreenInput(rgb.g);
2543
+ setBlueInput(rgb.b);
2544
+ }
2545
+ }
2546
+
2547
+ useEffect(() => {
2548
+ if (onChange) {
2549
+ onChange(innerColor);
2550
+ }
2551
+ }, [onChange, innerColor]);
2552
+ useEffect(() => {
2553
+ if (onAlphaChange && innerAlpha) {
2554
+ onAlphaChange(innerAlpha);
2555
+ }
2556
+ }, [onAlphaChange, innerAlpha]);
2557
+ const updateColorHsv = useCallback((_hsv, _changeColor) => {
2558
+ const rgb = ColorHelper.hsvToRgb(_hsv);
2559
+ const hex = ColorHelper.rgbToHex(rgb);
2560
+
2561
+ if (_changeColor) {
2562
+ setInnerColor(hex);
2563
+ }
2564
+
2565
+ updateInputs(hex);
2566
+ }, []);
2567
+ useEffect(() => {
2568
+ updateColorHsv(hsv, changeColor);
2569
+ }, [updateColorHsv, hsv, changeColor]);
2570
+
2571
+ function updateGradient(x, y) {
2572
+ setChangeColor(true);
2573
+ setHsv(prevHsv => Object.assign(Object.assign({}, prevHsv), {
2574
+ s: Math.floor(x) / baseSize,
2575
+ v: (baseSize - y) / baseSize
2576
+ }));
2577
+ }
2578
+
2579
+ function onGradientDrag(e, data) {
2580
+ e.preventDefault();
2581
+ updateGradient(data.x, data.y);
2582
+ }
2583
+
2584
+ function updateHue(y) {
2585
+ const newHue = y / baseSize;
2586
+ setChangeColor(true);
2587
+ setHsv(prevHsv => Object.assign(Object.assign({}, prevHsv), {
2588
+ h: newHue
2589
+ }));
2590
+ }
2591
+
2592
+ function onHueDrag(e, data) {
2593
+ e.preventDefault();
2594
+ updateHue(data.y + 14 + baseSize);
2595
+ }
2596
+
2597
+ function updateAlpha(y) {
2598
+ setInnerAlpha(100 - Math.round(y / baseSize * 100));
2599
+ }
2600
+
2601
+ function onAlphaDrag(e, data) {
2602
+ e.preventDefault();
2603
+ updateAlpha(data.y);
2604
+ }
2605
+
2606
+ const updateColorRgb = newColor => {
2607
+ const currentColor = newColor || '#FFFFFF';
2608
+ updateInputs(currentColor);
2609
+ const rgb = ColorHelper.hexToRgb(currentColor);
2610
+ setChangeColor(false);
2611
+
2612
+ if (rgb) {
2613
+ const newHsv = ColorHelper.rgbToHsv(rgb);
2614
+
2615
+ if (newHsv) {
2616
+ setHsv(newHsv);
2617
+ }
2618
+ }
2619
+
2620
+ setInnerColor(newColor);
2621
+ };
2622
+
2623
+ const isHexColor = _color => /^#[0-9A-F]{6}$/i.test(_color);
2624
+
2625
+ function onHexInput(event) {
2626
+ const newHexInputColor = event.target.value;
2627
+ setHexInputColor(newHexInputColor.toUpperCase());
2628
+
2629
+ if (isHexColor(newHexInputColor)) {
2630
+ updateColorRgb(newHexInputColor.toUpperCase());
2631
+ }
2632
+ }
2633
+
2634
+ function onHexBlur() {
2635
+ if (!isHexColor(hexInputColor) && innerColor) {
2636
+ setHexInputColor(innerColor);
2637
+ updateColorRgb(innerColor);
2638
+ }
2639
+ }
2640
+
2641
+ function onRgbBlur(channel) {
2642
+ let currentInput = '';
2643
+
2644
+ switch (channel) {
2645
+ case 'r':
2646
+ currentInput = redInput;
2647
+ break;
2648
+
2649
+ case 'g':
2650
+ currentInput = greenInput;
2651
+ break;
2652
+
2653
+ case 'b':
2654
+ currentInput = blueInput;
2655
+ break;
2656
+
2657
+ }
2658
+
2659
+ if (typeof currentInput !== 'number' || typeof currentInput === 'number' && currentInput > 255 && currentInput < 0) {
2660
+ const rgb = ColorHelper.hexToRgb(innerColor || '#FFFFFF');
2661
+
2662
+ if (rgb) {
2663
+ const newHexColor = ColorHelper.rgbToHex(rgb);
2664
+ updateInputs(newHexColor);
2665
+ }
2666
+ }
2667
+ }
2668
+
2669
+ function onRgbInput(_value, channel) {
2670
+ const numberValue = Number.parseInt(_value, 10);
2671
+
2672
+ switch (channel) {
2673
+ case 'r':
2674
+ setRedInput(_value);
2675
+ break;
2676
+
2677
+ case 'g':
2678
+ setGreenInput(_value);
2679
+ break;
2680
+
2681
+ case 'b':
2682
+ setBlueInput(_value);
2683
+ break;
2684
+
2685
+ }
2686
+
2687
+ if (numberValue <= 255 && numberValue >= 0) {
2688
+ const rgb = ColorHelper.hexToRgb(innerColor || '#FFFFFF');
2689
+
2690
+ if (rgb) {
2691
+ rgb[channel] = numberValue;
2692
+ const newHexColor = ColorHelper.rgbToHex(rgb);
2693
+ setInnerColor(newHexColor);
2694
+ updateColorRgb(newHexColor);
2695
+ }
2696
+ }
2697
+ }
2698
+
2699
+ function onAlphaInput(_alpha) {
2700
+ const numberValue = Number.parseInt(_alpha, 10);
2701
+ setInnerAlpha(numberValue);
2702
+ }
2703
+
2704
+ function onAlphaBlur() {
2705
+ setInnerAlpha(limitAlpha());
2706
+ }
2707
+
2708
+ const onChangeType = type => {
2709
+ setInputType(type);
2710
+ setSelectOpen(false);
2711
+ };
2712
+
2713
+ function onRemoveColor() {
2714
+ if (useAlpha) {
2715
+ setInnerAlpha(0);
2716
+ } else {
2717
+ updateColorRgb();
2718
+ }
2719
+ }
2720
+
2721
+ return jsxs("div", Object.assign({
2722
+ className: classNames('fwe-color-picker', {
2723
+ 'fwe-alpha-active': useAlpha
2724
+ }, className)
2725
+ }, {
2726
+ children: [!paletteOnly && jsxs("div", Object.assign({
2727
+ className: "fwe-d-flex"
2728
+ }, {
2729
+ children: [jsxs("div", Object.assign({
2730
+ className: "fwe-gradient-picker"
2731
+ }, {
2732
+ children: [jsx("div", {
2733
+ className: "fwe-saturation-gradient",
2734
+ style: {
2735
+ backgroundImage: getSaturationGradient()
2736
+ }
2737
+ }, void 0), jsx("div", {
2738
+ onClick: ({
2739
+ nativeEvent: {
2740
+ offsetX,
2741
+ offsetY
2742
+ }
2743
+ }) => updateGradient(offsetX, offsetY),
2744
+ className: "fwe-brightness-gradient"
2745
+ }, void 0), jsx(Draggable, Object.assign({
2746
+ position: {
2747
+ x: saturationKnobOffset,
2748
+ y: valueKnobOffset
2749
+ },
2750
+ onDrag: (e, data) => onGradientDrag(e, data),
2751
+ bounds: "parent"
2752
+ }, {
2753
+ children: jsx("div", {
2754
+ className: "fwe-knob"
2755
+ }, void 0)
2756
+ }), void 0)]
2757
+ }), void 0), jsxs("div", Object.assign({
2758
+ className: "fwe-hue-picker"
2759
+ }, {
2760
+ children: [jsx("div", {
2761
+ className: "fwe-picker-background",
2762
+ onClick: ({
2763
+ nativeEvent: {
2764
+ offsetY
2765
+ }
2766
+ }) => updateHue(offsetY)
2767
+ }, void 0), jsx(Draggable, Object.assign({
2768
+ position: {
2769
+ x: 3,
2770
+ y: hueKnobOffset
2771
+ },
2772
+ onDrag: (e, data) => onHueDrag(e, data),
2773
+ bounds: "parent"
2774
+ }, {
2775
+ children: jsx("div", {
2776
+ className: "fwe-knob",
2777
+ style: {
2778
+ background: `hsl(${hsv.h * 360}, 100%, 50%)`
2779
+ }
2780
+ }, void 0)
2781
+ }), void 0)]
2782
+ }), void 0), useAlpha && jsxs("div", Object.assign({
2783
+ className: "fwe-alpha-picker"
2784
+ }, {
2785
+ children: [jsxs("svg", Object.assign({
2786
+ className: "fwe-no-color-pattern",
2787
+ version: "1.1",
2788
+ xmlns: "http://www.w3.org/2000/svg",
2789
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
2790
+ id: "canvas1",
2791
+ width: "8",
2792
+ height: "184"
2793
+ }, {
2794
+ children: [jsx("defs", {
2795
+ children: jsxs("pattern", Object.assign({
2796
+ id: "bwsquare2px",
2797
+ width: "4",
2798
+ height: "4",
2799
+ patternUnits: "userSpaceOnUse"
2800
+ }, {
2801
+ children: [jsx("rect", {
2802
+ x: "0",
2803
+ y: "0",
2804
+ width: "2",
2805
+ height: "2",
2806
+ stroke: "none",
2807
+ fill: "#ffffff"
2808
+ }, void 0), jsx("rect", {
2809
+ x: "2",
2810
+ y: "0",
2811
+ width: "2",
2812
+ height: "2",
2813
+ stroke: "none",
2814
+ fill: "#e5e8eb"
2815
+ }, void 0), jsx("rect", {
2816
+ x: "0",
2817
+ y: "2",
2818
+ width: "2",
2819
+ height: "2",
2820
+ stroke: "none",
2821
+ fill: "#e5e8eb"
2822
+ }, void 0), jsx("rect", {
2823
+ x: "2",
2824
+ y: "2",
2825
+ width: "2",
2826
+ height: "2",
2827
+ stroke: "none",
2828
+ fill: "#ffffff"
2829
+ }, void 0)]
2830
+ }), void 0)
2831
+ }, void 0), jsx("rect", {
2832
+ x: "0",
2833
+ y: "0",
2834
+ rx: "4",
2835
+ ry: "4",
2836
+ width: "8",
2837
+ height: "184",
2838
+ fill: "url(#bwsquare2px)",
2839
+ strokeWidth: "0"
2840
+ }, void 0)]
2841
+ }), void 0), jsx("div", {
2842
+ onClick: ({
2843
+ nativeEvent: {
2844
+ offsetY
2845
+ }
2846
+ }) => updateAlpha(offsetY),
2847
+ className: "fwe-picker-background",
2848
+ style: {
2849
+ backgroundImage: `linear-gradient( ${innerColor}, transparent)`
2850
+ }
2851
+ }, void 0), jsx(Draggable, Object.assign({
2852
+ position: {
2853
+ x: 3,
2854
+ y: alphaKnobOffset
2855
+ },
2856
+ onDrag: (e, data) => onAlphaDrag(e, data),
2857
+ bounds: "parent"
2858
+ }, {
2859
+ children: jsx("div", {
2860
+ className: "fwe-knob"
2861
+ }, void 0)
2862
+ }), void 0)]
2863
+ }), void 0)]
2864
+ }), void 0), !paletteOnly && jsxs("div", Object.assign({
2865
+ className: "fwe-mt-s"
2866
+ }, {
2867
+ children: [jsxs("div", Object.assign({
2868
+ className: "fwe-type-select"
2869
+ }, {
2870
+ children: [jsxs("div", Object.assign({
2871
+ className: "fwe-type-indicator",
2872
+ onClick: () => setSelectOpen(prevOpen => !prevOpen)
2873
+ }, {
2874
+ children: [jsx("span", Object.assign({
2875
+ className: "fwe-input-type"
2876
+ }, {
2877
+ children: inputType
2878
+ }), void 0), jsx("i", {
2879
+ className: "fwe-icon fwe-icon-arrows-collapse"
2880
+ }, void 0)]
2881
+ }), void 0), selectOpen && jsxs("div", Object.assign({
2882
+ className: "fwe-popover"
2883
+ }, {
2884
+ children: [jsxs("div", Object.assign({
2885
+ className: classNames('fwe-type-item', {
2886
+ 'fwe-selected': inputType === 'HEX'
2887
+ }),
2888
+ onClick: () => onChangeType('HEX')
2889
+ }, {
2890
+ children: [jsx("i", {
2891
+ className: "fwe-icon fwe-icon-menu-check"
2892
+ }, void 0), " HEX"]
2893
+ }), void 0), jsxs("div", Object.assign({
2894
+ className: classNames('fwe-type-item', {
2895
+ 'fwe-selected': inputType === 'RGB'
2896
+ }),
2897
+ onClick: () => onChangeType('RGB')
2898
+ }, {
2899
+ children: [jsx("i", {
2900
+ className: "fwe-icon fwe-icon-menu-check"
2901
+ }, void 0), " RGB"]
2902
+ }), void 0)]
2903
+ }), void 0)]
2904
+ }), void 0), jsxs("div", Object.assign({
2905
+ className: "fwe-d-flex"
2906
+ }, {
2907
+ children: [inputType === 'HEX' && jsx("label", Object.assign({
2908
+ className: "fwe-input-text fwe-hex-input"
2909
+ }, {
2910
+ children: jsx("input", {
2911
+ type: "text",
2912
+ value: hexInputColor,
2913
+ onBlur: onHexBlur,
2914
+ onChange: onHexInput
2915
+ }, void 0)
2916
+ }), void 0), inputType === 'RGB' && jsxs(Fragment, {
2917
+ children: [jsx("label", Object.assign({
2918
+ className: "fwe-input-text fwe-red-input"
2919
+ }, {
2920
+ children: jsx("input", {
2921
+ type: "text",
2922
+ value: redInput,
2923
+ onBlur: () => onRgbBlur('r'),
2924
+ onChange: e => onRgbInput(e.target.value, 'r')
2925
+ }, void 0)
2926
+ }), void 0), jsx("label", Object.assign({
2927
+ className: "fwe-input-text fwe-green-input"
2928
+ }, {
2929
+ children: jsx("input", {
2930
+ type: "text",
2931
+ value: greenInput,
2932
+ onBlur: () => onRgbBlur('g'),
2933
+ onChange: e => onRgbInput(e.target.value, 'g')
2934
+ }, void 0)
2935
+ }), void 0), jsx("label", Object.assign({
2936
+ className: "fwe-input-text fwe-green-input"
2937
+ }, {
2938
+ children: jsx("input", {
2939
+ type: "text",
2940
+ value: blueInput,
2941
+ onBlur: () => onRgbBlur('b'),
2942
+ onChange: e => onRgbInput(e.target.value, 'b')
2943
+ }, void 0)
2944
+ }), void 0)]
2945
+ }, void 0), useAlpha && jsx("label", Object.assign({
2946
+ className: "fwe-input-text fwe-alpha-input fwe-ml-auto"
2947
+ }, {
2948
+ children: jsxs("span", {
2949
+ children: [jsx("input", {
2950
+ type: "number",
2951
+ min: "0",
2952
+ max: "100",
2953
+ value: innerAlpha,
2954
+ onBlur: () => onAlphaBlur(),
2955
+ onChange: e => onAlphaInput(e.target.value)
2956
+ }, void 0), jsx("span", Object.assign({
2957
+ className: "fwe-percent-char"
2958
+ }, {
2959
+ children: "%"
2960
+ }), void 0)]
2961
+ }, void 0)
2962
+ }), void 0)]
2963
+ }), void 0)]
2964
+ }), void 0), jsxs("div", Object.assign({
2965
+ className: "fwe-mt-xs fwe-color-grid"
2966
+ }, {
2967
+ children: [jsxs("div", Object.assign({
2968
+ className: "fwe-remove-color-button",
2969
+ onClick: onRemoveColor
2970
+ }, {
2971
+ children: [jsxs("svg", Object.assign({
2972
+ className: "fwe-no-color-pattern",
2973
+ version: "1.1",
2974
+ xmlns: "http://www.w3.org/2000/svg",
2975
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
2976
+ id: "canvas1",
2977
+ width: "18",
2978
+ height: "18"
2979
+ }, {
2980
+ children: [jsx("defs", {
2981
+ children: jsxs("pattern", Object.assign({
2982
+ id: "bwsquare2px",
2983
+ width: "4",
2984
+ height: "4",
2985
+ patternUnits: "userSpaceOnUse"
2986
+ }, {
2987
+ children: [jsx("rect", {
2988
+ x: "0",
2989
+ y: "0",
2990
+ width: "2",
2991
+ height: "2",
2992
+ stroke: "none",
2993
+ fill: "#ffffff"
2994
+ }, void 0), jsx("rect", {
2995
+ x: "2",
2996
+ y: "0",
2997
+ width: "2",
2998
+ height: "2",
2999
+ stroke: "none",
3000
+ fill: "#e5e8eb"
3001
+ }, void 0), jsx("rect", {
3002
+ x: "0",
3003
+ y: "2",
3004
+ width: "2",
3005
+ height: "2",
3006
+ stroke: "none",
3007
+ fill: "#e5e8eb"
3008
+ }, void 0), jsx("rect", {
3009
+ x: "2",
3010
+ y: "2",
3011
+ width: "2",
3012
+ height: "2",
3013
+ stroke: "none",
3014
+ fill: "#ffffff"
3015
+ }, void 0)]
3016
+ }), void 0)
3017
+ }, void 0), jsx("rect", {
3018
+ x: "0",
3019
+ y: "0",
3020
+ rx: "0",
3021
+ ry: "0",
3022
+ width: "18",
3023
+ height: "18",
3024
+ fill: "url(#bwsquare2px)",
3025
+ strokeWidth: "0"
3026
+ }, void 0)]
3027
+ }), void 0), jsx("i", {
3028
+ className: classNames('fwe-icon fwe-icon-menu-check', {
3029
+ 'fwe-color-text': !innerColor
3030
+ })
3031
+ }, void 0)]
3032
+ }), void 0), palette.map(colorItem => {
3033
+ const itemClasses = classNames('fwe-color-item', {
3034
+ 'fwe-white-item': colorItem.toUpperCase() === '#FFFFFF'
3035
+ });
3036
+ return jsx("div", Object.assign({
3037
+ className: itemClasses,
3038
+ style: {
3039
+ background: colorItem
3040
+ },
3041
+ onClick: () => updateColorRgb(colorItem.toUpperCase())
3042
+ }, {
3043
+ children: innerColor === colorItem.toUpperCase() && jsx("i", {
3044
+ className: "fwe-icon fwe-icon-menu-check"
3045
+ }, void 0)
3046
+ }), colorItem);
3047
+ })]
3048
+ }), void 0)]
3049
+ }), void 0);
3050
+ }
3051
+
3052
+ function DatePicker({
3053
+ children,
3054
+ className,
3055
+ disabled,
3056
+ required,
3057
+ error,
3058
+ hint,
3059
+ value,
3060
+ defaultValue = new Date(),
3061
+ formatDate = Intl.DateTimeFormat().format,
3062
+ options,
3063
+ onChange
3064
+ }) {
3065
+ const [open, setOpen] = useState(false);
3066
+ const [calendar, setCalendar] = useState(null);
3067
+ const innerDefaultValue = value || defaultValue;
3068
+
3069
+ function toggle() {
3070
+ const newOpen = !open;
3071
+ setOpen(newOpen);
3072
+
3073
+ if (newOpen) {
3074
+ calendar.open();
3075
+ } else {
3076
+ calendar.close();
3077
+ }
3078
+ }
3079
+
3080
+ const datePickerRef = useRef(null);
3081
+ const {
3082
+ keepOpenOnDateChange,
3083
+ maxDate,
3084
+ minDate
3085
+ } = options || {};
3086
+ useEffect(() => {
3087
+ if (calendar !== null && value !== undefined) {
3088
+ calendar.setDate(value);
3089
+ }
3090
+ }, [calendar, value]);
3091
+ useEffect(() => {
3092
+ var _a;
3093
+
3094
+ function handleChange(date) {
3095
+ datePickerRef.current.blur();
3096
+
3097
+ if (onChange) {
3098
+ onChange(date);
3099
+ }
3100
+ }
3101
+
3102
+ function handleClose() {
3103
+ setOpen(false);
3104
+ datePickerRef.current.blur();
3105
+ }
3106
+
3107
+ if (datePickerRef.current && calendar === null) {
3108
+ setCalendar(flatpickr(datePickerRef.current, {
3109
+ defaultDate: innerDefaultValue,
3110
+ onChange: v => handleChange(v[0]),
3111
+ onClose: handleClose,
3112
+ position: 'below center',
3113
+ formatDate,
3114
+ closeOnSelect: (_a = !keepOpenOnDateChange) !== null && _a !== void 0 ? _a : true,
3115
+ clickOpens: false,
3116
+ minDate,
3117
+ maxDate
3118
+ }));
3119
+ }
3120
+ }, [datePickerRef, calendar, maxDate, minDate, onChange, innerDefaultValue, formatDate, keepOpenOnDateChange]);
3121
+ useEffect(() => () => {
3122
+ if (calendar !== null) {
3123
+ calendar.destroy();
3124
+ }
3125
+ }, [calendar]);
3126
+ return jsxs("label", Object.assign({
3127
+ className: classNames('fwe-input-text fwe-input-text-icon', className),
3128
+ onClick: toggle
3129
+ }, {
3130
+ children: [jsx("i", {
3131
+ className: classNames('fwe-icon fwe-icon-time-calendar', {
3132
+ 'fwe-color-hero': open && !disabled,
3133
+ 'fwe-color-control-disabled': disabled
3134
+ })
3135
+ }, void 0), jsx("input", {
3136
+ ref: datePickerRef,
3137
+ "aria-label": "picked date",
3138
+ type: "text",
3139
+ readOnly: true,
3140
+ required: required || null,
3141
+ className: classNames('fr-date-picker', {
3142
+ 'fwe-border-hero': open && !disabled
3143
+ }),
3144
+ disabled: disabled
3145
+ }, void 0), jsx("span", Object.assign({
3146
+ className: "fwe-input-text-label"
3147
+ }, {
3148
+ children: children
3149
+ }), void 0), hint && jsx("span", Object.assign({
3150
+ className: "fwe-input-text-info"
3151
+ }, {
3152
+ children: hint
3153
+ }), void 0), error && jsx("span", Object.assign({
3154
+ className: "fwe-input-text-invalid"
3155
+ }, {
3156
+ children: error
3157
+ }), void 0)]
3158
+ }), void 0);
3159
+ }
3160
+
3161
+ function DateRangePicker({
3162
+ children,
3163
+ className,
3164
+ disabled,
3165
+ error,
3166
+ formatDate,
3167
+ hint,
3168
+ onChange,
3169
+ options,
3170
+ required,
3171
+ defaultValue = new Date()
3172
+ }) {
3173
+ const [open, setOpen] = useState(false);
3174
+ const [calendar, setCalendar] = useState(null);
3175
+
3176
+ function toggle() {
3177
+ const newOpen = !open;
3178
+ setOpen(newOpen);
3179
+
3180
+ if (newOpen) {
3181
+ calendar.open();
3182
+ } else {
3183
+ calendar.close();
3184
+ }
3185
+ }
3186
+
3187
+ const inputRef = useRef(null);
3188
+ const input2Ref = useRef(null);
3189
+ const containerRef = useRef(null);
3190
+ useEffect(() => {
3191
+ var _a;
3192
+
3193
+ function handleChange(dates) {
3194
+ if (onChange) {
3195
+ onChange(dates);
3196
+ }
3197
+ }
3198
+
3199
+ function handleClose() {
3200
+ setOpen(false);
3201
+ inputRef.current.blur();
3202
+ input2Ref.current.blur();
3203
+ }
3204
+
3205
+ if (containerRef.current && inputRef.current && input2Ref.current && calendar === null) {
3206
+ setCalendar(flatpickr(inputRef.current, {
3207
+ defaultDate: defaultValue,
3208
+ plugins: [rangePlugin({
3209
+ input: input2Ref.current
3210
+ })],
3211
+ onChange: v => handleChange(v),
3212
+ position: 'below center',
3213
+ positionElement: containerRef.current,
3214
+ formatDate,
3215
+ closeOnSelect: (_a = !(options === null || options === void 0 ? void 0 : options.keepOpenOnDateChange)) !== null && _a !== void 0 ? _a : true,
3216
+ clickOpens: false,
3217
+ onClose: handleClose,
3218
+ minDate: options === null || options === void 0 ? void 0 : options.minDate,
3219
+ maxDate: options === null || options === void 0 ? void 0 : options.maxDate
3220
+ }));
3221
+ }
3222
+ }, [inputRef, input2Ref, containerRef, formatDate, options, onChange, calendar, defaultValue]);
3223
+ useEffect(() => () => {
3224
+ if (calendar !== null) {
3225
+ calendar.destroy();
3226
+ }
3227
+ }, [calendar]);
3228
+ return jsx("div", Object.assign({
3229
+ className: classNames('fr-date-range-picker', className),
3230
+ onClick: toggle
3231
+ }, {
3232
+ children: jsxs("label", Object.assign({
3233
+ className: "fwe-input-text fwe-input-text-icon"
3234
+ }, {
3235
+ children: [jsx("i", {
3236
+ className: classNames('fwe-icon fwe-icon-time-calendar', {
3237
+ 'fwe-color-hero': open && !disabled,
3238
+ 'fwe-color-control-disabled': disabled
3239
+ })
3240
+ }, void 0), jsxs("div", Object.assign({
3241
+ ref: containerRef,
3242
+ className: "fr-date-range-picker-inputs"
3243
+ }, {
3244
+ children: [jsx("input", {
3245
+ ref: inputRef,
3246
+ "aria-label": "picked start date",
3247
+ type: "text",
3248
+ readOnly: true,
3249
+ required: required || null,
3250
+ className: classNames({
3251
+ 'fwe-border-hero': open && !disabled
3252
+ }),
3253
+ disabled: disabled
3254
+ }, void 0), jsx("input", {
3255
+ ref: input2Ref,
3256
+ "aria-label": "picked end date",
3257
+ type: "text",
3258
+ readOnly: true,
3259
+ required: required || null,
3260
+ className: classNames({
3261
+ 'fwe-border-hero': open && !disabled
3262
+ }),
3263
+ disabled: disabled
3264
+ }, void 0)]
3265
+ }), void 0), jsx("span", Object.assign({
3266
+ className: classNames('fwe-input-text-label', {
3267
+ 'fwe-color-text-disabled': disabled
3268
+ })
3269
+ }, {
3270
+ children: children
3271
+ }), void 0), hint && jsx("span", Object.assign({
3272
+ className: "fwe-input-text-info"
3273
+ }, {
3274
+ children: hint
3275
+ }), void 0), error && jsx("span", Object.assign({
3276
+ className: "fwe-input-text-invalid"
3277
+ }, {
3278
+ children: error
3279
+ }), void 0)]
3280
+ }), void 0)
3281
+ }), void 0);
3282
+ }
3283
+
3284
+ const RadioGroupContext = /*#__PURE__*/createContext({});
3285
+
3286
+ function RadioButton({
3287
+ id,
3288
+ onChange,
3289
+ value,
3290
+ name,
3291
+ checked,
3292
+ labelPosition = 'after',
3293
+ large = false,
3294
+ disabled = false,
3295
+ required = false,
3296
+ children,
3297
+ className
3298
+ }) {
3299
+ const {
3300
+ disabled: groupDisabled,
3301
+ labelPosition: groupLabelPosition,
3302
+ large: groupLarge,
3303
+ name: groupName,
3304
+ required: groupRequired,
3305
+ value: groupValue
3306
+ } = useContext(RadioGroupContext);
3307
+ const innerLabelPosition = groupLabelPosition || labelPosition;
3308
+ const classes = classNames('fwe-radio', {
3309
+ 'fwe-radio-label-below': innerLabelPosition === 'below'
3310
+ }, {
3311
+ 'fwe-radio-label-before': innerLabelPosition === 'before'
3312
+ }, {
3313
+ 'fwe-radio-lg': large || groupLarge
3314
+ }, className);
3315
+ return jsxs("label", Object.assign({
3316
+ className: classes,
3317
+ htmlFor: id
3318
+ }, {
3319
+ children: [jsx("input", {
3320
+ checked: checked,
3321
+ type: "radio",
3322
+ id: id,
3323
+ name: groupName || name,
3324
+ value: value || groupValue,
3325
+ onChange: () => onChange(value),
3326
+ disabled: disabled || groupDisabled,
3327
+ required: required || groupRequired
3328
+ }, void 0), jsx("div", {
3329
+ className: "fwe-radio-checkmark"
3330
+ }, void 0), " ", jsx("div", Object.assign({
3331
+ className: "fwe-radio-label-content"
3332
+ }, {
3333
+ children: children
3334
+ }), void 0)]
3335
+ }), void 0);
3336
+ }
3337
+
3338
+ const defaultConfig$1 = {
3339
+ outline: true,
3340
+ iconOnly: true
3341
+ };
3342
+ function Segment(props) {
3343
+ const {
3344
+ children,
3345
+ legend,
3346
+ config,
3347
+ onChange,
3348
+ className
3349
+ } = props;
3350
+ const innerConfig = Object.assign(Object.assign({}, defaultConfig$1), config);
3351
+ let useIcon = false;
3352
+ let useIconAndText = false;
3353
+ let tmpValue = '';
3354
+ React.Children.forEach(children, (child, index) => {
3355
+ if (! /*#__PURE__*/React.isValidElement(child)) {
3356
+ return null;
3357
+ }
3358
+
3359
+ if (index === 0 && child.props.icon !== null) {
3360
+ if (innerConfig.iconOnly) {
3361
+ useIcon = true;
3362
+ } else {
3363
+ useIconAndText = true;
3364
+ }
3365
+ }
3366
+
3367
+ if (child.props.checked) {
3368
+ tmpValue = child.props.value;
3369
+ }
3370
+
3371
+ return null;
3372
+ });
3373
+ const [value, setValue] = useState(tmpValue);
3374
+
3375
+ const handleChange = (event, _value) => {
3376
+ if (onChange) {
3377
+ onChange(event, _value);
3378
+ }
3379
+
3380
+ setValue(_value);
3381
+ };
3382
+
3383
+ return jsxs("fieldset", Object.assign({
3384
+ className: classNames('fwe-segment', {
3385
+ 'fwe-segment-outline': innerConfig.outline,
3386
+ 'fwe-segment-icon': useIcon,
3387
+ 'fwe-segment-icon-text': useIconAndText
3388
+ }, className)
3389
+ }, {
3390
+ children: [jsx("legend", Object.assign({
3391
+ className: "fwe-sr-only fwe-d-inline-block"
3392
+ }, {
3393
+ children: legend
3394
+ }), void 0), jsx("div", Object.assign({
3395
+ className: "fwe-segment-group"
3396
+ }, {
3397
+ children: React.Children.map(children, child => {
3398
+ if (! /*#__PURE__*/React.isValidElement(child)) {
3399
+ return null;
3400
+ }
3401
+
3402
+ const id = (Math.random() * Date.now()).toString().replace('.', '-');
3403
+ return /*#__PURE__*/React.cloneElement(child, {
3404
+ key: id,
3405
+ id,
3406
+ onChange: handleChange,
3407
+ iconOnly: innerConfig.iconOnly,
3408
+ checked: child.props.value === value
3409
+ });
3410
+ })
3411
+ }), void 0)]
3412
+ }), void 0);
3413
+ }
3414
+
3415
+ function SegmentControl(props) {
3416
+ const {
3417
+ label,
3418
+ checked,
3419
+ disabled,
3420
+ name,
3421
+ value,
3422
+ icon,
3423
+ onChange,
3424
+ iconOnly,
3425
+ id = (Math.random() * Date.now()).toString().replace('.', '-'),
3426
+ className
3427
+ } = props;
3428
+ let viewMode = 'text';
3429
+
3430
+ if (icon) {
3431
+ viewMode = iconOnly ? 'icon' : 'icon-text';
3432
+ }
3433
+
3434
+ const prefix = 'fwe-icon-';
3435
+ let innerIcon = icon;
3436
+
3437
+ if (icon && icon.indexOf(prefix) === -1) {
3438
+ innerIcon = prefix + icon;
3439
+ }
3440
+
3441
+ const handleChange = event => {
3442
+ if (onChange) {
3443
+ onChange(event, value);
3444
+ }
3445
+ };
3446
+
3447
+ return jsxs(Fragment, {
3448
+ children: [jsx("input", {
3449
+ className: "fwe-segment-input",
3450
+ type: "radio",
3451
+ id: id,
3452
+ name: name,
3453
+ value: value,
3454
+ checked: checked,
3455
+ disabled: disabled,
3456
+ onChange: e => handleChange(e)
3457
+ }, void 0), jsxs("label", Object.assign({
3458
+ className: classNames('fwe-segment-label', className),
3459
+ htmlFor: id
3460
+ }, {
3461
+ children: [viewMode === 'icon' && jsxs(Fragment, {
3462
+ children: [jsx("span", Object.assign({
3463
+ className: "fwe-sr-only"
3464
+ }, {
3465
+ children: label
3466
+ }), void 0), jsx("i", {
3467
+ "aria-hidden": "true",
3468
+ className: classNames('fwe-icon', innerIcon)
3469
+ }, void 0)]
3470
+ }, void 0), viewMode === 'text' && label, viewMode === 'icon-text' && jsxs(Fragment, {
3471
+ children: [jsx("i", {
3472
+ "aria-hidden": "true",
3473
+ className: classNames('fwe-icon', innerIcon)
3474
+ }, void 0), label]
3475
+ }, void 0)]
3476
+ }), void 0)]
3477
+ }, void 0);
3478
+ }
3479
+
3480
+ const SelectOption = /*#__PURE__*/forwardRef((_a, ref) => {
3481
+ var {
3482
+ children,
3483
+ className
3484
+ } = _a,
3485
+ props = __rest(_a, ["children", "className"]);
3486
+
3487
+ return jsx("span", Object.assign({
3488
+ ref: ref,
3489
+ className: className
3490
+ }, props, {
3491
+ children: children
3492
+ }), void 0);
3493
+ });
3494
+
3495
+ function calcVirtualScrollHeight(config, itemLength) {
3496
+ const defaultHeight = 48;
3497
+ let height = defaultHeight;
3498
+
3499
+ if (itemLength === 2) {
3500
+ height = defaultHeight * 2;
3501
+ } else if (itemLength >= 3) {
3502
+ height = defaultHeight * 3;
3503
+ }
3504
+
3505
+ if (config.scroll.viewportSize != null && config.scroll.viewportSize !== undefined) {
3506
+ if (itemLength >= config.scroll.viewportSize) {
3507
+ height = config.scroll.viewportSize * defaultHeight;
3508
+ } else if (itemLength < config.scroll.viewportSize) {
3509
+ height = itemLength * defaultHeight;
3510
+ }
3511
+ }
3512
+
3513
+ return height;
3514
+ }
3515
+
3516
+ const Select = /*#__PURE__*/forwardRef((_a, ref) => {
3517
+ var {
3518
+ defaultValue,
3519
+ value,
3520
+ label,
3521
+ options,
3522
+ onChange,
3523
+ required = false,
3524
+ config,
3525
+ disabled,
3526
+ className,
3527
+ name,
3528
+ id,
3529
+ children,
3530
+ hint,
3531
+ error
3532
+ } = _a,
3533
+ props = __rest(_a, ["defaultValue", "value", "label", "options", "onChange", "required", "config", "disabled", "className", "name", "id", "children", "hint", "error"]);
3534
+
3535
+ const [optionsWrapper, setOptionsWrapper] = useState({
3536
+ isFocused: false,
3537
+ action: ''
3538
+ });
3539
+ const controlled = value !== undefined;
3540
+ const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
3541
+ const buttonEl = useRef(null);
3542
+ const childrenList = [];
3543
+ React.Children.forEach(children, element => {
3544
+ if ( /*#__PURE__*/React.isValidElement(element)) {
3545
+ childrenList.push(Object.assign(Object.assign({}, element), {
3546
+ props: Object.assign(Object.assign({}, element.props), {
3547
+ className: 'fwe-select-option-content'
3548
+ })
3549
+ }));
3550
+ }
3551
+ });
3552
+ const usedOptions = options !== null && options !== void 0 ? options : childrenList.map(child => child.props.option);
3553
+ const listItemRef = useRef(Array.from({
3554
+ length: usedOptions.length
3555
+ }, () => /*#__PURE__*/React.createRef()));
3556
+ useEffect(() => {
3557
+ if (controlled) {
3558
+ setInnerValue(value);
3559
+ }
3560
+ }, [value, controlled]);
3561
+ const getSelectedOptionLabel = useCallback(() => {
3562
+ var _a;
3563
+
3564
+ if (innerValue !== undefined) {
3565
+ return (_a = usedOptions.find(option => option.data === innerValue)) === null || _a === void 0 ? void 0 : _a.label;
3566
+ }
3567
+
3568
+ return undefined;
3569
+ }, [usedOptions, innerValue]);
3570
+ const scroll = config === null || config === void 0 ? void 0 : config.scroll;
3571
+
3572
+ function handleButtonFocus(blur) {
3573
+ if (buttonEl && buttonEl.current) {
3574
+ if (blur) {
3575
+ buttonEl.current.blur();
3576
+ } else {
3577
+ buttonEl.current.focus();
3578
+ }
3579
+ }
3580
+ }
3581
+
3582
+ const focusNextElement = nextIndex => {
3583
+ if (listItemRef && listItemRef.current) {
3584
+ const nextItem = listItemRef.current[nextIndex].current;
3585
+
3586
+ if (nextItem !== null) {
3587
+ nextItem.focus();
3588
+ }
3589
+ }
3590
+ };
3591
+
3592
+ useEffect(() => {
3593
+ if (optionsWrapper.isFocused) {
3594
+ if (optionsWrapper.action === 'key') {
3595
+ const index = usedOptions.findIndex(option => option.label === getSelectedOptionLabel());
3596
+
3597
+ if (index >= 0) {
3598
+ focusNextElement(index);
3599
+ }
3600
+ } else if (optionsWrapper.action === 'click') {
3601
+ handleButtonFocus(true);
3602
+ }
3603
+ }
3604
+ }, [optionsWrapper, usedOptions, innerValue, getSelectedOptionLabel]);
3605
+
3606
+ const handleOptionChange = newOption => {
3607
+ if (!controlled) {
3608
+ setInnerValue(newOption.data);
3609
+ }
3610
+
3611
+ if (onChange) {
3612
+ onChange(newOption.data);
3613
+ }
3614
+
3615
+ setOptionsWrapper(prevOptionsWrapper => Object.assign(Object.assign({}, prevOptionsWrapper), {
3616
+ isFocused: false
3617
+ }));
3618
+
3619
+ if (buttonEl && buttonEl.current) {
3620
+ buttonEl.current.focus();
3621
+ }
3622
+ };
3623
+
3624
+ const handleListKeyDown = (event, option, index) => {
3625
+ const arrowKeys = ['ArrowDown', 'ArrowUp'];
3626
+ const validKeys = ['Enter', ' '];
3627
+
3628
+ if (arrowKeys.concat(validKeys).includes(event.key)) {
3629
+ event.preventDefault();
3630
+ }
3631
+
3632
+ if (event.key === 'ArrowDown') {
3633
+ focusNextElement((index + 1) % usedOptions.length);
3634
+ }
3635
+
3636
+ if (event.key === 'ArrowUp') {
3637
+ event.preventDefault();
3638
+ let nextIndex = (index - 1) % usedOptions.length;
3639
+
3640
+ if (nextIndex < 0) {
3641
+ nextIndex += usedOptions.length;
3642
+ }
3643
+
3644
+ focusNextElement(nextIndex);
3645
+ }
3646
+
3647
+ if (validKeys.includes(event.key)) {
3648
+ handleOptionChange(option);
3649
+ event.preventDefault();
3650
+ }
3651
+
3652
+ if (event.key === 'Escape') {
3653
+ setOptionsWrapper(prevOptionsWrapper => Object.assign(Object.assign({}, prevOptionsWrapper), {
3654
+ isFocused: false
3655
+ }));
3656
+ handleButtonFocus();
3657
+ }
3658
+ };
3659
+
3660
+ const handleKeyPress = event => {
3661
+ const validKeys = ['Enter', ' ', 'ArrowUp', 'ArrowDown'];
3662
+
3663
+ if (validKeys.includes(event.key)) {
3664
+ event.preventDefault();
3665
+
3666
+ if (!disabled) {
3667
+ setOptionsWrapper(prevOptionsWrapper => ({
3668
+ action: 'key',
3669
+ isFocused: !prevOptionsWrapper.isFocused
3670
+ }));
3671
+ }
3672
+ }
3673
+ };
3674
+
3675
+ const handleClick = e => {
3676
+ e.stopPropagation();
3677
+
3678
+ if (!disabled) {
3679
+ setOptionsWrapper(prevOptionsWrapper => ({
3680
+ action: '',
3681
+ isFocused: !prevOptionsWrapper.isFocused
3682
+ }));
3683
+ }
3684
+ };
3685
+
3686
+ const selectedOptionLabel = getSelectedOptionLabel();
3687
+ const selectClassName = classNames('fwe-select', {
3688
+ 'fwe-focus': optionsWrapper.isFocused
3689
+ }, {
3690
+ 'fwe-empty': selectedOptionLabel === undefined && !optionsWrapper.isFocused
3691
+ }, {
3692
+ 'fwe-required': required
3693
+ }, {
3694
+ 'fwe-disabled': disabled
3695
+ }, {
3696
+ 'fwe-invalid': error
3697
+ });
3698
+
3699
+ function renderOptions() {
3700
+ return jsxs(Fragment, {
3701
+ children: [options && options.map((option, i) => jsx("li", Object.assign({
3702
+ ref: listItemRef.current[i],
3703
+ role: "option",
3704
+ "aria-selected": option.label === selectedOptionLabel,
3705
+ onClick: () => handleOptionChange(option),
3706
+ className: classNames('fwe-select-option', {
3707
+ 'fwe-empty': !option.label
3708
+ }),
3709
+ onKeyDown: e => handleListKeyDown(e, option, i),
3710
+ tabIndex: 0
3711
+ }, {
3712
+ children: jsx("span", Object.assign({
3713
+ className: "fwe-select-option-content"
3714
+ }, {
3715
+ children: option.label
3716
+ }), void 0)
3717
+ }), option.data)), childrenList.map((child, i) => {
3718
+ const _a = child.props,
3719
+ {
3720
+ option
3721
+ } = _a,
3722
+ propsWithoutOption = __rest(_a, ["option"]);
3723
+
3724
+ return jsx("li", Object.assign({
3725
+ ref: listItemRef.current[i],
3726
+ role: "option",
3727
+ "aria-selected": option.label === selectedOptionLabel,
3728
+ onClick: () => handleOptionChange(option),
3729
+ className: classNames('fwe-select-option', {
3730
+ 'fwe-empty': !option.label
3731
+ }),
3732
+ onKeyDown: e => handleListKeyDown(e, option, i),
3733
+ tabIndex: 0
3734
+ }, {
3735
+ children: jsx(SelectOption, Object.assign({}, propsWithoutOption), void 0)
3736
+ }), option.data);
3737
+ })]
3738
+ }, void 0);
3739
+ }
3740
+
3741
+ return jsx(OutsideClickHandler, Object.assign({
3742
+ onOutsideClick: () => setOptionsWrapper({
3743
+ action: '',
3744
+ isFocused: false
3745
+ })
3746
+ }, {
3747
+ children: jsxs("div", Object.assign({
3748
+ ref: ref,
3749
+ className: classNames('fwe-select-wrapper', className)
3750
+ }, props, {
3751
+ children: [jsx("select", Object.assign({
3752
+ defaultValue: defaultValue,
3753
+ value: innerValue,
3754
+ name: name,
3755
+ id: id,
3756
+ "aria-label": label,
3757
+ disabled: disabled,
3758
+ required: required
3759
+ }, {
3760
+ children: usedOptions.map(option => jsx("option", Object.assign({
3761
+ value: option.data
3762
+ }, {
3763
+ children: option.label
3764
+ }), option.data))
3765
+ }), void 0), jsx("div", Object.assign({
3766
+ role: "button",
3767
+ tabIndex: 0,
3768
+ className: selectClassName,
3769
+ onClick: e => handleClick(e),
3770
+ ref: buttonEl,
3771
+ onKeyDown: handleKeyPress
3772
+ }, {
3773
+ children: jsx("div", Object.assign({
3774
+ className: "fwe-select-content"
3775
+ }, {
3776
+ children: selectedOptionLabel
3777
+ }), void 0)
3778
+ }), void 0), jsx("label", Object.assign({
3779
+ className: classNames('fwe-select-label', {
3780
+ 'fwe-sr-only': config === null || config === void 0 ? void 0 : config.hideLabel
3781
+ }),
3782
+ htmlFor: id
3783
+ }, {
3784
+ children: label || ''
3785
+ }), void 0), jsx("div", {
3786
+ className: "fwe-select-underline"
3787
+ }, void 0), hint && !error && jsx("div", Object.assign({
3788
+ className: "fwe-select-description"
3789
+ }, {
3790
+ children: hint
3791
+ }), void 0), error && jsxs("div", Object.assign({
3792
+ className: "fwe-select-invalid"
3793
+ }, {
3794
+ children: [" ", error, " "]
3795
+ }), void 0), jsx("ul", Object.assign({
3796
+ className: `fwe-select-options-container${optionsWrapper.isFocused ? '' : ' fwe-d-none'}`
3797
+ }, {
3798
+ children: (scroll === null || scroll === void 0 ? void 0 : scroll.enabled) ? jsx("div", Object.assign({
3799
+ className: "fr-select-scroll",
3800
+ style: {
3801
+ height: calcVirtualScrollHeight(config, usedOptions.length)
3802
+ }
3803
+ }, {
3804
+ children: renderOptions()
3805
+ }), void 0) : renderOptions()
3806
+ }), void 0)]
3807
+ }), void 0)
3808
+ }), void 0);
3809
+ });
3810
+
3811
+ function Slider({
3812
+ disabled = false,
3813
+ label,
3814
+ large = false,
3815
+ max,
3816
+ min,
3817
+ onChange,
3818
+ onChangeCommitted,
3819
+ step,
3820
+ value,
3821
+ showValue = true,
3822
+ className
3823
+ }) {
3824
+ const [innerValue, setInnerValue] = useState(value);
3825
+ const [left, setLeft] = useState(null);
3826
+ const labelEl = useRef(null);
3827
+ const classes = classNames('fwe-slider', {
3828
+ 'fwe-slider-lg': large
3829
+ }, {
3830
+ 'fr-slider-label': label !== null && showValue
3831
+ }, className);
3832
+ useEffect(() => {
3833
+ setInnerValue(value);
3834
+ }, [value]);
3835
+ const updateValuePosition = useCallback(() => {
3836
+ if (labelEl.current) {
3837
+ const {
3838
+ width
3839
+ } = labelEl.current.getBoundingClientRect();
3840
+ const diff = max - min;
3841
+ setLeft((innerValue - min) / diff * (width - 16));
3842
+ }
3843
+ }, [innerValue, max, min]);
3844
+
3845
+ const handleAfterChange = () => {
3846
+ if (onChangeCommitted) {
3847
+ onChangeCommitted(innerValue);
3848
+ }
3849
+ };
3850
+
3851
+ const handleChange = e => {
3852
+ const newValue = Number.parseFloat(e.target.value);
3853
+ setInnerValue(newValue);
3854
+
3855
+ if (onChange) {
3856
+ onChange(e, newValue);
3857
+ }
3858
+ };
3859
+
3860
+ useEffect(() => {
3861
+ function handleResize() {
3862
+ updateValuePosition();
3863
+ }
3864
+
3865
+ window.addEventListener('resize', handleResize);
3866
+ handleResize(); // Remove event listener on cleanup
3867
+
3868
+ return () => window.removeEventListener('resize', handleResize);
3869
+ }, [updateValuePosition]);
3870
+ return jsxs("label", Object.assign({
3871
+ ref: labelEl,
3872
+ className: classes
3873
+ }, {
3874
+ children: [label && jsx("span", {
3875
+ children: label
3876
+ }, void 0), jsx("input", {
3877
+ className: "fwe-slider-input",
3878
+ type: "range",
3879
+ disabled: disabled,
3880
+ min: min,
3881
+ max: max,
3882
+ step: step,
3883
+ onChange: handleChange,
3884
+ value: innerValue,
3885
+ onKeyUp: handleAfterChange,
3886
+ onMouseUp: handleAfterChange,
3887
+ onTouchEnd: handleAfterChange
3888
+ }, void 0), showValue && left !== null && jsx("span", Object.assign({
3889
+ className: "fr-slider-value",
3890
+ style: {
3891
+ left: `${left}px`
3892
+ }
3893
+ }, {
3894
+ children: innerValue
3895
+ }), void 0)]
3896
+ }), void 0);
3897
+ }
3898
+
3899
+ function Switch({
3900
+ labelPosition = 'before',
3901
+ large = false,
3902
+ title,
3903
+ value,
3904
+ disabled = false,
3905
+ onChange,
3906
+ className
3907
+ }) {
3908
+ const labelClassName = classNames('fwe-switch', {
3909
+ [`fwe-switch-label-${labelPosition}`]: true
3910
+ }, {
3911
+ 'fwe-switch-lg': large
3912
+ }, className);
3913
+ const [currentValue, setCurrentValue] = useState(value);
3914
+ useEffect(() => {
3915
+ setCurrentValue(value);
3916
+ }, [value]);
3917
+
3918
+ const handleChange = () => {
3919
+ const newValue = !currentValue;
3920
+ setCurrentValue(newValue);
3921
+
3922
+ if (onChange) {
3923
+ onChange(newValue);
3924
+ }
3925
+ };
3926
+
3927
+ return jsxs("label", Object.assign({
3928
+ className: labelClassName
3929
+ }, {
3930
+ children: [jsx("input", {
3931
+ type: "checkbox",
3932
+ disabled: disabled,
3933
+ checked: currentValue,
3934
+ onChange: () => handleChange()
3935
+ }, void 0), jsx("div", {
3936
+ className: "fwe-switch-track"
3937
+ }, void 0), jsx("div", Object.assign({
3938
+ className: "fwe-switch-label-content"
3939
+ }, {
3940
+ children: title
3941
+ }), void 0)]
3942
+ }), void 0);
3943
+ }
3944
+
3945
+ function TextArea({
3946
+ disabled,
3947
+ onBlur,
3948
+ onChange,
3949
+ onFocus,
3950
+ onInput,
3951
+ readonly,
3952
+ required,
3953
+ label,
3954
+ error,
3955
+ hint,
3956
+ value,
3957
+ rows,
3958
+ maxLength,
3959
+ className,
3960
+ defaultValue
3961
+ }) {
3962
+ const controlled = value !== undefined;
3963
+ const [innerValue, setInnerValue] = useState(controlled ? value : defaultValue);
3964
+ const hintClasses = classNames('fwe-input-text-info');
3965
+ const shadowRef = React.useRef(null);
3966
+ const ref = React.useRef(null);
3967
+ const [height, setHeight] = useState(null);
3968
+ useEffect(() => {
3969
+ if (controlled) {
3970
+ setInnerValue(value);
3971
+ }
3972
+ }, [value, controlled]);
3973
+ useEffect(() => {
3974
+ const input = ref.current;
3975
+ const shadow = shadowRef.current;
3976
+ const minRows = 2;
3977
+ shadow.value = input.value || 'x';
3978
+ shadow.style.width = `${input.clientWidth}`;
3979
+ const newHeight = Math.max(minRows * 24, shadow.scrollHeight);
3980
+ setHeight(newHeight + 4 + 4 + 1);
3981
+ }, [innerValue]);
3982
+
3983
+ function handleChange(event) {
3984
+ if (!controlled) {
3985
+ setInnerValue(event.target.value);
3986
+ }
3987
+
3988
+ if (onChange) {
3989
+ onChange(event);
3990
+ }
3991
+ }
3992
+
3993
+ return jsxs("label", Object.assign({
3994
+ className: classNames('fwe-input-text', className)
3995
+ }, {
3996
+ children: [jsx("textarea", {
3997
+ style: Object.assign({}, !rows && {
3998
+ height,
3999
+ overflow: 'hidden'
4000
+ }),
4001
+ ref: ref,
4002
+ className: classNames('fr-textarea', `fwe-row-${rows}`),
4003
+ disabled: disabled,
4004
+ readOnly: readonly,
4005
+ required: required,
4006
+ autoComplete: "off",
4007
+ onChange: handleChange,
4008
+ onFocus: onFocus,
4009
+ onInput: onInput,
4010
+ onBlur: onBlur,
4011
+ maxLength: maxLength,
4012
+ defaultValue: innerValue,
4013
+ value: innerValue
4014
+ }, void 0), jsx("textarea", {
4015
+ style: {
4016
+ visibility: 'hidden',
4017
+ position: 'absolute',
4018
+ overflow: 'hidden',
4019
+ height: 0,
4020
+ top: 0,
4021
+ left: 0,
4022
+ transform: 'translateZ(0)',
4023
+ padding: '0'
4024
+ },
4025
+ ref: shadowRef,
4026
+ readOnly: true
4027
+ }, void 0), jsx("span", Object.assign({
4028
+ className: "fwe-input-text-label"
4029
+ }, {
4030
+ children: label
4031
+ }), void 0), hint && jsx("span", Object.assign({
4032
+ className: hintClasses
4033
+ }, {
4034
+ children: hint
4035
+ }), void 0), error !== undefined && jsx("span", Object.assign({
4036
+ className: "fwe-input-text-invalid"
4037
+ }, {
4038
+ children: error
4039
+ }), void 0), maxLength > 0 && jsxs("span", Object.assign({
4040
+ className: "fwe-input-text-count"
4041
+ }, {
4042
+ children: [innerValue.length, " /", maxLength]
4043
+ }), void 0)]
4044
+ }), void 0);
4045
+ }
4046
+
4047
+ function TextEditorButton({
4048
+ disabled,
4049
+ label,
4050
+ type,
4051
+ className,
4052
+ icon,
4053
+ list,
4054
+ value,
4055
+ noAction,
4056
+ category
4057
+ }) {
4058
+ const [active, setActive] = useState(false);
4059
+ const btnRef = useRef(null);
4060
+
4061
+ function handleClick() {
4062
+ const btn = btnRef.current;
4063
+ setActive(prevActive => !prevActive);
4064
+ btn.click();
4065
+ }
4066
+
4067
+ useEffect(() => {
4068
+ function callback(mutationRecords) {
4069
+ mutationRecords.forEach(mutationRecord => {
4070
+ const {
4071
+ classList
4072
+ } = mutationRecord.target;
4073
+ const {
4074
+ oldValue
4075
+ } = mutationRecord;
4076
+
4077
+ if (classList.contains('ql-active')) {
4078
+ setActive(true);
4079
+ }
4080
+
4081
+ if (!classList.contains('ql-active') && oldValue.includes('ql-active')) {
4082
+ setActive(false);
4083
+ }
4084
+ });
4085
+ }
4086
+
4087
+ if (btnRef.current && !noAction) {
4088
+ const observer = new MutationObserver(callback);
4089
+ observer.observe(btnRef.current, {
4090
+ attributes: true,
4091
+ attributeFilter: ['class'],
4092
+ attributeOldValue: true
4093
+ });
4094
+ }
4095
+ }, [btnRef, noAction]);
4096
+ return jsxs(Fragment, {
4097
+ children: [jsx("button", {
4098
+ ref: btnRef,
4099
+ type: "button",
4100
+ className: classNames({
4101
+ [`ql-${category || type}`]: !list
4102
+ }, {
4103
+ 'ql-list': list
4104
+ }, 'fwe-d-none', {
4105
+ [`action-${type}`]: !noAction
4106
+ }),
4107
+ "aria-hidden": "true",
4108
+ value: value
4109
+ }, void 0), jsxs("button", Object.assign({
4110
+ type: "button",
4111
+ className: classNames('fwe-btn', {
4112
+ 'fwe-btn-toolbar-list': list
4113
+ }, 'fr-button', className, {
4114
+ 'fwe-active': active && !noAction
4115
+ }),
4116
+ onClick: () => handleClick(),
4117
+ disabled: disabled
4118
+ }, {
4119
+ children: [label && jsx("div", Object.assign({
4120
+ className: `fr-button-text fwe-text-${type}`
4121
+ }, {
4122
+ children: label
4123
+ }), void 0), icon && jsx("i", {
4124
+ className: classNames('fwe-icon fwe-icon-toolbar-list', `fwe-icon-${icon}`, 'fwe-pr-0')
4125
+ }, void 0)]
4126
+ }), void 0)]
4127
+ }, void 0);
4128
+ }
4129
+
4130
+ const xss = require('xss');
4131
+
4132
+ const defaultConfig = {
4133
+ toolbar: {
4134
+ bold: true,
4135
+ italic: true,
4136
+ underline: true,
4137
+ alignCenter: true,
4138
+ alignRight: true,
4139
+ bulletList: true,
4140
+ orderedList: true,
4141
+ image: true,
4142
+ link: true
4143
+ }
4144
+ };
4145
+ function TextEditor({
4146
+ disabled = false,
4147
+ label,
4148
+ maxLength,
4149
+ value,
4150
+ hint,
4151
+ error,
4152
+ readOnly = false,
4153
+ onChange,
4154
+ className,
4155
+ config: configProps
4156
+ }) {
4157
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4158
+
4159
+ const editorRef = useRef(null);
4160
+ const [editor, setEditor] = useState(null);
4161
+ const [id] = useState((Math.random() * Date.now()).toString().replace('.', '-'));
4162
+ const [innerValue, setInnerValue] = useState(value);
4163
+ const config = {
4164
+ toolbar: Object.assign(Object.assign({}, defaultConfig.toolbar), configProps === null || configProps === void 0 ? void 0 : configProps.toolbar)
4165
+ };
4166
+ useEffect(() => {
4167
+ if (editorRef && editor === null) {
4168
+ const newEditor = new Quill(editorRef.current, {
4169
+ modules: {
4170
+ toolbar: `#editor-toolbar-${id}`
4171
+ },
4172
+ theme: 'snow',
4173
+ scrollingContainer: `#editor-container-${id}`
4174
+ });
4175
+ newEditor.root.setAttribute('role', 'textbox');
4176
+ newEditor.root.setAttribute('aria-labelledby', `editor-label-${id}`);
4177
+ newEditor.root.setAttribute('aria-multiline', 'true');
4178
+ newEditor.enable(!readOnly);
4179
+
4180
+ if (disabled) {
4181
+ newEditor.disable();
4182
+ } else if (!readOnly) {
4183
+ newEditor.enable();
4184
+ } // set up a matcher that does allow/disallow to paste images corresponding to config settings
4185
+
4186
+
4187
+ newEditor.clipboard.addMatcher('img', (_node, delta) => {
4188
+ // allowed, passthru delta
4189
+ if (config.toolbar.image === true) {
4190
+ return delta;
4191
+ } // not allowed, remove image by setting up a new delta
4192
+
4193
+
4194
+ const Delta = Quill.import('quill-delta');
4195
+ return new Delta().insert('');
4196
+ });
4197
+ setEditor(newEditor);
4198
+ }
4199
+ }, [editorRef, editor, disabled, readOnly, className, id, config.toolbar.image]);
4200
+ useEffect(() => {
4201
+ if (editor) {
4202
+ editor.on('text-change', () => {
4203
+ let html = editor.root.innerHTML;
4204
+
4205
+ if (html === '<p><br></p>' || html === '<div><br></div>' || html === undefined) {
4206
+ html = null;
4207
+ }
4208
+
4209
+ if (onChange) {
4210
+ onChange(html);
4211
+ }
4212
+
4213
+ setInnerValue(html);
4214
+ });
4215
+ }
4216
+ }, [editor, onChange]);
4217
+ useEffect(() => {
4218
+ if (editor) {
4219
+ const whiteList = Object.assign(Object.assign({}, xss.whiteList), {
4220
+ a: [...xss.whiteList.a, 'rel']
4221
+ });
4222
+ const sanitizedValue = xss(value, {
4223
+ whiteList
4224
+ });
4225
+ const content = editor.clipboard.convert(sanitizedValue);
4226
+ editor.setContents(content, 'silent');
4227
+ }
4228
+ }, [editor, value]);
4229
+
4230
+ function currentLength() {
4231
+ return (innerValue === null || innerValue === void 0 ? void 0 : innerValue.length) || 0;
4232
+ }
4233
+
4234
+ function hideDivider(name) {
4235
+ const linkOrImage = config.toolbar.image || config.toolbar.link;
4236
+ const lists = config.toolbar.bulletList || config.toolbar.orderedList;
4237
+ const typos = config.toolbar.bold || config.toolbar.italic || config.toolbar.underline;
4238
+ const textAlign = config.toolbar.alignCenter || config.toolbar.alignRight;
4239
+
4240
+ switch (name) {
4241
+ case 'typo':
4242
+ return !typos || !textAlign && !linkOrImage && !lists;
4243
+
4244
+ case 'text-align':
4245
+ return !textAlign || !linkOrImage && !lists;
4246
+
4247
+ case 'lists':
4248
+ return !lists || !linkOrImage;
4249
+
4250
+ case 'image':
4251
+ return !config.toolbar.image || !config.toolbar.link;
4252
+ }
4253
+
4254
+ return true;
4255
+ }
4256
+
4257
+ return jsxs("label", Object.assign({
4258
+ className: classNames('fwe-input-text', {
4259
+ disabled
4260
+ })
4261
+ }, {
4262
+ children: [jsxs("div", Object.assign({
4263
+ className: classNames('fwe-editor-toolbar', {
4264
+ [`fwe-editor-toolbar-${className}`]: className
4265
+ }),
4266
+ id: `editor-toolbar-${id}`
4267
+ }, {
4268
+ children: [jsx("span", Object.assign({
4269
+ className: "ql-formats fwe-d-none"
4270
+ }, {
4271
+ children: jsxs("select", Object.assign({
4272
+ className: "ql-size",
4273
+ "aria-hidden": "true"
4274
+ }, {
4275
+ children: [jsx("option", {
4276
+ value: "small",
4277
+ "aria-label": "small"
4278
+ }, void 0), jsx("option", {
4279
+ selected: true,
4280
+ "aria-label": "selected"
4281
+ }, void 0), jsx("option", {
4282
+ value: "large",
4283
+ "aria-label": "large"
4284
+ }, void 0), jsx("option", {
4285
+ value: "huge",
4286
+ "aria-label": "huge"
4287
+ }, void 0)]
4288
+ }), void 0)
4289
+ }), void 0), jsxs("span", Object.assign({
4290
+ className: "ql-formats fwe-mr-3"
4291
+ }, {
4292
+ children: [((_a = config === null || config === void 0 ? void 0 : config.toolbar) === null || _a === void 0 ? void 0 : _a.bold) && jsx(TextEditorButton, {
4293
+ disabled: disabled,
4294
+ type: "bold",
4295
+ className: "fwe-mr-3",
4296
+ label: "B"
4297
+ }, void 0), ((_b = config === null || config === void 0 ? void 0 : config.toolbar) === null || _b === void 0 ? void 0 : _b.italic) && jsx(TextEditorButton, {
4298
+ disabled: disabled,
4299
+ type: "italic",
4300
+ className: "fwe-mr-3",
4301
+ label: "I"
4302
+ }, void 0), ((_c = config === null || config === void 0 ? void 0 : config.toolbar) === null || _c === void 0 ? void 0 : _c.underline) && jsx(TextEditorButton, {
4303
+ disabled: disabled,
4304
+ type: "underline",
4305
+ label: "U"
4306
+ }, void 0), !hideDivider('typo') && jsx("div", {
4307
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
4308
+ }, void 0), ((_d = config === null || config === void 0 ? void 0 : config.toolbar) === null || _d === void 0 ? void 0 : _d.alignCenter) && jsx(TextEditorButton, {
4309
+ disabled: disabled,
4310
+ category: "align",
4311
+ type: "align-center",
4312
+ icon: classNames('text-align-center', {
4313
+ 'fwe-gray': disabled
4314
+ }),
4315
+ value: "center",
4316
+ className: classNames('fwe-btn-toolbar-list fwe-btn-toolbar-list-alignments', {
4317
+ 'fwe-mr-3': (_e = config === null || config === void 0 ? void 0 : config.toolbar) === null || _e === void 0 ? void 0 : _e.alignRight
4318
+ })
4319
+ }, void 0), ((_f = config === null || config === void 0 ? void 0 : config.toolbar) === null || _f === void 0 ? void 0 : _f.alignRight) && jsx(TextEditorButton, {
4320
+ disabled: disabled,
4321
+ category: "align",
4322
+ type: "align-right",
4323
+ icon: classNames('text-align-right', {
4324
+ 'fwe-gray': disabled
4325
+ }),
4326
+ value: "right",
4327
+ className: "fwe-btn-toolbar-list fwe-btn-toolbar-list-alignments"
4328
+ }, void 0), !hideDivider('text-align') && jsx("div", {
4329
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
4330
+ }, void 0), ((_g = config === null || config === void 0 ? void 0 : config.toolbar) === null || _g === void 0 ? void 0 : _g.bulletList) && jsx(TextEditorButton, {
4331
+ disabled: disabled,
4332
+ className: "fwe-mr-3",
4333
+ type: "ul",
4334
+ list: true,
4335
+ icon: "list-list-view",
4336
+ value: "bullet"
4337
+ }, void 0), ((_h = config === null || config === void 0 ? void 0 : config.toolbar) === null || _h === void 0 ? void 0 : _h.orderedList) && jsx(TextEditorButton, {
4338
+ disabled: disabled,
4339
+ type: "ol",
4340
+ list: true,
4341
+ icon: "enumeration",
4342
+ value: "ordered"
4343
+ }, void 0), ((_j = config === null || config === void 0 ? void 0 : config.toolbar) === null || _j === void 0 ? void 0 : _j.image) && jsxs(Fragment, {
4344
+ children: [jsx("div", {
4345
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
4346
+ }, void 0), jsx(TextEditorButton, {
4347
+ disabled: disabled,
4348
+ type: "image",
4349
+ icon: "image-image",
4350
+ noAction: true
4351
+ }, void 0)]
4352
+ }, void 0), ((_k = config === null || config === void 0 ? void 0 : config.toolbar) === null || _k === void 0 ? void 0 : _k.link) && jsxs(Fragment, {
4353
+ children: [jsx("div", {
4354
+ className: "fwe-divider-y fwe-d-inline-flex fwe-mx-4"
4355
+ }, void 0), jsx(TextEditorButton, {
4356
+ disabled: disabled,
4357
+ type: "link",
4358
+ icon: "file-link",
4359
+ noAction: true
4360
+ }, void 0)]
4361
+ }, void 0)]
4362
+ }), void 0)]
4363
+ }), void 0), jsx("div", Object.assign({
4364
+ className: classNames('fwe-editor-container', {
4365
+ 'fwe-editor-container--error': error
4366
+ }),
4367
+ id: `editor-container-${id}`
4368
+ }, {
4369
+ children: jsx("div", {
4370
+ className: "fwe-editor",
4371
+ ref: editorRef
4372
+ }, void 0)
4373
+ }), void 0), jsx("span", Object.assign({
4374
+ className: "fwe-input-text-label",
4375
+ id: `editor-label-${id}`
4376
+ }, {
4377
+ children: label
4378
+ }), void 0), error && jsx("span", Object.assign({
4379
+ className: "fwe-text-editor-invalid"
4380
+ }, {
4381
+ children: error
4382
+ }), void 0), hint && jsx("span", Object.assign({
4383
+ className: "fwe-text-editor-info"
4384
+ }, {
4385
+ children: hint
4386
+ }), void 0), maxLength && maxLength > 0 && value != null && jsx("span", Object.assign({
4387
+ className: "fwe-input-text-count"
4388
+ }, {
4389
+ children: `${currentLength()} / ${maxLength}`
4390
+ }), void 0)]
4391
+ }), void 0);
4392
+ }
4393
+
4394
+ function useOnClickOutside(ref, callback, ref2) {
4395
+ useEffect(() => {
4396
+ const listener = event => {
4397
+ // Do nothing if clicking ref's element or descendent elements
4398
+ if (!ref.current || ref.current.contains(event.target) || !ref2 || !ref2.current || ref2.current.contains(event.target)) {
4399
+ return;
4400
+ }
4401
+
4402
+ callback();
4403
+ };
4404
+
4405
+ document.addEventListener('mousedown', listener);
4406
+ document.addEventListener('touchstart', listener);
4407
+ return () => {
4408
+ document.removeEventListener('mousedown', listener);
4409
+ document.removeEventListener('touchstart', listener);
4410
+ };
4411
+ }, [ref, ref2, callback]);
4412
+ }
4413
+
4414
+ const TimePickerDropdown = /*#__PURE__*/forwardRef(({
4415
+ timeFormat,
4416
+ date,
4417
+ onDateChange,
4418
+ showSeconds,
4419
+ onClose,
4420
+ style
4421
+ }, ref) => {
4422
+ const innerRef = useRef(null);
4423
+ const combinedRef = useForkRef(ref, innerRef);
4424
+ const hoursRef = useRef(null);
4425
+ const [tmpHours, setTmpHours] = useState(null);
4426
+ const [tmpMinutes, setTmpMinutes] = useState(null);
4427
+ const [tmpSeconds, setTmpSeconds] = useState(null);
4428
+ const [innerDate, setInnerDate] = useState(date);
4429
+ const min = 0;
4430
+ const hourMax = timeFormat === '12' ? 12 : 23;
4431
+ const minutesSecondsMax = 59;
4432
+ useEffect(() => {
4433
+ requestAnimationFrame(() => {
4434
+ hoursRef.current.focus();
4435
+ });
4436
+ }, []);
4437
+
4438
+ function handleKeyPress(e) {
4439
+ if (e.key === 'Escape' || e.key === 'Enter') {
4440
+ onClose(e.key === 'Enter' ? innerDate : undefined);
4441
+ }
4442
+ }
4443
+
4444
+ function handleHourUp() {
4445
+ const newDate = new Date(innerDate);
4446
+ newDate.setHours(innerDate.getHours() + 1);
4447
+ setInnerDate(newDate);
4448
+ onDateChange(newDate);
4449
+ setTmpHours(null);
4450
+ }
4451
+
4452
+ function handleHourDown() {
4453
+ const newDate = new Date(innerDate);
4454
+ newDate.setHours(innerDate.getHours() - 1);
4455
+ setInnerDate(newDate);
4456
+ onDateChange(newDate);
4457
+ setTmpHours(null);
4458
+ }
4459
+
4460
+ function handleHourChange(e) {
4461
+ const newDate = new Date(innerDate);
4462
+ const hour = +e.target.value;
4463
+ newDate.setHours(hour > hourMax ? hourMax : hour < min ? min : hour);
4464
+ setInnerDate(newDate);
4465
+ setTmpHours(e.target.value);
4466
+ }
4467
+
4468
+ function handleMinuteUp() {
4469
+ const newDate = new Date(innerDate);
4470
+ newDate.setMinutes(innerDate.getMinutes() + 1);
4471
+ setInnerDate(newDate);
4472
+ onDateChange(newDate);
4473
+ setTmpMinutes(null);
4474
+ }
4475
+
4476
+ function handleMinuteDown() {
4477
+ const newDate = new Date(innerDate);
4478
+ newDate.setMinutes(innerDate.getMinutes() - 1);
4479
+ setInnerDate(newDate);
4480
+ onDateChange(newDate);
4481
+ setTmpMinutes(null);
4482
+ }
4483
+
4484
+ function handleMinuteChange(e) {
4485
+ const newDate = new Date(innerDate);
4486
+ const minute = +e.target.value;
4487
+ newDate.setMinutes(minute > minutesSecondsMax ? minutesSecondsMax : minute < min ? min : minute);
4488
+ setInnerDate(newDate);
4489
+ setTmpMinutes(e.target.value);
4490
+ }
4491
+
4492
+ function handleSecondUp() {
4493
+ const newDate = new Date(innerDate);
4494
+ newDate.setSeconds(innerDate.getSeconds() + 1);
4495
+ setInnerDate(newDate);
4496
+ onDateChange(newDate);
4497
+ setTmpSeconds(null);
4498
+ }
4499
+
4500
+ function handleSecondDown() {
4501
+ const newDate = new Date(innerDate);
4502
+ newDate.setSeconds(innerDate.getSeconds() - 1);
4503
+ setInnerDate(newDate);
4504
+ onDateChange(newDate);
4505
+ setTmpSeconds(null);
4506
+ }
4507
+
4508
+ function handleSecondChange(e) {
4509
+ const newDate = new Date(innerDate);
4510
+ const seconds = +e.target.value;
4511
+ newDate.setSeconds(seconds > minutesSecondsMax ? minutesSecondsMax : seconds < min ? min : seconds);
4512
+ setInnerDate(newDate);
4513
+ setTmpSeconds(e.target.value);
4514
+ }
4515
+
4516
+ const hours = timeFormat === '12' ? (innerDate.getHours() + 11) % 12 + 1 : innerDate.getHours();
4517
+ return jsxs("div", Object.assign({
4518
+ style: style,
4519
+ ref: combinedRef,
4520
+ className: classNames('fr-timepicker fwe-timepicker', {
4521
+ 'fwe-timepicker-am-pm': timeFormat === '12'
4522
+ }),
4523
+ onKeyDown: e => handleKeyPress(e),
4524
+ tabIndex: -1
4525
+ }, {
4526
+ children: [jsxs("div", Object.assign({
4527
+ className: "fwe-timepicker-spinners"
4528
+ }, {
4529
+ children: [jsxs("div", Object.assign({
4530
+ className: "fwe-timepicker-spinners-hours"
4531
+ }, {
4532
+ children: [jsx("button", Object.assign({
4533
+ type: "button",
4534
+ "aria-label": "hour up",
4535
+ className: "fwe-btn fwe-btn-link fwe-dark",
4536
+ onClick: () => handleHourUp()
4537
+ }, {
4538
+ children: jsx("i", {
4539
+ "aria-hidden": true,
4540
+ className: "fwe-icon fwe-icon-arrows-expand"
4541
+ }, void 0)
4542
+ }), void 0), jsx("input", {
4543
+ "aria-label": "hours value",
4544
+ className: "fwe-timepicker-hide-spinners",
4545
+ type: "number",
4546
+ min: min,
4547
+ step: 1,
4548
+ value: tmpHours !== null && tmpHours !== void 0 ? tmpHours : (hours < 10 ? '0' : '') + hours,
4549
+ max: hourMax,
4550
+ onInput: handleHourChange,
4551
+ ref: hoursRef
4552
+ }, void 0), jsx("button", Object.assign({
4553
+ type: "button",
4554
+ "aria-label": "hour down",
4555
+ className: "fwe-btn fwe-btn-link fwe-dark",
4556
+ onClick: () => handleHourDown()
4557
+ }, {
4558
+ children: jsx("i", {
4559
+ "aria-hidden": true,
4560
+ className: "fwe-icon fwe-icon-arrows-collapse"
4561
+ }, void 0)
4562
+ }), void 0)]
4563
+ }), void 0), jsxs("div", Object.assign({
4564
+ className: "fwe-timepicker-spinners-minutes"
4565
+ }, {
4566
+ children: [jsx("button", Object.assign({
4567
+ type: "button",
4568
+ "aria-label": "minute up",
4569
+ className: "fwe-btn fwe-btn-link fwe-dark",
4570
+ onClick: () => handleMinuteUp()
4571
+ }, {
4572
+ children: jsx("i", {
4573
+ "aria-hidden": true,
4574
+ className: "fwe-icon fwe-icon-arrows-expand"
4575
+ }, void 0)
4576
+ }), void 0), jsx("input", {
4577
+ "aria-label": "minutes value",
4578
+ className: "fwe-timepicker-hide-spinners",
4579
+ type: "number",
4580
+ min: min,
4581
+ step: 1,
4582
+ value: tmpMinutes !== null && tmpMinutes !== void 0 ? tmpMinutes : (innerDate.getMinutes() < 10 ? '0' : '') + innerDate.getMinutes(),
4583
+ max: minutesSecondsMax,
4584
+ onInput: handleMinuteChange
4585
+ }, void 0), jsx("button", Object.assign({
4586
+ type: "button",
4587
+ "aria-label": "minute down",
4588
+ className: "fwe-btn fwe-btn-link fwe-dark",
4589
+ onClick: () => handleMinuteDown()
4590
+ }, {
4591
+ children: jsx("i", {
4592
+ "aria-hidden": true,
4593
+ className: "fwe-icon fwe-icon-arrows-collapse"
4594
+ }, void 0)
4595
+ }), void 0)]
4596
+ }), void 0), showSeconds && jsxs("div", Object.assign({
4597
+ className: "fwe-timepicker-spinners-seconds"
4598
+ }, {
4599
+ children: [jsx("button", Object.assign({
4600
+ type: "button",
4601
+ "aria-label": "seconds up",
4602
+ className: "fwe-btn fwe-btn-link fwe-dark",
4603
+ onClick: () => handleSecondUp()
4604
+ }, {
4605
+ children: jsx("i", {
4606
+ "aria-hidden": true,
4607
+ className: "fwe-icon fwe-icon-arrows-expand"
4608
+ }, void 0)
4609
+ }), void 0), jsx("input", {
4610
+ "aria-label": "seconds value",
4611
+ className: "fwe-timepicker-hide-spinners",
4612
+ type: "number",
4613
+ min: min,
4614
+ step: 1,
4615
+ value: tmpSeconds !== null && tmpSeconds !== void 0 ? tmpSeconds : (innerDate.getSeconds() < 10 ? '0' : '') + innerDate.getSeconds(),
4616
+ max: minutesSecondsMax,
4617
+ onInput: handleSecondChange
4618
+ }, void 0), jsx("button", Object.assign({
4619
+ type: "button",
4620
+ "aria-label": "minute down",
4621
+ className: "fwe-btn fwe-btn-link fwe-dark",
4622
+ onClick: () => handleSecondDown()
4623
+ }, {
4624
+ children: jsx("i", {
4625
+ "aria-hidden": true,
4626
+ className: "fwe-icon fwe-icon-arrows-collapse"
4627
+ }, void 0)
4628
+ }), void 0)]
4629
+ }), void 0)]
4630
+ }), void 0), timeFormat === '12' && jsx("span", Object.assign({
4631
+ className: "fwe-badge fwe-badge-control"
4632
+ }, {
4633
+ children: innerDate.getHours() >= 12 ? 'PM' : 'AM'
4634
+ }), void 0)]
4635
+ }), void 0);
4636
+ });
4637
+
4638
+ const TimePicker = /*#__PURE__*/forwardRef((_a, ref) => {
4639
+ var _b, _c, _d;
4640
+
4641
+ var {
4642
+ error,
4643
+ hint,
4644
+ required,
4645
+ disabled,
4646
+ children,
4647
+ value,
4648
+ options,
4649
+ defaultValue,
4650
+ formatDate,
4651
+ onChange
4652
+ } = _a,
4653
+ props = __rest(_a, ["error", "hint", "required", "disabled", "children", "value", "options", "defaultValue", "formatDate", "onChange"]);
4654
+
4655
+ const innerFormatDate = formatDate !== null && formatDate !== void 0 ? formatDate : Intl.DateTimeFormat('default', Object.assign({
4656
+ hour: 'numeric',
4657
+ minute: 'numeric'
4658
+ }, (options === null || options === void 0 ? void 0 : options.showSeconds) && {
4659
+ second: 'numeric'
4660
+ })).format;
4661
+ const timeFormat = (_b = options === null || options === void 0 ? void 0 : options.timeFormat) !== null && _b !== void 0 ? _b : '24';
4662
+ const [referenceElement, setReferenceElement] = useState(null);
4663
+ const [popperElement, setPopperElement] = useState(null);
4664
+ const customModifier = useMemo(() => ({
4665
+ name: 'offset',
4666
+ options: {
4667
+ offset: ({
4668
+ placement
4669
+ }) => {
4670
+ if (placement === 'bottom') {
4671
+ return [0, -12];
4672
+ } else {
4673
+ return [0, 0];
4674
+ }
4675
+ }
4676
+ }
4677
+ }), []);
4678
+ const {
4679
+ styles,
4680
+ attributes
4681
+ } = usePopper(referenceElement, popperElement, {
4682
+ modifiers: [customModifier]
4683
+ });
4684
+ const combinedRef = useForkRef(ref, setReferenceElement);
4685
+ const labelRef = useRef(null);
4686
+ const allRefs = useForkRef(combinedRef, labelRef);
4687
+ const timePickerRef = useRef(null);
4688
+ const combinedTimePickerRef = useForkRef(timePickerRef, setPopperElement);
4689
+ const [open, setOpen] = useState(false);
4690
+ const closeDropdown = useCallback(() => {
4691
+ setOpen(false);
4692
+ }, []);
4693
+ useOnClickOutside(labelRef, closeDropdown, timePickerRef);
4694
+ const controlled = value !== undefined;
4695
+ const initialValue = controlled ? value : defaultValue;
4696
+ const [innerValue, setInnerValue] = useState(initialValue !== null && initialValue !== void 0 ? initialValue : new Date());
4697
+ useEffect(() => {
4698
+ if (value !== undefined) {
4699
+ setInnerValue(value);
4700
+ }
4701
+ }, [value]);
4702
+
4703
+ function toggle(e) {
4704
+ e.preventDefault();
4705
+
4706
+ if (!disabled) {
4707
+ setOpen(prevOpen => !prevOpen);
4708
+ }
4709
+ }
4710
+
4711
+ function handleDateChange(newDate) {
4712
+ if (!controlled) {
4713
+ setInnerValue(newDate);
4714
+ }
4715
+
4716
+ if (onChange) {
4717
+ onChange(newDate);
4718
+ }
4719
+ }
4720
+
4721
+ function handleClose(newDate) {
4722
+ if (newDate) {
4723
+ handleDateChange(newDate);
4724
+ }
4725
+
4726
+ setOpen(false);
4727
+ }
4728
+
4729
+ const container = ((_c = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _c === void 0 ? void 0 : _c.ownerDocument) || document;
4730
+ return jsxs(Fragment, {
4731
+ children: [jsxs("label", Object.assign({
4732
+ ref: allRefs,
4733
+ className: "fr-time-picker fwe-input-text fwe-input-text-icon",
4734
+ onClick: toggle
4735
+ }, props, {
4736
+ children: [jsx("i", {
4737
+ className: classNames('fwe-icon fwe-icon-time-time', {
4738
+ 'fwe-color-hero': open,
4739
+ 'fwe-color-control-disabled': disabled
4740
+ })
4741
+ }, void 0), jsx("input", {
4742
+ "aria-label": "picked time",
4743
+ type: "text",
4744
+ readOnly: true,
4745
+ required: required,
4746
+ className: classNames({
4747
+ 'fwe-border-hero': open
4748
+ }),
4749
+ value: innerFormatDate(innerValue),
4750
+ disabled: disabled
4751
+ }, void 0), jsx("span", Object.assign({
4752
+ className: "fwe-input-text-label"
4753
+ }, {
4754
+ children: children
4755
+ }), void 0), hint && jsx("span", Object.assign({
4756
+ className: "fwe-input-text-info"
4757
+ }, {
4758
+ children: hint
4759
+ }), void 0), error && jsx("span", Object.assign({
4760
+ className: "fwe-input-text-invalid"
4761
+ }, {
4762
+ children: error
4763
+ }), void 0)]
4764
+ }), void 0), open && /*#__PURE__*/ReactDOM.createPortal(jsx(TimePickerDropdown, Object.assign({
4765
+ ref: combinedTimePickerRef,
4766
+ onClose: handleClose,
4767
+ onDateChange: handleDateChange,
4768
+ timeFormat: timeFormat,
4769
+ showSeconds: options === null || options === void 0 ? void 0 : options.showSeconds,
4770
+ date: innerValue,
4771
+ style: Object.assign(Object.assign({}, styles.popper), {
4772
+ minWidth: (_d = labelRef === null || labelRef === void 0 ? void 0 : labelRef.current) === null || _d === void 0 ? void 0 : _d.scrollWidth
4773
+ })
4774
+ }, attributes.popper), void 0), container.body)]
4775
+ }, void 0);
4776
+ });
4777
+
4778
+ export { Accordion, AccordionHeader, AccordionItem, AccordionItemBody, AccordionItemHeader, AlertModal, Breadcrumb, Button, Card, CardBody, CardHeader, CardNotification, Checkbox, Chip, ChipContainer, ChipType, ColorIndicator, ColorPicker, ConfirmModal, DatePicker, DateRangePicker, LinkButton, LoadingIndicator, Pagination, Popover, PopoverMenu, Progress, Prompt, RadioButton, RadioButton as RadioGroup, Segment, SegmentControl, Select, Slider, Snackbar, SnackbarProvider, StepHorizontal, StepVertical, StepperHorizontal, StepperVertical, Switch, TabPane, TableHeaderCell, Tabs, TextArea, TextEditor, TextInput, TimePicker, Tooltip, useSnackbar };