@simplybusiness/mobius 8.0.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/index.js +4773 -0
  3. package/dist/cjs/index.js.map +7 -0
  4. package/dist/cjs/meta.json +4948 -0
  5. package/dist/esm/index.js +542 -694
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/esm/meta.json +300 -532
  8. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  9. package/dist/types/src/hooks/index.d.ts +0 -7
  10. package/dist/types/src/utils/htmlDialogPolyfill.d.ts +1 -0
  11. package/dist/types/src/utils/index.d.ts +0 -1
  12. package/dist/types/src/utils/mockMatchMedia.d.ts +1 -0
  13. package/dist/types/vitest.config.d.ts +2 -0
  14. package/package.json +14 -18
  15. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  16. package/src/components/Accordion/Accordion.test.tsx +12 -12
  17. package/src/components/Accordion/Accordion.tsx +1 -1
  18. package/src/components/Accordion/AccordionList.stories.tsx +1 -1
  19. package/src/components/Accordion/AccordionList.test.tsx +6 -6
  20. package/src/components/AddressLookup/AddressLookup.stories.tsx +1 -1
  21. package/src/components/AddressLookup/AddressLookup.test.tsx +19 -20
  22. package/src/components/AddressLookup/LoqateAddressLookupService.test.tsx +7 -6
  23. package/src/components/Alert/Alert.stories.tsx +1 -1
  24. package/src/components/Box/Box.stories.tsx +1 -1
  25. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
  26. package/src/components/Button/Button.stories.tsx +3 -4
  27. package/src/components/Button/Button.test.tsx +4 -4
  28. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  29. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  30. package/src/components/Checkbox/CheckboxGroup.stories.tsx +1 -1
  31. package/src/components/Checkbox/CheckboxGroup.test.tsx +5 -5
  32. package/src/components/Combobox/Combobox.stories.tsx +1 -1
  33. package/src/components/Combobox/Combobox.test.tsx +67 -78
  34. package/src/components/Combobox/Combobox.tsx +2 -1
  35. package/src/components/Combobox/useComboboxOptions.test.ts +30 -30
  36. package/src/components/Combobox/useComboboxOptions.ts +1 -1
  37. package/src/components/Container/Container.stories.tsx +1 -1
  38. package/src/components/DateField/DateField.stories.tsx +1 -1
  39. package/src/components/DateField/DateField.test.tsx +1 -1
  40. package/src/components/Divider/Divider.stories.tsx +1 -1
  41. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  42. package/src/components/Drawer/Drawer.test.tsx +6 -6
  43. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +8 -10
  44. package/src/components/DropdownMenu/DropdownMenu.test.tsx +1 -1
  45. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +1 -1
  46. package/src/components/ExpandableText/ExpandableText.test.tsx +14 -14
  47. package/src/components/Fieldset/Fieldset.stories.tsx +1 -1
  48. package/src/components/Flex/Flex.stories.tsx +1 -1
  49. package/src/components/Grid/Grid.stories.tsx +4 -7
  50. package/src/components/Icon/Icon.stories.tsx +1 -1
  51. package/src/components/Image/Image.stories.tsx +1 -1
  52. package/src/components/Label/Label.stories.tsx +1 -1
  53. package/src/components/Link/Link.stories.tsx +1 -1
  54. package/src/components/Link/Link.test.tsx +1 -1
  55. package/src/components/LinkButton/LinkButton.stories.tsx +1 -1
  56. package/src/components/LinkButton/LinkButton.test.tsx +2 -2
  57. package/src/components/List/List.stories.tsx +1 -1
  58. package/src/components/LoadingIndicator/LoadingIndicator.stories.tsx +1 -1
  59. package/src/components/Logo/Logo.stories.tsx +1 -1
  60. package/src/components/Modal/Modal.stories.tsx +1 -1
  61. package/src/components/Modal/Modal.test.tsx +6 -6
  62. package/src/components/NumberField/NumberField.stories.tsx +1 -1
  63. package/src/components/NumberField/NumberField.test.tsx +5 -5
  64. package/src/components/PasswordField/PasswordField.stories.tsx +1 -1
  65. package/src/components/Popover/Popover.stories.tsx +4 -8
  66. package/src/components/Popover/Popover.test.tsx +4 -4
  67. package/src/components/Popover/Popover.tsx +1 -1
  68. package/src/components/Progress/Progress.stories.tsx +1 -1
  69. package/src/components/Radio/Radio.stories.tsx +1 -1
  70. package/src/components/Radio/Radio.test.tsx +9 -9
  71. package/src/components/SVG/SVG.stories.tsx +1 -1
  72. package/src/components/Segment/Segment.stories.tsx +1 -1
  73. package/src/components/Select/Select.stories.tsx +1 -1
  74. package/src/components/Select/Select.test.tsx +1 -1
  75. package/src/components/Slider/Slider.stories.tsx +1 -1
  76. package/src/components/Slider/Slider.test.tsx +6 -6
  77. package/src/components/Slider/helpers.test.ts +1 -1
  78. package/src/components/Stack/Stack.stories.tsx +1 -1
  79. package/src/components/Switch/Switch.stories.tsx +1 -1
  80. package/src/components/Switch/Switch.test.tsx +1 -1
  81. package/src/components/Table/Table.stories.tsx +1 -1
  82. package/src/components/Text/Text.stories.tsx +1 -1
  83. package/src/components/TextArea/TextArea.stories.tsx +1 -1
  84. package/src/components/TextArea/TextArea.test.tsx +3 -3
  85. package/src/components/TextField/TextField.stories.tsx +1 -1
  86. package/src/components/TextOrHTML/TextOrHTML.stories.tsx +1 -1
  87. package/src/components/Title/Title.stories.tsx +1 -1
  88. package/src/components/Toast/Toast.stories.tsx +1 -1
  89. package/src/components/Toast/Toast.test.tsx +6 -6
  90. package/src/components/Trust/Trust.stories.tsx +1 -1
  91. package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +1 -1
  92. package/src/hooks/index.tsx +0 -7
  93. package/src/hooks/useBreakpoint/useBreakpoint.ssr.test.tsx +18 -0
  94. package/src/hooks/useBreakpoint/useBreakpoint.stories.tsx +1 -1
  95. package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +65 -5
  96. package/src/hooks/useBreakpoint/useBreakpoint.tsx +25 -39
  97. package/src/hooks/useButton/useButton.test.tsx +4 -4
  98. package/src/hooks/useDialog/useDialog.ts +1 -1
  99. package/src/hooks/useLabel/useLabel.test.tsx +1 -1
  100. package/src/hooks/useTextField/useTextField.test.tsx +4 -4
  101. package/src/public-whitelist.test.ts +1 -0
  102. package/src/utils/delay.test.ts +4 -4
  103. package/src/utils/{jestHTMLDialogPolyfill.ts → htmlDialogPolyfill.ts} +5 -5
  104. package/src/utils/index.ts +0 -1
  105. package/src/utils/mockMatchMedia.ts +16 -0
  106. package/dist/types/src/hooks/useBodyScrollLock/index.d.ts +0 -1
  107. package/dist/types/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +0 -3
  108. package/dist/types/src/hooks/useDebouncedValue/index.d.ts +0 -1
  109. package/dist/types/src/hooks/useDebouncedValue/useDebouncedValue.d.ts +0 -1
  110. package/dist/types/src/hooks/useOnClickOutside/index.d.ts +0 -1
  111. package/dist/types/src/hooks/useOnClickOutside/useOnClickOutside.d.ts +0 -2
  112. package/dist/types/src/hooks/useOnUnmount/index.d.ts +0 -1
  113. package/dist/types/src/hooks/useOnUnmount/useOnUnmount.d.ts +0 -1
  114. package/dist/types/src/hooks/usePrefersReducedMotion/index.d.ts +0 -1
  115. package/dist/types/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.d.ts +0 -1
  116. package/dist/types/src/hooks/useRenderCount/index.d.ts +0 -1
  117. package/dist/types/src/hooks/useRenderCount/useRenderCount.d.ts +0 -1
  118. package/dist/types/src/hooks/useWindowEvent/index.d.ts +0 -1
  119. package/dist/types/src/hooks/useWindowEvent/useWindowEvent.d.ts +0 -1
  120. package/dist/types/src/utils/jestHTMLDialogPolyfill.d.ts +0 -1
  121. package/dist/types/src/utils/jestMockMatchMedia.d.ts +0 -1
  122. package/src/hooks/useBodyScrollLock/index.ts +0 -1
  123. package/src/hooks/useBodyScrollLock/useBodyScrollLock.test.ts +0 -34
  124. package/src/hooks/useBodyScrollLock/useBodyScrollLock.ts +0 -30
  125. package/src/hooks/useDebouncedValue/index.tsx +0 -1
  126. package/src/hooks/useDebouncedValue/useDebouncedValue.test.tsx +0 -62
  127. package/src/hooks/useDebouncedValue/useDebouncedValue.tsx +0 -25
  128. package/src/hooks/useOnClickOutside/index.tsx +0 -1
  129. package/src/hooks/useOnClickOutside/useOnClickOutside.test.tsx +0 -189
  130. package/src/hooks/useOnClickOutside/useOnClickOutside.tsx +0 -44
  131. package/src/hooks/useOnUnmount/index.tsx +0 -1
  132. package/src/hooks/useOnUnmount/useOnUnmount.test.tsx +0 -37
  133. package/src/hooks/useOnUnmount/useOnUnmount.tsx +0 -8
  134. package/src/hooks/usePrefersReducedMotion/index.tsx +0 -1
  135. package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.test.tsx +0 -48
  136. package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.tsx +0 -22
  137. package/src/hooks/useRenderCount/index.ts +0 -1
  138. package/src/hooks/useRenderCount/useRenderCount.test.ts +0 -26
  139. package/src/hooks/useRenderCount/useRenderCount.ts +0 -9
  140. package/src/hooks/useWindowEvent/index.tsx +0 -1
  141. package/src/hooks/useWindowEvent/useWindowEvent.test.tsx +0 -188
  142. package/src/hooks/useWindowEvent/useWindowEvent.tsx +0 -41
  143. package/src/utils/jestMockMatchMedia.ts +0 -16
