@simplybusiness/mobius 8.0.2 → 9.0.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 +46 -0
- package/dist/cjs/index.js +577 -733
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/meta.json +295 -520
- package/dist/esm/index.js +542 -694
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/meta.json +300 -532
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -7
- package/dist/types/src/utils/htmlDialogPolyfill.d.ts +1 -0
- package/dist/types/src/utils/index.d.ts +0 -1
- package/dist/types/src/utils/mockMatchMedia.d.ts +1 -0
- package/dist/types/vitest.config.d.ts +2 -0
- package/package.json +18 -24
- package/src/components/Accordion/Accordion.stories.tsx +1 -1
- package/src/components/Accordion/Accordion.test.tsx +12 -12
- package/src/components/Accordion/Accordion.tsx +1 -1
- package/src/components/Accordion/AccordionList.stories.tsx +1 -1
- package/src/components/Accordion/AccordionList.test.tsx +6 -6
- package/src/components/AddressLookup/AddressLookup.stories.tsx +1 -1
- package/src/components/AddressLookup/AddressLookup.test.tsx +19 -20
- package/src/components/AddressLookup/LoqateAddressLookupService.test.tsx +7 -6
- package/src/components/Alert/Alert.stories.tsx +1 -1
- package/src/components/Box/Box.stories.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
- package/src/components/Button/Button.stories.tsx +3 -4
- package/src/components/Button/Button.test.tsx +4 -4
- package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/CheckboxGroup.stories.tsx +1 -1
- package/src/components/Checkbox/CheckboxGroup.test.tsx +5 -5
- package/src/components/Combobox/Combobox.stories.tsx +1 -1
- package/src/components/Combobox/Combobox.test.tsx +67 -78
- package/src/components/Combobox/Combobox.tsx +2 -1
- package/src/components/Combobox/useComboboxOptions.test.ts +30 -30
- package/src/components/Combobox/useComboboxOptions.ts +1 -1
- package/src/components/Container/Container.stories.tsx +1 -1
- package/src/components/DateField/DateField.stories.tsx +1 -1
- package/src/components/DateField/DateField.test.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +1 -1
- package/src/components/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/Drawer/Drawer.test.tsx +6 -6
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +8 -10
- package/src/components/DropdownMenu/DropdownMenu.test.tsx +1 -1
- package/src/components/ErrorMessage/ErrorMessage.stories.tsx +1 -1
- package/src/components/ExpandableText/ExpandableText.test.tsx +14 -14
- package/src/components/Fieldset/Fieldset.stories.tsx +1 -1
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Grid/Grid.stories.tsx +4 -7
- package/src/components/Icon/Icon.stories.tsx +1 -1
- package/src/components/Image/Image.stories.tsx +1 -1
- package/src/components/Label/Label.stories.tsx +1 -1
- package/src/components/Link/Link.stories.tsx +1 -1
- package/src/components/Link/Link.test.tsx +1 -1
- package/src/components/LinkButton/LinkButton.stories.tsx +1 -1
- package/src/components/LinkButton/LinkButton.test.tsx +2 -2
- package/src/components/List/List.stories.tsx +1 -1
- package/src/components/LoadingIndicator/LoadingIndicator.stories.tsx +1 -1
- package/src/components/Logo/Logo.stories.tsx +1 -1
- package/src/components/Modal/Modal.stories.tsx +1 -1
- package/src/components/Modal/Modal.test.tsx +6 -6
- package/src/components/NumberField/NumberField.stories.tsx +1 -1
- package/src/components/NumberField/NumberField.test.tsx +5 -5
- package/src/components/PasswordField/PasswordField.stories.tsx +1 -1
- package/src/components/Popover/Popover.stories.tsx +4 -8
- package/src/components/Popover/Popover.test.tsx +4 -4
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/Progress/Progress.stories.tsx +1 -1
- package/src/components/Radio/Radio.stories.tsx +1 -1
- package/src/components/Radio/Radio.test.tsx +9 -9
- package/src/components/SVG/SVG.stories.tsx +1 -1
- package/src/components/Segment/Segment.stories.tsx +1 -1
- package/src/components/Select/Select.stories.tsx +1 -1
- package/src/components/Select/Select.test.tsx +1 -1
- package/src/components/Slider/Slider.stories.tsx +1 -1
- package/src/components/Slider/Slider.test.tsx +6 -6
- package/src/components/Slider/helpers.test.ts +1 -1
- package/src/components/Stack/Stack.stories.tsx +1 -1
- package/src/components/Switch/Switch.stories.tsx +1 -1
- package/src/components/Switch/Switch.test.tsx +1 -1
- package/src/components/Table/Table.stories.tsx +1 -1
- package/src/components/Text/Text.stories.tsx +1 -1
- package/src/components/TextArea/TextArea.stories.tsx +1 -1
- package/src/components/TextArea/TextArea.test.tsx +3 -3
- package/src/components/TextField/TextField.stories.tsx +1 -1
- package/src/components/TextOrHTML/TextOrHTML.stories.tsx +1 -1
- package/src/components/Title/Title.stories.tsx +1 -1
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/Toast/Toast.test.tsx +6 -6
- package/src/components/Trust/Trust.stories.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +1 -1
- package/src/hooks/index.tsx +0 -7
- package/src/hooks/useBreakpoint/useBreakpoint.ssr.test.tsx +18 -0
- package/src/hooks/useBreakpoint/useBreakpoint.stories.tsx +1 -1
- package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +57 -5
- package/src/hooks/useBreakpoint/useBreakpoint.tsx +25 -39
- package/src/hooks/useButton/useButton.test.tsx +4 -4
- package/src/hooks/useDialog/useDialog.ts +1 -1
- package/src/hooks/useLabel/useLabel.test.tsx +1 -1
- package/src/hooks/useTextField/useTextField.test.tsx +4 -4
- package/src/public-whitelist.test.ts +1 -0
- package/src/utils/delay.test.ts +4 -4
- package/src/utils/{jestHTMLDialogPolyfill.ts → htmlDialogPolyfill.ts} +5 -5
- package/src/utils/index.ts +0 -1
- package/src/utils/mockMatchMedia.ts +16 -0
- package/dist/types/src/hooks/useBodyScrollLock/index.d.ts +0 -1
- package/dist/types/src/hooks/useBodyScrollLock/useBodyScrollLock.d.ts +0 -3
- package/dist/types/src/hooks/useDebouncedValue/index.d.ts +0 -1
- package/dist/types/src/hooks/useDebouncedValue/useDebouncedValue.d.ts +0 -1
- package/dist/types/src/hooks/useOnClickOutside/index.d.ts +0 -1
- package/dist/types/src/hooks/useOnClickOutside/useOnClickOutside.d.ts +0 -2
- package/dist/types/src/hooks/useOnUnmount/index.d.ts +0 -1
- package/dist/types/src/hooks/useOnUnmount/useOnUnmount.d.ts +0 -1
- package/dist/types/src/hooks/usePrefersReducedMotion/index.d.ts +0 -1
- package/dist/types/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.d.ts +0 -1
- package/dist/types/src/hooks/useRenderCount/index.d.ts +0 -1
- package/dist/types/src/hooks/useRenderCount/useRenderCount.d.ts +0 -1
- package/dist/types/src/hooks/useWindowEvent/index.d.ts +0 -1
- package/dist/types/src/hooks/useWindowEvent/useWindowEvent.d.ts +0 -1
- package/dist/types/src/utils/jestHTMLDialogPolyfill.d.ts +0 -1
- package/dist/types/src/utils/jestMockMatchMedia.d.ts +0 -1
- package/src/hooks/useBodyScrollLock/index.ts +0 -1
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.test.ts +0 -34
- package/src/hooks/useBodyScrollLock/useBodyScrollLock.ts +0 -30
- package/src/hooks/useDebouncedValue/index.tsx +0 -1
- package/src/hooks/useDebouncedValue/useDebouncedValue.test.tsx +0 -62
- package/src/hooks/useDebouncedValue/useDebouncedValue.tsx +0 -25
- package/src/hooks/useOnClickOutside/index.tsx +0 -1
- package/src/hooks/useOnClickOutside/useOnClickOutside.test.tsx +0 -189
- package/src/hooks/useOnClickOutside/useOnClickOutside.tsx +0 -44
- package/src/hooks/useOnUnmount/index.tsx +0 -1
- package/src/hooks/useOnUnmount/useOnUnmount.test.tsx +0 -37
- package/src/hooks/useOnUnmount/useOnUnmount.tsx +0 -8
- package/src/hooks/usePrefersReducedMotion/index.tsx +0 -1
- package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.test.tsx +0 -48
- package/src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.tsx +0 -22
- package/src/hooks/useRenderCount/index.ts +0 -1
- package/src/hooks/useRenderCount/useRenderCount.test.ts +0 -26
- package/src/hooks/useRenderCount/useRenderCount.ts +0 -9
- package/src/hooks/useWindowEvent/index.tsx +0 -1
- package/src/hooks/useWindowEvent/useWindowEvent.test.tsx +0 -188
- package/src/hooks/useWindowEvent/useWindowEvent.tsx +0 -41
- package/src/utils/jestMockMatchMedia.ts +0 -16
package/dist/esm/index.js
CHANGED
|
@@ -8,549 +8,73 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
8
8
|
|
|
9
9
|
// src/components/Accordion/Accordion.tsx
|
|
10
10
|
import classNames4 from "classnames/dedupe";
|
|
11
|
-
import { useEffect
|
|
12
|
-
|
|
13
|
-
// src/hooks/useBodyScrollLock/useBodyScrollLock.ts
|
|
14
|
-
import { useEffect } from "react";
|
|
15
|
-
function useBodyScrollLock({
|
|
16
|
-
enabled = true
|
|
17
|
-
} = {}) {
|
|
18
|
-
function disableScrollLock() {
|
|
19
|
-
document.body.style.removeProperty("overflow");
|
|
20
|
-
document.body.style.removeProperty("scrollbar-gutter");
|
|
21
|
-
document.documentElement.style.removeProperty("scrollbar-gutter");
|
|
22
|
-
}
|
|
23
|
-
function enableScrollLock() {
|
|
24
|
-
document.body.style.overflow = "hidden";
|
|
25
|
-
document.body.style.scrollbarGutter = "stable";
|
|
26
|
-
document.documentElement.style.scrollbarGutter = "stable";
|
|
27
|
-
}
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (enabled) {
|
|
30
|
-
enableScrollLock();
|
|
31
|
-
} else {
|
|
32
|
-
disableScrollLock();
|
|
33
|
-
}
|
|
34
|
-
return () => {
|
|
35
|
-
disableScrollLock();
|
|
36
|
-
};
|
|
37
|
-
}, [enabled]);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// src/hooks/useBreakpoint/useBreakpoint.tsx
|
|
41
|
-
import debounce from "lodash.debounce";
|
|
42
|
-
import { useCallback, useEffect as useEffect2, useState } from "react";
|
|
43
|
-
var DEFAULT_BREAKPOINTS = [
|
|
44
|
-
{ size: "xs", value: 320 },
|
|
45
|
-
{ size: "sm", value: 480 },
|
|
46
|
-
{ size: "md", value: 670 },
|
|
47
|
-
{ size: "lg", value: 960 },
|
|
48
|
-
{ size: "xl", value: 1200 },
|
|
49
|
-
{ size: "xxl", value: 1320 }
|
|
50
|
-
];
|
|
51
|
-
var getBreakpoint = (breakpoints, windowWidth) => {
|
|
52
|
-
const closest = breakpoints.findIndex(
|
|
53
|
-
(breakpoint) => breakpoint.value >= windowWidth + 1
|
|
54
|
-
);
|
|
55
|
-
const smallest = breakpoints[0];
|
|
56
|
-
const largest = breakpoints[breakpoints.length - 1];
|
|
57
|
-
const match = breakpoints[closest - 1];
|
|
58
|
-
if (closest === 0) return smallest;
|
|
59
|
-
if (closest === -1) return largest;
|
|
60
|
-
return match;
|
|
61
|
-
};
|
|
62
|
-
var useBreakpoint = (customBreakpoints) => {
|
|
63
|
-
const window2 = globalThis?.window || void 0;
|
|
64
|
-
const isClientSide = typeof window2 !== "undefined";
|
|
65
|
-
const breakpoints = customBreakpoints || DEFAULT_BREAKPOINTS;
|
|
66
|
-
const defaultBreakpoint = breakpoints[0];
|
|
67
|
-
const [windowWidth, setWindowWidth] = useState(
|
|
68
|
-
isClientSide ? window2.innerWidth : defaultBreakpoint.value
|
|
69
|
-
);
|
|
70
|
-
const [currentBreakpoint, setCurrentBreakpoint] = useState(defaultBreakpoint);
|
|
71
|
-
const handleResize = () => {
|
|
72
|
-
setWindowWidth(window2.innerWidth);
|
|
73
|
-
};
|
|
74
|
-
useEffect2(() => {
|
|
75
|
-
if (!windowWidth || breakpoints.length === 0) {
|
|
76
|
-
setCurrentBreakpoint(breakpoints[0]);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const newBreakpoint = getBreakpoint(breakpoints, windowWidth);
|
|
80
|
-
if (currentBreakpoint.size === newBreakpoint?.size) return;
|
|
81
|
-
setCurrentBreakpoint(newBreakpoint);
|
|
82
|
-
}, [currentBreakpoint, windowWidth, breakpoints]);
|
|
83
|
-
useEffect2(() => {
|
|
84
|
-
window2.addEventListener("resize", debounce(handleResize, 200), {
|
|
85
|
-
passive: true
|
|
86
|
-
});
|
|
87
|
-
return () => window2.removeEventListener("resize", handleResize);
|
|
88
|
-
}, [window2]);
|
|
89
|
-
const up = useCallback(
|
|
90
|
-
(size) => {
|
|
91
|
-
const sizeIndex = breakpoints.findIndex((item) => item.size === size);
|
|
92
|
-
if (sizeIndex === -1) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
const currentIndex = breakpoints.findIndex(
|
|
96
|
-
(item) => item.size === currentBreakpoint.size
|
|
97
|
-
);
|
|
98
|
-
return currentIndex >= sizeIndex;
|
|
99
|
-
},
|
|
100
|
-
[currentBreakpoint, breakpoints]
|
|
101
|
-
);
|
|
102
|
-
const down = useCallback(
|
|
103
|
-
(size) => {
|
|
104
|
-
const sizeIndex = breakpoints.findIndex((item) => item.size === size);
|
|
105
|
-
if (sizeIndex === -1) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
const currentIndex = breakpoints.findIndex(
|
|
109
|
-
(item) => item.size === currentBreakpoint.size
|
|
110
|
-
);
|
|
111
|
-
return currentIndex <= sizeIndex;
|
|
112
|
-
},
|
|
113
|
-
[currentBreakpoint, breakpoints]
|
|
114
|
-
);
|
|
115
|
-
return {
|
|
116
|
-
breakpoint: isClientSide ? currentBreakpoint : defaultBreakpoint,
|
|
117
|
-
up,
|
|
118
|
-
down
|
|
119
|
-
};
|
|
120
|
-
};
|
|
11
|
+
import { useEffect, useState, useId } from "react";
|
|
12
|
+
import { usePrefersReducedMotion } from "@simplybusiness/mobius-hooks";
|
|
121
13
|
|
|
122
|
-
// src/
|
|
123
|
-
import
|
|
124
|
-
function useButton({
|
|
125
|
-
elementType = "button",
|
|
126
|
-
type = "button",
|
|
127
|
-
isDisabled = false,
|
|
128
|
-
href,
|
|
129
|
-
target,
|
|
130
|
-
rel,
|
|
131
|
-
role,
|
|
132
|
-
name,
|
|
133
|
-
value,
|
|
134
|
-
onClick,
|
|
135
|
-
onPress
|
|
136
|
-
}) {
|
|
137
|
-
const realOnClick = useCallback2(
|
|
138
|
-
(event) => {
|
|
139
|
-
if (isDisabled) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
onClick?.(event);
|
|
143
|
-
onPress?.(event);
|
|
144
|
-
},
|
|
145
|
-
[isDisabled, onClick, onPress]
|
|
146
|
-
);
|
|
147
|
-
function getRole() {
|
|
148
|
-
if (role) {
|
|
149
|
-
return role;
|
|
150
|
-
}
|
|
151
|
-
if (elementType === "a") {
|
|
152
|
-
return void 0;
|
|
153
|
-
}
|
|
154
|
-
return "button";
|
|
155
|
-
}
|
|
156
|
-
const extraProps = elementType === "button" ? { type } : {
|
|
157
|
-
role: getRole()
|
|
158
|
-
};
|
|
159
|
-
return {
|
|
160
|
-
buttonProps: {
|
|
161
|
-
href: elementType === "a" ? href : void 0,
|
|
162
|
-
target: elementType === "a" ? target : void 0,
|
|
163
|
-
rel: elementType === "a" ? rel : void 0,
|
|
164
|
-
tabIndex: isDisabled ? -1 : 0,
|
|
165
|
-
disabled: isDisabled || void 0,
|
|
166
|
-
"aria-disabled": isDisabled || void 0,
|
|
167
|
-
name: elementType === "input" || elementType === "button" ? name : void 0,
|
|
168
|
-
value: elementType === "input" || elementType === "button" ? value : void 0,
|
|
169
|
-
...extraProps,
|
|
170
|
-
onClick: realOnClick
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// src/hooks/useDebouncedValue/useDebouncedValue.tsx
|
|
176
|
-
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
177
|
-
function useDebouncedValue(value, delay = 0) {
|
|
178
|
-
const [debouncedValue, setDebouncedValue] = useState2(value);
|
|
179
|
-
useEffect3(() => {
|
|
180
|
-
let timeout = null;
|
|
181
|
-
if (delay === 0) {
|
|
182
|
-
setDebouncedValue(value);
|
|
183
|
-
} else {
|
|
184
|
-
timeout = setTimeout(() => {
|
|
185
|
-
setDebouncedValue(value);
|
|
186
|
-
}, delay);
|
|
187
|
-
}
|
|
188
|
-
return () => {
|
|
189
|
-
if (timeout) {
|
|
190
|
-
clearTimeout(timeout);
|
|
191
|
-
timeout = null;
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}, [value, delay]);
|
|
195
|
-
return debouncedValue;
|
|
196
|
-
}
|
|
14
|
+
// src/components/Accordion/AccordionLink.tsx
|
|
15
|
+
import classNames3 from "classnames/dedupe";
|
|
197
16
|
|
|
198
|
-
// src/
|
|
199
|
-
import
|
|
17
|
+
// src/components/Flex/Flex.tsx
|
|
18
|
+
import classNames from "classnames/dedupe";
|
|
200
19
|
|
|
201
20
|
// src/utils/filterUndefinedProps.ts
|
|
202
21
|
var filterUndefinedProps = (props) => {
|
|
203
22
|
const filteredProps = {};
|
|
204
23
|
Object.keys(props).forEach((key) => {
|
|
205
24
|
if (props[key] !== void 0) {
|
|
206
|
-
filteredProps[key] = props[key];
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
return filteredProps;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// src/utils/getSpacingValue.ts
|
|
213
|
-
var getSpacingValue = (padding) => {
|
|
214
|
-
if (typeof padding === "string") {
|
|
215
|
-
return `var(--size-${padding})`;
|
|
216
|
-
}
|
|
217
|
-
if (typeof padding === "number") {
|
|
218
|
-
return `${padding}px`;
|
|
219
|
-
}
|
|
220
|
-
return void 0;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
// src/utils/mergeRefs.ts
|
|
224
|
-
function mergeRefs(refs) {
|
|
225
|
-
return (value) => {
|
|
226
|
-
refs.forEach((ref) => {
|
|
227
|
-
if (typeof ref === "function") {
|
|
228
|
-
ref(value);
|
|
229
|
-
} else if (ref != null) {
|
|
230
|
-
ref.current = value;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/utils/polyfill-tests.ts
|
|
237
|
-
var supportsDialog = () => typeof HTMLDialogElement === "function";
|
|
238
|
-
|
|
239
|
-
// src/utils/sizeClasses.ts
|
|
240
|
-
var sizeClasses = (size) => {
|
|
241
|
-
if (!size) {
|
|
242
|
-
return {};
|
|
243
|
-
}
|
|
244
|
-
return {
|
|
245
|
-
"--is-xxs": size === "xxs",
|
|
246
|
-
"--is-xs": size === "xs",
|
|
247
|
-
"--is-sm": size === "sm",
|
|
248
|
-
"--is-md": size === "md",
|
|
249
|
-
"--is-lg": size === "lg",
|
|
250
|
-
"--is-xl": size === "xl",
|
|
251
|
-
"--is-xxl": size === "xxl"
|
|
252
|
-
};
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// src/utils/spaceDelimitedList.ts
|
|
256
|
-
function spaceDelimitedList(list) {
|
|
257
|
-
return list.filter(Boolean).join(" ") || void 0;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/hooks/useDialogPolyfill/useDialogPolyfill.ts
|
|
261
|
-
import { useEffect as useEffect4, useRef, useState as useState3 } from "react";
|
|
262
|
-
var useDialogPolyfill = () => {
|
|
263
|
-
const [hasDialogSupport, setHasDialogSupport] = useState3(false);
|
|
264
|
-
const hasAlreadyLoaded = useRef(false);
|
|
265
|
-
useEffect4(() => {
|
|
266
|
-
setHasDialogSupport(supportsDialog());
|
|
267
|
-
}, []);
|
|
268
|
-
const polyfillDialog = async (ref) => {
|
|
269
|
-
if (!hasAlreadyLoaded.current && !hasDialogSupport && typeof window !== "undefined" && ref.current !== null) {
|
|
270
|
-
const { default: dialogPolyfill } = await import("dialog-polyfill");
|
|
271
|
-
hasAlreadyLoaded.current = true;
|
|
272
|
-
try {
|
|
273
|
-
if (ref.current) {
|
|
274
|
-
dialogPolyfill.registerDialog(ref.current);
|
|
275
|
-
}
|
|
276
|
-
} catch (error3) {
|
|
277
|
-
console.error("Failed to load dialog-polyfill", error3);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
return {
|
|
282
|
-
polyfillDialog
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
// src/hooks/useDialog/useDialog.ts
|
|
287
|
-
var TRANSITION_CLASS_NAME = "--transition";
|
|
288
|
-
var FALLBACK_TRANSITION_DURATION = 0;
|
|
289
|
-
var useDialog = (props) => {
|
|
290
|
-
const { ref, isOpen, transition, onOpen, onClose } = props;
|
|
291
|
-
const [hasDialogSupport, setHasDialogSupport] = useState4(false);
|
|
292
|
-
const shouldTransition = hasDialogSupport && transition.isEnabled;
|
|
293
|
-
const { polyfillDialog } = useDialogPolyfill();
|
|
294
|
-
useEffect5(() => {
|
|
295
|
-
setHasDialogSupport(supportsDialog());
|
|
296
|
-
}, []);
|
|
297
|
-
const TRANSITION_DURATION_IN_MS = ref.current && Number(
|
|
298
|
-
getComputedStyle(ref.current).getPropertyValue(transition.CSSVariable).replace("ms", "")
|
|
299
|
-
) || FALLBACK_TRANSITION_DURATION;
|
|
300
|
-
useBodyScrollLock({ enabled: isOpen });
|
|
301
|
-
const open = useCallback3(() => {
|
|
302
|
-
ref.current?.showModal();
|
|
303
|
-
onOpen?.();
|
|
304
|
-
}, [onOpen, ref]);
|
|
305
|
-
const close = useCallback3(() => {
|
|
306
|
-
ref.current?.close();
|
|
307
|
-
onClose?.();
|
|
308
|
-
}, [onClose, ref]);
|
|
309
|
-
const handleClose = useCallback3(
|
|
310
|
-
(event) => {
|
|
311
|
-
if (event) {
|
|
312
|
-
event.preventDefault();
|
|
313
|
-
event.stopPropagation();
|
|
314
|
-
}
|
|
315
|
-
if (shouldTransition) {
|
|
316
|
-
ref.current?.classList.remove(TRANSITION_CLASS_NAME);
|
|
317
|
-
setTimeout(() => close(), TRANSITION_DURATION_IN_MS);
|
|
318
|
-
} else {
|
|
319
|
-
close();
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
[TRANSITION_DURATION_IN_MS, close, ref, shouldTransition]
|
|
323
|
-
);
|
|
324
|
-
useEffect5(() => {
|
|
325
|
-
async function toggleDialog() {
|
|
326
|
-
if (isOpen && !ref.current?.open) {
|
|
327
|
-
await polyfillDialog(ref);
|
|
328
|
-
open();
|
|
329
|
-
setTimeout(() => {
|
|
330
|
-
ref.current?.classList.add(TRANSITION_CLASS_NAME);
|
|
331
|
-
}, 0);
|
|
332
|
-
} else if (!isOpen && ref.current?.open) {
|
|
333
|
-
handleClose();
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
void toggleDialog();
|
|
337
|
-
}, [handleClose, isOpen, open, ref, polyfillDialog]);
|
|
338
|
-
return {
|
|
339
|
-
open,
|
|
340
|
-
close: handleClose
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
// src/hooks/useLabel/useLabel.tsx
|
|
345
|
-
import { useId, useRef as useRef2 } from "react";
|
|
346
|
-
function useLabel({
|
|
347
|
-
id: providedId,
|
|
348
|
-
label,
|
|
349
|
-
"aria-label": ariaLabel,
|
|
350
|
-
"aria-labelledby": ariaLabelledby,
|
|
351
|
-
labelElementType = "label"
|
|
352
|
-
}) {
|
|
353
|
-
let labelProps = {};
|
|
354
|
-
let fieldProps = {};
|
|
355
|
-
const hasWarnedAboutMissingLabels = useRef2(false);
|
|
356
|
-
const fallbackId = useId();
|
|
357
|
-
const id = providedId || fallbackId;
|
|
358
|
-
const labelId = useId();
|
|
359
|
-
if (label) {
|
|
360
|
-
ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
|
|
361
|
-
labelProps = {
|
|
362
|
-
id: labelId,
|
|
363
|
-
htmlFor: labelElementType === "label" ? id : void 0
|
|
364
|
-
};
|
|
365
|
-
} else if (!ariaLabelledby && !ariaLabel && !hasWarnedAboutMissingLabels.current) {
|
|
366
|
-
hasWarnedAboutMissingLabels.current = true;
|
|
367
|
-
console.warn(
|
|
368
|
-
"If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility"
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
fieldProps = {
|
|
372
|
-
id,
|
|
373
|
-
"aria-label": ariaLabel,
|
|
374
|
-
"aria-labelledby": ariaLabelledby
|
|
375
|
-
};
|
|
376
|
-
return {
|
|
377
|
-
labelProps,
|
|
378
|
-
fieldProps
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// src/hooks/useOnClickOutside/useOnClickOutside.tsx
|
|
383
|
-
import { useEffect as useEffect6, useEffectEvent } from "react";
|
|
384
|
-
var useOnClickOutside = (ref, handler) => {
|
|
385
|
-
const stableHandler = useEffectEvent(handler);
|
|
386
|
-
useEffect6(() => {
|
|
387
|
-
const listener = (event) => {
|
|
388
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
event.preventDefault();
|
|
392
|
-
event.stopPropagation();
|
|
393
|
-
stableHandler(event);
|
|
394
|
-
};
|
|
395
|
-
const handleEscapeKeyPress = (event) => {
|
|
396
|
-
if (event.key === "Escape") {
|
|
397
|
-
event.preventDefault();
|
|
398
|
-
event.stopPropagation();
|
|
399
|
-
stableHandler(event);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
document.addEventListener("mousedown", listener);
|
|
403
|
-
document.addEventListener("touchstart", listener);
|
|
404
|
-
document.addEventListener("keydown", handleEscapeKeyPress);
|
|
405
|
-
return () => {
|
|
406
|
-
document.removeEventListener("mousedown", listener);
|
|
407
|
-
document.removeEventListener("touchstart", listener);
|
|
408
|
-
document.removeEventListener("keydown", handleEscapeKeyPress);
|
|
409
|
-
};
|
|
410
|
-
}, [ref]);
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
// src/hooks/useOnUnmount/useOnUnmount.tsx
|
|
414
|
-
import { useEffect as useEffect7, useEffectEvent as useEffectEvent2 } from "react";
|
|
415
|
-
function useOnUnmount(callback) {
|
|
416
|
-
const stableCallback = useEffectEvent2(callback);
|
|
417
|
-
useEffect7(() => () => stableCallback(), []);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// src/hooks/usePrefersReducedMotion/usePrefersReducedMotion.tsx
|
|
421
|
-
import { useEffect as useEffect8, useState as useState5 } from "react";
|
|
422
|
-
function usePrefersReducedMotion() {
|
|
423
|
-
const [prefersReducedMotion, setPrefersReducedMotion] = useState5(false);
|
|
424
|
-
useEffect8(() => {
|
|
425
|
-
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
426
|
-
setPrefersReducedMotion(mediaQuery.matches);
|
|
427
|
-
const listener = (event) => {
|
|
428
|
-
setPrefersReducedMotion(event.matches);
|
|
429
|
-
};
|
|
430
|
-
mediaQuery.addEventListener("change", listener);
|
|
431
|
-
return () => {
|
|
432
|
-
mediaQuery.removeEventListener("change", listener);
|
|
433
|
-
};
|
|
434
|
-
}, []);
|
|
435
|
-
return prefersReducedMotion;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// src/hooks/useRenderCount/useRenderCount.ts
|
|
439
|
-
import { useEffect as useEffect9, useRef as useRef3 } from "react";
|
|
440
|
-
function useRenderCount() {
|
|
441
|
-
const count = useRef3(1);
|
|
442
|
-
useEffect9(() => {
|
|
443
|
-
count.current += 1;
|
|
444
|
-
});
|
|
445
|
-
return count.current;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// src/hooks/useTextField/useTextField.tsx
|
|
449
|
-
import { useId as useId2 } from "react";
|
|
450
|
-
function useTextField(props) {
|
|
451
|
-
const {
|
|
452
|
-
isDisabled = false,
|
|
453
|
-
isReadOnly = false,
|
|
454
|
-
isRequired = false,
|
|
455
|
-
inputElementType = "input"
|
|
456
|
-
} = props;
|
|
457
|
-
const { labelProps, fieldProps } = useLabel(props);
|
|
458
|
-
const descriptionId = useId2();
|
|
459
|
-
const descriptionProps = { id: descriptionId };
|
|
460
|
-
const errorMessageId = useId2();
|
|
461
|
-
const errorMessageProps = { id: errorMessageId };
|
|
462
|
-
const ariaDescribedBy = spaceDelimitedList([
|
|
463
|
-
props.description && descriptionId,
|
|
464
|
-
props.errorMessage && errorMessageId,
|
|
465
|
-
props["aria-describedby"]
|
|
466
|
-
]);
|
|
467
|
-
return {
|
|
468
|
-
descriptionProps,
|
|
469
|
-
errorMessageProps,
|
|
470
|
-
labelProps,
|
|
471
|
-
inputProps: {
|
|
472
|
-
defaultValue: props.defaultValue,
|
|
473
|
-
value: props.value,
|
|
474
|
-
onChange: props.onChange,
|
|
475
|
-
disabled: isDisabled,
|
|
476
|
-
readOnly: isReadOnly,
|
|
477
|
-
required: isRequired,
|
|
478
|
-
"aria-required": isRequired === true ? true : void 0,
|
|
479
|
-
"aria-invalid": props.isInvalid,
|
|
480
|
-
"aria-describedby": ariaDescribedBy,
|
|
481
|
-
"aria-errormessage": props["aria-errormessage"],
|
|
482
|
-
role: props.role,
|
|
483
|
-
type: inputElementType === "input" ? props.type : void 0,
|
|
484
|
-
pattern: inputElementType === "input" ? props.pattern : void 0,
|
|
485
|
-
autoComplete: props.autoComplete,
|
|
486
|
-
maxLength: props.maxLength,
|
|
487
|
-
minLength: props.minLength,
|
|
488
|
-
name: props.name,
|
|
489
|
-
placeholder: props.placeholder,
|
|
490
|
-
inputMode: props.inputMode,
|
|
491
|
-
// Clipboard events
|
|
492
|
-
onCopy: props.onCopy,
|
|
493
|
-
onCut: props.onCut,
|
|
494
|
-
onPaste: props.onPaste,
|
|
495
|
-
// Composition events
|
|
496
|
-
onCompositionEnd: props.onCompositionEnd,
|
|
497
|
-
onCompositionStart: props.onCompositionStart,
|
|
498
|
-
onCompositionUpdate: props.onCompositionUpdate,
|
|
499
|
-
// Selection events
|
|
500
|
-
onSelect: props.onSelect,
|
|
501
|
-
// Input events
|
|
502
|
-
onBeforeInput: props.onBeforeInput,
|
|
503
|
-
onInput: props.onInput,
|
|
504
|
-
// Focus events
|
|
505
|
-
onFocus: props.onFocus,
|
|
506
|
-
onBlur: props.onBlur,
|
|
507
|
-
...fieldProps
|
|
25
|
+
filteredProps[key] = props[key];
|
|
508
26
|
}
|
|
509
|
-
};
|
|
510
|
-
|
|
27
|
+
});
|
|
28
|
+
return filteredProps;
|
|
29
|
+
};
|
|
511
30
|
|
|
512
|
-
// src/
|
|
513
|
-
var
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return "--is-invalid";
|
|
31
|
+
// src/utils/getSpacingValue.ts
|
|
32
|
+
var getSpacingValue = (padding) => {
|
|
33
|
+
if (typeof padding === "string") {
|
|
34
|
+
return `var(--size-${padding})`;
|
|
517
35
|
}
|
|
518
|
-
if (
|
|
519
|
-
return
|
|
36
|
+
if (typeof padding === "number") {
|
|
37
|
+
return `${padding}px`;
|
|
520
38
|
}
|
|
521
|
-
return
|
|
39
|
+
return void 0;
|
|
522
40
|
};
|
|
523
41
|
|
|
524
|
-
// src/
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
function useWindowEvent(type, listener, options) {
|
|
536
|
-
const stableListener = useEffectEvent3(listener);
|
|
537
|
-
useEffect10(() => {
|
|
538
|
-
const controller = new AbortController();
|
|
539
|
-
const { signal } = controller;
|
|
540
|
-
const normalisedOptions = normaliseOptions(options, { signal });
|
|
541
|
-
window.addEventListener(type, stableListener, normalisedOptions);
|
|
542
|
-
return () => {
|
|
543
|
-
controller.abort();
|
|
544
|
-
window.removeEventListener(type, stableListener, normalisedOptions);
|
|
545
|
-
};
|
|
546
|
-
}, [type, options]);
|
|
42
|
+
// src/utils/mergeRefs.ts
|
|
43
|
+
function mergeRefs(refs) {
|
|
44
|
+
return (value) => {
|
|
45
|
+
refs.forEach((ref) => {
|
|
46
|
+
if (typeof ref === "function") {
|
|
47
|
+
ref(value);
|
|
48
|
+
} else if (ref != null) {
|
|
49
|
+
ref.current = value;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
547
53
|
}
|
|
548
54
|
|
|
549
|
-
// src/
|
|
550
|
-
|
|
55
|
+
// src/utils/polyfill-tests.ts
|
|
56
|
+
var supportsDialog = () => typeof HTMLDialogElement === "function";
|
|
551
57
|
|
|
552
|
-
// src/
|
|
553
|
-
|
|
58
|
+
// src/utils/sizeClasses.ts
|
|
59
|
+
var sizeClasses = (size) => {
|
|
60
|
+
if (!size) {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
"--is-xxs": size === "xxs",
|
|
65
|
+
"--is-xs": size === "xs",
|
|
66
|
+
"--is-sm": size === "sm",
|
|
67
|
+
"--is-md": size === "md",
|
|
68
|
+
"--is-lg": size === "lg",
|
|
69
|
+
"--is-xl": size === "xl",
|
|
70
|
+
"--is-xxl": size === "xxl"
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/utils/spaceDelimitedList.ts
|
|
75
|
+
function spaceDelimitedList(list) {
|
|
76
|
+
return list.filter(Boolean).join(" ") || void 0;
|
|
77
|
+
}
|
|
554
78
|
|
|
555
79
|
// src/components/Flex/propUtils.ts
|
|
556
80
|
var buildFlexStyles = (props) => {
|
|
@@ -790,7 +314,7 @@ var Accordion = ({ ref, ...props }) => {
|
|
|
790
314
|
headerChildren,
|
|
791
315
|
...rest
|
|
792
316
|
} = props;
|
|
793
|
-
const [accordionState, setAccordionState] =
|
|
317
|
+
const [accordionState, setAccordionState] = useState({
|
|
794
318
|
open: startOpen,
|
|
795
319
|
withAnimation: false
|
|
796
320
|
});
|
|
@@ -829,13 +353,13 @@ var Accordion = ({ ref, ...props }) => {
|
|
|
829
353
|
withAnimation: true
|
|
830
354
|
});
|
|
831
355
|
};
|
|
832
|
-
|
|
356
|
+
useEffect(() => {
|
|
833
357
|
setAccordionState({
|
|
834
358
|
open: startOpen,
|
|
835
359
|
withAnimation: true
|
|
836
360
|
});
|
|
837
361
|
}, [startOpen]);
|
|
838
|
-
const baseId =
|
|
362
|
+
const baseId = useId();
|
|
839
363
|
const accordionId = `accordion-header-${baseId}`;
|
|
840
364
|
const contentId = `accordion-panel-${baseId}`;
|
|
841
365
|
return /* @__PURE__ */ jsxs3("div", { ref, ...rest, className: containerClasses, children: [
|
|
@@ -880,7 +404,7 @@ var Accordion = ({ ref, ...props }) => {
|
|
|
880
404
|
Accordion.displayName = "Accordion";
|
|
881
405
|
|
|
882
406
|
// src/components/Accordion/AccordionList.tsx
|
|
883
|
-
import { useState as
|
|
407
|
+
import { useState as useState2, Fragment } from "react";
|
|
884
408
|
import classNames6 from "classnames/dedupe";
|
|
885
409
|
|
|
886
410
|
// src/components/Divider/Divider.tsx
|
|
@@ -901,69 +425,398 @@ var Divider = ({
|
|
|
901
425
|
...rest,
|
|
902
426
|
children: /* @__PURE__ */ jsx5("div", { className: "mobius-divider__inner" })
|
|
903
427
|
}
|
|
904
|
-
);
|
|
428
|
+
);
|
|
429
|
+
};
|
|
430
|
+
Divider.displayName = "Divider";
|
|
431
|
+
|
|
432
|
+
// src/components/Accordion/AccordionList.tsx
|
|
433
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
434
|
+
var AccordionList = (props) => {
|
|
435
|
+
const {
|
|
436
|
+
className,
|
|
437
|
+
content,
|
|
438
|
+
onOpen,
|
|
439
|
+
onClose,
|
|
440
|
+
allowMultiple = false,
|
|
441
|
+
...rest
|
|
442
|
+
} = props;
|
|
443
|
+
const [openIds, setOpenIds] = useState2(/* @__PURE__ */ new Set());
|
|
444
|
+
const classes = classNames6("mobius", "mobius-accordion-list", className);
|
|
445
|
+
const handleAccordionChange = (id, isOpen) => {
|
|
446
|
+
setOpenIds((prev) => {
|
|
447
|
+
const newSet = new Set(prev);
|
|
448
|
+
if (isOpen) {
|
|
449
|
+
if (!allowMultiple) {
|
|
450
|
+
newSet.clear();
|
|
451
|
+
}
|
|
452
|
+
newSet.add(id);
|
|
453
|
+
} else {
|
|
454
|
+
newSet.delete(id);
|
|
455
|
+
}
|
|
456
|
+
return newSet;
|
|
457
|
+
});
|
|
458
|
+
if (isOpen) {
|
|
459
|
+
onOpen?.(id);
|
|
460
|
+
} else {
|
|
461
|
+
onClose?.(id);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
return /* @__PURE__ */ jsx6("div", { className: classes, ...rest, children: content.map((item, index) => {
|
|
465
|
+
const { id, header, details } = item;
|
|
466
|
+
const isOpen = openIds.has(id);
|
|
467
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
468
|
+
/* @__PURE__ */ jsx6(
|
|
469
|
+
Accordion,
|
|
470
|
+
{
|
|
471
|
+
startOpen: isOpen,
|
|
472
|
+
showText: header,
|
|
473
|
+
hideText: header,
|
|
474
|
+
onChange: (isOpen2) => handleAccordionChange(id, isOpen2),
|
|
475
|
+
children: details
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
index < content.length - 1 && /* @__PURE__ */ jsx6(Divider, {})
|
|
479
|
+
] }, id);
|
|
480
|
+
}) });
|
|
481
|
+
};
|
|
482
|
+
AccordionList.displayName = "AccordionList";
|
|
483
|
+
|
|
484
|
+
// src/components/AddressLookup/AddressLookup.tsx
|
|
485
|
+
import { search } from "@simplybusiness/icons";
|
|
486
|
+
import { useCallback as useCallback4, useState as useState9 } from "react";
|
|
487
|
+
|
|
488
|
+
// src/components/Combobox/Combobox.tsx
|
|
489
|
+
import classNames14 from "classnames/dedupe";
|
|
490
|
+
import { useEffect as useEffect6, useId as useId4, useRef as useRef4, useState as useState8 } from "react";
|
|
491
|
+
import { useOnUnmount } from "@simplybusiness/mobius-hooks";
|
|
492
|
+
|
|
493
|
+
// src/hooks/useBreakpoint/useBreakpoint.tsx
|
|
494
|
+
import {
|
|
495
|
+
useDebouncedValue,
|
|
496
|
+
useIsClient,
|
|
497
|
+
useWindowEvent
|
|
498
|
+
} from "@simplybusiness/mobius-hooks";
|
|
499
|
+
import { useCallback, useMemo, useState as useState3 } from "react";
|
|
500
|
+
var DEFAULT_BREAKPOINTS = [
|
|
501
|
+
{ size: "xs", value: 320 },
|
|
502
|
+
{ size: "sm", value: 480 },
|
|
503
|
+
{ size: "md", value: 670 },
|
|
504
|
+
{ size: "lg", value: 960 },
|
|
505
|
+
{ size: "xl", value: 1200 },
|
|
506
|
+
{ size: "xxl", value: 1320 }
|
|
507
|
+
];
|
|
508
|
+
var PASSIVE = { passive: true };
|
|
509
|
+
var getBreakpoint = (breakpoints, windowWidth) => {
|
|
510
|
+
const closest = breakpoints.findIndex(
|
|
511
|
+
(breakpoint) => breakpoint.value >= windowWidth + 1
|
|
512
|
+
);
|
|
513
|
+
const smallest = breakpoints[0];
|
|
514
|
+
const largest = breakpoints[breakpoints.length - 1];
|
|
515
|
+
const match = breakpoints[closest - 1];
|
|
516
|
+
if (closest === 0) return smallest;
|
|
517
|
+
if (closest === -1) return largest;
|
|
518
|
+
return match;
|
|
519
|
+
};
|
|
520
|
+
var useBreakpoint = (customBreakpoints) => {
|
|
521
|
+
const isClientSide = useIsClient();
|
|
522
|
+
const breakpoints = customBreakpoints || DEFAULT_BREAKPOINTS;
|
|
523
|
+
const defaultBreakpoint = breakpoints[0];
|
|
524
|
+
const [windowWidth, setWindowWidth] = useState3(
|
|
525
|
+
typeof globalThis?.window !== "undefined" ? window.innerWidth : defaultBreakpoint.value
|
|
526
|
+
);
|
|
527
|
+
useWindowEvent("resize", () => setWindowWidth(window.innerWidth), PASSIVE);
|
|
528
|
+
const debouncedWidth = useDebouncedValue(windowWidth, 200);
|
|
529
|
+
const currentBreakpoint = useMemo(
|
|
530
|
+
() => !isClientSide || breakpoints.length === 0 ? defaultBreakpoint : getBreakpoint(breakpoints, debouncedWidth),
|
|
531
|
+
[isClientSide, breakpoints, defaultBreakpoint, debouncedWidth]
|
|
532
|
+
);
|
|
533
|
+
const up = useCallback(
|
|
534
|
+
(size) => {
|
|
535
|
+
const sizeIndex = breakpoints.findIndex((item) => item.size === size);
|
|
536
|
+
if (sizeIndex === -1) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
const currentIndex = breakpoints.findIndex(
|
|
540
|
+
(item) => item.size === currentBreakpoint.size
|
|
541
|
+
);
|
|
542
|
+
return currentIndex >= sizeIndex;
|
|
543
|
+
},
|
|
544
|
+
[currentBreakpoint, breakpoints]
|
|
545
|
+
);
|
|
546
|
+
const down = useCallback(
|
|
547
|
+
(size) => {
|
|
548
|
+
const sizeIndex = breakpoints.findIndex((item) => item.size === size);
|
|
549
|
+
if (sizeIndex === -1) {
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
const currentIndex = breakpoints.findIndex(
|
|
553
|
+
(item) => item.size === currentBreakpoint.size
|
|
554
|
+
);
|
|
555
|
+
return currentIndex <= sizeIndex;
|
|
556
|
+
},
|
|
557
|
+
[currentBreakpoint, breakpoints]
|
|
558
|
+
);
|
|
559
|
+
return {
|
|
560
|
+
breakpoint: currentBreakpoint,
|
|
561
|
+
up,
|
|
562
|
+
down
|
|
563
|
+
};
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/hooks/useButton/useButton.tsx
|
|
567
|
+
import { useCallback as useCallback2 } from "react";
|
|
568
|
+
function useButton({
|
|
569
|
+
elementType = "button",
|
|
570
|
+
type = "button",
|
|
571
|
+
isDisabled = false,
|
|
572
|
+
href,
|
|
573
|
+
target,
|
|
574
|
+
rel,
|
|
575
|
+
role,
|
|
576
|
+
name,
|
|
577
|
+
value,
|
|
578
|
+
onClick,
|
|
579
|
+
onPress
|
|
580
|
+
}) {
|
|
581
|
+
const realOnClick = useCallback2(
|
|
582
|
+
(event) => {
|
|
583
|
+
if (isDisabled) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
onClick?.(event);
|
|
587
|
+
onPress?.(event);
|
|
588
|
+
},
|
|
589
|
+
[isDisabled, onClick, onPress]
|
|
590
|
+
);
|
|
591
|
+
function getRole() {
|
|
592
|
+
if (role) {
|
|
593
|
+
return role;
|
|
594
|
+
}
|
|
595
|
+
if (elementType === "a") {
|
|
596
|
+
return void 0;
|
|
597
|
+
}
|
|
598
|
+
return "button";
|
|
599
|
+
}
|
|
600
|
+
const extraProps = elementType === "button" ? { type } : {
|
|
601
|
+
role: getRole()
|
|
602
|
+
};
|
|
603
|
+
return {
|
|
604
|
+
buttonProps: {
|
|
605
|
+
href: elementType === "a" ? href : void 0,
|
|
606
|
+
target: elementType === "a" ? target : void 0,
|
|
607
|
+
rel: elementType === "a" ? rel : void 0,
|
|
608
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
609
|
+
disabled: isDisabled || void 0,
|
|
610
|
+
"aria-disabled": isDisabled || void 0,
|
|
611
|
+
name: elementType === "input" || elementType === "button" ? name : void 0,
|
|
612
|
+
value: elementType === "input" || elementType === "button" ? value : void 0,
|
|
613
|
+
...extraProps,
|
|
614
|
+
onClick: realOnClick
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/hooks/useDialog/useDialog.ts
|
|
620
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState5 } from "react";
|
|
621
|
+
import { useBodyScrollLock } from "@simplybusiness/mobius-hooks";
|
|
622
|
+
|
|
623
|
+
// src/hooks/useDialogPolyfill/useDialogPolyfill.ts
|
|
624
|
+
import { useEffect as useEffect2, useRef, useState as useState4 } from "react";
|
|
625
|
+
var useDialogPolyfill = () => {
|
|
626
|
+
const [hasDialogSupport, setHasDialogSupport] = useState4(false);
|
|
627
|
+
const hasAlreadyLoaded = useRef(false);
|
|
628
|
+
useEffect2(() => {
|
|
629
|
+
setHasDialogSupport(supportsDialog());
|
|
630
|
+
}, []);
|
|
631
|
+
const polyfillDialog = async (ref) => {
|
|
632
|
+
if (!hasAlreadyLoaded.current && !hasDialogSupport && typeof window !== "undefined" && ref.current !== null) {
|
|
633
|
+
const { default: dialogPolyfill } = await import("dialog-polyfill");
|
|
634
|
+
hasAlreadyLoaded.current = true;
|
|
635
|
+
try {
|
|
636
|
+
if (ref.current) {
|
|
637
|
+
dialogPolyfill.registerDialog(ref.current);
|
|
638
|
+
}
|
|
639
|
+
} catch (error3) {
|
|
640
|
+
console.error("Failed to load dialog-polyfill", error3);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
return {
|
|
645
|
+
polyfillDialog
|
|
646
|
+
};
|
|
905
647
|
};
|
|
906
|
-
Divider.displayName = "Divider";
|
|
907
648
|
|
|
908
|
-
// src/
|
|
909
|
-
|
|
910
|
-
var
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
const
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
649
|
+
// src/hooks/useDialog/useDialog.ts
|
|
650
|
+
var TRANSITION_CLASS_NAME = "--transition";
|
|
651
|
+
var FALLBACK_TRANSITION_DURATION = 0;
|
|
652
|
+
var useDialog = (props) => {
|
|
653
|
+
const { ref, isOpen, transition, onOpen, onClose } = props;
|
|
654
|
+
const [hasDialogSupport, setHasDialogSupport] = useState5(false);
|
|
655
|
+
const shouldTransition = hasDialogSupport && transition.isEnabled;
|
|
656
|
+
const { polyfillDialog } = useDialogPolyfill();
|
|
657
|
+
useEffect3(() => {
|
|
658
|
+
setHasDialogSupport(supportsDialog());
|
|
659
|
+
}, []);
|
|
660
|
+
const TRANSITION_DURATION_IN_MS = ref.current && Number(
|
|
661
|
+
getComputedStyle(ref.current).getPropertyValue(transition.CSSVariable).replace("ms", "")
|
|
662
|
+
) || FALLBACK_TRANSITION_DURATION;
|
|
663
|
+
useBodyScrollLock({ enabled: isOpen });
|
|
664
|
+
const open = useCallback3(() => {
|
|
665
|
+
ref.current?.showModal();
|
|
666
|
+
onOpen?.();
|
|
667
|
+
}, [onOpen, ref]);
|
|
668
|
+
const close = useCallback3(() => {
|
|
669
|
+
ref.current?.close();
|
|
670
|
+
onClose?.();
|
|
671
|
+
}, [onClose, ref]);
|
|
672
|
+
const handleClose = useCallback3(
|
|
673
|
+
(event) => {
|
|
674
|
+
if (event) {
|
|
675
|
+
event.preventDefault();
|
|
676
|
+
event.stopPropagation();
|
|
677
|
+
}
|
|
678
|
+
if (shouldTransition) {
|
|
679
|
+
ref.current?.classList.remove(TRANSITION_CLASS_NAME);
|
|
680
|
+
setTimeout(() => close(), TRANSITION_DURATION_IN_MS);
|
|
929
681
|
} else {
|
|
930
|
-
|
|
682
|
+
close();
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
[TRANSITION_DURATION_IN_MS, close, ref, shouldTransition]
|
|
686
|
+
);
|
|
687
|
+
useEffect3(() => {
|
|
688
|
+
async function toggleDialog() {
|
|
689
|
+
if (isOpen && !ref.current?.open) {
|
|
690
|
+
await polyfillDialog(ref);
|
|
691
|
+
open();
|
|
692
|
+
setTimeout(() => {
|
|
693
|
+
ref.current?.classList.add(TRANSITION_CLASS_NAME);
|
|
694
|
+
}, 0);
|
|
695
|
+
} else if (!isOpen && ref.current?.open) {
|
|
696
|
+
handleClose();
|
|
931
697
|
}
|
|
932
|
-
return newSet;
|
|
933
|
-
});
|
|
934
|
-
if (isOpen) {
|
|
935
|
-
onOpen?.(id);
|
|
936
|
-
} else {
|
|
937
|
-
onClose?.(id);
|
|
938
698
|
}
|
|
699
|
+
void toggleDialog();
|
|
700
|
+
}, [handleClose, isOpen, open, ref, polyfillDialog]);
|
|
701
|
+
return {
|
|
702
|
+
open,
|
|
703
|
+
close: handleClose
|
|
939
704
|
};
|
|
940
|
-
return /* @__PURE__ */ jsx6("div", { className: classes, ...rest, children: content.map((item, index) => {
|
|
941
|
-
const { id, header, details } = item;
|
|
942
|
-
const isOpen = openIds.has(id);
|
|
943
|
-
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
944
|
-
/* @__PURE__ */ jsx6(
|
|
945
|
-
Accordion,
|
|
946
|
-
{
|
|
947
|
-
startOpen: isOpen,
|
|
948
|
-
showText: header,
|
|
949
|
-
hideText: header,
|
|
950
|
-
onChange: (isOpen2) => handleAccordionChange(id, isOpen2),
|
|
951
|
-
children: details
|
|
952
|
-
}
|
|
953
|
-
),
|
|
954
|
-
index < content.length - 1 && /* @__PURE__ */ jsx6(Divider, {})
|
|
955
|
-
] }, id);
|
|
956
|
-
}) });
|
|
957
705
|
};
|
|
958
|
-
AccordionList.displayName = "AccordionList";
|
|
959
706
|
|
|
960
|
-
// src/
|
|
961
|
-
import {
|
|
962
|
-
|
|
707
|
+
// src/hooks/useLabel/useLabel.tsx
|
|
708
|
+
import { useId as useId2, useRef as useRef2 } from "react";
|
|
709
|
+
function useLabel({
|
|
710
|
+
id: providedId,
|
|
711
|
+
label,
|
|
712
|
+
"aria-label": ariaLabel,
|
|
713
|
+
"aria-labelledby": ariaLabelledby,
|
|
714
|
+
labelElementType = "label"
|
|
715
|
+
}) {
|
|
716
|
+
let labelProps = {};
|
|
717
|
+
let fieldProps = {};
|
|
718
|
+
const hasWarnedAboutMissingLabels = useRef2(false);
|
|
719
|
+
const fallbackId = useId2();
|
|
720
|
+
const id = providedId || fallbackId;
|
|
721
|
+
const labelId = useId2();
|
|
722
|
+
if (label) {
|
|
723
|
+
ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;
|
|
724
|
+
labelProps = {
|
|
725
|
+
id: labelId,
|
|
726
|
+
htmlFor: labelElementType === "label" ? id : void 0
|
|
727
|
+
};
|
|
728
|
+
} else if (!ariaLabelledby && !ariaLabel && !hasWarnedAboutMissingLabels.current) {
|
|
729
|
+
hasWarnedAboutMissingLabels.current = true;
|
|
730
|
+
console.warn(
|
|
731
|
+
"If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility"
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
fieldProps = {
|
|
735
|
+
id,
|
|
736
|
+
"aria-label": ariaLabel,
|
|
737
|
+
"aria-labelledby": ariaLabelledby
|
|
738
|
+
};
|
|
739
|
+
return {
|
|
740
|
+
labelProps,
|
|
741
|
+
fieldProps
|
|
742
|
+
};
|
|
743
|
+
}
|
|
963
744
|
|
|
964
|
-
// src/
|
|
965
|
-
import
|
|
966
|
-
|
|
745
|
+
// src/hooks/useTextField/useTextField.tsx
|
|
746
|
+
import { useId as useId3 } from "react";
|
|
747
|
+
function useTextField(props) {
|
|
748
|
+
const {
|
|
749
|
+
isDisabled = false,
|
|
750
|
+
isReadOnly = false,
|
|
751
|
+
isRequired = false,
|
|
752
|
+
inputElementType = "input"
|
|
753
|
+
} = props;
|
|
754
|
+
const { labelProps, fieldProps } = useLabel(props);
|
|
755
|
+
const descriptionId = useId3();
|
|
756
|
+
const descriptionProps = { id: descriptionId };
|
|
757
|
+
const errorMessageId = useId3();
|
|
758
|
+
const errorMessageProps = { id: errorMessageId };
|
|
759
|
+
const ariaDescribedBy = spaceDelimitedList([
|
|
760
|
+
props.description && descriptionId,
|
|
761
|
+
props.errorMessage && errorMessageId,
|
|
762
|
+
props["aria-describedby"]
|
|
763
|
+
]);
|
|
764
|
+
return {
|
|
765
|
+
descriptionProps,
|
|
766
|
+
errorMessageProps,
|
|
767
|
+
labelProps,
|
|
768
|
+
inputProps: {
|
|
769
|
+
defaultValue: props.defaultValue,
|
|
770
|
+
value: props.value,
|
|
771
|
+
onChange: props.onChange,
|
|
772
|
+
disabled: isDisabled,
|
|
773
|
+
readOnly: isReadOnly,
|
|
774
|
+
required: isRequired,
|
|
775
|
+
"aria-required": isRequired === true ? true : void 0,
|
|
776
|
+
"aria-invalid": props.isInvalid,
|
|
777
|
+
"aria-describedby": ariaDescribedBy,
|
|
778
|
+
"aria-errormessage": props["aria-errormessage"],
|
|
779
|
+
role: props.role,
|
|
780
|
+
type: inputElementType === "input" ? props.type : void 0,
|
|
781
|
+
pattern: inputElementType === "input" ? props.pattern : void 0,
|
|
782
|
+
autoComplete: props.autoComplete,
|
|
783
|
+
maxLength: props.maxLength,
|
|
784
|
+
minLength: props.minLength,
|
|
785
|
+
name: props.name,
|
|
786
|
+
placeholder: props.placeholder,
|
|
787
|
+
inputMode: props.inputMode,
|
|
788
|
+
// Clipboard events
|
|
789
|
+
onCopy: props.onCopy,
|
|
790
|
+
onCut: props.onCut,
|
|
791
|
+
onPaste: props.onPaste,
|
|
792
|
+
// Composition events
|
|
793
|
+
onCompositionEnd: props.onCompositionEnd,
|
|
794
|
+
onCompositionStart: props.onCompositionStart,
|
|
795
|
+
onCompositionUpdate: props.onCompositionUpdate,
|
|
796
|
+
// Selection events
|
|
797
|
+
onSelect: props.onSelect,
|
|
798
|
+
// Input events
|
|
799
|
+
onBeforeInput: props.onBeforeInput,
|
|
800
|
+
onInput: props.onInput,
|
|
801
|
+
// Focus events
|
|
802
|
+
onFocus: props.onFocus,
|
|
803
|
+
onBlur: props.onBlur,
|
|
804
|
+
...fieldProps
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// src/hooks/useValidationClasses/useValidationClasses.ts
|
|
810
|
+
var useValidationClasses = (props) => {
|
|
811
|
+
const { isInvalid } = props;
|
|
812
|
+
if (isInvalid) {
|
|
813
|
+
return "--is-invalid";
|
|
814
|
+
}
|
|
815
|
+
if (isInvalid === false) {
|
|
816
|
+
return "--is-valid";
|
|
817
|
+
}
|
|
818
|
+
return "";
|
|
819
|
+
};
|
|
967
820
|
|
|
968
821
|
// src/components/TextField/TextField.tsx
|
|
969
822
|
import classNames11 from "classnames/dedupe";
|
|
@@ -1172,7 +1025,7 @@ function VisuallyHidden(props) {
|
|
|
1172
1025
|
import classNames13 from "classnames/dedupe";
|
|
1173
1026
|
|
|
1174
1027
|
// src/components/Combobox/Option.tsx
|
|
1175
|
-
import { useEffect as
|
|
1028
|
+
import { useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
1176
1029
|
import classNames12 from "classnames/dedupe";
|
|
1177
1030
|
|
|
1178
1031
|
// src/components/Combobox/utils.tsx
|
|
@@ -1205,8 +1058,8 @@ var Option = ({
|
|
|
1205
1058
|
optionComponent: OptionComponent,
|
|
1206
1059
|
id
|
|
1207
1060
|
}) => {
|
|
1208
|
-
const optionRef =
|
|
1209
|
-
|
|
1061
|
+
const optionRef = useRef3(null);
|
|
1062
|
+
useEffect4(() => {
|
|
1210
1063
|
if (isHighlighted && optionRef.current && optionRef.current.scrollIntoView) {
|
|
1211
1064
|
optionRef.current.scrollIntoView({ block: "nearest" });
|
|
1212
1065
|
}
|
|
@@ -1306,12 +1159,12 @@ var Listbox = ({
|
|
|
1306
1159
|
};
|
|
1307
1160
|
|
|
1308
1161
|
// src/components/Combobox/useComboboxHighlight.tsx
|
|
1309
|
-
import { useState as
|
|
1162
|
+
import { useState as useState6 } from "react";
|
|
1310
1163
|
function useComboboxHighlight(options) {
|
|
1311
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
1164
|
+
const [highlightedIndex, setHighlightedIndex] = useState6(
|
|
1312
1165
|
options && options.length ? 0 : -1
|
|
1313
1166
|
);
|
|
1314
|
-
const [highlightedGroupIndex, setHighlightedGroupIndex] =
|
|
1167
|
+
const [highlightedGroupIndex, setHighlightedGroupIndex] = useState6(0);
|
|
1315
1168
|
function highlightNextOption() {
|
|
1316
1169
|
const isGroup = isOptionGroup(options);
|
|
1317
1170
|
if (!options) {
|
|
@@ -1389,7 +1242,8 @@ function useComboboxHighlight(options) {
|
|
|
1389
1242
|
}
|
|
1390
1243
|
|
|
1391
1244
|
// src/components/Combobox/useComboboxOptions.ts
|
|
1392
|
-
import { useEffect as
|
|
1245
|
+
import { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1246
|
+
import { useDebouncedValue as useDebouncedValue2 } from "@simplybusiness/mobius-hooks";
|
|
1393
1247
|
function useComboboxOptions({
|
|
1394
1248
|
options,
|
|
1395
1249
|
asyncOptions,
|
|
@@ -1399,15 +1253,15 @@ function useComboboxOptions({
|
|
|
1399
1253
|
skipNextDebounceRef,
|
|
1400
1254
|
onSearched
|
|
1401
1255
|
}) {
|
|
1402
|
-
const [filteredOptions, setFilteredOptions] =
|
|
1403
|
-
const debouncedInputValue =
|
|
1256
|
+
const [filteredOptions, setFilteredOptions] = useState7(void 0);
|
|
1257
|
+
const debouncedInputValue = useDebouncedValue2(
|
|
1404
1258
|
inputValue,
|
|
1405
1259
|
// Don't debounce synchronous options
|
|
1406
1260
|
options ? 0 : delay
|
|
1407
1261
|
);
|
|
1408
|
-
const [isLoading, setIsLoading] =
|
|
1409
|
-
const [error3, setError] =
|
|
1410
|
-
|
|
1262
|
+
const [isLoading, setIsLoading] = useState7(false);
|
|
1263
|
+
const [error3, setError] = useState7(null);
|
|
1264
|
+
useEffect5(() => {
|
|
1411
1265
|
const controller = new AbortController();
|
|
1412
1266
|
const { signal } = controller;
|
|
1413
1267
|
const fetchOptions = async () => {
|
|
@@ -1492,11 +1346,11 @@ var ComboboxInner = ({
|
|
|
1492
1346
|
errorMessage,
|
|
1493
1347
|
...otherProps
|
|
1494
1348
|
} = props;
|
|
1495
|
-
const skipNextDebounceRef =
|
|
1496
|
-
const fallbackRef =
|
|
1497
|
-
const [inputValue, setInputValue] =
|
|
1498
|
-
const [isOpen, setIsOpen] =
|
|
1499
|
-
const [isChanging, setIsChanging] =
|
|
1349
|
+
const skipNextDebounceRef = useRef4(false);
|
|
1350
|
+
const fallbackRef = useRef4(null);
|
|
1351
|
+
const [inputValue, setInputValue] = useState8(defaultValue || "");
|
|
1352
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
1353
|
+
const [isChanging, setIsChanging] = useState8(false);
|
|
1500
1354
|
const { filteredOptions, updateFilteredOptions, isLoading, error: error3 } = useComboboxOptions({
|
|
1501
1355
|
options,
|
|
1502
1356
|
asyncOptions,
|
|
@@ -1517,9 +1371,9 @@ var ComboboxInner = ({
|
|
|
1517
1371
|
const inputRef = ref || fallbackRef;
|
|
1518
1372
|
const listboxId = useId4();
|
|
1519
1373
|
const statusId = useId4();
|
|
1520
|
-
const blurTimeoutRef =
|
|
1521
|
-
const userInteractedRef =
|
|
1522
|
-
const justSelectedRef =
|
|
1374
|
+
const blurTimeoutRef = useRef4(null);
|
|
1375
|
+
const userInteractedRef = useRef4(false);
|
|
1376
|
+
const justSelectedRef = useRef4(false);
|
|
1523
1377
|
const { down } = useBreakpoint();
|
|
1524
1378
|
const isMobile = down("md");
|
|
1525
1379
|
const handleFocus = (e) => {
|
|
@@ -1541,7 +1395,7 @@ var ComboboxInner = ({
|
|
|
1541
1395
|
justSelectedRef.current = false;
|
|
1542
1396
|
}
|
|
1543
1397
|
};
|
|
1544
|
-
|
|
1398
|
+
useEffect6(() => {
|
|
1545
1399
|
if (!inputRef || typeof inputRef === "function") return;
|
|
1546
1400
|
const inputElement = inputRef.current;
|
|
1547
1401
|
if (!inputElement) return;
|
|
@@ -1673,12 +1527,12 @@ var ComboboxInner = ({
|
|
|
1673
1527
|
default:
|
|
1674
1528
|
}
|
|
1675
1529
|
};
|
|
1676
|
-
|
|
1530
|
+
useEffect6(() => {
|
|
1677
1531
|
if (value) {
|
|
1678
1532
|
setInputValue(value);
|
|
1679
1533
|
}
|
|
1680
1534
|
}, [value]);
|
|
1681
|
-
|
|
1535
|
+
useEffect6(() => {
|
|
1682
1536
|
if (asyncOptions && isChanging) {
|
|
1683
1537
|
setIsOpen(!!filteredOptions && filteredOptions.length > 0);
|
|
1684
1538
|
}
|
|
@@ -1789,7 +1643,7 @@ var AddressLookup = ({
|
|
|
1789
1643
|
errorMessage,
|
|
1790
1644
|
...otherProps
|
|
1791
1645
|
}) => {
|
|
1792
|
-
const [error3, _setError] =
|
|
1646
|
+
const [error3, _setError] = useState9(null);
|
|
1793
1647
|
const setError = useCallback4(
|
|
1794
1648
|
(newError) => {
|
|
1795
1649
|
if (newError != null) onError?.(newError);
|
|
@@ -2144,7 +1998,7 @@ var Button = ({ ref, ...props }) => {
|
|
|
2144
1998
|
Button.displayName = "Button";
|
|
2145
1999
|
|
|
2146
2000
|
// src/components/Checkbox/Checkbox.tsx
|
|
2147
|
-
import { useRef as
|
|
2001
|
+
import { useRef as useRef5, useId as useId5, useState as useState10, useEffect as useEffect7 } from "react";
|
|
2148
2002
|
import classNames20 from "classnames/dedupe";
|
|
2149
2003
|
import { squareTick, square } from "@simplybusiness/icons";
|
|
2150
2004
|
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
@@ -2167,12 +2021,12 @@ var Checkbox = ({ ref, ...props }) => {
|
|
|
2167
2021
|
["aria-describedby"]: ariaDescribedBy,
|
|
2168
2022
|
...rest
|
|
2169
2023
|
} = props;
|
|
2170
|
-
const [checked, setChecked] =
|
|
2171
|
-
const fallbackRef =
|
|
2024
|
+
const [checked, setChecked] = useState10(defaultSelected);
|
|
2025
|
+
const fallbackRef = useRef5(null);
|
|
2172
2026
|
const refObj = ref || fallbackRef;
|
|
2173
2027
|
const inputId = useId5();
|
|
2174
2028
|
const isControlled = typeof selected === "boolean";
|
|
2175
|
-
|
|
2029
|
+
useEffect7(() => {
|
|
2176
2030
|
if (isControlled) {
|
|
2177
2031
|
setChecked(selected);
|
|
2178
2032
|
}
|
|
@@ -2253,10 +2107,10 @@ import {
|
|
|
2253
2107
|
Children as Children3,
|
|
2254
2108
|
cloneElement as cloneElement4,
|
|
2255
2109
|
isValidElement,
|
|
2256
|
-
useEffect as
|
|
2110
|
+
useEffect as useEffect8,
|
|
2257
2111
|
useId as useId6,
|
|
2258
|
-
useRef as
|
|
2259
|
-
useState as
|
|
2112
|
+
useRef as useRef6,
|
|
2113
|
+
useState as useState11
|
|
2260
2114
|
} from "react";
|
|
2261
2115
|
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2262
2116
|
var CheckboxGroup = ({ ref, ...props }) => {
|
|
@@ -2276,10 +2130,10 @@ var CheckboxGroup = ({ ref, ...props }) => {
|
|
|
2276
2130
|
lastItemDisables = false,
|
|
2277
2131
|
...rest
|
|
2278
2132
|
} = props;
|
|
2279
|
-
const [selected, setSelected] =
|
|
2280
|
-
const isInitializedRef =
|
|
2281
|
-
const prevDefaultValueRef =
|
|
2282
|
-
|
|
2133
|
+
const [selected, setSelected] = useState11(defaultValue);
|
|
2134
|
+
const isInitializedRef = useRef6(false);
|
|
2135
|
+
const prevDefaultValueRef = useRef6(defaultValue);
|
|
2136
|
+
useEffect8(() => {
|
|
2283
2137
|
const hasChanged = defaultValue.length !== prevDefaultValueRef.current.length || defaultValue.some(
|
|
2284
2138
|
(val, index) => val !== prevDefaultValueRef.current[index]
|
|
2285
2139
|
);
|
|
@@ -2394,7 +2248,7 @@ Container.displayName = "Container";
|
|
|
2394
2248
|
|
|
2395
2249
|
// src/components/DateField/DateField.tsx
|
|
2396
2250
|
import classNames23 from "classnames/dedupe";
|
|
2397
|
-
import { useEffect as
|
|
2251
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
|
|
2398
2252
|
|
|
2399
2253
|
// src/components/DateField/validation.ts
|
|
2400
2254
|
var convertToDateFormat = (date, format) => {
|
|
@@ -2442,9 +2296,9 @@ var DateField = ({ ref, ...props }) => {
|
|
|
2442
2296
|
value,
|
|
2443
2297
|
...otherProps
|
|
2444
2298
|
} = props;
|
|
2445
|
-
const [error3, setError] =
|
|
2446
|
-
const [isInvalid, setIsInvalid] =
|
|
2447
|
-
const localRef =
|
|
2299
|
+
const [error3, setError] = useState12(errorMessage);
|
|
2300
|
+
const [isInvalid, setIsInvalid] = useState12(void 0);
|
|
2301
|
+
const localRef = useRef7(null);
|
|
2448
2302
|
const classes = classNames23("mobius-date-field", className);
|
|
2449
2303
|
const formattedMin = min ? convertToDateFormat(min, format) : void 0;
|
|
2450
2304
|
const formattedMax = max ? convertToDateFormat(max, format) : void 0;
|
|
@@ -2458,7 +2312,7 @@ var DateField = ({ ref, ...props }) => {
|
|
|
2458
2312
|
setError(props.errorMessage);
|
|
2459
2313
|
setIsInvalid(false);
|
|
2460
2314
|
};
|
|
2461
|
-
|
|
2315
|
+
useEffect9(() => {
|
|
2462
2316
|
if (!isValidDate(min, format)) {
|
|
2463
2317
|
setInvalidState(`Invalid min date: ${min}`);
|
|
2464
2318
|
return;
|
|
@@ -2517,7 +2371,7 @@ Content.displayName = "Content";
|
|
|
2517
2371
|
|
|
2518
2372
|
// src/components/Drawer/Drawer.tsx
|
|
2519
2373
|
import classNames24 from "classnames/dedupe";
|
|
2520
|
-
import { useEffect as
|
|
2374
|
+
import { useEffect as useEffect10, useId as useId7, useMemo as useMemo2, useRef as useRef8, useState as useState13 } from "react";
|
|
2521
2375
|
|
|
2522
2376
|
// src/components/Drawer/DrawerContext.tsx
|
|
2523
2377
|
import { createContext } from "react";
|
|
@@ -2542,8 +2396,8 @@ var Drawer = ({ ref, ...props }) => {
|
|
|
2542
2396
|
onClose,
|
|
2543
2397
|
children
|
|
2544
2398
|
} = props;
|
|
2545
|
-
const dialogRef =
|
|
2546
|
-
const [shouldTransition, setShouldTransition] =
|
|
2399
|
+
const dialogRef = useRef8(null);
|
|
2400
|
+
const [shouldTransition, setShouldTransition] = useState13(false);
|
|
2547
2401
|
const { close } = useDialog({
|
|
2548
2402
|
ref: dialogRef,
|
|
2549
2403
|
isOpen,
|
|
@@ -2565,10 +2419,10 @@ var Drawer = ({ ref, ...props }) => {
|
|
|
2565
2419
|
"--should-transition": shouldTransition
|
|
2566
2420
|
}
|
|
2567
2421
|
);
|
|
2568
|
-
|
|
2422
|
+
useEffect10(() => {
|
|
2569
2423
|
setShouldTransition(supportsDialog());
|
|
2570
2424
|
}, []);
|
|
2571
|
-
const contextValue =
|
|
2425
|
+
const contextValue = useMemo2(
|
|
2572
2426
|
() => ({
|
|
2573
2427
|
onClose: close,
|
|
2574
2428
|
closeLabel,
|
|
@@ -2635,7 +2489,7 @@ var Drawer2 = Object.assign(Drawer, {
|
|
|
2635
2489
|
Drawer2.displayName = "Drawer";
|
|
2636
2490
|
|
|
2637
2491
|
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
2638
|
-
import { Children as Children4, isValidElement as isValidElement2, cloneElement as cloneElement5, useState as
|
|
2492
|
+
import { Children as Children4, isValidElement as isValidElement2, cloneElement as cloneElement5, useState as useState14 } from "react";
|
|
2639
2493
|
import useDropdownMenu from "react-accessible-dropdown-menu-hook";
|
|
2640
2494
|
import classNames25 from "classnames/dedupe";
|
|
2641
2495
|
import { jsx as jsx30, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -2647,7 +2501,7 @@ var DropdownMenu = ({ ref, ...props }) => {
|
|
|
2647
2501
|
children,
|
|
2648
2502
|
...otherProps
|
|
2649
2503
|
} = props;
|
|
2650
|
-
const [activeId, setActiveId] =
|
|
2504
|
+
const [activeId, setActiveId] = useState14(null);
|
|
2651
2505
|
const numberOfItems = Children4.count(children);
|
|
2652
2506
|
const {
|
|
2653
2507
|
buttonProps,
|
|
@@ -2816,7 +2670,7 @@ var Grid = ({ ref: _ref, ...props }) => {
|
|
|
2816
2670
|
Grid.displayName = "Grid";
|
|
2817
2671
|
|
|
2818
2672
|
// src/components/Grid/Item.tsx
|
|
2819
|
-
import { useEffect as
|
|
2673
|
+
import { useEffect as useEffect11, useState as useState15 } from "react";
|
|
2820
2674
|
import classNames29 from "classnames/dedupe";
|
|
2821
2675
|
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
2822
2676
|
var getBreakpointMap = (config) => Object.entries(config).reduce(
|
|
@@ -2853,9 +2707,9 @@ var GridItem = ({ ref: _ref, ...props }) => {
|
|
|
2853
2707
|
xl,
|
|
2854
2708
|
xxl
|
|
2855
2709
|
});
|
|
2856
|
-
const [responsiveSpan, setResponsiveSpan] =
|
|
2710
|
+
const [responsiveSpan, setResponsiveSpan] = useState15();
|
|
2857
2711
|
const classes = classNames29("mobius-grid__item", className);
|
|
2858
|
-
|
|
2712
|
+
useEffect11(() => {
|
|
2859
2713
|
setResponsiveSpan(breakpointMap[breakpointSize]);
|
|
2860
2714
|
}, [breakpointSize, breakpointMap]);
|
|
2861
2715
|
const styles = {
|
|
@@ -3126,7 +2980,7 @@ Header2.displayName = "Header";
|
|
|
3126
2980
|
|
|
3127
2981
|
// src/components/Modal/Modal.tsx
|
|
3128
2982
|
import classNames37 from "classnames/dedupe";
|
|
3129
|
-
import { useEffect as
|
|
2983
|
+
import { useEffect as useEffect12, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
|
|
3130
2984
|
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
3131
2985
|
var TRANSITION_CSS_VARIABLE2 = "--modal-transition-duration";
|
|
3132
2986
|
var Modal = ({ ref, ...props }) => {
|
|
@@ -3141,11 +2995,11 @@ var Modal = ({ ref, ...props }) => {
|
|
|
3141
2995
|
animation,
|
|
3142
2996
|
...rest
|
|
3143
2997
|
} = props;
|
|
3144
|
-
const [shouldTransition, setShouldTransition] =
|
|
3145
|
-
|
|
2998
|
+
const [shouldTransition, setShouldTransition] = useState16(false);
|
|
2999
|
+
useEffect12(() => {
|
|
3146
3000
|
setShouldTransition(supportsDialog());
|
|
3147
3001
|
}, []);
|
|
3148
|
-
const dialogRef =
|
|
3002
|
+
const dialogRef = useRef9(null);
|
|
3149
3003
|
const { close } = useDialog({
|
|
3150
3004
|
ref: dialogRef,
|
|
3151
3005
|
isOpen,
|
|
@@ -3169,7 +3023,7 @@ var Modal = ({ ref, ...props }) => {
|
|
|
3169
3023
|
},
|
|
3170
3024
|
className
|
|
3171
3025
|
);
|
|
3172
|
-
const contextValue =
|
|
3026
|
+
const contextValue = useMemo3(
|
|
3173
3027
|
() => ({
|
|
3174
3028
|
onClose: close,
|
|
3175
3029
|
closeLabel
|
|
@@ -3198,7 +3052,7 @@ Modal2.displayName = "Modal";
|
|
|
3198
3052
|
|
|
3199
3053
|
// src/components/NumberField/NumberField.tsx
|
|
3200
3054
|
import classNames38 from "classnames/dedupe";
|
|
3201
|
-
import { useCallback as useCallback5, useEffect as
|
|
3055
|
+
import { useCallback as useCallback5, useEffect as useEffect13, useRef as useRef10 } from "react";
|
|
3202
3056
|
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
3203
3057
|
var NumberField = ({ ref, ...props }) => {
|
|
3204
3058
|
const {
|
|
@@ -3215,9 +3069,9 @@ var NumberField = ({ ref, ...props }) => {
|
|
|
3215
3069
|
onBlur: customOnBlur,
|
|
3216
3070
|
...rest
|
|
3217
3071
|
} = otherProps;
|
|
3218
|
-
const focusedInputRef =
|
|
3072
|
+
const focusedInputRef = useRef10(null);
|
|
3219
3073
|
const wheelHandler = useCallback5((ev) => ev.preventDefault(), []);
|
|
3220
|
-
|
|
3074
|
+
useEffect13(() => {
|
|
3221
3075
|
return () => {
|
|
3222
3076
|
focusedInputRef.current?.removeEventListener("wheel", wheelHandler);
|
|
3223
3077
|
focusedInputRef.current = null;
|
|
@@ -3298,7 +3152,7 @@ Option2.displayName = "Option";
|
|
|
3298
3152
|
|
|
3299
3153
|
// src/components/PasswordField/PasswordField.tsx
|
|
3300
3154
|
import classNames39 from "classnames/dedupe";
|
|
3301
|
-
import { useRef as
|
|
3155
|
+
import { useRef as useRef11, useState as useState17 } from "react";
|
|
3302
3156
|
|
|
3303
3157
|
// src/components/PasswordField/ShowHideButton.tsx
|
|
3304
3158
|
import { eye, eyeSlash } from "@simplybusiness/icons";
|
|
@@ -3328,10 +3182,10 @@ var PasswordField = ({
|
|
|
3328
3182
|
className,
|
|
3329
3183
|
...props
|
|
3330
3184
|
}) => {
|
|
3331
|
-
const [show, setShow] =
|
|
3185
|
+
const [show, setShow] = useState17(false);
|
|
3332
3186
|
const type = show ? "text" : "password";
|
|
3333
3187
|
const classes = classNames39("mobius-password-field", className);
|
|
3334
|
-
const localRef =
|
|
3188
|
+
const localRef = useRef11(null);
|
|
3335
3189
|
const handleShowHideButtonClick = () => {
|
|
3336
3190
|
const selectionStart = localRef.current?.selectionStart;
|
|
3337
3191
|
const selectionEnd = localRef.current?.selectionEnd;
|
|
@@ -3370,13 +3224,14 @@ import {
|
|
|
3370
3224
|
} from "@floating-ui/react";
|
|
3371
3225
|
import { cross as cross3 } from "@simplybusiness/icons";
|
|
3372
3226
|
import classNames40 from "classnames/dedupe";
|
|
3373
|
-
import { cloneElement as cloneElement9, useRef as
|
|
3227
|
+
import { cloneElement as cloneElement9, useRef as useRef12, useState as useState18 } from "react";
|
|
3228
|
+
import { useWindowEvent as useWindowEvent2 } from "@simplybusiness/mobius-hooks";
|
|
3374
3229
|
import { Fragment as Fragment4, jsx as jsx49, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3375
3230
|
var OFFSET_FROM_CONTENT_DEFAULT = 10;
|
|
3376
3231
|
var Popover = (props) => {
|
|
3377
3232
|
const { trigger, children, onOpen, onClose, className } = props;
|
|
3378
|
-
const arrowRef =
|
|
3379
|
-
const [isOpen, setIsOpen] =
|
|
3233
|
+
const arrowRef = useRef12(null);
|
|
3234
|
+
const [isOpen, setIsOpen] = useState18(false);
|
|
3380
3235
|
const { refs, floatingStyles, context } = useFloating({
|
|
3381
3236
|
open: isOpen,
|
|
3382
3237
|
onOpenChange: setIsOpen,
|
|
@@ -3425,7 +3280,7 @@ var Popover = (props) => {
|
|
|
3425
3280
|
onClick: toggleVisibility,
|
|
3426
3281
|
...getReferenceProps()
|
|
3427
3282
|
});
|
|
3428
|
-
|
|
3283
|
+
useWindowEvent2("keydown", (e) => {
|
|
3429
3284
|
if (e.key === "Escape") {
|
|
3430
3285
|
onClose?.();
|
|
3431
3286
|
e.preventDefault();
|
|
@@ -3586,8 +3441,8 @@ import {
|
|
|
3586
3441
|
Children as Children7,
|
|
3587
3442
|
isValidElement as isValidElement5,
|
|
3588
3443
|
useLayoutEffect,
|
|
3589
|
-
useMemo as
|
|
3590
|
-
useRef as
|
|
3444
|
+
useMemo as useMemo4,
|
|
3445
|
+
useRef as useRef13
|
|
3591
3446
|
} from "react";
|
|
3592
3447
|
import { Fragment as Fragment5, jsx as jsx51, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3593
3448
|
var Radio = ({ ref, ...props }) => {
|
|
@@ -3613,12 +3468,12 @@ var Radio = ({ ref, ...props }) => {
|
|
|
3613
3468
|
const isMultiline = label && children;
|
|
3614
3469
|
const isControlled = selected !== void 0;
|
|
3615
3470
|
const isChecked = isControlled ? selected === value : defaultChecked;
|
|
3616
|
-
const contentRef =
|
|
3617
|
-
const prevOverflowRef =
|
|
3471
|
+
const contentRef = useRef13(null);
|
|
3472
|
+
const prevOverflowRef = useRef13({
|
|
3618
3473
|
vertical: false,
|
|
3619
3474
|
horizontal: false
|
|
3620
3475
|
});
|
|
3621
|
-
const hasIconFirst =
|
|
3476
|
+
const hasIconFirst = useMemo4(() => {
|
|
3622
3477
|
if (!children || Children7.count(children) === 0) return false;
|
|
3623
3478
|
const firstChild = Children7.toArray(children)[0];
|
|
3624
3479
|
if (!isValidElement5(firstChild)) return false;
|
|
@@ -3710,10 +3565,10 @@ import {
|
|
|
3710
3565
|
cloneElement as cloneElement10,
|
|
3711
3566
|
isValidElement as isValidElement6,
|
|
3712
3567
|
useCallback as useCallback6,
|
|
3713
|
-
useEffect as
|
|
3568
|
+
useEffect as useEffect14,
|
|
3714
3569
|
useId as useId10,
|
|
3715
|
-
useRef as
|
|
3716
|
-
useState as
|
|
3570
|
+
useRef as useRef14,
|
|
3571
|
+
useState as useState19
|
|
3717
3572
|
} from "react";
|
|
3718
3573
|
import { jsx as jsx52, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3719
3574
|
var getDefaultVal = (children, defaultValue) => {
|
|
@@ -3743,10 +3598,10 @@ var RadioGroup = ({ ref, ...props }) => {
|
|
|
3743
3598
|
...rest
|
|
3744
3599
|
} = props;
|
|
3745
3600
|
const defaultSelected = getDefaultVal(children, value || defaultValue);
|
|
3746
|
-
const [selected, setSelected] =
|
|
3747
|
-
const overflowsRef =
|
|
3748
|
-
const [hasOverflow, setHasOverflow] =
|
|
3749
|
-
|
|
3601
|
+
const [selected, setSelected] = useState19(defaultSelected);
|
|
3602
|
+
const overflowsRef = useRef14({});
|
|
3603
|
+
const [hasOverflow, setHasOverflow] = useState19(false);
|
|
3604
|
+
useEffect14(() => {
|
|
3750
3605
|
if (value !== void 0) {
|
|
3751
3606
|
setSelected(value);
|
|
3752
3607
|
}
|
|
@@ -3957,10 +3812,10 @@ Select.displayName = "Select";
|
|
|
3957
3812
|
|
|
3958
3813
|
// src/components/Slider/Slider.tsx
|
|
3959
3814
|
import classNames47 from "classnames/dedupe";
|
|
3960
|
-
import { useRef as
|
|
3815
|
+
import { useRef as useRef15, useState as useState20 } from "react";
|
|
3961
3816
|
|
|
3962
3817
|
// src/components/Slider/helpers.ts
|
|
3963
|
-
import { useCallback as useCallback7, useMemo as
|
|
3818
|
+
import { useCallback as useCallback7, useMemo as useMemo5 } from "react";
|
|
3964
3819
|
function numberFormatter(value, formatOptions, locale = navigator.languages?.[0] || "en-GB") {
|
|
3965
3820
|
if (!formatOptions) {
|
|
3966
3821
|
return value?.toString() || "";
|
|
@@ -3990,11 +3845,11 @@ var Slider = (props) => {
|
|
|
3990
3845
|
formatOptions,
|
|
3991
3846
|
isDisabled = false
|
|
3992
3847
|
} = props;
|
|
3993
|
-
const trackRef =
|
|
3994
|
-
const [currentValue, setCurrentValue] =
|
|
3848
|
+
const trackRef = useRef15(null);
|
|
3849
|
+
const [currentValue, setCurrentValue] = useState20(
|
|
3995
3850
|
value || defaultValue || 0
|
|
3996
3851
|
);
|
|
3997
|
-
const [isDragging, setIsDraggging] =
|
|
3852
|
+
const [isDragging, setIsDraggging] = useState20(false);
|
|
3998
3853
|
const { labelProps, fieldProps } = useLabel({
|
|
3999
3854
|
id,
|
|
4000
3855
|
label,
|
|
@@ -4080,8 +3935,8 @@ SVG.displayName = "SVG";
|
|
|
4080
3935
|
|
|
4081
3936
|
// src/components/Switch/Switch.tsx
|
|
4082
3937
|
import {
|
|
4083
|
-
useState as
|
|
4084
|
-
useEffect as
|
|
3938
|
+
useState as useState21,
|
|
3939
|
+
useEffect as useEffect15
|
|
4085
3940
|
} from "react";
|
|
4086
3941
|
import classNames49 from "classnames/dedupe";
|
|
4087
3942
|
import { jsx as jsx58, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
@@ -4093,8 +3948,8 @@ var Switch = ({ ref, ...props }) => {
|
|
|
4093
3948
|
isDisabled = false,
|
|
4094
3949
|
...otherProps
|
|
4095
3950
|
} = props;
|
|
4096
|
-
const [enabled, setEnabled] =
|
|
4097
|
-
|
|
3951
|
+
const [enabled, setEnabled] = useState21(checked);
|
|
3952
|
+
useEffect15(() => {
|
|
4098
3953
|
setEnabled(checked);
|
|
4099
3954
|
}, [checked]);
|
|
4100
3955
|
const classes = classNames49(
|
|
@@ -4307,7 +4162,7 @@ var TextArea = ({ ref, ...props }) => {
|
|
|
4307
4162
|
TextArea.displayName = "TextArea";
|
|
4308
4163
|
|
|
4309
4164
|
// src/components/TextOrHTML/TextOrHTML.tsx
|
|
4310
|
-
import { useMemo as
|
|
4165
|
+
import { useMemo as useMemo6 } from "react";
|
|
4311
4166
|
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
4312
4167
|
var TextOrHTML = ({
|
|
4313
4168
|
ref,
|
|
@@ -4318,7 +4173,7 @@ var TextOrHTML = ({
|
|
|
4318
4173
|
...textProps
|
|
4319
4174
|
}) => {
|
|
4320
4175
|
const DangerousComponent = htmlElementType;
|
|
4321
|
-
const dangerousHTML =
|
|
4176
|
+
const dangerousHTML = useMemo6(() => ({ __html: text }), [text]);
|
|
4322
4177
|
const dangerousElement = /* @__PURE__ */ jsx69(
|
|
4323
4178
|
DangerousComponent,
|
|
4324
4179
|
{
|
|
@@ -4472,7 +4327,7 @@ var toast = {
|
|
|
4472
4327
|
};
|
|
4473
4328
|
|
|
4474
4329
|
// src/components/Toast/Toaster.tsx
|
|
4475
|
-
import { useEffect as
|
|
4330
|
+
import { useEffect as useEffect16 } from "react";
|
|
4476
4331
|
import { Toaster as SonnerToaster } from "sonner";
|
|
4477
4332
|
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
4478
4333
|
var Toaster = ({
|
|
@@ -4483,7 +4338,7 @@ var Toaster = ({
|
|
|
4483
4338
|
visibleToasts = 3,
|
|
4484
4339
|
gap = 8
|
|
4485
4340
|
}) => {
|
|
4486
|
-
|
|
4341
|
+
useEffect16(() => {
|
|
4487
4342
|
toastState.showCloseButton = closeButton;
|
|
4488
4343
|
}, [closeButton]);
|
|
4489
4344
|
return /* @__PURE__ */ jsx72(
|
|
@@ -4502,7 +4357,7 @@ Toaster.displayName = "Toaster";
|
|
|
4502
4357
|
|
|
4503
4358
|
// src/components/Trust/Trust.tsx
|
|
4504
4359
|
import classNames62 from "classnames/dedupe";
|
|
4505
|
-
import { useEffect as
|
|
4360
|
+
import { useEffect as useEffect17, useRef as useRef16, useState as useState22 } from "react";
|
|
4506
4361
|
|
|
4507
4362
|
// src/components/Trust/constants.ts
|
|
4508
4363
|
var REQUIRED_TRUSTPILOT_CLASS_NAME = "trustpilot-widget";
|
|
@@ -4578,8 +4433,8 @@ var Trust = ({ ref, ...props }) => {
|
|
|
4578
4433
|
stars,
|
|
4579
4434
|
className
|
|
4580
4435
|
} = props;
|
|
4581
|
-
const [isMounted, setIsMounted] =
|
|
4582
|
-
const trustRef =
|
|
4436
|
+
const [isMounted, setIsMounted] = useState22(false);
|
|
4437
|
+
const trustRef = useRef16(null);
|
|
4583
4438
|
const {
|
|
4584
4439
|
templateId,
|
|
4585
4440
|
className: variantClassName,
|
|
@@ -4606,13 +4461,13 @@ var Trust = ({ ref, ...props }) => {
|
|
|
4606
4461
|
},
|
|
4607
4462
|
className
|
|
4608
4463
|
);
|
|
4609
|
-
|
|
4464
|
+
useEffect17(() => {
|
|
4610
4465
|
const hasTrustpilotLoaded = trustRef.current && window?.Trustpilot && window?.Trustpilot.loadFromElement;
|
|
4611
4466
|
if (isMounted && hasTrustpilotLoaded) {
|
|
4612
4467
|
window.Trustpilot.loadFromElement(trustRef.current, true);
|
|
4613
4468
|
}
|
|
4614
4469
|
}, [isMounted]);
|
|
4615
|
-
|
|
4470
|
+
useEffect17(() => {
|
|
4616
4471
|
setIsMounted(true);
|
|
4617
4472
|
}, []);
|
|
4618
4473
|
if (!isMounted) return /* @__PURE__ */ jsx73("div", { style: styles });
|
|
@@ -4639,7 +4494,7 @@ var Trust = ({ ref, ...props }) => {
|
|
|
4639
4494
|
|
|
4640
4495
|
// src/components/ExpandableText/ExpandableText.tsx
|
|
4641
4496
|
import classNames63 from "classnames/dedupe";
|
|
4642
|
-
import { useEffect as
|
|
4497
|
+
import { useEffect as useEffect18, useId as useId12, useRef as useRef17, useState as useState23 } from "react";
|
|
4643
4498
|
import { jsx as jsx74, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
4644
4499
|
var ExpandableText = ({ ref, ...props }) => {
|
|
4645
4500
|
const {
|
|
@@ -4654,14 +4509,14 @@ var ExpandableText = ({ ref, ...props }) => {
|
|
|
4654
4509
|
onToggle,
|
|
4655
4510
|
...otherProps
|
|
4656
4511
|
} = props;
|
|
4657
|
-
const [isExpanded, setIsExpanded] =
|
|
4658
|
-
const [isCollapsed, setIsCollapsed] =
|
|
4659
|
-
const textRef =
|
|
4512
|
+
const [isExpanded, setIsExpanded] = useState23(false);
|
|
4513
|
+
const [isCollapsed, setIsCollapsed] = useState23(false);
|
|
4514
|
+
const textRef = useRef17(null);
|
|
4660
4515
|
const { down } = useBreakpoint();
|
|
4661
4516
|
const baseId = useId12();
|
|
4662
4517
|
const expandButtonId = `expandable-text-expand-${baseId}`;
|
|
4663
4518
|
const shouldCollapse = breakpoint ? down(breakpoint) : true;
|
|
4664
|
-
|
|
4519
|
+
useEffect18(() => {
|
|
4665
4520
|
if (!shouldCollapse || !textRef.current) {
|
|
4666
4521
|
setIsCollapsed(false);
|
|
4667
4522
|
return;
|
|
@@ -4724,7 +4579,7 @@ var ExpandableText = ({ ref, ...props }) => {
|
|
|
4724
4579
|
ExpandableText.displayName = "ExpandableText";
|
|
4725
4580
|
|
|
4726
4581
|
// src/components/MaskedField/MaskedField.tsx
|
|
4727
|
-
import { useCallback as useCallback8, useEffect as
|
|
4582
|
+
import { useCallback as useCallback8, useEffect as useEffect19 } from "react";
|
|
4728
4583
|
import { useIMask } from "react-imask";
|
|
4729
4584
|
import { jsx as jsx75 } from "react/jsx-runtime";
|
|
4730
4585
|
var useAcceptHandler = (onChange, useMaskedValue, name) => {
|
|
@@ -4787,7 +4642,7 @@ var ControlledMaskedField = ({
|
|
|
4787
4642
|
const { ref: imaskRef, maskRef, setValue } = useIMask(mask, { onAccept });
|
|
4788
4643
|
const combinedRef = useCombinedRef(imaskRef, forwardedRef);
|
|
4789
4644
|
const handleBlur = useBlurHandler(onBlur, maskRef, useMaskedValue, name);
|
|
4790
|
-
|
|
4645
|
+
useEffect19(() => {
|
|
4791
4646
|
if (!maskRef.current) {
|
|
4792
4647
|
return;
|
|
4793
4648
|
}
|
|
@@ -4919,21 +4774,14 @@ export {
|
|
|
4919
4774
|
convertToDateFormat,
|
|
4920
4775
|
isValidDate,
|
|
4921
4776
|
toast,
|
|
4922
|
-
useBodyScrollLock,
|
|
4923
4777
|
useBreakpoint,
|
|
4924
4778
|
useButton,
|
|
4925
|
-
useDebouncedValue,
|
|
4926
4779
|
useDialog,
|
|
4927
4780
|
useDialogPolyfill,
|
|
4928
4781
|
useDrawer,
|
|
4929
4782
|
useLabel,
|
|
4930
4783
|
useModal,
|
|
4931
|
-
useOnClickOutside,
|
|
4932
|
-
useOnUnmount,
|
|
4933
|
-
usePrefersReducedMotion,
|
|
4934
|
-
useRenderCount,
|
|
4935
4784
|
useTextField,
|
|
4936
|
-
useValidationClasses
|
|
4937
|
-
useWindowEvent
|
|
4785
|
+
useValidationClasses
|
|
4938
4786
|
};
|
|
4939
4787
|
//# sourceMappingURL=index.js.map
|