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