@trackunit/react-components 0.1.65 → 0.1.67

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/index.cjs ADDED
@@ -0,0 +1,3334 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var tailwindStyledComponents = require('@trackunit/tailwind-styled-components');
7
+ var React = require('react');
8
+ var uiIcons = require('@trackunit/ui-icons');
9
+ var reactUse = require('react-use');
10
+ var dateFns = require('date-fns');
11
+ var react = require('@floating-ui/react');
12
+ var reactDayPicker = require('react-day-picker');
13
+ var locale = require('date-fns/locale');
14
+ var reactBrowserHooks = require('react-browser-hooks');
15
+ var usePortal = require('react-useportal');
16
+ var ReactSelect = require('react-select');
17
+ var ReactAsyncCreatableSelect = require('react-select/async-creatable');
18
+ var ReactCreatableSelect = require('react-select/creatable');
19
+ var ReactAsyncSelect = require('react-select/async');
20
+ var libphonenumberJs = require('libphonenumber-js');
21
+ var reactRouterDom = require('react-router-dom');
22
+ var reactHelmetAsync = require('react-helmet-async');
23
+ var uiDesignTokens = require('@trackunit/ui-design-tokens');
24
+
25
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
+
27
+ function _interopNamespace(e) {
28
+ if (e && e.__esModule) return e;
29
+ var n = Object.create(null);
30
+ if (e) {
31
+ Object.keys(e).forEach(function (k) {
32
+ if (k !== 'default') {
33
+ var d = Object.getOwnPropertyDescriptor(e, k);
34
+ Object.defineProperty(n, k, d.get ? d : {
35
+ enumerable: true,
36
+ get: function () { return e[k]; }
37
+ });
38
+ }
39
+ });
40
+ }
41
+ n["default"] = e;
42
+ return Object.freeze(n);
43
+ }
44
+
45
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
46
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
47
+ var usePortal__default = /*#__PURE__*/_interopDefaultLegacy(usePortal);
48
+ var ReactSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactSelect);
49
+ var ReactAsyncCreatableSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactAsyncCreatableSelect);
50
+ var ReactCreatableSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactCreatableSelect);
51
+ var ReactAsyncSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactAsyncSelect);
52
+
53
+ const docs = {
54
+ source: {
55
+ type: "dynamic",
56
+ excludeDecorators: true,
57
+ },
58
+ };
59
+
60
+ /**
61
+ * Utility for common props on containers.
62
+ *
63
+ * @param {UseContainerProps} ContainerProps - Props for the utility
64
+ * @param {string} ContainerProps.className - Optional custom className
65
+ * @param {string} ContainerProps.dataTestId - Optional custom data-TestId
66
+ * @returns {UseContainerProps} - Object with undefined values removed
67
+ */
68
+ const useContainerProps = ({ className, dataTestId }) => {
69
+ const containerProps = { className, "data-testid": dataTestId };
70
+ if (containerProps["data-testid"] === undefined) {
71
+ delete containerProps["data-testid"];
72
+ }
73
+ if (containerProps.className === undefined) {
74
+ delete containerProps.className;
75
+ }
76
+ return containerProps;
77
+ };
78
+
79
+ /******************************************************************************
80
+ Copyright (c) Microsoft Corporation.
81
+
82
+ Permission to use, copy, modify, and/or distribute this software for any
83
+ purpose with or without fee is hereby granted.
84
+
85
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
86
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
87
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
88
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
89
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
90
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
91
+ PERFORMANCE OF THIS SOFTWARE.
92
+ ***************************************************************************** */
93
+
94
+ function __rest(s, e) {
95
+ var t = {};
96
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
97
+ t[p] = s[p];
98
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
99
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
100
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
101
+ t[p[i]] = s[p[i]];
102
+ }
103
+ return t;
104
+ }
105
+
106
+ function __awaiter(thisArg, _arguments, P, generator) {
107
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
108
+ return new (P || (P = Promise))(function (resolve, reject) {
109
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
110
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
111
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
112
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
113
+ });
114
+ }
115
+
116
+ /**
117
+ * The spinner component provides visual feedback that data is being processed.
118
+ *
119
+ * Spinners are used when performing actions. They notify to the user that their request is being processed. Although they do not provide details about what is occurring on the back-end, they reassure the user that their action is being processed.
120
+ *
121
+ * Common actions that benefit from spinners include any create, update, or delete actions that may have a lot of data to process. It can be used in a table, after a primary or secondary button click, or even in a modal.
122
+ *
123
+ * Use a spinner component for any action that cannot be performed instantly and will only require a short time (between 1 to 5 seconds) to process.
124
+ *
125
+ * Use when retrieving or refreshing small data amounts, such as status.
126
+ *
127
+ * @param {SpinnerProps} props - The props for the Spinner component
128
+ * @returns {JSX.Element} Spinner component
129
+ */
130
+ const Spinner = ({ mode = "light", size = "medium", centering = "centered", className, containerClassName, dataTestId, }) => {
131
+ return (jsxRuntime.jsx(Container$a, Object.assign({ "$mode": mode, "$centering": centering, className: containerClassName }, { children: jsxRuntime.jsx(StyledSpinner$1, { "$size": size, "$mode": mode, role: "spinbutton", className: className, "data-testid": dataTestId }) })));
132
+ };
133
+ const getSpinnerStyles = () => ({ $size }) => {
134
+ switch ($size) {
135
+ case "small":
136
+ return tailwindStyledComponents.tws `tu-spinner--small`;
137
+ case "large":
138
+ return tailwindStyledComponents.tws `tu-spinner--large`;
139
+ case "medium":
140
+ default:
141
+ return;
142
+ }
143
+ };
144
+ const getCenteringStyles = () => ({ $centering }) => {
145
+ switch ($centering) {
146
+ case "centered":
147
+ return tailwindStyledComponents.tws `tu-spinner--container-centered`;
148
+ case "horizontally":
149
+ return tailwindStyledComponents.tws `tu-spinner--container-centered-horizontally`;
150
+ case "vertically":
151
+ return tailwindStyledComponents.tws `tu-spinner--container-centered-vertically`;
152
+ default:
153
+ return;
154
+ }
155
+ };
156
+ const StyledSpinner$1 = tailwindStyledComponents.tw.span `
157
+ tu-spinner
158
+ ${p => (p.$mode === "dark" ? tailwindStyledComponents.tws `tu-spinner--dark` : null)}
159
+ ${getSpinnerStyles()}
160
+ `;
161
+ const Container$a = tailwindStyledComponents.tw.div `
162
+ tu-spinner--container
163
+ ${getCenteringStyles()}
164
+
165
+ `;
166
+
167
+ /**
168
+ * Helper to get the needed classname from buttonProps.
169
+ *
170
+ * @returns {string} - Classnames for the button
171
+ */
172
+ const getStyles = () => ({ $color, $variant }) => {
173
+ const styles = {
174
+ filled: {
175
+ primary: tailwindStyledComponents.tws `tu-button--primary`,
176
+ secondary: tailwindStyledComponents.tws `tu-button--secondary`,
177
+ danger: tailwindStyledComponents.tws `tu-button--danger`,
178
+ tertiary: tailwindStyledComponents.tws `tu-button--tertiary`,
179
+ warning: tailwindStyledComponents.tws `tu-button--warning`,
180
+ },
181
+ transparent: {
182
+ primary: tailwindStyledComponents.tws `tu-button--transparent-primary`,
183
+ secondary: tailwindStyledComponents.tws `tu-button--transparent-secondary`,
184
+ danger: tailwindStyledComponents.tws `tu-button--transparent-danger`,
185
+ tertiary: tailwindStyledComponents.tws `tu-button--transparent-tertiary`,
186
+ warning: tailwindStyledComponents.tws `tu-button--transparent-warning`,
187
+ },
188
+ };
189
+ return styles[$variant][$color];
190
+ };
191
+ /**
192
+ * Helper to get the needed classname for padding.
193
+ *
194
+ * @returns {string} - The correct class for setting padding.
195
+ */
196
+ const getPadding = () => ({ $size }) => {
197
+ switch ($size) {
198
+ case "small":
199
+ return tailwindStyledComponents.tws `tu-button--small`;
200
+ case "large":
201
+ return tailwindStyledComponents.tws `tu-button--large`;
202
+ default:
203
+ return "";
204
+ }
205
+ };
206
+
207
+ /**
208
+ * Buttons allow users to perform an action when triggered.
209
+ *
210
+ * @param {ButtonProps} props - The props for the Button component
211
+ * @returns {JSX.Element} Button component
212
+ */
213
+ const Button = React__namespace.forwardRef((_a, ref) => {
214
+ var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, color = "primary", variant = "filled", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, renderAs = "button" } = _a, rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "color", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
215
+ return (jsxRuntime.jsxs(StyledButton$1, Object.assign({ "$as": renderAs, onClick: onClick, disabled: disabled || loading, type: type, className: className, "$color": color, "$fullWidth": fullWidth, "$variant": variant, "$size": size, "$square": square, title: title, "aria-label": title, role: role, tabIndex: tabIndex, "data-testid": dataTestId, ref: ref }, rest, { children: [loading && jsxRuntime.jsx(StyledSpinner, { centering: "vertically" }), prefix, children, suffix] })));
216
+ });
217
+ const StyledButton$1 = tailwindStyledComponents.tw.button `
218
+ tu-button
219
+ ${p => p.$square && tailwindStyledComponents.tws `tu-button--square`}
220
+ ${p => p.$fullWidth && tailwindStyledComponents.tws `tu-button--full-width`}
221
+ ${p => p.disabled &&
222
+ p.$as !== "button" &&
223
+ (p.$variant === "transparent" ? tailwindStyledComponents.tws `tu-button__disabled--transparent` : tailwindStyledComponents.tws `tu-button__disabled`)}
224
+ ${getStyles()}
225
+ ${getPadding()}
226
+ `;
227
+ const StyledSpinner = tailwindStyledComponents.twx(Spinner) `
228
+ tu-button__spinner
229
+ `;
230
+
231
+ const IconButton = React__namespace.forwardRef((_a, ref) => {
232
+ var { icon, size = "small", square = true, circular, loading, disabled } = _a, rest = __rest(_a, ["icon", "size", "square", "circular", "loading", "disabled"]);
233
+ return (jsxRuntime.jsx(StyledButton, Object.assign({ size: size, square: square, "$circular": circular, disabled: disabled || loading, ref: ref }, rest, { children: jsxRuntime.jsx(IconContainer$2, { children: loading ? jsxRuntime.jsx(Spinner, { size: size }) : icon }) })));
234
+ });
235
+ const StyledButton = tailwindStyledComponents.twx(Button) `
236
+ ${p => (p.$circular ? tailwindStyledComponents.tws `tu-button--rounded` : null)}
237
+ `;
238
+ const IconContainer$2 = tailwindStyledComponents.tw.div `
239
+ tu-button__container
240
+ ${p => (p.$size === "small" ? tailwindStyledComponents.tws `tu-button__container--small` : null)}
241
+ `;
242
+
243
+ const IconSizeClassMap = {
244
+ small: tailwindStyledComponents.tws `tu-icon--small`,
245
+ medium: tailwindStyledComponents.tws `tu-icon--medium`,
246
+ large: tailwindStyledComponents.tws `tu-icon--large`, // 24x24px
247
+ };
248
+ /**
249
+ * - The Icon component is used to display an Icon.
250
+ * - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
251
+ * - All the [HeroIcons](https://heroicons.dev/) as well as custom TrackUnit icons are available.
252
+ *
253
+ * @param {IconProps} props - The props for the Icon component
254
+ * @returns {JSX.Element} Icon component
255
+ */
256
+ const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
257
+ const iconSizeClassName = React__namespace.useMemo(() => IconSizeClassMap[size], [size]);
258
+ const correctIconType = React__namespace.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
259
+ const colorClassNames = React__namespace.useMemo(() => (correctIconType === "solid" ? tailwindStyledComponents.tws `fill-current stroke-transparent` : tailwindStyledComponents.tws `fill-transparent stroke-current`), [correctIconType]);
260
+ let IconComponent = null;
261
+ if (uiIcons.HeroIconsArray.find(icon => icon === name)) {
262
+ IconComponent = uiIcons.heroIconLookup(name, correctIconType);
263
+ }
264
+ else if (uiIcons.TrackunitSolidIconsArray.find(icon => icon === name) ||
265
+ uiIcons.TrackunitOutlineIconsArray.find(icon => icon === name)) {
266
+ IconComponent = uiIcons.trackunitIconLookup(name, correctIconType);
267
+ }
268
+ if (!IconComponent) {
269
+ return null;
270
+ }
271
+ return (jsxRuntime.jsx(React__namespace.Suspense, Object.assign({ fallback: jsxRuntime.jsx(LoadingDot, { className: iconSizeClassName }) }, { children: jsxRuntime.jsx(Root$9, Object.assign({ "$color": color, onClick: onClick, "data-testid": dataTestId, ref: forwardedRef }, { children: jsxRuntime.jsx(IconComponent, { "data-testid": dataTestId ? `${dataTestId}-${name}` : name, className: `${iconSizeClassName} ${colorClassNames} ${className !== null && className !== void 0 ? className : ""} ${name} aspect-square`, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style) }) })) })));
272
+ };
273
+ const LoadingDot = tailwindStyledComponents.tw.span `
274
+ tu-loading-dot
275
+ `;
276
+ const Root$9 = tailwindStyledComponents.tw.span `
277
+ tu-icon
278
+ ${({ $color }) => {
279
+ switch ($color) {
280
+ case "primary":
281
+ return tailwindStyledComponents.tws `tu-icon--primary`;
282
+ case "secondary":
283
+ return tailwindStyledComponents.tws `tu-icon--secondary`;
284
+ case "accent":
285
+ return tailwindStyledComponents.tws `tu-icon--accent`;
286
+ case "neutral":
287
+ return tailwindStyledComponents.tws `tu-icon--neutral`;
288
+ case "info":
289
+ return tailwindStyledComponents.tws `tu-icon--info`;
290
+ case "success":
291
+ return tailwindStyledComponents.tws `tu-icon--success`;
292
+ case "warning":
293
+ return tailwindStyledComponents.tws `tu-icon--warning`;
294
+ case "danger":
295
+ return tailwindStyledComponents.tws `tu-icon--danger`;
296
+ case "good":
297
+ return tailwindStyledComponents.tws `tu-icon--good`;
298
+ case "low":
299
+ return tailwindStyledComponents.tws `tu-icon--low`;
300
+ case "critical":
301
+ return tailwindStyledComponents.tws `tu-icon--critical`;
302
+ case "working":
303
+ return tailwindStyledComponents.tws `tu-icon--working`;
304
+ case "idle":
305
+ return tailwindStyledComponents.tws `tu-icon--idle`;
306
+ case "stopped":
307
+ return tailwindStyledComponents.tws `tu-icon--stopped`;
308
+ case "moving":
309
+ return tailwindStyledComponents.tws `tu-icon--moving`;
310
+ case "unknown":
311
+ return tailwindStyledComponents.tws `tu-icon--unknown`;
312
+ case "white":
313
+ return tailwindStyledComponents.tws `text-white`;
314
+ default:
315
+ return "tu-icon--default";
316
+ }
317
+ }}
318
+ `;
319
+
320
+ /**
321
+ * The ActionButton component is a wrapper over IconButton to perform an action when the onClick event is triggered.
322
+ *
323
+ * @param {ActionButtonProps} props - The props for the ActionButton component
324
+ * @returns {JSX.Element} ActionButton component
325
+ */
326
+ const ActionButton = ({ type, value, dataTestId, iconSize, disabled }) => {
327
+ const getIconName = () => {
328
+ switch (type) {
329
+ case "PHONE_NUMBER":
330
+ return "PhoneArrowUpRightIcon";
331
+ case "WEB_ADDRESS":
332
+ return "ArrowTopRightOnSquareIcon";
333
+ case "EMAIL":
334
+ default:
335
+ return "EnvelopeIcon";
336
+ }
337
+ };
338
+ const ButtonAction = () => {
339
+ switch (type) {
340
+ case "EMAIL":
341
+ return window.open(`mailto:${value}`);
342
+ case "WEB_ADDRESS":
343
+ if (value) {
344
+ return window.open(value, "_blank", "noopener,noreferrer");
345
+ }
346
+ return null;
347
+ case "PHONE_NUMBER":
348
+ default:
349
+ return window.open(`tel:${value}`);
350
+ }
351
+ };
352
+ return (jsxRuntime.jsx(ActionContainer, { children: jsxRuntime.jsx(StyledIconButton, { "$fieldSize": iconSize, disabled: disabled, dataTestId: dataTestId || "testIconButtonId", size: "small", color: "tertiary", icon: jsxRuntime.jsx(Icon, { size: "small", name: getIconName() }), onClick: ButtonAction }) }));
353
+ };
354
+ const ActionContainer = tailwindStyledComponents.tw.div `
355
+ tu-action-container
356
+ `;
357
+ const StyledIconButton = tailwindStyledComponents.twx(IconButton) `
358
+ tu-action-button
359
+ ${({ $fieldSize }) => $fieldSize === "small" && tailwindStyledComponents.tws `tu-action-button--small`}
360
+ `;
361
+
362
+ /**
363
+ * The StarButton component is used for favorite actions or similar.
364
+ *
365
+ * @param {StarButtonProps} props - The props for the StarButton component
366
+ * @returns {JSX.Element} StarButton component
367
+ */
368
+ const StarButton = ({ starred, onClick }) => {
369
+ return (jsxRuntime.jsx(Flex$2, Object.assign({ onClick: onClick, "data-test-id": "starred-filter" }, { children: jsxRuntime.jsx(CustomIcon, { name: "StarIcon", "$starred": starred }) })));
370
+ };
371
+ const Flex$2 = tailwindStyledComponents.tw.div `
372
+ flex
373
+ items-center
374
+ `;
375
+ const CustomIcon = tailwindStyledComponents.twx(Icon) `
376
+ cursor-pointer
377
+ w-5
378
+ h-5
379
+ hover:!fill-primary-400
380
+ hover:!stroke-transparent
381
+ ${p => (p.$starred ? tailwindStyledComponents.tws `!fill-primary-600 !stroke-transparent` : tailwindStyledComponents.tws `!fill-transparent !stroke-neutral-800`)}
382
+ `;
383
+
384
+ /**
385
+ * The Text component is used to apply Trackunit default typography styles to text.
386
+ *
387
+ * ### When to use
388
+ *
389
+ * Use Text when you want to show a text section, use Heading if you want to show a heading.
390
+ *
391
+ * @param {TextProps} props - The props for the Text component
392
+ * @returns {JSX.Element} Text component
393
+ */
394
+ const Text$1 = ({ children, type = "p", size = "medium", align = "left", weight = "normal", underline = false, inverted = false, subtle = false, italicize = false, uppercase = false, className, dataTestId, }) => {
395
+ return (jsxRuntime.jsx(StyledText$3, Object.assign({ "$as": type, className: className, "$align": align, "$inverted": inverted, "$subtle": subtle, "$italicize": italicize, "$uppercase": uppercase, "$size": size, "$weight": weight, "$underline": underline, "data-testid": dataTestId }, { children: children })));
396
+ };
397
+ const getTextSize = () => ({ $size }) => {
398
+ const sizes = {
399
+ small: tailwindStyledComponents.tws `tu-text--small`,
400
+ large: tailwindStyledComponents.tws `tu-text--large`,
401
+ default: null,
402
+ };
403
+ return sizes[$size];
404
+ };
405
+ const getTextWeight = () => ({ $weight }) => {
406
+ const weights = {
407
+ thick: tailwindStyledComponents.tws `tu-text--medium`,
408
+ bold: tailwindStyledComponents.tws `tu-text--semibold`,
409
+ default: null,
410
+ };
411
+ return weights[$weight];
412
+ };
413
+ const getFontColor$1 = () => ({ $inverted, $subtle }) => {
414
+ const subtle = $inverted ? tailwindStyledComponents.tws `tu-text--subtle-inverted` : tailwindStyledComponents.tws `tu-text--subtle`;
415
+ const inverted = $inverted ? tailwindStyledComponents.tws `tu-text--inverted` : null;
416
+ return $subtle ? subtle : inverted;
417
+ };
418
+ const getTextAlignment = () => ({ $align }) => {
419
+ const alignments = {
420
+ left: tailwindStyledComponents.tws `tu-text--align-left`,
421
+ center: tailwindStyledComponents.tws `tu-text--align-center`,
422
+ right: tailwindStyledComponents.tws `tu-text--align-right`,
423
+ };
424
+ return alignments[$align];
425
+ };
426
+ const StyledText$3 = tailwindStyledComponents.tw.text `
427
+ tu-text
428
+ ${getFontColor$1()}
429
+ ${p => (p.$italicize ? tailwindStyledComponents.tws `tu-text--italic` : "")}
430
+ ${p => (p.$uppercase ? tailwindStyledComponents.tws `tu-text--uppercase` : "")}
431
+ ${getTextAlignment()}
432
+ ${p => (p.$underline ? tailwindStyledComponents.tws `tu-text--underline` : "")}
433
+ ${getTextSize()}
434
+ ${getTextWeight()}
435
+ `;
436
+
437
+ /**
438
+ * The Alert component should be used to inform the user of important information.
439
+ *
440
+ * @param {AlertProps} props - The props for the Alert component
441
+ * @returns {JSX.Element} Alert component
442
+ */
443
+ const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, inline = false, }) => {
444
+ const ref = React__namespace.useRef();
445
+ const getIconFromColor = () => {
446
+ switch (color) {
447
+ case "danger":
448
+ return jsxRuntime.jsx(Icon, { name: "ExclamationTriangleIcon", color: "danger" });
449
+ case "warning":
450
+ return jsxRuntime.jsx(Icon, { name: "ExclamationCircleIcon", color: "warning" });
451
+ case "success":
452
+ return jsxRuntime.jsx(Icon, { name: "CheckCircleIcon", color: "success" });
453
+ default:
454
+ return jsxRuntime.jsx(Icon, { name: "InformationCircleIcon" });
455
+ }
456
+ };
457
+ const getButtonColor = () => {
458
+ switch (color) {
459
+ case "danger":
460
+ return "danger";
461
+ case "warning":
462
+ return "warning";
463
+ default:
464
+ return "primary";
465
+ }
466
+ };
467
+ const body = inline ? (jsxRuntime.jsxs("div", { children: [title && jsxRuntime.jsx(Text$1, Object.assign({ weight: "bold" }, { children: title !== null && title !== void 0 ? title : children })), children && (jsxRuntime.jsx(Description$2, Object.assign({ weight: !title ? "bold" : "normal", "$hasTitle": !!title }, { children: children })))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [title && jsxRuntime.jsx(Text$1, Object.assign({ weight: "bold" }, { children: title !== null && title !== void 0 ? title : children })), children && (jsxRuntime.jsx(Description$2, Object.assign({ weight: !title ? "bold" : "normal", "$hasTitle": !!title }, { children: children })))] }));
468
+ React__namespace.useEffect(() => {
469
+ if (autoScroll) {
470
+ ref && ref.current && ref.current.scrollIntoView && ref.current.scrollIntoView();
471
+ }
472
+ }, [ref, autoScroll]);
473
+ return (jsxRuntime.jsxs(Container$9, Object.assign({ "$color": color, className: className, "data-testid": dataTestId, "$inline": inline, ref: ref, role: "alert" }, { children: [jsxRuntime.jsx(IconContainer$1, Object.assign({ "$inline": inline }, { children: getIconFromColor() })), jsxRuntime.jsxs(Content$1, Object.assign({ "$inline": inline }, { children: [jsxRuntime.jsxs(ContentDetails, { children: [jsxRuntime.jsx(ContentBody, { children: body }), onClose && !inline ? (jsxRuntime.jsx(CloseButtonContainer, Object.assign({ "$inline": inline }, { children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] }), (primaryAction || secondaryAction || onClose) && (jsxRuntime.jsxs(RightAligned, Object.assign({ "$inline": inline }, { children: [secondaryAction && (jsxRuntime.jsx(Button, Object.assign({ size: "small", variant: "transparent", color: getButtonColor(), onClick: secondaryAction.onClick, loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading }, { children: secondaryAction.label }))), primaryAction && (jsxRuntime.jsx(Button, Object.assign({ size: "small", color: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading }, { children: primaryAction.label }))), onClose && inline ? (jsxRuntime.jsx(CloseButtonContainer, Object.assign({ "$inline": inline }, { children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] })))] }))] })));
474
+ };
475
+ const CloseButtonContainer = tailwindStyledComponents.tw.div `
476
+ ${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert__close-button-container--inline` : tailwindStyledComponents.tws `tu-alert__close-button-container`)}
477
+ `;
478
+ const getBackgroundColor = () => ({ $color }) => {
479
+ const colors = {
480
+ danger: tailwindStyledComponents.tws `tu-alert--danger`,
481
+ warning: tailwindStyledComponents.tws `tu-alert--warning`,
482
+ success: tailwindStyledComponents.tws `tu-alert--success`,
483
+ info: tailwindStyledComponents.tws `tu-alert--info`,
484
+ };
485
+ return colors[$color];
486
+ };
487
+ const Container$9 = tailwindStyledComponents.tw.div `
488
+ tu-alert
489
+ ${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert--inline` : null)}
490
+ ${getBackgroundColor()}
491
+ `;
492
+ const Content$1 = tailwindStyledComponents.tw.div `
493
+ ${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert__content--inline` : tailwindStyledComponents.tws `tu-alert__content`)}
494
+ `;
495
+ const ContentDetails = tailwindStyledComponents.tw.div `
496
+ tu-alert__content-details
497
+ `;
498
+ const ContentBody = tailwindStyledComponents.tw.div `
499
+ tu-alert__content-body
500
+ `;
501
+ const Description$2 = tailwindStyledComponents.twx(Text$1) `
502
+ ${p => (p.$hasTitle ? tailwindStyledComponents.tws `tu-alert__description` : null)}
503
+ `;
504
+ const RightAligned = tailwindStyledComponents.tw.div `
505
+ tu-alert__right-aligned
506
+ ${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert__right-aligned--inline` : null)}
507
+ `;
508
+ const IconContainer$1 = tailwindStyledComponents.tw.div `
509
+ tu-alert__icon-container
510
+ ${p => (p.$inline ? tailwindStyledComponents.tws `tu-alert__icon-container--inline` : null)}
511
+ `;
512
+
513
+ /**
514
+ * The Badge component is used to display a notification badge with an optional number value.
515
+ *
516
+ * @param {BadgeProps} props - The props for the Badge component
517
+ * @returns {JSX.Element} Badge component
518
+ */
519
+ const Badge = (_a) => {
520
+ var { color = "primary", subtle = false, className, count, max, hideZero = false, dataTestId } = _a; __rest(_a, ["color", "subtle", "className", "count", "max", "hideZero", "dataTestId"]);
521
+ if (hideZero && count === 0) {
522
+ return null;
523
+ }
524
+ const displayedCount = count && max ? (count > max ? `${max}+` : count) : count;
525
+ return (jsxRuntime.jsx(StyledText$2, Object.assign({ className: className, "$color": color, "$subtle": subtle, "$count": count, "data-testid": dataTestId, "$as": "span" }, { children: displayedCount })));
526
+ };
527
+ const getBadgeModifierClass = () => ({ $color, $subtle }) => {
528
+ const colorClasses = {
529
+ primary: $subtle ? tailwindStyledComponents.tws `tu-badge--primary-subtle` : tailwindStyledComponents.tws `tu-badge--primary`,
530
+ danger: $subtle ? tailwindStyledComponents.tws `tu-badge--danger-subtle` : tailwindStyledComponents.tws `tu-badge--danger`,
531
+ };
532
+ return colorClasses[$color];
533
+ };
534
+ const StyledText$2 = tailwindStyledComponents.tw.text `
535
+ tu-badge
536
+ ${({ $count }) => ($count === null || $count === undefined) && tailwindStyledComponents.tws `tu-badge--square`}
537
+ ${getBadgeModifierClass()}
538
+ `;
539
+
540
+ /**
541
+ * A base input component that can be used for text inputs, password inputs, etc.
542
+ * A reference to the input element is provided as the `ref` prop.
543
+ * Extends props from [React.InputHTMLAttributes](https://reactjs.org/docs/dom-elements.html#input)
544
+ *
545
+ * For specific input types make sure to use the corresponding input component.
546
+ * This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
547
+ */
548
+ const BaseInput = React__namespace.forwardRef((_a, ref) => {
549
+ var { className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false } = _a, rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize", "nonInteractive"]);
550
+ return (jsxRuntime.jsxs(InputContainer$1, Object.assign({ "$fieldSize": fieldSize, "$invalid": isInvalid, "$disabled": rest.disabled || rest.readOnly, className: className, "data-testid": dataTestId && `${dataTestId}-container` }, { children: [addonBefore && addonBefore !== undefined ? (jsxRuntime.jsx(AddonBefore, Object.assign({ "data-testid": dataTestId && `${dataTestId}-addonBefore` }, { children: addonBefore }))) : null, prefix && addonBefore !== prefix ? (jsxRuntime.jsx(InputPrefix, Object.assign({ "data-testid": dataTestId && `${dataTestId}-prefix` }, { children: prefix }))) : null, jsxRuntime.jsx("input", Object.assign({ ref: ref, "data-testid": dataTestId, className: tailwindStyledComponents.tws `tu-input__field` }, rest, { readOnly: rest.readOnly || nonInteractive })), suffix && addonBefore !== suffix ? (jsxRuntime.jsx(InputSuffix, Object.assign({ "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix }))) : null, actions && addonBefore !== actions ? actions : null, addonAfter && addonAfter !== undefined && addonBefore !== addonAfter ? (jsxRuntime.jsx(AddonAfter, Object.assign({ "data-testid": dataTestId && `${dataTestId}-addonAfter` }, { children: addonAfter }))) : null] })));
551
+ });
552
+ const InputPrefix = tailwindStyledComponents.tw.div `
553
+ tu-input__prefix
554
+ `;
555
+ const InputSuffix = tailwindStyledComponents.tw.div `
556
+ tu-input__suffix
557
+ `;
558
+ const AddonBefore = tailwindStyledComponents.tw.div `
559
+ tu-input__addon-before
560
+ `;
561
+ const AddonAfter = tailwindStyledComponents.tw.div `
562
+ tu-input__addon-after
563
+ `;
564
+ const InputContainer$1 = tailwindStyledComponents.tw.label `
565
+ tu-input
566
+ ${({ $invalid }) => ($invalid ? tailwindStyledComponents.tws `tu-input--invalid` : null)}
567
+ ${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-input--disabled` : null)}
568
+ ${({ $fieldSize }) => ($fieldSize === "small" ? tailwindStyledComponents.tws `tu-input--small` : null)}
569
+ `;
570
+
571
+ const ROLE_CARD = "region";
572
+ /**
573
+ * The Card component is a container for UI elements, and is the main component of the modal.
574
+ * To get the most out of the Card, use it in combination with the CardHeader, CardBody and CardFooter.
575
+ *
576
+ * @param {CardProps} props - The props for the Card component
577
+ * @returns {JSX.Element} Card component
578
+ */
579
+ const Card = (_a) => {
580
+ var { children, onClick, fullHeight = false, onMouseEnter, onMouseLeave, className, dataTestId, overflow = "visible", gridArea } = _a, rest = __rest(_a, ["children", "onClick", "fullHeight", "onMouseEnter", "onMouseLeave", "className", "dataTestId", "overflow", "gridArea"]);
581
+ return (jsxRuntime.jsx(StyledCard$2, Object.assign({}, rest, { "$fullHeight": fullHeight, "$overflow": overflow, onClick: onClick, className: className, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, "data-testid": dataTestId, role: ROLE_CARD, style: { gridArea } }, { children: children })));
582
+ };
583
+ const getOverflow$1 = () => ({ $overflow }) => {
584
+ if (!$overflow) {
585
+ return null;
586
+ }
587
+ const overflows = {
588
+ visible: tailwindStyledComponents.tws `overflow-visible`,
589
+ hidden: tailwindStyledComponents.tws `overflow-hidden`,
590
+ scroll: tailwindStyledComponents.tws `overflow-scroll`,
591
+ auto: tailwindStyledComponents.tws `overflow-auto`,
592
+ };
593
+ return overflows[$overflow];
594
+ };
595
+ const StyledCard$2 = tailwindStyledComponents.tw.div `
596
+ tu-card
597
+ ${p => (p.$fullHeight ? `h-full` : null)}
598
+
599
+ ${p => p.onClick && `tu-card--clickable`}
600
+ ${getOverflow$1()}
601
+ `;
602
+
603
+ /**
604
+ * The DensityContainer component applies gap and padding.
605
+ * The padding should live here, and not on the Card itself, as to not inset the scrollbar in case of overflow.
606
+ *
607
+ * @summary For applying auto padding and gap to a Card or Modal or whatever.
608
+ * @param {ContainerProps} props - The props for the DensityContainer component
609
+ * @returns {JSX.Element} DensityContainer component
610
+ */
611
+ const DensityContainer = ({ children, className, dataTestId, density, disableGap, direction, }) => {
612
+ return (jsxRuntime.jsx(StyledDensityContainer$1, Object.assign({ "$disableGap": disableGap, "$density": density, "$direction": direction, "data-testid": dataTestId, className: className }, { children: children })));
613
+ };
614
+ const getDirection = () => ({ $direction }) => {
615
+ $direction = $direction !== null && $direction !== void 0 ? $direction : "column";
616
+ const directions = {
617
+ row: tailwindStyledComponents.tws `flex-row`,
618
+ "row-reverse": tailwindStyledComponents.tws `flex-row-reverse`,
619
+ column: tailwindStyledComponents.tws `flex-col`,
620
+ "column-reverse": tailwindStyledComponents.tws `flex-col-reverse`,
621
+ };
622
+ return directions[$direction];
623
+ };
624
+ const densityAuto = tailwindStyledComponents.tws `
625
+ component-card-spacing
626
+ sm:component-card-spacing-sm
627
+ md:component-card-spacing-md
628
+ `;
629
+ const DensityFinder = ({ $density }) => {
630
+ switch ($density) {
631
+ case "none":
632
+ return;
633
+ case "compact":
634
+ return tailwindStyledComponents.tws `gap-3 p-3`;
635
+ case "comfortable":
636
+ return tailwindStyledComponents.tws `gap-4 p-4`;
637
+ case "spacious":
638
+ return tailwindStyledComponents.tws `gap-4 p-6`;
639
+ case "auto":
640
+ default:
641
+ return densityAuto;
642
+ }
643
+ };
644
+ const StyledDensityContainer$1 = tailwindStyledComponents.tw.div `
645
+ flex
646
+ ${getDirection()}
647
+ ${p => (p.$disableGap ? tailwindStyledComponents.tws `gap-0` : null)}
648
+ ${DensityFinder}
649
+ `;
650
+
651
+ /**
652
+ * The CardBody component should be used to inform the user of important information.
653
+ *
654
+ * @summary For applying padding and gap to a Card.
655
+ * @description The padding must live here, and not on the Card itself, as to not inset the scrollbar in case of overflow
656
+ * @param {CardBodyProps} props - The props for the CardBody component
657
+ * @returns {JSX.Element} CardBody component
658
+ */
659
+ const CardBody = ({ density = "auto", overflow = "auto", children, dataTestId, className, disableGap, }) => {
660
+ return (jsxRuntime.jsx(StyledDensityContainer, Object.assign({ "$overflow": overflow, density: density, dataTestId: dataTestId, className: className, disableGap: disableGap }, { children: children })));
661
+ };
662
+ const getOverflow = () => ({ $overflow }) => {
663
+ if (!$overflow) {
664
+ return null;
665
+ }
666
+ const overflows = {
667
+ visible: tailwindStyledComponents.tws `overflow-visible`,
668
+ hidden: tailwindStyledComponents.tws `overflow-hidden`,
669
+ scroll: tailwindStyledComponents.tws `overflow-scroll`,
670
+ auto: tailwindStyledComponents.tws `overflow-auto`,
671
+ };
672
+ return overflows[$overflow];
673
+ };
674
+ const StyledDensityContainer = tailwindStyledComponents.twx(DensityContainer) `
675
+ ${getOverflow()}
676
+ tu-card__body
677
+ `;
678
+
679
+ /**
680
+ * A simple footer intended to use with Cards and Modals.
681
+ * Currently only intended to contain Buttons.
682
+ * The buttons justifies to the right, but if you style a button with "margin-right: auto" it will move to the left
683
+ *
684
+ * @param {CardFooterProps} props - The props for the CardFooter component
685
+ * @returns {JSX.Element} CardFooter component
686
+ */
687
+ const CardFooter = ({ dataTestId, className, children, density, hideSeparator = false }) => {
688
+ return (jsxRuntime.jsx(Container$8, Object.assign({ dataTestId: dataTestId, className: className, "$hideSeparator": hideSeparator, density: density, direction: "row" }, { children: children })));
689
+ };
690
+ const Container$8 = tailwindStyledComponents.twx(DensityContainer) `
691
+ tu-card__footer-density-container
692
+ ${p => p.$hideSeparator && tailwindStyledComponents.tws `tu-card__footer-density-container--borderless`}
693
+ `;
694
+
695
+ /**
696
+ * The Heading is used for a heading of a section (h1,h2,h3,h4).
697
+ *
698
+ * @param {HeadingProps} props - The props for the Heading component
699
+ * @returns {JSX.Element} Heading component
700
+ */
701
+ const Heading$1 = ({ children, variant = "primary", inverted = false, subtle = false, className, dataTestId, }) => {
702
+ const semanticType = {
703
+ primary: "h1",
704
+ secondary: "h2",
705
+ tertiary: "h3",
706
+ subtitle: "h4",
707
+ };
708
+ return (jsxRuntime.jsx(StyledHeading, Object.assign({ "$as": semanticType[variant], className: className, "$variant": variant, "$inverted": inverted, "$subtle": subtle, "data-testid": dataTestId }, { children: children })));
709
+ };
710
+ const getVariantStyles = () => ({ $variant }) => {
711
+ const variants = {
712
+ primary: tailwindStyledComponents.tws `tu-heading--primary`,
713
+ secondary: tailwindStyledComponents.tws `tu-heading--secondary`,
714
+ tertiary: tailwindStyledComponents.tws `tu-heading--tertiary`,
715
+ subtitle: tailwindStyledComponents.tws `tu-heading--subtitle`,
716
+ };
717
+ return variants[$variant];
718
+ };
719
+ const getFontColor = () => ({ $inverted, $subtle }) => {
720
+ const subtle = $inverted ? tailwindStyledComponents.tws `tu-heading--subtle-inverted` : tailwindStyledComponents.tws `tu-heading--subtle`;
721
+ const inverted = $inverted ? tailwindStyledComponents.tws `tu-heading--inverted` : null;
722
+ return $subtle ? subtle : inverted;
723
+ };
724
+ const StyledHeading = tailwindStyledComponents.tw.div `
725
+ tu-heading
726
+ ${getFontColor()}
727
+ ${getVariantStyles()}
728
+ `;
729
+
730
+ /**
731
+ * Header for Cards and Modals.
732
+ *
733
+ * @param {CardHeaderProps} props - The props for the CardHeader component
734
+ * @returns {JSX.Element} CardHeader component
735
+ */
736
+ const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, hideSeparator = false, }) => {
737
+ return (jsxRuntime.jsx(Root$8, Object.assign({ dataTestId: dataTestId, className: className, "$hideSeparator": hideSeparator, density: density }, { children: jsxRuntime.jsxs(Container$7, { children: [jsxRuntime.jsxs("div", Object.assign({ className: extraClassName }, { children: [jsxRuntime.jsxs(HeadingContainer$1, { children: [jsxRuntime.jsx(Heading$1, Object.assign({ className: "self-center", variant: headingVariant }, { children: heading })), accessories] }), subHeading && (jsxRuntime.jsx(Heading$1, Object.assign({ subtle: true, variant: "subtitle" }, { children: subHeading }))), children] })), onClose && (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }), className: "!h-min" }))] }) })));
738
+ };
739
+ const Root$8 = tailwindStyledComponents.twx(DensityContainer) `
740
+ tu-card__header-density-container
741
+ ${p => p.$hideSeparator && tailwindStyledComponents.tws `tu-card__header-density-container--borderless`}
742
+ `;
743
+ const Container$7 = tailwindStyledComponents.tw.div `
744
+ tu-card__header
745
+ `;
746
+ const HeadingContainer$1 = tailwindStyledComponents.tw.div `
747
+ tu-card__header-heading-container
748
+ `;
749
+
750
+ /**
751
+ * The Label component is used for labels for input fields.
752
+ * This component is **not used directly**, but is part of the FormGroup and Field components.
753
+ *
754
+ * @param {LabelProps} props - The props for the Label component
755
+ * @returns {JSX.Element} Label component
756
+ */
757
+ const Label$2 = ({ id, htmlFor, children, className, dataTestId, disabled, isInvalid, }) => {
758
+ return (jsxRuntime.jsx(Root$7, Object.assign({ id: id || "", htmlFor: htmlFor || "", className: className, "data-testid": dataTestId, "$disabled": disabled, "$isInvalid": isInvalid }, { children: children })));
759
+ };
760
+ const Root$7 = tailwindStyledComponents.tw.label `
761
+ tu-label
762
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-label--disabled`}
763
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-label--invalid`}
764
+ `;
765
+
766
+ /**
767
+ * The CheckIcon component is used by the checkbox to display the checked state.
768
+ *
769
+ * @param {CheckIconProps} props - The props for the CheckIcon component
770
+ * @returns {JSX.Element} CheckIcon component
771
+ */
772
+ const CheckIcon = ({ className, dataTestId }) => {
773
+ return (jsxRuntime.jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", className: className, "data-testid": dataTestId, fill: "none", viewBox: "0 0 10 10", stroke: "currentColor", strokeWidth: "2" }, { children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m2 5.5 2 2L8.5 3" }) })));
774
+ };
775
+
776
+ /**
777
+ * The IndeterminateIcon component is used by the checkbox to display the Indeterminate state.
778
+ *
779
+ * @param {IndeterminateIconProps} props - The props for the IndeterminateIcon component
780
+ * @returns {JSX.Element} IndeterminateIcon component
781
+ */
782
+ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", className: className, fill: "none", viewBox: "0 0 10 10", stroke: "currentColor", strokeWidth: "2" }, { children: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 5h4" }) })));
783
+
784
+ /**
785
+ * Checkboxes are used when there are multiple items to select in a list. Users can select zero, one, or any number of items.
786
+ *
787
+ * Checkboxes are used for multiple choices, not for mutually exclusive choices. Each checkbox works independently from other checkboxes in the list, therefore checking an additional box does not affect any other selections.
788
+ *
789
+ * _**Do use** checkboxes to allow selection in a form, for filtering, terms and conditions to indicate agreement, and bulk actions in lists or tables._
790
+ *
791
+ * _**Do not use** checkboxes if the user can only select one option from a list, radio buttons should be used instead of checkboxes._
792
+ *
793
+ * @description A reference to the input element is provided as the `ref` prop.
794
+ * @augments props from [React.InputHTMLAttributes](https://reactjs.org/docs/dom-elements.html#input)
795
+ * @param {CheckboxProps} props - The props for the Checkbox component
796
+ * @returns {JSX.Element} Checkbox component
797
+ */
798
+ const Checkbox = React__namespace.forwardRef((_a, ref) => {
799
+ var { className, dataTestId, onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, children, label, tabIndex = 0 } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "children", "label", "tabIndex"]);
800
+ const icon = indeterminate ? jsxRuntime.jsx(StyledIndeterminateIcon, {}) : checked && jsxRuntime.jsx(StyledCheckIcon, {});
801
+ const internalRef = React__namespace.useRef(null);
802
+ const isReadonly = disabled || readOnly;
803
+ const onKeyPress = e => {
804
+ var _a;
805
+ if ("Space" === e.code) {
806
+ (_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
807
+ }
808
+ };
809
+ const uuid = rest.id || dataTestId;
810
+ return (jsxRuntime.jsxs(CheckboxContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}Container`, htmlFor: uuid, className: className }, { children: [jsxRuntime.jsx(HiddenInput$1, Object.assign({ type: "checkbox", checked: !indeterminate && checked, onChange: onChange, disabled: disabled, "data-testid": dataTestId, readOnly: readOnly, "aria-checked": !indeterminate && checked, role: "checkbox", id: uuid }, rest, { ref: ref })), jsxRuntime.jsx(CheckboxWrapper, Object.assign({ id: uuid, "$disabled": isReadonly, "$checked": checked, "$indeterminate": indeterminate, "$isInvalid": isReadonly ? false : isInvalid, tabIndex: isReadonly ? -1 : tabIndex, onKeyPress: onKeyPress }, { children: icon })), label && (jsxRuntime.jsx(Label$2, Object.assign({ className: tailwindStyledComponents.tws `cursor-pointer`, htmlFor: uuid, disabled: isReadonly, isInvalid: isReadonly ? false : isInvalid, dataTestId: dataTestId && `${dataTestId}-Label` }, { children: label }))), children] })));
811
+ });
812
+ const StyledCheckIcon = tailwindStyledComponents.twx(CheckIcon) `tu-checkbox--icon`;
813
+ const StyledIndeterminateIcon = tailwindStyledComponents.twx(IndeterminateIcon) `tu-checkbox--icon`;
814
+ const CheckboxContainer = tailwindStyledComponents.tw.label `tu-checkbox--container group`;
815
+ const HiddenInput$1 = tailwindStyledComponents.tw.input `tu-checkbox--input`;
816
+ const CheckboxWrapper = tailwindStyledComponents.tw.span `
817
+ tu-checkbox
818
+ ${({ $checked, $disabled, $indeterminate }) => {
819
+ if ($disabled) {
820
+ return tailwindStyledComponents.tws `tu-checkbox--disabled`;
821
+ }
822
+ return $indeterminate
823
+ ? tailwindStyledComponents.tws `tu-checkbox--indeterminate`
824
+ : $checked
825
+ ? tailwindStyledComponents.tws `tu-checkbox--selected`
826
+ : tailwindStyledComponents.tws `tu-checkbox--deselected`;
827
+ }}
828
+
829
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-checkbox--invalid`}
830
+ `;
831
+
832
+ /**
833
+ * The Collapse component is used to condense non-important information.
834
+ *
835
+ * @param {CollapseProps} props - The props for the Collapse component
836
+ * @returns {JSX.Element} Collapse component
837
+ */
838
+ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, className, dataTestId, }) => {
839
+ const [expanded, setExpanded] = React__namespace.useState(initialExpanded);
840
+ const handleClick = React__namespace.useCallback((e) => {
841
+ if (onToggle) {
842
+ onToggle(e, !expanded);
843
+ }
844
+ setExpanded(!expanded);
845
+ }, [expanded, onToggle]);
846
+ return (jsxRuntime.jsxs(StyledCollapse, Object.assign({ className: className, "data-testid": dataTestId }, { children: [jsxRuntime.jsx(CollapseLabel, Object.assign({ role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick }, { children: jsxRuntime.jsxs(LabelContainer$2, { children: [jsxRuntime.jsx(Text$1, Object.assign({ weight: "bold" }, { children: label })), jsxRuntime.jsx(IconButton, { icon: jsxRuntime.jsx(Rotate, { name: "ChevronDownIcon", size: "small", "$expanded": expanded }), size: "medium", variant: "transparent", color: "secondary" })] }) })), jsxRuntime.jsx(Collapsible, Object.assign({ expanded: expanded, id: id }, { children: children }))] })));
847
+ };
848
+ const Rotate = tailwindStyledComponents.twx(Icon) `
849
+ ${p => (p.$expanded ? tailwindStyledComponents.tws `tu-icon--animated-rotate-expanded` : null)}
850
+ tu-icon--animated-rotate
851
+ `;
852
+ const StyledCollapse = tailwindStyledComponents.tw.div `
853
+ tu-collapse
854
+ `;
855
+ const CollapseLabel = tailwindStyledComponents.tw.div `
856
+ tu-collapse__label
857
+ `;
858
+ const LabelContainer$2 = tailwindStyledComponents.tw.div `
859
+ tu-collapse__label__container
860
+ `;
861
+ const Collapsible = ({ children, expanded, id }) => {
862
+ const [ref, { height }] = reactUse.useMeasure();
863
+ return (jsxRuntime.jsx(AnimatedCollapsible, Object.assign({ id: id, style: { height: expanded ? height : "0" } }, { children: jsxRuntime.jsx(StyledCollapsible, Object.assign({ ref: ref }, { children: children })) })));
864
+ };
865
+ const AnimatedCollapsible = tailwindStyledComponents.tw.div `
866
+ tu-collapsible--animated
867
+ `;
868
+ const StyledCollapsible = tailwindStyledComponents.tw.div `
869
+ tu-collapsible
870
+ `;
871
+
872
+ /**
873
+ * The CopyableText component is used where the user should have easy access to copy information.
874
+ *
875
+ * @param {CopyableTextProps} props - The props for the CopyableText component
876
+ * @returns {JSX.Element} CopyableText component
877
+ */
878
+ const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
879
+ var _a;
880
+ const value = (_a = alternativeText !== null && alternativeText !== void 0 ? alternativeText : text) !== null && _a !== void 0 ? _a : "";
881
+ const [animating, setAnimating] = React.useState(false);
882
+ const [, copyToClipboard] = reactUse.useCopyToClipboard();
883
+ const handleOnClick = () => {
884
+ copyToClipboard(value);
885
+ setAnimating(true);
886
+ };
887
+ return (jsxRuntime.jsx(StyledCopyableText, Object.assign({ className: className, "data-testid": dataTestId, onClick: handleOnClick, onAnimationEnd: () => setAnimating(false), "$animating": animating, title: value }, { children: text })));
888
+ };
889
+ const StyledCopyableText = tailwindStyledComponents.tw.span `
890
+ tu-copyable-text
891
+ ${p => (p.$animating ? tailwindStyledComponents.tws `tu-copyable-text--animating` : null)}`;
892
+
893
+ /**
894
+ * A wrapper around BaseInput with a pop-up day picker.
895
+ *
896
+ * NOTE: If shown with a label, please use the `DateField` component instead.
897
+ */
898
+ const DateInput = React.forwardRef((_a, ref) => {
899
+ var { min, max, defaultValue, value } = _a, rest = __rest(_a, ["min", "max", "defaultValue", "value"]);
900
+ const formatDateToInputString = (date) => date instanceof Date ? dateFns.format(date, "yyyy-MM-dd") : date;
901
+ // @ts-ignore
902
+ // Chrome needs it's default icon to have datepicker functionality.
903
+ // window.chrome doesn't exist in TS but is available on chrome browsers.
904
+ // If it fails it will just show our icon.
905
+ const hideOnChrome = () => (window.chrome !== null && typeof window.chrome !== "undefined" ? "hidden" : "");
906
+ return (jsxRuntime.jsx(BaseInput, Object.assign({ type: "date", value: formatDateToInputString(value), defaultValue: formatDateToInputString(defaultValue), min: formatDateToInputString(min), max: formatDateToInputString(max), ref: ref, suffix: jsxRuntime.jsx(Icon, { dataTestId: "calendar", name: "CalendarIcon", size: "medium", type: "solid", className: hideOnChrome() }) }, rest)));
907
+ });
908
+
909
+ /**
910
+ * The hook that powers the Popover component.
911
+ * It should not be used directly, but rather through the Popover component.
912
+ *
913
+ * @param {PopoverProps} options The options for the popover
914
+ * @returns {ReturnType<usePopover>} The data for the popover
915
+ */
916
+ const usePopover = (_a) => {
917
+ var { initialOpen = false, placement = "bottom", isModal, isOpen: controlledIsOpen, activation = { click: true, hover: false }, onOpenStateChange: setControlledIsOpen } = _a, restOptions = __rest(_a, ["initialOpen", "placement", "isModal", "isOpen", "activation", "onOpenStateChange"]);
918
+ const [uncontrolledIsOpen, setUncontrolledIsOpen] = React.useState(initialOpen);
919
+ const [labelId, setLabelId] = React.useState();
920
+ const [descriptionId, setDescriptionId] = React.useState();
921
+ const isOpen = controlledIsOpen !== null && controlledIsOpen !== void 0 ? controlledIsOpen : uncontrolledIsOpen;
922
+ const setIsOpen = setControlledIsOpen !== null && setControlledIsOpen !== void 0 ? setControlledIsOpen : setUncontrolledIsOpen;
923
+ const popoverData = react.useFloating({
924
+ placement,
925
+ open: isOpen,
926
+ onOpenChange: setIsOpen,
927
+ whileElementsMounted: react.autoUpdate,
928
+ middleware: [
929
+ react.offset(8),
930
+ react.flip({ fallbackPlacements: ["top", "bottom", "right", "left"] }),
931
+ react.shift(),
932
+ react.size({
933
+ apply({ availableWidth, availableHeight, elements }) {
934
+ Object.assign(elements.floating.style, {
935
+ maxWidth: `${availableWidth}px`,
936
+ maxHeight: `${availableHeight}px`,
937
+ });
938
+ },
939
+ }),
940
+ ],
941
+ });
942
+ const popoverContext = popoverData.context;
943
+ const clickInteraction = react.useClick(popoverContext, { enabled: activation.click, ignoreMouse: activation.hover });
944
+ const dismissInteraction = react.useDismiss(popoverContext);
945
+ const hoverInteraction = react.useHover(popoverContext, { enabled: activation.hover });
946
+ const roleInteraction = react.useRole(popoverContext);
947
+ const combinedInteractions = react.useInteractions([
948
+ clickInteraction,
949
+ hoverInteraction,
950
+ dismissInteraction,
951
+ roleInteraction,
952
+ ]);
953
+ return React.useMemo(() => (Object.assign(Object.assign(Object.assign({ isOpen,
954
+ setIsOpen }, combinedInteractions), popoverData), { isModal,
955
+ labelId,
956
+ descriptionId,
957
+ setLabelId,
958
+ setDescriptionId, customProps: restOptions })), [isOpen, setIsOpen, combinedInteractions, popoverData, isModal, labelId, descriptionId, restOptions]);
959
+ };
960
+
961
+ const PopoverContext = React.createContext(null);
962
+ /**
963
+ * A hook to get the popover context.
964
+ * It should only be used by the Popover components.
965
+ *
966
+ * @returns {ContextType} The popover context
967
+ */
968
+ const usePopoverContext = () => {
969
+ const context = React.useContext(PopoverContext);
970
+ if (context === null) {
971
+ throw new Error("Popover components must be wrapped in <Popover />");
972
+ }
973
+ return context;
974
+ };
975
+ /**
976
+ * The popover component.
977
+ * - This component should wrap all the popover components.
978
+ * - It returns a context that is used by the popover components.
979
+ * - The context is used to share the state of the popover, such as the open state and the reference element.
980
+ *
981
+ * To open the popover, use the `<PopoverTrigger />` component.
982
+ *
983
+ * To render the content of the popover, use the `<PopoverContent />` component.
984
+ *
985
+ *
986
+ * @param {PopoverProps} props The props for the popover
987
+ * @returns {JSX.Element} A Popover Context Provider contining the children
988
+ */
989
+ const Popover = (_a) => {
990
+ var { children, isModal = false } = _a, restOptions = __rest(_a, ["children", "isModal"]);
991
+ const popover = usePopover(Object.assign({ isModal }, restOptions));
992
+ return jsxRuntime.jsx(PopoverContext.Provider, Object.assign({ value: popover }, { children: children }));
993
+ };
994
+
995
+ const PopoverContent = React__default["default"].forwardRef(function PopoverContent(_a, propRef) {
996
+ var _b, _c, _d, _e;
997
+ var { className, dataTestId, children } = _a, props = __rest(_a, ["className", "dataTestId", "children"]);
998
+ const _f = usePopoverContext(), { context: floatingContext, customProps } = _f, context = __rest(_f, ["context", "customProps"]);
999
+ const ref = react.useMergeRefs([context.refs.setFloating, propRef]);
1000
+ return (jsxRuntime.jsx(react.FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: context.isOpen && (jsxRuntime.jsx(react.FloatingFocusManager, Object.assign({ guards: false, context: floatingContext, modal: context.isModal, order: ["reference", "content"] }, { children: jsxRuntime.jsx("div", Object.assign({ ref: ref, className: `tu-popover-container animate-fade-in-fast ${(_b = className !== null && className !== void 0 ? className : customProps.className) !== null && _b !== void 0 ? _b : ""}`, "data-testid": (_c = dataTestId !== null && dataTestId !== void 0 ? dataTestId : customProps.dataTestId) !== null && _c !== void 0 ? _c : "popover-content", style: Object.assign({ position: context.strategy, top: (_d = context.y) !== null && _d !== void 0 ? _d : 0, left: (_e = context.x) !== null && _e !== void 0 ? _e : 0, width: "max-content" }, props.style), "aria-labelledby": context.labelId, "aria-describedby": context.descriptionId }, context.getFloatingProps(props), { children: typeof children === "function" ? children(() => context.setIsOpen(false)) : children })) }))) })));
1001
+ });
1002
+
1003
+ /**
1004
+ * The PopoverTitle component.
1005
+ *
1006
+ * @param {PopoverTitleProps} props - The props for the PopoverTitle component
1007
+ * @returns {JSX.Element} PopoverTitle component
1008
+ */
1009
+ const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
1010
+ return (jsxRuntime.jsxs(Container$6, Object.assign({ "$divider": divider, className: className, "data-testid": dataTestId }, { children: [jsxRuntime.jsx(StyledText$1, Object.assign({ type: "div", subtle: true, size: "small", weight: "bold", uppercase: true }, { children: children })), action] })));
1011
+ };
1012
+ const Container$6 = tailwindStyledComponents.tw.div `
1013
+ tu-popover-title-container
1014
+ ${p => p.$divider && `tu-popover-title-container--divider`}
1015
+ `;
1016
+ const StyledText$1 = tailwindStyledComponents.twx(Text$1) `
1017
+ tu-popover-title-text
1018
+ `;
1019
+
1020
+ const PopoverTrigger = React.forwardRef(function PopoverTrigger(_a, propRef) {
1021
+ var { children, renderButton } = _a, props = __rest(_a, ["children", "renderButton"]);
1022
+ const context = usePopoverContext();
1023
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1024
+ const childrenRef = children.ref;
1025
+ const ref = react.useMergeRefs([context.refs.setReference, propRef, childrenRef]);
1026
+ if (!renderButton && React.isValidElement(children)) {
1027
+ return React.cloneElement(children, context.getReferenceProps(Object.assign(Object.assign(Object.assign({ ref }, props), children.props), { "data-state": context.isOpen ? "open" : "closed" })));
1028
+ }
1029
+ else {
1030
+ return (jsxRuntime.jsx(Button, Object.assign({ ref: ref, type: "button", "data-state": context.isOpen ? "open" : "closed" }, context.getReferenceProps(props), { children: children })));
1031
+ }
1032
+ });
1033
+
1034
+ /**
1035
+ * The Tooltip component is used to show helpful tips or contextual information to the users.
1036
+ *
1037
+ * @param {TooltipProps} props - The props for the Tooltip component
1038
+ * @returns {JSX.Element} Tooltip component
1039
+ */
1040
+ const Tooltip = (_a) => {
1041
+ var { children, dataTestId, disabled, className } = _a, rest = __rest(_a, ["children", "dataTestId", "disabled", "className"]);
1042
+ const wrappedChildren = (jsxRuntime.jsx(Flex$1, Object.assign({ className: className, "data-testid": dataTestId && `${dataTestId}-parent` }, { children: children })));
1043
+ if (disabled) {
1044
+ return wrappedChildren;
1045
+ }
1046
+ return (jsxRuntime.jsx(TooltipContainer, Object.assign({ dataTestId: dataTestId }, rest, { children: wrappedChildren })));
1047
+ };
1048
+ const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxRuntime.jsxs(StyledPopover, Object.assign({ className: "tu-tooltip__container", placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "" }, { children: [jsxRuntime.jsx(PopoverTrigger, { children: children }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsx(Content, Object.assign({ "$mode": mode }, { children: jsxRuntime.jsx(Text$1, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) })) })] })));
1049
+ const Flex$1 = tailwindStyledComponents.tw.div `
1050
+ inline-flex
1051
+ `;
1052
+ const StyledPopover = tailwindStyledComponents.twx(Popover) `
1053
+ tu-tooltip__container
1054
+ `;
1055
+ const Content = tailwindStyledComponents.tw.div `
1056
+ tu-tooltip__content
1057
+ ${p => (p.$mode === "light" ? tailwindStyledComponents.tws `tu-tooltip--light` : null)}
1058
+ `;
1059
+
1060
+ /**
1061
+ * The Tip component is used to show helpful tips or contextual information to the users.
1062
+ * The tip can optionally be rendered as an anchor tag, which redirects to users to an external link on click.
1063
+ *
1064
+ * @param {TipProps} props - The props for the Tip component
1065
+ * @returns {JSX.Element} Tip component
1066
+ */
1067
+ const Tip = ({ children, iconProps, dataTestId, link, renderAs = "span", className, placement = "bottom", mode, }) => {
1068
+ const ifAnchorTag = renderAs === "a";
1069
+ return (jsxRuntime.jsx(TipContainer, Object.assign({ "data-testid": dataTestId, "$as": renderAs, href: ifAnchorTag ? link : undefined, target: ifAnchorTag ? "_blank" : undefined, className: className }, { children: jsxRuntime.jsx(Tooltip, Object.assign({ label: children, dataTestId: dataTestId && `${dataTestId}-tooltip`, mode: mode, className: "tu-tip-tooltip", placement: placement }, { children: jsxRuntime.jsx(Icon, Object.assign({ name: "QuestionMarkCircleIcon", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) })) })));
1070
+ };
1071
+ const TipContainer = tailwindStyledComponents.tw.text `
1072
+ tu-tip
1073
+ `;
1074
+
1075
+ /**
1076
+ * The FormGroup component should be used to wrap any Input element that needs a label.
1077
+ * Besides a label the component supplies an optional Tip, HelpText and HelpAddon support.
1078
+ *
1079
+ * @param {FormGroupProps} props - The props for the FormGroup component
1080
+ * @returns {JSX.Element} FormGroup component
1081
+ */
1082
+ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, disabled = false, }) => {
1083
+ return (jsxRuntime.jsxs(FormGroupRoot, Object.assign({ className: className, "data-testid": dataTestId, "$disabled": disabled }, { children: [jsxRuntime.jsxs(ContainerBefore, { children: [jsxRuntime.jsx(FormGroupLabel, Object.assign({ dataTestId: dataTestId && `${dataTestId}-label` }, { children: label })), tip && jsxRuntime.jsx(Tip, Object.assign({ dataTestId: dataTestId && `${dataTestId}-tip` }, { children: tip }))] }), children, jsxRuntime.jsxs(ContainerAfter, Object.assign({ "$isInvalid": isInvalid }, { children: [helpText && jsxRuntime.jsx("span", Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpText` }, { children: helpText })), helpAddon && jsxRuntime.jsx(HelpAddon, Object.assign({ "data-testid": dataTestId && `${dataTestId}-helpAddon` }, { children: helpAddon }))] }))] })));
1084
+ };
1085
+ const FormGroupRoot = tailwindStyledComponents.tw.label `
1086
+ tu-form-group
1087
+ ${({ $disabled }) => {
1088
+ return $disabled ? "pointer-events-none " : null;
1089
+ }}
1090
+ `;
1091
+ const ContainerBefore = tailwindStyledComponents.tw.div `
1092
+ tu-form-group__container-before
1093
+ `;
1094
+ const FormGroupLabel = tailwindStyledComponents.twx(Label$2) `
1095
+ component-formGroup-font
1096
+ `;
1097
+ const ContainerAfter = tailwindStyledComponents.tw.div `
1098
+ tu-form-group__container-after
1099
+ ${({ $isInvalid }) => ($isInvalid ? tailwindStyledComponents.tws `tu-form-group__container-after--invalid` : null)}
1100
+ `;
1101
+ const HelpAddon = tailwindStyledComponents.tw.span `
1102
+ tu-form-group__help-addon
1103
+ `;
1104
+
1105
+ /**
1106
+ * The date field component is used for entering date values.
1107
+ *
1108
+ * _**Do use**_ the DateField for date input.
1109
+ *
1110
+ * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
1111
+ */
1112
+ const DateField = React.forwardRef((_a, ref) => {
1113
+ var { label, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
1114
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1115
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(DateInput, Object.assign({ ref: ref, defaultValue: defaultValue, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1116
+ });
1117
+
1118
+ const localeLookup = {
1119
+ en: locale.enGB,
1120
+ "en-US": locale.enUS,
1121
+ "en-GB": locale.enGB,
1122
+ da: locale.da,
1123
+ de: locale.de,
1124
+ cs: locale.cs,
1125
+ nl: locale.nl,
1126
+ fr: locale.fr,
1127
+ fi: locale.fi,
1128
+ hu: locale.hu,
1129
+ it: locale.it,
1130
+ nb: locale.nb,
1131
+ pl: locale.pl,
1132
+ pt: locale.pt,
1133
+ ru: locale.ru,
1134
+ ro: locale.ro,
1135
+ es: locale.es,
1136
+ sv: locale.sv,
1137
+ ja: locale.ja,
1138
+ th: locale.th,
1139
+ };
1140
+ /**
1141
+ * A helper function to get the matching Locale object for a given language.
1142
+ *
1143
+ * @param {string} language The language to match
1144
+ * @returns {Locale} The corresponding Locale object
1145
+ */
1146
+ const useLocale = (language) => {
1147
+ return localeLookup[language] || localeLookup.en;
1148
+ };
1149
+
1150
+ /**
1151
+ * The DayPicker component is used when the user needs to select a date.
1152
+ *
1153
+ * @param {DayPickerProps} props - The props for the DayPicker component
1154
+ * @returns {JSX.Element} DayPicker component
1155
+ */
1156
+ const DayPicker = ({ onDaySelect, disabledDays, selectedDays, language, className, dataTestId, max, }) => {
1157
+ const locale = useLocale(language);
1158
+ return (jsxRuntime.jsx(reactDayPicker.DayPicker, { onDayClick: onDaySelect, selected: selectedDays, locale: locale, disabled: disabledDays, className: `custom-day-picker ${className !== null && className !== void 0 ? className : ""}`, max: max, footer: jsxRuntime.jsx("div", { "data-testid": dataTestId }) }));
1159
+ };
1160
+
1161
+ /**
1162
+ * The DayPickerPopover component returns a button which when clicked shows the daypicker.
1163
+ *
1164
+ * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
1165
+ * @returns {JSX.Element} DayPickerPopover component
1166
+ */
1167
+ const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
1168
+ return (jsxRuntime.jsxs(Popover, Object.assign({ placement: placement }, { children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(Button, Object.assign({ color: color, size: size, className: className, prefix: jsxRuntime.jsx(Icon, { name: "CalendarIcon", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker" }, { children: buttonContent })) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsx(Card, { children: jsxRuntime.jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] })));
1169
+ };
1170
+
1171
+ /**
1172
+ * The DayRangePicker component should be used when the user needs to select a range of dates.
1173
+ *
1174
+ * @param {DayRangePickerProps} props - The props for the DayRangePicker component
1175
+ * @returns {JSX.Element} DayRangePicker component
1176
+ */
1177
+ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, dataTestId, language, className, max, }) => {
1178
+ const locale = useLocale(language);
1179
+ const onSelect = React.useCallback((range) => {
1180
+ if (onRangeSelect && range === undefined) {
1181
+ onRangeSelect(undefined);
1182
+ }
1183
+ if (onRangeSelect && range) {
1184
+ const from = range.from;
1185
+ const to = range.to ? range.to : range.from;
1186
+ onRangeSelect({ from, to });
1187
+ }
1188
+ }, [onRangeSelect]);
1189
+ return (jsxRuntime.jsx(reactDayPicker.DayPicker, { mode: "range", onSelect: onSelect, selected: selectedDays, defaultMonth: selectedDays && selectedDays.from, locale: locale, disabled: disabledDays, className: `custom-day-picker range-picker ${className !== null && className !== void 0 ? className : ""}`, max: max, footer: jsxRuntime.jsx("div", { "data-testid": dataTestId }) }));
1190
+ };
1191
+
1192
+ /**
1193
+ * The drawer provides a slideover which can be used to provide access to different locations in the application.
1194
+ *
1195
+ * @param {DrawerProps} props - The props for the Drawer component
1196
+ * @returns {JSX.Element} Drawer component
1197
+ */
1198
+ const Drawer = ({ open, onClose = () => { }, children, disableOverlay = false, position = "left", className, dataTestId, }) => {
1199
+ const { context } = react.useFloating();
1200
+ React.useEffect(() => {
1201
+ // Close overlay when pressing escape button.
1202
+ const onKeyPress = (e) => {
1203
+ if (e.key === "Escape") {
1204
+ onClose();
1205
+ }
1206
+ };
1207
+ if (open) {
1208
+ window.addEventListener("keyup", onKeyPress);
1209
+ }
1210
+ return () => {
1211
+ window.removeEventListener("keyup", onKeyPress);
1212
+ };
1213
+ }, [open, onClose]);
1214
+ return (jsxRuntime.jsx(react.FloatingFocusManager, Object.assign({ context: context }, { children: open ? (jsxRuntime.jsxs(Root$6, Object.assign({ id: "drawer" }, { children: [!disableOverlay && jsxRuntime.jsx(Overlay, { "aria-hidden": open, "$open": open, onClick: onClose, id: "drawer__overlay" }), jsxRuntime.jsx(StyledCard$1, Object.assign({ "aria-hidden": open, "data-testId": dataTestId, "$open": open, "$position": position, id: "drawer__card", className: className }, { children: children }))] }))) : (
1215
+ // eslint-disable-next-line react/jsx-no-useless-fragment
1216
+ jsxRuntime.jsx(jsxRuntime.Fragment, {})) })));
1217
+ };
1218
+ const getPositionStyles = ($position) => {
1219
+ switch ($position) {
1220
+ case "top":
1221
+ return tailwindStyledComponents.tws `tu-drawer__card--top`;
1222
+ case "right":
1223
+ return tailwindStyledComponents.tws `tu-drawer__card--right`;
1224
+ case "bottom":
1225
+ return tailwindStyledComponents.tws `tu-drawer__card--bottom`;
1226
+ case "left":
1227
+ default:
1228
+ return tailwindStyledComponents.tws `tu-drawer__card--left`;
1229
+ }
1230
+ };
1231
+ const StyledCard$1 = tailwindStyledComponents.twx(Card) `
1232
+ tu-drawer__card
1233
+ ${({ $open }) => $open && tailwindStyledComponents.tws `tu-drawer__card--open`}
1234
+ ${({ $position }) => getPositionStyles($position)}
1235
+ `;
1236
+ const Root$6 = tailwindStyledComponents.tw.div `
1237
+ tu-drawer
1238
+ `;
1239
+ const Overlay = tailwindStyledComponents.tw.div `
1240
+ tu-drawer__overlay
1241
+ ${({ $open }) => $open && tailwindStyledComponents.tws `tu-drawer__overlay--open`}
1242
+ `;
1243
+
1244
+ /**
1245
+ * The Drop Zone can be used to drag and drop files
1246
+ *
1247
+ * @param {DropZoneProps} props - The props for the DropZone component
1248
+ * @returns {JSX.Element} DropZone component
1249
+ */
1250
+ const DropZone = (_a) => {
1251
+ var { className, dataTestId, filesSelected, label, size = "large", isInvalid = false, disabled = false } = _a, rest = __rest(_a, ["className", "dataTestId", "filesSelected", "label", "size", "isInvalid", "disabled"]);
1252
+ const [dragActive, setDragActive] = React__default["default"].useState(false);
1253
+ const [fileDropped, setFileDropped] = React__default["default"].useState(false);
1254
+ // function that handles drag enter, drag leave and drag over
1255
+ const handleDrag = (e) => {
1256
+ e.preventDefault();
1257
+ e.stopPropagation();
1258
+ if ((e.type === "dragenter" || e.type === "dragover") && !disabled) {
1259
+ setDragActive(true);
1260
+ }
1261
+ else if (e.type === "dragleave") {
1262
+ setDragActive(false);
1263
+ }
1264
+ };
1265
+ //function to handle when user clicks on dropzone to upload
1266
+ const handleChange = (e) => {
1267
+ e.preventDefault();
1268
+ e.stopPropagation();
1269
+ if (e.target.files && !disabled) {
1270
+ filesSelected(e.target.files);
1271
+ }
1272
+ };
1273
+ //funtion to handle drop
1274
+ const handleDrop = (e) => {
1275
+ e.preventDefault();
1276
+ e.stopPropagation();
1277
+ setDragActive(false);
1278
+ if (e.dataTransfer.files && e.dataTransfer.files[0] && !disabled) {
1279
+ filesSelected(e.dataTransfer.files);
1280
+ setFileDropped(true);
1281
+ }
1282
+ };
1283
+ return (jsxRuntime.jsxs(Root$5, Object.assign({ "$disabled": disabled, "$isInvalid": isInvalid, "$dragActive": dragActive, "$fileDropped": fileDropped, "$size": size, className: className, "data-testid": dataTestId, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, onClick: e => {
1284
+ if (disabled) {
1285
+ e.preventDefault();
1286
+ e.stopPropagation();
1287
+ }
1288
+ } }, rest, { children: [jsxRuntime.jsx("input", { title: "Hidden File Input", type: "file", id: "input-file-upload", onChange: handleChange, className: "hidden" }), jsxRuntime.jsxs(DropZoneLabel, Object.assign({ htmlFor: "input-file-upload", "data-testid": dataTestId && `${dataTestId}-label` }, { children: [jsxRuntime.jsx(Icon, { type: "solid", name: "ArrowUpCircleIcon", color: isInvalid ? "danger" : "neutral", style: !isInvalid ? { color: "rgb(156 163 175)" } : {} }), jsxRuntime.jsx("span", { children: label })] }))] })));
1289
+ };
1290
+ const Root$5 = tailwindStyledComponents.tw.div `
1291
+ tu-drop-zone
1292
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-drop-zone--small` : null)}
1293
+ ${({ $size }) => ($size === "medium" ? tailwindStyledComponents.tws `tu-drop-zone--medium` : null)}
1294
+ ${({ $size }) => ($size === "large" ? tailwindStyledComponents.tws `tu-drop-zone--large` : null)}
1295
+ ${({ $dragActive }) => ($dragActive ? tailwindStyledComponents.tws `tu-drop-zone--drag-active` : null)}
1296
+ ${({ $fileDropped }) => ($fileDropped ? tailwindStyledComponents.tws `tu-drop-zone--drop-complete` : null)}
1297
+ ${({ $isInvalid }) => ($isInvalid ? tailwindStyledComponents.tws `tu-drop-zone--invalid` : null)}
1298
+ ${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-drop-zone--disabled` : null)}
1299
+ `;
1300
+ const DropZoneLabel = tailwindStyledComponents.tw.label `
1301
+ tu-drop-zone__label
1302
+ `;
1303
+
1304
+ /**
1305
+ * A Email Input component is used for input of the type Email.
1306
+ *
1307
+ * It has an ActionButton which sends an email to the specified address using "mailto:" link.
1308
+ *
1309
+ * Extends props of BaseInput.
1310
+ *
1311
+ * A reference to the input element is provided as the `ref` prop.
1312
+ * For specific input types make sure to use the corresponding input component.
1313
+ */
1314
+ const EmailInput = React__namespace.forwardRef((_a, ref) => {
1315
+ var { fieldSize = "medium", disabled = false, dataTestId } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId"]);
1316
+ const [email, setEmail] = React__namespace.useState("");
1317
+ const sendEmail = () => {
1318
+ return window.open(`mailto:${email}`);
1319
+ };
1320
+ return (jsxRuntime.jsx(BaseInput, Object.assign({ dataTestId: dataTestId, fieldSize: fieldSize, ref: ref, type: "email", placeholder: rest.placeholder || "mail@example.com", onChange: e => setEmail(e.target.value) }, rest, { actions: jsxRuntime.jsx(ActionButton, { disabled: disabled, value: email, type: "EMAIL", onClick: sendEmail, dataTestId: dataTestId && `${dataTestId}-emailIcon`, iconSize: fieldSize }) })));
1321
+ });
1322
+
1323
+ /**
1324
+ * The EmailField component is used to enter email.
1325
+ * EmailField validates that user enters a valid email address.
1326
+ *
1327
+ */
1328
+ const EmailField = React.forwardRef((_a, ref) => {
1329
+ var { label, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
1330
+ const [value, setValue] = React.useState(defaultValue);
1331
+ // Type guard to check if value is a string
1332
+ function isString(inputValue) {
1333
+ return typeof inputValue === "string";
1334
+ }
1335
+ // Check the regular expression only if value is a string
1336
+ const renderAsInvalid = !!errorMessage || (isString(value) && !/^\S+@\S+\.\S+$/.test(value));
1337
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(EmailInput, Object.assign({ ref: ref, value: value, onChange: e => setValue(e.target.value), isInvalid: renderAsInvalid, disabled: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1338
+ });
1339
+
1340
+ /**
1341
+ * The external link component is used to link to an external page outside the Trackunit Manager.
1342
+ *
1343
+ * @param {ExternalLinkProps} props - The props for the external link component
1344
+ * @returns {JSX.Element} External Link component
1345
+ */
1346
+ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className, children = href, title = href, dataTestId, }) => {
1347
+ return (jsxRuntime.jsx("a", Object.assign({ "data-testid": dataTestId, className: className, title: title, href: href, rel: rel, target: target }, { children: children })));
1348
+ };
1349
+
1350
+ /**
1351
+ * Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
1352
+ *
1353
+ * Whenever an asset is presented, indicators provide the necessary information for a user to comprehend the state of the asset.
1354
+ *
1355
+ * _**Do use** indicators to communicate essential aspects of the state of an asset._
1356
+ *
1357
+ * _**Do not use** indicators for non-essential information, or to communicate information unrelated to the state of an asset._
1358
+ *
1359
+ * @param {IndicatorProps} props - The props for the Indicator component
1360
+ * @returns {JSX.Element} Indicator component
1361
+ */
1362
+ const Indicator = (_a) => {
1363
+ var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping"]);
1364
+ return (jsxRuntime.jsxs(Container$5, Object.assign({ "$color": color, "data-testid": dataTestId }, rest, { title: !withLabel ? label : undefined }, { children: [jsxRuntime.jsxs(IconBackground, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", "$withBackground": withBackground }, { children: [ping && jsxRuntime.jsx(Ping, { "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" }), icon] })), label !== undefined && withLabel && (jsxRuntime.jsx(Label$1, Object.assign({ "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label" }, { children: label })))] })));
1365
+ };
1366
+ const Container$5 = tailwindStyledComponents.tw.div `
1367
+ tu-indicator
1368
+ ${({ $color }) => {
1369
+ switch ($color) {
1370
+ case "primary":
1371
+ return tailwindStyledComponents.tws `tu-indicator--primary`;
1372
+ case "secondary":
1373
+ return tailwindStyledComponents.tws `tu-indicator--secondary`;
1374
+ case "accent":
1375
+ return tailwindStyledComponents.tws `tu-indicator--accent`;
1376
+ case "neutral":
1377
+ return tailwindStyledComponents.tws `tu-indicator--neutral`;
1378
+ case "info":
1379
+ return tailwindStyledComponents.tws `tu-indicator--info`;
1380
+ case "success":
1381
+ return tailwindStyledComponents.tws `tu-indicator--success`;
1382
+ case "warning":
1383
+ return tailwindStyledComponents.tws `tu-indicator--warning`;
1384
+ case "danger":
1385
+ return tailwindStyledComponents.tws `tu-indicator--danger`;
1386
+ case "good":
1387
+ return tailwindStyledComponents.tws `tu-indicator--good`;
1388
+ case "low":
1389
+ return tailwindStyledComponents.tws `tu-indicator--low`;
1390
+ case "critical":
1391
+ return tailwindStyledComponents.tws `tu-indicator--critical`;
1392
+ case "working":
1393
+ return tailwindStyledComponents.tws `tu-indicator--working`;
1394
+ case "idle":
1395
+ return tailwindStyledComponents.tws `tu-indicator--idle`;
1396
+ case "stopped":
1397
+ return tailwindStyledComponents.tws `tu-indicator--stopped`;
1398
+ case "moving":
1399
+ return tailwindStyledComponents.tws `tu-indicator--moving`;
1400
+ case "unknown":
1401
+ return tailwindStyledComponents.tws `tu-indicator--unknown`;
1402
+ case "unused":
1403
+ return tailwindStyledComponents.tws `tu-indicator--unused`;
1404
+ case "utilized":
1405
+ return tailwindStyledComponents.tws `tu-indicator--utilized`;
1406
+ case "heavily_utilized":
1407
+ return tailwindStyledComponents.tws `tu-indicator--heavily-utilized`;
1408
+ case "on_rent":
1409
+ return tailwindStyledComponents.tws `tu-indicator--on-rent`;
1410
+ case "available":
1411
+ return tailwindStyledComponents.tws `tu-indicator--available`;
1412
+ case "pickup_ready":
1413
+ return tailwindStyledComponents.tws `tu-indicator--pickup-ready`;
1414
+ case "transfer":
1415
+ return tailwindStyledComponents.tws `tu-indicator--transfer`;
1416
+ case "in_repair":
1417
+ return tailwindStyledComponents.tws `tu-indicator--in-repair`;
1418
+ case "returned":
1419
+ return tailwindStyledComponents.tws `tu-indicator--returned`;
1420
+ case "other_rental_status":
1421
+ return tailwindStyledComponents.tws `tu-indicator--other-rental-status`;
1422
+ default:
1423
+ return "";
1424
+ }
1425
+ }}
1426
+ `;
1427
+ const IconBackground = tailwindStyledComponents.tw.div `
1428
+ tu-indicator__icon-background
1429
+
1430
+ ${({ $withBackground }) => {
1431
+ return $withBackground ? "" : "tu-indicator__icon-background--none";
1432
+ }}
1433
+ `;
1434
+ const Label$1 = tailwindStyledComponents.tw.div `
1435
+ tu-indicator__label
1436
+ `;
1437
+ const Ping = tailwindStyledComponents.tw.span `
1438
+ tu-indicator__ping
1439
+ `;
1440
+
1441
+ /**
1442
+ * The MenuItem component is used to display a menu, primarily meant to be used in a list form.
1443
+ *
1444
+ * @param {MenuItemProps} props - The props for the MenuItem component
1445
+ * @returns {JSX.Element} MenuItem component
1446
+ */
1447
+ const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, }) => {
1448
+ const containerProps = useContainerProps({ className, dataTestId });
1449
+ return (jsxRuntime.jsxs(Container$4, Object.assign({}, containerProps, { onClick: e => {
1450
+ e.stopPropagation();
1451
+ onClick && onClick(e);
1452
+ }, "$selected": selected, "$focused": focused, tabIndex: 0, "$disabled": disabled }, { children: [prefix && (jsxRuntime.jsx(Prefix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-prefix` }, { children: prefix }))), children && typeof children !== "string" ? (children) : (jsxRuntime.jsx(Label, Object.assign({ "data-testid": dataTestId && `${dataTestId}-label` }, { children: children !== null && children !== void 0 ? children : label }))), suffix && (jsxRuntime.jsx(Suffix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix })))] })));
1453
+ };
1454
+ const Container$4 = tailwindStyledComponents.tw.div `
1455
+ group tu-menu-item
1456
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item--selected ` : "tu-menu-item--unselected")}
1457
+ ${({ $focused }) => ($focused ? tailwindStyledComponents.tws `tu-menu-item--focused ` : "")}
1458
+ ${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-menu-item--disabled ` : "")}
1459
+
1460
+ `;
1461
+ const Suffix = tailwindStyledComponents.tw.div `
1462
+ tu-menu-item__suffix
1463
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item__suffix--selected ` : "")}
1464
+ `;
1465
+ const Prefix = tailwindStyledComponents.tw.div `
1466
+ tu-menu-item__prefix
1467
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item__prefix--selected ` : "")}
1468
+ `;
1469
+ const Label = tailwindStyledComponents.tw.div `
1470
+ tu-menu-item__label
1471
+ `;
1472
+
1473
+ /**
1474
+ * The MenuList component is used for menus and selects.
1475
+ *
1476
+ * @param {MenuListProps} props - The props for the MenuList component
1477
+ * @returns {JSX.Element} MenuList component
1478
+ */
1479
+ const MenuList = (_a) => {
1480
+ var { dataTestId, className, children, withStickyHeader = false, showDivider = false } = _a; __rest(_a, ["dataTestId", "className", "children", "withStickyHeader", "showDivider"]);
1481
+ const childrenArr = React.Children.toArray(children);
1482
+ const isLastItem = (index) => index === childrenArr.length - 1;
1483
+ return (jsxRuntime.jsx(Container$3, Object.assign({ "$withStickyHeader": withStickyHeader, "data-testid": dataTestId, className: className, tabIndex: 0, role: "list" }, { children: React.Children.map(childrenArr, (menuItem, index) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsxRuntime.jsx(Divider, {})] }))) })));
1484
+ };
1485
+ const Container$3 = tailwindStyledComponents.tw.div `
1486
+ tu-menu-list
1487
+ ${props => props.$withStickyHeader && tailwindStyledComponents.tws `tu-menu-list--sticky-header`}
1488
+ `;
1489
+ const Divider = tailwindStyledComponents.tw.hr `
1490
+ tu-menu-list__divider
1491
+ `;
1492
+
1493
+ /**
1494
+ * A kebab menu component.
1495
+ * Advice: fill it with MenuList
1496
+ *
1497
+ * @param {MoreMenuProps} props - The props for the MoreMenu component
1498
+ * @returns {JSX.Element} MoreMenu component
1499
+ */
1500
+ const MoreMenu = ({ className, dataTestId, dotsDirection = "horizontal", menuPlacement, iconProps = {
1501
+ size: "medium",
1502
+ }, iconButtonProps = {
1503
+ size: "small",
1504
+ circular: true,
1505
+ square: true,
1506
+ color: "tertiary",
1507
+ }, children, }) => {
1508
+ const [actionMenuIsOpen, setActionMenuIsOpen] = React.useState(false);
1509
+ const dotsName = dotsDirection === "horizontal" ? "EllipsisHorizontalIcon" : "EllipsisVerticalIcon";
1510
+ const actionMenuRef = React.useRef(null);
1511
+ reactBrowserHooks.useClickOutside(actionMenuRef, () => {
1512
+ setActionMenuIsOpen(false);
1513
+ });
1514
+ return (jsxRuntime.jsx(Root$4, Object.assign({ ref: actionMenuRef, className: className, "data-testid": dataTestId }, { children: jsxRuntime.jsxs(Popover, Object.assign({ placement: menuPlacement }, { children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsxRuntime.jsx(Icon, Object.assign({ name: dotsName }, iconProps)), onClick: () => {
1515
+ setActionMenuIsOpen(!actionMenuIsOpen);
1516
+ } })) }), jsxRuntime.jsx(PopoverContent, { children: children })] })) })));
1517
+ };
1518
+ const Root$4 = tailwindStyledComponents.tw.div `
1519
+ tu-more-menu
1520
+ ${({ variant }) => (variant === "primary" ? tailwindStyledComponents.tws `tu-more-menu--primary` : "")}
1521
+ `;
1522
+
1523
+ /**
1524
+ * The Backdrop for the modal.
1525
+ *
1526
+ * @param {ModalBackdropProps} props - The props for the ModalBackdrop component
1527
+ * @returns {JSX.Element} ModalBackdrop component
1528
+ */
1529
+ const ModalBackdrop = ({ children, isVisible, onClick }) => {
1530
+ const ref = React__namespace.useRef(null);
1531
+ return (jsxRuntime.jsx(Backdrop, Object.assign({ ref: ref, "$isVisible": isVisible, onMouseDown: e => {
1532
+ var _a, _b;
1533
+ // only react on click on backdrop - accessing first child to get around styled element element
1534
+ if (ref.current !== null) {
1535
+ if ((e === null || e === void 0 ? void 0 : e.target) === ((_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[0])) {
1536
+ onClick();
1537
+ }
1538
+ }
1539
+ } }, { children: children })));
1540
+ };
1541
+ const Backdrop = tailwindStyledComponents.tw.div `
1542
+ tu-modal-backdrop
1543
+ ${({ $isVisible }) => {
1544
+ return $isVisible && tailwindStyledComponents.tws `tu-modal-backdrop--show`;
1545
+ }}
1546
+ `;
1547
+
1548
+ /**
1549
+ * - Modals are used to present critical information or request user input needed to complete a user's workflow.
1550
+ * - Modals interrupt a user's workflow by design.
1551
+ * - The modal component provides a foundation for creating dialogs, lightboxes, etc.
1552
+ */
1553
+ const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, className, role = "", onDismissClick = () => {
1554
+ return;
1555
+ }, }, ref) => {
1556
+ return (jsxRuntime.jsx(ModalBackdrop, Object.assign({ isVisible: isOpen, onClick: onDismissClick }, { children: isOpen && (jsxRuntime.jsx(StyledDiv, Object.assign({ ref: ref, role: role }, { children: jsxRuntime.jsx(StyledCard, Object.assign({ dataTestId: dataTestId, className: className }, { children: children })) }))) })));
1557
+ });
1558
+ const StyledCard = tailwindStyledComponents.twx(Card) `
1559
+ tu-modal__card
1560
+ `;
1561
+ const StyledDiv = tailwindStyledComponents.tw.div `
1562
+ tu-modal__container
1563
+ `;
1564
+
1565
+ /**
1566
+ * The useModal component should be used to inform the user of important information.
1567
+ *
1568
+ * @param {UseModalProps} props - The props for the useModal hook
1569
+ * @returns {*} useModal return
1570
+ */
1571
+ const useModal = ({ closeOnOutsideClick } = {}) => {
1572
+ const modalRef = React.useRef(null);
1573
+ const { isOpen, togglePortal, openPortal, closePortal, Portal } = usePortal__default["default"]({
1574
+ closeOnOutsideClick,
1575
+ onPortalClick: ({ target }) => {
1576
+ if (!closeOnOutsideClick) {
1577
+ return;
1578
+ }
1579
+ const clickingOutsideModal = modalRef && modalRef.current && !modalRef.current.contains(target);
1580
+ if (clickingOutsideModal) {
1581
+ closePortal();
1582
+ }
1583
+ },
1584
+ });
1585
+ const PortalWrapper = (props) => (jsxRuntime.jsx(Portal, { children: jsxRuntime.jsx(Modal, Object.assign({ ref: modalRef, isOpen: isOpen }, props)) }));
1586
+ PortalWrapper.displayName = "Modal";
1587
+ const WrappedModal = React.useCallback(PortalWrapper, [Portal, isOpen]);
1588
+ return {
1589
+ Modal: WrappedModal,
1590
+ toggleModal: togglePortal,
1591
+ openModal: openPortal,
1592
+ closeModal: closePortal,
1593
+ isOpen,
1594
+ };
1595
+ };
1596
+
1597
+ /**
1598
+ * A thin wrapper around the `BaseInput` component for number input fields.
1599
+ *
1600
+ * NOTE: If shown with a label, please use the `NumberField` component instead.
1601
+ */
1602
+ const NumberInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props))));
1603
+
1604
+ /**
1605
+ * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
1606
+ *
1607
+ * _**Do use**_ the NumberField when the controls to incrementally increase or decrease makes the task easier for the user.
1608
+ *
1609
+ * _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
1610
+ */
1611
+ const NumberField = React.forwardRef((_a, ref) => {
1612
+ var { label, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
1613
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1614
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(NumberInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
1615
+ });
1616
+
1617
+ /**
1618
+ * The tag component is used to categorize elements in the ui.
1619
+ *
1620
+ * This could be to tell the state of an asset, or label a page as Beta.
1621
+ *
1622
+ * The tag is also used in multiselect components to show selected options.
1623
+ *
1624
+ * **Do:** Use short labels for easy scanning.
1625
+ *
1626
+ * @param {TagProps} props - The props for the tag component
1627
+ * @returns {JSX.Element} tag component
1628
+ */
1629
+ const Tag = React__namespace.forwardRef((_a, ref) => {
1630
+ var { className, dataTestId, children, size = "medium", onClose, color = "primary" } = _a; __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
1631
+ return (jsxRuntime.jsxs(StyledText, Object.assign({ className: className, "$size": size, "data-testid": dataTestId && `${dataTestId}-tag`, "$as": "span", "$color": color, "$withXIcon": !!onClose, ref: ref }, { children: [children, onClose && (
1632
+ // a fix for multiselect deselecting tags working together with fade out animation
1633
+ jsxRuntime.jsx(IconContainer, Object.assign({ onMouseDown: onClose }, { children: jsxRuntime.jsx(Icon, { name: "XCircleIcon", dataTestId: dataTestId + "Icon", type: "solid", style: { WebkitTransition: "-webkit-transform 0.150s" }, className: size === "medium" ? tailwindStyledComponents.tws `tu-tag__icon` : tailwindStyledComponents.tws `tu-tag__icon tu-tag__icon--small` }) })))] })));
1634
+ });
1635
+ const getSizeModifierClass = () => ({ $size, $withXIcon }) => {
1636
+ const tagSizeModifierClass = {
1637
+ medium: $withXIcon ? tailwindStyledComponents.tws `tu-tag--with-icon ` : tailwindStyledComponents.tws ` `,
1638
+ small: $withXIcon ? tailwindStyledComponents.tws `tu-tag--small tu-tag--with-icon` : tailwindStyledComponents.tws `tu-tag--small`,
1639
+ };
1640
+ return tagSizeModifierClass[$size];
1641
+ };
1642
+ const getColorModifierClass = () => ({ $color }) => {
1643
+ const colorClasses = {
1644
+ primary: tailwindStyledComponents.tws `tu-tag--primary`,
1645
+ secondary: tailwindStyledComponents.tws `tu-tag--secondary`,
1646
+ accent: tailwindStyledComponents.tws `tu-tag--accent`,
1647
+ success: tailwindStyledComponents.tws `tu-tag--success`,
1648
+ danger: tailwindStyledComponents.tws `tu-tag--danger`,
1649
+ warning: tailwindStyledComponents.tws `tu-tag--warning`,
1650
+ info: tailwindStyledComponents.tws `tu-tag--info`,
1651
+ neutral: tailwindStyledComponents.tws `tu-tag--neutral`,
1652
+ good: tailwindStyledComponents.tws `tu-tag--good`,
1653
+ low: tailwindStyledComponents.tws `tu-tag--low`,
1654
+ critical: tailwindStyledComponents.tws `tu-tag--critical`,
1655
+ working: tailwindStyledComponents.tws `tu-tag--working`,
1656
+ idle: tailwindStyledComponents.tws `tu-tag--idle`,
1657
+ stopped: tailwindStyledComponents.tws `tu-tag--stopped`,
1658
+ unknown: tailwindStyledComponents.tws `tu-tag--unknown`,
1659
+ };
1660
+ return colorClasses[$color];
1661
+ };
1662
+ const StyledText = tailwindStyledComponents.tw.span `
1663
+ tu-tag
1664
+ ${getSizeModifierClass()}
1665
+ ${getColorModifierClass()}
1666
+ `;
1667
+ const IconContainer = tailwindStyledComponents.tw.div `
1668
+ tu-tag__icon-container
1669
+ `;
1670
+
1671
+ /**
1672
+ * Pageheader component is used to display a page header.
1673
+ *
1674
+ * PageHeader can be used to highlight the page topic, display important information about the page, and carry the action items related to the current page.
1675
+ *
1676
+ * @param {PageHeaderProps} props - The props for the PageHeader component
1677
+ * @returns {JSX.Element} PageHeader component
1678
+ */
1679
+ const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, children, }) => {
1680
+ return (jsxRuntime.jsxs(StyledPageHeader, Object.assign({ className: className, "data-testid": dataTestId }, { children: [jsxRuntime.jsxs(HeadingAndAccessoriesContainer, Object.assign({ "data-testid": dataTestId && `${dataTestId}-heading-container` }, { children: [jsxRuntime.jsxs(HeadingContainer, { children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeftIcon" }) })), jsxRuntime.jsx(Heading, Object.assign({ "data-testid": dataTestId && `${dataTestId}-heading` }, { children: title })), description && (jsxRuntime.jsx(StyledTip, Object.assign({ link: isValidHttpUrl(link) ? link : undefined, dataTestId: dataTestId && `${dataTestId}-tip`, iconProps: { name: "QuestionMarkCircleIcon" }, renderAs: link ? "a" : "span" }, { children: description })))] }), tag && jsxRuntime.jsx(Tag, Object.assign({ dataTestId: dataTestId }, { children: tag })), showLoading && jsxRuntime.jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] })), jsxRuntime.jsx(ChildContainer$1, { children: children })] })));
1681
+ };
1682
+ function isValidHttpUrl(link) {
1683
+ if (!link) {
1684
+ return false;
1685
+ }
1686
+ let url;
1687
+ try {
1688
+ url = new URL(link);
1689
+ }
1690
+ catch (_) {
1691
+ return false;
1692
+ }
1693
+ return url.protocol === "http:" || url.protocol === "https:";
1694
+ }
1695
+ const StyledPageHeader = tailwindStyledComponents.tw.div `
1696
+ tu-page-header
1697
+ `;
1698
+ const HeadingAndAccessoriesContainer = tailwindStyledComponents.tw.div `
1699
+ tu-page-header__heading-accessories-container
1700
+ `;
1701
+ const HeadingContainer = tailwindStyledComponents.tw.div `
1702
+ tu-page-header__heading-container
1703
+ `;
1704
+ const Heading = tailwindStyledComponents.tw.h1 `
1705
+ tu-page-header__heading
1706
+ `;
1707
+ const ChildContainer$1 = tailwindStyledComponents.tw.div `
1708
+ tu-page-header__child-container
1709
+ `;
1710
+ const StyledTip = tailwindStyledComponents.twx(Tip) `
1711
+ ${p => (p.link ? tailwindStyledComponents.tws `tu-page-header__tip` : null)}
1712
+ `;
1713
+
1714
+ /**
1715
+ * Display placeholder lines before the data gets loaded to reduce load-time frustration.
1716
+ */
1717
+ const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId }) => {
1718
+ const skeletonLines = [];
1719
+ const getWidth = (index) => {
1720
+ if (width instanceof Array) {
1721
+ return width[index] || "100%";
1722
+ }
1723
+ return width;
1724
+ };
1725
+ const getHeight = (index) => {
1726
+ if (height instanceof Array) {
1727
+ return height[index] || "auto";
1728
+ }
1729
+ return height;
1730
+ };
1731
+ for (let i = 0; i < lines; i++) {
1732
+ skeletonLines.push(jsxRuntime.jsx(SkeletonLine, Object.assign({ "data-testid": dataTestId, "data-type": "loading-skeleton-line", className: className, style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" } }, { children: lines > 1 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u00A0" }) }), i));
1733
+ }
1734
+ // eslint-disable-next-line react/jsx-no-useless-fragment
1735
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
1736
+ });
1737
+ const SkeletonLine = tailwindStyledComponents.tw.div `
1738
+ tu-skeleton-line
1739
+ `;
1740
+
1741
+ /**
1742
+ * Pagination Description. It could be used when you need navigation for your paging feature.
1743
+ *
1744
+ * @param {IPaginationProps} props - The props for the Pagination component
1745
+ * @returns {JSX.Element} Pagination component
1746
+ */
1747
+ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, pageCount, pageIndex, loading, className, dataTestId, getTranslatedCount, onPageChange, cursorBase, }) => {
1748
+ const [page, setPage] = React.useState(pageIndex);
1749
+ const [currentPage, setCurrentPage] = React.useState(String(pageIndex !== undefined ? pageIndex + 1 : 1));
1750
+ if (!loading && pageCount === undefined) {
1751
+ throw Error("Pagination should be provided with a pageCount");
1752
+ }
1753
+ React.useEffect(() => {
1754
+ if (pageIndex !== undefined && (isNaN(pageIndex) || pageIndex < 0)) {
1755
+ setPage(pageIndex);
1756
+ setCurrentPage(String(pageIndex + 1));
1757
+ }
1758
+ }, [pageIndex, setPage, setCurrentPage, pageCount]);
1759
+ const handlePageChange = React.useCallback((action) => {
1760
+ const from = page;
1761
+ let to = from;
1762
+ let description = "";
1763
+ switch (action) {
1764
+ case "prev":
1765
+ to = from !== undefined ? from - 1 : 0;
1766
+ previousPage();
1767
+ description = "Previous Page";
1768
+ break;
1769
+ case "next":
1770
+ to = from !== undefined ? from + 1 : 0;
1771
+ nextPage();
1772
+ description = "Next Page";
1773
+ break;
1774
+ }
1775
+ if (to !== undefined && to >= 0) {
1776
+ setPage(to);
1777
+ setCurrentPage(String(to + 1));
1778
+ }
1779
+ onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange({ from, to, description });
1780
+ }, [page, onPageChange, previousPage, nextPage]);
1781
+ if (loading) {
1782
+ return (jsxRuntime.jsx(Root$3, Object.assign({ className: className }, { children: jsxRuntime.jsx(SkeletonLines, { height: 16, width: 150 }) })));
1783
+ }
1784
+ return (jsxRuntime.jsxs(Root$3, Object.assign({ "data-testid": dataTestId, className: className }, { children: [jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronLeftIcon", size: "small" }), size: "small", color: "secondary", variant: "transparent" }), !cursorBase && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TextStyled, Object.assign({ dataTestId: "current-page" }, { children: currentPage })), jsxRuntime.jsx(TextStyled, Object.assign({ dataTestId: "page-count" }, { children: pageCount !== null && pageCount !== undefined && getTranslatedCount(pageCount) }))] })), jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
1785
+ ? !canNextPage || false
1786
+ : page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronRightIcon", size: "small" }), size: "small", color: "secondary", variant: "transparent" })] })));
1787
+ };
1788
+ const Root$3 = tailwindStyledComponents.tw.div `
1789
+ tu-pagination
1790
+ `;
1791
+ const TextStyled = tailwindStyledComponents.twx(Text$1) `
1792
+ tu-pagination__text
1793
+ `;
1794
+
1795
+ /**
1796
+ * The SelectContainer component.
1797
+ *
1798
+ * @param {SelectContainerProps} props - The props for the SelectContainer component
1799
+ * @returns {JSX.Element} SelectContainer component
1800
+ */
1801
+ const SelectContainer$1 = ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, isDisabled, }) => {
1802
+ return (jsxRuntime.jsxs(Container$2, Object.assign({ "data-testid": dataTestId, "$hasError": hasError, "$isDisabled": isDisabled }, { children: [label && !hideLabel && jsxRuntime.jsx(Label$2, Object.assign({ htmlFor: id }, { children: label })), children, (hasError || info) && (jsxRuntime.jsx(InformativeText, Object.assign({ size: "small", "$hasError": hasError !== null && hasError !== void 0 ? hasError : false }, { children: hasError ? error : info })))] })));
1803
+ };
1804
+ const Container$2 = tailwindStyledComponents.tw.label `
1805
+ tu-select__container
1806
+ tu-select
1807
+ ${({ $hasError }) => ($hasError ? tailwindStyledComponents.tws `tu-select--invalid` : null)}
1808
+ ${({ $isDisabled }) => ($isDisabled ? tailwindStyledComponents.tws `tu-select--disabled` : null)}
1809
+ `;
1810
+ const InformativeText = tailwindStyledComponents.twx(Text$1) `
1811
+ tu-informative-text
1812
+ ${p => (p.$hasError ? `tu-informative-text--error` : null)}
1813
+ `;
1814
+
1815
+ /**
1816
+ * @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
1817
+ * @returns {arg is MultiValue<Option> } is Multivalue
1818
+ */
1819
+ function isMultiValue(arg) {
1820
+ return Array.isArray(arg);
1821
+ }
1822
+ function isGroupBase(arg) {
1823
+ return arg.options !== undefined;
1824
+ }
1825
+ const isSelectedOption = (option, selected) => {
1826
+ if (isGroupBase(option)) {
1827
+ return false;
1828
+ }
1829
+ return isMultiValue(selected)
1830
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
1831
+ selected.some(v => v.value === option.value)
1832
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
1833
+ option.value === (selected === null || selected === void 0 ? void 0 : selected.value);
1834
+ };
1835
+ const removeSelectedFromGroups = (group, selected) => {
1836
+ if (isGroupBase(group)) {
1837
+ return Object.assign(Object.assign({}, group), { options: group.options.filter(option => !isSelectedOption(option, selected)) });
1838
+ }
1839
+ return group;
1840
+ };
1841
+ /**
1842
+ * @template IsMulti
1843
+ * @template Group
1844
+ * @param {OptionsOrGroups<Option, Group> | undefined} options An array of options to select from
1845
+ * @param {PropsValue<Option> | undefined} value Selected values
1846
+ * @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
1847
+ */
1848
+ const getOrderedOptions = (options, value) => {
1849
+ if (value && options) {
1850
+ const orderedValues = isMultiValue(value)
1851
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
1852
+ [...value].sort((a, b) => a.label.localeCompare(b.label))
1853
+ : [value];
1854
+ const selectableOptions = options
1855
+ .filter(option => !isSelectedOption(option, value))
1856
+ .map(option => removeSelectedFromGroups(option, value));
1857
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1858
+ return orderedValues.concat(selectableOptions) || [];
1859
+ }
1860
+ return options || [];
1861
+ };
1862
+ const SelectPrefix = tailwindStyledComponents.tw.div `
1863
+ tu-select__prefix
1864
+ `;
1865
+
1866
+ /**
1867
+ * A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
1868
+ *
1869
+ * @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
1870
+ * @returns {JSX.Element} SingleSelectMenuItem
1871
+ */
1872
+ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focused, disabled, }) => {
1873
+ return (jsxRuntime.jsx(MenuItem, { dataTestId: dataTestId, label: label, prefix: icon, onClick: onClick, selected: selected, disabled: disabled, focused: focused, suffix: selected ? jsxRuntime.jsx(Icon, { name: "CheckIcon", size: "small" }) : undefined }));
1874
+ };
1875
+ /**
1876
+ * A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
1877
+ *
1878
+ * @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
1879
+ * @returns {JSX.Element} multi select menu item
1880
+ */
1881
+ const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, focused, disabled, }) => {
1882
+ return (jsxRuntime.jsx(MenuItem, { dataTestId: dataTestId, label: label, disabled: disabled, prefix: jsxRuntime.jsx(Checkbox, { checked: selected, readOnly: false, onChange: () => null, disabled: disabled, onClick: e => {
1883
+ e.stopPropagation();
1884
+ } }), onClick: e => {
1885
+ e.stopPropagation();
1886
+ onClick && onClick(e);
1887
+ }, selected: selected, focused: focused }));
1888
+ };
1889
+
1890
+ /**
1891
+ * Extended Tag component with information about its own width.
1892
+ * Used in the select component.
1893
+ *
1894
+ * @param {TagProps} props - The props for the tag component
1895
+ * @returns {JSX.Element} TagWithWidth component
1896
+ */
1897
+ const TagWithWidth = (_a) => {
1898
+ var { onWidthKnown, children } = _a, rest = __rest(_a, ["onWidthKnown", "children"]);
1899
+ const ref = React__default["default"].useRef(null);
1900
+ React__default["default"].useLayoutEffect(() => {
1901
+ var _a;
1902
+ onWidthKnown && onWidthKnown({ width: ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0 });
1903
+ }, [ref, onWidthKnown]);
1904
+ return (jsxRuntime.jsx(Tag, Object.assign({ ref: ref }, rest, { children: children })));
1905
+ };
1906
+
1907
+ /**
1908
+ * TagsContainer component to display tags in limited space when children can't fit space it displays counter
1909
+ *
1910
+ * @param {TagsContainerProps} props - The props for the TagContainer
1911
+ * @returns {JSX.Element} TagsContainer
1912
+ */
1913
+ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix }) => {
1914
+ const [isReady, setIsReady] = React__default["default"].useState(false);
1915
+ const [counterWidth, setCounterWidth] = React__default["default"].useState(0);
1916
+ const containerRef = React__default["default"].useRef(null);
1917
+ const availableWidth = React__default["default"].useRef();
1918
+ const childrenWidth = React__default["default"].useRef([]);
1919
+ const itemsCount = items.length;
1920
+ React__default["default"].useLayoutEffect(() => {
1921
+ var _a;
1922
+ availableWidth.current = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1923
+ }, [containerRef]);
1924
+ const onWidthKnownHandler = ({ width: reportedWidth }) => {
1925
+ childrenWidth.current.push({ width: reportedWidth + itemsGap });
1926
+ if (childrenWidth.current.length === itemsCount) {
1927
+ setIsReady(true);
1928
+ }
1929
+ };
1930
+ const requiredSpace = childrenWidth.current.reduce((previous, current) => {
1931
+ return previous + current.width;
1932
+ }, 0);
1933
+ let counter = 0;
1934
+ const availableSpace = ((availableWidth === null || availableWidth === void 0 ? void 0 : availableWidth.current) || 0) - counterWidth;
1935
+ const renderedElements = items
1936
+ .concat({ text: "", onClick: () => null, disabled: false }) // reserved element for a potential counter
1937
+ .map((item, index) => {
1938
+ const spaceNeeded = childrenWidth.current.slice(0, index + 1).reduce((previous, current) => {
1939
+ return previous + current.width;
1940
+ }, 0);
1941
+ const isLast = index === items.length;
1942
+ const counterRequired = requiredSpace > availableSpace && counter !== 0;
1943
+ if (isLast && counterRequired) {
1944
+ return (jsxRuntime.jsx(TagWithWidth, Object.assign({ onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth), color: "neutral" }, { children: jsxRuntime.jsxs(Counter, { children: ["+", counter] }) }), item.text + index));
1945
+ }
1946
+ if (isLast) {
1947
+ return null;
1948
+ }
1949
+ const itemCanFit = spaceNeeded <= availableSpace;
1950
+ if (itemCanFit) {
1951
+ return (jsxRuntime.jsx(TagWithWidth, Object.assign({ onWidthKnown: onWidthKnownHandler, className: tailwindStyledComponents.tws `shrink-0 inline-flex`, onClose: e => {
1952
+ e.stopPropagation();
1953
+ item.onClick();
1954
+ }, color: item.disabled ? "unknown" : "primary", dataTestId: item.text }, { children: item.text }), item.text + index));
1955
+ }
1956
+ const fromTheItems = item.text !== "";
1957
+ if (fromTheItems) {
1958
+ counter = counter + 1;
1959
+ }
1960
+ return null;
1961
+ })
1962
+ .filter(element => element !== null);
1963
+ return (jsxRuntime.jsxs(Container$1, Object.assign({ style: {
1964
+ width: `${width}`,
1965
+ }, "$ready": isReady, ref: containerRef }, { children: [renderedElements, postFix] })));
1966
+ };
1967
+ const Container$1 = tailwindStyledComponents.tw.div `
1968
+ tu-select__dynamic-tag--container
1969
+ ${({ $ready }) => {
1970
+ return $ready ? tailwindStyledComponents.tws `visible` : tailwindStyledComponents.tws `invisible`;
1971
+ }}
1972
+ `;
1973
+ const Counter = tailwindStyledComponents.tw.div `
1974
+ tu-select__counter
1975
+ `;
1976
+
1977
+ /**
1978
+ * A hook to retrieve components override object.
1979
+ * This complex object includes all the compositional components that are used in react-select. If you wish to overwrite a component, pass in an object with the appropriate namespace.
1980
+ *
1981
+ * @template IsMulti
1982
+ * @template Group
1983
+ * @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
1984
+ * @param {boolean} disabled decide to override disabled variant
1985
+ * @param {boolean} menuIsOpen menu is open state
1986
+ * @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
1987
+ * @param {string} dataTestId a test id
1988
+ * @param {number} maxSelectedDisplayCount a number of max display count
1989
+ * @param {JSX.Element} dropdownIcon an custom dropdown icon
1990
+ * @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
1991
+ */
1992
+ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
1993
+ // perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
1994
+ const customComponents = React__namespace.useMemo(() => {
1995
+ return Object.assign({ ValueContainer: props => {
1996
+ if (props.isMulti) {
1997
+ const PLACEHOLDER_KEY = "placeholder";
1998
+ const key = props && props.children && props.children[0] ? props.children[0].key : "";
1999
+ const values = props && props.children ? props.children[0] : [];
2000
+ const tags = key === PLACEHOLDER_KEY ? [] : values;
2001
+ const searchInput = props && props.children && props.children[1];
2002
+ return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled }, { children: maxSelectedDisplayCount === undefined ? (jsxRuntime.jsx(TagsContainer, { width: "100%", items: tags
2003
+ ? tags.map(({ props: tagProps }) => {
2004
+ return {
2005
+ text: tagProps.children,
2006
+ onClick: disabled
2007
+ ? undefined
2008
+ : (e) => {
2009
+ var _a, _b;
2010
+ refMenuIsEnabled.current = false;
2011
+ ((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
2012
+ },
2013
+ disabled: disabled,
2014
+ };
2015
+ })
2016
+ : [], postFix: searchInput })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [tags &&
2017
+ tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
2018
+ var _a, _b;
2019
+ return (jsxRuntime.jsx(Tag, Object.assign({ className: tailwindStyledComponents.tws `shrink-0 inline-flex`, onClose: e => {
2020
+ var _a, _b;
2021
+ e.stopPropagation();
2022
+ refMenuIsEnabled.current = false;
2023
+ ((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
2024
+ }, color: disabled ? "unknown" : "primary", dataTestId: (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString() }, { children: tagProps.children }), (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
2025
+ }), tags && tags.length > maxSelectedDisplayCount && (jsxRuntime.jsxs(Tag, Object.assign({ color: "neutral", dataTestId: "counter" }, { children: ["+", tags.length - maxSelectedDisplayCount] }))), searchInput] })) })));
2026
+ }
2027
+ return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled }, { children: props.children })));
2028
+ }, LoadingIndicator: props => {
2029
+ return jsxRuntime.jsx(Spinner, { size: "small", className: tailwindStyledComponents.tws `mt-1.5 mr-1` });
2030
+ }, DropdownIndicator: props => {
2031
+ const icon = props.selectProps.menuIsOpen ? (jsxRuntime.jsx(Icon, { name: "ChevronUpIcon", size: "medium" })) : (jsxRuntime.jsx(Icon, { name: "ChevronDownIcon", size: "medium" }));
2032
+ return props.selectProps.isLoading ? null : (jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, Object.assign({}, props, { children: jsxRuntime.jsx(StyledIcon, { children: dropdownIcon ? dropdownIcon : icon }) })));
2033
+ }, IndicatorSeparator: () => null, ClearIndicator: props => {
2034
+ if (disabled) {
2035
+ return null;
2036
+ }
2037
+ return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, Object.assign({}, props, { children: jsxRuntime.jsx(XMarkIcon, Object.assign({ onClick: props.clearValue, "data-testid": dataTestId && `${dataTestId}-XMarkIcon` }, { children: jsxRuntime.jsx(Icon, { name: "XCircleIcon", size: "medium" }) })) })));
2038
+ }, Control: props => {
2039
+ return (jsxRuntime.jsx(ReactSelect.components.Control, Object.assign({}, props, { className: props.isDisabled ? tailwindStyledComponents.tws `tu-select__control--disabled` : "" })));
2040
+ }, SingleValue: props => {
2041
+ return (jsxRuntime.jsx(ReactSelect.components.SingleValue, Object.assign({}, props, { className: props.isDisabled ? tailwindStyledComponents.tws `tu-select__single-value--disabled` : "" }, { children: jsxRuntime.jsx("div", Object.assign({ "data-testid": dataTestId + "-singleValue" }, { children: props.children })) })));
2042
+ }, Menu: props => {
2043
+ return (jsxRuntime.jsx(ReactSelect.components.Menu, Object.assign({}, props, { className: props.selectProps.menuIsOpen
2044
+ ? tailwindStyledComponents.tws `tu-select__menu-list animate-fade-in-fast`
2045
+ : tailwindStyledComponents.tws `tu-select__menu-list animate-fade-out-fast` })));
2046
+ }, Option: props => {
2047
+ const componentProps = {
2048
+ label: props.label,
2049
+ focused: props.isFocused,
2050
+ selected: props.isSelected,
2051
+ onClick: props.innerProps.onClick,
2052
+ };
2053
+ return (jsxRuntime.jsx(ReactSelect.components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }) }, { children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, Object.assign({}, componentProps, { disabled: disabled, dataTestId: props.label }))) : (jsxRuntime.jsx(SingleSelectMenuItem, Object.assign({}, componentProps, { disabled: disabled || props.isDisabled, dataTestId: props.label }))) })));
2054
+ } }, componentsProps);
2055
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2056
+ }, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
2057
+ return customComponents;
2058
+ };
2059
+ const StyledIcon = tailwindStyledComponents.tw.div `
2060
+ tu-select--icon
2061
+ `;
2062
+ const XMarkIcon = tailwindStyledComponents.tw.div `
2063
+ tu-select--icon
2064
+ tu-select__x-icon
2065
+ `;
2066
+
2067
+ /**
2068
+ * @template IsMulti
2069
+ * @template Group
2070
+ * @param {React.RefObject<HTMLDivElement>} refContainer react ref to container element
2071
+ * @param {React.RefObject<HTMLDivElement>} refPrefix react ref to prefix element
2072
+ * @param {number | undefined} maxSelectedDisplayCount a number of max display count
2073
+ * @param {StylesConfig<Option, IsMulti, Group> | undefined} styles a optional object to override styles of react-select
2074
+ * @returns {StylesConfig<Option, boolean>} styles to override in select
2075
+ */
2076
+ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, styles) => {
2077
+ const customStyles = React__namespace.useMemo(() => {
2078
+ return Object.assign({ control: base => {
2079
+ return Object.assign(Object.assign({}, base), { border: "0", boxShadow: "0", "&:hover": {
2080
+ border: "0",
2081
+ }, marginRight: "2px", backgroundColor: "" });
2082
+ }, singleValue: base => (Object.assign({}, base)), multiValue: base => (Object.assign({}, base)), multiValueLabel: base => (Object.assign({}, base)), indicatorsContainer: base => (Object.assign({}, base)), indicatorSeparator: () => ({
2083
+ width: "0px",
2084
+ }), menu: base => {
2085
+ return Object.assign(Object.assign({}, base), { width: "100%", marginTop: "4px", marginBottom: "18px", transition: "all 1s ease-in-out" });
2086
+ }, input: base => (Object.assign(Object.assign({}, base), { marginLeft: "0px" })), placeholder: base => (Object.assign({}, base)), option: () => ({}), menuPortal: base => (Object.assign(Object.assign({}, base), { width: (refContainer === null || refContainer === void 0 ? void 0 : refContainer.current) ? `${refContainer.current.clientWidth}px` : base.width, transform: (refPrefix === null || refPrefix === void 0 ? void 0 : refPrefix.current) ? `translate(-${refPrefix.current.clientWidth + 2}px)` : "translate(-2px)", backgroundColor: "#ffffff", borderRadius: "var(--border-radius-lg)", zIndex: 20, borderColor: "rgb(var(--color-slate-300))", boxShadow: "var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)" })), menuList: base => {
2087
+ return Object.assign(Object.assign({}, base), { position: "relative", padding: "var(--spacing-1)", display: "grid", gap: "var(--spacing-1)", width: "100%", borderRadius: "0px", boxShadow: "none", paddingTop: "0px" });
2088
+ }, valueContainer: base => {
2089
+ return Object.assign(Object.assign({}, base), { flexWrap: maxSelectedDisplayCount !== undefined ? "wrap" : "nowrap", gap: "0.25rem" });
2090
+ }, container: base => (Object.assign(Object.assign({}, base), { border: "none", width: "calc(100% - 2px)", paddingLeft: "2px" })), dropdownIndicator: base => (Object.assign(Object.assign({}, base), { padding: "0px" })), clearIndicator: base => {
2091
+ return Object.assign(Object.assign({}, base), { padding: "0px" });
2092
+ } }, styles);
2093
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2094
+ }, [refContainer, refPrefix]);
2095
+ return { customStyles };
2096
+ };
2097
+
2098
+ /**
2099
+ * A hook used by selects to share the common code
2100
+ *
2101
+ * @param {SelectProps} props - The props for the Select component
2102
+ * @returns {IUseSelect} Select component
2103
+ */
2104
+ const useSelect = (_a) => {
2105
+ var _b;
2106
+ var { id, className, dataTestId = "select", prefix, async, dropdownIcon, maxMenuHeight = 200, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix = "", onMenuOpen, onMenuClose, maxSelectedDisplayCount = undefined, isClearable = false, isSearchable = true, onMenuScrollToBottom, styles, filterOption, onInputChange } = _a, props = __rest(_a, ["id", "className", "dataTestId", "prefix", "async", "dropdownIcon", "maxMenuHeight", "label", "hasError", "disabled", "isMulti", "components", "value", "options", "onChange", "isLoading", "classNamePrefix", "onMenuOpen", "onMenuClose", "maxSelectedDisplayCount", "isClearable", "isSearchable", "onMenuScrollToBottom", "styles", "filterOption", "onInputChange"]);
2107
+ const refContainer = React__default["default"].useRef(null);
2108
+ const refPrefix = React__default["default"].useRef(null);
2109
+ const { customStyles } = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
2110
+ const [menuIsOpen, setMenuIsOpen] = React__default["default"].useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
2111
+ const refMenuIsEnabled = React__default["default"].useRef(true);
2112
+ const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
2113
+ const menuPlacement = "auto";
2114
+ const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
2115
+ onMenuOpen && onMenuOpen();
2116
+ if (refMenuIsEnabled.current) {
2117
+ setMenuIsOpen(true);
2118
+ }
2119
+ else {
2120
+ refMenuIsEnabled.current = true;
2121
+ }
2122
+ });
2123
+ const closeMenuHandler = () => {
2124
+ setMenuIsOpen(false);
2125
+ onMenuClose && onMenuClose();
2126
+ };
2127
+ const orderedOptions = React__default["default"].useMemo(() => {
2128
+ return disabled
2129
+ ? getOrderedOptions(options, value).map(option => {
2130
+ return Object.assign(Object.assign({}, option), { disabled: true });
2131
+ })
2132
+ : getOrderedOptions(options, value);
2133
+ }, [options, value, disabled]);
2134
+ return {
2135
+ refContainer,
2136
+ refPrefix,
2137
+ customStyles,
2138
+ menuIsOpen,
2139
+ customComponents,
2140
+ menuPlacement,
2141
+ openMenuHandler,
2142
+ closeMenuHandler,
2143
+ orderedOptions,
2144
+ };
2145
+ };
2146
+
2147
+ /**
2148
+ * The CreatableSelect component.
2149
+ *
2150
+ * @param {CreateableSelectProps} props - The props for the CreatableSelect component
2151
+ * @returns {JSX.Element} CreatableSelect component
2152
+ */
2153
+ const CreatableSelect = (props) => {
2154
+ const { id, dataTestId = "select", async, maxMenuHeight = 200, label, error, disabled, isMulti, value, hideLabel, description, info, options, onChange, isLoading, classNamePrefix = "", filterOption, prefix, } = props;
2155
+ const hasError = !!error;
2156
+ const { refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
2157
+ const selectProps = {
2158
+ value,
2159
+ menuPlacement,
2160
+ maxMenuHeight,
2161
+ onChange,
2162
+ "aria-label": label,
2163
+ "data-testid": dataTestId,
2164
+ components: customComponents,
2165
+ styles: customStyles,
2166
+ tabSelectsValue: false,
2167
+ blurInputOnSelect: !isMulti,
2168
+ menuPortalTarget: document.body,
2169
+ isSearchable: disabled ? false : true,
2170
+ menuShouldBlockScroll: true,
2171
+ menuShouldScrollIntoView: true,
2172
+ openMenuOnFocus: disabled ? false : true,
2173
+ menuIsOpen: disabled ? false : menuIsOpen,
2174
+ openMenuOnClick: true,
2175
+ closeMenuOnSelect: false,
2176
+ isMulti: isMulti,
2177
+ classNamePrefix,
2178
+ isLoading,
2179
+ id,
2180
+ };
2181
+ return (jsxRuntime.jsx(SelectContainer$1, Object.assign({ label: label, hideLabel: hideLabel, id: id, hasError: hasError, error: error, description: description, info: info, dataTestId: dataTestId, isDisabled: disabled }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [prefix !== undefined && (jsxRuntime.jsx(SelectPrefix, Object.assign({ "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix }, { children: prefix }))), async ? (jsxRuntime.jsx(ReactAsyncCreatableSelect__default["default"], Object.assign({ "aria-label": label, maxMenuHeight: maxMenuHeight, "data-testid": dataTestId, components: customComponents }, props, { onMenuOpen: () => {
2182
+ !disabled && openMenuHandler();
2183
+ }, onMenuClose: () => {
2184
+ closeMenuHandler();
2185
+ } }))) : (jsxRuntime.jsx(ReactCreatableSelect__default["default"], Object.assign({}, selectProps, { options: filterOption ? orderedOptions : options, isMulti: isMulti, onMenuOpen: () => {
2186
+ !disabled && openMenuHandler();
2187
+ }, onMenuClose: () => {
2188
+ closeMenuHandler();
2189
+ } })))] }) })));
2190
+ };
2191
+
2192
+ /**
2193
+ * Selects are input components used to choose a value from a set.
2194
+ *
2195
+ * @param {SelectProps} props - The props for the Select component
2196
+ * @returns {JSX.Element} Select component
2197
+ */
2198
+ const Select = (props) => {
2199
+ const { className } = props, propsNoClassName = __rest(props, ["className"]);
2200
+ const { id, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = "", onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable, } = props;
2201
+ const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
2202
+ const selectProps = {
2203
+ value,
2204
+ menuPlacement,
2205
+ maxMenuHeight,
2206
+ onChange,
2207
+ "aria-label": label,
2208
+ "data-testid": dataTestId,
2209
+ components: customComponents,
2210
+ styles: customStyles,
2211
+ tabSelectsValue: false,
2212
+ blurInputOnSelect: !isMulti,
2213
+ menuPortalTarget: props.menuPortalTarget || document.body,
2214
+ isSearchable: disabled ? false : isSearchable,
2215
+ menuShouldBlockScroll: true,
2216
+ menuShouldScrollIntoView: true,
2217
+ openMenuOnFocus: true,
2218
+ menuIsOpen,
2219
+ openMenuOnClick: true,
2220
+ closeMenuOnSelect: false,
2221
+ isMulti,
2222
+ classNamePrefix,
2223
+ isLoading,
2224
+ isClearable,
2225
+ id,
2226
+ onMenuScrollToBottom,
2227
+ onInputChange,
2228
+ };
2229
+ return (jsxRuntime.jsxs(SelectContainer, Object.assign({ ref: refContainer, className: className, "data-testid": dataTestId, "$hasError": hasError, "$isDisabled": disabled }, { children: [prefix !== undefined && (jsxRuntime.jsx(SelectPrefix, Object.assign({ "data-testid": dataTestId && `${dataTestId}-prefix`, ref: refPrefix }, { children: prefix }))), async ? (jsxRuntime.jsx(ReactAsyncSelect__default["default"], Object.assign({}, propsNoClassName, selectProps, async, { onMenuOpen: openMenuHandler, onMenuClose: closeMenuHandler }))) : (jsxRuntime.jsx(ReactSelect__default["default"], Object.assign({}, propsNoClassName, selectProps, { options: filterOption ? orderedOptions : options, hideSelectedOptions: false, isMulti: isMulti, onMenuOpen: openMenuHandler, onMenuClose: closeMenuHandler })))] })));
2230
+ };
2231
+ const SelectContainer = tailwindStyledComponents.tw.div `
2232
+ tu-select
2233
+ ${({ $hasError }) => ($hasError ? tailwindStyledComponents.tws `tu-select--invalid` : null)}
2234
+ ${({ $isDisabled }) => ($isDisabled ? tailwindStyledComponents.tws `tu-select--disabled` : null)}
2235
+ `;
2236
+ Select.displayName = "Select";
2237
+
2238
+ const COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND = ["53", "98", "211", "247", "249", "383", "850", "963"];
2239
+ const ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND = [
2240
+ "1242",
2241
+ "1246",
2242
+ "1264",
2243
+ "1268",
2244
+ "1284",
2245
+ "1340",
2246
+ "1345",
2247
+ "1441",
2248
+ "1473",
2249
+ "1649",
2250
+ "1664",
2251
+ "1670",
2252
+ "1671",
2253
+ "1684",
2254
+ "1721",
2255
+ "1758",
2256
+ "1767",
2257
+ "1784",
2258
+ "1809",
2259
+ "1868",
2260
+ "1869",
2261
+ "1876",
2262
+ "379",
2263
+ "5999",
2264
+ "881",
2265
+ "882",
2266
+ "883",
2267
+ ];
2268
+ const countryCodesSet = [
2269
+ ...new Set(libphonenumberJs.getCountries().map(code => libphonenumberJs.getCountryCallingCode(code))),
2270
+ ...ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND,
2271
+ ]
2272
+ .filter(code => !COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND.includes(code))
2273
+ .sort((a, b) => Number(a) - Number(b));
2274
+ const countryCodes = countryCodesSet.map(code => ({ label: `+${code}`, value: code }));
2275
+
2276
+ /**
2277
+ * The CountryCodeSelect component is used to select a country code for a phone number.
2278
+ *
2279
+ * @param {CountryCodeSelectProps} props - The props for the CountryCodeSelect component
2280
+ * @returns {JSX.Element} CountryCodeSelect component
2281
+ */
2282
+ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, setCountryCode, }) => {
2283
+ const [isCountryCodeMissing, setIsCountryCodeMissing] = React.useState(false);
2284
+ React.useEffect(() => {
2285
+ countryCode && setIsCountryCodeMissing(false);
2286
+ }, [countryCode]);
2287
+ const filteredCodes = countryCodes.filter(code => {
2288
+ return !(excludedCountries === null || excludedCountries === void 0 ? void 0 : excludedCountries.some(excludedCode => excludedCode.value === code.value));
2289
+ });
2290
+ return (jsxRuntime.jsx(Select, { className: "w-28", "aria-invalid": isCountryCodeMissing, options: filteredCodes.map(code => code), value: filteredCodes.find(({ value: currentValue }) => currentValue === countryCode), onChange: input => {
2291
+ setCountryCode(input === null || input === void 0 ? void 0 : input.value);
2292
+ }, placeholder: "+45", hasError: isCountryCodeMissing || isInvalid, maxMenuHeight: 200 }));
2293
+ };
2294
+
2295
+ /**
2296
+ * A component for inputting phone numbers with an optional action button for initiating a phone call.
2297
+ *
2298
+ * @param {string} [dataTestId] - The data test ID for the component.
2299
+ * @param {boolean} [disabled=false] - Whether the component is disabled or not.
2300
+ * @param {string} [fieldSize="medium"] - The size of the input field.
2301
+ * @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
2302
+ * @returns {JSX.Element} - The PhoneInput component.
2303
+ */
2304
+ const PhoneInput = React.forwardRef((_a, ref) => {
2305
+ var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction"]);
2306
+ const [phoneNumber, setPhoneNumber] = React.useState();
2307
+ const [renderAsInvalid, setRenderAsInvalid] = React.useState(false);
2308
+ const [countryCode, setCountryCode] = React.useState(undefined);
2309
+ const [isPhoneNumberInvalid, setIsPhoneNumberInvalid] = React.useState(false);
2310
+ const handlePhoneNumberChange = (e) => {
2311
+ const input = e.target.value;
2312
+ setIsPhoneNumberInvalid(!Boolean(input));
2313
+ setPhoneNumber(input);
2314
+ };
2315
+ React.useEffect(() => {
2316
+ setRenderAsInvalid(isInvalid || isPhoneNumberInvalid);
2317
+ }, [isInvalid, isPhoneNumberInvalid]);
2318
+ return (jsxRuntime.jsxs(Container, { children: [jsxRuntime.jsx(CountryCodeSelect, { isInvalid: renderAsInvalid, countryCode: countryCode, setCountryCode: setCountryCode }), jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, dataTestId: dataTestId, isInvalid: renderAsInvalid, fieldSize: fieldSize, type: "tel", value: phoneNumber, onChange: handlePhoneNumberChange, disabled: disabled, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { disabled: !countryCode || !phoneNumber || disabled || renderAsInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
2319
+ });
2320
+ const Container = tailwindStyledComponents.tw.div `
2321
+ grid
2322
+ grid-cols-min-fr
2323
+ gap-2
2324
+ `;
2325
+
2326
+ /**
2327
+ * The PhoneField component is used to enter phone number.
2328
+ * It is a wrapper around the PhoneInput component and the FormGroup component.
2329
+ * It is used to render a phone number field with a label, a tip, a help text, a help addon and an error message.
2330
+ *
2331
+ * @param {string} [label] - The label for the component.
2332
+ * @param {string} [tip] - The tip for the component.
2333
+ * @param {string} [helpText] - The help text for the component.
2334
+ * @param {string} [helpAddon] - The help addon for the component.
2335
+ * @param {string} [errorMessage] - The error message for the component.
2336
+ * @param {string} [defaultValue] - The default value for the component.
2337
+ * @param {boolean} [disabled=false] - Whether the component is disabled or not.
2338
+ * @param {string} [fieldSize="medium"] - The size of the input field.
2339
+ * @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
2340
+ * @returns {JSX.Element} - The PhoneField component.
2341
+ */
2342
+ const PhoneField = React.forwardRef((_a, ref) => {
2343
+ var { label, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "isInvalid", "errorMessage", "value", "helpAddon", "className", "defaultValue", "dataTestId"]);
2344
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2345
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(PhoneInput, Object.assign({ value: value || defaultValue, isInvalid: renderAsInvalid }, rest)) })));
2346
+ });
2347
+
2348
+ function useConfirmExit(confirmExit, when = true) {
2349
+ const { navigator } = React.useContext(reactRouterDom.UNSAFE_NavigationContext);
2350
+ React.useEffect(() => {
2351
+ if (!when) {
2352
+ return;
2353
+ }
2354
+ const push = navigator.push;
2355
+ navigator.push = (...args) => {
2356
+ const result = confirmExit();
2357
+ if (result !== false) {
2358
+ push(...args);
2359
+ }
2360
+ };
2361
+ return () => {
2362
+ navigator.push = push;
2363
+ };
2364
+ }, [navigator, confirmExit, when]);
2365
+ }
2366
+ /**
2367
+ * The usePrompt hook.
2368
+ *
2369
+ * @param {string} message -
2370
+ * @param {boolean} when -
2371
+ * @returns {void} void
2372
+ */
2373
+ const usePrompt = (message, when = true) => {
2374
+ React.useEffect(() => {
2375
+ if (when) {
2376
+ window.onbeforeunload = function () {
2377
+ return message;
2378
+ };
2379
+ }
2380
+ return () => {
2381
+ window.onbeforeunload = null;
2382
+ };
2383
+ }, [message, when]);
2384
+ const confirmExit = React.useCallback(() => {
2385
+ const confirm = window.confirm(message);
2386
+ return confirm;
2387
+ }, [message]);
2388
+ useConfirmExit(confirmExit, when);
2389
+ };
2390
+ /**
2391
+ * The Prompt function.
2392
+ *
2393
+ * @param {PromptProps} Props -
2394
+ * @returns {void} void
2395
+ */
2396
+ const Prompt = ({ when, message }) => {
2397
+ usePrompt(message, when);
2398
+ return null;
2399
+ };
2400
+
2401
+ const RadioGroupContext = React__namespace.createContext(null);
2402
+
2403
+ /**
2404
+ * Use radio buttons when you have a group of mutually exclusive choices and only one selection from the group is allowed.
2405
+ *
2406
+ * Radio buttons are used for mutually exclusive choices, not for multiple choices. Only one radio button can be selected at a time. When a user chooses a new item, the previous choice is automatically deselected.
2407
+ *
2408
+ * _**Do use** Radio buttons in forms, settings, or selections in a list._
2409
+ *
2410
+ * _**Do not use** Radio buttons if a user can select many option from a list, use checkboxes instead of radio buttons._
2411
+ *
2412
+ * @param {RadioGroupProps} props - The props for the RadioGroup component
2413
+ * @returns {JSX.Element} RadioGroup component
2414
+ */
2415
+ const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
2416
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(Flex, Object.assign({ "$inline": inline, className: className, "data-testid": dataTestId }, { children: jsxRuntime.jsx(RadioGroupContext.Provider, Object.assign({ value: {
2417
+ id,
2418
+ value,
2419
+ name: name || id,
2420
+ onChange,
2421
+ disabled,
2422
+ isInvalid,
2423
+ } }, { children: children })) })) })));
2424
+ };
2425
+ RadioGroup.displayName = "RadioGroup";
2426
+ const Flex = tailwindStyledComponents.tw.div `
2427
+ ${({ $inline }) => ($inline ? tailwindStyledComponents.tws `tu-radiogroup--inline` : tailwindStyledComponents.tws `tu-radiogroup`)}
2428
+ `;
2429
+
2430
+ /**
2431
+ * The RadioItem component.
2432
+ *
2433
+ * @param {RadioItemProps} props - The props for the RadioItem component
2434
+ * @returns {JSX.Element} RadioItem component
2435
+ */
2436
+ const RadioItem = ({ label, value, dataTestId, className, description }) => {
2437
+ const groupCtx = React__namespace.useContext(RadioGroupContext);
2438
+ const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
2439
+ return (jsxRuntime.jsxs(InputWrapper, Object.assign({ className: className, htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Wrapper` }, { children: [jsxRuntime.jsx(Input, { id: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, type: "radio", value: value, checked: isChecked, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, "$isInvalid": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid, onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange, "data-testid": dataTestId, "$checked": isChecked }), jsxRuntime.jsxs(LabelContainer$1, { children: [jsxRuntime.jsx(Label$2, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, dataTestId: dataTestId && `${dataTestId}-Label`, disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled, isInvalid: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.isInvalid }, { children: label })), description && (jsxRuntime.jsx(Description$1, Object.assign({ htmlFor: `${groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.id} ${label}`, "data-testid": dataTestId && `${dataTestId}-Description`, "$disabled": groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled }, { children: description })))] })] })));
2440
+ };
2441
+ const InputWrapper = tailwindStyledComponents.tw.label `tu-radioitem__wrapper`;
2442
+ const Input = tailwindStyledComponents.tw.input `
2443
+ tu-radioitem
2444
+ ${({ $checked }) => $checked && tailwindStyledComponents.tws `tu-radioitem--checked`}
2445
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem--disabled`}
2446
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-radioitem--invalid`}
2447
+ `;
2448
+ const LabelContainer$1 = tailwindStyledComponents.tw.div `tu-radioitem__label-container`;
2449
+ const Description$1 = tailwindStyledComponents.tw.label `
2450
+ tu-radioitem__description
2451
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem__description--disabled`}
2452
+ `;
2453
+
2454
+ /**
2455
+ * A thin wrapper around the `BaseInput` component for text input fields.
2456
+ *
2457
+ * NOTE: If shown with a label, please use the `TextField` component instead.
2458
+ */
2459
+ const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
2460
+
2461
+ /**
2462
+ * The Search component is used to render a search input field.
2463
+ *
2464
+ * @param {SearchProps} props - The props for the Search component
2465
+ * @returns {JSX.Element} Search component
2466
+ */
2467
+ const Search = (_a) => {
2468
+ var { className, placeholder = "Search", value, widenInputOnFocus, showBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ref } = _a, rest = __rest(_a, ["className", "placeholder", "value", "widenInputOnFocus", "showBorderWhenNotInFocus", "disabled", "onKeyUp", "onChange", "onFocus", "onBlur", "name", "onClear", "dataTestId", "autoComplete", "ref"]);
2469
+ return (jsxRuntime.jsx(StyledTextInput, Object.assign({}, rest, { ref: ref, dataTestId: dataTestId, name: name, className: className, "$widenOnFocus": widenInputOnFocus, "$showBorderWhenNotInFocus": showBorderWhenNotInFocus, placeholder: placeholder, prefix: jsxRuntime.jsx(Icon, { name: "MagnifyingGlassIcon", size: "medium" }), suffix: onClear ? (jsxRuntime.jsx("button", Object.assign({ "data-testid": dataTestId && `${dataTestId}_suffix_component`, onClick: () => {
2470
+ onClear();
2471
+ } }, { children: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }) }))) : undefined, value: value, disabled: disabled, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, autoComplete: autoComplete })));
2472
+ };
2473
+ const StyledTextInput = tailwindStyledComponents.twx(TextInput) `
2474
+ tu-search
2475
+ ${({ $showBorderWhenNotInFocus }) => $showBorderWhenNotInFocus && tailwindStyledComponents.tws `tu-search--border`}
2476
+ ${({ $widenOnFocus }) => $widenOnFocus && tailwindStyledComponents.tws `tu-search--widen-on-focus`}
2477
+ `;
2478
+
2479
+ /**
2480
+ * The Spacer component is used for adding a bit of space in the ui.
2481
+ *
2482
+ * @param {SpacerProps} props - The props for the Spacer component
2483
+ * @returns {JSX.Element} Spacer component
2484
+ */
2485
+ const Spacer = ({ minHeight, border = false, dataTestId }) => {
2486
+ return jsxRuntime.jsx(Space, { "data-testid": dataTestId, "$minHeight": minHeight, "$border": border });
2487
+ };
2488
+ const GetSpacerHeight = () => ({ $minHeight }) => {
2489
+ switch ($minHeight) {
2490
+ case "normal":
2491
+ return tailwindStyledComponents.tws `tu-spacer--normal`;
2492
+ case "large":
2493
+ return tailwindStyledComponents.tws `tu-spacer--large`;
2494
+ default:
2495
+ return "";
2496
+ }
2497
+ };
2498
+ const Space = tailwindStyledComponents.tw.div `
2499
+ ${p => `${p.$border ? `tu-spacer--border` : null}`}
2500
+ ${GetSpacerHeight()}
2501
+ `;
2502
+
2503
+ /**
2504
+ * The SectionHeader component is used on sections to set the section title.
2505
+ *
2506
+ * @param {SectionHeaderProps} props - The props for the section header component
2507
+ * @returns {JSX.Element} SectionHeader component
2508
+ */
2509
+ const SectionHeader = ({ title, subtitle, dataTestId, addon }) => {
2510
+ return (jsxRuntime.jsxs(SectionHeaderContainer, { children: [jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(reactHelmetAsync.Helmet, { title: title }) }), jsxRuntime.jsxs(StyledFlex, { children: [jsxRuntime.jsx(Heading$1, Object.assign({ variant: "secondary", dataTestId: dataTestId }, { children: title })), addon] }), subtitle && (jsxRuntime.jsx(Heading$1, Object.assign({ variant: "subtitle", subtle: true }, { children: subtitle }))), jsxRuntime.jsx(Spacer, { minHeight: "normal" })] }));
2511
+ };
2512
+ const SectionHeaderContainer = tailwindStyledComponents.tw.div `tu-section-header`;
2513
+ const StyledFlex = tailwindStyledComponents.tw.div `tu-section-header__flex`;
2514
+
2515
+ /**
2516
+ * A hook used to detect what children are overflowing a container.
2517
+ *
2518
+ * @param {OverflowItemsOptions} root0 The options for the hook.
2519
+ * @param {OverflowItemsOptions.threshold} root0.threshold The threshold for the intersection observer.
2520
+ * @returns {object} The overflow items and the ref to the container.
2521
+ */
2522
+ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id", children, }) => {
2523
+ const [itemOverflowMap, setItemOverflowMap] = React.useState({});
2524
+ const overflowContainerRef = React.useRef(null); // TODO: Handle other elements than div
2525
+ const observerRef = React.useRef(null);
2526
+ const handleIntersection = React.useCallback(entries => {
2527
+ const updatedEntries = {};
2528
+ entries.forEach(entry => {
2529
+ const targetElementId = entry.target[childUniqueIdentifierAttribute];
2530
+ if (targetElementId) {
2531
+ updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
2532
+ }
2533
+ });
2534
+ setItemOverflowMap(prev => (Object.assign(Object.assign({}, prev), updatedEntries)));
2535
+ }, [childUniqueIdentifierAttribute]);
2536
+ const observe = React.useCallback(() => {
2537
+ const node = overflowContainerRef.current;
2538
+ if (node && node.children) {
2539
+ const root = overflowContainerRef.current;
2540
+ const options = { root, threshold };
2541
+ const observer = new IntersectionObserver(handleIntersection, options);
2542
+ Array.from(node.children).forEach(child => {
2543
+ observer.observe(child);
2544
+ });
2545
+ observer.observe(node);
2546
+ observerRef.current = observer;
2547
+ }
2548
+ }, [handleIntersection, threshold]);
2549
+ const unobserve = React.useCallback(() => {
2550
+ const currentObserver = observerRef.current;
2551
+ currentObserver === null || currentObserver === void 0 ? void 0 : currentObserver.disconnect();
2552
+ observerRef.current = null;
2553
+ }, []);
2554
+ const initializeObserver = React.useCallback(() => {
2555
+ unobserve();
2556
+ observe();
2557
+ }, [observe, unobserve]);
2558
+ React.useEffect(() => {
2559
+ initializeObserver();
2560
+ return () => {
2561
+ unobserve();
2562
+ };
2563
+ }, [initializeObserver, unobserve, children]);
2564
+ return { overflowContainerRef, itemOverflowMap };
2565
+ };
2566
+
2567
+ /**
2568
+ * The sidebar components is used to render a responsive sidebar.
2569
+ * - The sidebar will be rendered horizontally until a given breakpoint where it will be stacked vertically.
2570
+ * - The sidebar hides items that does not fit in the sidebar and show them in a more menu.
2571
+ * - **_The sidebar is just a wrapper. You are responsible for styling the children._**
2572
+ *
2573
+ * When using this component make sure to add `setupIntersectionObserver();` to your jest.setup.ts file.
2574
+ *
2575
+ * @param {SidebarProps} props - The props for the Sidebar component
2576
+ * @returns {JSX.Element} Sidebar component
2577
+ */
2578
+ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", className, dataTestId = "sidebar", moreMenuProps, menuListProps, overflowThreshold, }) => {
2579
+ const { overflowContainerRef, itemOverflowMap } = useOverflowItems({
2580
+ children,
2581
+ childUniqueIdentifierAttribute: "id",
2582
+ threshold: overflowThreshold !== null && overflowThreshold !== void 0 ? overflowThreshold : 0.8,
2583
+ });
2584
+ const overflowItemCount = Object.values(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2585
+ const itemVisibilityClassName = (id) => {
2586
+ if (itemOverflowMap[id]) {
2587
+ return tailwindStyledComponents.tws `invisible`;
2588
+ }
2589
+ return tailwindStyledComponents.tws `visible`;
2590
+ };
2591
+ return (jsxRuntime.jsxs(Root$2, Object.assign({ className: className, "data-testid": dataTestId }, { children: [jsxRuntime.jsx(ChildContainer, Object.assign({ "$breakpoint": breakpoint, ref: overflowContainerRef, className: childContainerClassName, "data-testid": dataTestId && `${dataTestId}-child-container` }, { children: React__default["default"].Children.map(children, child => {
2592
+ return React__default["default"].cloneElement(child, {
2593
+ className: `${child.props.className} ${itemVisibilityClassName(child.props.id)}`,
2594
+ });
2595
+ }) })), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, Object.assign({ iconButtonProps: {
2596
+ circular: false,
2597
+ variant: "transparent",
2598
+ color: "secondary",
2599
+ }, menuPlacement: "bottom-end" }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId && `${dataTestId}-more-menu` }, { children: close => (jsxRuntime.jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId && `${dataTestId}-menu-list` }, { children: React__default["default"].Children.map(children, child => {
2600
+ return itemOverflowMap[child.props.id]
2601
+ ? React__default["default"].cloneElement(child, {
2602
+ onClick: () => {
2603
+ var _a, _b;
2604
+ (_b = (_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
2605
+ close();
2606
+ },
2607
+ })
2608
+ : null;
2609
+ }) }))) }))) : null] })));
2610
+ };
2611
+ const Root$2 = tailwindStyledComponents.tw.div `
2612
+ tu-sidebar
2613
+ `;
2614
+ const breakpointClasses = {
2615
+ xs: tailwindStyledComponents.tws `tu-sidebar__child-container--xs`,
2616
+ sm: tailwindStyledComponents.tws `tu-sidebar__child-container--sm`,
2617
+ md: tailwindStyledComponents.tws `tu-sidebar__child-container--md`,
2618
+ lg: tailwindStyledComponents.tws `tu-sidebar__child-container--lg`,
2619
+ xl: tailwindStyledComponents.tws `tu-sidebar__child-container--xl`,
2620
+ "2xl": tailwindStyledComponents.tws `tu-sidebar__child-container--2xl`,
2621
+ "3xl": tailwindStyledComponents.tws `tu-sidebar__child-container--3xl`,
2622
+ };
2623
+ const ChildContainer = tailwindStyledComponents.tw.div `
2624
+ tu-sidebar__child-container
2625
+ ${({ $breakpoint }) => breakpointClasses[$breakpoint]}
2626
+ `;
2627
+
2628
+ /**
2629
+ * The TextArea is a base component, and should not be used very often.
2630
+ * For most cases the TextAreaField is the correct component.
2631
+ */
2632
+ const TextArea = React__namespace.forwardRef((_a, ref) => {
2633
+ var { id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, className, required, dataTestId, isInvalid } = _a, rest = __rest(_a, ["id", "name", "value", "rows", "disabled", "placeholder", "readOnly", "tabIndex", "onChange", "onFocus", "onBlur", "maxLength", "resize", "defaultValue", "className", "required", "dataTestId", "isInvalid"]);
2634
+ return (jsxRuntime.jsx(StyledTextArea, Object.assign({ name: name, value: value, rows: rows, disabled: disabled, placeholder: placeholder, readOnly: readOnly, tabIndex: tabIndex, onFocus: onFocus, onBlur: onBlur, maxLength: maxLength, "$resize": resize, "$invalid": isInvalid, ref: ref, defaultValue: defaultValue, required: required }, rest, { onChange: onChange, "data-testid": dataTestId })));
2635
+ });
2636
+ const StyledTextArea = tailwindStyledComponents.tw.textarea `
2637
+ tu-textarea
2638
+ ${({ $invalid }) => ($invalid ? tailwindStyledComponents.tws `tu-textarea--invalid` : null)}
2639
+ ${({ disabled }) => (disabled ? tailwindStyledComponents.tws `tu-textarea--disabled` : null)}
2640
+ ${({ $resize }) => {
2641
+ switch ($resize) {
2642
+ case "both":
2643
+ return tailwindStyledComponents.tws `resize`;
2644
+ case "horizontal":
2645
+ return tailwindStyledComponents.tws `resize-x`;
2646
+ case "vertical":
2647
+ return tailwindStyledComponents.tws `resize-y`;
2648
+ case "none":
2649
+ return tailwindStyledComponents.tws `resize-none`;
2650
+ default:
2651
+ return null;
2652
+ }
2653
+ }};
2654
+ `;
2655
+
2656
+ /**
2657
+ * The TextLengthIndicator component shows a `{length}/{maxLength}` label.
2658
+ * Used for TextFields to communicate a maximum allowed input length.
2659
+ *
2660
+ * @param {TextLengthIndicatorProps} props - The props for the TextLengthIndicator component
2661
+ * @returns {JSX.Element} TextLengthIndicator component
2662
+ */
2663
+ const TextLengthIndicator = ({ length, maxLength }) => {
2664
+ return (jsxRuntime.jsxs(Root$1, { children: [length, "/", maxLength] }));
2665
+ };
2666
+ const Root$1 = tailwindStyledComponents.tw.span `
2667
+ font-mono
2668
+ `;
2669
+
2670
+ const TextAreaField = React__namespace.forwardRef((_a, ref) => {
2671
+ var { label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2672
+ const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
2673
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2674
+ const handleChange = React__namespace.useCallback((event) => {
2675
+ setValueLength(event.target.value.length);
2676
+ if (onChange) {
2677
+ onChange(event);
2678
+ }
2679
+ }, [onChange]);
2680
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon ||
2681
+ (maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), className: className, dataTestId: dataTestId && `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(TextArea, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2682
+ });
2683
+
2684
+ /**
2685
+ * Text fields enable the user to interact with and input content and data. This component can be used for long and short form entries. Allow the size of the text input box to reflect the length of the content you expect the user to enter.
2686
+ *
2687
+ * _**Do use** when the user has to input or edit simple text based information, such as metadata._
2688
+ *
2689
+ * _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
2690
+ */
2691
+ const TextField = React__namespace.forwardRef((_a, ref) => {
2692
+ var { label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
2693
+ const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
2694
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
2695
+ const handleChange = React__namespace.useCallback((event) => {
2696
+ setValueLength(event.target.value.length);
2697
+ if (onChange) {
2698
+ onChange(event);
2699
+ }
2700
+ }, [onChange]);
2701
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon ||
2702
+ (maxLength !== null && maxLength !== undefined && (jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength }))), dataTestId: dataTestId && `${dataTestId}-FormGroup`, disabled: rest.readOnly }, { children: jsxRuntime.jsx(TextInput, Object.assign({ ref: ref, maxLength: maxLength, value: value, isInvalid: renderAsInvalid }, rest, { className: className, onChange: handleChange, dataTestId: dataTestId })) })));
2703
+ });
2704
+
2705
+ /**
2706
+ * Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
2707
+ * - with an indicator (dot)
2708
+ * - a header (next to the dot)
2709
+ * - and a body.
2710
+ *
2711
+ * @param {TimelineProps} props - The props for the Timeline component
2712
+ * @returns {JSX.Element} Timeline component
2713
+ */
2714
+ const Timeline = ({ className, dataTestId, children }) => {
2715
+ return (jsxRuntime.jsx("ol", Object.assign({ className: `${className !== null && className !== void 0 ? className : ""} ${tailwindStyledComponents.tws `tu-timeline`}`, "data-testid": dataTestId }, { children: children })));
2716
+ };
2717
+ /**
2718
+ * TimelineElement - entry on a timeline - rendered with an icon on the timeline
2719
+ * - a date as the header and the children provided as body.
2720
+ *
2721
+ * @param {TimeLineElementProps} props the props
2722
+ * @returns {JSX.Element} component
2723
+ */
2724
+ const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", dot = jsxRuntime.jsx(Indicator, { className: tailwindStyledComponents.tws `mt-[-1px]`, color: "neutral", icon: jsxRuntime.jsx(Icon, { name: "CalendarIcon", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
2725
+ var _a;
2726
+ return (jsxRuntime.jsxs("li", Object.assign({ className: `${tailwindStyledComponents.tws `tu-timeline-element`}${(_a = " " + className) !== null && _a !== void 0 ? _a : ""} `, "data-date": `${date}`, "data-testid": dataTestId && `${dataTestId}`, onClick: () => onClick && onClick() }, { children: [jsxRuntime.jsx("div", Object.assign({ className: tailwindStyledComponents.tws `tu-timeline-element__dot` }, { children: dot })), jsxRuntime.jsx("div", { children: header }), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { children: children }) })] })));
2727
+ };
2728
+ function defaultHeader(date, showTime) {
2729
+ return `${dateFns.format(date, showTime ? "MMM d, yyyy H:mm" : "MMM d, yyyy")} (${dateFns.formatDistance(date, new Date(), {
2730
+ addSuffix: true,
2731
+ })})`;
2732
+ }
2733
+
2734
+ /**
2735
+ * Use Toggle when you have to only enable/disable a feature.
2736
+ *
2737
+ * _**Do use** Toggle in forms or settings._
2738
+ *
2739
+ * _**Do not use** Toggle if a user can select many option from a list, use checkboxes instead of toggle._
2740
+ *
2741
+ * @param {ToggleProps} props - The props for the Toggle component
2742
+ * @returns {JSX.Element} Toggle component
2743
+ */
2744
+ const Toggle = React__namespace.forwardRef(({ toggled = false, onChange, disabled, size = "medium", id, tabIndex, required, className, dataTestId, onBlur, name, description = "", }, ref) => {
2745
+ return (jsxRuntime.jsxs(ToggleWrapper, { children: [jsxRuntime.jsxs(InputContainer, Object.assign({ htmlFor: id }, { children: [jsxRuntime.jsx(HiddenInput, { name: name, type: "checkbox", checked: toggled, disabled: disabled, onChange: e => {
2746
+ e.stopPropagation();
2747
+ onChange(!toggled, e);
2748
+ }, id: id, "aria-checked": toggled, role: "checkbox", tabIndex: tabIndex, required: required, ref: ref, "data-testid": dataTestId && `${dataTestId}-Input`, onBlur: onBlur }), jsxRuntime.jsx(SwitchContainer, Object.assign({ "$toggled": toggled, htmlFor: id, "$disabled": disabled, "$size": size }, { children: jsxRuntime.jsx(Switch, { "$toggled": toggled, htmlFor: id, "data-testid": dataTestId && `${dataTestId}-Switch` }) }))] })), jsxRuntime.jsxs(LabelContainer, { children: [jsxRuntime.jsx(Label$2, Object.assign({ htmlFor: id, dataTestId: dataTestId && `${dataTestId}-Label`, disabled: disabled }, { children: name })), description && (jsxRuntime.jsx(Description, Object.assign({ htmlFor: id, "data-testid": dataTestId && `${dataTestId}-Description`, "$disabled": disabled }, { children: description })))] })] }));
2749
+ });
2750
+ Toggle.displayName = "Toggle";
2751
+ const ToggleWrapper = tailwindStyledComponents.tw.div `tu-toggle__wrapper`;
2752
+ const InputContainer = tailwindStyledComponents.tw.label `tu-toggle__input-container `;
2753
+ const HiddenInput = tailwindStyledComponents.tw.input `tu-toggle__input`;
2754
+ const Switch = tailwindStyledComponents.tw.label `
2755
+ ${({ $toggled }) => ($toggled ? tailwindStyledComponents.tws `tu-toggle__switch` : tailwindStyledComponents.tws `tu-toggle`)}`;
2756
+ const SwitchContainer = tailwindStyledComponents.tw.label `
2757
+ tu-toggle__switch-container
2758
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-toggle--disabled`};
2759
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-toggle--small` : tailwindStyledComponents.tws `tu-toggle--medium`)};
2760
+ ${({ $toggled }) => $toggled && tailwindStyledComponents.tws `tu-toggle--toggled`}`;
2761
+ const LabelContainer = tailwindStyledComponents.tw.div `tu-toggle__label-container`;
2762
+ const Description = tailwindStyledComponents.tw.label `
2763
+ tu-toggle__description
2764
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-toggle__description--disabled`}
2765
+ `;
2766
+
2767
+ /**
2768
+ * A thin wrapper around the `BaseInput` component for upload input fields.
2769
+ *
2770
+ * NOTE: If shown with a label, please use the `UploadField` component instead.
2771
+ */
2772
+ const UploadInput = React.forwardRef((_a, ref) => {
2773
+ var { disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles } = _a, rest = __rest(_a, ["disabled", "acceptedTypes", "nonInteractive", "uploadLabel", "multipleFiles"]);
2774
+ return (jsxRuntime.jsx(UploadInputContainer, { children: jsxRuntime.jsx(BaseInput, Object.assign({ addonBefore: uploadLabel, ref: ref, disabled: disabled, accept: acceptedTypes, multiple: multipleFiles, type: "file", nonInteractive: nonInteractive,
2775
+ // onClick used to work with nonInteractive option
2776
+ onClick: event => {
2777
+ if (nonInteractive) {
2778
+ event.preventDefault();
2779
+ event.stopPropagation();
2780
+ }
2781
+ } }, rest)) }));
2782
+ });
2783
+ const UploadInputContainer = tailwindStyledComponents.tw.label `
2784
+ tu-upload-input`;
2785
+
2786
+ /**
2787
+ * Upload fields enable the user to upload Files.
2788
+ */
2789
+ const UploadField = React.forwardRef((_a, ref) => {
2790
+ var { label, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
2791
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2792
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, dataTestId: `${dataTestId}-FormGroup` }, { children: jsxRuntime.jsx(UploadInput, Object.assign({ ref: ref, isInvalid: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) })));
2793
+ });
2794
+
2795
+ /**
2796
+ * Helper function to get normalized score in range 0-1 used by the ValueBar
2797
+ *
2798
+ * @param {number} value - value for which score should be returned
2799
+ * @param {number} min - min range value
2800
+ * @param {number} max - max range value
2801
+ * @returns {number} normalized score
2802
+ */
2803
+ const getScore = (value, min, max) => {
2804
+ if (value <= min) {
2805
+ return 0.01; // always render at least some small fragment
2806
+ }
2807
+ if (value >= max) {
2808
+ return 1;
2809
+ }
2810
+ return (value - min) / (max - min);
2811
+ };
2812
+ /**
2813
+ * Helper function to get default color used by the ValueBar
2814
+ *
2815
+ * @param {number} score - score number for which color should be returned
2816
+ * @returns {string} color value
2817
+ */
2818
+ const getDefaultFillColor = (score) => {
2819
+ if (score < 0.3) {
2820
+ return uiDesignTokens.color("DANGER", 500, "CSS");
2821
+ }
2822
+ if (score >= 0.6) {
2823
+ return uiDesignTokens.color("SUCCESS", 600, "CSS");
2824
+ }
2825
+ return uiDesignTokens.color("WARNING", 300, "CSS");
2826
+ };
2827
+ /**
2828
+ * Helper function to get custom color used by the ValueBar
2829
+ *
2830
+ * @param {number} score - score number for which color should be returned
2831
+ * @param {LevelColors} levelColors - custom colors and levels definitions
2832
+ * @returns {string} color value
2833
+ */
2834
+ const getFillColor = (score, levelColors) => {
2835
+ var _a, _b;
2836
+ if (levelColors.low && score < (levelColors.low.level || 0)) {
2837
+ return levelColors.low.color;
2838
+ }
2839
+ if (levelColors.high && score >= (levelColors.high.level || 0)) {
2840
+ return levelColors.high.color;
2841
+ }
2842
+ return (_b = (_a = levelColors.medium) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : uiDesignTokens.color("WARNING", 300);
2843
+ };
2844
+ /**
2845
+ * Helper function to get color used by the ValueBar
2846
+ *
2847
+ * @param {number} value - value for which color should be returned
2848
+ * @param {number} min - min range value
2849
+ * @param {number} max - max range value
2850
+ * @param {LevelColors} levelColors - level colors used to coloring the bar
2851
+ * @returns {JSX.Element} ValueBar component
2852
+ */
2853
+ const getValueBarColorByValue = (value, min, max, levelColors) => {
2854
+ const score = getScore(value, min, max);
2855
+ return getFillColor(score, levelColors);
2856
+ };
2857
+
2858
+ /**
2859
+ * ValueBar component is used to display value on a colorful bar within provided range.
2860
+ *
2861
+ * @param {ValueBarProps} props - The props for the ValueBar component
2862
+ * @returns {JSX.Element} ValueBar component
2863
+ */
2864
+ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue, className, dataTestId, }) => {
2865
+ const score = getScore(value, min, max);
2866
+ const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
2867
+ const barWidth = showValue && size === "small" ? 90 : 100;
2868
+ return (jsxRuntime.jsx(Root, Object.assign({ className: className, "data-testid": dataTestId, "$size": size }, { children: jsxRuntime.jsxs("g", { children: [jsxRuntime.jsx(Background, { width: `${barWidth}%`, rx: "5" }), jsxRuntime.jsx(Bar, { width: `${score * barWidth}%`, fill: barFillColor, rx: "5" }), showValue && size === "large" && (jsxRuntime.jsxs(Text, Object.assign({ "$size": size, x: "12", y: "23", fill: valueColor !== null && valueColor !== void 0 ? valueColor : "white" }, { children: [Number(value.toFixed(1)), unit || ""] }))), showValue && size === "small" && (jsxRuntime.jsxs(Text, Object.assign({ "$size": size, x: `${barWidth + 2}%`, y: "11", fill: valueColor !== null && valueColor !== void 0 ? valueColor : uiDesignTokens.color("NEUTRAL", 400, "CSS") }, { children: [Number(value.toFixed(1)), unit || ""] })))] }) })));
2869
+ };
2870
+ const Root = tailwindStyledComponents.tw.svg `
2871
+ tu-value-bar
2872
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-value-bar--small` : tailwindStyledComponents.tws `tu-value-bar--large`)}
2873
+ `;
2874
+ const Text = tailwindStyledComponents.tw.text `
2875
+ tu-value-bar__text
2876
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-value-bar__text--small` : tailwindStyledComponents.tws `tu-value-bar__text--large`)}
2877
+ `;
2878
+ const Background = tailwindStyledComponents.tw.rect `
2879
+ tu-value-bar__background
2880
+ `;
2881
+ const Bar = tailwindStyledComponents.tw.rect `
2882
+ tu-value-bar__bar
2883
+ `;
2884
+
2885
+ /**
2886
+ * The useDebounce hook works like useState, but adds a delay where previous values will be ignored.
2887
+ *
2888
+ * @param {any} value The value to set
2889
+ * @param {number} delay The debounce time
2890
+ * @returns {any} value The latest values received
2891
+ */
2892
+ const useDebounce = (value, delay = 500) => {
2893
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
2894
+ React.useEffect(() => {
2895
+ const handler = setTimeout(() => {
2896
+ setDebouncedValue(value);
2897
+ }, delay);
2898
+ return () => {
2899
+ clearTimeout(handler);
2900
+ };
2901
+ }, [value, delay]);
2902
+ return debouncedValue;
2903
+ };
2904
+
2905
+ // Copied from https://github.com/rexxars/use-device-pixel-ratio
2906
+ /**
2907
+ * Get the device pixel ratio, potentially rounded and capped.
2908
+ * Will emit new values if it changes.
2909
+ *
2910
+ * @param {DevicePixelRatioOptions} options the options object
2911
+ * @returns { number } The current device pixel ratio, or the default if none can be resolved
2912
+ */
2913
+ function useDevicePixelRatio(options) {
2914
+ const dpr = getDevicePixelRatio(options);
2915
+ const [currentDpr, setCurrentDpr] = React.useState(dpr);
2916
+ const { defaultDpr, maxDpr, round } = options || {};
2917
+ React.useEffect(() => {
2918
+ const canListen = typeof window !== "undefined" && "matchMedia" in window;
2919
+ if (!canListen) {
2920
+ return;
2921
+ }
2922
+ const updateDpr = () => setCurrentDpr(getDevicePixelRatio({ defaultDpr, maxDpr, round }));
2923
+ const mediaMatcher = window.matchMedia(`screen and (resolution: ${currentDpr}dppx)`);
2924
+ // Safari 13.1 does not have `addEventListener`, but does have `addListener`
2925
+ if (mediaMatcher.addEventListener) {
2926
+ mediaMatcher.addEventListener("change", updateDpr);
2927
+ }
2928
+ else {
2929
+ mediaMatcher.addListener(updateDpr);
2930
+ }
2931
+ return () => {
2932
+ if (mediaMatcher.removeEventListener) {
2933
+ mediaMatcher.removeEventListener("change", updateDpr);
2934
+ }
2935
+ else {
2936
+ mediaMatcher.removeListener(updateDpr);
2937
+ }
2938
+ };
2939
+ }, [currentDpr, defaultDpr, maxDpr, round]);
2940
+ return currentDpr;
2941
+ }
2942
+ /**
2943
+ * Returns the current device pixel ratio (DPR) given the passed options
2944
+ *
2945
+ * @param { DevicePixelRatioOptions } options the options object
2946
+ * @returns { number } current device pixel ratio
2947
+ */
2948
+ function getDevicePixelRatio(options) {
2949
+ const { defaultDpr = 1, maxDpr = 3, round = true } = options || {};
2950
+ const hasDprProp = typeof window !== "undefined" && typeof window.devicePixelRatio === "number";
2951
+ const dpr = hasDprProp ? window.devicePixelRatio : defaultDpr;
2952
+ const rounded = Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
2953
+ return rounded;
2954
+ }
2955
+
2956
+ /**
2957
+ * The useLocalStorage hook works like useState, but saves to localstorage.
2958
+ *
2959
+ * @param {string} key - The key the values is saved under.
2960
+ * @param {string | null | undefined} initialValue - The initial value for the state/local storage item
2961
+ * @returns {string | null | undefined} value
2962
+ */
2963
+ const useLocalStorage = (key, initialValue) => {
2964
+ if (!key) {
2965
+ throw new Error("useLocalStorage key may not be falsy");
2966
+ }
2967
+ const setLocalStorageItem = React.useCallback((value) => window.localStorage.setItem(key, typeof value === "object" ? JSON.stringify(value) : `${value}`), [key]);
2968
+ const removeLocalStorageItem = React.useCallback(() => window.localStorage.removeItem(key), [key]);
2969
+ const [item, setValue] = React.useState(() => {
2970
+ const value = window.localStorage.getItem(key);
2971
+ if (value !== undefined && value !== null) {
2972
+ const parsedValue = tryParse(value);
2973
+ return parsedValue;
2974
+ }
2975
+ return initialValue !== null && initialValue !== void 0 ? initialValue : null;
2976
+ });
2977
+ React.useEffect(() => {
2978
+ if (item !== undefined && item !== null) {
2979
+ setLocalStorageItem(item);
2980
+ }
2981
+ else {
2982
+ removeLocalStorageItem();
2983
+ }
2984
+ }, [item, setLocalStorageItem, removeLocalStorageItem, key]);
2985
+ /*
2986
+ // Sync local storage between tabs / windows
2987
+ useEffect(() => {
2988
+ const handleStorageChange = (e: StorageEvent) => {
2989
+ if (e.key === key) {
2990
+ setValue(tryParse(e.newValue));
2991
+ }
2992
+ };
2993
+
2994
+ window.addEventListener("storage", handleStorageChange);
2995
+
2996
+ return () => {
2997
+ window.removeEventListener("storage", handleStorageChange);
2998
+ };
2999
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3000
+ }, []);
3001
+ */
3002
+ const removeItem = () => {
3003
+ setValue(null);
3004
+ };
3005
+ return [item, setValue, removeItem];
3006
+ };
3007
+ function tryParse(value) {
3008
+ try {
3009
+ return JSON.parse(value);
3010
+ }
3011
+ catch (_a) {
3012
+ return value;
3013
+ }
3014
+ }
3015
+
3016
+ /**
3017
+ * @param {UseTimeoutProps} props The props
3018
+ * @returns {{ startTimeout: () => void; stopTimeout: () => void; isReady: boolean | null}} return
3019
+ */
3020
+ const useTimeout = ({ onTimeout, duration }) => {
3021
+ const ready = React.useRef(false);
3022
+ const timeout = React.useRef();
3023
+ const callback = React.useRef(onTimeout);
3024
+ const isReady = React.useCallback(() => ready.current, []);
3025
+ const startTimeout = React.useCallback(() => {
3026
+ ready.current = false;
3027
+ timeout.current && clearTimeout(timeout.current);
3028
+ timeout.current = setTimeout(() => {
3029
+ ready.current = true;
3030
+ callback.current();
3031
+ }, duration);
3032
+ }, [duration]);
3033
+ const stopTimeout = React.useCallback(() => {
3034
+ ready.current = null;
3035
+ timeout.current && clearTimeout(timeout.current);
3036
+ }, []);
3037
+ // update ref when function changes
3038
+ React.useEffect(() => {
3039
+ callback.current = onTimeout;
3040
+ }, [onTimeout]);
3041
+ // startTimeout on mount, stopTimeout on unmount
3042
+ React.useEffect(() => {
3043
+ startTimeout();
3044
+ return stopTimeout;
3045
+ }, [duration, startTimeout, stopTimeout]);
3046
+ return [isReady, stopTimeout, startTimeout];
3047
+ };
3048
+
3049
+ /**
3050
+ * The MinTopFullContentLayout component.
3051
+ *
3052
+ * @param {MinTopFullContentLayoutProps} props - The props for the MinTopFullContentLayout component
3053
+ * @returns {JSX.Element} MinTopFullContentLayout component
3054
+ */
3055
+ const MinTopFullContentLayout = ({ children, className, dataTestId }) => (jsxRuntime.jsx(Layout$5, Object.assign({ className: className, "data-testid": dataTestId }, { children: children })));
3056
+ const Layout$5 = tailwindStyledComponents.tw.span `
3057
+ grid
3058
+ h-full
3059
+ grid-rows-min-fr
3060
+ `;
3061
+
3062
+ /**
3063
+ * Responsive layout component setting up three grid areas
3064
+ * one for filtering, (result-)list and (result-map)
3065
+ *
3066
+ * List needs to handle its own min size - and map takes up the rest.
3067
+ *
3068
+ * Will be inlined to
3069
+ * - filter
3070
+ * - list
3071
+ * - map
3072
+ * on screens < mediaQuery.xxl
3073
+ *
3074
+ *
3075
+ * @param {FilterListMapLayoutProps} props - The props for the FilterListMapLayout component
3076
+ * @returns {JSX.Element} FilterListMapLayout component
3077
+ */
3078
+ const FilterListMapLayout = ({ children }) => jsxRuntime.jsx(Layout$4, { children: children });
3079
+ const Layout$4 = tailwindStyledComponents.tw.span `
3080
+ tu-layout-FilterListMap
3081
+ `;
3082
+
3083
+ /**
3084
+ * Layout component with repeating full width areas, default one height fraction each but option to use content height instead
3085
+ * Row min height can optionally be set here or managed by children
3086
+ * Scrolling happens if/when children's a min-height is reached
3087
+ *
3088
+ * @param {FullWidthRepeatingLayoutProps} props - The props for the FullWidthRepeatingLayout component
3089
+ * @returns {JSX.Element} FullWidthRepeatingLayout component
3090
+ */
3091
+ const FullWidthRepeatingLayout = ({ children, rowSizing = "Unmanaged", rowMinHeight, dataTestId, className, }) => (jsxRuntime.jsx(Layout$3, Object.assign({ "data-testid": dataTestId, className: className, "$rowSizing": rowSizing, "$rowMinHeight": rowMinHeight !== null && rowMinHeight !== void 0 ? rowMinHeight : 0 }, { children: children })));
3092
+ const Layout$3 = tailwindStyledComponents.tw.span `
3093
+ tu-layout-FullWidthRepeatingLayout
3094
+
3095
+ ${({ $rowSizing }) => {
3096
+ switch ($rowSizing) {
3097
+ case "MinContent":
3098
+ return tailwindStyledComponents.tws ` tu-layout-FullWidthRepeatingLayout--MinContent`;
3099
+ case "Equal":
3100
+ return tailwindStyledComponents.tws ` tu-layout-FullWidthRepeatingLayout--Equal`;
3101
+ case "Unmanaged":
3102
+ default:
3103
+ return null;
3104
+ }
3105
+ }}
3106
+ `;
3107
+
3108
+ /**
3109
+ * Simply applies a Grid Area to the element
3110
+ *
3111
+ * @param {GridAreaProps} props - The props for the GridArea component
3112
+ * @returns {JSX.Element} GridArea component
3113
+ */
3114
+ const GridArea = ({ area, dataTestId, className, children }) => (jsxRuntime.jsx("section", Object.assign({ className: className, "data-testid": dataTestId, style: { gridArea: area } }, { children: children })));
3115
+
3116
+ /**
3117
+ * A grid container that has a flexible number of columns.
3118
+ * Adds more columns if constraints allow it, otherwise wraps to next row
3119
+ *
3120
+ * @param {IntrinsicallyResponsiveGridProps} props - The props for the IntrinsicallyResponsiveGrid component
3121
+ * @returns {JSX.Element} IntrinsicallyResponsiveGrid component
3122
+ */
3123
+ const IntrinsicallyResponsiveGrid = ({ children, occupation = "auto-fill", minColumnWidth = "md", rowHeight = "1fr", gap = "auto", dataTestId, className, }) => (jsxRuntime.jsx(Layout$2, Object.assign({ "$minColumnWidth": minColumnWidth, "data-testid": dataTestId, "$gap": gap, "$rowHeight": rowHeight, "$occupation": occupation, className: className }, { children: children })));
3124
+ const Layout$2 = tailwindStyledComponents.tw.span `
3125
+ tu-layout-IntrinsicallyResponsiveGrid
3126
+ ${({ $occupation }) => {
3127
+ switch ($occupation) {
3128
+ case "auto-fit":
3129
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--fit`;
3130
+ case "auto-fill":
3131
+ default:
3132
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--fill`;
3133
+ }
3134
+ }}
3135
+
3136
+ ${({ $minColumnWidth }) => {
3137
+ switch ($minColumnWidth) {
3138
+ case "xs":
3139
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--xs`;
3140
+ case "sm":
3141
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--sm`;
3142
+ case "lg":
3143
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--lg`;
3144
+ case "xl":
3145
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--xl`;
3146
+ case "md":
3147
+ default:
3148
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--md`;
3149
+ }
3150
+ }}
3151
+
3152
+ ${({ $gap }) => {
3153
+ switch ($gap) {
3154
+ case "tiny":
3155
+ return tailwindStyledComponents.tws `gap-1`;
3156
+ case "mini":
3157
+ return tailwindStyledComponents.tws `gap-2`;
3158
+ case "small":
3159
+ return tailwindStyledComponents.tws `gap-3`;
3160
+ case "medium":
3161
+ return tailwindStyledComponents.tws `gap-4`;
3162
+ case "large":
3163
+ return tailwindStyledComponents.tws `gap-6`;
3164
+ case "giant":
3165
+ return tailwindStyledComponents.tws `gap-8`;
3166
+ case "enormous":
3167
+ return tailwindStyledComponents.tws `gap-10`;
3168
+ case "none":
3169
+ return tailwindStyledComponents.tws `gap-0`;
3170
+ case "inherit":
3171
+ return tailwindStyledComponents.tws `gap-[inherit]`;
3172
+ case "auto":
3173
+ default:
3174
+ return tailwindStyledComponents.tws `tu-gap-responsive`;
3175
+ }
3176
+ }};
3177
+
3178
+ ${({ $rowHeight }) => {
3179
+ switch ($rowHeight) {
3180
+ case "auto":
3181
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--row-auto`;
3182
+ case "1fr":
3183
+ default:
3184
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--row-1fr`;
3185
+ }
3186
+ }};
3187
+ `;
3188
+
3189
+ /**
3190
+ * The TitleNavContentLayout.
3191
+ * Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
3192
+ *
3193
+ * @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
3194
+ * @returns {JSX.Element} TitleNavContentLayout component
3195
+ */
3196
+ const TitleNavContentLayout = ({ children, className }) => (jsxRuntime.jsx(Layout$1, Object.assign({ className: className }, { children: children })));
3197
+ const Layout$1 = tailwindStyledComponents.tw.div `
3198
+ tu-layout-TitleNavContentLayout
3199
+ lg:tu-layout-TitleNavContentLayout-lg
3200
+ `;
3201
+ /**
3202
+ * A component to define the title area of the TitleNavContentLayout.
3203
+ */
3204
+ const TitleGridArea = tailwindStyledComponents.tw.header `
3205
+ tu-layout-area-title
3206
+ `;
3207
+ /**
3208
+ * A component to define the navigation area of the TitleNavContentLayout.
3209
+ * Adds the needed left padding on large screens.
3210
+ */
3211
+ const NavGridArea = tailwindStyledComponents.tw.aside `
3212
+ tu-layout-area-nav
3213
+ `;
3214
+ /**
3215
+ * A component to define the content area of the TitleNavContentLayout.
3216
+ * Adds the needed right padding on large screens.
3217
+ */
3218
+ const ContentGridArea = tailwindStyledComponents.tw.article `
3219
+ tu-layout-area-content
3220
+ `;
3221
+
3222
+ /**
3223
+ * TwoColumnLayout.
3224
+ *
3225
+ * @param {TwoColumnLayoutProps} props - The props for the TwoColumnLayout component
3226
+ * @returns {JSX.Element} TwoColumnLayout component
3227
+ */
3228
+ const TwoColumnLayout = ({ children }) => jsxRuntime.jsx(Layout, { children: children });
3229
+ const Layout = tailwindStyledComponents.tw.div `
3230
+ tu-layout-TwoColumnLayout
3231
+ `;
3232
+
3233
+ Object.defineProperty(exports, 'ValueType', {
3234
+ enumerable: true,
3235
+ get: function () { return ReactSelect__default["default"]; }
3236
+ });
3237
+ exports.ActionButton = ActionButton;
3238
+ exports.Alert = Alert;
3239
+ exports.Badge = Badge;
3240
+ exports.BaseInput = BaseInput;
3241
+ exports.Button = Button;
3242
+ exports.Card = Card;
3243
+ exports.CardBody = CardBody;
3244
+ exports.CardFooter = CardFooter;
3245
+ exports.CardHeader = CardHeader;
3246
+ exports.Checkbox = Checkbox;
3247
+ exports.Collapse = Collapse;
3248
+ exports.ContentGridArea = ContentGridArea;
3249
+ exports.CopyableText = CopyableText;
3250
+ exports.CreatableSelect = CreatableSelect;
3251
+ exports.DateField = DateField;
3252
+ exports.DateInput = DateInput;
3253
+ exports.DayPicker = DayPicker;
3254
+ exports.DayPickerPopover = DayPickerPopover;
3255
+ exports.DayRangePicker = DayRangePicker;
3256
+ exports.DensityContainer = DensityContainer;
3257
+ exports.Drawer = Drawer;
3258
+ exports.DropZone = DropZone;
3259
+ exports.EmailField = EmailField;
3260
+ exports.EmailInput = EmailInput;
3261
+ exports.ExternalLink = ExternalLink;
3262
+ exports.FilterListMapLayout = FilterListMapLayout;
3263
+ exports.FormGroup = FormGroup;
3264
+ exports.FullWidthRepeatingLayout = FullWidthRepeatingLayout;
3265
+ exports.GridArea = GridArea;
3266
+ exports.Heading = Heading$1;
3267
+ exports.Icon = Icon;
3268
+ exports.IconButton = IconButton;
3269
+ exports.Indicator = Indicator;
3270
+ exports.IntrinsicallyResponsiveGrid = IntrinsicallyResponsiveGrid;
3271
+ exports.Label = Label$2;
3272
+ exports.MenuItem = MenuItem;
3273
+ exports.MenuList = MenuList;
3274
+ exports.MinTopFullContentLayout = MinTopFullContentLayout;
3275
+ exports.Modal = Modal;
3276
+ exports.ModalBackdrop = ModalBackdrop;
3277
+ exports.MoreMenu = MoreMenu;
3278
+ exports.MultiSelectMenuItem = MultiSelectMenuItem;
3279
+ exports.NavGridArea = NavGridArea;
3280
+ exports.NumberField = NumberField;
3281
+ exports.NumberInput = NumberInput;
3282
+ exports.PageHeader = PageHeader;
3283
+ exports.Pagination = Pagination;
3284
+ exports.PhoneField = PhoneField;
3285
+ exports.PhoneInput = PhoneInput;
3286
+ exports.Popover = Popover;
3287
+ exports.PopoverContent = PopoverContent;
3288
+ exports.PopoverTitle = PopoverTitle;
3289
+ exports.PopoverTrigger = PopoverTrigger;
3290
+ exports.Prompt = Prompt;
3291
+ exports.ROLE_CARD = ROLE_CARD;
3292
+ exports.RadioGroup = RadioGroup;
3293
+ exports.RadioItem = RadioItem;
3294
+ exports.Search = Search;
3295
+ exports.SectionHeader = SectionHeader;
3296
+ exports.Select = Select;
3297
+ exports.SelectPrefix = SelectPrefix;
3298
+ exports.Sidebar = Sidebar;
3299
+ exports.SingleSelectMenuItem = SingleSelectMenuItem;
3300
+ exports.SkeletonLines = SkeletonLines;
3301
+ exports.Spacer = Spacer;
3302
+ exports.Spinner = Spinner;
3303
+ exports.StarButton = StarButton;
3304
+ exports.Tag = Tag;
3305
+ exports.Text = Text$1;
3306
+ exports.TextArea = TextArea;
3307
+ exports.TextAreaField = TextAreaField;
3308
+ exports.TextField = TextField;
3309
+ exports.TextInput = TextInput;
3310
+ exports.Timeline = Timeline;
3311
+ exports.TimelineElement = TimelineElement;
3312
+ exports.Tip = Tip;
3313
+ exports.TitleGridArea = TitleGridArea;
3314
+ exports.TitleNavContentLayout = TitleNavContentLayout;
3315
+ exports.Toggle = Toggle;
3316
+ exports.Tooltip = Tooltip;
3317
+ exports.TwoColumnLayout = TwoColumnLayout;
3318
+ exports.UploadField = UploadField;
3319
+ exports.UploadInput = UploadInput;
3320
+ exports.ValueBar = ValueBar;
3321
+ exports.docs = docs;
3322
+ exports.getDevicePixelRatio = getDevicePixelRatio;
3323
+ exports.getOrderedOptions = getOrderedOptions;
3324
+ exports.getValueBarColorByValue = getValueBarColorByValue;
3325
+ exports.isMultiValue = isMultiValue;
3326
+ exports.useContainerProps = useContainerProps;
3327
+ exports.useCustomComponents = useCustomComponents;
3328
+ exports.useDebounce = useDebounce;
3329
+ exports.useDevicePixelRatio = useDevicePixelRatio;
3330
+ exports.useLocalStorage = useLocalStorage;
3331
+ exports.useModal = useModal;
3332
+ exports.usePopoverContext = usePopoverContext;
3333
+ exports.usePrompt = usePrompt;
3334
+ exports.useTimeout = useTimeout;