@alto-avios/alto-ui 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Accordion.css +1 -0
- package/dist/assets/AviosBadge.css +1 -0
- package/dist/assets/Button.css +1 -1
- package/dist/assets/CalloutBanner.css +1 -0
- package/dist/assets/CreditCardNumberField.css +1 -0
- package/dist/assets/DetailsDisclosure.css +1 -0
- package/dist/assets/Dialog.css +1 -0
- package/dist/assets/ErrorSummary.css +1 -0
- package/dist/assets/FieldHeader.css +1 -1
- package/dist/assets/FieldLabel.css +1 -1
- package/dist/assets/FieldsetHeader.css +1 -1
- package/dist/assets/Icon.css +1 -0
- package/dist/assets/IconBackdrop.css +1 -0
- package/dist/assets/IconButton.css +1 -1
- package/dist/assets/Menu.css +1 -0
- package/dist/assets/PasswordField.css +1 -0
- package/dist/assets/PhoneNumberField.css +1 -0
- package/dist/assets/Popover.css +1 -0
- package/dist/assets/SelectCard.css +1 -0
- package/dist/assets/SelectNative.css +1 -0
- package/dist/assets/Slider.css +1 -0
- package/dist/assets/Switch.css +1 -0
- package/dist/assets/Tag.css +1 -1
- package/dist/assets/ToggleButton.css +1 -1
- package/dist/assets/ToggleIconButton.css +1 -1
- package/dist/assets/backgroundColor.css +1 -0
- package/dist/assets/flex.css +1 -1
- package/dist/assets/foregroundColor.css +1 -0
- package/dist/assets/position.css +1 -0
- package/dist/components/Accordion/Accordion.d.ts +35 -0
- package/dist/components/Accordion/Accordion.js +140 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Accordion/index.js +5 -0
- package/dist/components/Accordion/index.js.map +1 -0
- package/dist/components/AviosBadge/AviosBadge.d.ts +34 -0
- package/dist/components/AviosBadge/AviosBadge.js +58 -0
- package/dist/components/AviosBadge/AviosBadge.js.map +1 -0
- package/dist/components/AviosBadge/index.d.ts +1 -0
- package/dist/components/AviosBadge/index.js +5 -0
- package/dist/components/AviosBadge/index.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts +7 -2
- package/dist/components/Badge/Badge.js +2 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Box/Box.d.ts +9 -5
- package/dist/components/Box/Box.js +10 -1
- package/dist/components/Box/Box.js.map +1 -1
- package/dist/components/Button/Button.js +31 -31
- package/dist/components/CalloutBanner/CalloutBanner.d.ts +21 -0
- package/dist/components/CalloutBanner/CalloutBanner.js +96 -0
- package/dist/components/CalloutBanner/CalloutBanner.js.map +1 -0
- package/dist/components/CalloutBanner/index.d.ts +1 -0
- package/dist/components/CalloutBanner/index.js +5 -0
- package/dist/components/CalloutBanner/index.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/CreditCardNumberField/CreditCardNumberField.d.ts +29 -0
- package/dist/components/CreditCardNumberField/CreditCardNumberField.js +46 -0
- package/dist/components/CreditCardNumberField/CreditCardNumberField.js.map +1 -0
- package/dist/components/CreditCardNumberField/index.d.ts +1 -0
- package/dist/components/CreditCardNumberField/index.js +5 -0
- package/dist/components/CreditCardNumberField/index.js.map +1 -0
- package/dist/components/DateField/DateField.d.ts +22 -3
- package/dist/components/DateField/DateField.js +856 -2
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/DetailsDisclosure/DetailsDisclosure.d.ts +33 -0
- package/dist/components/DetailsDisclosure/DetailsDisclosure.js +39 -0
- package/dist/components/DetailsDisclosure/DetailsDisclosure.js.map +1 -0
- package/dist/components/DetailsDisclosure/index.d.ts +2 -0
- package/dist/components/DetailsDisclosure/index.js +5 -0
- package/dist/components/DetailsDisclosure/index.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +46 -0
- package/dist/components/Dialog/Dialog.js +117 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/Dialog/index.js +5 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +7 -0
- package/dist/components/ErrorSummary/ErrorSummary.js +44 -0
- package/dist/components/ErrorSummary/ErrorSummary.js.map +1 -0
- package/dist/components/ErrorSummary/index.d.ts +1 -0
- package/dist/components/ErrorSummary/index.js +5 -0
- package/dist/components/ErrorSummary/index.js.map +1 -0
- package/dist/components/FieldError/FieldError.js +1 -1
- package/dist/components/FieldHeader/FieldHeader.js +6 -6
- package/dist/components/FieldLabel/FieldLabel.js +1 -1
- package/dist/components/FieldsetHeader/FieldsetHeader.js +3 -3
- package/dist/components/Heading/Heading.d.ts +25 -6
- package/dist/components/Heading/Heading.js +9 -4
- package/dist/components/Heading/Heading.js.map +1 -1
- package/dist/components/Icon/Icon.d.ts +31 -4
- package/dist/components/Icon/Icon.js +98 -5
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/IconBackdrop/IconBackdrop.d.ts +24 -0
- package/dist/components/IconBackdrop/IconBackdrop.js +34 -0
- package/dist/components/IconBackdrop/IconBackdrop.js.map +1 -0
- package/dist/components/IconBackdrop/index.d.ts +1 -0
- package/dist/components/IconBackdrop/index.js +5 -0
- package/dist/components/IconBackdrop/index.js.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +1 -1
- package/dist/components/IconButton/IconButton.js +28 -28
- package/dist/components/Image/Image.d.ts +3 -2
- package/dist/components/Image/Image.js +7 -2
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Link/Link.d.ts +3 -3
- package/dist/components/Link/Link.js +2 -2
- package/dist/components/Menu/Menu.d.ts +75 -0
- package/dist/components/Menu/Menu.js +356 -0
- package/dist/components/Menu/Menu.js.map +1 -0
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/Menu/index.js +5 -0
- package/dist/components/Menu/index.js.map +1 -0
- package/dist/components/Paragraph/Paragraph.d.ts +9 -5
- package/dist/components/Paragraph/Paragraph.js +9 -4
- package/dist/components/Paragraph/Paragraph.js.map +1 -1
- package/dist/components/PasswordField/PasswordField.d.ts +30 -0
- package/dist/components/PasswordField/PasswordField.js +104 -0
- package/dist/components/PasswordField/PasswordField.js.map +1 -0
- package/dist/components/PasswordField/index.d.ts +1 -0
- package/dist/components/PasswordField/index.js +5 -0
- package/dist/components/PasswordField/index.js.map +1 -0
- package/dist/components/PhoneNumberField/PhoneNumberField.d.ts +53 -0
- package/dist/components/PhoneNumberField/PhoneNumberField.js +96 -0
- package/dist/components/PhoneNumberField/PhoneNumberField.js.map +1 -0
- package/dist/components/PhoneNumberField/index.d.ts +3 -0
- package/dist/components/PhoneNumberField/index.js +7 -0
- package/dist/components/PhoneNumberField/index.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +48 -0
- package/dist/components/Popover/Popover.js +65 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Popover/index.js +5 -0
- package/dist/components/Popover/index.js.map +1 -0
- package/dist/components/Radio/index.d.ts +1 -0
- package/dist/components/Section/Section.d.ts +2 -1
- package/dist/components/Section/Section.js +7 -2
- package/dist/components/Section/Section.js.map +1 -1
- package/dist/components/SelectCard/SelectCard.d.ts +51 -0
- package/dist/components/SelectCard/SelectCard.js +85 -0
- package/dist/components/SelectCard/SelectCard.js.map +1 -0
- package/dist/components/SelectCard/index.d.ts +1 -0
- package/dist/components/SelectCard/index.js +5 -0
- package/dist/components/SelectCard/index.js.map +1 -0
- package/dist/components/SelectNative/SelectNative.d.ts +56 -0
- package/dist/components/SelectNative/SelectNative.js +40 -0
- package/dist/components/SelectNative/SelectNative.js.map +1 -0
- package/dist/components/SelectNative/index.d.ts +1 -0
- package/dist/components/SelectNative/index.js +5 -0
- package/dist/components/SelectNative/index.js.map +1 -0
- package/dist/components/Slider/Slider.d.ts +33 -0
- package/dist/components/Slider/Slider.js +113 -0
- package/dist/components/Slider/Slider.js.map +1 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +5 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/SubHeading/SubHeading.d.ts +26 -5
- package/dist/components/SubHeading/SubHeading.js +9 -4
- package/dist/components/SubHeading/SubHeading.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +7 -0
- package/dist/components/Switch/Switch.js +18 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Switch/index.js +5 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Tag/Tag.js +4 -4
- package/dist/components/ToggleButton/ToggleButton.js +6 -6
- package/dist/components/ToggleIconButton/ToggleIconButton.js +6 -6
- package/dist/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/components/Tooltip/Tooltip.js +2 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/_base/Field/Field.d.ts +2 -2
- package/dist/components/_base/Field/Field.js +2 -5
- package/dist/components/_base/Field/Field.js.map +1 -1
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +45 -14
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +45 -14
- package/dist/index.js.map +1 -1
- package/dist/react-number-format.es-DMLgWFZX.js +760 -0
- package/dist/react-number-format.es-DMLgWFZX.js.map +1 -0
- package/dist/utils/backgroundColor/backgroundColor.d.ts +8 -0
- package/dist/utils/backgroundColor/backgroundColor.js +102 -0
- package/dist/utils/backgroundColor/backgroundColor.js.map +1 -0
- package/dist/utils/border/border.d.ts +3 -3
- package/dist/utils/creditCard/creditCard.d.ts +7 -0
- package/dist/utils/creditCard/creditCard.js +25 -0
- package/dist/utils/creditCard/creditCard.js.map +1 -0
- package/dist/utils/flex/flex.d.ts +11 -6
- package/dist/utils/flex/flex.js +390 -46
- package/dist/utils/flex/flex.js.map +1 -1
- package/dist/utils/flex/flex.test.d.ts +1 -0
- package/dist/utils/focus/focusStyles.d.ts +1 -1
- package/dist/utils/foregroundColour/foregroundColor.d.ts +8 -0
- package/dist/utils/foregroundColour/foregroundColor.js +125 -0
- package/dist/utils/foregroundColour/foregroundColor.js.map +1 -0
- package/dist/utils/padding/padding.d.ts +7 -7
- package/dist/utils/phoneNumber/phoneNumber.d.ts +24 -0
- package/dist/utils/phoneNumber/phoneNumber.js +566 -0
- package/dist/utils/phoneNumber/phoneNumber.js.map +1 -0
- package/dist/utils/position/position.d.ts +8 -0
- package/dist/utils/position/position.js +57 -0
- package/dist/utils/position/position.js.map +1 -0
- package/dist/utils/position/position.test.d.ts +1 -0
- package/dist/utils/stories/iconPropsArgTypes.js +49 -13
- package/dist/utils/stories/iconPropsArgTypes.js.map +1 -1
- package/package.json +2 -1
- package/dist/assets/backgroundColour.css +0 -1
- package/dist/assets/fgColor.css +0 -1
- package/dist/utils/backgroundColour/backgroundColour.d.ts +0 -8
- package/dist/utils/backgroundColour/backgroundColour.js +0 -102
- package/dist/utils/backgroundColour/backgroundColour.js.map +0 -1
- package/dist/utils/fgColour/fgColor.d.ts +0 -5
- package/dist/utils/fgColour/fgColor.js +0 -84
- package/dist/utils/fgColour/fgColor.js.map +0 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState, useRef, useEffect } from "react";
|
|
3
|
+
import { Button } from "../Button/Button.js";
|
|
4
|
+
import { Popover } from "../Popover/Popover.js";
|
|
5
|
+
import '../../assets/Menu.css';const menuContainer = "_menuContainer_qw7ps_1";
|
|
6
|
+
const menuContent = "_menuContent_qw7ps_6";
|
|
7
|
+
const styles = {
|
|
8
|
+
menuContainer,
|
|
9
|
+
menuContent
|
|
10
|
+
};
|
|
11
|
+
const menuRegistry = {
|
|
12
|
+
activeMenuId: null,
|
|
13
|
+
setActiveMenu: (id) => {
|
|
14
|
+
menuRegistry.activeMenuId = id;
|
|
15
|
+
},
|
|
16
|
+
getActiveMenu: () => menuRegistry.activeMenuId
|
|
17
|
+
};
|
|
18
|
+
const Menu = ({
|
|
19
|
+
label,
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
isDisabled = false,
|
|
22
|
+
placement = "bottom start",
|
|
23
|
+
buttonEmphasis = "tertiary",
|
|
24
|
+
buttonStyleVariant = "neutral",
|
|
25
|
+
buttonOpenVariant = buttonStyleVariant,
|
|
26
|
+
alignToElementId,
|
|
27
|
+
shouldFlip = false,
|
|
28
|
+
openOnHoverAndFocus = false,
|
|
29
|
+
allowTabOut = true,
|
|
30
|
+
children,
|
|
31
|
+
iconStartProps,
|
|
32
|
+
iconEndProps
|
|
33
|
+
}) => {
|
|
34
|
+
const uniqueId = useId();
|
|
35
|
+
const menuId = `menu-${uniqueId}`;
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
const [preventFocusOpen, setPreventFocusOpen] = useState(false);
|
|
38
|
+
const [openedViaKeyboard, setOpenedViaKeyboard] = useState(false);
|
|
39
|
+
const buttonRef = useRef(null);
|
|
40
|
+
const containerRef = useRef(null);
|
|
41
|
+
const menuRef = useRef(null);
|
|
42
|
+
const currentStyleVariant = isOpen ? buttonOpenVariant : buttonStyleVariant;
|
|
43
|
+
const getAlignmentTarget = () => {
|
|
44
|
+
if (alignToElementId) {
|
|
45
|
+
const targetElement = document.getElementById(alignToElementId);
|
|
46
|
+
if (targetElement) {
|
|
47
|
+
return {
|
|
48
|
+
current: targetElement
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return buttonRef;
|
|
53
|
+
};
|
|
54
|
+
const handleKeyDown = (e) => {
|
|
55
|
+
if (e.key === "Escape" && isOpen) {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
menuRegistry.setActiveMenu(null);
|
|
58
|
+
setIsOpen(false);
|
|
59
|
+
setPreventFocusOpen(true);
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
setPreventFocusOpen(false);
|
|
62
|
+
}, 300);
|
|
63
|
+
} else if (e.key === "ArrowDown" && !isOpen) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
66
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
67
|
+
detail: {
|
|
68
|
+
exceptMenuId: menuId
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
menuRegistry.setActiveMenu(menuId);
|
|
73
|
+
setIsOpen(true);
|
|
74
|
+
setOpenedViaKeyboard(true);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const closeMenu = () => {
|
|
78
|
+
menuRegistry.setActiveMenu(null);
|
|
79
|
+
setIsOpen(false);
|
|
80
|
+
setPreventFocusOpen(true);
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
setPreventFocusOpen(false);
|
|
83
|
+
}, 300);
|
|
84
|
+
};
|
|
85
|
+
const toggleMenu = () => {
|
|
86
|
+
const isKeyboardFocused = document.activeElement === buttonRef.current;
|
|
87
|
+
setOpenedViaKeyboard(isKeyboardFocused);
|
|
88
|
+
if (isDisabled) return;
|
|
89
|
+
if (!isOpen) {
|
|
90
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
91
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
92
|
+
detail: {
|
|
93
|
+
exceptMenuId: menuId
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
menuRegistry.setActiveMenu(menuId);
|
|
98
|
+
setIsOpen(true);
|
|
99
|
+
} else {
|
|
100
|
+
menuRegistry.setActiveMenu(null);
|
|
101
|
+
setIsOpen(false);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const handleCloseAll = (e) => {
|
|
106
|
+
const {
|
|
107
|
+
exceptMenuId
|
|
108
|
+
} = e.detail || {};
|
|
109
|
+
if (exceptMenuId && exceptMenuId === menuId) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (isOpen) {
|
|
113
|
+
setIsOpen(false);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
document.addEventListener("menu:closeAll", handleCloseAll);
|
|
117
|
+
return () => {
|
|
118
|
+
document.removeEventListener("menu:closeAll", handleCloseAll);
|
|
119
|
+
};
|
|
120
|
+
}, [menuId, isOpen]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const isActive = menuRegistry.getActiveMenu() === menuId;
|
|
123
|
+
if (isActive !== isOpen) {
|
|
124
|
+
setIsOpen(isActive);
|
|
125
|
+
}
|
|
126
|
+
}, [menuId, isOpen]);
|
|
127
|
+
const findNextFocusableElement = (startElement) => {
|
|
128
|
+
const focusableElements = Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'));
|
|
129
|
+
const startIndex = focusableElements.indexOf(startElement);
|
|
130
|
+
return startIndex !== -1 && startIndex < focusableElements.length - 1 ? focusableElements[startIndex + 1] : focusableElements[0];
|
|
131
|
+
};
|
|
132
|
+
const handleMenuKeyDown = (e) => {
|
|
133
|
+
if (e.key === "Escape") {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
closeMenu();
|
|
136
|
+
if (buttonRef.current) {
|
|
137
|
+
buttonRef.current.focus();
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (e.key === "Tab" && allowTabOut) {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const triggerElement = buttonRef.current;
|
|
144
|
+
if (triggerElement) {
|
|
145
|
+
const nextElement = findNextFocusableElement(triggerElement);
|
|
146
|
+
closeMenu();
|
|
147
|
+
setTimeout(() => {
|
|
148
|
+
if (nextElement) {
|
|
149
|
+
nextElement.focus();
|
|
150
|
+
}
|
|
151
|
+
}, 10);
|
|
152
|
+
} else {
|
|
153
|
+
closeMenu();
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!menuRef.current) return;
|
|
158
|
+
const focusableElements = Array.from(menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'));
|
|
159
|
+
if (focusableElements.length === 0) return;
|
|
160
|
+
const focusedElement = document.activeElement;
|
|
161
|
+
const currentIndex = focusableElements.indexOf(focusedElement);
|
|
162
|
+
if (e.key === "ArrowDown" && currentIndex < focusableElements.length - 1) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
focusableElements[currentIndex + 1].focus();
|
|
165
|
+
} else if (e.key === "ArrowUp" && currentIndex > 0) {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
focusableElements[currentIndex - 1].focus();
|
|
168
|
+
} else if (e.key === "Home") {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
focusableElements[0].focus();
|
|
171
|
+
} else if (e.key === "End") {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
focusableElements[focusableElements.length - 1].focus();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (isOpen && openedViaKeyboard && menuRef.current) {
|
|
178
|
+
const focusableElements = menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])');
|
|
179
|
+
if (focusableElements.length > 0) {
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
focusableElements[0].focus();
|
|
182
|
+
}, 50);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, [isOpen, openedViaKeyboard]);
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (!openOnHoverAndFocus || isDisabled) return;
|
|
188
|
+
let hoverTimeout = null;
|
|
189
|
+
const handleMouseEnter = () => {
|
|
190
|
+
if (hoverTimeout) {
|
|
191
|
+
clearTimeout(hoverTimeout);
|
|
192
|
+
}
|
|
193
|
+
hoverTimeout = setTimeout(() => {
|
|
194
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
195
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
196
|
+
detail: {
|
|
197
|
+
exceptMenuId: menuId
|
|
198
|
+
}
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
setOpenedViaKeyboard(false);
|
|
202
|
+
menuRegistry.setActiveMenu(menuId);
|
|
203
|
+
setIsOpen(true);
|
|
204
|
+
}, 300);
|
|
205
|
+
};
|
|
206
|
+
const handleMouseLeave = () => {
|
|
207
|
+
if (hoverTimeout) {
|
|
208
|
+
clearTimeout(hoverTimeout);
|
|
209
|
+
}
|
|
210
|
+
hoverTimeout = setTimeout(() => {
|
|
211
|
+
if (menuRegistry.getActiveMenu() === menuId) {
|
|
212
|
+
menuRegistry.setActiveMenu(null);
|
|
213
|
+
}
|
|
214
|
+
setIsOpen(false);
|
|
215
|
+
}, 300);
|
|
216
|
+
};
|
|
217
|
+
const buttonElement = buttonRef.current;
|
|
218
|
+
if (buttonElement) {
|
|
219
|
+
buttonElement.addEventListener("mouseenter", handleMouseEnter);
|
|
220
|
+
buttonElement.addEventListener("mouseleave", handleMouseLeave);
|
|
221
|
+
}
|
|
222
|
+
return () => {
|
|
223
|
+
if (buttonElement) {
|
|
224
|
+
buttonElement.removeEventListener("mouseenter", handleMouseEnter);
|
|
225
|
+
buttonElement.removeEventListener("mouseleave", handleMouseLeave);
|
|
226
|
+
}
|
|
227
|
+
if (hoverTimeout) {
|
|
228
|
+
clearTimeout(hoverTimeout);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}, [openOnHoverAndFocus, isDisabled, menuId]);
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (!openOnHoverAndFocus || isDisabled) return;
|
|
234
|
+
const buttonElement = buttonRef.current;
|
|
235
|
+
if (!buttonElement) return;
|
|
236
|
+
let focusTimeout = null;
|
|
237
|
+
let isMenuOpening = false;
|
|
238
|
+
const handleFocus = () => {
|
|
239
|
+
if (preventFocusOpen) return;
|
|
240
|
+
if (focusTimeout) {
|
|
241
|
+
clearTimeout(focusTimeout);
|
|
242
|
+
}
|
|
243
|
+
isMenuOpening = true;
|
|
244
|
+
focusTimeout = setTimeout(() => {
|
|
245
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
246
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
247
|
+
detail: {
|
|
248
|
+
exceptMenuId: menuId
|
|
249
|
+
}
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
const activeElement = document.activeElement;
|
|
253
|
+
const wasFocusedByKeyboard = activeElement === buttonElement && document.activeElement !== document.body;
|
|
254
|
+
setOpenedViaKeyboard(wasFocusedByKeyboard);
|
|
255
|
+
menuRegistry.setActiveMenu(menuId);
|
|
256
|
+
setIsOpen(true);
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
isMenuOpening = false;
|
|
259
|
+
}, 500);
|
|
260
|
+
}, 300);
|
|
261
|
+
};
|
|
262
|
+
const handleBlur = (e) => {
|
|
263
|
+
if (isMenuOpening) return;
|
|
264
|
+
if (focusTimeout) {
|
|
265
|
+
clearTimeout(focusTimeout);
|
|
266
|
+
}
|
|
267
|
+
const containerElement = containerRef.current;
|
|
268
|
+
const relatedTarget = e.relatedTarget;
|
|
269
|
+
if (containerElement && !containerElement.contains(relatedTarget)) {
|
|
270
|
+
focusTimeout = setTimeout(() => {
|
|
271
|
+
if (menuRegistry.getActiveMenu() === menuId) {
|
|
272
|
+
menuRegistry.setActiveMenu(null);
|
|
273
|
+
}
|
|
274
|
+
setIsOpen(false);
|
|
275
|
+
}, 200);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
buttonElement.addEventListener("focus", handleFocus);
|
|
279
|
+
buttonElement.addEventListener("blur", handleBlur);
|
|
280
|
+
return () => {
|
|
281
|
+
buttonElement.removeEventListener("focus", handleFocus);
|
|
282
|
+
buttonElement.removeEventListener("blur", handleBlur);
|
|
283
|
+
if (focusTimeout) {
|
|
284
|
+
clearTimeout(focusTimeout);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}, [openOnHoverAndFocus, isDisabled, preventFocusOpen, menuId]);
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (!isOpen) return;
|
|
290
|
+
const handleOutsideClick = (e) => {
|
|
291
|
+
const container = containerRef.current;
|
|
292
|
+
if (container && !container.contains(e.target)) {
|
|
293
|
+
if (menuRegistry.getActiveMenu() === menuId) {
|
|
294
|
+
menuRegistry.setActiveMenu(null);
|
|
295
|
+
}
|
|
296
|
+
setIsOpen(false);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
300
|
+
return () => {
|
|
301
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
302
|
+
};
|
|
303
|
+
}, [isOpen, menuId]);
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
if (!isOpen) {
|
|
306
|
+
setOpenedViaKeyboard(false);
|
|
307
|
+
}
|
|
308
|
+
}, [isOpen]);
|
|
309
|
+
const menuTriggerState = {
|
|
310
|
+
isOpen,
|
|
311
|
+
open: () => {
|
|
312
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
313
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
314
|
+
detail: {
|
|
315
|
+
exceptMenuId: menuId
|
|
316
|
+
}
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
menuRegistry.setActiveMenu(menuId);
|
|
320
|
+
setIsOpen(true);
|
|
321
|
+
},
|
|
322
|
+
close: closeMenu,
|
|
323
|
+
toggle: () => toggleMenu(),
|
|
324
|
+
setOpen: (open) => {
|
|
325
|
+
if (open) {
|
|
326
|
+
if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
|
|
327
|
+
document.dispatchEvent(new CustomEvent("menu:closeAll", {
|
|
328
|
+
detail: {
|
|
329
|
+
exceptMenuId: menuId
|
|
330
|
+
}
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
menuRegistry.setActiveMenu(menuId);
|
|
334
|
+
} else {
|
|
335
|
+
if (menuRegistry.getActiveMenu() === menuId) {
|
|
336
|
+
menuRegistry.setActiveMenu(null);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
setIsOpen(open);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.menuContainer, ref: containerRef, children: [
|
|
343
|
+
/* @__PURE__ */ jsx(Button, { ref: buttonRef, emphasis: buttonEmphasis, styleVariant: currentStyleVariant, isDisabled, onPress: () => {
|
|
344
|
+
setPreventFocusOpen(false);
|
|
345
|
+
const isKeyboardFocused = document.activeElement === buttonRef.current;
|
|
346
|
+
setOpenedViaKeyboard(isKeyboardFocused);
|
|
347
|
+
toggleMenu();
|
|
348
|
+
}, onKeyDown: handleKeyDown, "aria-haspopup": "true", "aria-expanded": isOpen, iconStartProps, iconEndProps, children: label }),
|
|
349
|
+
isOpen && /* @__PURE__ */ jsx(Popover, { state: menuTriggerState, triggerRef: getAlignmentTarget(), hasArrow: false, placement, shouldFlip, isNonModal: true, allowTabOut, autoFocus: openedViaKeyboard, children: /* @__PURE__ */ jsx("div", { className: styles.menuContent, ref: menuRef, onKeyDown: handleMenuKeyDown, role: "menu", "aria-label": ariaLabel || label, tabIndex: -1, children }) })
|
|
350
|
+
] });
|
|
351
|
+
};
|
|
352
|
+
export {
|
|
353
|
+
Menu,
|
|
354
|
+
Menu as default
|
|
355
|
+
};
|
|
356
|
+
//# sourceMappingURL=Menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Menu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Menu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
|
3
|
-
import {
|
|
3
|
+
import { ForegroundVariants } from '../../utils/foregroundColour/foregroundColor';
|
|
4
4
|
declare const paragraph: (props?: ({
|
|
5
5
|
size?: "lg" | "sm" | "xs" | "md" | null | undefined;
|
|
6
|
-
textAlign?: "
|
|
6
|
+
textAlign?: "center" | "end" | "start" | null | undefined;
|
|
7
7
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
8
|
type ParagraphVariants = VariantProps<typeof paragraph>;
|
|
9
|
-
type FgColorVariants = VariantProps<typeof fgColorVariants>;
|
|
10
9
|
type ParagraphSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
11
10
|
export interface ParagraphProps extends ParagraphVariants {
|
|
12
11
|
children: React.ReactNode;
|
|
@@ -19,12 +18,17 @@ export interface ParagraphProps extends ParagraphVariants {
|
|
|
19
18
|
* The foreground color of the paragraph
|
|
20
19
|
* @default "secondary"
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
foregroundColor?: ForegroundVariants['foregroundColor'];
|
|
22
|
+
/**
|
|
23
|
+
* The foreground color of the paragraph
|
|
24
|
+
* @deprecated Use `foregroundColor` instead
|
|
25
|
+
*/
|
|
26
|
+
fgColor?: ForegroundVariants['foregroundColor'];
|
|
23
27
|
/**
|
|
24
28
|
* The text alignment of the paragraph
|
|
25
29
|
* @default "start"
|
|
26
30
|
*/
|
|
27
31
|
textAlign?: 'start' | 'center' | 'end';
|
|
28
32
|
}
|
|
29
|
-
export declare const Paragraph: ({ children, size, fgColor, textAlign, ...props }: ParagraphProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const Paragraph: ({ children, size, foregroundColor, fgColor, textAlign, ...props }: ParagraphProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
34
|
export default Paragraph;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c as cva } from "../../index-Bi3v_EjJ.js";
|
|
3
|
-
import {
|
|
3
|
+
import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
|
|
4
4
|
import '../../assets/Paragraph.css';const paragraph$1 = "_paragraph_odu3c_1";
|
|
5
5
|
const xs = "_xs_odu3c_9";
|
|
6
6
|
const sm = "_sm_odu3c_15";
|
|
@@ -41,15 +41,20 @@ const paragraph = cva(styles.paragraph, {
|
|
|
41
41
|
const Paragraph = ({
|
|
42
42
|
children,
|
|
43
43
|
size = "md",
|
|
44
|
-
|
|
44
|
+
foregroundColor = "secondary",
|
|
45
|
+
fgColor,
|
|
45
46
|
textAlign = "start",
|
|
46
47
|
...props
|
|
47
48
|
}) => {
|
|
49
|
+
if (fgColor) {
|
|
50
|
+
console.warn("The `fgColor` prop has been deprecated. Please use `foregroundColor` instead.");
|
|
51
|
+
}
|
|
52
|
+
const resolvedFontColor = fgColor ?? foregroundColor ?? "secondary";
|
|
48
53
|
return /* @__PURE__ */ jsx("p", { className: `${paragraph({
|
|
49
54
|
size,
|
|
50
55
|
textAlign
|
|
51
|
-
})} ${
|
|
52
|
-
|
|
56
|
+
})} ${foregroundColorVariants({
|
|
57
|
+
foregroundColor: resolvedFontColor
|
|
53
58
|
})}`, ...props, children });
|
|
54
59
|
};
|
|
55
60
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paragraph.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Paragraph.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FieldProps } from '../_base/Field';
|
|
2
|
+
import { TextFieldProps as AriaTextFieldProps } from 'react-aria-components';
|
|
3
|
+
type PasswordStrengthValidation = {
|
|
4
|
+
message: string;
|
|
5
|
+
validation: (value?: string) => boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface PasswordFieldProps extends FieldProps<AriaTextFieldProps> {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the password input value revealed or not.
|
|
10
|
+
*/
|
|
11
|
+
isVisible?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The strength validations to be applied to the password input value.
|
|
14
|
+
*/
|
|
15
|
+
strengthValidations?: PasswordStrengthValidation[];
|
|
16
|
+
/**
|
|
17
|
+
* Tooltip label to show password
|
|
18
|
+
*/
|
|
19
|
+
tooltipLabelShowPassword?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Tooltip label to hide password
|
|
22
|
+
*/
|
|
23
|
+
tooltipLabelHidePassword?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Label for the password requirements.
|
|
26
|
+
*/
|
|
27
|
+
requirementsLabel?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const PasswordField: ({ tooltipLabelShowPassword, tooltipLabelHidePassword, requirementsLabel, ...props }: PasswordFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export default PasswordField;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { Field } from "../_base/Field/Field.js";
|
|
4
|
+
import { TextField, Group, Input } from "react-aria-components";
|
|
5
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
6
|
+
import { c as cva } from "../../index-Bi3v_EjJ.js";
|
|
7
|
+
import { Icon } from "../Icon/Icon.js";
|
|
8
|
+
import '../../assets/PasswordField.css';const passwordField = "_passwordField_esslh_1";
|
|
9
|
+
const passwordField__strength = "_passwordField__strength_esslh_10";
|
|
10
|
+
const passwordStrengthItem$1 = "_passwordStrengthItem_esslh_88";
|
|
11
|
+
const passwordStrengthItemValid = "_passwordStrengthItemValid_esslh_98";
|
|
12
|
+
const passwordStrengthItemNeutral = "_passwordStrengthItemNeutral_esslh_102";
|
|
13
|
+
const passwordStrengthItemInvalid = "_passwordStrengthItemInvalid_esslh_106";
|
|
14
|
+
const styles = {
|
|
15
|
+
passwordField,
|
|
16
|
+
passwordField__strength,
|
|
17
|
+
passwordStrengthItem: passwordStrengthItem$1,
|
|
18
|
+
passwordStrengthItemValid,
|
|
19
|
+
passwordStrengthItemNeutral,
|
|
20
|
+
passwordStrengthItemInvalid
|
|
21
|
+
};
|
|
22
|
+
const PasswordField = ({
|
|
23
|
+
tooltipLabelShowPassword = "Show Password",
|
|
24
|
+
tooltipLabelHidePassword = "Hide Password",
|
|
25
|
+
requirementsLabel = "Password requirements",
|
|
26
|
+
...props
|
|
27
|
+
}) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const [internalVisible, setInternalVisible] = useState(props.isVisible || false);
|
|
30
|
+
const [internalValue, setInternalValue] = useState(props == null ? void 0 : props.defaultValue);
|
|
31
|
+
const value = (props == null ? void 0 : props.value) ?? internalValue;
|
|
32
|
+
const isVisibleState = (props == null ? void 0 : props.isVisible) ?? internalVisible;
|
|
33
|
+
const handleChange = React.useCallback((e) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
setInternalValue(e.target.value);
|
|
36
|
+
(_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, e.target.value);
|
|
37
|
+
}, [props == null ? void 0 : props.onChange]);
|
|
38
|
+
const tooltipLabel = isVisibleState ? tooltipLabelHidePassword : tooltipLabelShowPassword;
|
|
39
|
+
return /* @__PURE__ */ jsx("div", { className: styles["passwordField"], children: /* @__PURE__ */ jsxs(Field, { as: TextField, className: styles.passwordField, label: "Password", ...props, children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(Group, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Input, { type: isVisibleState ? "text" : "password", value, onChange: handleChange }),
|
|
42
|
+
/* @__PURE__ */ jsx(IconButton, { size: "sm", iconProps: isVisibleState ? {
|
|
43
|
+
iconName: "eye",
|
|
44
|
+
iconPrefix: "fas"
|
|
45
|
+
} : {
|
|
46
|
+
iconName: "eye-slash",
|
|
47
|
+
iconPrefix: "fas"
|
|
48
|
+
}, onClick: () => setInternalVisible(!isVisibleState), isDisabled: props == null ? void 0 : props.isDisabled, styleVariant: "neutral", emphasis: "tertiary", "aria-label": tooltipLabel, tooltipLabel })
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ jsx("ul", { className: styles["passwordField__strength"], "aria-label": requirementsLabel, "aria-live": "polite", children: (_a = props.strengthValidations) == null ? void 0 : _a.map((validation) => /* @__PURE__ */ jsx(PasswordStrengthItem, { status: value ? validation.validation(value) ? "valid" : "invalid" : "neutral", message: validation.message }, `${validation.message}-${value}`)) })
|
|
51
|
+
] }) });
|
|
52
|
+
};
|
|
53
|
+
const passwordStrengthItem = cva(styles.passwordStrengthItem, {
|
|
54
|
+
variants: {
|
|
55
|
+
status: {
|
|
56
|
+
valid: styles.passwordStrengthItemValid,
|
|
57
|
+
neutral: styles.passwordStrengthItemNeutral,
|
|
58
|
+
invalid: styles.passwordStrengthItemInvalid
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
status: "neutral"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
function getIcon(status) {
|
|
66
|
+
switch (status) {
|
|
67
|
+
case "invalid":
|
|
68
|
+
return {
|
|
69
|
+
iconName: "circle-xmark",
|
|
70
|
+
ariaLabel: "Requirement not met: "
|
|
71
|
+
};
|
|
72
|
+
case "valid":
|
|
73
|
+
return {
|
|
74
|
+
iconName: "circle-check",
|
|
75
|
+
ariaLabel: "Requirement met: "
|
|
76
|
+
};
|
|
77
|
+
case "neutral":
|
|
78
|
+
default:
|
|
79
|
+
return {
|
|
80
|
+
iconName: "circle-minus",
|
|
81
|
+
ariaLabel: "Requirement: "
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const PasswordStrengthItem = ({
|
|
86
|
+
status,
|
|
87
|
+
message
|
|
88
|
+
}) => {
|
|
89
|
+
const {
|
|
90
|
+
iconName,
|
|
91
|
+
ariaLabel
|
|
92
|
+
} = getIcon(status);
|
|
93
|
+
return /* @__PURE__ */ jsxs("li", { className: passwordStrengthItem({
|
|
94
|
+
status
|
|
95
|
+
}), "aria-label": `${ariaLabel}${message}`, children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Icon, { iconName, iconPrefix: "fas" }),
|
|
97
|
+
/* @__PURE__ */ jsx("span", { children: message })
|
|
98
|
+
] });
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
PasswordField,
|
|
102
|
+
PasswordField as default
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=PasswordField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PasswordField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PhoneNumberFieldOption, PhoneNumberValue } from '../../utils/phoneNumber/phoneNumber';
|
|
2
|
+
import { FieldProps } from '../_base/Field';
|
|
3
|
+
export interface PhoneNumberFieldProps extends FieldProps {
|
|
4
|
+
/**
|
|
5
|
+
* Country code of the default phone number
|
|
6
|
+
*/
|
|
7
|
+
defaultCountry?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to show the country select
|
|
10
|
+
*/
|
|
11
|
+
hasCountrySelect?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Limit selectable country codes
|
|
14
|
+
*/
|
|
15
|
+
countryCodes?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Phone number options
|
|
18
|
+
* When undefined will use default options (all)
|
|
19
|
+
*/
|
|
20
|
+
options?: PhoneNumberFieldOption[];
|
|
21
|
+
/**
|
|
22
|
+
* Handle phone number change
|
|
23
|
+
* Returns raw phone number without formatting
|
|
24
|
+
*/
|
|
25
|
+
onChange?: (value: PhoneNumberValue) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Controlled country code
|
|
28
|
+
*/
|
|
29
|
+
countryCode?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Controlled input value
|
|
32
|
+
*/
|
|
33
|
+
value?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Wether to format the phone number according to country pattern
|
|
36
|
+
*/
|
|
37
|
+
isFormatted?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional ID for the select element. If not provided, one will be generated.
|
|
40
|
+
*/
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The label for the country select
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
countrySelectLabel?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The placeholder for the phone number input
|
|
49
|
+
*/
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare const PhoneNumberField: ({ defaultCountry, hasCountrySelect, options, onChange, countryCode: countryCodeControlled, value: valueControlled, countryCodes, isFormatted, id: providedId, countrySelectLabel, label, ...props }: PhoneNumberFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export default PhoneNumberField;
|