@trackunit/react-components 0.1.65 → 0.1.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.cjs +3315 -0
  2. package/package.json +5 -5
package/index.cjs ADDED
@@ -0,0 +1,3315 @@
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 reactRouterDom = require('react-router-dom');
13
+ var reactDayPicker = require('react-day-picker');
14
+ var locale = require('date-fns/locale');
15
+ var reactBrowserHooks = require('react-browser-hooks');
16
+ var usePortal = require('react-useportal');
17
+ var ReactSelect = require('react-select');
18
+ var ReactAsyncCreatableSelect = require('react-select/async-creatable');
19
+ var ReactCreatableSelect = require('react-select/creatable');
20
+ var ReactAsyncSelect = require('react-select/async');
21
+ var libphonenumberJs = require('libphonenumber-js');
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$4, 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$4 = 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$3, 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$3 = 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
+ * @param {PopoverProps} props The children to render in the popover
911
+ * @returns {ReactElement} Popover with specified content and placement
912
+ */
913
+ const Popover = ({ children, render, placement, activation = { click: true, hover: false }, className, dataTestId, }) => {
914
+ const [open, setOpen] = React.useState(false);
915
+ const { x, y, reference, floating, strategy, context } = react.useFloating({
916
+ open,
917
+ onOpenChange: setOpen,
918
+ middleware: [
919
+ react.offset(8),
920
+ react.flip({ fallbackPlacements: ["top", "bottom", "right", "left"] }),
921
+ react.size({
922
+ apply({ availableWidth, availableHeight, elements }) {
923
+ Object.assign(elements.floating.style, {
924
+ maxWidth: `${availableWidth}px`,
925
+ maxHeight: `${availableHeight}px`,
926
+ });
927
+ },
928
+ }),
929
+ react.shift(),
930
+ ],
931
+ placement,
932
+ whileElementsMounted: react.autoUpdate,
933
+ });
934
+ const { getReferenceProps, getFloatingProps } = react.useInteractions([
935
+ react.useClick(context, { enabled: activation.click, ignoreMouse: activation.hover }),
936
+ react.useHover(context, { enabled: activation.hover }),
937
+ react.useRole(context),
938
+ react.useDismiss(context),
939
+ ]);
940
+ // Preserve the consumer's ref
941
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
942
+ const ref = React.useMemo(() => mergeRefs([reference, children.ref]), [reference, children]);
943
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [React.cloneElement(children, getReferenceProps(Object.assign({ ref }, children.props))), jsxRuntime.jsx(react.FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: open && (jsxRuntime.jsx(react.FloatingFocusManager, Object.assign({ guards: false, context: context, modal: false, order: ["reference", "content"], returnFocus: false }, { children: jsxRuntime.jsx("div", Object.assign({ ref: floating, className: `tu-popover-container animate-fade-in-fast ${className !== null && className !== void 0 ? className : ""}`, "data-testid": dataTestId, style: {
944
+ position: strategy,
945
+ top: y !== null && y !== void 0 ? y : 0,
946
+ left: x !== null && x !== void 0 ? x : 0,
947
+ display: "flex",
948
+ } }, getFloatingProps(), { children: render({
949
+ close: () => {
950
+ setOpen(false);
951
+ },
952
+ }) })) }))) }))] }));
953
+ };
954
+ // Utility to merge refs — Heavily inspired by https://github.com/gregberge/react-merge-refs
955
+ function mergeRefs(refs) {
956
+ return value => {
957
+ refs.forEach(ref => {
958
+ if (typeof ref === "function") {
959
+ ref(value);
960
+ }
961
+ else if (ref !== null) {
962
+ ref.current = value;
963
+ }
964
+ });
965
+ };
966
+ }
967
+
968
+ /**
969
+ * The PopoverList component.
970
+ *
971
+ * @param {PopoverListProps} props - The props for the PopoverList component
972
+ * @returns {JSX.Element} PopoverList component
973
+ */
974
+ const PopoverList = ({ className, children, dataTestId }) => {
975
+ return (jsxRuntime.jsx(Card, Object.assign({ className: className, dataTestId: dataTestId }, { children: jsxRuntime.jsx(StyledCardBody, Object.assign({ density: "comfortable" }, { children: jsxRuntime.jsx(List, { children: children }) })) })));
976
+ };
977
+ const List = tailwindStyledComponents.tw.ul `
978
+ tu-popover-list
979
+ `;
980
+ const StyledCardBody = tailwindStyledComponents.twx(CardBody) `
981
+ tu-popover-list-body
982
+ `;
983
+
984
+ /**
985
+ * The PopoverListItem component.
986
+ *
987
+ * @param {PopoverListItemProps} props - The props for the PopoverListItem component
988
+ * @returns {JSX.Element} PopoverListItem component
989
+ */
990
+ const PopoverListItem = ({ selected, children, disabled, ariaLabel, url, onClick, prefix, suffix, dataTestId, className, }) => {
991
+ const content = (jsxRuntime.jsxs("div", Object.assign({ className: "flex items-center gap-3" }, { children: [prefix && jsxRuntime.jsx("div", { children: prefix }), jsxRuntime.jsx(StyledText$2, Object.assign({ weight: selected ? "bold" : "normal", "$selected": selected }, { children: children })), suffix && jsxRuntime.jsx("div", { children: suffix })] })));
992
+ return (jsxRuntime.jsx(ListItem, Object.assign({ "$selected": selected, disabled: disabled, onClick: onClick, "aria-label": ariaLabel, "data-testid": dataTestId, className: className }, { children: url ? jsxRuntime.jsx(PopoverLink, Object.assign({ to: url }, { children: content })) : content })));
993
+ };
994
+ const StyledText$2 = tailwindStyledComponents.twx(Text$1) `
995
+ tu-popover-list-item__text
996
+ ${p => p.$selected && tailwindStyledComponents.tws `tu-popover-list-item__text--selected`}
997
+ `;
998
+ const ListItem = tailwindStyledComponents.tw.li `
999
+ group
1000
+ tu-popover-list-item
1001
+ ${p => p.disabled && tailwindStyledComponents.tws `tu-popover-list-item--disabled`}
1002
+ `;
1003
+ const PopoverLink = tailwindStyledComponents.twx(reactRouterDom.Link) `
1004
+ tu-popover-list-item__anchor
1005
+ `;
1006
+
1007
+ /**
1008
+ * The PopoverTitle component.
1009
+ *
1010
+ * @param {PopoverTitleProps} props - The props for the PopoverTitle component
1011
+ * @returns {JSX.Element} PopoverTitle component
1012
+ */
1013
+ const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
1014
+ 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] })));
1015
+ };
1016
+ const Container$6 = tailwindStyledComponents.tw.div `
1017
+ tu-popover-title-container
1018
+ ${p => p.$divider && `tu-popover-title-container--divider`}
1019
+ `;
1020
+ const StyledText$1 = tailwindStyledComponents.twx(Text$1) `
1021
+ tu-popover-title-text
1022
+ `;
1023
+
1024
+ /**
1025
+ * The Tooltip component is used to show helpful tips or contextual information to the users.
1026
+ *
1027
+ * @param {TooltipProps} props - The props for the Tooltip component
1028
+ * @returns {JSX.Element} Tooltip component
1029
+ */
1030
+ const Tooltip = (_a) => {
1031
+ var { children, dataTestId, disabled, className } = _a, rest = __rest(_a, ["children", "dataTestId", "disabled", "className"]);
1032
+ const wrappedChildren = (jsxRuntime.jsx(Flex$1, Object.assign({ className: className, "data-testid": dataTestId && `${dataTestId}-parent` }, { children: children })));
1033
+ if (disabled) {
1034
+ return wrappedChildren;
1035
+ }
1036
+ return (jsxRuntime.jsx(TooltipContainer, Object.assign({ dataTestId: dataTestId }, rest, { children: wrappedChildren })));
1037
+ };
1038
+ const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxRuntime.jsx(StyledPopover, Object.assign({ className: "tu-tooltip__container", placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", render: () => (jsxRuntime.jsx(Content, Object.assign({ "$mode": mode }, { children: jsxRuntime.jsx(Text$1, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) }))) }, { children: children })));
1039
+ const Flex$1 = tailwindStyledComponents.tw.div `
1040
+ inline-flex
1041
+ `;
1042
+ const StyledPopover = tailwindStyledComponents.twx(Popover) `
1043
+ tu-tooltip__container
1044
+ `;
1045
+ const Content = tailwindStyledComponents.tw.div `
1046
+ tu-tooltip__content
1047
+ ${p => (p.$mode === "light" ? tailwindStyledComponents.tws `tu-tooltip--light` : null)}
1048
+ `;
1049
+
1050
+ /**
1051
+ * The Tip component is used to show helpful tips or contextual information to the users.
1052
+ * The tip can optionally be rendered as an anchor tag, which redirects to users to an external link on click.
1053
+ *
1054
+ * @param {TipProps} props - The props for the Tip component
1055
+ * @returns {JSX.Element} Tip component
1056
+ */
1057
+ const Tip = ({ children, iconProps, dataTestId, link, renderAs = "span", className, placement = "bottom", mode, }) => {
1058
+ const ifAnchorTag = renderAs === "a";
1059
+ 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)) })) })));
1060
+ };
1061
+ const TipContainer = tailwindStyledComponents.tw.text `
1062
+ tu-tip
1063
+ `;
1064
+
1065
+ /**
1066
+ * The FormGroup component should be used to wrap any Input element that needs a label.
1067
+ * Besides a label the component supplies an optional Tip, HelpText and HelpAddon support.
1068
+ *
1069
+ * @param {FormGroupProps} props - The props for the FormGroup component
1070
+ * @returns {JSX.Element} FormGroup component
1071
+ */
1072
+ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, children, disabled = false, }) => {
1073
+ 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 }))] }))] })));
1074
+ };
1075
+ const FormGroupRoot = tailwindStyledComponents.tw.label `
1076
+ tu-form-group
1077
+ ${({ $disabled }) => {
1078
+ return $disabled ? "pointer-events-none " : null;
1079
+ }}
1080
+ `;
1081
+ const ContainerBefore = tailwindStyledComponents.tw.div `
1082
+ tu-form-group__container-before
1083
+ `;
1084
+ const FormGroupLabel = tailwindStyledComponents.twx(Label$2) `
1085
+ component-formGroup-font
1086
+ `;
1087
+ const ContainerAfter = tailwindStyledComponents.tw.div `
1088
+ tu-form-group__container-after
1089
+ ${({ $isInvalid }) => ($isInvalid ? tailwindStyledComponents.tws `tu-form-group__container-after--invalid` : null)}
1090
+ `;
1091
+ const HelpAddon = tailwindStyledComponents.tw.span `
1092
+ tu-form-group__help-addon
1093
+ `;
1094
+
1095
+ /**
1096
+ * The date field component is used for entering date values.
1097
+ *
1098
+ * _**Do use**_ the DateField for date input.
1099
+ *
1100
+ * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
1101
+ */
1102
+ const DateField = React.forwardRef((_a, ref) => {
1103
+ var { label, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
1104
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1105
+ 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 })) })));
1106
+ });
1107
+
1108
+ const localeLookup = {
1109
+ en: locale.enGB,
1110
+ "en-US": locale.enUS,
1111
+ "en-GB": locale.enGB,
1112
+ da: locale.da,
1113
+ de: locale.de,
1114
+ cs: locale.cs,
1115
+ nl: locale.nl,
1116
+ fr: locale.fr,
1117
+ fi: locale.fi,
1118
+ hu: locale.hu,
1119
+ it: locale.it,
1120
+ nb: locale.nb,
1121
+ pl: locale.pl,
1122
+ pt: locale.pt,
1123
+ ru: locale.ru,
1124
+ ro: locale.ro,
1125
+ es: locale.es,
1126
+ sv: locale.sv,
1127
+ ja: locale.ja,
1128
+ th: locale.th,
1129
+ };
1130
+ /**
1131
+ * A helper function to get the matching Locale object for a given language.
1132
+ *
1133
+ * @param {string} language The language to match
1134
+ * @returns {Locale} The corresponding Locale object
1135
+ */
1136
+ const useLocale = (language) => {
1137
+ return localeLookup[language] || localeLookup.en;
1138
+ };
1139
+
1140
+ /**
1141
+ * The DayPicker component is used when the user needs to select a date.
1142
+ *
1143
+ * @param {DayPickerProps} props - The props for the DayPicker component
1144
+ * @returns {JSX.Element} DayPicker component
1145
+ */
1146
+ const DayPicker = ({ onDaySelect, disabledDays, selectedDays, language, className, dataTestId, max, }) => {
1147
+ const locale = useLocale(language);
1148
+ 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 }) }));
1149
+ };
1150
+
1151
+ /**
1152
+ * The DayPickerPopover component returns a button which when clicked shows the daypicker.
1153
+ *
1154
+ * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
1155
+ * @returns {JSX.Element} DayPickerPopover component
1156
+ */
1157
+ const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
1158
+ return (jsxRuntime.jsx(Popover, Object.assign({ placement: placement, render: () => (jsxRuntime.jsx(PopoverList, { children: jsxRuntime.jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) })) }, { 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 })) })));
1159
+ };
1160
+
1161
+ /**
1162
+ * The DayRangePicker component should be used when the user needs to select a range of dates.
1163
+ *
1164
+ * @param {DayRangePickerProps} props - The props for the DayRangePicker component
1165
+ * @returns {JSX.Element} DayRangePicker component
1166
+ */
1167
+ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, dataTestId, language, className, max, }) => {
1168
+ const locale = useLocale(language);
1169
+ const onSelect = React.useCallback((range) => {
1170
+ if (onRangeSelect && range === undefined) {
1171
+ onRangeSelect(undefined);
1172
+ }
1173
+ if (onRangeSelect && range) {
1174
+ const from = range.from;
1175
+ const to = range.to ? range.to : range.from;
1176
+ onRangeSelect({ from, to });
1177
+ }
1178
+ }, [onRangeSelect]);
1179
+ 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 }) }));
1180
+ };
1181
+
1182
+ /**
1183
+ * The drawer provides a slideover which can be used to provide access to different locations in the application.
1184
+ *
1185
+ * @param {DrawerProps} props - The props for the Drawer component
1186
+ * @returns {JSX.Element} Drawer component
1187
+ */
1188
+ const Drawer = ({ open, onClose = () => { }, children, disableOverlay = false, position = "left", className, dataTestId, }) => {
1189
+ const { context } = react.useFloating();
1190
+ React.useEffect(() => {
1191
+ // Close overlay when pressing escape button.
1192
+ const onKeyPress = (e) => {
1193
+ if (e.key === "Escape") {
1194
+ onClose();
1195
+ }
1196
+ };
1197
+ if (open) {
1198
+ window.addEventListener("keyup", onKeyPress);
1199
+ }
1200
+ return () => {
1201
+ window.removeEventListener("keyup", onKeyPress);
1202
+ };
1203
+ }, [open, onClose]);
1204
+ 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 }))] }))) : (
1205
+ // eslint-disable-next-line react/jsx-no-useless-fragment
1206
+ jsxRuntime.jsx(jsxRuntime.Fragment, {})) })));
1207
+ };
1208
+ const getPositionStyles = ($position) => {
1209
+ switch ($position) {
1210
+ case "top":
1211
+ return tailwindStyledComponents.tws `tu-drawer__card--top`;
1212
+ case "right":
1213
+ return tailwindStyledComponents.tws `tu-drawer__card--right`;
1214
+ case "bottom":
1215
+ return tailwindStyledComponents.tws `tu-drawer__card--bottom`;
1216
+ case "left":
1217
+ default:
1218
+ return tailwindStyledComponents.tws `tu-drawer__card--left`;
1219
+ }
1220
+ };
1221
+ const StyledCard$1 = tailwindStyledComponents.twx(Card) `
1222
+ tu-drawer__card
1223
+ ${({ $open }) => $open && tailwindStyledComponents.tws `tu-drawer__card--open`}
1224
+ ${({ $position }) => getPositionStyles($position)}
1225
+ `;
1226
+ const Root$6 = tailwindStyledComponents.tw.div `
1227
+ tu-drawer
1228
+ `;
1229
+ const Overlay = tailwindStyledComponents.tw.div `
1230
+ tu-drawer__overlay
1231
+ ${({ $open }) => $open && tailwindStyledComponents.tws `tu-drawer__overlay--open`}
1232
+ `;
1233
+
1234
+ /**
1235
+ * The Drop Zone can be used to drag and drop files
1236
+ *
1237
+ * @param {DropZoneProps} props - The props for the DropZone component
1238
+ * @returns {JSX.Element} DropZone component
1239
+ */
1240
+ const DropZone = (_a) => {
1241
+ var { className, dataTestId, filesSelected, label, size = "large", isInvalid = false, disabled = false } = _a, rest = __rest(_a, ["className", "dataTestId", "filesSelected", "label", "size", "isInvalid", "disabled"]);
1242
+ const [dragActive, setDragActive] = React__default["default"].useState(false);
1243
+ const [fileDropped, setFileDropped] = React__default["default"].useState(false);
1244
+ // function that handles drag enter, drag leave and drag over
1245
+ const handleDrag = (e) => {
1246
+ e.preventDefault();
1247
+ e.stopPropagation();
1248
+ if ((e.type === "dragenter" || e.type === "dragover") && !disabled) {
1249
+ setDragActive(true);
1250
+ }
1251
+ else if (e.type === "dragleave") {
1252
+ setDragActive(false);
1253
+ }
1254
+ };
1255
+ //function to handle when user clicks on dropzone to upload
1256
+ const handleChange = (e) => {
1257
+ e.preventDefault();
1258
+ e.stopPropagation();
1259
+ if (e.target.files && !disabled) {
1260
+ filesSelected(e.target.files);
1261
+ }
1262
+ };
1263
+ //funtion to handle drop
1264
+ const handleDrop = (e) => {
1265
+ e.preventDefault();
1266
+ e.stopPropagation();
1267
+ setDragActive(false);
1268
+ if (e.dataTransfer.files && e.dataTransfer.files[0] && !disabled) {
1269
+ filesSelected(e.dataTransfer.files);
1270
+ setFileDropped(true);
1271
+ }
1272
+ };
1273
+ 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 => {
1274
+ if (disabled) {
1275
+ e.preventDefault();
1276
+ e.stopPropagation();
1277
+ }
1278
+ } }, 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 })] }))] })));
1279
+ };
1280
+ const Root$5 = tailwindStyledComponents.tw.div `
1281
+ tu-drop-zone
1282
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-drop-zone--small` : null)}
1283
+ ${({ $size }) => ($size === "medium" ? tailwindStyledComponents.tws `tu-drop-zone--medium` : null)}
1284
+ ${({ $size }) => ($size === "large" ? tailwindStyledComponents.tws `tu-drop-zone--large` : null)}
1285
+ ${({ $dragActive }) => ($dragActive ? tailwindStyledComponents.tws `tu-drop-zone--drag-active` : null)}
1286
+ ${({ $fileDropped }) => ($fileDropped ? tailwindStyledComponents.tws `tu-drop-zone--drop-complete` : null)}
1287
+ ${({ $isInvalid }) => ($isInvalid ? tailwindStyledComponents.tws `tu-drop-zone--invalid` : null)}
1288
+ ${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-drop-zone--disabled` : null)}
1289
+ `;
1290
+ const DropZoneLabel = tailwindStyledComponents.tw.label `
1291
+ tu-drop-zone__label
1292
+ `;
1293
+
1294
+ /**
1295
+ * A Email Input component is used for input of the type Email.
1296
+ *
1297
+ * It has an ActionButton which sends an email to the specified address using "mailto:" link.
1298
+ *
1299
+ * Extends props of BaseInput.
1300
+ *
1301
+ * A reference to the input element is provided as the `ref` prop.
1302
+ * For specific input types make sure to use the corresponding input component.
1303
+ */
1304
+ const EmailInput = React__namespace.forwardRef((_a, ref) => {
1305
+ var { fieldSize = "medium", disabled = false, dataTestId } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId"]);
1306
+ const [email, setEmail] = React__namespace.useState("");
1307
+ const sendEmail = () => {
1308
+ return window.open(`mailto:${email}`);
1309
+ };
1310
+ 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 }) })));
1311
+ });
1312
+
1313
+ /**
1314
+ * The EmailField component is used to enter email.
1315
+ * EmailField validates that user enters a valid email address.
1316
+ *
1317
+ */
1318
+ const EmailField = React.forwardRef((_a, ref) => {
1319
+ var { label, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
1320
+ const [value, setValue] = React.useState(defaultValue);
1321
+ // Type guard to check if value is a string
1322
+ function isString(inputValue) {
1323
+ return typeof inputValue === "string";
1324
+ }
1325
+ // Check the regular expression only if value is a string
1326
+ const renderAsInvalid = !!errorMessage || (isString(value) && !/^\S+@\S+\.\S+$/.test(value));
1327
+ 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 })) })));
1328
+ });
1329
+
1330
+ /**
1331
+ * The external link component is used to link to an external page outside the Trackunit Manager.
1332
+ *
1333
+ * @param {ExternalLinkProps} props - The props for the external link component
1334
+ * @returns {JSX.Element} External Link component
1335
+ */
1336
+ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className, children = href, title = href, dataTestId, }) => {
1337
+ return (jsxRuntime.jsx("a", Object.assign({ "data-testid": dataTestId, className: className, title: title, href: href, rel: rel, target: target }, { children: children })));
1338
+ };
1339
+
1340
+ /**
1341
+ * Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
1342
+ *
1343
+ * Whenever an asset is presented, indicators provide the necessary information for a user to comprehend the state of the asset.
1344
+ *
1345
+ * _**Do use** indicators to communicate essential aspects of the state of an asset._
1346
+ *
1347
+ * _**Do not use** indicators for non-essential information, or to communicate information unrelated to the state of an asset._
1348
+ *
1349
+ * @param {IndicatorProps} props - The props for the Indicator component
1350
+ * @returns {JSX.Element} Indicator component
1351
+ */
1352
+ const Indicator = (_a) => {
1353
+ var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping"]);
1354
+ 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 })))] })));
1355
+ };
1356
+ const Container$5 = tailwindStyledComponents.tw.div `
1357
+ tu-indicator
1358
+ ${({ $color }) => {
1359
+ switch ($color) {
1360
+ case "primary":
1361
+ return tailwindStyledComponents.tws `tu-indicator--primary`;
1362
+ case "secondary":
1363
+ return tailwindStyledComponents.tws `tu-indicator--secondary`;
1364
+ case "accent":
1365
+ return tailwindStyledComponents.tws `tu-indicator--accent`;
1366
+ case "neutral":
1367
+ return tailwindStyledComponents.tws `tu-indicator--neutral`;
1368
+ case "info":
1369
+ return tailwindStyledComponents.tws `tu-indicator--info`;
1370
+ case "success":
1371
+ return tailwindStyledComponents.tws `tu-indicator--success`;
1372
+ case "warning":
1373
+ return tailwindStyledComponents.tws `tu-indicator--warning`;
1374
+ case "danger":
1375
+ return tailwindStyledComponents.tws `tu-indicator--danger`;
1376
+ case "good":
1377
+ return tailwindStyledComponents.tws `tu-indicator--good`;
1378
+ case "low":
1379
+ return tailwindStyledComponents.tws `tu-indicator--low`;
1380
+ case "critical":
1381
+ return tailwindStyledComponents.tws `tu-indicator--critical`;
1382
+ case "working":
1383
+ return tailwindStyledComponents.tws `tu-indicator--working`;
1384
+ case "idle":
1385
+ return tailwindStyledComponents.tws `tu-indicator--idle`;
1386
+ case "stopped":
1387
+ return tailwindStyledComponents.tws `tu-indicator--stopped`;
1388
+ case "moving":
1389
+ return tailwindStyledComponents.tws `tu-indicator--moving`;
1390
+ case "unknown":
1391
+ return tailwindStyledComponents.tws `tu-indicator--unknown`;
1392
+ case "unused":
1393
+ return tailwindStyledComponents.tws `tu-indicator--unused`;
1394
+ case "utilized":
1395
+ return tailwindStyledComponents.tws `tu-indicator--utilized`;
1396
+ case "heavily_utilized":
1397
+ return tailwindStyledComponents.tws `tu-indicator--heavily-utilized`;
1398
+ case "on_rent":
1399
+ return tailwindStyledComponents.tws `tu-indicator--on-rent`;
1400
+ case "available":
1401
+ return tailwindStyledComponents.tws `tu-indicator--available`;
1402
+ case "pickup_ready":
1403
+ return tailwindStyledComponents.tws `tu-indicator--pickup-ready`;
1404
+ case "transfer":
1405
+ return tailwindStyledComponents.tws `tu-indicator--transfer`;
1406
+ case "in_repair":
1407
+ return tailwindStyledComponents.tws `tu-indicator--in-repair`;
1408
+ case "returned":
1409
+ return tailwindStyledComponents.tws `tu-indicator--returned`;
1410
+ case "other_rental_status":
1411
+ return tailwindStyledComponents.tws `tu-indicator--other-rental-status`;
1412
+ default:
1413
+ return "";
1414
+ }
1415
+ }}
1416
+ `;
1417
+ const IconBackground = tailwindStyledComponents.tw.div `
1418
+ tu-indicator__icon-background
1419
+
1420
+ ${({ $withBackground }) => {
1421
+ return $withBackground ? "" : "tu-indicator__icon-background--none";
1422
+ }}
1423
+ `;
1424
+ const Label$1 = tailwindStyledComponents.tw.div `
1425
+ tu-indicator__label
1426
+ `;
1427
+ const Ping = tailwindStyledComponents.tw.span `
1428
+ tu-indicator__ping
1429
+ `;
1430
+
1431
+ /**
1432
+ * The MenuItem component is used to display a menu, primarily meant to be used in a list form.
1433
+ *
1434
+ * @param {MenuItemProps} props - The props for the MenuItem component
1435
+ * @returns {JSX.Element} MenuItem component
1436
+ */
1437
+ const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, }) => {
1438
+ const containerProps = useContainerProps({ className, dataTestId });
1439
+ return (jsxRuntime.jsxs(Container$4, Object.assign({}, containerProps, { onClick: e => {
1440
+ e.stopPropagation();
1441
+ onClick && onClick(e);
1442
+ }, "$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 !== null && children !== void 0 ? children : jsxRuntime.jsx(Label, Object.assign({ "data-testid": dataTestId && `${dataTestId}-label` }, { children: label })), suffix && (jsxRuntime.jsx(Suffix, Object.assign({ "$selected": selected, "data-testid": dataTestId && `${dataTestId}-suffix` }, { children: suffix })))] })));
1443
+ };
1444
+ const Container$4 = tailwindStyledComponents.tw.div `
1445
+ group tu-menu-item
1446
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item--selected ` : "tu-menu-item--unselected")}
1447
+ ${({ $focused }) => ($focused ? tailwindStyledComponents.tws `tu-menu-item--focused ` : "")}
1448
+ ${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-menu-item--disabled ` : "")}
1449
+
1450
+ `;
1451
+ const Suffix = tailwindStyledComponents.tw.div `
1452
+ tu-menu-item__suffix
1453
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item__suffix--selected ` : "")}
1454
+ `;
1455
+ const Prefix = tailwindStyledComponents.tw.div `
1456
+ tu-menu-item__prefix
1457
+ ${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item__prefix--selected ` : "")}
1458
+ `;
1459
+ const Label = tailwindStyledComponents.tw.div `
1460
+ tu-menu-item__label
1461
+ `;
1462
+
1463
+ /**
1464
+ * The MenuList component is used for menus and selects.
1465
+ *
1466
+ * @param {MenuListProps} props - The props for the MenuList component
1467
+ * @returns {JSX.Element} MenuList component
1468
+ */
1469
+ const MenuList = (_a) => {
1470
+ var { dataTestId, className, children, withStickyHeader = false, showDivider = false } = _a; __rest(_a, ["dataTestId", "className", "children", "withStickyHeader", "showDivider"]);
1471
+ const childrenArr = React.Children.toArray(children);
1472
+ const isLastItem = (index) => index === childrenArr.length - 1;
1473
+ return (jsxRuntime.jsx(Container$3, Object.assign({ "$withStickyHeader": withStickyHeader, "data-testid": dataTestId, className: className, tabIndex: 0 }, { children: React.Children.map(childrenArr, (menuItem, index) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsxRuntime.jsx(Divider, {})] }))) })));
1474
+ };
1475
+ const Container$3 = tailwindStyledComponents.tw.div `
1476
+ tu-menu-list
1477
+ ${props => props.$withStickyHeader && tailwindStyledComponents.tws `tu-menu-list--sticky-header`}
1478
+ `;
1479
+ const Divider = tailwindStyledComponents.tw.hr `
1480
+ tu-menu-list__divider
1481
+ `;
1482
+
1483
+ /**
1484
+ * A kebab menu component.
1485
+ * Advice: fill it with MenuList
1486
+ *
1487
+ * @param {MoreMenuProps} props - The props for the MoreMenu component
1488
+ * @returns {JSX.Element} MoreMenu component
1489
+ */
1490
+ const MoreMenu = ({ className, dataTestId, dotsDirection = "horizontal", menuPlacement, iconProps = {
1491
+ size: "medium",
1492
+ }, iconButtonProps = {
1493
+ size: "small",
1494
+ circular: true,
1495
+ square: true,
1496
+ color: "tertiary",
1497
+ }, children, }) => {
1498
+ const [actionMenuIsOpen, setActionMenuIsOpen] = React.useState(false);
1499
+ const dotsName = dotsDirection === "horizontal" ? "EllipsisHorizontalIcon" : "EllipsisVerticalIcon";
1500
+ const actionMenuRef = React.useRef(null);
1501
+ reactBrowserHooks.useClickOutside(actionMenuRef, () => {
1502
+ setActionMenuIsOpen(false);
1503
+ });
1504
+ return (jsxRuntime.jsx(Root$4, Object.assign({ ref: actionMenuRef, className: className, "data-testid": dataTestId }, { children: jsxRuntime.jsx(Popover, Object.assign({ render: () => children, placement: menuPlacement }, { children: jsxRuntime.jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsxRuntime.jsx(Icon, Object.assign({ name: dotsName }, iconProps)), onClick: () => {
1505
+ setActionMenuIsOpen(!actionMenuIsOpen);
1506
+ } })) })) })));
1507
+ };
1508
+ const Root$4 = tailwindStyledComponents.tw.div `
1509
+ tu-more-menu
1510
+ ${({ variant }) => (variant === "primary" ? tailwindStyledComponents.tws `tu-more-menu--primary` : "")}
1511
+ `;
1512
+
1513
+ /**
1514
+ * The Backdrop for the modal.
1515
+ *
1516
+ * @param {ModalBackdropProps} props - The props for the ModalBackdrop component
1517
+ * @returns {JSX.Element} ModalBackdrop component
1518
+ */
1519
+ const ModalBackdrop = ({ children, isVisible, onClick }) => {
1520
+ const ref = React__namespace.useRef(null);
1521
+ return (jsxRuntime.jsx(Backdrop, Object.assign({ ref: ref, "$isVisible": isVisible, onMouseDown: e => {
1522
+ var _a, _b;
1523
+ // only react on click on backdrop - accessing first child to get around styled element element
1524
+ if (ref.current !== null) {
1525
+ 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])) {
1526
+ onClick();
1527
+ }
1528
+ }
1529
+ } }, { children: children })));
1530
+ };
1531
+ const Backdrop = tailwindStyledComponents.tw.div `
1532
+ tu-modal-backdrop
1533
+ ${({ $isVisible }) => {
1534
+ return $isVisible && tailwindStyledComponents.tws `tu-modal-backdrop--show`;
1535
+ }}
1536
+ `;
1537
+
1538
+ /**
1539
+ * - Modals are used to present critical information or request user input needed to complete a user's workflow.
1540
+ * - Modals interrupt a user's workflow by design.
1541
+ * - The modal component provides a foundation for creating dialogs, lightboxes, etc.
1542
+ */
1543
+ const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, className, role = "", onDismissClick = () => {
1544
+ return;
1545
+ }, }, ref) => {
1546
+ 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 })) }))) })));
1547
+ });
1548
+ const StyledCard = tailwindStyledComponents.twx(Card) `
1549
+ tu-modal__card
1550
+ `;
1551
+ const StyledDiv = tailwindStyledComponents.tw.div `
1552
+ tu-modal__container
1553
+ `;
1554
+
1555
+ /**
1556
+ * The useModal component should be used to inform the user of important information.
1557
+ *
1558
+ * @param {UseModalProps} props - The props for the useModal hook
1559
+ * @returns {*} useModal return
1560
+ */
1561
+ const useModal = ({ closeOnOutsideClick } = {}) => {
1562
+ const modalRef = React.useRef(null);
1563
+ const { isOpen, togglePortal, openPortal, closePortal, Portal } = usePortal__default["default"]({
1564
+ closeOnOutsideClick,
1565
+ onPortalClick: ({ target }) => {
1566
+ if (!closeOnOutsideClick) {
1567
+ return;
1568
+ }
1569
+ const clickingOutsideModal = modalRef && modalRef.current && !modalRef.current.contains(target);
1570
+ if (clickingOutsideModal) {
1571
+ closePortal();
1572
+ }
1573
+ },
1574
+ });
1575
+ const PortalWrapper = (props) => (jsxRuntime.jsx(Portal, { children: jsxRuntime.jsx(Modal, Object.assign({ ref: modalRef, isOpen: isOpen }, props)) }));
1576
+ PortalWrapper.displayName = "Modal";
1577
+ const WrappedModal = React.useCallback(PortalWrapper, [Portal, isOpen]);
1578
+ return {
1579
+ Modal: WrappedModal,
1580
+ toggleModal: togglePortal,
1581
+ openModal: openPortal,
1582
+ closeModal: closePortal,
1583
+ isOpen,
1584
+ };
1585
+ };
1586
+
1587
+ /**
1588
+ * A thin wrapper around the `BaseInput` component for number input fields.
1589
+ *
1590
+ * NOTE: If shown with a label, please use the `NumberField` component instead.
1591
+ */
1592
+ const NumberInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props))));
1593
+
1594
+ /**
1595
+ * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
1596
+ *
1597
+ * _**Do use**_ the NumberField when the controls to incrementally increase or decrease makes the task easier for the user.
1598
+ *
1599
+ * _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
1600
+ */
1601
+ const NumberField = React.forwardRef((_a, ref) => {
1602
+ 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"]);
1603
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
1604
+ 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 })) })));
1605
+ });
1606
+
1607
+ /**
1608
+ * The tag component is used to categorize elements in the ui.
1609
+ *
1610
+ * This could be to tell the state of an asset, or label a page as Beta.
1611
+ *
1612
+ * The tag is also used in multiselect components to show selected options.
1613
+ *
1614
+ * **Do:** Use short labels for easy scanning.
1615
+ *
1616
+ * @param {TagProps} props - The props for the tag component
1617
+ * @returns {JSX.Element} tag component
1618
+ */
1619
+ const Tag = React__namespace.forwardRef((_a, ref) => {
1620
+ var { className, dataTestId, children, size = "medium", onClose, color = "primary" } = _a; __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
1621
+ 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 && (
1622
+ // a fix for multiselect deselecting tags working together with fade out animation
1623
+ 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` }) })))] })));
1624
+ });
1625
+ const getSizeModifierClass = () => ({ $size, $withXIcon }) => {
1626
+ const tagSizeModifierClass = {
1627
+ medium: $withXIcon ? tailwindStyledComponents.tws `tu-tag--with-icon ` : tailwindStyledComponents.tws ` `,
1628
+ small: $withXIcon ? tailwindStyledComponents.tws `tu-tag--small tu-tag--with-icon` : tailwindStyledComponents.tws `tu-tag--small`,
1629
+ };
1630
+ return tagSizeModifierClass[$size];
1631
+ };
1632
+ const getColorModifierClass = () => ({ $color }) => {
1633
+ const colorClasses = {
1634
+ primary: tailwindStyledComponents.tws `tu-tag--primary`,
1635
+ secondary: tailwindStyledComponents.tws `tu-tag--secondary`,
1636
+ accent: tailwindStyledComponents.tws `tu-tag--accent`,
1637
+ success: tailwindStyledComponents.tws `tu-tag--success`,
1638
+ danger: tailwindStyledComponents.tws `tu-tag--danger`,
1639
+ warning: tailwindStyledComponents.tws `tu-tag--warning`,
1640
+ info: tailwindStyledComponents.tws `tu-tag--info`,
1641
+ neutral: tailwindStyledComponents.tws `tu-tag--neutral`,
1642
+ good: tailwindStyledComponents.tws `tu-tag--good`,
1643
+ low: tailwindStyledComponents.tws `tu-tag--low`,
1644
+ critical: tailwindStyledComponents.tws `tu-tag--critical`,
1645
+ working: tailwindStyledComponents.tws `tu-tag--working`,
1646
+ idle: tailwindStyledComponents.tws `tu-tag--idle`,
1647
+ stopped: tailwindStyledComponents.tws `tu-tag--stopped`,
1648
+ unknown: tailwindStyledComponents.tws `tu-tag--unknown`,
1649
+ };
1650
+ return colorClasses[$color];
1651
+ };
1652
+ const StyledText = tailwindStyledComponents.tw.span `
1653
+ tu-tag
1654
+ ${getSizeModifierClass()}
1655
+ ${getColorModifierClass()}
1656
+ `;
1657
+ const IconContainer = tailwindStyledComponents.tw.div `
1658
+ tu-tag__icon-container
1659
+ `;
1660
+
1661
+ /**
1662
+ * Pageheader component is used to display a page header.
1663
+ *
1664
+ * 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.
1665
+ *
1666
+ * @param {PageHeaderProps} props - The props for the PageHeader component
1667
+ * @returns {JSX.Element} PageHeader component
1668
+ */
1669
+ const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, children, }) => {
1670
+ 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 })] })));
1671
+ };
1672
+ function isValidHttpUrl(link) {
1673
+ if (!link) {
1674
+ return false;
1675
+ }
1676
+ let url;
1677
+ try {
1678
+ url = new URL(link);
1679
+ }
1680
+ catch (_) {
1681
+ return false;
1682
+ }
1683
+ return url.protocol === "http:" || url.protocol === "https:";
1684
+ }
1685
+ const StyledPageHeader = tailwindStyledComponents.tw.div `
1686
+ tu-page-header
1687
+ `;
1688
+ const HeadingAndAccessoriesContainer = tailwindStyledComponents.tw.div `
1689
+ tu-page-header__heading-accessories-container
1690
+ `;
1691
+ const HeadingContainer = tailwindStyledComponents.tw.div `
1692
+ tu-page-header__heading-container
1693
+ `;
1694
+ const Heading = tailwindStyledComponents.tw.h1 `
1695
+ tu-page-header__heading
1696
+ `;
1697
+ const ChildContainer$1 = tailwindStyledComponents.tw.div `
1698
+ tu-page-header__child-container
1699
+ `;
1700
+ const StyledTip = tailwindStyledComponents.twx(Tip) `
1701
+ ${p => (p.link ? tailwindStyledComponents.tws `tu-page-header__tip` : null)}
1702
+ `;
1703
+
1704
+ /**
1705
+ * Display placeholder lines before the data gets loaded to reduce load-time frustration.
1706
+ */
1707
+ const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId }) => {
1708
+ const skeletonLines = [];
1709
+ const getWidth = (index) => {
1710
+ if (width instanceof Array) {
1711
+ return width[index] || "100%";
1712
+ }
1713
+ return width;
1714
+ };
1715
+ const getHeight = (index) => {
1716
+ if (height instanceof Array) {
1717
+ return height[index] || "auto";
1718
+ }
1719
+ return height;
1720
+ };
1721
+ for (let i = 0; i < lines; i++) {
1722
+ 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));
1723
+ }
1724
+ // eslint-disable-next-line react/jsx-no-useless-fragment
1725
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
1726
+ });
1727
+ const SkeletonLine = tailwindStyledComponents.tw.div `
1728
+ tu-skeleton-line
1729
+ `;
1730
+
1731
+ /**
1732
+ * Pagination Description. It could be used when you need navigation for your paging feature.
1733
+ *
1734
+ * @param {IPaginationProps} props - The props for the Pagination component
1735
+ * @returns {JSX.Element} Pagination component
1736
+ */
1737
+ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, pageCount, pageIndex, loading, className, dataTestId, getTranslatedCount, onPageChange, cursorBase, }) => {
1738
+ const [page, setPage] = React.useState(pageIndex);
1739
+ const [currentPage, setCurrentPage] = React.useState(String(pageIndex !== undefined ? pageIndex + 1 : 1));
1740
+ if (!loading && pageCount === undefined) {
1741
+ throw Error("Pagination should be provided with a pageCount");
1742
+ }
1743
+ React.useEffect(() => {
1744
+ if (pageIndex !== undefined && (isNaN(pageIndex) || pageIndex < 0)) {
1745
+ setPage(pageIndex);
1746
+ setCurrentPage(String(pageIndex + 1));
1747
+ }
1748
+ }, [pageIndex, setPage, setCurrentPage, pageCount]);
1749
+ const handlePageChange = React.useCallback((action) => {
1750
+ const from = page;
1751
+ let to = from;
1752
+ let description = "";
1753
+ switch (action) {
1754
+ case "prev":
1755
+ to = from !== undefined ? from - 1 : 0;
1756
+ previousPage();
1757
+ description = "Previous Page";
1758
+ break;
1759
+ case "next":
1760
+ to = from !== undefined ? from + 1 : 0;
1761
+ nextPage();
1762
+ description = "Next Page";
1763
+ break;
1764
+ }
1765
+ if (to !== undefined && to >= 0) {
1766
+ setPage(to);
1767
+ setCurrentPage(String(to + 1));
1768
+ }
1769
+ onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange({ from, to, description });
1770
+ }, [page, onPageChange, previousPage, nextPage]);
1771
+ if (loading) {
1772
+ return (jsxRuntime.jsx(Root$3, Object.assign({ className: className }, { children: jsxRuntime.jsx(SkeletonLines, { height: 16, width: 150 }) })));
1773
+ }
1774
+ 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
1775
+ ? !canNextPage || false
1776
+ : 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" })] })));
1777
+ };
1778
+ const Root$3 = tailwindStyledComponents.tw.div `
1779
+ tu-pagination
1780
+ `;
1781
+ const TextStyled = tailwindStyledComponents.twx(Text$1) `
1782
+ tu-pagination__text
1783
+ `;
1784
+
1785
+ /**
1786
+ * The SelectContainer component.
1787
+ *
1788
+ * @param {SelectContainerProps} props - The props for the SelectContainer component
1789
+ * @returns {JSX.Element} SelectContainer component
1790
+ */
1791
+ const SelectContainer$1 = ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, isDisabled, }) => {
1792
+ 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 })))] })));
1793
+ };
1794
+ const Container$2 = tailwindStyledComponents.tw.label `
1795
+ tu-select__container
1796
+ tu-select
1797
+ ${({ $hasError }) => ($hasError ? tailwindStyledComponents.tws `tu-select--invalid` : null)}
1798
+ ${({ $isDisabled }) => ($isDisabled ? tailwindStyledComponents.tws `tu-select--disabled` : null)}
1799
+ `;
1800
+ const InformativeText = tailwindStyledComponents.twx(Text$1) `
1801
+ tu-informative-text
1802
+ ${p => (p.$hasError ? `tu-informative-text--error` : null)}
1803
+ `;
1804
+
1805
+ /**
1806
+ * @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
1807
+ * @returns {arg is MultiValue<Option> } is Multivalue
1808
+ */
1809
+ function isMultiValue(arg) {
1810
+ return Array.isArray(arg);
1811
+ }
1812
+ function isGroupBase(arg) {
1813
+ return arg.options !== undefined;
1814
+ }
1815
+ const isSelectedOption = (option, selected) => {
1816
+ if (isGroupBase(option)) {
1817
+ return false;
1818
+ }
1819
+ return isMultiValue(selected)
1820
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
1821
+ selected.some(v => v.value === option.value)
1822
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
1823
+ option.value === (selected === null || selected === void 0 ? void 0 : selected.value);
1824
+ };
1825
+ const removeSelectedFromGroups = (group, selected) => {
1826
+ if (isGroupBase(group)) {
1827
+ return Object.assign(Object.assign({}, group), { options: group.options.filter(option => !isSelectedOption(option, selected)) });
1828
+ }
1829
+ return group;
1830
+ };
1831
+ /**
1832
+ * @template IsMulti
1833
+ * @template Group
1834
+ * @param {OptionsOrGroups<Option, Group> | undefined} options An array of options to select from
1835
+ * @param {PropsValue<Option> | undefined} value Selected values
1836
+ * @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
1837
+ */
1838
+ const getOrderedOptions = (options, value) => {
1839
+ if (value && options) {
1840
+ const orderedValues = isMultiValue(value)
1841
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
1842
+ [...value].sort((a, b) => a.label.localeCompare(b.label))
1843
+ : [value];
1844
+ const selectableOptions = options
1845
+ .filter(option => !isSelectedOption(option, value))
1846
+ .map(option => removeSelectedFromGroups(option, value));
1847
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1848
+ return orderedValues.concat(selectableOptions) || [];
1849
+ }
1850
+ return options || [];
1851
+ };
1852
+ const SelectPrefix = tailwindStyledComponents.tw.div `
1853
+ tu-select__prefix
1854
+ `;
1855
+
1856
+ /**
1857
+ * A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
1858
+ *
1859
+ * @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
1860
+ * @returns {JSX.Element} SingleSelectMenuItem
1861
+ */
1862
+ const SingleSelectMenuItem = ({ label, icon, onClick, selected, dataTestId, focused, disabled, }) => {
1863
+ 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 }));
1864
+ };
1865
+ /**
1866
+ * A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
1867
+ *
1868
+ * @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
1869
+ * @returns {JSX.Element} multi select menu item
1870
+ */
1871
+ const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, focused, disabled, }) => {
1872
+ return (jsxRuntime.jsx(MenuItem, { dataTestId: dataTestId, label: label, disabled: disabled, prefix: jsxRuntime.jsx(Checkbox, { checked: selected, readOnly: false, onChange: () => null, disabled: disabled, onClick: e => {
1873
+ e.stopPropagation();
1874
+ } }), onClick: e => {
1875
+ e.stopPropagation();
1876
+ onClick && onClick(e);
1877
+ }, selected: selected, focused: focused }));
1878
+ };
1879
+
1880
+ /**
1881
+ * Extended Tag component with information about its own width.
1882
+ * Used in the select component.
1883
+ *
1884
+ * @param {TagProps} props - The props for the tag component
1885
+ * @returns {JSX.Element} TagWithWidth component
1886
+ */
1887
+ const TagWithWidth = (_a) => {
1888
+ var { onWidthKnown, children } = _a, rest = __rest(_a, ["onWidthKnown", "children"]);
1889
+ const ref = React__default["default"].useRef(null);
1890
+ React__default["default"].useLayoutEffect(() => {
1891
+ var _a;
1892
+ onWidthKnown && onWidthKnown({ width: ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0 });
1893
+ }, [ref, onWidthKnown]);
1894
+ return (jsxRuntime.jsx(Tag, Object.assign({ ref: ref }, rest, { children: children })));
1895
+ };
1896
+
1897
+ /**
1898
+ * TagsContainer component to display tags in limited space when children can't fit space it displays counter
1899
+ *
1900
+ * @param {TagsContainerProps} props - The props for the TagContainer
1901
+ * @returns {JSX.Element} TagsContainer
1902
+ */
1903
+ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix }) => {
1904
+ const [isReady, setIsReady] = React__default["default"].useState(false);
1905
+ const [counterWidth, setCounterWidth] = React__default["default"].useState(0);
1906
+ const containerRef = React__default["default"].useRef(null);
1907
+ const availableWidth = React__default["default"].useRef();
1908
+ const childrenWidth = React__default["default"].useRef([]);
1909
+ const itemsCount = items.length;
1910
+ React__default["default"].useLayoutEffect(() => {
1911
+ var _a;
1912
+ availableWidth.current = ((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
1913
+ }, [containerRef]);
1914
+ const onWidthKnownHandler = ({ width: reportedWidth }) => {
1915
+ childrenWidth.current.push({ width: reportedWidth + itemsGap });
1916
+ if (childrenWidth.current.length === itemsCount) {
1917
+ setIsReady(true);
1918
+ }
1919
+ };
1920
+ const requiredSpace = childrenWidth.current.reduce((previous, current) => {
1921
+ return previous + current.width;
1922
+ }, 0);
1923
+ let counter = 0;
1924
+ const availableSpace = ((availableWidth === null || availableWidth === void 0 ? void 0 : availableWidth.current) || 0) - counterWidth;
1925
+ const renderedElements = items
1926
+ .concat({ text: "", onClick: () => null, disabled: false }) // reserved element for a potential counter
1927
+ .map((item, index) => {
1928
+ const spaceNeeded = childrenWidth.current.slice(0, index + 1).reduce((previous, current) => {
1929
+ return previous + current.width;
1930
+ }, 0);
1931
+ const isLast = index === items.length;
1932
+ const counterRequired = requiredSpace > availableSpace && counter !== 0;
1933
+ if (isLast && counterRequired) {
1934
+ return (jsxRuntime.jsx(TagWithWidth, Object.assign({ onWidthKnown: ({ width: reportedWidth }) => setCounterWidth(reportedWidth), color: "neutral" }, { children: jsxRuntime.jsxs(Counter, { children: ["+", counter] }) }), item.text + index));
1935
+ }
1936
+ if (isLast) {
1937
+ return null;
1938
+ }
1939
+ const itemCanFit = spaceNeeded <= availableSpace;
1940
+ if (itemCanFit) {
1941
+ return (jsxRuntime.jsx(TagWithWidth, Object.assign({ onWidthKnown: onWidthKnownHandler, className: tailwindStyledComponents.tws `shrink-0 inline-flex`, onClose: e => {
1942
+ e.stopPropagation();
1943
+ item.onClick();
1944
+ }, color: item.disabled ? "unknown" : "primary", dataTestId: item.text }, { children: item.text }), item.text + index));
1945
+ }
1946
+ const fromTheItems = item.text !== "";
1947
+ if (fromTheItems) {
1948
+ counter = counter + 1;
1949
+ }
1950
+ return null;
1951
+ })
1952
+ .filter(element => element !== null);
1953
+ return (jsxRuntime.jsxs(Container$1, Object.assign({ style: {
1954
+ width: `${width}`,
1955
+ }, "$ready": isReady, ref: containerRef }, { children: [renderedElements, postFix] })));
1956
+ };
1957
+ const Container$1 = tailwindStyledComponents.tw.div `
1958
+ tu-select__dynamic-tag--container
1959
+ ${({ $ready }) => {
1960
+ return $ready ? tailwindStyledComponents.tws `visible` : tailwindStyledComponents.tws `invisible`;
1961
+ }}
1962
+ `;
1963
+ const Counter = tailwindStyledComponents.tw.div `
1964
+ tu-select__counter
1965
+ `;
1966
+
1967
+ /**
1968
+ * A hook to retrieve components override object.
1969
+ * 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.
1970
+ *
1971
+ * @template IsMulti
1972
+ * @template Group
1973
+ * @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
1974
+ * @param {boolean} disabled decide to override disabled variant
1975
+ * @param {boolean} menuIsOpen menu is open state
1976
+ * @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
1977
+ * @param {string} dataTestId a test id
1978
+ * @param {number} maxSelectedDisplayCount a number of max display count
1979
+ * @param {JSX.Element} dropdownIcon an custom dropdown icon
1980
+ * @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
1981
+ */
1982
+ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
1983
+ // perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
1984
+ const customComponents = React__namespace.useMemo(() => {
1985
+ return Object.assign({ ValueContainer: props => {
1986
+ if (props.isMulti) {
1987
+ const PLACEHOLDER_KEY = "placeholder";
1988
+ const key = props && props.children && props.children[0] ? props.children[0].key : "";
1989
+ const values = props && props.children ? props.children[0] : [];
1990
+ const tags = key === PLACEHOLDER_KEY ? [] : values;
1991
+ const searchInput = props && props.children && props.children[1];
1992
+ return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled }, { children: maxSelectedDisplayCount === undefined ? (jsxRuntime.jsx(TagsContainer, { width: "100%", items: tags
1993
+ ? tags.map(({ props: tagProps }) => {
1994
+ return {
1995
+ text: tagProps.children,
1996
+ onClick: disabled
1997
+ ? undefined
1998
+ : (e) => {
1999
+ var _a, _b;
2000
+ refMenuIsEnabled.current = false;
2001
+ ((_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));
2002
+ },
2003
+ disabled: disabled,
2004
+ };
2005
+ })
2006
+ : [], postFix: searchInput })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [tags &&
2007
+ tags.slice(0, maxSelectedDisplayCount).map(({ props: tagProps }) => {
2008
+ var _a, _b;
2009
+ return (jsxRuntime.jsx(Tag, Object.assign({ className: tailwindStyledComponents.tws `shrink-0 inline-flex`, onClose: e => {
2010
+ var _a, _b;
2011
+ e.stopPropagation();
2012
+ refMenuIsEnabled.current = false;
2013
+ ((_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));
2014
+ }, 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()));
2015
+ }), tags && tags.length > maxSelectedDisplayCount && (jsxRuntime.jsxs(Tag, Object.assign({ color: "neutral", dataTestId: "counter" }, { children: ["+", tags.length - maxSelectedDisplayCount] }))), searchInput] })) })));
2016
+ }
2017
+ return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled }, { children: props.children })));
2018
+ }, LoadingIndicator: props => {
2019
+ return jsxRuntime.jsx(Spinner, { size: "small", className: tailwindStyledComponents.tws `mt-1.5 mr-1` });
2020
+ }, DropdownIndicator: props => {
2021
+ const icon = props.selectProps.menuIsOpen ? (jsxRuntime.jsx(Icon, { name: "ChevronUpIcon", size: "medium" })) : (jsxRuntime.jsx(Icon, { name: "ChevronDownIcon", size: "medium" }));
2022
+ return props.selectProps.isLoading ? null : (jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, Object.assign({}, props, { children: jsxRuntime.jsx(StyledIcon, { children: dropdownIcon ? dropdownIcon : icon }) })));
2023
+ }, IndicatorSeparator: () => null, ClearIndicator: props => {
2024
+ if (disabled) {
2025
+ return null;
2026
+ }
2027
+ 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" }) })) })));
2028
+ }, Control: props => {
2029
+ return (jsxRuntime.jsx(ReactSelect.components.Control, Object.assign({}, props, { className: props.isDisabled ? tailwindStyledComponents.tws `tu-select__control--disabled` : "" })));
2030
+ }, SingleValue: props => {
2031
+ 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 })) })));
2032
+ }, Menu: props => {
2033
+ return (jsxRuntime.jsx(ReactSelect.components.Menu, Object.assign({}, props, { className: props.selectProps.menuIsOpen
2034
+ ? tailwindStyledComponents.tws `tu-select__menu-list animate-fade-in-fast`
2035
+ : tailwindStyledComponents.tws `tu-select__menu-list animate-fade-out-fast` })));
2036
+ }, Option: props => {
2037
+ const componentProps = {
2038
+ label: props.label,
2039
+ focused: props.isFocused,
2040
+ selected: props.isSelected,
2041
+ onClick: props.innerProps.onClick,
2042
+ };
2043
+ 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 }))) })));
2044
+ } }, componentsProps);
2045
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2046
+ }, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
2047
+ return customComponents;
2048
+ };
2049
+ const StyledIcon = tailwindStyledComponents.tw.div `
2050
+ tu-select--icon
2051
+ `;
2052
+ const XMarkIcon = tailwindStyledComponents.tw.div `
2053
+ tu-select--icon
2054
+ tu-select__x-icon
2055
+ `;
2056
+
2057
+ /**
2058
+ * @template IsMulti
2059
+ * @template Group
2060
+ * @param {React.RefObject<HTMLDivElement>} refContainer react ref to container element
2061
+ * @param {React.RefObject<HTMLDivElement>} refPrefix react ref to prefix element
2062
+ * @param {number | undefined} maxSelectedDisplayCount a number of max display count
2063
+ * @param {StylesConfig<Option, IsMulti, Group> | undefined} styles a optional object to override styles of react-select
2064
+ * @returns {StylesConfig<Option, boolean>} styles to override in select
2065
+ */
2066
+ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, styles) => {
2067
+ const customStyles = React__namespace.useMemo(() => {
2068
+ return Object.assign({ control: base => {
2069
+ return Object.assign(Object.assign({}, base), { border: "0", boxShadow: "0", "&:hover": {
2070
+ border: "0",
2071
+ }, marginRight: "2px", backgroundColor: "" });
2072
+ }, singleValue: base => (Object.assign({}, base)), multiValue: base => (Object.assign({}, base)), multiValueLabel: base => (Object.assign({}, base)), indicatorsContainer: base => (Object.assign({}, base)), indicatorSeparator: () => ({
2073
+ width: "0px",
2074
+ }), menu: base => {
2075
+ return Object.assign(Object.assign({}, base), { width: "100%", marginTop: "4px", marginBottom: "18px", transition: "all 1s ease-in-out" });
2076
+ }, 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 => {
2077
+ 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" });
2078
+ }, valueContainer: base => {
2079
+ return Object.assign(Object.assign({}, base), { flexWrap: maxSelectedDisplayCount !== undefined ? "wrap" : "nowrap", gap: "0.25rem" });
2080
+ }, 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 => {
2081
+ return Object.assign(Object.assign({}, base), { padding: "0px" });
2082
+ } }, styles);
2083
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2084
+ }, [refContainer, refPrefix]);
2085
+ return { customStyles };
2086
+ };
2087
+
2088
+ /**
2089
+ * A hook used by selects to share the common code
2090
+ *
2091
+ * @param {SelectProps} props - The props for the Select component
2092
+ * @returns {IUseSelect} Select component
2093
+ */
2094
+ const useSelect = (_a) => {
2095
+ var _b;
2096
+ 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"]);
2097
+ const refContainer = React__default["default"].useRef(null);
2098
+ const refPrefix = React__default["default"].useRef(null);
2099
+ const { customStyles } = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
2100
+ const [menuIsOpen, setMenuIsOpen] = React__default["default"].useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
2101
+ const refMenuIsEnabled = React__default["default"].useRef(true);
2102
+ const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
2103
+ const menuPlacement = "auto";
2104
+ const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
2105
+ onMenuOpen && onMenuOpen();
2106
+ if (refMenuIsEnabled.current) {
2107
+ setMenuIsOpen(true);
2108
+ }
2109
+ else {
2110
+ refMenuIsEnabled.current = true;
2111
+ }
2112
+ });
2113
+ const closeMenuHandler = () => {
2114
+ setMenuIsOpen(false);
2115
+ onMenuClose && onMenuClose();
2116
+ };
2117
+ const orderedOptions = React__default["default"].useMemo(() => {
2118
+ return disabled
2119
+ ? getOrderedOptions(options, value).map(option => {
2120
+ return Object.assign(Object.assign({}, option), { disabled: true });
2121
+ })
2122
+ : getOrderedOptions(options, value);
2123
+ }, [options, value, disabled]);
2124
+ return {
2125
+ refContainer,
2126
+ refPrefix,
2127
+ customStyles,
2128
+ menuIsOpen,
2129
+ customComponents,
2130
+ menuPlacement,
2131
+ openMenuHandler,
2132
+ closeMenuHandler,
2133
+ orderedOptions,
2134
+ };
2135
+ };
2136
+
2137
+ /**
2138
+ * The CreatableSelect component.
2139
+ *
2140
+ * @param {CreateableSelectProps} props - The props for the CreatableSelect component
2141
+ * @returns {JSX.Element} CreatableSelect component
2142
+ */
2143
+ const CreatableSelect = (props) => {
2144
+ const { id, dataTestId = "select", async, maxMenuHeight = 200, label, error, disabled, isMulti, value, hideLabel, description, info, options, onChange, isLoading, classNamePrefix = "", filterOption, prefix, } = props;
2145
+ const hasError = !!error;
2146
+ const { refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
2147
+ const selectProps = {
2148
+ value,
2149
+ menuPlacement,
2150
+ maxMenuHeight,
2151
+ onChange,
2152
+ "aria-label": label,
2153
+ "data-testid": dataTestId,
2154
+ components: customComponents,
2155
+ styles: customStyles,
2156
+ tabSelectsValue: false,
2157
+ blurInputOnSelect: !isMulti,
2158
+ menuPortalTarget: document.body,
2159
+ isSearchable: disabled ? false : true,
2160
+ menuShouldBlockScroll: true,
2161
+ menuShouldScrollIntoView: true,
2162
+ openMenuOnFocus: disabled ? false : true,
2163
+ menuIsOpen: disabled ? false : menuIsOpen,
2164
+ openMenuOnClick: true,
2165
+ closeMenuOnSelect: false,
2166
+ isMulti: isMulti,
2167
+ classNamePrefix,
2168
+ isLoading,
2169
+ id,
2170
+ };
2171
+ 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: () => {
2172
+ !disabled && openMenuHandler();
2173
+ }, onMenuClose: () => {
2174
+ closeMenuHandler();
2175
+ } }))) : (jsxRuntime.jsx(ReactCreatableSelect__default["default"], Object.assign({}, selectProps, { options: filterOption ? orderedOptions : options, isMulti: isMulti, onMenuOpen: () => {
2176
+ !disabled && openMenuHandler();
2177
+ }, onMenuClose: () => {
2178
+ closeMenuHandler();
2179
+ } })))] }) })));
2180
+ };
2181
+
2182
+ /**
2183
+ * Selects are input components used to choose a value from a set.
2184
+ *
2185
+ * @param {SelectProps} props - The props for the Select component
2186
+ * @returns {JSX.Element} Select component
2187
+ */
2188
+ const Select = (props) => {
2189
+ const { className } = props, propsNoClassName = __rest(props, ["className"]);
2190
+ const { id, dataTestId = "select", prefix, async, maxMenuHeight = 200, label, hasError, disabled, isMulti, value, options, onChange, isLoading, classNamePrefix = "", onMenuScrollToBottom, filterOption, onInputChange, isSearchable, isClearable, } = props;
2191
+ const { refContainer, refPrefix, customStyles, menuIsOpen, customComponents, menuPlacement, openMenuHandler, closeMenuHandler, orderedOptions, } = useSelect(props);
2192
+ const selectProps = {
2193
+ value,
2194
+ menuPlacement,
2195
+ maxMenuHeight,
2196
+ onChange,
2197
+ "aria-label": label,
2198
+ "data-testid": dataTestId,
2199
+ components: customComponents,
2200
+ styles: customStyles,
2201
+ tabSelectsValue: false,
2202
+ blurInputOnSelect: !isMulti,
2203
+ menuPortalTarget: props.menuPortalTarget || document.body,
2204
+ isSearchable: disabled ? false : isSearchable,
2205
+ menuShouldBlockScroll: true,
2206
+ menuShouldScrollIntoView: true,
2207
+ openMenuOnFocus: true,
2208
+ menuIsOpen,
2209
+ openMenuOnClick: true,
2210
+ closeMenuOnSelect: false,
2211
+ isMulti,
2212
+ classNamePrefix,
2213
+ isLoading,
2214
+ isClearable,
2215
+ id,
2216
+ onMenuScrollToBottom,
2217
+ onInputChange,
2218
+ };
2219
+ 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 })))] })));
2220
+ };
2221
+ const SelectContainer = tailwindStyledComponents.tw.div `
2222
+ tu-select
2223
+ ${({ $hasError }) => ($hasError ? tailwindStyledComponents.tws `tu-select--invalid` : null)}
2224
+ ${({ $isDisabled }) => ($isDisabled ? tailwindStyledComponents.tws `tu-select--disabled` : null)}
2225
+ `;
2226
+ Select.displayName = "Select";
2227
+
2228
+ const COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND = ["53", "98", "211", "247", "249", "383", "850", "963"];
2229
+ const ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND = [
2230
+ "1242",
2231
+ "1246",
2232
+ "1264",
2233
+ "1268",
2234
+ "1284",
2235
+ "1340",
2236
+ "1345",
2237
+ "1441",
2238
+ "1473",
2239
+ "1649",
2240
+ "1664",
2241
+ "1670",
2242
+ "1671",
2243
+ "1684",
2244
+ "1721",
2245
+ "1758",
2246
+ "1767",
2247
+ "1784",
2248
+ "1809",
2249
+ "1868",
2250
+ "1869",
2251
+ "1876",
2252
+ "379",
2253
+ "5999",
2254
+ "881",
2255
+ "882",
2256
+ "883",
2257
+ ];
2258
+ const countryCodesSet = [
2259
+ ...new Set(libphonenumberJs.getCountries().map(code => libphonenumberJs.getCountryCallingCode(code))),
2260
+ ...ADDITIONAL_COUNTRY_CODES_SUPPORTED_BY_BACKEND,
2261
+ ]
2262
+ .filter(code => !COUNTRY_CODES_NOT_SUPPORTED_BY_BACKEND.includes(code))
2263
+ .sort((a, b) => Number(a) - Number(b));
2264
+ const countryCodes = countryCodesSet.map(code => ({ label: `+${code}`, value: code }));
2265
+
2266
+ /**
2267
+ * The CountryCodeSelect component is used to select a country code for a phone number.
2268
+ *
2269
+ * @param {CountryCodeSelectProps} props - The props for the CountryCodeSelect component
2270
+ * @returns {JSX.Element} CountryCodeSelect component
2271
+ */
2272
+ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, setCountryCode, }) => {
2273
+ const [isCountryCodeMissing, setIsCountryCodeMissing] = React.useState(false);
2274
+ React.useEffect(() => {
2275
+ countryCode && setIsCountryCodeMissing(false);
2276
+ }, [countryCode]);
2277
+ const filteredCodes = countryCodes.filter(code => {
2278
+ return !(excludedCountries === null || excludedCountries === void 0 ? void 0 : excludedCountries.some(excludedCode => excludedCode.value === code.value));
2279
+ });
2280
+ return (jsxRuntime.jsx(Select, { className: "w-28", "aria-invalid": isCountryCodeMissing, options: filteredCodes.map(code => code), value: filteredCodes.find(({ value: currentValue }) => currentValue === countryCode), onChange: input => {
2281
+ setCountryCode(input === null || input === void 0 ? void 0 : input.value);
2282
+ }, placeholder: "+45", hasError: isCountryCodeMissing || isInvalid, maxMenuHeight: 200 }));
2283
+ };
2284
+
2285
+ /**
2286
+ * A component for inputting phone numbers with an optional action button for initiating a phone call.
2287
+ *
2288
+ * @param {string} [dataTestId] - The data test ID for the component.
2289
+ * @param {boolean} [disabled=false] - Whether the component is disabled or not.
2290
+ * @param {string} [fieldSize="medium"] - The size of the input field.
2291
+ * @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
2292
+ * @returns {JSX.Element} - The PhoneInput component.
2293
+ */
2294
+ const PhoneInput = React.forwardRef((_a, ref) => {
2295
+ var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction"]);
2296
+ const [phoneNumber, setPhoneNumber] = React.useState();
2297
+ const [renderAsInvalid, setRenderAsInvalid] = React.useState(false);
2298
+ const [countryCode, setCountryCode] = React.useState(undefined);
2299
+ const [isPhoneNumberInvalid, setIsPhoneNumberInvalid] = React.useState(false);
2300
+ const handlePhoneNumberChange = (e) => {
2301
+ const input = e.target.value;
2302
+ setIsPhoneNumberInvalid(!Boolean(input));
2303
+ setPhoneNumber(input);
2304
+ };
2305
+ React.useEffect(() => {
2306
+ setRenderAsInvalid(isInvalid || isPhoneNumberInvalid);
2307
+ }, [isInvalid, isPhoneNumberInvalid]);
2308
+ 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))] }));
2309
+ });
2310
+ const Container = tailwindStyledComponents.tw.div `
2311
+ grid
2312
+ grid-cols-min-fr
2313
+ gap-2
2314
+ `;
2315
+
2316
+ /**
2317
+ * The PhoneField component is used to enter phone number.
2318
+ * It is a wrapper around the PhoneInput component and the FormGroup component.
2319
+ * It is used to render a phone number field with a label, a tip, a help text, a help addon and an error message.
2320
+ *
2321
+ * @param {string} [label] - The label for the component.
2322
+ * @param {string} [tip] - The tip for the component.
2323
+ * @param {string} [helpText] - The help text for the component.
2324
+ * @param {string} [helpAddon] - The help addon for the component.
2325
+ * @param {string} [errorMessage] - The error message for the component.
2326
+ * @param {string} [defaultValue] - The default value for the component.
2327
+ * @param {boolean} [disabled=false] - Whether the component is disabled or not.
2328
+ * @param {string} [fieldSize="medium"] - The size of the input field.
2329
+ * @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
2330
+ * @returns {JSX.Element} - The PhoneField component.
2331
+ */
2332
+ const PhoneField = React.forwardRef((_a, ref) => {
2333
+ 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"]);
2334
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2335
+ 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)) })));
2336
+ });
2337
+
2338
+ function useConfirmExit(confirmExit, when = true) {
2339
+ const { navigator } = React.useContext(reactRouterDom.UNSAFE_NavigationContext);
2340
+ React.useEffect(() => {
2341
+ if (!when) {
2342
+ return;
2343
+ }
2344
+ const push = navigator.push;
2345
+ navigator.push = (...args) => {
2346
+ const result = confirmExit();
2347
+ if (result !== false) {
2348
+ push(...args);
2349
+ }
2350
+ };
2351
+ return () => {
2352
+ navigator.push = push;
2353
+ };
2354
+ }, [navigator, confirmExit, when]);
2355
+ }
2356
+ /**
2357
+ * The usePrompt hook.
2358
+ *
2359
+ * @param {string} message -
2360
+ * @param {boolean} when -
2361
+ * @returns {void} void
2362
+ */
2363
+ const usePrompt = (message, when = true) => {
2364
+ React.useEffect(() => {
2365
+ if (when) {
2366
+ window.onbeforeunload = function () {
2367
+ return message;
2368
+ };
2369
+ }
2370
+ return () => {
2371
+ window.onbeforeunload = null;
2372
+ };
2373
+ }, [message, when]);
2374
+ const confirmExit = React.useCallback(() => {
2375
+ const confirm = window.confirm(message);
2376
+ return confirm;
2377
+ }, [message]);
2378
+ useConfirmExit(confirmExit, when);
2379
+ };
2380
+ /**
2381
+ * The Prompt function.
2382
+ *
2383
+ * @param {PromptProps} Props -
2384
+ * @returns {void} void
2385
+ */
2386
+ const Prompt = ({ when, message }) => {
2387
+ usePrompt(message, when);
2388
+ return null;
2389
+ };
2390
+
2391
+ const RadioGroupContext = React__namespace.createContext(null);
2392
+
2393
+ /**
2394
+ * Use radio buttons when you have a group of mutually exclusive choices and only one selection from the group is allowed.
2395
+ *
2396
+ * 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.
2397
+ *
2398
+ * _**Do use** Radio buttons in forms, settings, or selections in a list._
2399
+ *
2400
+ * _**Do not use** Radio buttons if a user can select many option from a list, use checkboxes instead of radio buttons._
2401
+ *
2402
+ * @param {RadioGroupProps} props - The props for the RadioGroup component
2403
+ * @returns {JSX.Element} RadioGroup component
2404
+ */
2405
+ const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline, className, dataTestId, isInvalid, }) => {
2406
+ 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: {
2407
+ id,
2408
+ value,
2409
+ name: name || id,
2410
+ onChange,
2411
+ disabled,
2412
+ isInvalid,
2413
+ } }, { children: children })) })) })));
2414
+ };
2415
+ RadioGroup.displayName = "RadioGroup";
2416
+ const Flex = tailwindStyledComponents.tw.div `
2417
+ ${({ $inline }) => ($inline ? tailwindStyledComponents.tws `tu-radiogroup--inline` : tailwindStyledComponents.tws `tu-radiogroup`)}
2418
+ `;
2419
+
2420
+ /**
2421
+ * The RadioItem component.
2422
+ *
2423
+ * @param {RadioItemProps} props - The props for the RadioItem component
2424
+ * @returns {JSX.Element} RadioItem component
2425
+ */
2426
+ const RadioItem = ({ label, value, dataTestId, className, description }) => {
2427
+ const groupCtx = React__namespace.useContext(RadioGroupContext);
2428
+ const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
2429
+ 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 })))] })] })));
2430
+ };
2431
+ const InputWrapper = tailwindStyledComponents.tw.label `tu-radioitem__wrapper`;
2432
+ const Input = tailwindStyledComponents.tw.input `
2433
+ tu-radioitem
2434
+ ${({ $checked }) => $checked && tailwindStyledComponents.tws `tu-radioitem--checked`}
2435
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem--disabled`}
2436
+ ${({ $isInvalid }) => $isInvalid && tailwindStyledComponents.tws `tu-radioitem--invalid`}
2437
+ `;
2438
+ const LabelContainer$1 = tailwindStyledComponents.tw.div `tu-radioitem__label-container`;
2439
+ const Description$1 = tailwindStyledComponents.tw.label `
2440
+ tu-radioitem__description
2441
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-radioitem__description--disabled`}
2442
+ `;
2443
+
2444
+ /**
2445
+ * A thin wrapper around the `BaseInput` component for text input fields.
2446
+ *
2447
+ * NOTE: If shown with a label, please use the `TextField` component instead.
2448
+ */
2449
+ const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "text" }, props))));
2450
+
2451
+ /**
2452
+ * The Search component is used to render a search input field.
2453
+ *
2454
+ * @param {SearchProps} props - The props for the Search component
2455
+ * @returns {JSX.Element} Search component
2456
+ */
2457
+ const Search = (_a) => {
2458
+ 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"]);
2459
+ 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: () => {
2460
+ onClear();
2461
+ } }, { children: jsxRuntime.jsx(Icon, { name: "XMarkIcon", size: "small" }) }))) : undefined, value: value, disabled: disabled, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, autoComplete: autoComplete })));
2462
+ };
2463
+ const StyledTextInput = tailwindStyledComponents.twx(TextInput) `
2464
+ tu-search
2465
+ ${({ $showBorderWhenNotInFocus }) => $showBorderWhenNotInFocus && tailwindStyledComponents.tws `tu-search--border`}
2466
+ ${({ $widenOnFocus }) => $widenOnFocus && tailwindStyledComponents.tws `tu-search--widen-on-focus`}
2467
+ `;
2468
+
2469
+ /**
2470
+ * The Spacer component is used for adding a bit of space in the ui.
2471
+ *
2472
+ * @param {SpacerProps} props - The props for the Spacer component
2473
+ * @returns {JSX.Element} Spacer component
2474
+ */
2475
+ const Spacer = ({ minHeight, border = false, dataTestId }) => {
2476
+ return jsxRuntime.jsx(Space, { "data-testid": dataTestId, "$minHeight": minHeight, "$border": border });
2477
+ };
2478
+ const GetSpacerHeight = () => ({ $minHeight }) => {
2479
+ switch ($minHeight) {
2480
+ case "normal":
2481
+ return tailwindStyledComponents.tws `tu-spacer--normal`;
2482
+ case "large":
2483
+ return tailwindStyledComponents.tws `tu-spacer--large`;
2484
+ default:
2485
+ return "";
2486
+ }
2487
+ };
2488
+ const Space = tailwindStyledComponents.tw.div `
2489
+ ${p => `${p.$border ? `tu-spacer--border` : null}`}
2490
+ ${GetSpacerHeight()}
2491
+ `;
2492
+
2493
+ /**
2494
+ * The SectionHeader component is used on sections to set the section title.
2495
+ *
2496
+ * @param {SectionHeaderProps} props - The props for the section header component
2497
+ * @returns {JSX.Element} SectionHeader component
2498
+ */
2499
+ const SectionHeader = ({ title, subtitle, dataTestId, addon }) => {
2500
+ 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" })] }));
2501
+ };
2502
+ const SectionHeaderContainer = tailwindStyledComponents.tw.div `tu-section-header`;
2503
+ const StyledFlex = tailwindStyledComponents.tw.div `tu-section-header__flex`;
2504
+
2505
+ /**
2506
+ * A hook used to detect what children are overflowing a container.
2507
+ *
2508
+ * @param {OverflowItemsOptions} root0 The options for the hook.
2509
+ * @param {OverflowItemsOptions.threshold} root0.threshold The threshold for the intersection observer.
2510
+ * @returns {object} The overflow items and the ref to the container.
2511
+ */
2512
+ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id", children, }) => {
2513
+ const [itemOverflowMap, setItemOverflowMap] = React.useState({});
2514
+ const overflowContainerRef = React.useRef(null); // TODO: Handle other elements than div
2515
+ const observerRef = React.useRef(null);
2516
+ const handleIntersection = React.useCallback(entries => {
2517
+ const updatedEntries = {};
2518
+ entries.forEach(entry => {
2519
+ const targetElementId = entry.target[childUniqueIdentifierAttribute];
2520
+ if (targetElementId) {
2521
+ updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
2522
+ }
2523
+ });
2524
+ setItemOverflowMap(prev => (Object.assign(Object.assign({}, prev), updatedEntries)));
2525
+ }, [childUniqueIdentifierAttribute]);
2526
+ const observe = React.useCallback(() => {
2527
+ const node = overflowContainerRef.current;
2528
+ if (node && node.children) {
2529
+ const root = overflowContainerRef.current;
2530
+ const options = { root, threshold };
2531
+ const observer = new IntersectionObserver(handleIntersection, options);
2532
+ Array.from(node.children).forEach(child => {
2533
+ observer.observe(child);
2534
+ });
2535
+ observer.observe(node);
2536
+ observerRef.current = observer;
2537
+ }
2538
+ }, [handleIntersection, threshold]);
2539
+ const unobserve = React.useCallback(() => {
2540
+ const currentObserver = observerRef.current;
2541
+ currentObserver === null || currentObserver === void 0 ? void 0 : currentObserver.disconnect();
2542
+ observerRef.current = null;
2543
+ }, []);
2544
+ const initializeObserver = React.useCallback(() => {
2545
+ unobserve();
2546
+ observe();
2547
+ }, [observe, unobserve]);
2548
+ React.useEffect(() => {
2549
+ initializeObserver();
2550
+ return () => {
2551
+ unobserve();
2552
+ };
2553
+ }, [initializeObserver, unobserve, children]);
2554
+ return { overflowContainerRef, itemOverflowMap };
2555
+ };
2556
+
2557
+ /**
2558
+ * The sidebar components is used to render a responsive sidebar.
2559
+ * - The sidebar will be rendered horizontally until a given breakpoint where it will be stacked vertically.
2560
+ * - The sidebar hides items that does not fit in the sidebar and show them in a more menu.
2561
+ * - **_The sidebar is just a wrapper. You are responsible for styling the children._**
2562
+ *
2563
+ * When using this component make sure to add `setupIntersectionObserver();` to your jest.setup.ts file.
2564
+ *
2565
+ * @param {SidebarProps} props - The props for the Sidebar component
2566
+ * @returns {JSX.Element} Sidebar component
2567
+ */
2568
+ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", className, dataTestId = "sidebar", moreMenuProps, menuListProps, overflowThreshold, }) => {
2569
+ const { overflowContainerRef, itemOverflowMap } = useOverflowItems({
2570
+ children,
2571
+ childUniqueIdentifierAttribute: "id",
2572
+ threshold: overflowThreshold !== null && overflowThreshold !== void 0 ? overflowThreshold : 0.8,
2573
+ });
2574
+ const overflowItemCount = Object.values(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
2575
+ const itemVisibilityClassName = (id) => {
2576
+ if (itemOverflowMap[id]) {
2577
+ return tailwindStyledComponents.tws `invisible`;
2578
+ }
2579
+ return tailwindStyledComponents.tws `visible`;
2580
+ };
2581
+ 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 => {
2582
+ return React__default["default"].cloneElement(child, {
2583
+ className: `${child.props.className} ${itemVisibilityClassName(child.props.id)}`,
2584
+ });
2585
+ }) })), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, Object.assign({ iconButtonProps: {
2586
+ circular: false,
2587
+ variant: "transparent",
2588
+ color: "secondary",
2589
+ }, menuPlacement: "bottom-end" }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId && `${dataTestId}-more-menu` }, { children: jsxRuntime.jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId && `${dataTestId}-menu-list` }, { children: React__default["default"].Children.map(children, child => {
2590
+ return itemOverflowMap[child.props.id] ? child : null;
2591
+ }) })) }))) : null] })));
2592
+ };
2593
+ const Root$2 = tailwindStyledComponents.tw.div `
2594
+ tu-sidebar
2595
+ `;
2596
+ const breakpointClasses = {
2597
+ xs: tailwindStyledComponents.tws `tu-sidebar__child-container--xs`,
2598
+ sm: tailwindStyledComponents.tws `tu-sidebar__child-container--sm`,
2599
+ md: tailwindStyledComponents.tws `tu-sidebar__child-container--md`,
2600
+ lg: tailwindStyledComponents.tws `tu-sidebar__child-container--lg`,
2601
+ xl: tailwindStyledComponents.tws `tu-sidebar__child-container--xl`,
2602
+ "2xl": tailwindStyledComponents.tws `tu-sidebar__child-container--2xl`,
2603
+ "3xl": tailwindStyledComponents.tws `tu-sidebar__child-container--3xl`,
2604
+ };
2605
+ const ChildContainer = tailwindStyledComponents.tw.div `
2606
+ tu-sidebar__child-container
2607
+ ${({ $breakpoint }) => breakpointClasses[$breakpoint]}
2608
+ `;
2609
+
2610
+ /**
2611
+ * The TextArea is a base component, and should not be used very often.
2612
+ * For most cases the TextAreaField is the correct component.
2613
+ */
2614
+ const TextArea = React__namespace.forwardRef((_a, ref) => {
2615
+ 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"]);
2616
+ 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 })));
2617
+ });
2618
+ const StyledTextArea = tailwindStyledComponents.tw.textarea `
2619
+ tu-textarea
2620
+ ${({ $invalid }) => ($invalid ? tailwindStyledComponents.tws `tu-textarea--invalid` : null)}
2621
+ ${({ disabled }) => (disabled ? tailwindStyledComponents.tws `tu-textarea--disabled` : null)}
2622
+ ${({ $resize }) => {
2623
+ switch ($resize) {
2624
+ case "both":
2625
+ return tailwindStyledComponents.tws `resize`;
2626
+ case "horizontal":
2627
+ return tailwindStyledComponents.tws `resize-x`;
2628
+ case "vertical":
2629
+ return tailwindStyledComponents.tws `resize-y`;
2630
+ case "none":
2631
+ return tailwindStyledComponents.tws `resize-none`;
2632
+ default:
2633
+ return null;
2634
+ }
2635
+ }};
2636
+ `;
2637
+
2638
+ /**
2639
+ * The TextLengthIndicator component shows a `{length}/{maxLength}` label.
2640
+ * Used for TextFields to communicate a maximum allowed input length.
2641
+ *
2642
+ * @param {TextLengthIndicatorProps} props - The props for the TextLengthIndicator component
2643
+ * @returns {JSX.Element} TextLengthIndicator component
2644
+ */
2645
+ const TextLengthIndicator = ({ length, maxLength }) => {
2646
+ return (jsxRuntime.jsxs(Root$1, { children: [length, "/", maxLength] }));
2647
+ };
2648
+ const Root$1 = tailwindStyledComponents.tw.span `
2649
+ font-mono
2650
+ `;
2651
+
2652
+ const TextAreaField = React__namespace.forwardRef((_a, ref) => {
2653
+ 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"]);
2654
+ const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
2655
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2656
+ const handleChange = React__namespace.useCallback((event) => {
2657
+ setValueLength(event.target.value.length);
2658
+ if (onChange) {
2659
+ onChange(event);
2660
+ }
2661
+ }, [onChange]);
2662
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: errorMessage || helpText, helpAddon: helpAddon ||
2663
+ (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 })) })));
2664
+ });
2665
+
2666
+ /**
2667
+ * 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.
2668
+ *
2669
+ * _**Do use** when the user has to input or edit simple text based information, such as metadata._
2670
+ *
2671
+ * _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
2672
+ */
2673
+ const TextField = React__namespace.forwardRef((_a, ref) => {
2674
+ 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"]);
2675
+ const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
2676
+ const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
2677
+ const handleChange = React__namespace.useCallback((event) => {
2678
+ setValueLength(event.target.value.length);
2679
+ if (onChange) {
2680
+ onChange(event);
2681
+ }
2682
+ }, [onChange]);
2683
+ return (jsxRuntime.jsx(FormGroup, Object.assign({ label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon ||
2684
+ (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 })) })));
2685
+ });
2686
+
2687
+ /**
2688
+ * Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
2689
+ * - with an indicator (dot)
2690
+ * - a header (next to the dot)
2691
+ * - and a body.
2692
+ *
2693
+ * @param {TimelineProps} props - The props for the Timeline component
2694
+ * @returns {JSX.Element} Timeline component
2695
+ */
2696
+ const Timeline = ({ className, dataTestId, children }) => {
2697
+ return (jsxRuntime.jsx("ol", Object.assign({ className: `${className !== null && className !== void 0 ? className : ""} ${tailwindStyledComponents.tws `tu-timeline`}`, "data-testid": dataTestId }, { children: children })));
2698
+ };
2699
+ /**
2700
+ * TimelineElement - entry on a timeline - rendered with an icon on the timeline
2701
+ * - a date as the header and the children provided as body.
2702
+ *
2703
+ * @param {TimeLineElementProps} props the props
2704
+ * @returns {JSX.Element} component
2705
+ */
2706
+ 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, }) => {
2707
+ var _a;
2708
+ 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 }) })] })));
2709
+ };
2710
+ function defaultHeader(date, showTime) {
2711
+ return `${dateFns.format(date, showTime ? "MMM d, yyyy H:mm" : "MMM d, yyyy")} (${dateFns.formatDistance(date, new Date(), {
2712
+ addSuffix: true,
2713
+ })})`;
2714
+ }
2715
+
2716
+ /**
2717
+ * Use Toggle when you have to only enable/disable a feature.
2718
+ *
2719
+ * _**Do use** Toggle in forms or settings._
2720
+ *
2721
+ * _**Do not use** Toggle if a user can select many option from a list, use checkboxes instead of toggle._
2722
+ *
2723
+ * @param {ToggleProps} props - The props for the Toggle component
2724
+ * @returns {JSX.Element} Toggle component
2725
+ */
2726
+ const Toggle = React__namespace.forwardRef(({ toggled = false, onChange, disabled, size = "medium", id, tabIndex, required, className, dataTestId, onBlur, name, description = "", }, ref) => {
2727
+ 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 => {
2728
+ e.stopPropagation();
2729
+ onChange(!toggled, e);
2730
+ }, 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 })))] })] }));
2731
+ });
2732
+ Toggle.displayName = "Toggle";
2733
+ const ToggleWrapper = tailwindStyledComponents.tw.div `tu-toggle__wrapper`;
2734
+ const InputContainer = tailwindStyledComponents.tw.label `tu-toggle__input-container `;
2735
+ const HiddenInput = tailwindStyledComponents.tw.input `tu-toggle__input`;
2736
+ const Switch = tailwindStyledComponents.tw.label `
2737
+ ${({ $toggled }) => ($toggled ? tailwindStyledComponents.tws `tu-toggle__switch` : tailwindStyledComponents.tws `tu-toggle`)}`;
2738
+ const SwitchContainer = tailwindStyledComponents.tw.label `
2739
+ tu-toggle__switch-container
2740
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-toggle--disabled`};
2741
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-toggle--small` : tailwindStyledComponents.tws `tu-toggle--medium`)};
2742
+ ${({ $toggled }) => $toggled && tailwindStyledComponents.tws `tu-toggle--toggled`}`;
2743
+ const LabelContainer = tailwindStyledComponents.tw.div `tu-toggle__label-container`;
2744
+ const Description = tailwindStyledComponents.tw.label `
2745
+ tu-toggle__description
2746
+ ${({ $disabled }) => $disabled && tailwindStyledComponents.tws `tu-toggle__description--disabled`}
2747
+ `;
2748
+
2749
+ /**
2750
+ * A thin wrapper around the `BaseInput` component for upload input fields.
2751
+ *
2752
+ * NOTE: If shown with a label, please use the `UploadField` component instead.
2753
+ */
2754
+ const UploadInput = React.forwardRef((_a, ref) => {
2755
+ var { disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles } = _a, rest = __rest(_a, ["disabled", "acceptedTypes", "nonInteractive", "uploadLabel", "multipleFiles"]);
2756
+ return (jsxRuntime.jsx(UploadInputContainer, { children: jsxRuntime.jsx(BaseInput, Object.assign({ addonBefore: uploadLabel, ref: ref, disabled: disabled, accept: acceptedTypes, multiple: multipleFiles, type: "file", nonInteractive: nonInteractive,
2757
+ // onClick used to work with nonInteractive option
2758
+ onClick: event => {
2759
+ if (nonInteractive) {
2760
+ event.preventDefault();
2761
+ event.stopPropagation();
2762
+ }
2763
+ } }, rest)) }));
2764
+ });
2765
+ const UploadInputContainer = tailwindStyledComponents.tw.label `
2766
+ tu-upload-input`;
2767
+
2768
+ /**
2769
+ * Upload fields enable the user to upload Files.
2770
+ */
2771
+ const UploadField = React.forwardRef((_a, ref) => {
2772
+ var { label, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
2773
+ const renderAsInvalid = isInvalid || Boolean(errorMessage);
2774
+ 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 })) })));
2775
+ });
2776
+
2777
+ /**
2778
+ * Helper function to get normalized score in range 0-1 used by the ValueBar
2779
+ *
2780
+ * @param {number} value - value for which score should be returned
2781
+ * @param {number} min - min range value
2782
+ * @param {number} max - max range value
2783
+ * @returns {number} normalized score
2784
+ */
2785
+ const getScore = (value, min, max) => {
2786
+ if (value <= min) {
2787
+ return 0.01; // always render at least some small fragment
2788
+ }
2789
+ if (value >= max) {
2790
+ return 1;
2791
+ }
2792
+ return (value - min) / (max - min);
2793
+ };
2794
+ /**
2795
+ * Helper function to get default color used by the ValueBar
2796
+ *
2797
+ * @param {number} score - score number for which color should be returned
2798
+ * @returns {string} color value
2799
+ */
2800
+ const getDefaultFillColor = (score) => {
2801
+ if (score < 0.3) {
2802
+ return uiDesignTokens.color("DANGER", 500, "CSS");
2803
+ }
2804
+ if (score >= 0.6) {
2805
+ return uiDesignTokens.color("SUCCESS", 600, "CSS");
2806
+ }
2807
+ return uiDesignTokens.color("WARNING", 300, "CSS");
2808
+ };
2809
+ /**
2810
+ * Helper function to get custom color used by the ValueBar
2811
+ *
2812
+ * @param {number} score - score number for which color should be returned
2813
+ * @param {LevelColors} levelColors - custom colors and levels definitions
2814
+ * @returns {string} color value
2815
+ */
2816
+ const getFillColor = (score, levelColors) => {
2817
+ var _a, _b;
2818
+ if (levelColors.low && score < (levelColors.low.level || 0)) {
2819
+ return levelColors.low.color;
2820
+ }
2821
+ if (levelColors.high && score >= (levelColors.high.level || 0)) {
2822
+ return levelColors.high.color;
2823
+ }
2824
+ return (_b = (_a = levelColors.medium) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : uiDesignTokens.color("WARNING", 300);
2825
+ };
2826
+ /**
2827
+ * Helper function to get color used by the ValueBar
2828
+ *
2829
+ * @param {number} value - value for which color should be returned
2830
+ * @param {number} min - min range value
2831
+ * @param {number} max - max range value
2832
+ * @param {LevelColors} levelColors - level colors used to coloring the bar
2833
+ * @returns {JSX.Element} ValueBar component
2834
+ */
2835
+ const getValueBarColorByValue = (value, min, max, levelColors) => {
2836
+ const score = getScore(value, min, max);
2837
+ return getFillColor(score, levelColors);
2838
+ };
2839
+
2840
+ /**
2841
+ * ValueBar component is used to display value on a colorful bar within provided range.
2842
+ *
2843
+ * @param {ValueBarProps} props - The props for the ValueBar component
2844
+ * @returns {JSX.Element} ValueBar component
2845
+ */
2846
+ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue, className, dataTestId, }) => {
2847
+ const score = getScore(value, min, max);
2848
+ const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
2849
+ const barWidth = showValue && size === "small" ? 90 : 100;
2850
+ 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 || ""] })))] }) })));
2851
+ };
2852
+ const Root = tailwindStyledComponents.tw.svg `
2853
+ tu-value-bar
2854
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-value-bar--small` : tailwindStyledComponents.tws `tu-value-bar--large`)}
2855
+ `;
2856
+ const Text = tailwindStyledComponents.tw.text `
2857
+ tu-value-bar__text
2858
+ ${({ $size }) => ($size === "small" ? tailwindStyledComponents.tws `tu-value-bar__text--small` : tailwindStyledComponents.tws `tu-value-bar__text--large`)}
2859
+ `;
2860
+ const Background = tailwindStyledComponents.tw.rect `
2861
+ tu-value-bar__background
2862
+ `;
2863
+ const Bar = tailwindStyledComponents.tw.rect `
2864
+ tu-value-bar__bar
2865
+ `;
2866
+
2867
+ /**
2868
+ * The useDebounce hook works like useState, but adds a delay where previous values will be ignored.
2869
+ *
2870
+ * @param {any} value The value to set
2871
+ * @param {number} delay The debounce time
2872
+ * @returns {any} value The latest values received
2873
+ */
2874
+ const useDebounce = (value, delay = 500) => {
2875
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
2876
+ React.useEffect(() => {
2877
+ const handler = setTimeout(() => {
2878
+ setDebouncedValue(value);
2879
+ }, delay);
2880
+ return () => {
2881
+ clearTimeout(handler);
2882
+ };
2883
+ }, [value, delay]);
2884
+ return debouncedValue;
2885
+ };
2886
+
2887
+ // Copied from https://github.com/rexxars/use-device-pixel-ratio
2888
+ /**
2889
+ * Get the device pixel ratio, potentially rounded and capped.
2890
+ * Will emit new values if it changes.
2891
+ *
2892
+ * @param {DevicePixelRatioOptions} options the options object
2893
+ * @returns { number } The current device pixel ratio, or the default if none can be resolved
2894
+ */
2895
+ function useDevicePixelRatio(options) {
2896
+ const dpr = getDevicePixelRatio(options);
2897
+ const [currentDpr, setCurrentDpr] = React.useState(dpr);
2898
+ const { defaultDpr, maxDpr, round } = options || {};
2899
+ React.useEffect(() => {
2900
+ const canListen = typeof window !== "undefined" && "matchMedia" in window;
2901
+ if (!canListen) {
2902
+ return;
2903
+ }
2904
+ const updateDpr = () => setCurrentDpr(getDevicePixelRatio({ defaultDpr, maxDpr, round }));
2905
+ const mediaMatcher = window.matchMedia(`screen and (resolution: ${currentDpr}dppx)`);
2906
+ // Safari 13.1 does not have `addEventListener`, but does have `addListener`
2907
+ if (mediaMatcher.addEventListener) {
2908
+ mediaMatcher.addEventListener("change", updateDpr);
2909
+ }
2910
+ else {
2911
+ mediaMatcher.addListener(updateDpr);
2912
+ }
2913
+ return () => {
2914
+ if (mediaMatcher.removeEventListener) {
2915
+ mediaMatcher.removeEventListener("change", updateDpr);
2916
+ }
2917
+ else {
2918
+ mediaMatcher.removeListener(updateDpr);
2919
+ }
2920
+ };
2921
+ }, [currentDpr, defaultDpr, maxDpr, round]);
2922
+ return currentDpr;
2923
+ }
2924
+ /**
2925
+ * Returns the current device pixel ratio (DPR) given the passed options
2926
+ *
2927
+ * @param { DevicePixelRatioOptions } options the options object
2928
+ * @returns { number } current device pixel ratio
2929
+ */
2930
+ function getDevicePixelRatio(options) {
2931
+ const { defaultDpr = 1, maxDpr = 3, round = true } = options || {};
2932
+ const hasDprProp = typeof window !== "undefined" && typeof window.devicePixelRatio === "number";
2933
+ const dpr = hasDprProp ? window.devicePixelRatio : defaultDpr;
2934
+ const rounded = Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
2935
+ return rounded;
2936
+ }
2937
+
2938
+ /**
2939
+ * The useLocalStorage hook works like useState, but saves to localstorage.
2940
+ *
2941
+ * @param {string} key - The key the values is saved under.
2942
+ * @param {string | null | undefined} initialValue - The initial value for the state/local storage item
2943
+ * @returns {string | null | undefined} value
2944
+ */
2945
+ const useLocalStorage = (key, initialValue) => {
2946
+ if (!key) {
2947
+ throw new Error("useLocalStorage key may not be falsy");
2948
+ }
2949
+ const setLocalStorageItem = React.useCallback((value) => window.localStorage.setItem(key, typeof value === "object" ? JSON.stringify(value) : `${value}`), [key]);
2950
+ const removeLocalStorageItem = React.useCallback(() => window.localStorage.removeItem(key), [key]);
2951
+ const [item, setValue] = React.useState(() => {
2952
+ const value = window.localStorage.getItem(key);
2953
+ if (value !== undefined && value !== null) {
2954
+ const parsedValue = tryParse(value);
2955
+ return parsedValue;
2956
+ }
2957
+ return initialValue !== null && initialValue !== void 0 ? initialValue : null;
2958
+ });
2959
+ React.useEffect(() => {
2960
+ if (item !== undefined && item !== null) {
2961
+ setLocalStorageItem(item);
2962
+ }
2963
+ else {
2964
+ removeLocalStorageItem();
2965
+ }
2966
+ }, [item, setLocalStorageItem, removeLocalStorageItem, key]);
2967
+ /*
2968
+ // Sync local storage between tabs / windows
2969
+ useEffect(() => {
2970
+ const handleStorageChange = (e: StorageEvent) => {
2971
+ if (e.key === key) {
2972
+ setValue(tryParse(e.newValue));
2973
+ }
2974
+ };
2975
+
2976
+ window.addEventListener("storage", handleStorageChange);
2977
+
2978
+ return () => {
2979
+ window.removeEventListener("storage", handleStorageChange);
2980
+ };
2981
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2982
+ }, []);
2983
+ */
2984
+ const removeItem = () => {
2985
+ setValue(null);
2986
+ };
2987
+ return [item, setValue, removeItem];
2988
+ };
2989
+ function tryParse(value) {
2990
+ try {
2991
+ return JSON.parse(value);
2992
+ }
2993
+ catch (_a) {
2994
+ return value;
2995
+ }
2996
+ }
2997
+
2998
+ /**
2999
+ * @param {UseTimeoutProps} props The props
3000
+ * @returns {{ startTimeout: () => void; stopTimeout: () => void; isReady: boolean | null}} return
3001
+ */
3002
+ const useTimeout = ({ onTimeout, duration }) => {
3003
+ const ready = React.useRef(false);
3004
+ const timeout = React.useRef();
3005
+ const callback = React.useRef(onTimeout);
3006
+ const isReady = React.useCallback(() => ready.current, []);
3007
+ const startTimeout = React.useCallback(() => {
3008
+ ready.current = false;
3009
+ timeout.current && clearTimeout(timeout.current);
3010
+ timeout.current = setTimeout(() => {
3011
+ ready.current = true;
3012
+ callback.current();
3013
+ }, duration);
3014
+ }, [duration]);
3015
+ const stopTimeout = React.useCallback(() => {
3016
+ ready.current = null;
3017
+ timeout.current && clearTimeout(timeout.current);
3018
+ }, []);
3019
+ // update ref when function changes
3020
+ React.useEffect(() => {
3021
+ callback.current = onTimeout;
3022
+ }, [onTimeout]);
3023
+ // startTimeout on mount, stopTimeout on unmount
3024
+ React.useEffect(() => {
3025
+ startTimeout();
3026
+ return stopTimeout;
3027
+ }, [duration, startTimeout, stopTimeout]);
3028
+ return [isReady, stopTimeout, startTimeout];
3029
+ };
3030
+
3031
+ /**
3032
+ * The MinTopFullContentLayout component.
3033
+ *
3034
+ * @param {MinTopFullContentLayoutProps} props - The props for the MinTopFullContentLayout component
3035
+ * @returns {JSX.Element} MinTopFullContentLayout component
3036
+ */
3037
+ const MinTopFullContentLayout = ({ children, className, dataTestId }) => (jsxRuntime.jsx(Layout$5, Object.assign({ className: className, "data-testid": dataTestId }, { children: children })));
3038
+ const Layout$5 = tailwindStyledComponents.tw.span `
3039
+ grid
3040
+ h-full
3041
+ grid-rows-min-fr
3042
+ `;
3043
+
3044
+ /**
3045
+ * Responsive layout component setting up three grid areas
3046
+ * one for filtering, (result-)list and (result-map)
3047
+ *
3048
+ * List needs to handle its own min size - and map takes up the rest.
3049
+ *
3050
+ * Will be inlined to
3051
+ * - filter
3052
+ * - list
3053
+ * - map
3054
+ * on screens < mediaQuery.xxl
3055
+ *
3056
+ *
3057
+ * @param {FilterListMapLayoutProps} props - The props for the FilterListMapLayout component
3058
+ * @returns {JSX.Element} FilterListMapLayout component
3059
+ */
3060
+ const FilterListMapLayout = ({ children }) => jsxRuntime.jsx(Layout$4, { children: children });
3061
+ const Layout$4 = tailwindStyledComponents.tw.span `
3062
+ tu-layout-FilterListMap
3063
+ `;
3064
+
3065
+ /**
3066
+ * Layout component with repeating full width areas, default one height fraction each but option to use content height instead
3067
+ * Row min height can optionally be set here or managed by children
3068
+ * Scrolling happens if/when children's a min-height is reached
3069
+ *
3070
+ * @param {FullWidthRepeatingLayoutProps} props - The props for the FullWidthRepeatingLayout component
3071
+ * @returns {JSX.Element} FullWidthRepeatingLayout component
3072
+ */
3073
+ 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 })));
3074
+ const Layout$3 = tailwindStyledComponents.tw.span `
3075
+ tu-layout-FullWidthRepeatingLayout
3076
+
3077
+ ${({ $rowSizing }) => {
3078
+ switch ($rowSizing) {
3079
+ case "MinContent":
3080
+ return tailwindStyledComponents.tws ` tu-layout-FullWidthRepeatingLayout--MinContent`;
3081
+ case "Equal":
3082
+ return tailwindStyledComponents.tws ` tu-layout-FullWidthRepeatingLayout--Equal`;
3083
+ case "Unmanaged":
3084
+ default:
3085
+ return null;
3086
+ }
3087
+ }}
3088
+ `;
3089
+
3090
+ /**
3091
+ * Simply applies a Grid Area to the element
3092
+ *
3093
+ * @param {GridAreaProps} props - The props for the GridArea component
3094
+ * @returns {JSX.Element} GridArea component
3095
+ */
3096
+ const GridArea = ({ area, dataTestId, className, children }) => (jsxRuntime.jsx("section", Object.assign({ className: className, "data-testid": dataTestId, style: { gridArea: area } }, { children: children })));
3097
+
3098
+ /**
3099
+ * A grid container that has a flexible number of columns.
3100
+ * Adds more columns if constraints allow it, otherwise wraps to next row
3101
+ *
3102
+ * @param {IntrinsicallyResponsiveGridProps} props - The props for the IntrinsicallyResponsiveGrid component
3103
+ * @returns {JSX.Element} IntrinsicallyResponsiveGrid component
3104
+ */
3105
+ 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 })));
3106
+ const Layout$2 = tailwindStyledComponents.tw.span `
3107
+ tu-layout-IntrinsicallyResponsiveGrid
3108
+ ${({ $occupation }) => {
3109
+ switch ($occupation) {
3110
+ case "auto-fit":
3111
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--fit`;
3112
+ case "auto-fill":
3113
+ default:
3114
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--fill`;
3115
+ }
3116
+ }}
3117
+
3118
+ ${({ $minColumnWidth }) => {
3119
+ switch ($minColumnWidth) {
3120
+ case "xs":
3121
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--xs`;
3122
+ case "sm":
3123
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--sm`;
3124
+ case "lg":
3125
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--lg`;
3126
+ case "xl":
3127
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--xl`;
3128
+ case "md":
3129
+ default:
3130
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--md`;
3131
+ }
3132
+ }}
3133
+
3134
+ ${({ $gap }) => {
3135
+ switch ($gap) {
3136
+ case "tiny":
3137
+ return tailwindStyledComponents.tws `gap-1`;
3138
+ case "mini":
3139
+ return tailwindStyledComponents.tws `gap-2`;
3140
+ case "small":
3141
+ return tailwindStyledComponents.tws `gap-3`;
3142
+ case "medium":
3143
+ return tailwindStyledComponents.tws `gap-4`;
3144
+ case "large":
3145
+ return tailwindStyledComponents.tws `gap-6`;
3146
+ case "giant":
3147
+ return tailwindStyledComponents.tws `gap-8`;
3148
+ case "enormous":
3149
+ return tailwindStyledComponents.tws `gap-10`;
3150
+ case "none":
3151
+ return tailwindStyledComponents.tws `gap-0`;
3152
+ case "inherit":
3153
+ return tailwindStyledComponents.tws `gap-[inherit]`;
3154
+ case "auto":
3155
+ default:
3156
+ return tailwindStyledComponents.tws `tu-gap-responsive`;
3157
+ }
3158
+ }};
3159
+
3160
+ ${({ $rowHeight }) => {
3161
+ switch ($rowHeight) {
3162
+ case "auto":
3163
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--row-auto`;
3164
+ case "1fr":
3165
+ default:
3166
+ return tailwindStyledComponents.tws `tu-layout-IntrinsicallyResponsiveGrid--row-1fr`;
3167
+ }
3168
+ }};
3169
+ `;
3170
+
3171
+ /**
3172
+ * The TitleNavContentLayout.
3173
+ * Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
3174
+ *
3175
+ * @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
3176
+ * @returns {JSX.Element} TitleNavContentLayout component
3177
+ */
3178
+ const TitleNavContentLayout = ({ children, className }) => (jsxRuntime.jsx(Layout$1, Object.assign({ className: className }, { children: children })));
3179
+ const Layout$1 = tailwindStyledComponents.tw.div `
3180
+ tu-layout-TitleNavContentLayout
3181
+ lg:tu-layout-TitleNavContentLayout-lg
3182
+ `;
3183
+ /**
3184
+ * A component to define the title area of the TitleNavContentLayout.
3185
+ */
3186
+ const TitleGridArea = tailwindStyledComponents.tw.header `
3187
+ tu-layout-area-title
3188
+ `;
3189
+ /**
3190
+ * A component to define the navigation area of the TitleNavContentLayout.
3191
+ * Adds the needed left padding on large screens.
3192
+ */
3193
+ const NavGridArea = tailwindStyledComponents.tw.aside `
3194
+ tu-layout-area-nav
3195
+ `;
3196
+ /**
3197
+ * A component to define the content area of the TitleNavContentLayout.
3198
+ * Adds the needed right padding on large screens.
3199
+ */
3200
+ const ContentGridArea = tailwindStyledComponents.tw.article `
3201
+ tu-layout-area-content
3202
+ `;
3203
+
3204
+ /**
3205
+ * TwoColumnLayout.
3206
+ *
3207
+ * @param {TwoColumnLayoutProps} props - The props for the TwoColumnLayout component
3208
+ * @returns {JSX.Element} TwoColumnLayout component
3209
+ */
3210
+ const TwoColumnLayout = ({ children }) => jsxRuntime.jsx(Layout, { children: children });
3211
+ const Layout = tailwindStyledComponents.tw.div `
3212
+ tu-layout-TwoColumnLayout
3213
+ `;
3214
+
3215
+ Object.defineProperty(exports, 'ValueType', {
3216
+ enumerable: true,
3217
+ get: function () { return ReactSelect__default["default"]; }
3218
+ });
3219
+ exports.ActionButton = ActionButton;
3220
+ exports.Alert = Alert;
3221
+ exports.Badge = Badge;
3222
+ exports.BaseInput = BaseInput;
3223
+ exports.Button = Button;
3224
+ exports.Card = Card;
3225
+ exports.CardBody = CardBody;
3226
+ exports.CardFooter = CardFooter;
3227
+ exports.CardHeader = CardHeader;
3228
+ exports.Checkbox = Checkbox;
3229
+ exports.Collapse = Collapse;
3230
+ exports.ContentGridArea = ContentGridArea;
3231
+ exports.CopyableText = CopyableText;
3232
+ exports.CreatableSelect = CreatableSelect;
3233
+ exports.DateField = DateField;
3234
+ exports.DateInput = DateInput;
3235
+ exports.DayPicker = DayPicker;
3236
+ exports.DayPickerPopover = DayPickerPopover;
3237
+ exports.DayRangePicker = DayRangePicker;
3238
+ exports.DensityContainer = DensityContainer;
3239
+ exports.Drawer = Drawer;
3240
+ exports.DropZone = DropZone;
3241
+ exports.EmailField = EmailField;
3242
+ exports.EmailInput = EmailInput;
3243
+ exports.ExternalLink = ExternalLink;
3244
+ exports.FilterListMapLayout = FilterListMapLayout;
3245
+ exports.FormGroup = FormGroup;
3246
+ exports.FullWidthRepeatingLayout = FullWidthRepeatingLayout;
3247
+ exports.GridArea = GridArea;
3248
+ exports.Heading = Heading$1;
3249
+ exports.Icon = Icon;
3250
+ exports.IconButton = IconButton;
3251
+ exports.Indicator = Indicator;
3252
+ exports.IntrinsicallyResponsiveGrid = IntrinsicallyResponsiveGrid;
3253
+ exports.Label = Label$2;
3254
+ exports.MenuItem = MenuItem;
3255
+ exports.MenuList = MenuList;
3256
+ exports.MinTopFullContentLayout = MinTopFullContentLayout;
3257
+ exports.Modal = Modal;
3258
+ exports.ModalBackdrop = ModalBackdrop;
3259
+ exports.MoreMenu = MoreMenu;
3260
+ exports.MultiSelectMenuItem = MultiSelectMenuItem;
3261
+ exports.NavGridArea = NavGridArea;
3262
+ exports.NumberField = NumberField;
3263
+ exports.NumberInput = NumberInput;
3264
+ exports.PageHeader = PageHeader;
3265
+ exports.Pagination = Pagination;
3266
+ exports.PhoneField = PhoneField;
3267
+ exports.PhoneInput = PhoneInput;
3268
+ exports.Popover = Popover;
3269
+ exports.PopoverList = PopoverList;
3270
+ exports.PopoverListItem = PopoverListItem;
3271
+ exports.PopoverTitle = PopoverTitle;
3272
+ exports.Prompt = Prompt;
3273
+ exports.ROLE_CARD = ROLE_CARD;
3274
+ exports.RadioGroup = RadioGroup;
3275
+ exports.RadioItem = RadioItem;
3276
+ exports.Search = Search;
3277
+ exports.SectionHeader = SectionHeader;
3278
+ exports.Select = Select;
3279
+ exports.SelectPrefix = SelectPrefix;
3280
+ exports.Sidebar = Sidebar;
3281
+ exports.SingleSelectMenuItem = SingleSelectMenuItem;
3282
+ exports.SkeletonLines = SkeletonLines;
3283
+ exports.Spacer = Spacer;
3284
+ exports.Spinner = Spinner;
3285
+ exports.StarButton = StarButton;
3286
+ exports.Tag = Tag;
3287
+ exports.Text = Text$1;
3288
+ exports.TextArea = TextArea;
3289
+ exports.TextAreaField = TextAreaField;
3290
+ exports.TextField = TextField;
3291
+ exports.TextInput = TextInput;
3292
+ exports.Timeline = Timeline;
3293
+ exports.TimelineElement = TimelineElement;
3294
+ exports.Tip = Tip;
3295
+ exports.TitleGridArea = TitleGridArea;
3296
+ exports.TitleNavContentLayout = TitleNavContentLayout;
3297
+ exports.Toggle = Toggle;
3298
+ exports.Tooltip = Tooltip;
3299
+ exports.TwoColumnLayout = TwoColumnLayout;
3300
+ exports.UploadField = UploadField;
3301
+ exports.UploadInput = UploadInput;
3302
+ exports.ValueBar = ValueBar;
3303
+ exports.docs = docs;
3304
+ exports.getDevicePixelRatio = getDevicePixelRatio;
3305
+ exports.getOrderedOptions = getOrderedOptions;
3306
+ exports.getValueBarColorByValue = getValueBarColorByValue;
3307
+ exports.isMultiValue = isMultiValue;
3308
+ exports.useContainerProps = useContainerProps;
3309
+ exports.useCustomComponents = useCustomComponents;
3310
+ exports.useDebounce = useDebounce;
3311
+ exports.useDevicePixelRatio = useDevicePixelRatio;
3312
+ exports.useLocalStorage = useLocalStorage;
3313
+ exports.useModal = useModal;
3314
+ exports.usePrompt = usePrompt;
3315
+ exports.useTimeout = useTimeout;