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