@@ -0,0 +1,4773 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
33
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
34
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
35
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
36
+
37
+ // index.tsx
38
+ var index_exports = {};
39
+ __export(index_exports, {
40
+ Accordion: () => Accordion,
41
+ AccordionList: () => AccordionList,
42
+ AddressLookup: () => AddressLookup,
43
+ Alert: () => Alert,
44
+ Box: () => Box,
45
+ BreadcrumbItem: () => BreadcrumbItem,
46
+ Breadcrumbs: () => Breadcrumbs,
47
+ Button: () => Button,
48
+ Checkbox: () => Checkbox,
49
+ CheckboxGroup: () => CheckboxGroup,
50
+ Combobox: () => Combobox,
51
+ Container: () => Container,
52
+ DEFAULT_BREAKPOINTS: () => DEFAULT_BREAKPOINTS,
53
+ DateField: () => DateField,
54
+ Divider: () => Divider,
55
+ Drawer: () => Drawer2,
56
+ DropdownMenu: () => DropdownMenu2,
57
+ ErrorMessage: () => ErrorMessage,
58
+ ExpandableText: () => ExpandableText,
59
+ Fieldset: () => Fieldset,
60
+ Flex: () => Flex,
61
+ Grid: () => Grid2,
62
+ Icon: () => Icon,
63
+ Image: () => Image,
64
+ Label: () => Label,
65
+ Link: () => Link,
66
+ LinkButton: () => LinkButton,
67
+ List: () => List,
68
+ ListItem: () => ListItem,
69
+ LoadingIndicator: () => LoadingIndicator,
70
+ Logo: () => Logo,
71
+ LoqateAddressLookupService: () => LoqateAddressLookupService,
72
+ MIN_MAX_ERROR: () => MIN_MAX_ERROR,
73
+ MaskedField: () => MaskedField,
74
+ Modal: () => Modal2,
75
+ NumberField: () => NumberField,
76
+ Option: () => Option2,
77
+ PasswordField: () => PasswordField,
78
+ Popover: () => Popover,
79
+ Progress: () => Progress,
80
+ Radio: () => Radio,
81
+ RadioGroup: () => RadioGroup,
82
+ SVG: () => SVG,
83
+ Segment: () => Segment,
84
+ SegmentGroup: () => SegmentGroup,
85
+ Select: () => Select,
86
+ Slider: () => Slider,
87
+ Stack: () => Stack,
88
+ Switch: () => Switch,
89
+ Table: () => Table2,
90
+ Text: () => Text,
91
+ TextArea: () => TextArea,
92
+ TextAreaInput: () => TextAreaInput,
93
+ TextField: () => TextField,
94
+ TextOrHTML: () => TextOrHTML,
95
+ Title: () => Title,
96
+ Toaster: () => Toaster,
97
+ Trust: () => Trust,
98
+ VisuallyHidden: () => VisuallyHidden,
99
+ convertToDateFormat: () => convertToDateFormat,
100
+ isValidDate: () => isValidDate,
101
+ toast: () => toast,
102
+ useBreakpoint: () => useBreakpoint,
103
+ useButton: () => useButton,
104
+ useDialog: () => useDialog,
105
+ useDialogPolyfill: () => useDialogPolyfill,
106
+ useDrawer: () => useDrawer,
107
+ useLabel: () => useLabel,
108
+ useModal: () => useModal,
109
+ useTextField: () => useTextField,
110
+ useValidationClasses: () => useValidationClasses
111
+ });
112
+ module.exports = __toCommonJS(index_exports);
113
+
114
+ // src/components/Accordion/Accordion.tsx
115
+ var import_dedupe4 = __toESM(require("classnames/dedupe"));
116
+ var import_react = require("react");
117
+ var import_mobius_hooks = require("@simplybusiness/mobius-hooks");
118
+
119
+ // src/components/Accordion/AccordionLink.tsx
120
+ var import_dedupe3 = __toESM(require("classnames/dedupe"));
121
+
122
+ // src/components/Flex/Flex.tsx
123
+ var import_dedupe = __toESM(require("classnames/dedupe"));
124
+
125
+ // src/utils/filterUndefinedProps.ts
126
+ var filterUndefinedProps = (props) => {
127
+ const filteredProps = {};
128
+ Object.keys(props).forEach((key) => {
129
+ if (props[key] !== void 0) {
130
+ filteredProps[key] = props[key];
131
+ }
132
+ });
133
+ return filteredProps;
134
+ };
135
+
136
+ // src/utils/getSpacingValue.ts
137
+ var getSpacingValue = (padding) => {
138
+ if (typeof padding === "string") {
139
+ return `var(--size-${padding})`;
140
+ }
141
+ if (typeof padding === "number") {
142
+ return `${padding}px`;
143
+ }
144
+ return void 0;
145
+ };
146
+
147
+ // src/utils/mergeRefs.ts
148
+ function mergeRefs(refs) {
149
+ return (value) => {
150
+ refs.forEach((ref) => {
151
+ if (typeof ref === "function") {
152
+ ref(value);
153
+ } else if (ref != null) {
154
+ ref.current = value;
155
+ }
156
+ });
157
+ };
158
+ }
159
+
160
+ // src/utils/polyfill-tests.ts
161
+ var supportsDialog = () => typeof HTMLDialogElement === "function";
162
+
163
+ // src/utils/sizeClasses.ts
164
+ var sizeClasses = (size) => {
165
+ if (!size) {
166
+ return {};
167
+ }
168
+ return {
169
+ "--is-xxs": size === "xxs",
170
+ "--is-xs": size === "xs",
171
+ "--is-sm": size === "sm",
172
+ "--is-md": size === "md",
173
+ "--is-lg": size === "lg",
174
+ "--is-xl": size === "xl",
175
+ "--is-xxl": size === "xxl"
176
+ };
177
+ };
178
+
179
+ // src/utils/spaceDelimitedList.ts
180
+ function spaceDelimitedList(list) {
181
+ return list.filter(Boolean).join(" ") || void 0;
182
+ }
183
+
184
+ // src/components/Flex/propUtils.ts
185
+ var buildFlexStyles = (props) => {
186
+ const {
187
+ flexDirection,
188
+ flexWrap,
189
+ flexGrow,
190
+ flex,
191
+ justifyContent,
192
+ alignItems,
193
+ alignContent,
194
+ gap,
195
+ rowGap,
196
+ columnGap
197
+ } = props;
198
+ const styleProps = {
199
+ flexDirection,
200
+ flexWrap,
201
+ flexGrow,
202
+ flex,
203
+ justifyContent,
204
+ alignItems,
205
+ alignContent,
206
+ gap: getSpacingValue(gap),
207
+ columnGap: getSpacingValue(columnGap),
208
+ rowGap: getSpacingValue(rowGap)
209
+ };
210
+ return filterUndefinedProps(styleProps);
211
+ };
212
+ var splitProps = (props) => {
213
+ const {
214
+ flexDirection,
215
+ flexWrap,
216
+ flexGrow,
217
+ flex,
218
+ justifyContent,
219
+ alignItems,
220
+ alignContent,
221
+ gap,
222
+ rowGap,
223
+ columnGap,
224
+ ...otherProps
225
+ } = props;
226
+ return [
227
+ {
228
+ flexDirection,
229
+ flexWrap,
230
+ flexGrow,
231
+ flex,
232
+ justifyContent,
233
+ alignItems,
234
+ alignContent,
235
+ gap,
236
+ rowGap,
237
+ columnGap
238
+ },
239
+ otherProps
240
+ ];
241
+ };
242
+
243
+ // src/components/Flex/Flex.tsx
244
+ var import_jsx_runtime = require("react/jsx-runtime");
245
+ var Flex = ({ ref, ...props }) => {
246
+ const {
247
+ elementType: Element = "div",
248
+ style,
249
+ className,
250
+ ...otherProps
251
+ } = props;
252
+ const classes = (0, import_dedupe.default)("mobius", "mobius-flex", className);
253
+ const [styleProps, restProps] = splitProps(otherProps);
254
+ const flexStyles = buildFlexStyles(styleProps);
255
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
256
+ Element,
257
+ {
258
+ ref,
259
+ style: {
260
+ ...flexStyles,
261
+ ...style
262
+ },
263
+ className: classes,
264
+ ...restProps
265
+ }
266
+ );
267
+ };
268
+ Flex.displayName = "Flex";
269
+
270
+ // src/components/Icon/Icon.tsx
271
+ var import_dedupe2 = __toESM(require("classnames/dedupe"));
272
+ var import_jsx_runtime2 = require("react/jsx-runtime");
273
+ var ICON_PREFIX = "mobius-icon";
274
+ var capitaliseFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
275
+ function Icon({
276
+ ref,
277
+ icon,
278
+ className,
279
+ size = "xs",
280
+ color,
281
+ fixedWidth,
282
+ spin,
283
+ spinReverse,
284
+ title,
285
+ ...otherProps
286
+ }) {
287
+ if (!icon) {
288
+ throw new Error("Must specify icon object");
289
+ }
290
+ const classes = (0, import_dedupe2.default)(
291
+ "mobius",
292
+ "mobius-icon",
293
+ `svg-inline--${ICON_PREFIX}`,
294
+ `--size-${size}`,
295
+ className,
296
+ {
297
+ [`${ICON_PREFIX}-fw`]: fixedWidth,
298
+ [`${ICON_PREFIX}-spin`]: spin || spinReverse,
299
+ [`${ICON_PREFIX}-spin-reverse`]: spinReverse
300
+ }
301
+ );
302
+ const { iconName, width, height, svgPathData } = icon;
303
+ const formattedIconName = iconName.split("-").join(" ");
304
+ const defaultTitle = `${capitaliseFirstLetter(formattedIconName)} icon`;
305
+ const titleText = title || defaultTitle;
306
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
307
+ "svg",
308
+ {
309
+ ref,
310
+ focusable: "false",
311
+ "data-icon": iconName,
312
+ className: classes,
313
+ role: "img",
314
+ xmlns: "http://www.w3.org/2000/svg",
315
+ viewBox: `0 0 ${width} ${height}`,
316
+ style: { color },
317
+ ...otherProps,
318
+ children: [
319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("title", { children: titleText }),
320
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", d: svgPathData })
321
+ ]
322
+ }
323
+ );
324
+ }
325
+
326
+ // src/components/Accordion/AccordionLink.tsx
327
+ var import_icons = require("@simplybusiness/icons");
328
+ var import_jsx_runtime3 = require("react/jsx-runtime");
329
+ var AccordionLink = ({
330
+ text,
331
+ elementType: LinkElement = "span",
332
+ toggle,
333
+ onClick,
334
+ headerChildren,
335
+ ariaExpanded,
336
+ accordionId,
337
+ contentId
338
+ }) => {
339
+ const linkClasses = (0, import_dedupe3.default)("mobius-accordion__link", {
340
+ "--is-open": ariaExpanded
341
+ });
342
+ const iconClasses = (0, import_dedupe3.default)("mobius-accordion__link-icon", {
343
+ "--is-open": ariaExpanded
344
+ });
345
+ const handleOnClick = (e) => {
346
+ if (onClick) {
347
+ onClick(e);
348
+ }
349
+ toggle();
350
+ };
351
+ const handleKeyDown = (e) => {
352
+ if (e.key === " " || e.key === "Enter") {
353
+ toggle();
354
+ }
355
+ };
356
+ if (headerChildren) {
357
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
358
+ Flex,
359
+ {
360
+ justifyContent: "space-between",
361
+ alignItems: "center",
362
+ className: "mobius-accordion__header",
363
+ children: [
364
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
365
+ "div",
366
+ {
367
+ id: accordionId,
368
+ className: linkClasses,
369
+ onClick: handleOnClick,
370
+ onKeyDown: handleKeyDown,
371
+ role: "button",
372
+ tabIndex: 0,
373
+ "aria-expanded": !!ariaExpanded,
374
+ "aria-controls": contentId,
375
+ children: [
376
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LinkElement, { className: "mobius-accordion__link-text", children: text }),
377
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon: import_icons.chevronDown, className: iconClasses })
378
+ ]
379
+ }
380
+ ),
381
+ headerChildren
382
+ ]
383
+ }
384
+ );
385
+ }
386
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
387
+ "div",
388
+ {
389
+ id: accordionId,
390
+ className: linkClasses,
391
+ onClick: handleOnClick,
392
+ onKeyDown: handleKeyDown,
393
+ role: "button",
394
+ tabIndex: 0,
395
+ "aria-expanded": !!ariaExpanded,
396
+ "aria-controls": contentId,
397
+ children: [
398
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LinkElement, { className: "mobius-accordion__link-text", children: text }),
399
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon: import_icons.chevronDown, className: iconClasses })
400
+ ]
401
+ }
402
+ );
403
+ };
404
+
405
+ // src/components/Accordion/Accordion.tsx
406
+ var import_jsx_runtime4 = require("react/jsx-runtime");
407
+ var Accordion = ({ ref, ...props }) => {
408
+ const {
409
+ showText = "See more",
410
+ hideText = "See less",
411
+ headerPosition = "top",
412
+ startOpen = false,
413
+ linkElementType,
414
+ onClick,
415
+ onOpen,
416
+ onClose,
417
+ onChange = () => {
418
+ },
419
+ headerChildren,
420
+ ...rest
421
+ } = props;
422
+ const [accordionState, setAccordionState] = (0, import_react.useState)({
423
+ open: startOpen,
424
+ withAnimation: false
425
+ });
426
+ const prefersReducedMotion = (0, import_mobius_hooks.usePrefersReducedMotion)();
427
+ const containerClasses = (0, import_dedupe4.default)(
428
+ "mobius",
429
+ "mobius-accordion",
430
+ props.className,
431
+ {
432
+ "--should-animate": accordionState.withAnimation && !prefersReducedMotion,
433
+ "--is-open": accordionState.open
434
+ }
435
+ );
436
+ const contentContainerClasses = (0, import_dedupe4.default)(
437
+ "mobius-accordion__content-container",
438
+ {
439
+ "--is-open": accordionState.open
440
+ }
441
+ );
442
+ const contentClasses = (0, import_dedupe4.default)("mobius-accordion__content", {
443
+ "--is-open": accordionState.open
444
+ });
445
+ const linkText = accordionState.open ? hideText : showText;
446
+ const handleChange = () => {
447
+ if (!accordionState.open && onOpen) {
448
+ onOpen();
449
+ }
450
+ if (accordionState.open && onClose) {
451
+ onClose();
452
+ }
453
+ if (onChange) {
454
+ onChange(!accordionState.open);
455
+ }
456
+ setAccordionState({
457
+ open: !accordionState.open,
458
+ withAnimation: true
459
+ });
460
+ };
461
+ (0, import_react.useEffect)(() => {
462
+ setAccordionState({
463
+ open: startOpen,
464
+ withAnimation: true
465
+ });
466
+ }, [startOpen]);
467
+ const baseId = (0, import_react.useId)();
468
+ const accordionId = `accordion-header-${baseId}`;
469
+ const contentId = `accordion-panel-${baseId}`;
470
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref, ...rest, className: containerClasses, children: [
471
+ headerPosition === "top" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
472
+ AccordionLink,
473
+ {
474
+ text: linkText,
475
+ elementType: linkElementType,
476
+ toggle: handleChange,
477
+ onClick,
478
+ ariaExpanded: accordionState.open,
479
+ headerChildren,
480
+ accordionId,
481
+ contentId
482
+ }
483
+ ),
484
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
485
+ "div",
486
+ {
487
+ id: contentId,
488
+ className: contentContainerClasses,
489
+ "aria-hidden": !accordionState.open,
490
+ "aria-labelledby": accordionId,
491
+ role: "region",
492
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: contentClasses, children: props.children })
493
+ }
494
+ ),
495
+ headerPosition === "bottom" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
496
+ AccordionLink,
497
+ {
498
+ text: linkText,
499
+ toggle: handleChange,
500
+ onClick,
501
+ ariaExpanded: accordionState.open,
502
+ headerChildren,
503
+ accordionId,
504
+ contentId
505
+ }
506
+ )
507
+ ] });
508
+ };
509
+ Accordion.displayName = "Accordion";
510
+
511
+ // src/components/Accordion/AccordionList.tsx
512
+ var import_react2 = require("react");
513
+ var import_dedupe6 = __toESM(require("classnames/dedupe"));
514
+
515
+ // src/components/Divider/Divider.tsx
516
+ var import_dedupe5 = __toESM(require("classnames/dedupe"));
517
+ var import_jsx_runtime5 = require("react/jsx-runtime");
518
+ var Divider = ({
519
+ "aria-orientation": ariaOrientation = "horizontal",
520
+ className,
521
+ ...rest
522
+ }) => {
523
+ const classes = (0, import_dedupe5.default)("mobius", "mobius-divider", className);
524
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
525
+ "div",
526
+ {
527
+ className: classes,
528
+ role: "separator",
529
+ "aria-orientation": ariaOrientation,
530
+ ...rest,
531
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mobius-divider__inner" })
532
+ }
533
+ );
534
+ };
535
+ Divider.displayName = "Divider";
536
+
537
+ // src/components/Accordion/AccordionList.tsx
538
+ var import_jsx_runtime6 = require("react/jsx-runtime");
539
+ var AccordionList = (props) => {
540
+ const {
541
+ className,
542
+ content,
543
+ onOpen,
544
+ onClose,
545
+ allowMultiple = false,
546
+ ...rest
547
+ } = props;
548
+ const [openIds, setOpenIds] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
549
+ const classes = (0, import_dedupe6.default)("mobius", "mobius-accordion-list", className);
550
+ const handleAccordionChange = (id, isOpen) => {
551
+ setOpenIds((prev) => {
552
+ const newSet = new Set(prev);
553
+ if (isOpen) {
554
+ if (!allowMultiple) {
555
+ newSet.clear();
556
+ }
557
+ newSet.add(id);
558
+ } else {
559
+ newSet.delete(id);
560
+ }
561
+ return newSet;
562
+ });
563
+ if (isOpen) {
564
+ onOpen?.(id);
565
+ } else {
566
+ onClose?.(id);
567
+ }
568
+ };
569
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: classes, ...rest, children: content.map((item, index) => {
570
+ const { id, header, details } = item;
571
+ const isOpen = openIds.has(id);
572
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react2.Fragment, { children: [
573
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
574
+ Accordion,
575
+ {
576
+ startOpen: isOpen,
577
+ showText: header,
578
+ hideText: header,
579
+ onChange: (isOpen2) => handleAccordionChange(id, isOpen2),
580
+ children: details
581
+ }
582
+ ),
583
+ index < content.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Divider, {})
584
+ ] }, id);
585
+ }) });
586
+ };
587
+ AccordionList.displayName = "AccordionList";
588
+
589
+ // src/components/AddressLookup/AddressLookup.tsx
590
+ var import_icons3 = require("@simplybusiness/icons");
591
+ var import_react14 = require("react");
592
+
593
+ // src/components/Combobox/Combobox.tsx
594
+ var import_dedupe14 = __toESM(require("classnames/dedupe"));
595
+ var import_react13 = require("react");
596
+ var import_mobius_hooks5 = require("@simplybusiness/mobius-hooks");
597
+
598
+ // src/hooks/useBreakpoint/useBreakpoint.tsx
599
+ var import_mobius_hooks2 = require("@simplybusiness/mobius-hooks");
600
+ var import_react3 = require("react");
601
+ var DEFAULT_BREAKPOINTS = [
602
+ { size: "xs", value: 320 },
603
+ { size: "sm", value: 480 },
604
+ { size: "md", value: 670 },
605
+ { size: "lg", value: 960 },
606
+ { size: "xl", value: 1200 },
607
+ { size: "xxl", value: 1320 }
608
+ ];
609
+ var PASSIVE = { passive: true };
610
+ var getBreakpoint = (breakpoints, windowWidth) => {
611
+ const closest = breakpoints.findIndex(
612
+ (breakpoint) => breakpoint.value >= windowWidth + 1
613
+ );
614
+ const smallest = breakpoints[0];
615
+ const largest = breakpoints[breakpoints.length - 1];
616
+ const match = breakpoints[closest - 1];
617
+ if (closest === 0) return smallest;
618
+ if (closest === -1) return largest;
619
+ return match;
620
+ };
621
+ var useBreakpoint = (customBreakpoints) => {
622
+ const isClientSide = (0, import_mobius_hooks2.useIsClient)();
623
+ const breakpoints = customBreakpoints || DEFAULT_BREAKPOINTS;
624
+ const defaultBreakpoint = breakpoints[0];
625
+ const [windowWidth, setWindowWidth] = (0, import_react3.useState)(
626
+ typeof globalThis?.window !== "undefined" ? window.innerWidth : defaultBreakpoint.value
627
+ );
628
+ (0, import_mobius_hooks2.useWindowEvent)("resize", () => setWindowWidth(window.innerWidth), PASSIVE);
629
+ const debouncedWidth = (0, import_mobius_hooks2.useDebouncedValue)(windowWidth, 200);
630
+ const currentBreakpoint = (0, import_react3.useMemo)(
631
+ () => !isClientSide || breakpoints.length === 0 ? defaultBreakpoint : getBreakpoint(breakpoints, debouncedWidth),
632
+ [isClientSide, breakpoints, defaultBreakpoint, debouncedWidth]
633
+ );
634
+ const up = (0, import_react3.useCallback)(
635
+ (size) => {
636
+ const sizeIndex = breakpoints.findIndex((item) => item.size === size);
637
+ if (sizeIndex === -1) {
638
+ return false;
639
+ }
640
+ const currentIndex = breakpoints.findIndex(
641
+ (item) => item.size === currentBreakpoint.size
642
+ );
643
+ return currentIndex >= sizeIndex;
644
+ },
645
+ [currentBreakpoint, breakpoints]
646
+ );
647
+ const down = (0, import_react3.useCallback)(
648
+ (size) => {
649
+ const sizeIndex = breakpoints.findIndex((item) => item.size === size);
650
+ if (sizeIndex === -1) {
651
+ return true;
652
+ }
653
+ const currentIndex = breakpoints.findIndex(
654
+ (item) => item.size === currentBreakpoint.size
655
+ );
656
+ return currentIndex <= sizeIndex;
657
+ },
658
+ [currentBreakpoint, breakpoints]
659
+ );
660
+ return {
661
+ breakpoint: currentBreakpoint,
662
+ up,
663
+ down
664
+ };
665
+ };
666
+
667
+ // src/hooks/useButton/useButton.tsx
668
+ var import_react4 = require("react");
669
+ function useButton({
670
+ elementType = "button",
671
+ type = "button",
672
+ isDisabled = false,
673
+ href,
674
+ target,
675
+ rel,
676
+ role,
677
+ name,
678
+ value,
679
+ onClick,
680
+ onPress
681
+ }) {
682
+ const realOnClick = (0, import_react4.useCallback)(
683
+ (event) => {
684
+ if (isDisabled) {
685
+ return;
686
+ }
687
+ onClick?.(event);
688
+ onPress?.(event);
689
+ },
690
+ [isDisabled, onClick, onPress]
691
+ );
692
+ function getRole() {
693
+ if (role) {
694
+ return role;
695
+ }
696
+ if (elementType === "a") {
697
+ return void 0;
698
+ }
699
+ return "button";
700
+ }
701
+ const extraProps = elementType === "button" ? { type } : {
702
+ role: getRole()
703
+ };
704
+ return {
705
+ buttonProps: {
706
+ href: elementType === "a" ? href : void 0,
707
+ target: elementType === "a" ? target : void 0,
708
+ rel: elementType === "a" ? rel : void 0,
709
+ tabIndex: isDisabled ? -1 : 0,
710
+ disabled: isDisabled || void 0,
711
+ "aria-disabled": isDisabled || void 0,
712
+ name: elementType === "input" || elementType === "button" ? name : void 0,
713
+ value: elementType === "input" || elementType === "button" ? value : void 0,
714
+ ...extraProps,
715
+ onClick: realOnClick
716
+ }
717
+ };
718
+ }
719
+
720
+ // src/hooks/useDialog/useDialog.ts
721
+ var import_react6 = require("react");
722
+ var import_mobius_hooks3 = require("@simplybusiness/mobius-hooks");
723
+
724
+ // src/hooks/useDialogPolyfill/useDialogPolyfill.ts
725
+ var import_react5 = require("react");
726
+ var useDialogPolyfill = () => {
727
+ const [hasDialogSupport, setHasDialogSupport] = (0, import_react5.useState)(false);
728
+ const hasAlreadyLoaded = (0, import_react5.useRef)(false);
729
+ (0, import_react5.useEffect)(() => {
730
+ setHasDialogSupport(supportsDialog());
731
+ }, []);
732
+ const polyfillDialog = async (ref) => {
733
+ if (!hasAlreadyLoaded.current && !hasDialogSupport && typeof window !== "undefined" && ref.current !== null) {
734
+ const { default: dialogPolyfill } = await import("dialog-polyfill");
735
+ hasAlreadyLoaded.current = true;
736
+ try {
737
+ if (ref.current) {
738
+ dialogPolyfill.registerDialog(ref.current);
739
+ }
740
+ } catch (error3) {
741
+ console.error("Failed to load dialog-polyfill", error3);
742
+ }
743
+ }
744
+ };
745
+ return {
746
+ polyfillDialog
747
+ };
748
+ };
749
+
750
+ // src/hooks/useDialog/useDialog.ts
751
+ var TRANSITION_CLASS_NAME = "--transition";
752
+ var FALLBACK_TRANSITION_DURATION = 0;
753
+ var useDialog = (props) => {
754
+ const { ref, isOpen, transition, onOpen, onClose } = props;
755
+ const [hasDialogSupport, setHasDialogSupport] = (0, import_react6.useState)(false);
756
+ const shouldTransition = hasDialogSupport && transition.isEnabled;
757
+ const { polyfillDialog } = useDialogPolyfill();
758
+ (0, import_react6.useEffect)(() => {
759
+ setHasDialogSupport(supportsDialog());
760
+ }, []);
761
+ const TRANSITION_DURATION_IN_MS = ref.current && Number(
762
+ getComputedStyle(ref.current).getPropertyValue(transition.CSSVariable).replace("ms", "")
763
+ ) || FALLBACK_TRANSITION_DURATION;
764
+ (0, import_mobius_hooks3.useBodyScrollLock)({ enabled: isOpen });
765
+ const open = (0, import_react6.useCallback)(() => {
766
+ ref.current?.showModal();
767
+ onOpen?.();
768
+ }, [onOpen, ref]);
769
+ const close = (0, import_react6.useCallback)(() => {
770
+ ref.current?.close();
771
+ onClose?.();
772
+ }, [onClose, ref]);
773
+ const handleClose = (0, import_react6.useCallback)(
774
+ (event) => {
775
+ if (event) {
776
+ event.preventDefault();
777
+ event.stopPropagation();
778
+ }
779
+ if (shouldTransition) {
780
+ ref.current?.classList.remove(TRANSITION_CLASS_NAME);
781
+ setTimeout(() => close(), TRANSITION_DURATION_IN_MS);
782
+ } else {
783
+ close();
784
+ }
785
+ },
786
+ [TRANSITION_DURATION_IN_MS, close, ref, shouldTransition]
787
+ );
788
+ (0, import_react6.useEffect)(() => {
789
+ async function toggleDialog() {
790
+ if (isOpen && !ref.current?.open) {
791
+ await polyfillDialog(ref);
792
+ open();
793
+ setTimeout(() => {
794
+ ref.current?.classList.add(TRANSITION_CLASS_NAME);
795
+ }, 0);
796
+ } else if (!isOpen && ref.current?.open) {
797
+ handleClose();
798
+ }
799
+ }
800
+ void toggleDialog();
801
+ }, [handleClose, isOpen, open, ref, polyfillDialog]);
802
+ return {
803
+ open,
804
+ close: handleClose
805
+ };
806
+ };
807
+
808
+ // src/hooks/useLabel/useLabel.tsx
809
+ var import_react7 = require("react");
810
+ function useLabel({
811
+ id: providedId,
812
+ label,
813
+ "aria-label": ariaLabel,
814
+ "aria-labelledby": ariaLabelledby,
815
+ labelElementType = "label"
816
+ }) {
817
+ let labelProps = {};
818
+ let fieldProps = {};
819
+ const hasWarnedAboutMissingLabels = (0, import_react7.useRef)(false);
820
+ const fallbackId = (0, import_react7.useId)();
821
+ const id = providedId || fallbackId;
822
+ const labelId = (0, import_react7.useId)();
823
+ if (label) {
824
+ ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
825
+ labelProps = {
826
+ id: labelId,
827
+ htmlFor: labelElementType === "label" ? id : void 0
828
+ };
829
+ } else if (!ariaLabelledby && !ariaLabel && !hasWarnedAboutMissingLabels.current) {
830
+ hasWarnedAboutMissingLabels.current = true;
831
+ console.warn(
832
+ "If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility"
833
+ );
834
+ }
835
+ fieldProps = {
836
+ id,
837
+ "aria-label": ariaLabel,
838
+ "aria-labelledby": ariaLabelledby
839
+ };
840
+ return {
841
+ labelProps,
842
+ fieldProps
843
+ };
844
+ }
845
+
846
+ // src/hooks/useTextField/useTextField.tsx
847
+ var import_react8 = require("react");
848
+ function useTextField(props) {
849
+ const {
850
+ isDisabled = false,
851
+ isReadOnly = false,
852
+ isRequired = false,
853
+ inputElementType = "input"
854
+ } = props;
855
+ const { labelProps, fieldProps } = useLabel(props);
856
+ const descriptionId = (0, import_react8.useId)();
857
+ const descriptionProps = { id: descriptionId };
858
+ const errorMessageId = (0, import_react8.useId)();
859
+ const errorMessageProps = { id: errorMessageId };
860
+ const ariaDescribedBy = spaceDelimitedList([
861
+ props.description && descriptionId,
862
+ props.errorMessage && errorMessageId,
863
+ props["aria-describedby"]
864
+ ]);
865
+ return {
866
+ descriptionProps,
867
+ errorMessageProps,
868
+ labelProps,
869
+ inputProps: {
870
+ defaultValue: props.defaultValue,
871
+ value: props.value,
872
+ onChange: props.onChange,
873
+ disabled: isDisabled,
874
+ readOnly: isReadOnly,
875
+ required: isRequired,
876
+ "aria-required": isRequired === true ? true : void 0,
877
+ "aria-invalid": props.isInvalid,
878
+ "aria-describedby": ariaDescribedBy,
879
+ "aria-errormessage": props["aria-errormessage"],
880
+ role: props.role,
881
+ type: inputElementType === "input" ? props.type : void 0,
882
+ pattern: inputElementType === "input" ? props.pattern : void 0,
883
+ autoComplete: props.autoComplete,
884
+ maxLength: props.maxLength,
885
+ minLength: props.minLength,
886
+ name: props.name,
887
+ placeholder: props.placeholder,
888
+ inputMode: props.inputMode,
889
+ // Clipboard events
890
+ onCopy: props.onCopy,
891
+ onCut: props.onCut,
892
+ onPaste: props.onPaste,
893
+ // Composition events
894
+ onCompositionEnd: props.onCompositionEnd,
895
+ onCompositionStart: props.onCompositionStart,
896
+ onCompositionUpdate: props.onCompositionUpdate,
897
+ // Selection events
898
+ onSelect: props.onSelect,
899
+ // Input events
900
+ onBeforeInput: props.onBeforeInput,
901
+ onInput: props.onInput,
902
+ // Focus events
903
+ onFocus: props.onFocus,
904
+ onBlur: props.onBlur,
905
+ ...fieldProps
906
+ }
907
+ };
908
+ }
909
+
910
+ // src/hooks/useValidationClasses/useValidationClasses.ts
911
+ var useValidationClasses = (props) => {
912
+ const { isInvalid } = props;
913
+ if (isInvalid) {
914
+ return "--is-invalid";
915
+ }
916
+ if (isInvalid === false) {
917
+ return "--is-valid";
918
+ }
919
+ return "";
920
+ };
921
+
922
+ // src/components/TextField/TextField.tsx
923
+ var import_dedupe11 = __toESM(require("classnames/dedupe"));
924
+
925
+ // src/components/ErrorMessage/ErrorMessage.tsx
926
+ var import_icons2 = require("@simplybusiness/icons");
927
+ var import_dedupe7 = __toESM(require("classnames/dedupe"));
928
+ var import_jsx_runtime7 = require("react/jsx-runtime");
929
+ var ErrorMessage = ({
930
+ id,
931
+ errorMessage,
932
+ className
933
+ }) => {
934
+ const classes = (0, import_dedupe7.default)("mobius", "mobius-error-message", className);
935
+ if (!errorMessage) return null;
936
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { id, className: classes, "data-testid": "ErrorMessage", role: "alert", children: [
937
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
938
+ Icon,
939
+ {
940
+ icon: import_icons2.error,
941
+ className: "mobius-error-message__icon",
942
+ "aria-hidden": "true"
943
+ }
944
+ ),
945
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
946
+ TextOrHTML,
947
+ {
948
+ elementType: "span",
949
+ className: "mobius-error-message__text",
950
+ text: errorMessage
951
+ }
952
+ )
953
+ ] });
954
+ };
955
+ ErrorMessage.displayName = "ErrorMessage";
956
+
957
+ // src/components/Label/Label.tsx
958
+ var import_dedupe8 = __toESM(require("classnames/dedupe"));
959
+ var import_jsx_runtime8 = require("react/jsx-runtime");
960
+ var Label = ({ ref, ...props }) => {
961
+ const { elementType: Element = "label", children, ...otherProps } = props;
962
+ const classes = (0, import_dedupe8.default)("mobius", "mobius-label", props.className);
963
+ otherProps.className = classes;
964
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Element, { ref, ...otherProps, className: classes, children });
965
+ };
966
+ Label.displayName = "Label";
967
+
968
+ // src/components/Stack/Stack.tsx
969
+ var import_dedupe9 = __toESM(require("classnames/dedupe"));
970
+ var import_jsx_runtime9 = require("react/jsx-runtime");
971
+ var Stack = ({ ref, ...props }) => {
972
+ const { elementType: Element = "div", gap, ...otherProps } = props;
973
+ const classes = (0, import_dedupe9.default)(
974
+ "mobius",
975
+ "mobius-stack",
976
+ {
977
+ [`--gap-${gap}`]: gap
978
+ },
979
+ otherProps.className
980
+ );
981
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Element, { ref, ...otherProps, className: classes });
982
+ };
983
+ Stack.displayName = "Stack";
984
+
985
+ // src/components/TextField/adornmentWithClassName.ts
986
+ var import_dedupe10 = __toESM(require("classnames/dedupe"));
987
+ var import_react9 = require("react");
988
+ var adornmentWithClassName = (component, validationClasses, className) => {
989
+ if (!component) return null;
990
+ return (0, import_react9.cloneElement)(component, {
991
+ className: (0, import_dedupe10.default)(
992
+ component.props.className,
993
+ validationClasses,
994
+ className
995
+ )
996
+ });
997
+ };
998
+
999
+ // src/components/TextField/TextField.tsx
1000
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1001
+ var TextField = ({ ref, ...props }) => {
1002
+ const {
1003
+ isDisabled,
1004
+ type = "text",
1005
+ isInvalid,
1006
+ className,
1007
+ label,
1008
+ errorMessage,
1009
+ children,
1010
+ isRequired,
1011
+ prefixInside,
1012
+ prefixOutside,
1013
+ suffixInside,
1014
+ suffixOutside,
1015
+ isReadOnly,
1016
+ ...otherProps
1017
+ } = props;
1018
+ const { inputProps, labelProps, errorMessageProps } = useTextField({
1019
+ ...props,
1020
+ "aria-errormessage": errorMessage
1021
+ });
1022
+ const hidden = type === "hidden";
1023
+ const validationClasses = useValidationClasses({ isInvalid });
1024
+ const textfieldClasses = {
1025
+ "--is-disabled": isDisabled,
1026
+ "--is-required": typeof isRequired === "boolean" && isRequired,
1027
+ "--is-optional": typeof isRequired === "boolean" && !isRequired,
1028
+ "--is-hidden": hidden,
1029
+ [className || ""]: true
1030
+ };
1031
+ const sharedClasses = (0, import_dedupe11.default)(validationClasses, textfieldClasses);
1032
+ const labelClasses = (0, import_dedupe11.default)(
1033
+ {
1034
+ "--is-disabled": isDisabled
1035
+ },
1036
+ validationClasses
1037
+ );
1038
+ const containerClasses = (0, import_dedupe11.default)(
1039
+ "mobius",
1040
+ "mobius-text-field",
1041
+ sharedClasses
1042
+ );
1043
+ const inputClasses = (0, import_dedupe11.default)(
1044
+ "mobius",
1045
+ "mobius-text-field__input",
1046
+ sharedClasses
1047
+ );
1048
+ const inputWrapperClasses = (0, import_dedupe11.default)(
1049
+ "mobius-text-field__input-wrapper",
1050
+ sharedClasses
1051
+ );
1052
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Stack, { gap: "xs", className: containerClasses, children: [
1053
+ label && !hidden && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Label, { ...labelProps, className: labelClasses, children: label }),
1054
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "mobius-text-field__inner-container", children: [
1055
+ adornmentWithClassName(
1056
+ prefixOutside,
1057
+ labelClasses,
1058
+ "mobius-text-field__prefix-outside"
1059
+ ),
1060
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: inputWrapperClasses, children: [
1061
+ adornmentWithClassName(
1062
+ prefixInside,
1063
+ labelClasses,
1064
+ "mobius-text-field__prefix-inside"
1065
+ ),
1066
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1067
+ "input",
1068
+ {
1069
+ ...otherProps,
1070
+ ...inputProps,
1071
+ ref,
1072
+ type,
1073
+ className: inputClasses
1074
+ }
1075
+ ),
1076
+ adornmentWithClassName(
1077
+ suffixInside,
1078
+ labelClasses,
1079
+ "mobius-text-field__suffix-inside"
1080
+ )
1081
+ ] }),
1082
+ adornmentWithClassName(
1083
+ suffixOutside,
1084
+ labelClasses,
1085
+ "mobius-text-field__suffix-outside"
1086
+ )
1087
+ ] }),
1088
+ children && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mobius-text-field__children", children }),
1089
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ErrorMessage, { ...errorMessageProps, errorMessage })
1090
+ ] });
1091
+ };
1092
+ TextField.displayName = "TextField";
1093
+
1094
+ // src/components/VisuallyHidden/VisuallyHidden.tsx
1095
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1096
+ function VisuallyHidden(props) {
1097
+ const {
1098
+ className,
1099
+ children,
1100
+ elementType: Component = "div",
1101
+ ...otherProps
1102
+ } = props;
1103
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1104
+ Component,
1105
+ {
1106
+ className,
1107
+ style: {
1108
+ border: 0,
1109
+ clip: "rect(0 0 0 0)",
1110
+ clipPath: "inset(50%)",
1111
+ height: "1px",
1112
+ margin: "-1px",
1113
+ overflow: "hidden",
1114
+ padding: 0,
1115
+ position: "absolute",
1116
+ width: "1px",
1117
+ whiteSpace: "nowrap"
1118
+ },
1119
+ ...otherProps,
1120
+ children
1121
+ }
1122
+ );
1123
+ }
1124
+
1125
+ // src/components/Combobox/Listbox.tsx
1126
+ var import_dedupe13 = __toESM(require("classnames/dedupe"));
1127
+
1128
+ // src/components/Combobox/Option.tsx
1129
+ var import_react10 = require("react");
1130
+ var import_dedupe12 = __toESM(require("classnames/dedupe"));
1131
+
1132
+ // src/components/Combobox/utils.tsx
1133
+ function isOptionGroup(options) {
1134
+ if (!options) return false;
1135
+ return typeof options[0] === "object" && "options" in options[0] && options[0].options !== void 0 && "heading" in options[0] && options[0].heading !== void 0;
1136
+ }
1137
+ var getOptionValue = (option) => typeof option === "string" ? option : option?.value;
1138
+ var getOptionLabel = (option) => typeof option === "string" ? option : option?.label;
1139
+ function filterOptions(options, inputValue) {
1140
+ if (isOptionGroup(options)) {
1141
+ return options.map((optionGroup) => ({
1142
+ ...optionGroup,
1143
+ options: optionGroup.options.filter(
1144
+ (option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
1145
+ )
1146
+ })).filter((optionGroup) => optionGroup.options.length > 0);
1147
+ }
1148
+ return options.filter(
1149
+ (option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
1150
+ );
1151
+ }
1152
+
1153
+ // src/components/Combobox/Option.tsx
1154
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1155
+ var Option = ({
1156
+ option,
1157
+ isHighlighted,
1158
+ onOptionSelect,
1159
+ optionComponent: OptionComponent,
1160
+ id
1161
+ }) => {
1162
+ const optionRef = (0, import_react10.useRef)(null);
1163
+ (0, import_react10.useEffect)(() => {
1164
+ if (isHighlighted && optionRef.current && optionRef.current.scrollIntoView) {
1165
+ optionRef.current.scrollIntoView({ block: "nearest" });
1166
+ }
1167
+ }, [isHighlighted]);
1168
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1169
+ "li",
1170
+ {
1171
+ ref: optionRef,
1172
+ role: "option",
1173
+ id,
1174
+ "aria-selected": isHighlighted,
1175
+ onMouseDown: () => onOptionSelect(option),
1176
+ className: (0, import_dedupe12.default)("mobius-combobox__option", "has-pii", {
1177
+ "mobius-combobox__option--is-highlighted": isHighlighted
1178
+ }),
1179
+ children: OptionComponent ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OptionComponent, { option, isHighlighted }) : getOptionLabel(option)
1180
+ },
1181
+ getOptionValue(option)
1182
+ );
1183
+ };
1184
+
1185
+ // src/components/Combobox/Listbox.tsx
1186
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1187
+ var getOptionKey = (option, index, groupIndex) => {
1188
+ let key;
1189
+ if (typeof option === "object" && option.id) key = option.id;
1190
+ else if (typeof option === "object") key = `${option.value}::${option.label}`;
1191
+ else if (typeof option === "string") key = option;
1192
+ else key = String(index);
1193
+ return groupIndex !== void 0 ? `${groupIndex}:${key}` : key;
1194
+ };
1195
+ var Listbox = ({
1196
+ id,
1197
+ isOpen = false,
1198
+ options,
1199
+ highlightedIndex,
1200
+ highlightedGroupIndex,
1201
+ onOptionSelect,
1202
+ optionComponent
1203
+ }) => {
1204
+ const classes = (0, import_dedupe13.default)("mobius-combobox__list", {
1205
+ "mobius-combobox__list--hidden": !isOpen
1206
+ });
1207
+ function getOptionId(option, groupIndex, index) {
1208
+ if (typeof option === "object" && "id" in option && typeof option.id === "string") {
1209
+ return option.id;
1210
+ }
1211
+ return isOptionGroup(options) ? `${id}-option-${groupIndex}-${index}` : `${id}-option-${index}`;
1212
+ }
1213
+ if (!isOpen) {
1214
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "listbox", id, className: classes });
1215
+ }
1216
+ if (options && options.length === 0) {
1217
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "listbox", id, className: classes, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mobius-combobox__no-options", children: "No options" }) });
1218
+ }
1219
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "listbox", id, className: classes, children: isOptionGroup(options) ? options.map((option, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1220
+ "ul",
1221
+ {
1222
+ role: "group",
1223
+ "aria-labelledby": `${id}-group-${groupIndex}`,
1224
+ className: "mobius-combobox__group",
1225
+ children: [
1226
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1227
+ "li",
1228
+ {
1229
+ role: "presentation",
1230
+ id: `${id}-group-${groupIndex}`,
1231
+ className: "mobius-combobox__group-label",
1232
+ children: option.heading
1233
+ }
1234
+ ),
1235
+ option.options.map((groupOption, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1236
+ Option,
1237
+ {
1238
+ option: groupOption,
1239
+ isHighlighted: highlightedIndex === index && highlightedGroupIndex === groupIndex,
1240
+ onOptionSelect,
1241
+ optionComponent,
1242
+ id: getOptionId(groupOption, groupIndex, index)
1243
+ },
1244
+ getOptionKey(groupOption, index, groupIndex)
1245
+ ))
1246
+ ]
1247
+ },
1248
+ option.heading
1249
+ )) : typeof options !== "undefined" ? options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1250
+ Option,
1251
+ {
1252
+ option,
1253
+ isHighlighted: highlightedIndex === index,
1254
+ onOptionSelect,
1255
+ optionComponent,
1256
+ id: getOptionId(option, 0, index)
1257
+ },
1258
+ getOptionKey(option, index)
1259
+ )) : null });
1260
+ };
1261
+
1262
+ // src/components/Combobox/useComboboxHighlight.tsx
1263
+ var import_react11 = require("react");
1264
+ function useComboboxHighlight(options) {
1265
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react11.useState)(
1266
+ options && options.length ? 0 : -1
1267
+ );
1268
+ const [highlightedGroupIndex, setHighlightedGroupIndex] = (0, import_react11.useState)(0);
1269
+ function highlightNextOption() {
1270
+ const isGroup = isOptionGroup(options);
1271
+ if (!options) {
1272
+ return;
1273
+ }
1274
+ if (isGroup) {
1275
+ const group = options[highlightedGroupIndex];
1276
+ if (highlightedIndex === group.options.length - 1) {
1277
+ if (highlightedGroupIndex === options.length - 1) {
1278
+ return;
1279
+ }
1280
+ setHighlightedIndex(0);
1281
+ setHighlightedGroupIndex(highlightedGroupIndex + 1);
1282
+ } else {
1283
+ setHighlightedIndex(highlightedIndex + 1);
1284
+ }
1285
+ } else {
1286
+ if (highlightedIndex === options.length - 1) {
1287
+ return;
1288
+ }
1289
+ setHighlightedIndex(highlightedIndex + 1);
1290
+ }
1291
+ }
1292
+ function highlightPreviousOption() {
1293
+ const isGroup = isOptionGroup(options);
1294
+ if (highlightedIndex === 0 && highlightedGroupIndex === 0) {
1295
+ return;
1296
+ }
1297
+ if (isGroup) {
1298
+ if (highlightedIndex === 0) {
1299
+ const prevGroupIndex = highlightedGroupIndex - 1;
1300
+ const prevGroup = options[prevGroupIndex];
1301
+ setHighlightedGroupIndex(prevGroupIndex);
1302
+ setHighlightedIndex(prevGroup.options.length - 1);
1303
+ } else {
1304
+ setHighlightedIndex(highlightedIndex - 1);
1305
+ }
1306
+ } else {
1307
+ setHighlightedIndex(highlightedIndex - 1);
1308
+ }
1309
+ }
1310
+ function highlightFirstOption() {
1311
+ setHighlightedIndex(0);
1312
+ setHighlightedGroupIndex(0);
1313
+ }
1314
+ function highlightLastOption() {
1315
+ const isGroup = isOptionGroup(options);
1316
+ if (!options) {
1317
+ return;
1318
+ }
1319
+ if (isGroup) {
1320
+ const lastGroupIndex = options.length - 1;
1321
+ const lastGroup = options[lastGroupIndex];
1322
+ setHighlightedGroupIndex(lastGroupIndex);
1323
+ setHighlightedIndex(lastGroup.options.length - 1);
1324
+ } else {
1325
+ setHighlightedIndex(options.length - 1);
1326
+ }
1327
+ }
1328
+ const clearHighlight = () => {
1329
+ setHighlightedIndex(
1330
+ typeof options === "undefined" || options.length ? 0 : -1
1331
+ );
1332
+ setHighlightedGroupIndex(0);
1333
+ };
1334
+ return {
1335
+ highlightedIndex,
1336
+ highlightedGroupIndex,
1337
+ highlightPreviousOption,
1338
+ highlightNextOption,
1339
+ highlightFirstOption,
1340
+ highlightLastOption,
1341
+ clearHighlight
1342
+ };
1343
+ }
1344
+
1345
+ // src/components/Combobox/useComboboxOptions.ts
1346
+ var import_react12 = require("react");
1347
+ var import_mobius_hooks4 = require("@simplybusiness/mobius-hooks");
1348
+ function useComboboxOptions({
1349
+ options,
1350
+ asyncOptions,
1351
+ delay = 300,
1352
+ minSearchLength = 3,
1353
+ inputValue = "",
1354
+ skipNextDebounceRef,
1355
+ onSearched
1356
+ }) {
1357
+ const [filteredOptions, setFilteredOptions] = (0, import_react12.useState)(void 0);
1358
+ const debouncedInputValue = (0, import_mobius_hooks4.useDebouncedValue)(
1359
+ inputValue,
1360
+ // Don't debounce synchronous options
1361
+ options ? 0 : delay
1362
+ );
1363
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
1364
+ const [error3, setError] = (0, import_react12.useState)(null);
1365
+ (0, import_react12.useEffect)(() => {
1366
+ const controller = new AbortController();
1367
+ const { signal } = controller;
1368
+ const fetchOptions = async () => {
1369
+ setIsLoading(true);
1370
+ setError(null);
1371
+ try {
1372
+ if (asyncOptions) {
1373
+ if (debouncedInputValue.length < minSearchLength) {
1374
+ setFilteredOptions(void 0);
1375
+ return;
1376
+ }
1377
+ const result = await asyncOptions(debouncedInputValue, { signal });
1378
+ setFilteredOptions(result);
1379
+ onSearched?.(debouncedInputValue);
1380
+ } else if (options) {
1381
+ setFilteredOptions(filterOptions(options, debouncedInputValue));
1382
+ } else {
1383
+ setError(new Error("No options provided"));
1384
+ }
1385
+ } catch (e) {
1386
+ if (e instanceof DOMException && e.name === "AbortError") {
1387
+ return;
1388
+ }
1389
+ setError(e);
1390
+ } finally {
1391
+ setIsLoading(false);
1392
+ }
1393
+ };
1394
+ if (!skipNextDebounceRef?.current) {
1395
+ void fetchOptions();
1396
+ } else {
1397
+ skipNextDebounceRef.current = false;
1398
+ }
1399
+ return () => {
1400
+ controller.abort();
1401
+ };
1402
+ }, [
1403
+ debouncedInputValue,
1404
+ options,
1405
+ asyncOptions,
1406
+ delay,
1407
+ minSearchLength,
1408
+ skipNextDebounceRef,
1409
+ onSearched
1410
+ ]);
1411
+ function updateFilteredOptions(newOptions) {
1412
+ setIsLoading(true);
1413
+ return newOptions.then(setFilteredOptions).catch(setError).finally(() => setIsLoading(false));
1414
+ }
1415
+ return {
1416
+ filteredOptions,
1417
+ updateFilteredOptions,
1418
+ isLoading,
1419
+ error: error3,
1420
+ isError: error3 != null
1421
+ };
1422
+ }
1423
+
1424
+ // src/components/Combobox/Combobox.tsx
1425
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1426
+ var ComboboxInner = ({
1427
+ ref,
1428
+ ...props
1429
+ }) => {
1430
+ const {
1431
+ id,
1432
+ defaultValue,
1433
+ value,
1434
+ options,
1435
+ asyncOptions,
1436
+ delay,
1437
+ minSearchLength,
1438
+ onSelected,
1439
+ className,
1440
+ placeholder,
1441
+ icon,
1442
+ onBlur,
1443
+ onFocus,
1444
+ onChange,
1445
+ // onSearched, // unused prop, consider removing
1446
+ optionComponent,
1447
+ errorMessage,
1448
+ ...otherProps
1449
+ } = props;
1450
+ const skipNextDebounceRef = (0, import_react13.useRef)(false);
1451
+ const fallbackRef = (0, import_react13.useRef)(null);
1452
+ const [inputValue, setInputValue] = (0, import_react13.useState)(defaultValue || "");
1453
+ const [isOpen, setIsOpen] = (0, import_react13.useState)(false);
1454
+ const [isChanging, setIsChanging] = (0, import_react13.useState)(false);
1455
+ const { filteredOptions, updateFilteredOptions, isLoading, error: error3 } = useComboboxOptions({
1456
+ options,
1457
+ asyncOptions,
1458
+ inputValue,
1459
+ delay,
1460
+ minSearchLength,
1461
+ skipNextDebounceRef
1462
+ });
1463
+ const {
1464
+ highlightedIndex,
1465
+ highlightedGroupIndex,
1466
+ highlightNextOption,
1467
+ highlightPreviousOption,
1468
+ highlightFirstOption,
1469
+ highlightLastOption,
1470
+ clearHighlight
1471
+ } = useComboboxHighlight(filteredOptions);
1472
+ const inputRef = ref || fallbackRef;
1473
+ const listboxId = (0, import_react13.useId)();
1474
+ const statusId = (0, import_react13.useId)();
1475
+ const blurTimeoutRef = (0, import_react13.useRef)(null);
1476
+ const userInteractedRef = (0, import_react13.useRef)(false);
1477
+ const justSelectedRef = (0, import_react13.useRef)(false);
1478
+ const { down } = useBreakpoint();
1479
+ const isMobile = down("md");
1480
+ const handleFocus = (e) => {
1481
+ onFocus?.(e);
1482
+ if (!filteredOptions || filteredOptions.length === 0) return;
1483
+ if (blurTimeoutRef.current) {
1484
+ clearTimeout(blurTimeoutRef.current);
1485
+ blurTimeoutRef.current = null;
1486
+ }
1487
+ const isNaturalFocus = userInteractedRef.current || e.relatedTarget !== null;
1488
+ if (userInteractedRef.current) {
1489
+ userInteractedRef.current = false;
1490
+ }
1491
+ if (justSelectedRef.current && !isNaturalFocus) {
1492
+ return;
1493
+ }
1494
+ if (isNaturalFocus) {
1495
+ setIsOpen(true);
1496
+ justSelectedRef.current = false;
1497
+ }
1498
+ };
1499
+ (0, import_react13.useEffect)(() => {
1500
+ if (!inputRef || typeof inputRef === "function") return;
1501
+ const inputElement = inputRef.current;
1502
+ if (!inputElement) return;
1503
+ const handleMouseDown = () => {
1504
+ userInteractedRef.current = true;
1505
+ };
1506
+ inputElement.addEventListener("mousedown", handleMouseDown);
1507
+ return () => {
1508
+ inputElement.removeEventListener("mousedown", handleMouseDown);
1509
+ };
1510
+ }, [inputRef]);
1511
+ (0, import_mobius_hooks5.useOnUnmount)(() => {
1512
+ if (blurTimeoutRef.current) {
1513
+ clearTimeout(blurTimeoutRef.current);
1514
+ }
1515
+ });
1516
+ const handleInputChange = (e) => {
1517
+ const newValue = e.target.value;
1518
+ setInputValue(newValue);
1519
+ justSelectedRef.current = false;
1520
+ setIsChanging(true);
1521
+ if (!asyncOptions) {
1522
+ setIsOpen(true);
1523
+ }
1524
+ clearHighlight();
1525
+ onChange?.(e);
1526
+ };
1527
+ const handleOptionSelect = (option) => {
1528
+ const val = getOptionValue(option);
1529
+ if (!val) return;
1530
+ if (typeof option === "object" && "callback" in option && option.callback && typeof option.callback === "function") {
1531
+ setTimeout(() => {
1532
+ if (inputRef && typeof inputRef !== "function" && inputRef.current) {
1533
+ inputRef.current.focus();
1534
+ }
1535
+ }, 0);
1536
+ updateFilteredOptions(option.callback());
1537
+ return;
1538
+ }
1539
+ skipNextDebounceRef.current = true;
1540
+ justSelectedRef.current = true;
1541
+ setIsChanging(false);
1542
+ setIsOpen(false);
1543
+ setInputValue(val);
1544
+ onSelected?.(option);
1545
+ };
1546
+ const getFirstOption = () => {
1547
+ if (!filteredOptions) return void 0;
1548
+ if (isOptionGroup(filteredOptions)) {
1549
+ return filteredOptions[0]?.options[0];
1550
+ }
1551
+ return filteredOptions[0];
1552
+ };
1553
+ const getHighlightedOption = () => {
1554
+ if (!filteredOptions) return void 0;
1555
+ if (highlightedIndex === -1) return void 0;
1556
+ if (isOptionGroup(filteredOptions)) {
1557
+ const group = filteredOptions[highlightedGroupIndex];
1558
+ return group?.options[highlightedIndex];
1559
+ }
1560
+ return filteredOptions[highlightedIndex];
1561
+ };
1562
+ const getHighlightedOptionId = () => {
1563
+ const option = getHighlightedOption();
1564
+ if (!option) return void 0;
1565
+ if (isOptionGroup(filteredOptions)) {
1566
+ return `${listboxId}-option-${highlightedGroupIndex}-${highlightedIndex}`;
1567
+ }
1568
+ return `${listboxId}-option-${highlightedIndex}`;
1569
+ };
1570
+ const handleBlur = (e) => {
1571
+ if (!justSelectedRef.current) {
1572
+ const typedText = inputValue.trim().toLowerCase();
1573
+ const highlightedOption = getHighlightedOption();
1574
+ const label = getOptionLabel(highlightedOption);
1575
+ if (typedText === label?.toLowerCase()) {
1576
+ setTimeout(() => {
1577
+ handleOptionSelect(highlightedOption);
1578
+ }, 0);
1579
+ }
1580
+ }
1581
+ blurTimeoutRef.current = setTimeout(() => {
1582
+ onBlur?.(e);
1583
+ setIsOpen(false);
1584
+ setIsChanging(false);
1585
+ }, 150);
1586
+ };
1587
+ const handleKeyDown = (e) => {
1588
+ switch (e.key) {
1589
+ case "ArrowDown":
1590
+ e.preventDefault();
1591
+ justSelectedRef.current = false;
1592
+ setIsOpen(true);
1593
+ highlightNextOption();
1594
+ break;
1595
+ case "ArrowUp":
1596
+ e.preventDefault();
1597
+ justSelectedRef.current = false;
1598
+ setIsOpen(true);
1599
+ highlightPreviousOption();
1600
+ break;
1601
+ case "Home":
1602
+ e.preventDefault();
1603
+ justSelectedRef.current = false;
1604
+ setIsOpen(true);
1605
+ highlightFirstOption();
1606
+ break;
1607
+ case "End":
1608
+ e.preventDefault();
1609
+ justSelectedRef.current = false;
1610
+ setIsOpen(true);
1611
+ highlightLastOption();
1612
+ break;
1613
+ case "Enter":
1614
+ e.preventDefault();
1615
+ if (isOpen) {
1616
+ const selectedOption = getHighlightedOption() || getFirstOption();
1617
+ if (selectedOption) {
1618
+ handleOptionSelect(selectedOption);
1619
+ }
1620
+ }
1621
+ break;
1622
+ case "Escape":
1623
+ e.preventDefault();
1624
+ setInputValue("");
1625
+ setIsOpen(false);
1626
+ clearHighlight();
1627
+ break;
1628
+ default:
1629
+ }
1630
+ };
1631
+ (0, import_react13.useEffect)(() => {
1632
+ if (value) {
1633
+ setInputValue(value);
1634
+ }
1635
+ }, [value]);
1636
+ (0, import_react13.useEffect)(() => {
1637
+ if (asyncOptions && isChanging) {
1638
+ setIsOpen(!!filteredOptions && filteredOptions.length > 0);
1639
+ }
1640
+ }, [filteredOptions, asyncOptions, isChanging]);
1641
+ const classes = (0, import_dedupe14.default)(
1642
+ "mobius mobius-combobox",
1643
+ {
1644
+ "mobius-combobox--is-expanded": isOpen,
1645
+ "mobius-combobox--is-loading": isLoading,
1646
+ "mobius-combobox--is-mobile": isMobile
1647
+ },
1648
+ className
1649
+ );
1650
+ const getStatusMessage = () => {
1651
+ if (isLoading) return "Loading options";
1652
+ if (!filteredOptions || filteredOptions.length === 0) {
1653
+ return isChanging ? "No options found" : "";
1654
+ }
1655
+ const count = isOptionGroup(filteredOptions) ? filteredOptions.reduce((sum, group) => sum + group.options.length, 0) : filteredOptions.length;
1656
+ return isOpen && isChanging ? `${count} option${count === 1 ? "" : "s"} available` : "";
1657
+ };
1658
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { id, "data-testid": "mobius-combobox__wrapper", className: classes, children: [
1659
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1660
+ VisuallyHidden,
1661
+ {
1662
+ role: "status",
1663
+ "aria-live": "polite",
1664
+ id: statusId,
1665
+ elementType: "div",
1666
+ className: "mobius-combobox__status",
1667
+ children: getStatusMessage()
1668
+ }
1669
+ ),
1670
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1671
+ TextField,
1672
+ {
1673
+ ...otherProps,
1674
+ className: "mobius-combobox__input",
1675
+ role: "combobox",
1676
+ value: inputValue,
1677
+ placeholder,
1678
+ onFocus: handleFocus,
1679
+ onBlur: handleBlur,
1680
+ onKeyDown: handleKeyDown,
1681
+ onChange: handleInputChange,
1682
+ autoComplete: "off",
1683
+ "aria-describedby": isLoading ? statusId : void 0,
1684
+ "aria-autocomplete": "list",
1685
+ "aria-haspopup": "listbox",
1686
+ "aria-owns": listboxId,
1687
+ "aria-controls": listboxId,
1688
+ "aria-expanded": isOpen,
1689
+ "aria-activedescendant": highlightedIndex === -1 ? void 0 : getHighlightedOptionId(),
1690
+ prefixInside: icon,
1691
+ ref: inputRef,
1692
+ errorMessage: errorMessage || error3?.message || void 0
1693
+ }
1694
+ ),
1695
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1696
+ Listbox,
1697
+ {
1698
+ id: listboxId,
1699
+ isOpen,
1700
+ isLoading,
1701
+ options: filteredOptions,
1702
+ highlightedIndex,
1703
+ highlightedGroupIndex,
1704
+ onOptionSelect: handleOptionSelect,
1705
+ optionComponent
1706
+ }
1707
+ )
1708
+ ] });
1709
+ };
1710
+ var Combobox = ComboboxInner;
1711
+
1712
+ // src/components/AddressLookup/utils.ts
1713
+ function isLoqateErrorResponse(response) {
1714
+ return Array.isArray(response) && response.some((item) => "Error" in item);
1715
+ }
1716
+
1717
+ // src/components/AddressLookup/AddressLookup.tsx
1718
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1719
+ function optionsFromResponse({ Items }, addressLookupService) {
1720
+ if (!Items || !Array.isArray(Items)) {
1721
+ throw Error("No address found");
1722
+ }
1723
+ if (isLoqateErrorResponse(Items)) {
1724
+ throw Error(Items[0].Description);
1725
+ }
1726
+ return Items.map((item) => ({
1727
+ id: item.Id,
1728
+ label: `${item.Text}, ${item.Description}`,
1729
+ value: item.Text,
1730
+ // Add a callback to trigger secondary search
1731
+ // if the address type is not "Address"
1732
+ callback: item.Type === "Address" ? void 0 : async () => {
1733
+ const result = await addressLookupService.findById(item.Id);
1734
+ return optionsFromResponse(result, addressLookupService);
1735
+ }
1736
+ }));
1737
+ }
1738
+ var AddressLookup = ({
1739
+ ref,
1740
+ addressLookupService,
1741
+ onAddressSelected,
1742
+ onOptionsDisplayed,
1743
+ onError,
1744
+ errorMessage,
1745
+ ...otherProps
1746
+ }) => {
1747
+ const [error3, _setError] = (0, import_react14.useState)(null);
1748
+ const setError = (0, import_react14.useCallback)(
1749
+ (newError) => {
1750
+ if (newError != null) onError?.(newError);
1751
+ _setError(newError);
1752
+ },
1753
+ [onError]
1754
+ );
1755
+ const asyncOptions = (0, import_react14.useCallback)(
1756
+ async (searchTerm) => {
1757
+ try {
1758
+ const response = await addressLookupService.search(searchTerm);
1759
+ setError(null);
1760
+ const options = optionsFromResponse(response, addressLookupService);
1761
+ onOptionsDisplayed?.();
1762
+ return options;
1763
+ } catch (e) {
1764
+ setError(e);
1765
+ return [];
1766
+ }
1767
+ },
1768
+ [addressLookupService, setError, onOptionsDisplayed]
1769
+ );
1770
+ const handleSelected = (selected) => {
1771
+ setError(null);
1772
+ if (typeof selected === "string" || !selected.id) {
1773
+ setError(new Error("Selected option missing id"));
1774
+ return Promise.resolve();
1775
+ }
1776
+ return addressLookupService.get(selected.id).then(onAddressSelected).catch(setError);
1777
+ };
1778
+ const realErrorMessage = error3 && "An error occurred" || errorMessage;
1779
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1780
+ Combobox,
1781
+ {
1782
+ ...otherProps,
1783
+ ref,
1784
+ onSelected: handleSelected,
1785
+ asyncOptions,
1786
+ errorMessage: realErrorMessage,
1787
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { icon: import_icons3.search })
1788
+ }
1789
+ );
1790
+ };
1791
+ AddressLookup.displayName = "AddressLookup";
1792
+
1793
+ // src/components/AddressLookup/LoqateAddressLookupError.tsx
1794
+ var LoqateAddressLookupError = class extends Error {
1795
+ constructor(response) {
1796
+ super(response.Description);
1797
+ this.name = "LoqateAddressLookupError";
1798
+ this.response = response;
1799
+ }
1800
+ };
1801
+
1802
+ // src/components/AddressLookup/LoqateAddressLookupService.tsx
1803
+ var LOQATE_BASE_URL = "https://api.addressy.com/Capture/Interactive";
1804
+ var LOQATE_FIND_URL = "/Find/v1.00/json3.ws";
1805
+ var LOQATE_RETRIEVE_URL = "/Retrieve/v1.2/json3.ws";
1806
+ var DEFAULT_COUNTRIES = ["GB"];
1807
+ var _baseUrl, _apiKey, _countries, _filters;
1808
+ var LoqateAddressLookupService = class {
1809
+ constructor({
1810
+ baseUrl,
1811
+ apiKey,
1812
+ countries,
1813
+ filters
1814
+ }) {
1815
+ /**
1816
+ * Base URL for the Loqate API
1817
+ */
1818
+ __privateAdd(this, _baseUrl);
1819
+ /**
1820
+ * API key for the Loqate API
1821
+ */
1822
+ __privateAdd(this, _apiKey);
1823
+ /**
1824
+ * List of allowed country codes for the Loqate API
1825
+ * 2 or 3 character ISO country codes
1826
+ */
1827
+ __privateAdd(this, _countries);
1828
+ /**
1829
+ * Optional filters for the Loqate API
1830
+ * E.g., { AdministrativeArea: "CA", PostalCode: "90210" }
1831
+ */
1832
+ __privateAdd(this, _filters);
1833
+ __privateSet(this, _apiKey, apiKey);
1834
+ __privateSet(this, _baseUrl, baseUrl || LOQATE_BASE_URL);
1835
+ __privateSet(this, _countries, countries || DEFAULT_COUNTRIES);
1836
+ __privateSet(this, _filters, filters);
1837
+ }
1838
+ fetchFromApi(url) {
1839
+ return fetch(`${__privateGet(this, _baseUrl)}${url}`).then((response) => response.json()).then((json) => {
1840
+ if (json.Items?.some((item) => item.Error)) {
1841
+ throw new LoqateAddressLookupError(json);
1842
+ }
1843
+ return json;
1844
+ });
1845
+ }
1846
+ /**
1847
+ * Builds the Filters query parameter for Loqate API requests.
1848
+ * - Filter keys (e.g., "AdministrativeArea", "PostalCode") are predefined by Loqate API (no need to encode)
1849
+ * - Filter values (e.g., "New York", "90210") contain user input that may have special characters (need encoding)
1850
+ *
1851
+ * @returns Empty string if no filters, otherwise "&Filters=key1:value1&key2:value2" (Loqate's expected format for Filters)
1852
+ */
1853
+ buildFiltersQuery() {
1854
+ if (!__privateGet(this, _filters) || Object.keys(__privateGet(this, _filters)).length === 0) {
1855
+ return "";
1856
+ }
1857
+ const encodedFilters = Object.entries(__privateGet(this, _filters)).map(([key, value]) => `${key}:${encodeURIComponent(value)}`).join("&");
1858
+ return `&Filters=${encodedFilters}`;
1859
+ }
1860
+ search(searchTerm) {
1861
+ let url = `${LOQATE_FIND_URL}?Key=${__privateGet(this, _apiKey)}&Text=${searchTerm}&Countries=${__privateGet(this, _countries)?.join(",")}`;
1862
+ url += this.buildFiltersQuery();
1863
+ return this.fetchFromApi(url);
1864
+ }
1865
+ findById(id) {
1866
+ let url = `${LOQATE_FIND_URL}?Key=${__privateGet(this, _apiKey)}&Container=${id}&Countries=${__privateGet(this, _countries)?.join(",")}`;
1867
+ url += this.buildFiltersQuery();
1868
+ return this.fetchFromApi(url);
1869
+ }
1870
+ async get(id) {
1871
+ const url = `${LOQATE_RETRIEVE_URL}?Key=${__privateGet(this, _apiKey)}&Id=${id}`;
1872
+ const response = await this.fetchFromApi(url);
1873
+ return response.Items[0];
1874
+ }
1875
+ };
1876
+ _baseUrl = new WeakMap();
1877
+ _apiKey = new WeakMap();
1878
+ _countries = new WeakMap();
1879
+ _filters = new WeakMap();
1880
+
1881
+ // src/components/Alert/Alert.tsx
1882
+ var import_icons4 = require("@simplybusiness/icons");
1883
+ var import_dedupe15 = __toESM(require("classnames/dedupe"));
1884
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1885
+ function isAlertVariant(value) {
1886
+ return value === "info" || value === "success" || value === "warning" || value === "error";
1887
+ }
1888
+ var Alert = ({ ref, ...props }) => {
1889
+ const {
1890
+ elementType: Element = "div",
1891
+ variant: variantProp,
1892
+ show = true,
1893
+ header,
1894
+ children,
1895
+ ...otherProps
1896
+ } = props;
1897
+ if (!show) return null;
1898
+ const variant = variantProp && isAlertVariant(variantProp) ? variantProp : "info";
1899
+ const colorValue = variant === "success" ? `var(--color-valid)` : `var(--color-${variant})`;
1900
+ const classes = (0, import_dedupe15.default)(
1901
+ "mobius",
1902
+ "mobius-alert",
1903
+ {
1904
+ "--info": variant === "info",
1905
+ "--success": variant === "success",
1906
+ "--warning": variant === "warning",
1907
+ "--error": variant === "error",
1908
+ "--has-header": header
1909
+ },
1910
+ otherProps.className
1911
+ );
1912
+ const icon = {
1913
+ info: import_icons4.circleInfo,
1914
+ success: import_icons4.circleTick,
1915
+ warning: import_icons4.warning,
1916
+ error: import_icons4.error
1917
+ };
1918
+ const headerClasses = (0, import_dedupe15.default)("mobius", "mobius-alert__header");
1919
+ const iconClasses = (0, import_dedupe15.default)("mobius", "mobius-alert__icon");
1920
+ const contentClasses = (0, import_dedupe15.default)("mobius", "mobius-alert__content");
1921
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Element, { ref, role: "alert", ...otherProps, className: classes, children: [
1922
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: iconClasses, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Icon, { icon: icon[variant], color: colorValue }) }),
1923
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
1924
+ header && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: headerClasses, children: header }),
1925
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: contentClasses, children })
1926
+ ] })
1927
+ ] });
1928
+ };
1929
+ Alert.displayName = "Alert";
1930
+
1931
+ // src/components/Box/Box.tsx
1932
+ var import_dedupe16 = __toESM(require("classnames/dedupe"));
1933
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1934
+ var Box = ({ ref, ...props }) => {
1935
+ const {
1936
+ elementType: Element = "div",
1937
+ padding,
1938
+ paddingX,
1939
+ paddingInline,
1940
+ paddingInlineStart,
1941
+ paddingInlineEnd,
1942
+ paddingY,
1943
+ paddingBlock,
1944
+ paddingBlockStart,
1945
+ paddingBlockEnd,
1946
+ paddingTop,
1947
+ paddingRight,
1948
+ paddingBottom,
1949
+ paddingLeft,
1950
+ minWidth,
1951
+ minHeight,
1952
+ maxWidth,
1953
+ maxHeight,
1954
+ width,
1955
+ height,
1956
+ style,
1957
+ ...otherProps
1958
+ } = props;
1959
+ const classes = (0, import_dedupe16.default)("mobius", "mobius-box", otherProps.className);
1960
+ const styleProps = filterUndefinedProps({
1961
+ padding: getSpacingValue(padding),
1962
+ paddingInline: getSpacingValue(paddingInline || paddingX),
1963
+ paddingBlock: getSpacingValue(paddingBlock || paddingY),
1964
+ paddingTop: getSpacingValue(paddingTop || paddingBlockStart),
1965
+ paddingRight: getSpacingValue(paddingRight || paddingInlineEnd),
1966
+ paddingBottom: getSpacingValue(paddingBottom || paddingBlockEnd),
1967
+ paddingLeft: getSpacingValue(paddingLeft || paddingInlineStart),
1968
+ minWidth,
1969
+ minHeight,
1970
+ maxWidth,
1971
+ maxHeight,
1972
+ width,
1973
+ height,
1974
+ ...style
1975
+ });
1976
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Element, { ref, style: styleProps, ...otherProps, className: classes });
1977
+ };
1978
+ Box.displayName = "Box";
1979
+
1980
+ // src/components/Breadcrumbs/Breadcrumbs.tsx
1981
+ var import_react15 = require("react");
1982
+ var import_dedupe17 = __toESM(require("classnames/dedupe"));
1983
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1984
+ var Breadcrumbs = ({ ref, ...props }) => {
1985
+ const { "aria-label": ariaLabel = "Breadcrumbs" } = props;
1986
+ const { navProps } = { navProps: { "aria-label": ariaLabel } };
1987
+ const { children, ...otherProps } = props;
1988
+ const childArray = import_react15.Children.toArray(children);
1989
+ const classes = (0, import_dedupe17.default)(
1990
+ "mobius",
1991
+ "mobius-breadcrumb",
1992
+ otherProps.className
1993
+ );
1994
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("nav", { ref, ...otherProps, ...navProps, className: classes, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { children: childArray.map(
1995
+ (child, i) => (0, import_react15.cloneElement)(
1996
+ child,
1997
+ {
1998
+ key: i,
1999
+ isCurrent: i === childArray.length - 1
2000
+ }
2001
+ )
2002
+ ) }) });
2003
+ };
2004
+ Breadcrumbs.displayName = "Breadcrumbs";
2005
+
2006
+ // src/components/Breadcrumbs/BreadcrumbItem.tsx
2007
+ var import_react16 = require("react");
2008
+ var import_dedupe18 = __toESM(require("classnames/dedupe"));
2009
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2010
+ var BreadcrumbItem = ({ ref, ...props }) => {
2011
+ const {
2012
+ isDisabled = false,
2013
+ isCurrent = false,
2014
+ "aria-current": ariaCurrent = "page",
2015
+ children,
2016
+ separator = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Box, { className: "mobius-breadcrumb__separator", "aria-hidden": "true", children: ">" }),
2017
+ ...otherProps
2018
+ } = props;
2019
+ const { itemProps } = {
2020
+ itemProps: {
2021
+ "aria-current": isCurrent ? ariaCurrent : void 0,
2022
+ "aria-disabled": isDisabled || isCurrent,
2023
+ ...otherProps
2024
+ }
2025
+ };
2026
+ const classes = (0, import_dedupe18.default)(
2027
+ "mobius",
2028
+ "mobius-breadcrumb__item",
2029
+ props.className
2030
+ );
2031
+ const child = typeof children === "string" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { ...itemProps, children }) : import_react16.Children.only(children);
2032
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { className: classes, children: [
2033
+ (0, import_react16.cloneElement)(child, {
2034
+ ...child.props,
2035
+ ...itemProps,
2036
+ ref
2037
+ }),
2038
+ !props.isCurrent && separator
2039
+ ] });
2040
+ };
2041
+ BreadcrumbItem.displayName = "BreadcrumbItem";
2042
+
2043
+ // src/components/Button/Button.tsx
2044
+ var import_dedupe19 = __toESM(require("classnames/dedupe"));
2045
+
2046
+ // src/components/Button/Loading.tsx
2047
+ var import_icons5 = require("@simplybusiness/icons");
2048
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2049
+ var Loading = (props) => {
2050
+ const { children } = props;
2051
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
2052
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mobius-button__icon-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Icon, { icon: import_icons5.loading, spin: true, size: "md" }) }),
2053
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VisuallyHidden, { className: "mobius-button__loading-text", children: "Loading" }),
2054
+ children
2055
+ ] });
2056
+ };
2057
+
2058
+ // src/components/Button/Success.tsx
2059
+ var import_icons6 = require("@simplybusiness/icons");
2060
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2061
+ var Success = () => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2062
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "mobius-button__icon-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Icon, { icon: import_icons6.tick, size: "md" }) }),
2063
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VisuallyHidden, { className: "mobius-button__success-text", children: "Success" })
2064
+ ] });
2065
+
2066
+ // src/components/Button/Button.tsx
2067
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2068
+ var Button = ({ ref, ...props }) => {
2069
+ const {
2070
+ children,
2071
+ elementType: Component = "button",
2072
+ isDisabled,
2073
+ isLoading,
2074
+ isSuccess,
2075
+ variant = "primary",
2076
+ size = "md",
2077
+ onPress,
2078
+ onClick,
2079
+ ...otherProps
2080
+ } = props;
2081
+ const { buttonProps } = useButton(props);
2082
+ otherProps.className = (0, import_dedupe19.default)(
2083
+ "mobius",
2084
+ "mobius-button",
2085
+ `--variant-${variant}`,
2086
+ `--size-${size}`,
2087
+ {
2088
+ "--is-disabled": isDisabled,
2089
+ "--is-loading": isLoading,
2090
+ "--is-success": isSuccess && !isLoading
2091
+ },
2092
+ otherProps.className
2093
+ );
2094
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Component, { ref, ...buttonProps, ...otherProps, children: [
2095
+ isLoading ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loading, { children }) : children,
2096
+ isSuccess && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Success, {})
2097
+ ] });
2098
+ };
2099
+ Button.displayName = "Button";
2100
+
2101
+ // src/components/Checkbox/Checkbox.tsx
2102
+ var import_react17 = require("react");
2103
+ var import_dedupe20 = __toESM(require("classnames/dedupe"));
2104
+ var import_icons7 = require("@simplybusiness/icons");
2105
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2106
+ var Checkbox = ({ ref, ...props }) => {
2107
+ const {
2108
+ id,
2109
+ label,
2110
+ isDisabled,
2111
+ isRequired,
2112
+ isInvalid,
2113
+ onChange,
2114
+ className,
2115
+ errorMessage,
2116
+ selected,
2117
+ defaultSelected = false,
2118
+ isReadOnly,
2119
+ isLastItem,
2120
+ name,
2121
+ value,
2122
+ ["aria-describedby"]: ariaDescribedBy,
2123
+ ...rest
2124
+ } = props;
2125
+ const [checked, setChecked] = (0, import_react17.useState)(defaultSelected);
2126
+ const fallbackRef = (0, import_react17.useRef)(null);
2127
+ const refObj = ref || fallbackRef;
2128
+ const inputId = (0, import_react17.useId)();
2129
+ const isControlled = typeof selected === "boolean";
2130
+ (0, import_react17.useEffect)(() => {
2131
+ if (isControlled) {
2132
+ setChecked(selected);
2133
+ }
2134
+ }, [selected, isControlled]);
2135
+ const validationClasses = useValidationClasses({ isInvalid });
2136
+ const sharedClasses = (0, import_dedupe20.default)(
2137
+ {
2138
+ "--is-disabled": isDisabled,
2139
+ "--is-selected": checked,
2140
+ "--is-required": typeof isRequired === "boolean" && isRequired,
2141
+ "--is-optional": typeof isRequired === "boolean" && !isRequired
2142
+ },
2143
+ validationClasses
2144
+ );
2145
+ const wrapperClasses = (0, import_dedupe20.default)(
2146
+ "mobius",
2147
+ "mobius-checkbox",
2148
+ sharedClasses,
2149
+ className
2150
+ );
2151
+ const labelClasses = (0, import_dedupe20.default)("mobius-checkbox__label", sharedClasses);
2152
+ const inputClasses = (0, import_dedupe20.default)("mobius-checkbox__input", sharedClasses);
2153
+ const iconClasses = (0, import_dedupe20.default)("mobius-checkbox__icon", sharedClasses);
2154
+ const errorMessageId = (0, import_react17.useId)();
2155
+ const shouldErrorMessageShow = errorMessage ? errorMessageId : void 0;
2156
+ const describedBy = spaceDelimitedList([
2157
+ shouldErrorMessageShow,
2158
+ ariaDescribedBy
2159
+ ]);
2160
+ const labelId = (0, import_react17.useId)();
2161
+ const handleChange = (event) => {
2162
+ setChecked(!checked);
2163
+ if (onChange) {
2164
+ onChange(event, isLastItem);
2165
+ }
2166
+ };
2167
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Stack, { gap: "xs", className: wrapperClasses, children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: labelClasses, children: [
2169
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2170
+ "input",
2171
+ {
2172
+ "aria-describedby": describedBy,
2173
+ "aria-errormessage": shouldErrorMessageShow,
2174
+ "aria-invalid": isInvalid,
2175
+ "aria-labelledby": labelId,
2176
+ readOnly: isReadOnly,
2177
+ disabled: isDisabled,
2178
+ ref: refObj,
2179
+ className: inputClasses,
2180
+ onChange: handleChange,
2181
+ type: "checkbox",
2182
+ checked,
2183
+ required: isRequired,
2184
+ id: id || inputId,
2185
+ name,
2186
+ value,
2187
+ ...rest
2188
+ }
2189
+ ),
2190
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2191
+ Icon,
2192
+ {
2193
+ icon: checked ? import_icons7.squareTick : import_icons7.square,
2194
+ size: "md",
2195
+ className: iconClasses
2196
+ }
2197
+ ),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { id: labelId, className: "mobius-checkbox__visible-label", children: label })
2199
+ ] }),
2200
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ErrorMessage, { id: errorMessageId, errorMessage })
2201
+ ] });
2202
+ };
2203
+ Checkbox.displayName = "Checkbox";
2204
+
2205
+ // src/components/Checkbox/CheckboxGroup.tsx
2206
+ var import_dedupe21 = __toESM(require("classnames/dedupe"));
2207
+ var import_react18 = require("react");
2208
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2209
+ var CheckboxGroup = ({ ref, ...props }) => {
2210
+ const {
2211
+ label,
2212
+ isDisabled = false,
2213
+ isRequired,
2214
+ isInvalid,
2215
+ orientation = "vertical",
2216
+ onChange,
2217
+ className,
2218
+ errorMessage,
2219
+ children,
2220
+ defaultValue = [],
2221
+ isReadOnly,
2222
+ itemsPerRow,
2223
+ lastItemDisables = false,
2224
+ ...rest
2225
+ } = props;
2226
+ const [selected, setSelected] = (0, import_react18.useState)(defaultValue);
2227
+ const isInitializedRef = (0, import_react18.useRef)(false);
2228
+ const prevDefaultValueRef = (0, import_react18.useRef)(defaultValue);
2229
+ (0, import_react18.useEffect)(() => {
2230
+ const hasChanged = defaultValue.length !== prevDefaultValueRef.current.length || defaultValue.some(
2231
+ (val, index) => val !== prevDefaultValueRef.current[index]
2232
+ );
2233
+ if (hasChanged || !isInitializedRef.current) {
2234
+ setSelected(defaultValue);
2235
+ prevDefaultValueRef.current = defaultValue;
2236
+ isInitializedRef.current = true;
2237
+ }
2238
+ }, [defaultValue]);
2239
+ const checkboxGroupClasses = (0, import_dedupe21.default)(
2240
+ "mobius",
2241
+ "mobius-checkbox-group",
2242
+ className,
2243
+ {
2244
+ "--is-horizontal": orientation === "horizontal",
2245
+ "--is-vertical": orientation === "vertical",
2246
+ "--is-required": typeof isRequired === "boolean" && isRequired,
2247
+ "--is-optional": typeof isRequired === "boolean" && !isRequired
2248
+ }
2249
+ );
2250
+ const validationClasses = useValidationClasses({ isInvalid });
2251
+ const labelClasses = (0, import_dedupe21.default)(
2252
+ {
2253
+ "--is-disabled": isDisabled
2254
+ },
2255
+ validationClasses
2256
+ );
2257
+ const errorMessageId = (0, import_react18.useId)();
2258
+ const shouldErrorMessageShow = errorMessage ? errorMessageId : void 0;
2259
+ const describedBy = spaceDelimitedList([
2260
+ shouldErrorMessageShow,
2261
+ props["aria-describedby"]
2262
+ ]);
2263
+ const labelId = (0, import_react18.useId)();
2264
+ const handleChange = (event, isLastItem = false) => {
2265
+ const {
2266
+ target: { value, checked }
2267
+ } = event;
2268
+ let newValue = [...selected];
2269
+ if (!checked) {
2270
+ newValue = selected.filter((item) => item !== value);
2271
+ }
2272
+ if (checked) {
2273
+ newValue = [...selected, value];
2274
+ }
2275
+ if (checked && lastItemDisables && isLastItem) {
2276
+ newValue = [value];
2277
+ }
2278
+ setSelected(newValue);
2279
+ onChange?.(newValue);
2280
+ };
2281
+ const childrenArray = import_react18.Children.toArray(children);
2282
+ const lastCheckbox = childrenArray.filter(
2283
+ (child) => (0, import_react18.isValidElement)(child) && child.type === Checkbox
2284
+ ).pop();
2285
+ const lastCheckboxIsChecked = lastCheckbox && selected.includes(lastCheckbox.props.value);
2286
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2287
+ "div",
2288
+ {
2289
+ ...rest,
2290
+ "aria-labelledby": props["aria-labelledby"] || labelId,
2291
+ ref,
2292
+ className: checkboxGroupClasses,
2293
+ role: "group",
2294
+ style: {
2295
+ "--checkbox-items-per-row": itemsPerRow || import_react18.Children.count(children)
2296
+ },
2297
+ children: [
2298
+ label && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Label, { elementType: "span", id: labelId, className: labelClasses, children: label }),
2299
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "mobius-checkbox-group__wrapper", children: childrenArray.map((child) => {
2300
+ if ((0, import_react18.isValidElement)(child)) {
2301
+ const isLastItem = child === lastCheckbox;
2302
+ const isChildDisabled = isDisabled || lastItemDisables && lastCheckboxIsChecked && !isLastItem;
2303
+ const childProps = child.props;
2304
+ return (0, import_react18.cloneElement)(
2305
+ child,
2306
+ {
2307
+ isDisabled: isChildDisabled,
2308
+ isRequired,
2309
+ isReadOnly,
2310
+ isInvalid,
2311
+ isLastItem,
2312
+ selected: selected.includes(childProps.value),
2313
+ onChange: childProps.onChange || handleChange,
2314
+ "aria-describedby": describedBy
2315
+ }
2316
+ );
2317
+ }
2318
+ return child;
2319
+ }) }),
2320
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ErrorMessage, { id: errorMessageId, errorMessage })
2321
+ ]
2322
+ }
2323
+ );
2324
+ };
2325
+ CheckboxGroup.displayName = "CheckboxGroup";
2326
+
2327
+ // src/components/Container/Container.tsx
2328
+ var import_dedupe22 = __toESM(require("classnames/dedupe"));
2329
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2330
+ var Container = ({ ref, ...props }) => {
2331
+ const { elementType: Element = "div", size = "md", ...otherProps } = props;
2332
+ const classes = (0, import_dedupe22.default)(
2333
+ "mobius",
2334
+ "mobius-container",
2335
+ sizeClasses(size),
2336
+ otherProps.className
2337
+ );
2338
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Element, { ref, ...otherProps, className: classes });
2339
+ };
2340
+ Container.displayName = "Container";
2341
+
2342
+ // src/components/DateField/DateField.tsx
2343
+ var import_dedupe23 = __toESM(require("classnames/dedupe"));
2344
+ var import_react19 = require("react");
2345
+
2346
+ // src/components/DateField/validation.ts
2347
+ var convertToDateFormat = (date, format) => {
2348
+ const dateParts = date.split(/[-/]/);
2349
+ const formatParts = format ? format.split(/[-/]/) : ["yyyy", "mm", "dd"];
2350
+ const dateObj = {};
2351
+ const formattedDate = [];
2352
+ for (let i = 0; i < formatParts.length; i++) {
2353
+ dateObj[formatParts[i]] = dateParts[i] ? parseInt(dateParts[i], 10) : 0;
2354
+ }
2355
+ formattedDate.push(dateObj["yyyy"]?.toString() || "0000");
2356
+ formattedDate.push(
2357
+ (dateObj["mm"] < 10 ? "0" : "") + (dateObj["mm"]?.toString() || "00")
2358
+ );
2359
+ formattedDate.push(
2360
+ (dateObj["dd"] < 10 ? "0" : "") + (dateObj["dd"]?.toString() || "00")
2361
+ );
2362
+ return formattedDate.join("-");
2363
+ };
2364
+ var isValidDate = (date, format = "yyyy-mm-dd") => {
2365
+ if (!date) return true;
2366
+ const standardDate = convertToDateFormat(date, format);
2367
+ const [yearStr, monthStr, dayStr] = standardDate.split("-");
2368
+ const year = parseInt(yearStr, 10);
2369
+ const month = parseInt(monthStr, 10);
2370
+ const day = parseInt(dayStr, 10);
2371
+ if (month < 1 || month > 12) {
2372
+ return false;
2373
+ }
2374
+ const daysInMonth = new Date(year, month, 0).getDate();
2375
+ return day > 0 && day <= daysInMonth;
2376
+ };
2377
+
2378
+ // src/components/DateField/DateField.tsx
2379
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2380
+ var MIN_MAX_ERROR = '"min" value should not be greater than "max" value.';
2381
+ var DateField = ({ ref, ...props }) => {
2382
+ const {
2383
+ min,
2384
+ max,
2385
+ format,
2386
+ className,
2387
+ errorMessage,
2388
+ defaultValue,
2389
+ value,
2390
+ ...otherProps
2391
+ } = props;
2392
+ const [error3, setError] = (0, import_react19.useState)(errorMessage);
2393
+ const [isInvalid, setIsInvalid] = (0, import_react19.useState)(void 0);
2394
+ const localRef = (0, import_react19.useRef)(null);
2395
+ const classes = (0, import_dedupe23.default)("mobius-date-field", className);
2396
+ const formattedMin = min ? convertToDateFormat(min, format) : void 0;
2397
+ const formattedMax = max ? convertToDateFormat(max, format) : void 0;
2398
+ const formattedDefaultValue = defaultValue ? convertToDateFormat(defaultValue, format) : void 0;
2399
+ const formattedValue = value ? convertToDateFormat(value, format) : void 0;
2400
+ const setInvalidState = (error4) => {
2401
+ setError(error4);
2402
+ setIsInvalid(true);
2403
+ };
2404
+ const setValidState = () => {
2405
+ setError(props.errorMessage);
2406
+ setIsInvalid(false);
2407
+ };
2408
+ (0, import_react19.useEffect)(() => {
2409
+ if (!isValidDate(min, format)) {
2410
+ setInvalidState(`Invalid min date: ${min}`);
2411
+ return;
2412
+ }
2413
+ if (!isValidDate(max, format)) {
2414
+ setInvalidState(`Invalid max date: ${max}`);
2415
+ return;
2416
+ }
2417
+ if (min && max) {
2418
+ const minDate = new Date(min);
2419
+ const maxDate = new Date(max);
2420
+ if (minDate > maxDate) {
2421
+ setInvalidState(MIN_MAX_ERROR);
2422
+ } else {
2423
+ setValidState();
2424
+ }
2425
+ } else {
2426
+ setValidState();
2427
+ }
2428
+ }, [min, max, format]);
2429
+ const validate = () => {
2430
+ const isValidInput = localRef.current?.checkValidity();
2431
+ if (!isValidInput) {
2432
+ setInvalidState("Invalid date input");
2433
+ } else {
2434
+ setValidState();
2435
+ }
2436
+ };
2437
+ const handleBlur = (event) => {
2438
+ validate();
2439
+ otherProps.onBlur?.(event);
2440
+ };
2441
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2442
+ TextField,
2443
+ {
2444
+ ref: mergeRefs([localRef, ref]),
2445
+ className: classes,
2446
+ type: "date",
2447
+ min: formattedMin,
2448
+ max: formattedMax,
2449
+ errorMessage: errorMessage ?? error3,
2450
+ isInvalid,
2451
+ defaultValue: formattedDefaultValue,
2452
+ value: formattedValue,
2453
+ onBlur: handleBlur,
2454
+ ...otherProps
2455
+ }
2456
+ );
2457
+ };
2458
+ DateField.displayName = "DateField";
2459
+
2460
+ // src/components/Drawer/Content.tsx
2461
+ var import_jsx_runtime27 = require("react/jsx-runtime");
2462
+ var Content = ({ ref, children, ...otherProps }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref, ...otherProps, className: "mobius-drawer__content", children });
2463
+ Content.displayName = "Content";
2464
+
2465
+ // src/components/Drawer/Drawer.tsx
2466
+ var import_dedupe24 = __toESM(require("classnames/dedupe"));
2467
+ var import_react21 = require("react");
2468
+
2469
+ // src/components/Drawer/DrawerContext.tsx
2470
+ var import_react20 = require("react");
2471
+ var DrawerContext = (0, import_react20.createContext)({
2472
+ onClose: () => {
2473
+ },
2474
+ closeLabel: void 0,
2475
+ headerId: void 0
2476
+ });
2477
+
2478
+ // src/components/Drawer/Drawer.tsx
2479
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2480
+ var TRANSITION_CSS_VARIABLE = "--drawer-transition-duration";
2481
+ var Drawer = ({ ref, ...props }) => {
2482
+ const {
2483
+ isOpen,
2484
+ className,
2485
+ closeLabel,
2486
+ direction,
2487
+ announce = "Drawer opened on screen",
2488
+ onOpen,
2489
+ onClose,
2490
+ children
2491
+ } = props;
2492
+ const dialogRef = (0, import_react21.useRef)(null);
2493
+ const [shouldTransition, setShouldTransition] = (0, import_react21.useState)(false);
2494
+ const { close } = useDialog({
2495
+ ref: dialogRef,
2496
+ isOpen,
2497
+ onOpen,
2498
+ onClose,
2499
+ transition: {
2500
+ isEnabled: true,
2501
+ CSSVariable: TRANSITION_CSS_VARIABLE
2502
+ }
2503
+ });
2504
+ const hiddenId = `dialog-screen-reader-announce-${(0, import_react21.useId)()}`;
2505
+ const headerId = `dialog-header-${(0, import_react21.useId)()}`;
2506
+ const dialogClasses = (0, import_dedupe24.default)(
2507
+ "mobius",
2508
+ "mobius-drawer",
2509
+ `--${direction}`,
2510
+ className,
2511
+ {
2512
+ "--should-transition": shouldTransition
2513
+ }
2514
+ );
2515
+ (0, import_react21.useEffect)(() => {
2516
+ setShouldTransition(supportsDialog());
2517
+ }, []);
2518
+ const contextValue = (0, import_react21.useMemo)(
2519
+ () => ({
2520
+ onClose: close,
2521
+ closeLabel,
2522
+ headerId
2523
+ }),
2524
+ [close, closeLabel, headerId]
2525
+ );
2526
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2527
+ "dialog",
2528
+ {
2529
+ id: (0, import_react21.useId)(),
2530
+ ref: mergeRefs([dialogRef, ref]),
2531
+ onCancel: close,
2532
+ className: dialogClasses,
2533
+ "aria-describedby": hiddenId,
2534
+ "aria-labelledby": headerId,
2535
+ children: [
2536
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { id: hiddenId, children: announce }) }),
2537
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DrawerContext.Provider, { value: contextValue, children })
2538
+ ]
2539
+ }
2540
+ );
2541
+ };
2542
+ Drawer.displayName = "Drawer";
2543
+
2544
+ // src/components/Drawer/useDrawer.ts
2545
+ var import_react22 = require("react");
2546
+ var useDrawer = () => {
2547
+ const { onClose, closeLabel, headerId } = (0, import_react22.useContext)(DrawerContext);
2548
+ return { onClose, closeLabel, headerId };
2549
+ };
2550
+
2551
+ // src/components/Drawer/Header.tsx
2552
+ var import_icons8 = require("@simplybusiness/icons");
2553
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2554
+ var Header = ({ ref, children, ...otherProps }) => {
2555
+ const { onClose, closeLabel, headerId } = useDrawer();
2556
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("header", { ref, ...otherProps, className: "mobius-drawer__header", children: [
2557
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h2", { id: headerId, children }),
2558
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2559
+ Button,
2560
+ {
2561
+ "aria-label": "Close",
2562
+ variant: "basic",
2563
+ onPress: onClose,
2564
+ className: "mobius-drawer__close",
2565
+ size: "sm",
2566
+ children: [
2567
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Icon, { icon: import_icons8.cross }),
2568
+ " ",
2569
+ closeLabel
2570
+ ]
2571
+ }
2572
+ )
2573
+ ] });
2574
+ };
2575
+ Header.displayName = "Header";
2576
+
2577
+ // src/components/Drawer/index.tsx
2578
+ var Drawer2 = Object.assign(Drawer, {
2579
+ Header,
2580
+ Content
2581
+ });
2582
+ Drawer2.displayName = "Drawer";
2583
+
2584
+ // src/components/DropdownMenu/DropdownMenu.tsx
2585
+ var import_react23 = require("react");
2586
+ var import_react_accessible_dropdown_menu_hook = __toESM(require("react-accessible-dropdown-menu-hook"));
2587
+ var import_dedupe25 = __toESM(require("classnames/dedupe"));
2588
+ var import_jsx_runtime30 = require("react/jsx-runtime");
2589
+ var DropdownMenu = ({ ref, ...props }) => {
2590
+ const {
2591
+ elementType: Element = "nav",
2592
+ trigger,
2593
+ label = "Menu",
2594
+ children,
2595
+ ...otherProps
2596
+ } = props;
2597
+ const [activeId, setActiveId] = (0, import_react23.useState)(null);
2598
+ const numberOfItems = import_react23.Children.count(children);
2599
+ const {
2600
+ buttonProps,
2601
+ itemProps,
2602
+ isOpen: open,
2603
+ setIsOpen
2604
+ } = (0, import_react_accessible_dropdown_menu_hook.default)(numberOfItems);
2605
+ const classes = (0, import_dedupe25.default)(
2606
+ "mobius",
2607
+ "mobius-dropdown-menu",
2608
+ otherProps.className
2609
+ );
2610
+ const triggerClasses = (0, import_dedupe25.default)("mobius", "mobius-dropdown-menu__trigger");
2611
+ const listClasses = (0, import_dedupe25.default)("mobius", "mobius-dropdown-menu__list", {
2612
+ "--is-open": open
2613
+ });
2614
+ const handleChildClick = ({ onClick }, index) => {
2615
+ setActiveId(index);
2616
+ setIsOpen(false);
2617
+ if (onClick) {
2618
+ onClick();
2619
+ }
2620
+ };
2621
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Element, { ref, ...otherProps, className: classes, children: [
2622
+ trigger ? (0, import_react23.cloneElement)(trigger, {
2623
+ className: triggerClasses,
2624
+ open,
2625
+ label,
2626
+ ...buttonProps
2627
+ }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { className: triggerClasses, ...buttonProps, children: label }),
2628
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("ul", { className: listClasses, role: "menu", children: import_react23.Children.map(children, (child, index) => {
2629
+ if ((0, import_react23.isValidElement)(child)) {
2630
+ return (0, import_react23.cloneElement)(child, {
2631
+ onClick: () => handleChildClick(child.props, index),
2632
+ active: index === activeId,
2633
+ ...itemProps[index]
2634
+ });
2635
+ }
2636
+ return child;
2637
+ }) })
2638
+ ] });
2639
+ };
2640
+ DropdownMenu.displayName = "DropdownMenu";
2641
+
2642
+ // src/components/DropdownMenu/Item.tsx
2643
+ var import_react24 = require("react");
2644
+ var import_dedupe26 = __toESM(require("classnames/dedupe"));
2645
+ var import_jsx_runtime31 = require("react/jsx-runtime");
2646
+ var Item = ({ ref, ...props }) => {
2647
+ const {
2648
+ elementType: Element = "li",
2649
+ active,
2650
+ onClick,
2651
+ children,
2652
+ ...otherProps
2653
+ } = props;
2654
+ const classes = (0, import_dedupe26.default)(
2655
+ "mobius",
2656
+ "mobius-dropdown-menu__item",
2657
+ { "--is-active": active },
2658
+ otherProps.className
2659
+ );
2660
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Element, { ref, onClick, ...otherProps, children: import_react24.Children.map(children, (child) => {
2661
+ if ((0, import_react24.isValidElement)(child)) {
2662
+ const childClasses = (0, import_dedupe26.default)(
2663
+ child.props.className,
2664
+ classes
2665
+ );
2666
+ return (0, import_react24.cloneElement)(
2667
+ child,
2668
+ {
2669
+ className: childClasses
2670
+ }
2671
+ );
2672
+ }
2673
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: classes, children: child });
2674
+ }) });
2675
+ };
2676
+ Item.displayName = "DropdownMenu.Item";
2677
+
2678
+ // src/components/DropdownMenu/index.tsx
2679
+ var DropdownMenu2 = Object.assign(
2680
+ DropdownMenu,
2681
+ {
2682
+ Item
2683
+ }
2684
+ );
2685
+ DropdownMenu2.displayName = "DropdownMenu";
2686
+
2687
+ // src/components/Fieldset/Fieldset.tsx
2688
+ var import_dedupe27 = __toESM(require("classnames/dedupe"));
2689
+ var import_react25 = require("react");
2690
+ var import_jsx_runtime32 = require("react/jsx-runtime");
2691
+ var useFieldset = (props) => {
2692
+ const { legend } = props;
2693
+ let legendProps = {};
2694
+ let containerProps = {
2695
+ role: "group"
2696
+ };
2697
+ const legendId = (0, import_react25.useId)();
2698
+ if (legend) {
2699
+ legendProps = {
2700
+ ...legendProps,
2701
+ id: legendId
2702
+ };
2703
+ containerProps = {
2704
+ ...containerProps,
2705
+ "aria-labelledby": legendId
2706
+ };
2707
+ }
2708
+ return {
2709
+ legendProps,
2710
+ containerProps
2711
+ };
2712
+ };
2713
+ var Fieldset = ({ ref: _ref, ...props }) => {
2714
+ const {
2715
+ children,
2716
+ legend,
2717
+ legendComponent = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("legend", {}),
2718
+ ...otherProps
2719
+ } = props;
2720
+ const { legendProps, containerProps } = useFieldset(props);
2721
+ const classes = (0, import_dedupe27.default)("mobius", "mobius-fieldset", props.className);
2722
+ legendProps.className = "mobius-fieldset__legend";
2723
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Flex, { ...containerProps, ...otherProps, className: classes, children: [
2724
+ legend && (0, import_react25.cloneElement)(legendComponent, { ...legendProps }, [legend]),
2725
+ children
2726
+ ] });
2727
+ };
2728
+ Fieldset.displayName = "Fieldset";
2729
+
2730
+ // src/components/Grid/Grid.tsx
2731
+ var import_dedupe28 = __toESM(require("classnames/dedupe"));
2732
+ var import_jsx_runtime33 = require("react/jsx-runtime");
2733
+ var Grid = ({ ref: _ref, ...props }) => {
2734
+ const {
2735
+ columns = 12,
2736
+ gap,
2737
+ columnGap,
2738
+ rowGap,
2739
+ alignContent,
2740
+ alignItems,
2741
+ justifyContent,
2742
+ justifyItems,
2743
+ className,
2744
+ style,
2745
+ ...rest
2746
+ } = props;
2747
+ const classes = (0, import_dedupe28.default)("mobius", "mobius-grid", className);
2748
+ const styles = filterUndefinedProps({
2749
+ boxSizing: "border-box",
2750
+ display: "grid",
2751
+ gridTemplateColumns: `repeat(${columns}, 1fr)`,
2752
+ gap: getSpacingValue(gap),
2753
+ columnGap: getSpacingValue(columnGap),
2754
+ rowGap: getSpacingValue(rowGap),
2755
+ alignContent,
2756
+ alignItems,
2757
+ justifyContent,
2758
+ justifyItems,
2759
+ ...style
2760
+ });
2761
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { style: styles, className: classes, ...rest });
2762
+ };
2763
+ Grid.displayName = "Grid";
2764
+
2765
+ // src/components/Grid/Item.tsx
2766
+ var import_react26 = require("react");
2767
+ var import_dedupe29 = __toESM(require("classnames/dedupe"));
2768
+ var import_jsx_runtime34 = require("react/jsx-runtime");
2769
+ var getBreakpointMap = (config) => Object.entries(config).reduce(
2770
+ (prev, [key, value]) => {
2771
+ const previous = Object.values(prev);
2772
+ const lastDefined = previous[previous.length - 1];
2773
+ return { ...prev, [key]: value || lastDefined };
2774
+ },
2775
+ {}
2776
+ );
2777
+ var DEFAULT_SPAN = 12;
2778
+ var GridItem = ({ ref: _ref, ...props }) => {
2779
+ const {
2780
+ breakpoint: { size: breakpointSize }
2781
+ } = useBreakpoint();
2782
+ const {
2783
+ span,
2784
+ xs = Array.isArray(span) ? DEFAULT_SPAN : span,
2785
+ sm,
2786
+ md,
2787
+ lg,
2788
+ xl,
2789
+ xxl,
2790
+ alignSelf,
2791
+ justifySelf,
2792
+ className,
2793
+ ...rest
2794
+ } = props;
2795
+ const breakpointMap = getBreakpointMap({
2796
+ xs,
2797
+ sm,
2798
+ md,
2799
+ lg,
2800
+ xl,
2801
+ xxl
2802
+ });
2803
+ const [responsiveSpan, setResponsiveSpan] = (0, import_react26.useState)();
2804
+ const classes = (0, import_dedupe29.default)("mobius-grid__item", className);
2805
+ (0, import_react26.useEffect)(() => {
2806
+ setResponsiveSpan(breakpointMap[breakpointSize]);
2807
+ }, [breakpointSize, breakpointMap]);
2808
+ const styles = {
2809
+ gridColumn: responsiveSpan ? `span ${responsiveSpan}` : void 0,
2810
+ alignSelf,
2811
+ justifySelf
2812
+ };
2813
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { style: { ...styles }, className: classes, ...rest });
2814
+ };
2815
+ GridItem.displayName = "GridItem";
2816
+
2817
+ // src/components/Grid/index.tsx
2818
+ var Grid2 = Object.assign(Grid, {
2819
+ Item: GridItem
2820
+ });
2821
+ Grid2.displayName = "Grid";
2822
+
2823
+ // src/components/Image/Image.tsx
2824
+ var import_dedupe30 = __toESM(require("classnames/dedupe"));
2825
+ var import_jsx_runtime35 = require("react/jsx-runtime");
2826
+ var Image = ({
2827
+ ref,
2828
+ alt,
2829
+ elementType: Component = "img",
2830
+ ...otherProps
2831
+ }) => {
2832
+ const classes = (0, import_dedupe30.default)("mobius", "mobius-image", otherProps.className);
2833
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Component, { alt, ref, ...otherProps, className: classes });
2834
+ };
2835
+ Image.displayName = "Image";
2836
+
2837
+ // src/components/Link/Link.tsx
2838
+ var import_dedupe31 = __toESM(require("classnames/dedupe"));
2839
+ var import_jsx_runtime36 = require("react/jsx-runtime");
2840
+ var Link = ({ ref, ...props }) => {
2841
+ const {
2842
+ isDisabled = false,
2843
+ elementType: Component = "a",
2844
+ style,
2845
+ className,
2846
+ variant = "primary",
2847
+ ...otherProps
2848
+ } = props;
2849
+ const disabledStyles = {
2850
+ pointerEvents: "none"
2851
+ };
2852
+ const styles = { ...style, ...isDisabled && disabledStyles };
2853
+ const classes = (0, import_dedupe31.default)(
2854
+ "mobius",
2855
+ "mobius-link",
2856
+ className,
2857
+ `mobius-link--${variant}`,
2858
+ {
2859
+ "--is-disabled": isDisabled
2860
+ }
2861
+ );
2862
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2863
+ Component,
2864
+ {
2865
+ ref,
2866
+ style: styles,
2867
+ className: classes,
2868
+ "aria-disabled": isDisabled ? true : void 0,
2869
+ ...otherProps,
2870
+ children: props.children
2871
+ }
2872
+ );
2873
+ };
2874
+ Link.displayName = "Link";
2875
+
2876
+ // src/components/LinkButton/LinkButton.tsx
2877
+ var import_dedupe32 = __toESM(require("classnames/dedupe"));
2878
+ var import_jsx_runtime37 = require("react/jsx-runtime");
2879
+ function LinkButton({
2880
+ href,
2881
+ children,
2882
+ className,
2883
+ elementType = "a",
2884
+ ...rest
2885
+ }) {
2886
+ if (!href) {
2887
+ throw new Error("LinkButton requires a href prop");
2888
+ }
2889
+ const classes = (0, import_dedupe32.default)("mobius", "mobius-link-button", className);
2890
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Button, { elementType, href, className: classes, ...rest, children });
2891
+ }
2892
+
2893
+ // src/components/List/List.tsx
2894
+ var import_react27 = require("react");
2895
+ var import_dedupe33 = __toESM(require("classnames/dedupe"));
2896
+ var import_jsx_runtime38 = require("react/jsx-runtime");
2897
+ var List = ({ ref, ...props }) => {
2898
+ const Component = props.isOrdered ? "ol" : "ul";
2899
+ const { children, icon, ...otherProps } = props;
2900
+ const { isOrdered, liststyletype, isReversed, ...restProps } = otherProps;
2901
+ const mappedProps = {
2902
+ ...restProps,
2903
+ reversed: isReversed
2904
+ };
2905
+ const classes = (0, import_dedupe33.default)(
2906
+ "mobius",
2907
+ "mobius-list",
2908
+ {
2909
+ "--has-icon": icon,
2910
+ [`--is-${liststyletype}`]: liststyletype
2911
+ },
2912
+ otherProps.className
2913
+ );
2914
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Component, { ref, ...mappedProps, className: classes, children: import_react27.Children.map(children, (child) => {
2915
+ if ((0, import_react27.isValidElement)(child)) {
2916
+ return (0, import_react27.cloneElement)(child, {
2917
+ parentIcon: icon
2918
+ });
2919
+ }
2920
+ return child;
2921
+ }) });
2922
+ };
2923
+ List.displayName = "List";
2924
+
2925
+ // src/components/List/ListItem.tsx
2926
+ var import_dedupe34 = __toESM(require("classnames/dedupe"));
2927
+ var import_jsx_runtime39 = require("react/jsx-runtime");
2928
+ var ListItem = ({ ref, ...props }) => {
2929
+ const { parentIcon, icon, children, ...otherProps } = props;
2930
+ const iconContent = icon || parentIcon;
2931
+ const classes = (0, import_dedupe34.default)(
2932
+ "mobius",
2933
+ "mobius-list__item",
2934
+ {
2935
+ "--has-icon": iconContent
2936
+ },
2937
+ props.className
2938
+ );
2939
+ const contentClasses = (0, import_dedupe34.default)("mobius", "mobius-list__item-content");
2940
+ const iconClasses = (0, import_dedupe34.default)("mobius", "mobius-list__icon");
2941
+ if (iconContent) {
2942
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("li", { ref, ...otherProps, className: classes, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { className: contentClasses, children: [
2943
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: iconClasses, children: iconContent }),
2944
+ children
2945
+ ] }) });
2946
+ }
2947
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("li", { ref, ...otherProps, className: classes, children });
2948
+ };
2949
+ ListItem.displayName = "ListItem";
2950
+
2951
+ // src/components/LoadingIndicator/LoadingIndicator.tsx
2952
+ var import_dedupe35 = __toESM(require("classnames/dedupe"));
2953
+ var import_icons9 = require("@simplybusiness/icons");
2954
+ var import_jsx_runtime40 = require("react/jsx-runtime");
2955
+ var LoadingIndicator = ({ ref, ...props }) => {
2956
+ const { icon = import_icons9.loading, ...otherProps } = props;
2957
+ const classes = (0, import_dedupe35.default)(
2958
+ "mobius",
2959
+ "mobius-loading-indicator",
2960
+ otherProps.className
2961
+ );
2962
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Icon, { icon, spin: true, ref, ...otherProps, className: classes });
2963
+ };
2964
+ LoadingIndicator.displayName = "LoadingIndicator";
2965
+
2966
+ // src/components/Logo/Logo.tsx
2967
+ var import_dedupe36 = __toESM(require("classnames/dedupe"));
2968
+ var import_jsx_runtime41 = require("react/jsx-runtime");
2969
+ var Logo = ({ ref, ...props }) => {
2970
+ const { className, width, height, ...otherProps } = props;
2971
+ const classes = (0, import_dedupe36.default)("mobius", "mobius-logo", className);
2972
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
2973
+ "svg",
2974
+ {
2975
+ width,
2976
+ height,
2977
+ ref,
2978
+ className: classes,
2979
+ viewBox: "0 0 144 37",
2980
+ ...otherProps,
2981
+ children: [
2982
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
2983
+ "linearGradient",
2984
+ {
2985
+ id: "logo-gradient",
2986
+ x1: "83.508%",
2987
+ x2: "11.891%",
2988
+ y1: "76.042%",
2989
+ y2: "26.973%",
2990
+ children: [
2991
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("stop", { stopColor: "#4632D8", offset: "0%" }),
2992
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("stop", { stopColor: "#9084E8", offset: "100%" })
2993
+ ]
2994
+ }
2995
+ ) }),
2996
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("g", { children: [
2997
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
2998
+ "path",
2999
+ {
3000
+ fill: "#0E0A2B",
3001
+ d: "M68.788 11.307c0-2.486-2.027-3.345-3.833-4.1-1.332-.562-2.471-1.036-2.471-2.072 0-.873.77-1.42 1.968-1.42 1.051 0 1.806.444 2.294.725.193.103.474.222.755.133.192-.06.34-.207.459-.444l.34-.621c.266-.474.163-.888-.281-1.2-.533-.384-1.88-1.05-3.537-1.05-2.738 0-4.647 1.643-4.647 4.01 0 2.413 2.012 3.301 3.788 4.07 1.347.593 2.516 1.096 2.516 2.161 0 .873-.754 1.45-1.924 1.45-1.287 0-2.22-.65-2.678-.961l-.03-.015c-.533-.296-.903-.237-1.228.192l-.415.607c-.444.607-.148.992.134 1.228.828.637 2.427 1.392 4.203 1.392 2.708 0 4.587-1.673 4.587-4.085zm4.44 2.975V6.186c0-.577-.31-.888-.873-.888h-.843c-.563 0-.874.311-.874.888v8.096c0 .577.296.888.874.888h.843c.563 0 .873-.311.873-.888zM71.482 4.203h.755c.518 0 .814-.281.814-.8v-.517c0-.518-.296-.814-.814-.814h-.755c-.518 0-.8.281-.8.814v.518c.016.518.297.8.8.8zM92.645 24.48h.755c.518 0 .814-.282.814-.8v-.518c0-.518-.296-.814-.814-.814h-.755c-.518 0-.799.282-.799.814v.518c0 .518.281.8.8.8zm-6.26-19.42c-1.539 0-2.397.962-2.945 1.895-.444-1.243-1.435-1.895-2.871-1.895-1.362 0-2.146.888-2.723 1.806v-.68c0-.578-.311-.889-.873-.889h-.74c-.563 0-.873.311-.873.888v8.096c0 .577.295.888.873.888h.843c.577 0 .873-.311.873-.888V10.73c0-2.25.888-3.271 2.058-3.271 1.006 0 1.198.71 1.198 1.85v4.987c0 .578.311.888.888.888h.844c.577 0 .873-.31.873-.888v-3.551c0-2.25.873-3.271 2.013-3.271 1.036 0 1.243.74 1.243 1.85v4.987c0 .577.31.888.888.888h.814c.577 0 .888-.31.888-.888V8.835c0-2.5-1.095-3.774-3.27-3.774zm10.804 10.33c2.679 0 4.558-2.13 4.558-5.164 0-3.094-1.776-5.166-4.425-5.166-1.761 0-2.708 1.036-3.049 1.51v-.533c0-.459-.34-.755-.873-.755h-.607c-.562 0-.888.326-.888.888v11.9c0 .576.311.887.888.887h.814c.578 0 .888-.31.888-.888v-3.404c0-.207-.014-.4-.014-.532.325.429 1.184 1.258 2.708 1.258zm-2.768-5.105c0-1.362.622-2.975 2.368-2.975 1.377 0 2.309 1.184 2.309 2.945 0 1.746-.947 2.916-2.338 2.916-1.54 0-2.339-1.45-2.339-2.886zm12.965 4.07v-.652c0-.444-.252-.725-.681-.784-.34-.03-.68-.192-.68-1.066v-9.47c0-.563-.326-.888-.874-.888h-.843c-.563 0-.874.31-.874.888v9.679c0 1.258.34 2.16 1.021 2.678.637.489 1.466.533 2.013.533.607 0 .918-.325.918-.917zm9.457-9.073h-.962c-.518 0-.844.237-.977.726l-1.717 4.972c-.089.311-.192.71-.251.977-.074-.281-.193-.71-.296-1.021l-1.835-4.943c-.163-.489-.489-.71-.977-.71h-1.036c-.415 0-.622.162-.71.295-.09.134-.163.385.014.755l3.685 8.57-.34.813c-.252.592-.77 1.229-1.45 1.229-.267 0-.474-.09-.652-.163h-.014c-.43-.104-.755.074-.962.488l-.163.415c-.119.251-.148.517-.06.725.075.192.237.34.474.429.326.118.814.296 1.391.296 1.628 0 2.975-.977 3.597-2.605l3.996-10.226c.103-.296.088-.563-.045-.755-.163-.163-.4-.267-.71-.267zM67.634 28.297c.977-.592 1.54-1.658 1.54-2.886 0-2.176-1.688-3.567-4.293-3.567h-4.04c-.562 0-.873.311-.873.888v11.899c0 .577.296.888.873.888h4.1c1.346 0 2.5-.34 3.33-.962.932-.71 1.42-1.761 1.42-3.049.03-1.524-.784-2.767-2.057-3.211zm-5.017-.962v-3.212h2.25c1.02 0 1.628.592 1.628 1.584 0 .991-.607 1.643-1.57 1.643h-2.308v-.015zm4.396 4.01c0 1.155-.71 1.865-1.865 1.865h-2.53v-3.714h2.53c1.14.014 1.865.74 1.865 1.85zm12.638-5.712h-.814c-.577 0-.888.31-.888.888v3.655c0 2.176-1.361 3.182-2.634 3.182-1.006 0-1.406-.547-1.406-1.88v-4.942c0-.578-.31-.888-.888-.888h-.814c-.562 0-.888.325-.888.888v5.431c0 2.516 1.17 3.774 3.463 3.774a3.937 3.937 0 003.286-1.761v.651c0 .577.296.888.873.888h.74c.577 0 .888-.31.888-.888v-8.095c-.03-.578-.355-.903-.918-.903zm6.956 3.937c-.917-.311-1.702-.592-1.702-1.184 0-.74.77-.859 1.229-.859.784 0 1.406.281 1.805.474.548.237.947.118 1.184-.34l.193-.341c.251-.518.133-.947-.326-1.184-.326-.178-1.288-.71-2.753-.71-2.279 0-3.803 1.213-3.803 3.004 0 2.042 1.731 2.65 3.137 3.138.903.325 1.687.592 1.687 1.169 0 .547-.488.902-1.258.902-.917 0-1.613-.37-2.057-.621l-.059-.03c-.533-.28-.903-.207-1.213.222l-.222.34c-.178.252-.237.504-.178.726.044.207.192.37.4.488a5.774 5.774 0 003.285 1.007c2.235 0 3.789-1.273 3.789-3.079-.03-2.042-1.761-2.649-3.138-3.122zm6.897-3.937h-.844c-.562 0-.873.31-.873.888v8.095c0 .577.296.888.873.888h.844c.577 0 .873-.31.873-.888v-8.095c0-.563-.31-.888-.873-.888zm9.324-.237c-1.924 0-2.93 1.154-3.36 1.806v-.681c0-.577-.31-.888-.873-.888h-.74c-.563 0-.873.31-.873.888v8.095c0 .577.296.888.873.888h.843c.578 0 .874-.31.874-.888v-3.744c0-1.79 1.14-3.078 2.708-3.078 1.021 0 1.436.547 1.436 1.88v4.942c0 .577.31.888.887.888h.814c.578 0 .888-.31.888-.888v-5.431c0-2.516-1.169-3.789-3.477-3.789zm10.448 0c-2.96 0-5.032 2.131-5.032 5.165 0 2.99 2.235 5.165 5.313 5.165 1.48 0 2.635-.533 3.345-.977.444-.266.562-.695.296-1.198l-.222-.385c-.266-.459-.651-.563-1.184-.31h-.015a3.885 3.885 0 01-2.042.606c-1.54 0-2.634-.962-2.812-2.472h5.816a.935.935 0 00.933-.917c.014-2.827-1.717-4.677-4.396-4.677zm-.044 2.013c1.065 0 1.79.77 1.864 1.968h-4.1c.253-1.213 1.096-1.968 2.236-1.968zm10.152 2.16c-.917-.31-1.702-.591-1.702-1.183 0-.74.77-.859 1.229-.859.784 0 1.406.281 1.805.474.548.237.947.118 1.184-.34l.192-.341c.252-.518.134-.947-.325-1.184-.326-.178-1.288-.71-2.753-.71-2.279 0-3.803 1.213-3.803 3.004 0 2.042 1.731 2.65 3.137 3.138.903.325 1.687.592 1.687 1.169 0 .547-.488.902-1.258.902-.917 0-1.613-.37-2.057-.621l-.059-.03c-.533-.28-.903-.207-1.214.222l-.222.34c-.177.252-.236.504-.177.726.044.207.192.37.4.488a5.774 5.774 0 003.285 1.007c2.235 0 3.789-1.273 3.789-3.079-.015-2.042-1.747-2.649-3.138-3.122zm8.791 0c-.917-.31-1.702-.591-1.702-1.183 0-.74.77-.859 1.229-.859.784 0 1.406.281 1.805.474.548.237.947.118 1.184-.34l.192-.341c.252-.518.134-.947-.325-1.184-.326-.178-1.288-.71-2.753-.71-2.279 0-3.803 1.213-3.803 3.004 0 2.042 1.731 2.65 3.137 3.138.903.325 1.687.592 1.687 1.169 0 .547-.488.902-1.258.902-.917 0-1.613-.37-2.057-.621l-.059-.03c-.533-.28-.903-.207-1.214.222l-.222.34c-.177.252-.236.504-.177.726.044.207.192.37.4.488a5.774 5.774 0 003.285 1.007c2.235 0 3.789-1.273 3.789-3.079-.015-2.042-1.747-2.649-3.138-3.122z"
3002
+ }
3003
+ ),
3004
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3005
+ "path",
3006
+ {
3007
+ fill: "url(#logo-gradient)",
3008
+ d: "M22.747 22.288c.607 1.214.918 2.59.918 4.144 0 1.45-.267 2.827-.8 4.1a10.018 10.018 0 01-2.279 3.36c-.991.961-2.235 1.73-3.744 2.278-1.51.563-3.167.829-4.988.829-2.264 0-4.35-.385-6.29-1.14-1.938-.77-3.492-1.598-4.676-2.5-.31-.252-.548-.504-.696-.77a1.332 1.332 0 01-.177-.71.718.718 0 010-.252c.03-.37.207-.785.547-1.199l1.14-1.598c.4-.548.829-.844 1.288-.918a.896.896 0 01.222-.03c.4 0 .873.163 1.39.474 2.487 1.776 4.914 2.679 7.252 2.679 1.643 0 2.96-.385 3.922-1.14.962-.755 1.45-1.746 1.45-2.96 0-.725-.192-1.39-.562-1.983a5.347 5.347 0 00-1.539-1.569 18.207 18.207 0 00-2.235-1.287 56.102 56.102 0 00-2.649-1.214c-.917-.4-1.835-.814-2.752-1.258a19.282 19.282 0 01-2.62-1.539 14.014 14.014 0 01-2.22-1.924c-.666-.695-1.169-1.539-1.554-2.545-.37-.992-.562-2.087-.562-3.271 0-2.042.533-3.863 1.598-5.446 1.066-1.584 2.516-2.797 4.336-3.641C8.303.414 10.345 0 12.624 0c1.91 0 3.685.281 5.358.844 1.657.562 2.96 1.198 3.892 1.88.68.473 1.006 1.035 1.006 1.671 0 .385-.118.785-.37 1.2l-.917 1.657c-.385.74-.903 1.11-1.554 1.11-.4 0-.83-.133-1.318-.4a42.421 42.421 0 00-1.687-.947c-.473-.237-1.14-.488-1.998-.71a9.458 9.458 0 00-2.56-.356c-1.672 0-3.004.37-3.981 1.11-.992.74-1.48 1.717-1.48 2.946 0 .902.31 1.701.932 2.412.622.695 1.421 1.302 2.398 1.79.977.489 2.057.977 3.256 1.466a54.048 54.048 0 013.552 1.628 20.795 20.795 0 013.24 2.042c.948.755 1.732 1.732 2.354 2.945zm31.257 2.945c0 3.197-1.155 6.083-3.256 8.14-2.265 2.205-5.506 3.36-9.368 3.36H30.71c-2.443 0-4.278-1.836-4.278-4.278V4.53c0-1.2.43-2.28 1.214-3.064C28.43.681 29.51.252 30.709.252h9.013c3.419 0 6.32 1.095 8.377 3.182 1.909 1.923 2.945 4.558 2.945 7.429 0 2.294-.622 4.203-1.91 5.816 1.377.77 2.487 1.776 3.286 2.99 1.066 1.583 1.584 3.448 1.584 5.564zm-12.106-7.68c.044-.03 4.913-3.02 4.913-6.675 0-1.761-.607-3.345-1.717-4.455-1.568-1.584-3.788-1.924-5.372-1.924H30.68v28h10.7c2.738 0 4.958-.754 6.408-2.16 1.273-1.243 1.983-3.049 1.983-5.106 0-1.272-.296-2.353-.858-3.196v-.03c-1.362-2.353-6.838-3.774-6.897-3.789l-.844-.222.726-.444z"
3009
+ }
3010
+ ),
3011
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3012
+ "path",
3013
+ {
3014
+ fill: "#0E0A2B",
3015
+ d: "M138.199 25.455c0-.4.074-.784.222-1.14.148-.354.355-.665.606-.932.267-.266.563-.473.903-.621.34-.148.725-.222 1.11-.222.4 0 .784.074 1.125.222.355.148.666.355.917.621.267.267.474.578.622.933.148.355.222.74.222 1.14 0 .399-.074.784-.222 1.139a2.86 2.86 0 01-.622.932 3.087 3.087 0 01-.917.637 2.646 2.646 0 01-1.125.236c-.4 0-.77-.074-1.11-.236a2.777 2.777 0 01-.903-.637 2.821 2.821 0 01-.606-.932 2.898 2.898 0 01-.222-1.14zm.71 0c0 .326.06.622.163.903.103.281.266.518.459.725a2.051 2.051 0 001.524.666c.31 0 .592-.059.858-.177a2.175 2.175 0 001.155-1.214c.118-.281.162-.577.162-.903 0-.325-.059-.621-.162-.902a2.422 2.422 0 00-.46-.726 2.112 2.112 0 00-.695-.488 2.073 2.073 0 00-.858-.178c-.31 0-.592.06-.844.178a2.051 2.051 0 00-.68.488 2.45 2.45 0 00-.46.726 2.636 2.636 0 00-.162.902zm1.154-1.14c0-.221.119-.34.34-.34h.889c.296 0 .532.09.695.252.178.163.267.4.267.68a.623.623 0 01-.06.297.557.557 0 01-.133.222.512.512 0 01-.163.148c-.059.044-.118.059-.162.074v.014l.03.03c.014.015.014.03.029.06l.044.088.34.666c.06.118.075.207.045.281-.03.074-.104.104-.207.104h-.104c-.192 0-.31-.089-.385-.252l-.384-.829h-.4v.74c0 .222-.104.34-.31.34h-.06c-.207 0-.31-.118-.31-.34v-2.234zm1.051 1.037c.133 0 .252-.045.31-.119.075-.074.104-.192.104-.325s-.03-.252-.103-.326a.413.413 0 00-.296-.118h-.385v.873h.37v.015z"
3016
+ }
3017
+ )
3018
+ ] })
3019
+ ]
3020
+ }
3021
+ );
3022
+ };
3023
+ Logo.displayName = "Logo";
3024
+
3025
+ // src/components/Modal/Content.tsx
3026
+ var import_jsx_runtime42 = require("react/jsx-runtime");
3027
+ var Content2 = ({ ref, children, ...otherProps }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ref, ...otherProps, className: "mobius-modal__content", children });
3028
+ Content2.displayName = "Content";
3029
+
3030
+ // src/components/Modal/Header.tsx
3031
+ var import_icons10 = require("@simplybusiness/icons");
3032
+
3033
+ // src/components/Modal/useModal.ts
3034
+ var import_react29 = require("react");
3035
+
3036
+ // src/components/Modal/ModalContext.tsx
3037
+ var import_react28 = require("react");
3038
+ var ModalContext = (0, import_react28.createContext)({
3039
+ onClose: () => {
3040
+ },
3041
+ closeLabel: void 0
3042
+ });
3043
+
3044
+ // src/components/Modal/useModal.ts
3045
+ var useModal = () => {
3046
+ const { onClose, closeLabel } = (0, import_react29.useContext)(ModalContext);
3047
+ return { onClose, closeLabel };
3048
+ };
3049
+
3050
+ // src/components/Modal/Header.tsx
3051
+ var import_jsx_runtime43 = require("react/jsx-runtime");
3052
+ var Header2 = ({ ref, children, ...otherProps }) => {
3053
+ const { onClose, closeLabel } = useModal();
3054
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("header", { ref, ...otherProps, className: "mobius-modal__header", children: [
3055
+ children,
3056
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
3057
+ Button,
3058
+ {
3059
+ "aria-label": "Close",
3060
+ variant: "basic",
3061
+ onPress: onClose,
3062
+ className: "mobius-modal__close",
3063
+ children: [
3064
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon: import_icons10.cross }),
3065
+ " ",
3066
+ closeLabel
3067
+ ]
3068
+ }
3069
+ )
3070
+ ] });
3071
+ };
3072
+ Header2.displayName = "Header";
3073
+
3074
+ // src/components/Modal/Modal.tsx
3075
+ var import_dedupe37 = __toESM(require("classnames/dedupe"));
3076
+ var import_react30 = require("react");
3077
+ var import_jsx_runtime44 = require("react/jsx-runtime");
3078
+ var TRANSITION_CSS_VARIABLE2 = "--modal-transition-duration";
3079
+ var Modal = ({ ref, ...props }) => {
3080
+ const {
3081
+ isOpen,
3082
+ onClose,
3083
+ onOpen,
3084
+ children,
3085
+ className,
3086
+ closeLabel,
3087
+ isFullScreen,
3088
+ animation,
3089
+ ...rest
3090
+ } = props;
3091
+ const [shouldTransition, setShouldTransition] = (0, import_react30.useState)(false);
3092
+ (0, import_react30.useEffect)(() => {
3093
+ setShouldTransition(supportsDialog());
3094
+ }, []);
3095
+ const dialogRef = (0, import_react30.useRef)(null);
3096
+ const { close } = useDialog({
3097
+ ref: dialogRef,
3098
+ isOpen,
3099
+ onOpen,
3100
+ onClose,
3101
+ transition: {
3102
+ isEnabled: !!animation,
3103
+ CSSVariable: TRANSITION_CSS_VARIABLE2
3104
+ }
3105
+ });
3106
+ const modalClasses = (0, import_dedupe37.default)(
3107
+ "mobius",
3108
+ "mobius-modal",
3109
+ {
3110
+ "--no-dialog-support": !shouldTransition,
3111
+ // This class is used to correctly position modal in x/y middle on iOS <= 15.2
3112
+ "--should-transition": shouldTransition && animation,
3113
+ "--slide-up": animation === "slideUp",
3114
+ "--fade": animation === "fade",
3115
+ "--is-fullscreen": isFullScreen
3116
+ },
3117
+ className
3118
+ );
3119
+ const contextValue = (0, import_react30.useMemo)(
3120
+ () => ({
3121
+ onClose: close,
3122
+ closeLabel
3123
+ }),
3124
+ [close, closeLabel]
3125
+ );
3126
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3127
+ "dialog",
3128
+ {
3129
+ ref: mergeRefs([dialogRef, ref]),
3130
+ onCancel: close,
3131
+ className: modalClasses,
3132
+ ...rest,
3133
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ModalContext.Provider, { value: contextValue, children })
3134
+ }
3135
+ );
3136
+ };
3137
+ Modal.displayName = "Modal";
3138
+
3139
+ // src/components/Modal/index.tsx
3140
+ var Modal2 = Object.assign(Modal, {
3141
+ Header: Header2,
3142
+ Content: Content2
3143
+ });
3144
+ Modal2.displayName = "Modal";
3145
+
3146
+ // src/components/NumberField/NumberField.tsx
3147
+ var import_dedupe38 = __toESM(require("classnames/dedupe"));
3148
+ var import_react31 = require("react");
3149
+ var import_jsx_runtime45 = require("react/jsx-runtime");
3150
+ var NumberField = ({ ref, ...props }) => {
3151
+ const {
3152
+ minValue,
3153
+ maxValue,
3154
+ step,
3155
+ defaultValue,
3156
+ hideSpinButtons,
3157
+ className,
3158
+ ...otherProps
3159
+ } = props;
3160
+ const {
3161
+ onFocus: customOnFocus,
3162
+ onBlur: customOnBlur,
3163
+ ...rest
3164
+ } = otherProps;
3165
+ const focusedInputRef = (0, import_react31.useRef)(null);
3166
+ const wheelHandler = (0, import_react31.useCallback)((ev) => ev.preventDefault(), []);
3167
+ (0, import_react31.useEffect)(() => {
3168
+ return () => {
3169
+ focusedInputRef.current?.removeEventListener("wheel", wheelHandler);
3170
+ focusedInputRef.current = null;
3171
+ };
3172
+ }, [wheelHandler]);
3173
+ const containerClasses = (0, import_dedupe38.default)("mobius-number-field", className, {
3174
+ "--hide-spin-buttons": hideSpinButtons
3175
+ });
3176
+ const handleBeforeInput = (event) => {
3177
+ const { data } = event.nativeEvent;
3178
+ if (step && Number.isInteger(step) && data === ".") {
3179
+ event.preventDefault();
3180
+ }
3181
+ if (minValue && minValue >= 0 && data === "-") {
3182
+ event.preventDefault();
3183
+ }
3184
+ };
3185
+ const handleBlur = (event) => {
3186
+ const { value } = event.target;
3187
+ const numValue = parseFloat(value);
3188
+ if (step && step > 1 && !isNaN(numValue)) {
3189
+ const baseValue = minValue ?? 0;
3190
+ const steps = Math.round((numValue - baseValue) / step);
3191
+ const snappedValue = baseValue + steps * step;
3192
+ if (snappedValue !== numValue) {
3193
+ event.target.value = snappedValue.toString();
3194
+ const changeEvent = new Event("change", { bubbles: true });
3195
+ event.target.dispatchEvent(changeEvent);
3196
+ const syntheticChangeEvent = {
3197
+ ...event,
3198
+ target: event.target,
3199
+ currentTarget: event.currentTarget
3200
+ };
3201
+ otherProps.onChange?.(syntheticChangeEvent);
3202
+ }
3203
+ }
3204
+ customOnBlur?.(event);
3205
+ };
3206
+ const forwardedProps = {
3207
+ ...rest,
3208
+ onFocus: (e) => {
3209
+ const el = e.currentTarget;
3210
+ focusedInputRef.current?.removeEventListener("wheel", wheelHandler);
3211
+ focusedInputRef.current = el;
3212
+ el.addEventListener("wheel", wheelHandler, { passive: false });
3213
+ customOnFocus?.(e);
3214
+ },
3215
+ onBlur: (e) => handleBlur(e)
3216
+ };
3217
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
3218
+ TextField,
3219
+ {
3220
+ ...forwardedProps,
3221
+ className: containerClasses,
3222
+ onBeforeInput: handleBeforeInput,
3223
+ type: "number",
3224
+ min: minValue ?? void 0,
3225
+ max: maxValue ?? void 0,
3226
+ step,
3227
+ ref,
3228
+ defaultValue: defaultValue != null ? defaultValue?.toString() : defaultValue
3229
+ }
3230
+ );
3231
+ };
3232
+ NumberField.displayName = "NumberField";
3233
+
3234
+ // src/components/Option/Option.tsx
3235
+ var import_jsx_runtime46 = require("react/jsx-runtime");
3236
+ var Option2 = ({ ref, ...props }) => {
3237
+ const { isDisabled, ...rest } = props;
3238
+ const mappedProps = {
3239
+ ...rest,
3240
+ disabled: isDisabled
3241
+ };
3242
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { ...mappedProps, ref });
3243
+ };
3244
+ Option2.displayName = "Option";
3245
+
3246
+ // src/components/PasswordField/PasswordField.tsx
3247
+ var import_dedupe39 = __toESM(require("classnames/dedupe"));
3248
+ var import_react32 = require("react");
3249
+
3250
+ // src/components/PasswordField/ShowHideButton.tsx
3251
+ var import_icons11 = require("@simplybusiness/icons");
3252
+ var import_jsx_runtime47 = require("react/jsx-runtime");
3253
+ var ShowHideButton = ({
3254
+ show = false,
3255
+ onClick
3256
+ }) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
3257
+ "button",
3258
+ {
3259
+ className: "mobius-password-field__show-button",
3260
+ type: "button",
3261
+ onClick: (e) => {
3262
+ e.preventDefault();
3263
+ onClick();
3264
+ },
3265
+ "aria-label": `${show ? "Hide" : "Show"} password`,
3266
+ "data-testid": "show-hide-button",
3267
+ children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Icon, { icon: show ? import_icons11.eyeSlash : import_icons11.eye, "aria-hidden": "true" })
3268
+ }
3269
+ );
3270
+
3271
+ // src/components/PasswordField/PasswordField.tsx
3272
+ var import_jsx_runtime48 = require("react/jsx-runtime");
3273
+ var PasswordField = ({
3274
+ ref,
3275
+ className,
3276
+ ...props
3277
+ }) => {
3278
+ const [show, setShow] = (0, import_react32.useState)(false);
3279
+ const type = show ? "text" : "password";
3280
+ const classes = (0, import_dedupe39.default)("mobius-password-field", className);
3281
+ const localRef = (0, import_react32.useRef)(null);
3282
+ const handleShowHideButtonClick = () => {
3283
+ const selectionStart = localRef.current?.selectionStart;
3284
+ const selectionEnd = localRef.current?.selectionEnd;
3285
+ setShow((oldShow) => !oldShow);
3286
+ requestAnimationFrame(() => {
3287
+ localRef.current?.focus();
3288
+ if (selectionStart != null && selectionEnd != null) {
3289
+ localRef.current?.setSelectionRange(selectionStart, selectionEnd);
3290
+ }
3291
+ });
3292
+ };
3293
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
3294
+ TextField,
3295
+ {
3296
+ ref: mergeRefs([localRef, ref]),
3297
+ className: classes,
3298
+ ...props,
3299
+ type,
3300
+ suffixInside: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ShowHideButton, { onClick: handleShowHideButtonClick, show })
3301
+ }
3302
+ );
3303
+ };
3304
+ PasswordField.displayName = "PasswordField";
3305
+
3306
+ // src/components/Popover/Popover.tsx
3307
+ var import_react33 = require("@floating-ui/react");
3308
+ var import_icons12 = require("@simplybusiness/icons");
3309
+ var import_dedupe40 = __toESM(require("classnames/dedupe"));
3310
+ var import_react34 = require("react");
3311
+ var import_mobius_hooks6 = require("@simplybusiness/mobius-hooks");
3312
+ var import_jsx_runtime49 = require("react/jsx-runtime");
3313
+ var OFFSET_FROM_CONTENT_DEFAULT = 10;
3314
+ var Popover = (props) => {
3315
+ const { trigger, children, onOpen, onClose, className } = props;
3316
+ const arrowRef = (0, import_react34.useRef)(null);
3317
+ const [isOpen, setIsOpen] = (0, import_react34.useState)(false);
3318
+ const { refs, floatingStyles, context } = (0, import_react33.useFloating)({
3319
+ open: isOpen,
3320
+ onOpenChange: setIsOpen,
3321
+ whileElementsMounted: import_react33.autoUpdate,
3322
+ middleware: [
3323
+ (0, import_react33.arrow)({
3324
+ element: arrowRef
3325
+ }),
3326
+ (0, import_react33.offset)(OFFSET_FROM_CONTENT_DEFAULT),
3327
+ (0, import_react33.shift)(),
3328
+ (0, import_react33.flip)()
3329
+ ]
3330
+ });
3331
+ const dismiss = (0, import_react33.useDismiss)(context, {
3332
+ bubbles: true,
3333
+ outsidePress: (event) => {
3334
+ const toggle = refs.reference.current;
3335
+ const isToggleClick = !toggle?.contains(event.target);
3336
+ if (isToggleClick) {
3337
+ onClose?.();
3338
+ }
3339
+ return true;
3340
+ }
3341
+ });
3342
+ const { getReferenceProps, getFloatingProps } = (0, import_react33.useInteractions)([dismiss]);
3343
+ const containerClasses = (0, import_dedupe40.default)(
3344
+ "mobius",
3345
+ "mobius-popover__container",
3346
+ className
3347
+ );
3348
+ const toggleVisibility = () => {
3349
+ if (isOpen) {
3350
+ setIsOpen(false);
3351
+ onClose?.();
3352
+ return;
3353
+ }
3354
+ setIsOpen(true);
3355
+ onOpen?.();
3356
+ };
3357
+ const triggerComponent = (0, import_react34.cloneElement)(trigger, {
3358
+ ref: refs.setReference,
3359
+ className: (0, import_dedupe40.default)(
3360
+ trigger.props.className,
3361
+ "mobius-popover__toggle"
3362
+ ),
3363
+ onClick: toggleVisibility,
3364
+ ...getReferenceProps()
3365
+ });
3366
+ (0, import_mobius_hooks6.useWindowEvent)("keydown", (e) => {
3367
+ if (e.key === "Escape") {
3368
+ onClose?.();
3369
+ e.preventDefault();
3370
+ e.stopPropagation();
3371
+ }
3372
+ });
3373
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
3374
+ triggerComponent,
3375
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
3376
+ "div",
3377
+ {
3378
+ className: containerClasses,
3379
+ ref: refs.setFloating,
3380
+ style: floatingStyles,
3381
+ ...getFloatingProps(),
3382
+ children: [
3383
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "mobius-popover", children: [
3384
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("header", { className: "mobius-popover__header", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3385
+ Button,
3386
+ {
3387
+ type: "button",
3388
+ className: "mobius-popover__close-button",
3389
+ onClick: toggleVisibility,
3390
+ "aria-label": "Close",
3391
+ variant: "ghost",
3392
+ children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3393
+ Icon,
3394
+ {
3395
+ icon: import_icons12.cross,
3396
+ size: "md",
3397
+ className: "mobius-popover__close-icon"
3398
+ }
3399
+ )
3400
+ }
3401
+ ) }),
3402
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "mobius-popover__body", children })
3403
+ ] }),
3404
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
3405
+ import_react33.FloatingArrow,
3406
+ {
3407
+ ref: arrowRef,
3408
+ context,
3409
+ width: 20,
3410
+ className: "mobius-popover__arrow-icon"
3411
+ }
3412
+ )
3413
+ ]
3414
+ }
3415
+ )
3416
+ ] });
3417
+ };
3418
+
3419
+ // src/components/Progress/Progress.tsx
3420
+ var import_dedupe41 = __toESM(require("classnames/dedupe"));
3421
+ var import_react35 = require("react");
3422
+ var import_jsx_runtime50 = require("react/jsx-runtime");
3423
+ function warnAboutInvalidValues(value, minValue, maxValue) {
3424
+ if (minValue > maxValue) {
3425
+ console.warn("minValue is greater than maxValue");
3426
+ }
3427
+ if (value < minValue) {
3428
+ console.warn("Progress value is less than minValue");
3429
+ }
3430
+ if (value > maxValue) {
3431
+ console.warn("Progress value is greater than maxValue");
3432
+ }
3433
+ }
3434
+ var sanitizedValue = (value, defaultValue) => {
3435
+ if (value === void 0 || Number.isNaN(value)) {
3436
+ return defaultValue;
3437
+ }
3438
+ return value;
3439
+ };
3440
+ var getLabelComponent = (label, progressLabelId, showLabel) => {
3441
+ if (showLabel) {
3442
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
3443
+ Label,
3444
+ {
3445
+ id: progressLabelId,
3446
+ className: "mobius-progress__label",
3447
+ elementType: "span",
3448
+ children: label
3449
+ }
3450
+ );
3451
+ }
3452
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
3453
+ Label,
3454
+ {
3455
+ id: progressLabelId,
3456
+ className: "mobius-progress__label",
3457
+ elementType: "span",
3458
+ children: label
3459
+ }
3460
+ ) });
3461
+ };
3462
+ var DEFAULT_VALUE = 0;
3463
+ var DEFAULT_MIN_VALUE = 0;
3464
+ var DEFAULT_MAX_VALUE = 100;
3465
+ var Progress = ({ ref, ...props }) => {
3466
+ const progressId = (0, import_react35.useId)();
3467
+ const progressLabelId = (0, import_react35.useId)();
3468
+ const {
3469
+ id,
3470
+ label,
3471
+ showLabel = true,
3472
+ showValueLabel = !!label,
3473
+ valueFormatter,
3474
+ variant = "primary",
3475
+ className
3476
+ } = props;
3477
+ let { value, minValue, maxValue } = props;
3478
+ value = sanitizedValue(value, DEFAULT_VALUE);
3479
+ minValue = sanitizedValue(minValue, DEFAULT_MIN_VALUE);
3480
+ maxValue = sanitizedValue(maxValue, DEFAULT_MAX_VALUE);
3481
+ if (value === void 0 || minValue === void 0 || maxValue === void 0) {
3482
+ return null;
3483
+ }
3484
+ warnAboutInvalidValues(value, minValue, maxValue);
3485
+ const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
3486
+ const percentage = clamp(
3487
+ Math.round((value - minValue) / (maxValue - minValue) * 100),
3488
+ 0,
3489
+ 100
3490
+ );
3491
+ const barWidth = `${percentage}%`;
3492
+ const classes = (0, import_dedupe41.default)("mobius", "mobius-progress", className, {
3493
+ "--is-primary": variant === "primary",
3494
+ "--is-secondary": variant === "secondary"
3495
+ });
3496
+ const progressBarProps = {};
3497
+ progressBarProps["aria-valuemin"] = minValue.toString();
3498
+ progressBarProps["aria-valuemax"] = maxValue.toString();
3499
+ progressBarProps["aria-valuenow"] = value.toString();
3500
+ progressBarProps["aria-valuetext"] = valueFormatter instanceof Function ? valueFormatter(value, minValue, maxValue) : barWidth;
3501
+ const labelComponent = getLabelComponent(label, progressLabelId, showLabel);
3502
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
3503
+ "div",
3504
+ {
3505
+ id: id || progressId,
3506
+ ...progressBarProps,
3507
+ ref,
3508
+ className: classes,
3509
+ role: "progressbar",
3510
+ "aria-labelledby": progressLabelId,
3511
+ children: [
3512
+ labelComponent,
3513
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "mobius-progress__track", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "mobius-progress__bar", style: { width: barWidth } }) }),
3514
+ showValueLabel && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Label, { "data-testid": "value-label", elementType: "span", children: progressBarProps["aria-valuetext"] })
3515
+ ]
3516
+ }
3517
+ );
3518
+ };
3519
+ Progress.displayName = "Progress";
3520
+
3521
+ // src/components/Radio/Radio.tsx
3522
+ var import_dedupe42 = __toESM(require("classnames/dedupe"));
3523
+ var import_react36 = require("react");
3524
+ var import_jsx_runtime51 = require("react/jsx-runtime");
3525
+ var Radio = ({ ref, ...props }) => {
3526
+ const {
3527
+ children,
3528
+ value,
3529
+ label,
3530
+ className,
3531
+ isDisabled,
3532
+ errorMessage,
3533
+ onChange,
3534
+ defaultChecked,
3535
+ groupDisabled,
3536
+ name,
3537
+ selected,
3538
+ setSelected,
3539
+ isRequired,
3540
+ onOverflow,
3541
+ orientation,
3542
+ ...otherProps
3543
+ } = props;
3544
+ const realDisabled = groupDisabled || isDisabled;
3545
+ const isMultiline = label && children;
3546
+ const isControlled = selected !== void 0;
3547
+ const isChecked = isControlled ? selected === value : defaultChecked;
3548
+ const contentRef = (0, import_react36.useRef)(null);
3549
+ const prevOverflowRef = (0, import_react36.useRef)({
3550
+ vertical: false,
3551
+ horizontal: false
3552
+ });
3553
+ const hasIconFirst = (0, import_react36.useMemo)(() => {
3554
+ if (!children || import_react36.Children.count(children) === 0) return false;
3555
+ const firstChild = import_react36.Children.toArray(children)[0];
3556
+ if (!(0, import_react36.isValidElement)(firstChild)) return false;
3557
+ const props2 = firstChild.props;
3558
+ return "icon" in props2 && props2.icon !== void 0;
3559
+ }, [children]);
3560
+ (0, import_react36.useLayoutEffect)(() => {
3561
+ if (!contentRef.current || !onOverflow) return;
3562
+ if (orientation === "vertical") {
3563
+ return;
3564
+ }
3565
+ const element = contentRef.current;
3566
+ const scrollOverflowVertical = element.scrollHeight > element.clientHeight;
3567
+ const scrollOverflowHorizontal = element.scrollWidth > element.clientWidth;
3568
+ const styles = window.getComputedStyle(element);
3569
+ const lineHeight = parseFloat(styles.lineHeight);
3570
+ const fontSize = parseFloat(styles.fontSize);
3571
+ const singleLineHeight = isNaN(lineHeight) ? fontSize * 1.2 : lineHeight;
3572
+ const WRAP_DETECTION_TOLERANCE = 1.1;
3573
+ const hasWrapped = element.clientHeight > singleLineHeight * WRAP_DETECTION_TOLERANCE;
3574
+ const vertical = scrollOverflowVertical || hasWrapped;
3575
+ const horizontal = scrollOverflowHorizontal;
3576
+ const newOverflowState = { vertical, horizontal };
3577
+ const prevOverflow = prevOverflowRef.current;
3578
+ if (newOverflowState.vertical !== prevOverflow.vertical || newOverflowState.horizontal !== prevOverflow.horizontal) {
3579
+ prevOverflowRef.current = newOverflowState;
3580
+ onOverflow(newOverflowState);
3581
+ }
3582
+ }, [label, children, onOverflow, orientation]);
3583
+ const radioClasses = {
3584
+ "--is-disabled": realDisabled,
3585
+ "--is-selected": selected === value,
3586
+ "--is-multiline": !!isMultiline,
3587
+ "--is-required": isRequired
3588
+ };
3589
+ const containerClasses = (0, import_dedupe42.default)(
3590
+ "mobius-radio__label",
3591
+ radioClasses,
3592
+ className,
3593
+ { "--has-icon-first": hasIconFirst }
3594
+ );
3595
+ const inputClasses = (0, import_dedupe42.default)("mobius-radio__input", radioClasses);
3596
+ const { "aria-describedby": _ariaDescribedBy, ...rest } = otherProps;
3597
+ const handleChange = (event) => {
3598
+ if (setSelected) {
3599
+ setSelected(event.target.value);
3600
+ }
3601
+ if (onChange) {
3602
+ const adaptedEvent = {
3603
+ ...event.nativeEvent,
3604
+ target: event.target
3605
+ };
3606
+ onChange(adaptedEvent);
3607
+ }
3608
+ };
3609
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
3610
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Label, { className: containerClasses, children: [
3611
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
3612
+ "input",
3613
+ {
3614
+ "aria-describedby": otherProps["aria-describedby"],
3615
+ disabled: realDisabled,
3616
+ ref,
3617
+ className: inputClasses,
3618
+ value,
3619
+ tabIndex: 0,
3620
+ type: "radio",
3621
+ onChange: handleChange,
3622
+ ...isControlled ? { checked: isChecked } : { defaultChecked: isChecked },
3623
+ name,
3624
+ required: isRequired,
3625
+ ...rest
3626
+ }
3627
+ ),
3628
+ isMultiline ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { ref: contentRef, className: "mobius-radio__content--multiline", children: [
3629
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "mobius-radio__content-first-line", children: label }),
3630
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "mobius-radio__extra-content", children })
3631
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ref: contentRef, className: "mobius-radio__content", children: label || children })
3632
+ ] }),
3633
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorMessage, { errorMessage })
3634
+ ] });
3635
+ };
3636
+ Radio.displayName = "Radio";
3637
+
3638
+ // src/components/Radio/RadioGroup.tsx
3639
+ var import_dedupe43 = __toESM(require("classnames/dedupe"));
3640
+ var import_react37 = require("react");
3641
+ var import_jsx_runtime52 = require("react/jsx-runtime");
3642
+ var getDefaultVal = (children, defaultValue) => {
3643
+ if (Array.isArray(children) && defaultValue) {
3644
+ const option = children?.find((item) => item.props.value === defaultValue);
3645
+ if (!option) return "";
3646
+ return option.props.value;
3647
+ }
3648
+ return "";
3649
+ };
3650
+ var RadioGroup = ({ ref, ...props }) => {
3651
+ const {
3652
+ label,
3653
+ isDisabled = false,
3654
+ isRequired,
3655
+ isInvalid,
3656
+ orientation = "vertical",
3657
+ className,
3658
+ errorMessage,
3659
+ children,
3660
+ defaultValue,
3661
+ value,
3662
+ isReadOnly,
3663
+ name,
3664
+ onChange,
3665
+ autoStack = false,
3666
+ ...rest
3667
+ } = props;
3668
+ const defaultSelected = getDefaultVal(children, value || defaultValue);
3669
+ const [selected, setSelected] = (0, import_react37.useState)(defaultSelected);
3670
+ const overflowsRef = (0, import_react37.useRef)({});
3671
+ const [hasOverflow, setHasOverflow] = (0, import_react37.useState)(false);
3672
+ (0, import_react37.useEffect)(() => {
3673
+ if (value !== void 0) {
3674
+ setSelected(value);
3675
+ }
3676
+ }, [value]);
3677
+ const handleOverflow = (0, import_react37.useCallback)(
3678
+ (radioValue, overflow) => {
3679
+ overflowsRef.current = {
3680
+ ...overflowsRef.current,
3681
+ [radioValue]: overflow
3682
+ };
3683
+ const anyOverflow = Object.values(overflowsRef.current).some(
3684
+ (o) => o.vertical || o.horizontal
3685
+ );
3686
+ if (anyOverflow !== hasOverflow) {
3687
+ setHasOverflow(anyOverflow);
3688
+ }
3689
+ },
3690
+ [hasOverflow]
3691
+ );
3692
+ const effectiveOrientation = autoStack && orientation === "horizontal" && hasOverflow ? "vertical" : orientation;
3693
+ const validationClasses = useValidationClasses({ isInvalid });
3694
+ const radioClasses = {
3695
+ "--is-disabled": isDisabled,
3696
+ "--is-required": typeof isRequired === "boolean" && isRequired,
3697
+ "--is-optional": typeof isRequired === "boolean" && !isRequired,
3698
+ [`--is-${effectiveOrientation}`]: true,
3699
+ [className || ""]: true
3700
+ };
3701
+ const radioGroupClasses = (0, import_dedupe43.default)(
3702
+ "mobius",
3703
+ "mobius-radio-group",
3704
+ radioClasses,
3705
+ validationClasses
3706
+ );
3707
+ const radioWrapperClasses = (0, import_dedupe43.default)("mobius-radio__wrapper", {
3708
+ [`--is-${effectiveOrientation}`]: true
3709
+ });
3710
+ const labelClasses = (0, import_dedupe43.default)(radioClasses, validationClasses);
3711
+ const errorMessageId = (0, import_react37.useId)();
3712
+ const defaultNameAttrId = (0, import_react37.useId)();
3713
+ const nameAttribute = name || defaultNameAttrId;
3714
+ const shouldErrorMessageShow = errorMessage ? errorMessageId : void 0;
3715
+ const describedBy = spaceDelimitedList([
3716
+ shouldErrorMessageShow,
3717
+ props["aria-describedby"]
3718
+ ]);
3719
+ const labelId = (0, import_react37.useId)();
3720
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
3721
+ "div",
3722
+ {
3723
+ ...rest,
3724
+ "aria-describedby": describedBy,
3725
+ "aria-disabled": isDisabled,
3726
+ "aria-errormessage": shouldErrorMessageShow,
3727
+ "aria-invalid": isInvalid,
3728
+ "aria-label": props["aria-label"],
3729
+ "aria-labelledby": props["aria-labelledby"] || labelId,
3730
+ "aria-orientation": effectiveOrientation,
3731
+ "aria-readonly": isReadOnly,
3732
+ "aria-required": isRequired,
3733
+ ref,
3734
+ className: radioGroupClasses,
3735
+ role: "radiogroup",
3736
+ children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { gap: "xs", children: [
3737
+ label && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Label, { htmlFor: name, id: labelId, className: labelClasses, children: label }),
3738
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: radioWrapperClasses, children: import_react37.Children.map(children, (child) => {
3739
+ if ((0, import_react37.isValidElement)(child)) {
3740
+ const childValue = child.props.value;
3741
+ return (0, import_react37.cloneElement)(
3742
+ child,
3743
+ {
3744
+ orientation: effectiveOrientation,
3745
+ groupDisabled: isDisabled,
3746
+ name: nameAttribute,
3747
+ selected: selected || defaultSelected,
3748
+ // in case state does not update
3749
+ setSelected,
3750
+ isRequired,
3751
+ "aria-describedby": describedBy,
3752
+ onChange,
3753
+ onOverflow: childValue ? (overflow) => handleOverflow(childValue, overflow) : void 0
3754
+ }
3755
+ );
3756
+ }
3757
+ return child;
3758
+ }) }),
3759
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ErrorMessage, { id: errorMessageId, errorMessage })
3760
+ ] })
3761
+ }
3762
+ );
3763
+ };
3764
+ RadioGroup.displayName = "RadioGroup";
3765
+
3766
+ // src/components/Segment/SegmentGroup.tsx
3767
+ var import_dedupe44 = __toESM(require("classnames/dedupe"));
3768
+ var import_jsx_runtime53 = require("react/jsx-runtime");
3769
+ var SegmentGroup = (props) => {
3770
+ const { children, horizontal, gap, className, ...rest } = props;
3771
+ const gapClass = gap ? `gap-${gap}` : "";
3772
+ const classes = (0, import_dedupe44.default)(
3773
+ "mobius",
3774
+ "mobius-segment-group",
3775
+ className,
3776
+ { "--is-horizontal": horizontal },
3777
+ gapClass
3778
+ );
3779
+ return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: classes, ...rest, children });
3780
+ };
3781
+ SegmentGroup.displayName = "SegmentGroup";
3782
+
3783
+ // src/components/Segment/Segment.tsx
3784
+ var import_dedupe45 = __toESM(require("classnames/dedupe"));
3785
+ var import_jsx_runtime54 = require("react/jsx-runtime");
3786
+ var Segment = (props) => {
3787
+ const { heading, children, colour, inverted, className, ...rest } = props;
3788
+ const classes = (0, import_dedupe45.default)(
3789
+ "mobius",
3790
+ "mobius-segment",
3791
+ colour,
3792
+ { inverted },
3793
+ className
3794
+ );
3795
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: classes, ...rest, children: [
3796
+ heading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "mobius-segment__heading", children: heading }),
3797
+ children
3798
+ ] });
3799
+ };
3800
+ Segment.displayName = "Segment";
3801
+
3802
+ // src/components/Select/Select.tsx
3803
+ var import_icons13 = require("@simplybusiness/icons");
3804
+ var import_dedupe46 = __toESM(require("classnames/dedupe"));
3805
+ var import_react38 = require("react");
3806
+ var import_jsx_runtime55 = require("react/jsx-runtime");
3807
+ var Select = ({ ref, ...props }) => {
3808
+ const {
3809
+ label,
3810
+ onChange,
3811
+ isInvalid,
3812
+ errorMessage,
3813
+ isDisabled = false,
3814
+ isRequired,
3815
+ ...otherProps
3816
+ } = props;
3817
+ const { labelProps, fieldProps } = useLabel({
3818
+ label,
3819
+ ...otherProps
3820
+ });
3821
+ const validationClasses = useValidationClasses({ isInvalid });
3822
+ const stateClasses = {
3823
+ "--is-disabled": isDisabled,
3824
+ "--is-required": typeof isRequired === "boolean" && isRequired,
3825
+ "--is-optional": typeof isRequired === "boolean" && !isRequired
3826
+ };
3827
+ const sharedClasses = (0, import_dedupe46.default)(validationClasses, stateClasses);
3828
+ const wrapperClasses = (0, import_dedupe46.default)(
3829
+ "mobius-select__wrapper",
3830
+ sharedClasses,
3831
+ otherProps.className
3832
+ );
3833
+ const selectClasses = (0, import_dedupe46.default)(
3834
+ "mobius-select",
3835
+ sharedClasses,
3836
+ otherProps.className
3837
+ );
3838
+ const labelClasses = (0, import_dedupe46.default)(
3839
+ "mobius-label",
3840
+ sharedClasses,
3841
+ otherProps.className
3842
+ );
3843
+ const iconClasses = (0, import_dedupe46.default)("mobius-select__icon", sharedClasses);
3844
+ const errorMessageId = (0, import_react38.useId)();
3845
+ const shouldErrorMessageShow = errorMessage ? errorMessageId : void 0;
3846
+ const describedBy = spaceDelimitedList([
3847
+ shouldErrorMessageShow,
3848
+ props["aria-describedby"]
3849
+ ]);
3850
+ const handleChange = (e) => {
3851
+ if (onChange) {
3852
+ onChange(e);
3853
+ }
3854
+ };
3855
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { className: "mobius mobius-select__outer", gap: "xs", children: [
3856
+ label && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Label, { ...labelProps, className: labelClasses, children: label }),
3857
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: wrapperClasses, children: [
3858
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
3859
+ "select",
3860
+ {
3861
+ ...otherProps,
3862
+ ...fieldProps,
3863
+ ref,
3864
+ multiple: false,
3865
+ className: selectClasses,
3866
+ disabled: isDisabled,
3867
+ "aria-invalid": !!errorMessage,
3868
+ "aria-describedby": describedBy,
3869
+ "aria-required": isRequired,
3870
+ required: isRequired,
3871
+ onChange: handleChange
3872
+ }
3873
+ ),
3874
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: iconClasses, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { icon: import_icons13.chevronDown }) })
3875
+ ] }),
3876
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ErrorMessage, { id: errorMessageId, errorMessage })
3877
+ ] });
3878
+ };
3879
+ Select.displayName = "Select";
3880
+
3881
+ // src/components/Slider/Slider.tsx
3882
+ var import_dedupe47 = __toESM(require("classnames/dedupe"));
3883
+ var import_react40 = require("react");
3884
+
3885
+ // src/components/Slider/helpers.ts
3886
+ var import_react39 = require("react");
3887
+ function numberFormatter(value, formatOptions, locale = navigator.languages?.[0] || "en-GB") {
3888
+ if (!formatOptions) {
3889
+ return value?.toString() || "";
3890
+ }
3891
+ return new Intl.NumberFormat(locale, formatOptions).format(+(value || 0));
3892
+ }
3893
+
3894
+ // src/components/Slider/Slider.tsx
3895
+ var import_jsx_runtime56 = require("react/jsx-runtime");
3896
+ var Slider = (props) => {
3897
+ const {
3898
+ id,
3899
+ className,
3900
+ label,
3901
+ "aria-label": ariaLabel,
3902
+ "aria-labelledby": ariaLabelledBy,
3903
+ minValue,
3904
+ maxValue,
3905
+ step = 1,
3906
+ defaultValue = 0,
3907
+ value,
3908
+ onChange,
3909
+ onChangeEnd,
3910
+ variant = "primary",
3911
+ minLabel,
3912
+ maxLabel,
3913
+ formatOptions,
3914
+ isDisabled = false
3915
+ } = props;
3916
+ const trackRef = (0, import_react40.useRef)(null);
3917
+ const [currentValue, setCurrentValue] = (0, import_react40.useState)(
3918
+ value || defaultValue || 0
3919
+ );
3920
+ const [isDragging, setIsDraggging] = (0, import_react40.useState)(false);
3921
+ const { labelProps, fieldProps } = useLabel({
3922
+ id,
3923
+ label,
3924
+ "aria-label": ariaLabel,
3925
+ "aria-labelledby": ariaLabelledBy
3926
+ });
3927
+ const formattedValue = numberFormatter(currentValue, formatOptions);
3928
+ const classes = (0, import_dedupe47.default)("mobius", "mobius-slider", className, {
3929
+ "--is-disabled": isDisabled,
3930
+ "--is-primary": variant === "primary",
3931
+ "--is-secondary": variant === "secondary",
3932
+ "--is-dragging": isDragging
3933
+ });
3934
+ const handleChange = (e) => {
3935
+ const val = +e.target.value;
3936
+ setCurrentValue(val);
3937
+ if (onChange) {
3938
+ onChange(val);
3939
+ }
3940
+ };
3941
+ const handleChangeStart = () => {
3942
+ setIsDraggging(true);
3943
+ };
3944
+ const handleChangeEnd = () => {
3945
+ setIsDraggging(false);
3946
+ if (onChangeEnd) {
3947
+ onChangeEnd(currentValue);
3948
+ }
3949
+ };
3950
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: classes, children: [
3951
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "mobius-slider__label-wrapper", children: [
3952
+ label && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Label, { ...labelProps, children: label }),
3953
+ label && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("output", { style: { flex: "1 0 auto", textAlign: "end" }, children: formattedValue })
3954
+ ] }),
3955
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { ref: trackRef, className: "mobius-slider__track-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
3956
+ "input",
3957
+ {
3958
+ className: "mobius-slider__track",
3959
+ type: "range",
3960
+ min: minValue,
3961
+ max: maxValue,
3962
+ value: currentValue,
3963
+ step,
3964
+ onChange: handleChange,
3965
+ autoComplete: "off",
3966
+ disabled: isDisabled,
3967
+ onMouseDown: handleChangeStart,
3968
+ onMouseUp: handleChangeEnd,
3969
+ onKeyDown: handleChangeStart,
3970
+ onKeyUp: handleChangeEnd,
3971
+ ...fieldProps
3972
+ }
3973
+ ) }),
3974
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "mobius-slider__labels", children: [
3975
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "mobius-slider__min-label", "data-testid": "min-label", children: minLabel }),
3976
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "mobius-slider__max-label", "data-testid": "max-label", children: maxLabel })
3977
+ ] })
3978
+ ] });
3979
+ };
3980
+
3981
+ // src/components/SVG/SVG.tsx
3982
+ var import_react41 = require("react");
3983
+ var import_dedupe48 = __toESM(require("classnames/dedupe"));
3984
+ var import_jsx_runtime57 = require("react/jsx-runtime");
3985
+ var SVG = ({ ref, ...props }) => {
3986
+ const { children, className, ...otherProps } = props;
3987
+ const classes = (0, import_dedupe48.default)("mobius", "mobius-svg", className);
3988
+ const svgNode = import_react41.Children.only(children);
3989
+ const { children: svgChildren, viewBox, xmlns } = svgNode.props;
3990
+ return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
3991
+ "svg",
3992
+ {
3993
+ viewBox,
3994
+ xmlns,
3995
+ ref,
3996
+ ...otherProps,
3997
+ className: classes,
3998
+ children: svgChildren
3999
+ }
4000
+ );
4001
+ };
4002
+ SVG.displayName = "SVG";
4003
+
4004
+ // src/components/Switch/Switch.tsx
4005
+ var import_react42 = require("react");
4006
+ var import_dedupe49 = __toESM(require("classnames/dedupe"));
4007
+ var import_jsx_runtime58 = require("react/jsx-runtime");
4008
+ var Switch = ({ ref, ...props }) => {
4009
+ const {
4010
+ checked = false,
4011
+ className,
4012
+ onChange,
4013
+ isDisabled = false,
4014
+ ...otherProps
4015
+ } = props;
4016
+ const [enabled, setEnabled] = (0, import_react42.useState)(checked);
4017
+ (0, import_react42.useEffect)(() => {
4018
+ setEnabled(checked);
4019
+ }, [checked]);
4020
+ const classes = (0, import_dedupe49.default)(
4021
+ "mobius",
4022
+ "mobius-switch",
4023
+ {
4024
+ "mobius-switch--checked": enabled,
4025
+ "mobius-switch--disabled": isDisabled
4026
+ },
4027
+ className
4028
+ );
4029
+ const handleChange = (event) => {
4030
+ setEnabled(!enabled);
4031
+ if (onChange) {
4032
+ onChange(event);
4033
+ }
4034
+ };
4035
+ return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("label", { ref, className: classes, children: [
4036
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: enabled ? "On" : "Off" }) }),
4037
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
4038
+ "input",
4039
+ {
4040
+ type: "checkbox",
4041
+ role: "switch",
4042
+ checked: enabled,
4043
+ onChange: handleChange,
4044
+ disabled: isDisabled,
4045
+ ...otherProps
4046
+ }
4047
+ ),
4048
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "mobius-switch__slider" })
4049
+ ] });
4050
+ };
4051
+ Switch.displayName = "Switch";
4052
+
4053
+ // src/components/Table/Table.tsx
4054
+ var import_dedupe50 = __toESM(require("classnames/dedupe"));
4055
+ var import_jsx_runtime59 = require("react/jsx-runtime");
4056
+ var Table = ({ ref, ...props }) => {
4057
+ const classes = (0, import_dedupe50.default)("mobius", "mobius-table", props.className);
4058
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("table", { ref, ...props, className: classes });
4059
+ };
4060
+ Table.displayName = "Table";
4061
+
4062
+ // src/components/Table/Head.tsx
4063
+ var import_dedupe51 = __toESM(require("classnames/dedupe"));
4064
+ var import_jsx_runtime60 = require("react/jsx-runtime");
4065
+ var Head = ({ ref, ...props }) => {
4066
+ const classes = (0, import_dedupe51.default)("mobius", "mobius-table__head", props.className);
4067
+ return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("thead", { ref, ...props, className: classes });
4068
+ };
4069
+ Head.displayName = "Table.Head";
4070
+
4071
+ // src/components/Table/Body.tsx
4072
+ var import_dedupe52 = __toESM(require("classnames/dedupe"));
4073
+ var import_jsx_runtime61 = require("react/jsx-runtime");
4074
+ var Body = ({ ref, ...props }) => {
4075
+ const classes = (0, import_dedupe52.default)("mobius", "mobius-table__body", props.className);
4076
+ return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("tbody", { ref, ...props, className: classes });
4077
+ };
4078
+ Body.displayName = "Table.Body";
4079
+
4080
+ // src/components/Table/Foot.tsx
4081
+ var import_dedupe53 = __toESM(require("classnames/dedupe"));
4082
+ var import_jsx_runtime62 = require("react/jsx-runtime");
4083
+ var Foot = ({ ref, ...props }) => {
4084
+ const classes = (0, import_dedupe53.default)("mobius", "mobius-table__foot", props.className);
4085
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tfoot", { ref, ...props, className: classes });
4086
+ };
4087
+ Foot.displayName = "Table.Foot";
4088
+
4089
+ // src/components/Table/Row.tsx
4090
+ var import_dedupe54 = __toESM(require("classnames/dedupe"));
4091
+ var import_jsx_runtime63 = require("react/jsx-runtime");
4092
+ var Row = ({ ref, ...props }) => {
4093
+ const classes = (0, import_dedupe54.default)("mobius", "mobius-table__row", props.className);
4094
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("tr", { ref, ...props, className: classes });
4095
+ };
4096
+ Row.displayName = "Table.Row";
4097
+
4098
+ // src/components/Table/HeaderCell.tsx
4099
+ var import_dedupe55 = __toESM(require("classnames/dedupe"));
4100
+ var import_jsx_runtime64 = require("react/jsx-runtime");
4101
+ var HeaderCell = ({ ref, ...props }) => {
4102
+ const classes = (0, import_dedupe55.default)(
4103
+ "mobius",
4104
+ "mobius-table__head-cell",
4105
+ props.className
4106
+ );
4107
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("th", { ...props, ref, className: classes });
4108
+ };
4109
+ HeaderCell.displayName = "Table.HeaderCell";
4110
+
4111
+ // src/components/Table/Cell.tsx
4112
+ var import_dedupe56 = __toESM(require("classnames/dedupe"));
4113
+ var import_jsx_runtime65 = require("react/jsx-runtime");
4114
+ var Cell = ({ ref, ...props }) => {
4115
+ const classes = (0, import_dedupe56.default)(
4116
+ "mobius",
4117
+ "mobius-table__body-cell",
4118
+ props.className
4119
+ );
4120
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("td", { ref, ...props, className: classes });
4121
+ };
4122
+ Cell.displayName = "Table.Cell";
4123
+
4124
+ // src/components/Table/index.tsx
4125
+ var Table2 = Object.assign(Table, {
4126
+ Head,
4127
+ Body,
4128
+ Foot,
4129
+ Row,
4130
+ HeaderCell,
4131
+ Cell
4132
+ });
4133
+ Table2.displayName = "Table";
4134
+
4135
+ // src/components/Text/Text.tsx
4136
+ var import_dedupe57 = __toESM(require("classnames/dedupe"));
4137
+ var import_jsx_runtime66 = require("react/jsx-runtime");
4138
+ var getElementType = (variant, elementType) => {
4139
+ if (variant) {
4140
+ return ["h1", "h2", "h3", "h4"].includes(variant) ? variant : "p";
4141
+ }
4142
+ return elementType || "p";
4143
+ };
4144
+ var Text = ({ ref, elementType: Component = "p", ...props }) => {
4145
+ const { variant, className, spacing, ...otherProps } = props;
4146
+ const elementType = getElementType(variant, Component);
4147
+ const variantType = variant || elementType;
4148
+ const classes = (0, import_dedupe57.default)(
4149
+ "mobius",
4150
+ "mobius-text",
4151
+ { [`--is-${variantType}`]: variantType },
4152
+ { [`--has-line-height-${spacing}`]: spacing },
4153
+ className
4154
+ );
4155
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Component, { ref, ...otherProps, className: classes });
4156
+ };
4157
+ Text.displayName = "Text";
4158
+
4159
+ // src/components/TextArea/TextArea.tsx
4160
+ var import_dedupe59 = __toESM(require("classnames/dedupe"));
4161
+
4162
+ // src/components/TextAreaInput/TextAreaInput.tsx
4163
+ var import_dedupe58 = __toESM(require("classnames/dedupe"));
4164
+ var import_jsx_runtime67 = require("react/jsx-runtime");
4165
+ var TextAreaInput = ({ ref, ...props }) => {
4166
+ const { isSelected, isDisabled, isReadOnly, isRequired, ...otherProps } = props;
4167
+ const classes = (0, import_dedupe58.default)(
4168
+ "mobius",
4169
+ "mobius-text-area__input",
4170
+ {
4171
+ "--is-disabled": isDisabled,
4172
+ "--is-selected": isSelected,
4173
+ "--is-required": isRequired
4174
+ },
4175
+ otherProps.className
4176
+ );
4177
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
4178
+ "textarea",
4179
+ {
4180
+ ref,
4181
+ ...otherProps,
4182
+ required: isRequired,
4183
+ readOnly: isReadOnly,
4184
+ className: classes
4185
+ }
4186
+ );
4187
+ };
4188
+ TextAreaInput.displayName = "TextAreaInput";
4189
+
4190
+ // src/components/TextArea/TextArea.tsx
4191
+ var import_jsx_runtime68 = require("react/jsx-runtime");
4192
+ var TextArea = ({ ref, ...props }) => {
4193
+ const {
4194
+ isDisabled,
4195
+ className,
4196
+ errorMessage,
4197
+ label,
4198
+ isInvalid,
4199
+ ...otherProps
4200
+ } = props;
4201
+ const { inputProps, labelProps, errorMessageProps } = useTextField(props);
4202
+ const classes = (0, import_dedupe59.default)("mobius", "mobius-text-area", className);
4203
+ const validationClasses = useValidationClasses({ isInvalid });
4204
+ const inputClasses = (0, import_dedupe59.default)("mobius-text-area__input", validationClasses);
4205
+ const labelClasses = (0, import_dedupe59.default)(
4206
+ {
4207
+ "--is-disabled": isDisabled
4208
+ },
4209
+ validationClasses
4210
+ );
4211
+ return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { className: classes, gap: "xs", children: [
4212
+ label && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Label, { ...labelProps, className: labelClasses, children: props.label }),
4213
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
4214
+ TextAreaInput,
4215
+ {
4216
+ ...otherProps,
4217
+ ...inputProps,
4218
+ ref,
4219
+ className: inputClasses,
4220
+ isDisabled,
4221
+ "aria-invalid": errorMessage != null
4222
+ }
4223
+ ),
4224
+ /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ErrorMessage, { ...errorMessageProps, errorMessage })
4225
+ ] });
4226
+ };
4227
+ TextArea.displayName = "TextArea";
4228
+
4229
+ // src/components/TextOrHTML/TextOrHTML.tsx
4230
+ var import_react43 = require("react");
4231
+ var import_jsx_runtime69 = require("react/jsx-runtime");
4232
+ var TextOrHTML = ({
4233
+ ref,
4234
+ text,
4235
+ htmlClassName,
4236
+ htmlElementType = "span",
4237
+ textWrapper = false,
4238
+ ...textProps
4239
+ }) => {
4240
+ const DangerousComponent = htmlElementType;
4241
+ const dangerousHTML = (0, import_react43.useMemo)(() => ({ __html: text }), [text]);
4242
+ const dangerousElement = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
4243
+ DangerousComponent,
4244
+ {
4245
+ className: htmlClassName,
4246
+ dangerouslySetInnerHTML: dangerousHTML
4247
+ }
4248
+ );
4249
+ if (textWrapper) {
4250
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Text, { ref, ...textProps, children: dangerousElement });
4251
+ }
4252
+ return dangerousElement;
4253
+ };
4254
+ TextOrHTML.displayName = "TextOrHTML";
4255
+
4256
+ // src/components/Title/Title.tsx
4257
+ var import_dedupe60 = __toESM(require("classnames/dedupe"));
4258
+ var import_jsx_runtime70 = require("react/jsx-runtime");
4259
+ var Title = ({ ref, ...props }) => {
4260
+ const {
4261
+ elementType: Element = "div",
4262
+ title,
4263
+ description,
4264
+ ...otherProps
4265
+ } = props;
4266
+ const classes = (0, import_dedupe60.default)("mobius", "mobius-title", otherProps.className);
4267
+ const headerClasses = (0, import_dedupe60.default)("mobius", "mobius-title__header");
4268
+ const contentClasses = (0, import_dedupe60.default)("mobius", "mobius-title__description");
4269
+ const containerClasses = (0, import_dedupe60.default)("mobius", "mobius-title__container");
4270
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Element, { ref, ...otherProps, className: classes, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Flex, { flexDirection: "column", className: containerClasses, children: [
4271
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("p", { className: headerClasses, children: title }),
4272
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("p", { className: contentClasses, children: description })
4273
+ ] }) });
4274
+ };
4275
+ Title.displayName = "Title";
4276
+
4277
+ // src/components/Toast/Toast.tsx
4278
+ var import_icons14 = require("@simplybusiness/icons");
4279
+ var import_dedupe61 = __toESM(require("classnames/dedupe"));
4280
+ var import_sonner = require("sonner");
4281
+
4282
+ // src/components/Toast/state.ts
4283
+ var toastState = {
4284
+ showCloseButton: true
4285
+ };
4286
+
4287
+ // src/components/Toast/Toast.tsx
4288
+ var import_jsx_runtime71 = require("react/jsx-runtime");
4289
+ var variantIcons = {
4290
+ info: import_icons14.circleInfo,
4291
+ success: import_icons14.circleCheck,
4292
+ warning: import_icons14.triangleExclamation,
4293
+ error: import_icons14.circleExclamation
4294
+ };
4295
+ var variantColors = {
4296
+ info: "var(--color-info)",
4297
+ success: "var(--color-valid)",
4298
+ warning: "var(--color-warning)",
4299
+ error: "var(--color-error)"
4300
+ };
4301
+ var ToastIcon = ({ variant }) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "mobius-toast__icon", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Icon, { icon: variantIcons[variant], color: variantColors[variant] }) });
4302
+ var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "mobius-toast__close-icon", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Icon, { icon: import_icons14.cross }) });
4303
+ var ToastContent = ({
4304
+ toastId,
4305
+ variant,
4306
+ title,
4307
+ description,
4308
+ action,
4309
+ cancel,
4310
+ showCloseButton = toastState.showCloseButton
4311
+ }) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: (0, import_dedupe61.default)("mobius", "mobius-toast", `--${variant}`), children: [
4312
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ToastIcon, { variant }),
4313
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "mobius-toast__body", children: [
4314
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "mobius-toast__content", children: [
4315
+ title && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "mobius-toast__title", children: title }),
4316
+ description && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "mobius-toast__description", children: description })
4317
+ ] }),
4318
+ (action || cancel) && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "mobius-toast__actions", children: [
4319
+ cancel && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
4320
+ "button",
4321
+ {
4322
+ type: "button",
4323
+ className: "mobius-toast__cancel",
4324
+ onClick: () => {
4325
+ cancel.onClick?.();
4326
+ import_sonner.toast.dismiss(toastId);
4327
+ },
4328
+ children: cancel.label
4329
+ }
4330
+ ),
4331
+ action && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
4332
+ "button",
4333
+ {
4334
+ type: "button",
4335
+ className: "mobius-toast__action",
4336
+ onClick: () => {
4337
+ action.onClick();
4338
+ import_sonner.toast.dismiss(toastId);
4339
+ },
4340
+ children: action.label
4341
+ }
4342
+ )
4343
+ ] })
4344
+ ] }),
4345
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
4346
+ "button",
4347
+ {
4348
+ type: "button",
4349
+ className: "mobius-toast__close",
4350
+ onClick: () => import_sonner.toast.dismiss(toastId),
4351
+ "aria-label": "Close",
4352
+ children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CloseIcon, {})
4353
+ }
4354
+ )
4355
+ ] });
4356
+ var createCustomToast = (message, variant, options) => import_sonner.toast.custom(
4357
+ (id) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
4358
+ ToastContent,
4359
+ {
4360
+ toastId: id,
4361
+ variant,
4362
+ title: options?.title,
4363
+ description: options?.description ?? message,
4364
+ action: options?.action,
4365
+ cancel: options?.cancel,
4366
+ showCloseButton: options?.showCloseButton
4367
+ }
4368
+ ),
4369
+ {
4370
+ duration: options?.duration,
4371
+ onDismiss: options?.onDismiss,
4372
+ onAutoClose: options?.onAutoClose
4373
+ }
4374
+ );
4375
+ var toast = {
4376
+ /** Show an info toast */
4377
+ info: (message, options) => createCustomToast(message, "info", options),
4378
+ /** Show a success toast */
4379
+ success: (message, options) => createCustomToast(message, "success", options),
4380
+ /** Show a warning toast */
4381
+ warning: (message, options) => createCustomToast(message, "warning", options),
4382
+ /** Show an error toast */
4383
+ error: (message, options) => createCustomToast(message, "error", options),
4384
+ /** Dismiss a specific toast by ID or all toasts */
4385
+ dismiss: (toastId) => import_sonner.toast.dismiss(toastId)
4386
+ };
4387
+
4388
+ // src/components/Toast/Toaster.tsx
4389
+ var import_react44 = require("react");
4390
+ var import_sonner2 = require("sonner");
4391
+ var import_jsx_runtime72 = require("react/jsx-runtime");
4392
+ var Toaster = ({
4393
+ position = "top-right",
4394
+ closeButton = true,
4395
+ expand = false,
4396
+ duration = 4e3,
4397
+ visibleToasts = 3,
4398
+ gap = 8
4399
+ }) => {
4400
+ (0, import_react44.useEffect)(() => {
4401
+ toastState.showCloseButton = closeButton;
4402
+ }, [closeButton]);
4403
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
4404
+ import_sonner2.Toaster,
4405
+ {
4406
+ position,
4407
+ closeButton: false,
4408
+ expand,
4409
+ duration,
4410
+ visibleToasts,
4411
+ gap
4412
+ }
4413
+ );
4414
+ };
4415
+ Toaster.displayName = "Toaster";
4416
+
4417
+ // src/components/Trust/Trust.tsx
4418
+ var import_dedupe62 = __toESM(require("classnames/dedupe"));
4419
+ var import_react45 = require("react");
4420
+
4421
+ // src/components/Trust/constants.ts
4422
+ var REQUIRED_TRUSTPILOT_CLASS_NAME = "trustpilot-widget";
4423
+ var SIMPLYBUSINESS_UNIT_ID = "5ca35a3da72b330001954cef";
4424
+ var SIMPLYBUSINESS_UNIT_IDS = {
4425
+ "en-US": "5ca35a3da72b330001954cef",
4426
+ // US business unit ID
4427
+ "en-GB": "56b1db010000ff0005887125"
4428
+ // UK business unit ID
4429
+ };
4430
+ var TRUSTPILOT_LINKS = {
4431
+ "en-US": "https://www.trustpilot.com/review/simplybusiness.com",
4432
+ "en-GB": "https://www.trustpilot.com/review/simplybusiness.co.uk"
4433
+ };
4434
+ var TRUSTPILOT_TEMPLATE_IDS = {
4435
+ "micro-combo": "5419b6ffb0d04a076446a9af",
4436
+ mini: "53aa8807dec7e10d38f59f32",
4437
+ carousel: "53aa8912dec7e10d38f59f36",
4438
+ horizontal: "5406e65db0d04a09e042d5fc",
4439
+ "micro-star": "5419b732fbfb950b10de65e5"
4440
+ };
4441
+ var TRUSTPILOT_WIDGET = {
4442
+ // Keys based on actual widget names
4443
+ // https://support.trustpilot.com/hc/en-us/articles/360019826379-TrustBox-widget-overview
4444
+ "micro-combo": {
4445
+ templateId: TRUSTPILOT_TEMPLATE_IDS["micro-combo"],
4446
+ className: "--is-variant-micro-combo",
4447
+ styles: {
4448
+ height: "25px"
4449
+ }
4450
+ },
4451
+ mini: {
4452
+ templateId: TRUSTPILOT_TEMPLATE_IDS["mini"],
4453
+ className: "--is-variant-mini",
4454
+ styles: {
4455
+ width: "300px",
4456
+ height: "150px"
4457
+ }
4458
+ },
4459
+ carousel: {
4460
+ templateId: TRUSTPILOT_TEMPLATE_IDS["carousel"],
4461
+ className: "--is-variant-carousel",
4462
+ styles: {
4463
+ height: "150px"
4464
+ }
4465
+ },
4466
+ horizontal: {
4467
+ templateId: TRUSTPILOT_TEMPLATE_IDS["horizontal"],
4468
+ className: "--is-variant-horizontal",
4469
+ styles: {
4470
+ height: "28px"
4471
+ }
4472
+ },
4473
+ "micro-star": {
4474
+ templateId: TRUSTPILOT_TEMPLATE_IDS["micro-star"],
4475
+ className: "--is-variant-micro-star",
4476
+ styles: {
4477
+ height: "24px"
4478
+ }
4479
+ }
4480
+ };
4481
+
4482
+ // src/components/Trust/Trust.tsx
4483
+ var import_jsx_runtime73 = require("react/jsx-runtime");
4484
+ var Trust = ({ ref, ...props }) => {
4485
+ const {
4486
+ elementType: Element = "div",
4487
+ variant,
4488
+ theme,
4489
+ locale,
4490
+ height,
4491
+ width,
4492
+ stars,
4493
+ className
4494
+ } = props;
4495
+ const [isMounted, setIsMounted] = (0, import_react45.useState)(false);
4496
+ const trustRef = (0, import_react45.useRef)(null);
4497
+ const {
4498
+ templateId,
4499
+ className: variantClassName,
4500
+ styles
4501
+ } = TRUSTPILOT_WIDGET[variant];
4502
+ const link = TRUSTPILOT_LINKS[locale];
4503
+ const businessUnitId = SIMPLYBUSINESS_UNIT_IDS[locale] || SIMPLYBUSINESS_UNIT_ID;
4504
+ const dataProps = {
4505
+ "data-businessunit-id": businessUnitId,
4506
+ "data-locale": locale,
4507
+ "data-template-id": templateId,
4508
+ "data-theme": theme,
4509
+ "data-style-width": width || "100%",
4510
+ "data-style-height": height,
4511
+ "data-stars": stars
4512
+ };
4513
+ const classes = (0, import_dedupe62.default)(
4514
+ "mobius",
4515
+ "mobius-trust",
4516
+ REQUIRED_TRUSTPILOT_CLASS_NAME,
4517
+ {
4518
+ [`--is-${theme}`]: theme,
4519
+ [variantClassName]: variant
4520
+ },
4521
+ className
4522
+ );
4523
+ (0, import_react45.useEffect)(() => {
4524
+ const hasTrustpilotLoaded = trustRef.current && window?.Trustpilot && window?.Trustpilot.loadFromElement;
4525
+ if (isMounted && hasTrustpilotLoaded) {
4526
+ window.Trustpilot.loadFromElement(trustRef.current, true);
4527
+ }
4528
+ }, [isMounted]);
4529
+ (0, import_react45.useEffect)(() => {
4530
+ setIsMounted(true);
4531
+ }, []);
4532
+ if (!isMounted) return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { style: styles });
4533
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
4534
+ Element,
4535
+ {
4536
+ ref: mergeRefs([trustRef, ref]),
4537
+ className: classes,
4538
+ style: styles,
4539
+ ...dataProps,
4540
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
4541
+ "a",
4542
+ {
4543
+ href: link,
4544
+ target: "_blank",
4545
+ rel: "noopener noreferrer",
4546
+ className: "mobius-trust__link",
4547
+ children: "Trustpilot"
4548
+ }
4549
+ )
4550
+ }
4551
+ );
4552
+ };
4553
+
4554
+ // src/components/ExpandableText/ExpandableText.tsx
4555
+ var import_dedupe63 = __toESM(require("classnames/dedupe"));
4556
+ var import_react46 = require("react");
4557
+ var import_jsx_runtime74 = require("react/jsx-runtime");
4558
+ var ExpandableText = ({ ref, ...props }) => {
4559
+ const {
4560
+ text,
4561
+ maxLines = 3,
4562
+ breakpoint,
4563
+ showText = "Read more",
4564
+ hideText = "Read less",
4565
+ className,
4566
+ textProps = {},
4567
+ accordionProps = {},
4568
+ onToggle,
4569
+ ...otherProps
4570
+ } = props;
4571
+ const [isExpanded, setIsExpanded] = (0, import_react46.useState)(false);
4572
+ const [isCollapsed, setIsCollapsed] = (0, import_react46.useState)(false);
4573
+ const textRef = (0, import_react46.useRef)(null);
4574
+ const { down } = useBreakpoint();
4575
+ const baseId = (0, import_react46.useId)();
4576
+ const expandButtonId = `expandable-text-expand-${baseId}`;
4577
+ const shouldCollapse = breakpoint ? down(breakpoint) : true;
4578
+ (0, import_react46.useEffect)(() => {
4579
+ if (!shouldCollapse || !textRef.current) {
4580
+ setIsCollapsed(false);
4581
+ return;
4582
+ }
4583
+ const element = textRef.current;
4584
+ const isOverflowing = element.scrollHeight > element.clientHeight;
4585
+ setIsCollapsed(isOverflowing);
4586
+ }, [text, shouldCollapse, maxLines]);
4587
+ if (breakpoint && !shouldCollapse) {
4588
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { ref, className, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(TextOrHTML, { text, textWrapper: true, ...textProps }) });
4589
+ }
4590
+ const handleAccordionChange = (expanded) => {
4591
+ setIsExpanded(expanded);
4592
+ onToggle?.(expanded);
4593
+ };
4594
+ const classes = (0, import_dedupe63.default)("mobius-expandable-text", className);
4595
+ const textContainerClasses = (0, import_dedupe63.default)("mobius-expandable-text__content", {
4596
+ "mobius-expandable-text__content--collapsed": !isExpanded
4597
+ });
4598
+ const textContainerStyle = {
4599
+ "--line-clamp": maxLines
4600
+ };
4601
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
4602
+ "div",
4603
+ {
4604
+ ref,
4605
+ className: classes,
4606
+ "data-testid": "expandable-text",
4607
+ ...otherProps,
4608
+ children: [
4609
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
4610
+ "div",
4611
+ {
4612
+ ref: textRef,
4613
+ className: textContainerClasses,
4614
+ style: textContainerStyle,
4615
+ "data-testid": "expandable-text-content",
4616
+ "aria-describedby": isCollapsed ? expandButtonId : void 0,
4617
+ children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(TextOrHTML, { elementType: "span", textWrapper: true, text, ...textProps })
4618
+ }
4619
+ ),
4620
+ isCollapsed && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
4621
+ Accordion,
4622
+ {
4623
+ showText,
4624
+ hideText,
4625
+ headerPosition: "bottom",
4626
+ onChange: handleAccordionChange,
4627
+ onClick: (e) => {
4628
+ e?.stopPropagation();
4629
+ },
4630
+ id: expandButtonId,
4631
+ ...accordionProps
4632
+ }
4633
+ )
4634
+ ]
4635
+ }
4636
+ );
4637
+ };
4638
+ ExpandableText.displayName = "ExpandableText";
4639
+
4640
+ // src/components/MaskedField/MaskedField.tsx
4641
+ var import_react47 = require("react");
4642
+ var import_react_imask = require("react-imask");
4643
+ var import_jsx_runtime75 = require("react/jsx-runtime");
4644
+ var useAcceptHandler = (onChange, useMaskedValue, name) => {
4645
+ return (0, import_react47.useCallback)(
4646
+ (maskedValue, maskInstance) => {
4647
+ if (!onChange) {
4648
+ return;
4649
+ }
4650
+ const formattedValue = maskedValue;
4651
+ const rawValue = maskInstance.unmaskedValue;
4652
+ const valueToEmit = useMaskedValue ? formattedValue : rawValue;
4653
+ onChange({
4654
+ target: { name, value: valueToEmit }
4655
+ });
4656
+ },
4657
+ [onChange, useMaskedValue, name]
4658
+ );
4659
+ };
4660
+ var useCombinedRef = (imaskRef, forwardedRef) => {
4661
+ return (0, import_react47.useCallback)(
4662
+ (element) => {
4663
+ imaskRef.current = element;
4664
+ if (typeof forwardedRef === "function") {
4665
+ forwardedRef(element);
4666
+ } else if (forwardedRef) {
4667
+ forwardedRef.current = element;
4668
+ }
4669
+ },
4670
+ [imaskRef, forwardedRef]
4671
+ );
4672
+ };
4673
+ var useBlurHandler = (onBlur, maskRef, useMaskedValue, name) => {
4674
+ return (0, import_react47.useCallback)(
4675
+ (event) => {
4676
+ if (!onBlur || !maskRef.current) {
4677
+ return;
4678
+ }
4679
+ const formattedValue = maskRef.current.value;
4680
+ const rawValue = maskRef.current.unmaskedValue;
4681
+ const valueToEmit = useMaskedValue ? formattedValue : rawValue;
4682
+ onBlur({
4683
+ ...event,
4684
+ target: { ...event.target, name, value: valueToEmit }
4685
+ });
4686
+ },
4687
+ [onBlur, maskRef, useMaskedValue, name]
4688
+ );
4689
+ };
4690
+ var ControlledMaskedField = ({
4691
+ mask,
4692
+ useMaskedValue = false,
4693
+ value,
4694
+ onChange,
4695
+ onBlur,
4696
+ name,
4697
+ forwardedRef,
4698
+ ...textFieldProps
4699
+ }) => {
4700
+ const onAccept = useAcceptHandler(onChange, useMaskedValue, name);
4701
+ const { ref: imaskRef, maskRef, setValue } = (0, import_react_imask.useIMask)(mask, { onAccept });
4702
+ const combinedRef = useCombinedRef(imaskRef, forwardedRef);
4703
+ const handleBlur = useBlurHandler(onBlur, maskRef, useMaskedValue, name);
4704
+ (0, import_react47.useEffect)(() => {
4705
+ if (!maskRef.current) {
4706
+ return;
4707
+ }
4708
+ const stringValue = value.toString();
4709
+ const currentMasked = maskRef.current.value;
4710
+ const currentUnmasked = maskRef.current.unmaskedValue;
4711
+ if (currentMasked !== stringValue && currentUnmasked !== stringValue) {
4712
+ setValue(stringValue);
4713
+ }
4714
+ }, [value, maskRef, setValue, imaskRef]);
4715
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
4716
+ TextField,
4717
+ {
4718
+ ...textFieldProps,
4719
+ ref: combinedRef,
4720
+ name,
4721
+ onBlur: handleBlur
4722
+ }
4723
+ );
4724
+ };
4725
+ var UncontrolledMaskedField = ({
4726
+ mask,
4727
+ useMaskedValue = false,
4728
+ defaultValue,
4729
+ onChange,
4730
+ onBlur,
4731
+ name,
4732
+ forwardedRef,
4733
+ ...textFieldProps
4734
+ }) => {
4735
+ const onAccept = useAcceptHandler(onChange, useMaskedValue, name);
4736
+ const { ref: imaskRef, maskRef } = (0, import_react_imask.useIMask)(mask, { onAccept });
4737
+ const combinedRef = useCombinedRef(imaskRef, forwardedRef);
4738
+ const handleBlur = useBlurHandler(onBlur, maskRef, useMaskedValue, name);
4739
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
4740
+ TextField,
4741
+ {
4742
+ ...textFieldProps,
4743
+ ref: combinedRef,
4744
+ name,
4745
+ onBlur: handleBlur,
4746
+ defaultValue: defaultValue?.toString()
4747
+ }
4748
+ );
4749
+ };
4750
+ var MaskedField = ({ ref: forwardedRef, ...props }) => {
4751
+ const { value, defaultValue, ...rest } = props;
4752
+ if ("value" in props) {
4753
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
4754
+ ControlledMaskedField,
4755
+ {
4756
+ ...rest,
4757
+ value: value ?? "",
4758
+ forwardedRef
4759
+ }
4760
+ );
4761
+ } else {
4762
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
4763
+ UncontrolledMaskedField,
4764
+ {
4765
+ ...rest,
4766
+ defaultValue,
4767
+ forwardedRef
4768
+ }
4769
+ );
4770
+ }
4771
+ };
4772
+ MaskedField.displayName = "MaskedField";
4773
+ //# sourceMappingURL=index.js.map