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