@longline/aqua-ui 1.0.338 → 1.0.340
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/containers/Anchor/Anchor.d.ts +5 -0
- package/containers/Anchor/Anchor.js +20 -8
- package/containers/Dock/Dock.d.ts +5 -0
- package/containers/Dock/Dock.js +1 -1
- package/containers/Dock/Dockable.d.ts +5 -0
- package/containers/Dock/Dockable.js +20 -12
- package/containers/DragBar/DragBar.d.ts +5 -0
- package/containers/DragBar/DragBar.js +16 -5
- package/containers/Form/Field.d.ts +0 -3
- package/containers/Form/Field.js +3 -6
- package/containers/Form/Form.js +5 -36
- package/containers/Form/Validation.d.ts +1 -1
- package/containers/Form/Validation.js +6 -6
- package/containers/Form/context/FormContext.d.ts +1 -2
- package/containers/Form/context/useForm.d.ts +1 -1
- package/containers/Form/elements/BoxWrapper.js +2 -0
- package/containers/GlassPane/GlassPane.d.ts +7 -2
- package/containers/GlassPane/GlassPane.js +3 -3
- package/containers/InfoBox/InfoBox.d.ts +5 -0
- package/containers/InfoBox/InfoBox.js +1 -1
- package/containers/List/List.d.ts +5 -0
- package/containers/List/List.js +1 -1
- package/containers/List/ListCell.d.ts +5 -0
- package/containers/List/ListCell.js +1 -1
- package/containers/List/ListRow.d.ts +7 -2
- package/containers/List/ListRow.js +1 -1
- package/containers/Message/Error.d.ts +2 -0
- package/containers/Message/Error.js +1 -1
- package/containers/Message/Message.d.ts +5 -0
- package/containers/Message/Message.js +1 -1
- package/containers/Message/NoData.d.ts +2 -0
- package/containers/Message/NoData.js +1 -1
- package/containers/Message/NoFilteredData.d.ts +2 -0
- package/containers/Message/NoFilteredData.js +1 -1
- package/containers/Openable/Openable.d.ts +5 -0
- package/containers/Openable/Openable.js +8 -8
- package/containers/PublicRoute/PublicRoute.d.ts +9 -1
- package/containers/PublicRoute/PublicRoute.js +3 -7
- package/containers/Tabs/Pane.d.ts +5 -0
- package/containers/Tabs/Pane.js +3 -3
- package/containers/Tabs/Tabs.d.ts +5 -0
- package/containers/Tabs/Tabs.js +3 -3
- package/controls/Chip/Chip.d.ts +15 -3
- package/controls/Chip/Chip.js +7 -6
- package/controls/CircularProgress/CircularProgress.d.ts +11 -0
- package/controls/CircularProgress/CircularProgress.js +19 -11
- package/controls/Dropzone/Dropzone.d.ts +11 -1
- package/controls/Dropzone/Dropzone.js +18 -7
- package/controls/Fab/Fab.d.ts +14 -6
- package/controls/Fab/Fab.js +7 -20
- package/controls/Ghost/Ghost.js +3 -3
- package/controls/Gradient/Gradient.d.ts +5 -0
- package/controls/Gradient/Gradient.js +7 -4
- package/controls/Histogram/Histogram.d.ts +8 -2
- package/controls/Histogram/Histogram.js +9 -9
- package/controls/Histogram/HistogramBar.d.ts +2 -2
- package/controls/Icon/Icon.d.ts +10 -4
- package/controls/Icon/Icon.js +23 -6
- package/controls/Key/Key.d.ts +5 -0
- package/controls/Key/Key.js +2 -5
- package/controls/LinearChart/LinearChart.d.ts +9 -0
- package/controls/LinearChart/LinearChart.js +11 -6
- package/controls/ListButton/ListButton.d.ts +46 -3
- package/controls/ListButton/ListButton.js +70 -9
- package/controls/ListView/ColumnsManager/ColumnDraggable.js +11 -5
- package/controls/ListView/ColumnsManager/SourceColumns.js +1 -1
- package/controls/ListView/IListViewProps.d.ts +9 -2
- package/controls/ListView/ListView.js +13 -12
- package/controls/ListView/defaults.d.ts +3 -0
- package/controls/ListView/defaults.js +6 -0
- package/controls/ListView/elements/Body.d.ts +1 -1
- package/controls/ListView/elements/Body.js +23 -12
- package/controls/ListView/elements/Ghost.js +3 -2
- package/controls/ListView/elements/Header.js +3 -2
- package/controls/ListView/elements/HeaderCell.js +3 -3
- package/controls/ListView/elements/Table.js +16 -10
- package/controls/Mouse/Mouse.d.ts +6 -4
- package/controls/Mouse/Mouse.js +15 -8
- package/controls/PrimaryButton/PrimaryButton.d.ts +9 -3
- package/controls/PrimaryButton/PrimaryButton.js +5 -5
- package/controls/Progress/Progress.d.ts +9 -0
- package/controls/Progress/Progress.js +12 -8
- package/controls/SecondaryButton/SecondaryButton.d.ts +8 -3
- package/controls/SecondaryButton/SecondaryButton.js +1 -1
- package/controls/SpeechRecognizer/EditorRegistry.js +1 -2
- package/controls/SpeechRecognizer/SpeechRecognizer.d.ts +9 -1
- package/controls/SpeechRecognizer/SpeechRecognizer.js +16 -9
- package/controls/TabBar/TabBar.d.ts +5 -0
- package/controls/TabBar/TabBar.js +14 -6
- package/controls/TabBar/Underliner.js +1 -1
- package/controls/TertiaryButton/TertiaryButton.d.ts +9 -3
- package/controls/TertiaryButton/TertiaryButton.js +5 -3
- package/controls/ToggleButton/ToggleButton.d.ts +8 -2
- package/controls/ToggleButton/ToggleButton.js +1 -1
- package/controls/View/View.d.ts +5 -0
- package/controls/View/View.js +1 -1
- package/formatters/CountryFormatter/CountryFormatter.d.ts +3 -2
- package/formatters/CountryFormatter/CountryUtil.d.ts +3 -3
- package/formatters/DateTimeFormatter/DateTimeFormatter.d.ts +11 -10
- package/formatters/DateTimeFormatter/elements/Custom.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/DistanceDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongDateTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/LongTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/Month.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortDate.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortDateTime.d.ts +1 -1
- package/formatters/DateTimeFormatter/elements/ShortTime.d.ts +1 -1
- package/formatters/DivisionFormatter/DivisionFormatter.d.ts +2 -2
- package/formatters/DivisionFormatter/DivisionFormatter.js +1 -1
- package/formatters/DivisionFormatter/DivisionUtil.d.ts +1 -1
- package/formatters/DivisionFormatter/DivisionUtil.js +5 -3
- package/formatters/FilesizeFormatter/FilesizeFormatter.d.ts +3 -3
- package/formatters/GIS/CoordinateFormatter.d.ts +2 -2
- package/formatters/GIS/LatitudeFormatter.d.ts +2 -2
- package/formatters/GIS/LongitudeFormatter.d.ts +2 -2
- package/formatters/HumanFormatter/HumanFormatter.d.ts +3 -3
- package/formatters/NumberFormatter/NumberFormatter.d.ts +3 -3
- package/formatters/PhoneFormatter/PhoneFormatter.d.ts +25 -0
- package/formatters/PhoneFormatter/PhoneFormatter.js +34 -0
- package/formatters/PhoneFormatter/index.d.ts +1 -0
- package/formatters/PhoneFormatter/index.js +1 -0
- package/formatters/StringFormatter/StringFormatter.d.ts +3 -3
- package/formatters/StringFormatter/StringFormatter.js +1 -4
- package/helper/DMS.d.ts +1 -1
- package/helper/DMS.js +2 -2
- package/helper/phoneNumber.d.ts +31 -0
- package/helper/phoneNumber.js +142 -0
- package/hooks/useOutsideClose/useOutsideClose.js +20 -11
- package/hooks/useSpeechAIRecorder/useSpeechAIRecorder.js +10 -7
- package/index.js +1 -0
- package/inputs/DateInput/Body.d.ts +2 -2
- package/inputs/DateInput/Body.js +11 -7
- package/inputs/DateInput/Calendar.d.ts +1 -1
- package/inputs/DateInput/Calendar.js +3 -5
- package/inputs/DateInput/DateInput.d.ts +11 -3
- package/inputs/DateInput/DateInput.js +11 -3
- package/inputs/DateInput/Day.d.ts +1 -1
- package/inputs/DateInput/InfiniteList.js +6 -3
- package/inputs/DateInput/Navbar.js +3 -2
- package/inputs/DateInput/NumericInput.js +3 -0
- package/inputs/DateInput/Selector.d.ts +1 -1
- package/inputs/DateInput/Selector.js +9 -6
- package/inputs/Dropdown/Body.d.ts +2 -2
- package/inputs/Dropdown/Column.d.ts +1 -1
- package/inputs/Dropdown/Dropdown.d.ts +5 -0
- package/inputs/Dropdown/Dropdown.js +36 -63
- package/inputs/Dropdown/Pill.js +1 -1
- package/inputs/Dropdown/Selection.js +1 -1
- package/inputs/Editor/Editor.d.ts +5 -0
- package/inputs/Editor/Editor.js +16 -6
- package/inputs/Editor/buttons/SpeechAIButton.js +2 -0
- package/inputs/Editor/buttons/TextAIButton.d.ts +0 -13
- package/inputs/Editor/buttons/TextAIButton.js +30 -14
- package/inputs/Editor/buttons/TextAIMenu.js +1 -1
- package/inputs/Editor/menu/MenuBar.d.ts +1 -1
- package/inputs/Editor/menu/MenuBar.js +1 -1
- package/inputs/Editor/menu/MenuButton.js +1 -1
- package/inputs/Input/Clear.js +1 -1
- package/inputs/Input/Input.d.ts +5 -0
- package/inputs/Input/Input.js +8 -6
- package/inputs/Input/InputWrapper.d.ts +2 -0
- package/inputs/Input/InputWrapper.js +1 -1
- package/inputs/Input/Reveal.js +1 -1
- package/inputs/MonthRange/Body.d.ts +1 -1
- package/inputs/MonthRange/Calendar.d.ts +2 -2
- package/inputs/MonthRange/Calendar.js +6 -9
- package/inputs/MonthRange/MonthRange.d.ts +7 -1
- package/inputs/MonthRange/MonthRange.js +14 -6
- package/inputs/MonthRange/Selector.d.ts +1 -1
- package/inputs/MonthRange/Selector.js +12 -11
- package/inputs/PhoneInput/PhoneInput.d.ts +97 -0
- package/inputs/PhoneInput/PhoneInput.js +113 -0
- package/inputs/PhoneInput/index.d.ts +2 -0
- package/inputs/PhoneInput/index.js +1 -0
- package/inputs/Selector/Selector.d.ts +5 -0
- package/inputs/Selector/Selector.js +4 -1
- package/inputs/Slider/Slider.d.ts +75 -22
- package/inputs/Slider/Slider.js +104 -22
- package/inputs/Textarea/Textarea.d.ts +5 -5
- package/inputs/Textarea/Textarea.js +3 -2
- package/map/Map/Map.d.ts +2 -2
- package/map/Map/Map.js +20 -14
- package/map/PositionsManager/PositionBox.js +7 -3
- package/map/PositionsManager/PositionsManager.js +33 -13
- package/map/controls/CompassButton/CompassButton.js +1 -1
- package/map/controls/FullscreenButton/FullscreenButton.js +1 -1
- package/map/controls/Geocoder/Geocoder.js +28 -14
- package/map/controls/Geocoder/GeocoderApi.js +2 -0
- package/map/controls/Geocoder/GeocoderSelector.js +1 -1
- package/map/controls/Graticule/Graticule.js +1 -5
- package/map/controls/MapLoader/MapLoader.js +1 -1
- package/map/controls/ScaleControl/ScaleControl.js +1 -1
- package/map/controls/ZoomInButton/ZoomInButton.js +1 -1
- package/map/controls/ZoomOutButton/ZoomOutButton.d.ts +1 -1
- package/map/controls/ZoomOutButton/ZoomOutButton.js +2 -2
- package/map/controls/base/MapButton/MapButton.d.ts +8 -2
- package/map/controls/base/MapButton/MapButton.js +11 -2
- package/map/controls/base/MapControl/MapControl.d.ts +5 -0
- package/map/controls/base/MapControl/MapControl.js +10 -7
- package/map/layers/ClusterLayer/ClusterLayer.d.ts +1 -1
- package/map/layers/ClusterLayer/ClusterLayer.js +7 -3
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer.js +8 -4
- package/map/layers/IdwBlendLayer/IdwBlendLayer.js +9 -4
- package/map/layers/IdwLayer/IdwLayer.d.ts +2 -1
- package/map/layers/IdwLayer/IdwLayer.js +271 -215
- package/map/layers/InterpolationLayer/ContoursFragmentShader.d.ts +1 -1
- package/map/layers/InterpolationLayer/ContoursFragmentShader.js +1 -1
- package/map/layers/InterpolationLayer/InterpolationLayer.d.ts +4 -3
- package/map/layers/InterpolationLayer/InterpolationLayer.js +362 -275
- package/map/layers/ParticlesLayer/ParticlesLayer.d.ts +8 -7
- package/map/layers/ParticlesLayer/ParticlesLayer.js +528 -404
- package/map/markers/ClusterMarker/ClusterMarker.d.ts +6 -1
- package/map/markers/ClusterMarker/ClusterMarker.js +15 -6
- package/map/markers/RiskMarker/RiskMarker.d.ts +5 -1
- package/map/markers/RiskMarker/RiskMarker.js +4 -4
- package/modules/CountryDropdown/CountryDropdown.js +10 -1
- package/modules/Filter/Filter.d.ts +5 -0
- package/modules/Filter/Filter.js +10 -6
- package/modules/Globe/Globe.d.ts +5 -0
- package/modules/Globe/Globe.js +4 -4
- package/modules/MainMenu/Item.d.ts +9 -2
- package/modules/MainMenu/Item.js +8 -5
- package/modules/MainMenu/MainMenu.d.ts +5 -0
- package/modules/MainMenu/MainMenu.js +1 -1
- package/modules/ParticleGlobe/GL.d.ts +1 -1
- package/modules/ParticleGlobe/ParticleGlobe.d.ts +5 -0
- package/modules/ParticleGlobe/ParticleGlobe.js +69 -40
- package/modules/Public/Public.d.ts +5 -0
- package/modules/Public/Public.js +3 -3
- package/package.json +1 -1
- package/services/Auth/Auth.js +13 -7
- package/services/Auth/AuthContext.js +9 -1
- package/services/Dialog/Dialog.d.ts +7 -2
- package/services/Dialog/Dialog.js +7 -6
- package/services/Dialog/DialogWindow.d.ts +3 -1
- package/services/Dialog/DialogWindow.js +1 -1
- package/services/Dialog/XhrDialog.d.ts +1 -1
- package/services/Toast/Toast.js +5 -3
- package/services/Toast/ToastContainer.js +3 -1
- package/services/Toast/ToastContext.d.ts +1 -1
- package/services/Toast/ToastProvider.js +2 -0
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.d.ts +0 -35
- package/map/layers/HtmlMarkerLayer/HtmlMarkerLayer copy.js +0 -176
- package/modules/Root/Content.d.ts +0 -16
- package/modules/Root/Content.js +0 -25
- package/modules/Root/Overlay.d.ts +0 -23
- package/modules/Root/Overlay.js +0 -33
- package/modules/Root/Root.d.ts +0 -10
- package/modules/Root/Root.js +0 -46
- package/modules/Root/Shader.d.ts +0 -15
- package/modules/Root/Shader.js +0 -24
- package/modules/Root/Sidebar.d.ts +0 -13
- package/modules/Root/Sidebar.js +0 -24
- package/modules/Root/index.d.ts +0 -1
- package/modules/Root/index.js +0 -1
- package/modules/Root/stories/SampleContent.d.ts +0 -7
- package/modules/Root/stories/SampleContent.js +0 -44
|
@@ -46,7 +46,7 @@ var MenuButtonBase = function (props) {
|
|
|
46
46
|
}
|
|
47
47
|
]
|
|
48
48
|
}), styles = _a.styles, attributes = _a.attributes, update = _a.update;
|
|
49
|
-
return (React.createElement("button", { className: props.className, disabled: props.disabled, onClick: props.onClick, ref: buttonRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
49
|
+
return (React.createElement("button", { className: props.className, disabled: props.disabled, onClick: props.onClick, ref: buttonRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, "aria-label": typeof props.hint === 'string' ? props.hint : undefined },
|
|
50
50
|
React.createElement(Icon, __assign({}, (typeof props.icon === 'string' ? { url: props.icon } : props.icon))),
|
|
51
51
|
buttonRef.current && createPortal(React.createElement(MenuButtonHint, { keys: props.keys, ref: hintRef, styles: styles, attributes: attributes }, props.hint), buttonRef.current)));
|
|
52
52
|
};
|
package/inputs/Input/Clear.js
CHANGED
|
@@ -6,7 +6,7 @@ var Clear = function (props) {
|
|
|
6
6
|
var theme = useTheme();
|
|
7
7
|
var handleClick = function (e) {
|
|
8
8
|
// Stop propagation, or color/date controls will open on click.
|
|
9
|
-
e.stopPropagation();
|
|
9
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
10
10
|
props.onClick();
|
|
11
11
|
};
|
|
12
12
|
return (React.createElement(Icon, { size: 17, url: SVG.Icons.Cross, circle: true, color: theme.colors.primary[3], onClick: handleClick }));
|
package/inputs/Input/Input.d.ts
CHANGED
|
@@ -129,6 +129,11 @@ interface IInputProps extends ITestable {
|
|
|
129
129
|
* Listeners are notified when the Input receives focus.
|
|
130
130
|
*/
|
|
131
131
|
onFocus?: () => void;
|
|
132
|
+
/**
|
|
133
|
+
* Optional inline styles applied to the outer element, for one-off overrides
|
|
134
|
+
* of the default styling.
|
|
135
|
+
*/
|
|
136
|
+
style?: React.CSSProperties;
|
|
132
137
|
}
|
|
133
138
|
declare const Input: {
|
|
134
139
|
(props: IInputProps): React.JSX.Element;
|
package/inputs/Input/Input.js
CHANGED
|
@@ -35,8 +35,9 @@ var InputBase = function (props) {
|
|
|
35
35
|
};
|
|
36
36
|
// When input is cleared, its value is set to NULL.
|
|
37
37
|
var handleClear = function () {
|
|
38
|
+
var _a;
|
|
38
39
|
setValue("");
|
|
39
|
-
inputRef.current.focus();
|
|
40
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
40
41
|
if (props.onChange) {
|
|
41
42
|
props.onChange(null);
|
|
42
43
|
}
|
|
@@ -57,8 +58,9 @@ var InputBase = function (props) {
|
|
|
57
58
|
}, []);
|
|
58
59
|
// Handle hotkey check.
|
|
59
60
|
var handleKeyDown = function (e) {
|
|
61
|
+
var _a, _b;
|
|
60
62
|
// If not the hotkey, then abort.
|
|
61
|
-
if (e.key.toLowerCase() != props.hotKey.toLowerCase())
|
|
63
|
+
if (!props.hotKey || e.key.toLowerCase() != props.hotKey.toLowerCase())
|
|
62
64
|
return;
|
|
63
65
|
// Check modifier keys:
|
|
64
66
|
if (props.hotKeyCtrl && !e.ctrlKey)
|
|
@@ -68,13 +70,13 @@ var InputBase = function (props) {
|
|
|
68
70
|
if (props.hotKeyShift && !e.shiftKey)
|
|
69
71
|
return;
|
|
70
72
|
// It's our key. Focus the input.
|
|
71
|
-
inputRef.current.focus();
|
|
72
|
-
inputRef.current.select();
|
|
73
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
74
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.select();
|
|
73
75
|
};
|
|
74
|
-
return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, icon: props.icon, iconPosition: props.iconPosition, onClear: (props.clearable && props.value) ? handleClear :
|
|
76
|
+
return (React.createElement(InputWrapper, { fluid: props.fluid, ghost: props.ghost, error: props.error, disabled: props.disabled, transparent: props.transparent, icon: props.icon, iconPosition: props.iconPosition, onClear: (props.clearable && props.value) ? handleClear : undefined, onToggleReveal: props.revealable ? handleToggleReveal : undefined, revealed: revealed, unit: props.unit, style: props.style },
|
|
75
77
|
React.createElement("input", { "data-testid": props['data-testid'] || "Input", className: props.className, ref: inputRef, tabIndex: props.noTabIndex ? -1 : 0, value: value, placeholder: props.placeholder, disabled: props.disabled, type: props.type == 'password' ? (revealed ? 'text' : 'password') : props.type, maxLength: props.maxLength, autoComplete: props.autocomplete, onChange: handleChange, onFocus: props.onFocus })));
|
|
76
78
|
};
|
|
77
|
-
var InputStyled = styled(InputBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Dimensions:\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n border: none;\n\n
|
|
79
|
+
var InputStyled = styled(InputBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n // Dimensions:\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n border: none;\n\n background: transparent;\n padding: 0;\n margin: 0;\n outline: none;\n\n // Font\n font: ", ";\n text-align: left;\n color: ", ";\n\n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Focus:\n &:focus {\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n\n ", "\n\n // Make sure HTML5 validation does not show up.\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n // Turn off number spinners.\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n appearance:textfield;\n -moz-appearance:textfield; /* Firefox */\n } \n"], ["\n // Dimensions:\n width: 100%;\n box-sizing: border-box;\n z-index: 0;\n border: none;\n\n background: transparent;\n padding: 0;\n margin: 0;\n outline: none;\n\n // Font\n font: ", ";\n text-align: left;\n color: ", ";\n\n // Define colors for placeholder text.\n &::placeholder {\n color: rgb(from ", " r g b / 50%);\n opacity: 1 !important; /* Firefox applies opacity */\n }\n\n // Focus:\n &:focus {\n &::placeholder {\n color: rgb(from ", " r g b / 30%);\n }\n }\n\n ", "\n\n // Make sure HTML5 validation does not show up.\n &:valid {\n box-shadow: none;\n }\n &:invalid {\n box-shadow: none;\n }\n\n // Turn off number spinners.\n &[type=number]::-webkit-inner-spin-button, \n &[type=number]::-webkit-outer-spin-button { \n -webkit-appearance: none; /* Webkit (Chrome) */\n margin: 0; \n } \n &[type=number] {\n appearance:textfield;\n -moz-appearance:textfield; /* Firefox */\n } \n"])), function (p) { return p.theme.font.bodyMedium; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.theme.colors.primary[3]; }, function (p) { return p.disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), p.theme.colors.neutral[50]); });
|
|
78
80
|
var Input = function (props) { return React.createElement(InputStyled, __assign({}, props)); };
|
|
79
81
|
Input.displayName = 'Input';
|
|
80
82
|
export { Input };
|
|
@@ -18,6 +18,8 @@ interface IProps extends ITestable {
|
|
|
18
18
|
*/
|
|
19
19
|
iconPosition?: 'left' | 'right';
|
|
20
20
|
unit?: React.ReactNode;
|
|
21
|
+
/** Optional inline styles applied to the wrapper's outer element. */
|
|
22
|
+
style?: React.CSSProperties;
|
|
21
23
|
onClear?: () => void;
|
|
22
24
|
onClick?: () => void;
|
|
23
25
|
revealed?: boolean;
|
|
@@ -42,7 +42,7 @@ var InputWrapperBase = function (props) {
|
|
|
42
42
|
else if (props.icon != null) {
|
|
43
43
|
icon = (React.createElement(Icon, __assign({ size: 17, color: (_a = props.icon.color) !== null && _a !== void 0 ? _a : theme.colors.primary[3] }, props.icon)));
|
|
44
44
|
}
|
|
45
|
-
return (React.createElement("div", { "data-testid": props['data-testid'] || "InputWrapper", className: props.className, onClick: props.onClick },
|
|
45
|
+
return (React.createElement("div", { "data-testid": props['data-testid'] || "InputWrapper", className: props.className, style: props.style, onClick: props.onClick },
|
|
46
46
|
props.ghost && React.createElement(Ghost, { style: { position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, zIndex: 100 } }),
|
|
47
47
|
icon && !props.ghost && props.iconPosition == 'left' && icon,
|
|
48
48
|
React.createElement(Content, null, props.children),
|
package/inputs/Input/Reveal.js
CHANGED
|
@@ -6,7 +6,7 @@ var Reveal = function (props) {
|
|
|
6
6
|
var theme = useTheme();
|
|
7
7
|
var handleClick = function (e) {
|
|
8
8
|
// Stop propagation, or color/date controls will open on click.
|
|
9
|
-
e.stopPropagation();
|
|
9
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
10
10
|
props.onClick();
|
|
11
11
|
};
|
|
12
12
|
return (React.createElement(Icon, { size: 17, url: props.revealed ? SVG.Icons.EyeClosed : SVG.Icons.Eye, color: theme.colors.primary[3], onClick: handleClick }));
|
|
@@ -23,6 +23,6 @@ interface IProps {
|
|
|
23
23
|
attributes: any;
|
|
24
24
|
}
|
|
25
25
|
declare const Body: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<IProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
26
|
-
ref?: React.
|
|
26
|
+
ref?: React.RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
|
|
27
27
|
}, never>> & string & Omit<React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLDivElement>>, keyof React.Component<any, {}, any>>;
|
|
28
28
|
export { Body };
|
|
@@ -5,9 +5,9 @@ interface IProps {
|
|
|
5
5
|
/** Calendar year */
|
|
6
6
|
year: number;
|
|
7
7
|
/** Selected start date */
|
|
8
|
-
start: Date;
|
|
8
|
+
start: Date | null;
|
|
9
9
|
/** Selected end date */
|
|
10
|
-
end: Date;
|
|
10
|
+
end: Date | null;
|
|
11
11
|
/** Fired when calendar changes year */
|
|
12
12
|
onChangeYear: (year: number) => void;
|
|
13
13
|
/** Fired when month is clicked. */
|
|
@@ -23,10 +23,10 @@ var CalendarBase = function (props) {
|
|
|
23
23
|
return (React.createElement("div", { className: props.className },
|
|
24
24
|
React.createElement(YearSelector, { year: props.year, onChange: props.onChangeYear }),
|
|
25
25
|
React.createElement(Months, null, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(function (month) {
|
|
26
|
-
var $start = props.start && props.start.getFullYear() == props.year && props.start.getMonth() == month;
|
|
27
|
-
var $end = props.end && props.end.getFullYear() == props.year && props.end.getMonth() == month;
|
|
28
|
-
var $between = props.start && props.start.getFullYear() * 12 + props.start.getMonth() < props.year * 12 + month &&
|
|
29
|
-
props.end && props.end.getFullYear() * 12 + props.end.getMonth() > props.year * 12 + month;
|
|
26
|
+
var $start = !!(props.start && props.start.getFullYear() == props.year && props.start.getMonth() == month);
|
|
27
|
+
var $end = !!(props.end && props.end.getFullYear() == props.year && props.end.getMonth() == month);
|
|
28
|
+
var $between = !!(props.start && props.start.getFullYear() * 12 + props.start.getMonth() < props.year * 12 + month &&
|
|
29
|
+
props.end && props.end.getFullYear() * 12 + props.end.getMonth() > props.year * 12 + month);
|
|
30
30
|
var $length = (props.start && props.end) ?
|
|
31
31
|
(props.end.getFullYear() * 12 + props.end.getMonth()) - (props.start.getFullYear() * 12 + props.start.getMonth())
|
|
32
32
|
: 0;
|
|
@@ -35,11 +35,8 @@ var CalendarBase = function (props) {
|
|
|
35
35
|
};
|
|
36
36
|
var CalendarStyled = styled(CalendarBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 12px 16px 12px 16px;\n user-select: none;\n"], ["\n padding: 12px 16px 12px 16px;\n user-select: none;\n"])));
|
|
37
37
|
var Months = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: repeat(4, 40px);\n grid-template-rows: repeat(3, 40px);\n row-gap: 4px;\n"], ["\n display: grid;\n grid-template-columns: repeat(4, 40px);\n grid-template-rows: repeat(3, 40px);\n row-gap: 4px;\n"])));
|
|
38
|
-
var
|
|
39
|
-
return {
|
|
40
|
-
r: "50%" // Border radius one-time definition
|
|
41
|
-
};
|
|
42
|
-
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n position: relative;\n cursor: pointer;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ", ";\n\n // Set backgrounds and border radii.\n // Note: $between is neither start nor end, but between them.\n ", "\n ", " \n ", "\n ", "\n\n // Hover effect only on unselected months.\n ", "\n"], ["\n position: relative;\n cursor: pointer;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ", ";\n\n // Set backgrounds and border radii.\n // Note: $between is neither start nor end, but between them.\n ", "\n ", " \n ", "\n ", "\n\n // Hover effect only on unselected months.\n ", "\n"])), function (p) { return p.r; }, function (p) { return (p.$between || p.$start || p.$end) && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n "], ["\n background-color: ", ";\n color: ", ";\n "])), function (p) { return p.theme.colors.neutral[30]; }, function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.$between && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-radius: 0px;\n "], ["\n border-radius: 0px;\n "]))); }, function (p) { return p.$start && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n "], ["\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n "])), p.r, p.r, p.$length ? 0 : p.r, p.$length ? 0 : p.r); }, function (p) { return p.$end && css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", "; \n "], ["\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", "; \n "])), p.r, p.r, p.$length ? 0 : p.r, p.$length ? 0 : p.r); }, function (p) { return (!p.$between && !p.$start && !p.$end) && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n &:hover {\n background-color: rgb(from ", " r g b / 30%);\n }\n "], ["\n &:hover {\n background-color: rgb(from ", " r g b / 30%);\n }\n "])), function (p) { return p.theme.colors.primary[1]; }); });
|
|
38
|
+
var RADIUS = "50%";
|
|
39
|
+
var Month = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n position: relative;\n cursor: pointer;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ", ";\n\n // Set backgrounds and border radii.\n // Note: $between is neither start nor end, but between them.\n ", "\n ", " \n ", "\n ", "\n\n // Hover effect only on unselected months.\n ", "\n"], ["\n position: relative;\n cursor: pointer;\n display: flex;\n justify-content: center;\n align-items: center;\n border-radius: ", ";\n\n // Set backgrounds and border radii.\n // Note: $between is neither start nor end, but between them.\n ", "\n ", " \n ", "\n ", "\n\n // Hover effect only on unselected months.\n ", "\n"])), RADIUS, function (p) { return (p.$between || p.$start || p.$end) && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n "], ["\n background-color: ", ";\n color: ", ";\n "])), function (p) { return p.theme.colors.neutral[30]; }, function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.$between && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-radius: 0px;\n "], ["\n border-radius: 0px;\n "]))); }, function (p) { return p.$start && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n "], ["\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n "])), RADIUS, RADIUS, p.$length ? 0 : RADIUS, p.$length ? 0 : RADIUS); }, function (p) { return p.$end && css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n "], ["\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n "])), RADIUS, RADIUS, p.$length ? 0 : RADIUS, p.$length ? 0 : RADIUS); }, function (p) { return (!p.$between && !p.$start && !p.$end) && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n &:hover {\n background-color: rgb(from ", " r g b / 30%);\n }\n "], ["\n &:hover {\n background-color: rgb(from ", " r g b / 30%);\n }\n "])), function (p) { return p.theme.colors.primary[1]; }); });
|
|
43
40
|
var Calendar = function (props) { return React.createElement(CalendarStyled, __assign({}, props)); };
|
|
44
41
|
export { Calendar };
|
|
45
42
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -61,9 +61,15 @@ interface IMonthRangeProps extends ITestable {
|
|
|
61
61
|
*/
|
|
62
62
|
onChange?: (value: [Date, Date] | null) => void;
|
|
63
63
|
/**
|
|
64
|
-
* Listeners are notified when the `MonthRange` receives focus
|
|
64
|
+
* Listeners are notified when the `MonthRange` receives focus (from outside
|
|
65
|
+
* the component; internal focus moves do not re-fire it).
|
|
65
66
|
*/
|
|
66
67
|
onFocus?: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Optional inline styles applied to the outer element, for one-off overrides
|
|
70
|
+
* of the default styling.
|
|
71
|
+
*/
|
|
72
|
+
style?: React.CSSProperties;
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
75
|
* A `MonthRange` allows a selection of a time period, measured in months.
|
|
@@ -32,10 +32,11 @@ import { Selector } from './Selector';
|
|
|
32
32
|
import { Body } from './Body';
|
|
33
33
|
import { useOutsideClose } from '../../hooks/useOutsideClose';
|
|
34
34
|
var MonthRangeBase = function (props) {
|
|
35
|
+
var _a;
|
|
35
36
|
var wrapperRef = React.useRef(null);
|
|
36
37
|
var bodyRef = React.useRef(null);
|
|
37
|
-
var
|
|
38
|
-
var
|
|
38
|
+
var _b = React.useState((_a = props.value) !== null && _a !== void 0 ? _a : null), value = _b[0], setValue = _b[1];
|
|
39
|
+
var _c = React.useState(false), open = _c[0], setOpen = _c[1];
|
|
39
40
|
useOutsideClose({
|
|
40
41
|
open: open,
|
|
41
42
|
refs: [wrapperRef, bodyRef],
|
|
@@ -69,7 +70,14 @@ var MonthRangeBase = function (props) {
|
|
|
69
70
|
if (e.key == 'Escape' && open)
|
|
70
71
|
setOpen(false);
|
|
71
72
|
};
|
|
72
|
-
var
|
|
73
|
+
var handleFocus = function (e) {
|
|
74
|
+
if (!props.onFocus)
|
|
75
|
+
return;
|
|
76
|
+
// Only notify when focus enters from outside the component.
|
|
77
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
78
|
+
props.onFocus();
|
|
79
|
+
};
|
|
80
|
+
var _d = usePopper(wrapperRef.current, bodyRef.current, {
|
|
73
81
|
placement: props.direction == 'down' ? 'bottom-start' : 'top-start',
|
|
74
82
|
modifiers: [
|
|
75
83
|
{
|
|
@@ -79,9 +87,9 @@ var MonthRangeBase = function (props) {
|
|
|
79
87
|
},
|
|
80
88
|
}
|
|
81
89
|
]
|
|
82
|
-
}), styles =
|
|
83
|
-
return (React.createElement("div", { "data-testid": props['data-testid'] || "MonthRange", tabIndex: -1, className: props.className, onKeyDown: handleKeyDown, ref: wrapperRef },
|
|
84
|
-
React.createElement(Selector, { value: value, disabled: props.disabled, ghost: props.ghost, transparent: props.transparent, error: props.error, clearable: props.clearable, placeholder: props.placeholder, count: props.count, onClear: (!props.disabled && props.clearable && value != null) ? function () { return handleSelect(null); } :
|
|
90
|
+
}), styles = _d.styles, attributes = _d.attributes, update = _d.update;
|
|
91
|
+
return (React.createElement("div", { "data-testid": props['data-testid'] || "MonthRange", tabIndex: -1, className: props.className, style: props.style, onKeyDown: handleKeyDown, onFocus: handleFocus, ref: wrapperRef },
|
|
92
|
+
React.createElement(Selector, { value: value, disabled: props.disabled, ghost: props.ghost, transparent: props.transparent, error: props.error, clearable: props.clearable, placeholder: props.placeholder, count: props.count, onClear: (!props.disabled && props.clearable && value != null) ? function () { return handleSelect(null); } : undefined, onCalendar: handleToggle }),
|
|
85
93
|
createPortal(React.createElement(Body, { ref: bodyRef, value: value, open: open, transparent: props.transparent, onSelect: handleSelect, styles: styles, attributes: attributes }), document.body)));
|
|
86
94
|
};
|
|
87
95
|
var MonthRangeStyled = styled(MonthRangeBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n // MonthRange has a minimum width.\n width: 250px;\n // A fluid MonthRange occupies full horizontal width.\n ", " \n"], ["\n position: relative;\n // MonthRange has a minimum width.\n width: 250px;\n // A fluid MonthRange occupies full horizontal width.\n ", " \n"
|
|
@@ -20,40 +20,41 @@ var Selector = function (props) {
|
|
|
20
20
|
return (d2.getFullYear() * 12 + d2.getMonth()) - (d1.getFullYear() * 12 + d1.getMonth()) + 1;
|
|
21
21
|
};
|
|
22
22
|
var renderDates = function () {
|
|
23
|
+
var value = props.value;
|
|
23
24
|
// No selection?
|
|
24
|
-
if (!
|
|
25
|
+
if (value == null || !Array.isArray(value) || value.length != 2 || value[0] == null || value[1] == null)
|
|
25
26
|
return React.createElement(React.Fragment, null,
|
|
26
27
|
props.placeholder,
|
|
27
28
|
"\u00A0");
|
|
28
29
|
// Same year?
|
|
29
|
-
if (
|
|
30
|
+
if (value[0].getFullYear() == value[1].getFullYear()) {
|
|
30
31
|
// Same month?
|
|
31
|
-
if (
|
|
32
|
+
if (value[0].getMonth() == value[1].getMonth()) {
|
|
32
33
|
return React.createElement(React.Fragment, null,
|
|
33
|
-
React.createElement(DateTimeFormatter, { type: "month", value:
|
|
34
|
+
React.createElement(DateTimeFormatter, { type: "month", value: value[0] }));
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
37
|
return React.createElement(React.Fragment, null,
|
|
37
|
-
React.createElement(DateTimeFormatter, { type: "month", value:
|
|
38
|
+
React.createElement(DateTimeFormatter, { type: "month", value: value[0] }),
|
|
38
39
|
" - ",
|
|
39
|
-
React.createElement(DateTimeFormatter, { type: "month", value:
|
|
40
|
+
React.createElement(DateTimeFormatter, { type: "month", value: value[1] }),
|
|
40
41
|
props.count && React.createElement("span", null,
|
|
41
42
|
" (",
|
|
42
|
-
monthsDiff(
|
|
43
|
+
monthsDiff(value[0], value[1]),
|
|
43
44
|
"m)"));
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
// Different years:
|
|
47
48
|
return React.createElement(React.Fragment, null,
|
|
48
|
-
React.createElement(DateTimeFormatter, { type: "month", value:
|
|
49
|
+
React.createElement(DateTimeFormatter, { type: "month", value: value[0] }),
|
|
49
50
|
" - ",
|
|
50
|
-
React.createElement(DateTimeFormatter, { type: "month", value:
|
|
51
|
+
React.createElement(DateTimeFormatter, { type: "month", value: value[1] }),
|
|
51
52
|
props.count && React.createElement("span", null,
|
|
52
53
|
" (",
|
|
53
|
-
monthsDiff(
|
|
54
|
+
monthsDiff(value[0], value[1]),
|
|
54
55
|
"m)"));
|
|
55
56
|
};
|
|
56
|
-
return (React.createElement(InputWrapper, { fluid: true, error: props.error, disabled: props.disabled, ghost: props.ghost, transparent: props.transparent, onClear: (props.clearable && hasValue()) ? props.onClear :
|
|
57
|
+
return (React.createElement(InputWrapper, { fluid: true, error: props.error, disabled: props.disabled, ghost: props.ghost, transparent: props.transparent, onClear: (props.clearable && hasValue()) ? props.onClear : undefined, onClick: props.onCalendar, icon: { url: SVG.Icons.Calendar, color: theme.colors.primary[3] }, iconPosition: 'right' },
|
|
57
58
|
React.createElement(Selection, { "$placeholder": !hasValue() }, renderDates())));
|
|
58
59
|
};
|
|
59
60
|
var Selection = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n"], ["\n width: 100%;\n outline: none;\n overflow-x: hidden;\n overflow-y: hidden;\n white-space: nowrap;\n ", " \n"])), function (p) { return p.$placeholder && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: rgb(from ", " r g b / 50%);\n "], ["\n color: rgb(from ", " r g b / 50%);\n "])), function (p) { return p.theme.colors.primary[3]; }); });
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ITestable } from '../../Types';
|
|
3
|
+
interface IPhoneInputProps extends ITestable {
|
|
4
|
+
/** @ignore */
|
|
5
|
+
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Field name, for use in forms.
|
|
8
|
+
*/
|
|
9
|
+
name?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Current value in E.164 format, e.g. `"+351123456789"`.
|
|
12
|
+
*/
|
|
13
|
+
value?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Notified with the assembled E.164 string whenever the country or number
|
|
16
|
+
* changes. Receives `''` when the field is cleared.
|
|
17
|
+
*/
|
|
18
|
+
onChange?: (value: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Country selected for new/empty values, and the country restored when the
|
|
21
|
+
* field is cleared (ISO 3166-1 alpha-2, e.g. `"GB"`). A country is always
|
|
22
|
+
* selected, which is why there is no country placeholder.
|
|
23
|
+
* @default US
|
|
24
|
+
*/
|
|
25
|
+
defaultCountry?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Placeholder shown in the phone-number field when it is empty. The country
|
|
28
|
+
* field needs no placeholder, as a country is always selected.
|
|
29
|
+
*/
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
/**
|
|
32
|
+
* If set, the phone-number field shows a clear button that empties the
|
|
33
|
+
* number and resets the country to the default.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
clearable?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Marks the control as disabled. Disabled controls cannot be interacted with.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Shows the control in an error state.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
error?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* A fluid control takes up all horizontal space available to it.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
fluid?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Removes borders and makes the background transparent. Useful when placing
|
|
54
|
+
* the control inside a `Field`.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
transparent?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Shows the control in a ghost state, where content is being loaded.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
ghost?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Locale code for country-name display and sorting (e.g. `"pt"`, `"es"`).
|
|
65
|
+
* @default en
|
|
66
|
+
*/
|
|
67
|
+
locale?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Optional inline styles applied to the outer element, for one-off overrides
|
|
70
|
+
* of the default styling.
|
|
71
|
+
*/
|
|
72
|
+
style?: React.CSSProperties;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A phone-number input: a searchable country dropdown that supplies the
|
|
76
|
+
* international dialing prefix, beside a free-text field for the rest of the
|
|
77
|
+
* number. The value is a single E.164 string (`"+351123456789"`) — the prefix
|
|
78
|
+
* is never stored separately.
|
|
79
|
+
*
|
|
80
|
+
* A country is always selected (default US, configurable via `defaultCountry`),
|
|
81
|
+
* so there is no country placeholder to translate; the `placeholder` prop
|
|
82
|
+
* applies to the number field. It satisfies the `Form.Field` control contract (`value` +
|
|
83
|
+
* `onChange(value)`), so a surrounding `Form.Field` validates the assembled
|
|
84
|
+
* E.164 string.
|
|
85
|
+
*
|
|
86
|
+
* ## Usage
|
|
87
|
+
*
|
|
88
|
+
* ```tsx
|
|
89
|
+
* <PhoneInput value="+351123456789" onChange={setPhone} clearable/>
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare const PhoneInput: {
|
|
93
|
+
(props: IPhoneInputProps): React.JSX.Element;
|
|
94
|
+
displayName: string;
|
|
95
|
+
};
|
|
96
|
+
export { PhoneInput };
|
|
97
|
+
export type { IPhoneInputProps };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
6
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
7
|
+
if (ar || !(i in from)) {
|
|
8
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
9
|
+
ar[i] = from[i];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
13
|
+
};
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import styled from 'styled-components';
|
|
16
|
+
import { Dropdown } from '../Dropdown';
|
|
17
|
+
import { Input } from '../Input';
|
|
18
|
+
import { CountryFormatter } from '../../formatters/CountryFormatter';
|
|
19
|
+
import { Countries } from '../../formatters/CountryFormatter/Countries';
|
|
20
|
+
import { DIAL_BY_ISO, parseE164, assembleE164, digitsOnly } from '../../helper/phoneNumber';
|
|
21
|
+
var ALL_ISO = Object.keys(DIAL_BY_ISO);
|
|
22
|
+
var nameOf = function (iso) { var _a; return (_a = Countries[iso]) !== null && _a !== void 0 ? _a : iso; };
|
|
23
|
+
var strip = function (s) { return s.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase(); };
|
|
24
|
+
/**
|
|
25
|
+
* A phone-number input: a searchable country dropdown that supplies the
|
|
26
|
+
* international dialing prefix, beside a free-text field for the rest of the
|
|
27
|
+
* number. The value is a single E.164 string (`"+351123456789"`) — the prefix
|
|
28
|
+
* is never stored separately.
|
|
29
|
+
*
|
|
30
|
+
* A country is always selected (default US, configurable via `defaultCountry`),
|
|
31
|
+
* so there is no country placeholder to translate; the `placeholder` prop
|
|
32
|
+
* applies to the number field. It satisfies the `Form.Field` control contract (`value` +
|
|
33
|
+
* `onChange(value)`), so a surrounding `Form.Field` validates the assembled
|
|
34
|
+
* E.164 string.
|
|
35
|
+
*
|
|
36
|
+
* ## Usage
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <PhoneInput value="+351123456789" onChange={setPhone} clearable/>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
var PhoneInput = function (props) {
|
|
43
|
+
var value = props.value, onChange = props.onChange, _a = props.defaultCountry, defaultCountry = _a === void 0 ? 'US' : _a, clearable = props.clearable, locale = props.locale, placeholder = props.placeholder, disabled = props.disabled, error = props.error, fluid = props.fluid, transparent = props.transparent, ghost = props.ghost, className = props.className, name = props.name, style = props.style;
|
|
44
|
+
var _b = React.useState(function () { var _a; return (_a = parseE164(value).iso) !== null && _a !== void 0 ? _a : defaultCountry; }), iso = _b[0], setIso = _b[1];
|
|
45
|
+
var _c = React.useState(function () { return parseE164(value).national; }), national = _c[0], setNational = _c[1];
|
|
46
|
+
var _d = React.useState(''), query = _d[0], setQuery = _d[1];
|
|
47
|
+
// Re-sync from an externally-set value (initial load, form reset). During
|
|
48
|
+
// normal typing the parent value matches our assembled output, so this no-ops
|
|
49
|
+
// and won't fight the user.
|
|
50
|
+
React.useEffect(function () {
|
|
51
|
+
if ((value !== null && value !== void 0 ? value : '') !== assembleE164(iso, national)) {
|
|
52
|
+
var parsed = parseE164(value);
|
|
53
|
+
if (parsed.iso)
|
|
54
|
+
setIso(parsed.iso);
|
|
55
|
+
setNational(parsed.national);
|
|
56
|
+
}
|
|
57
|
+
}, [value]);
|
|
58
|
+
var sortedIso = React.useMemo(function () { return __spreadArray([], ALL_ISO, true).sort(function (a, b) { return nameOf(a).localeCompare(nameOf(b)); }); }, []);
|
|
59
|
+
var data = React.useMemo(function () {
|
|
60
|
+
var q = strip(query);
|
|
61
|
+
if (!q)
|
|
62
|
+
return sortedIso;
|
|
63
|
+
var qDigits = digitsOnly(query);
|
|
64
|
+
return sortedIso.filter(function (c) { return strip(nameOf(c)).includes(q) || (qDigits !== '' && DIAL_BY_ISO[c].startsWith(qDigits)); });
|
|
65
|
+
}, [query, sortedIso]);
|
|
66
|
+
var handleCountry = function (next) {
|
|
67
|
+
var nextIso = next !== null && next !== void 0 ? next : defaultCountry;
|
|
68
|
+
setIso(nextIso);
|
|
69
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(assembleE164(nextIso, national));
|
|
70
|
+
};
|
|
71
|
+
var handleNational = function (next) {
|
|
72
|
+
// The Input's clear button emits null (typing only ever emits a string).
|
|
73
|
+
// Treat it as "clear the whole control": empty the number and reset the
|
|
74
|
+
// country to the default.
|
|
75
|
+
if (next === null) {
|
|
76
|
+
setIso(defaultCountry);
|
|
77
|
+
setNational('');
|
|
78
|
+
onChange === null || onChange === void 0 ? void 0 : onChange('');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
var digits = digitsOnly(next);
|
|
82
|
+
setNational(digits);
|
|
83
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(assembleE164(iso, digits));
|
|
84
|
+
};
|
|
85
|
+
return (
|
|
86
|
+
// Stop clicks bubbling to the Form.Field box wrapper. That wrapper routes
|
|
87
|
+
// any click to the first child with tabIndex=0 (the Dropdown), which would
|
|
88
|
+
// otherwise hijack clicks on the number field and force the dropdown open.
|
|
89
|
+
React.createElement(Wrapper, { "$fluid": fluid, className: className, style: style, "data-testid": props['data-testid'] || "PhoneInput", onClick: function (e) { return e.stopPropagation(); } },
|
|
90
|
+
React.createElement(Prefix, null,
|
|
91
|
+
React.createElement(Dropdown, { data: data, value: iso, onChange: handleCountry, onSearch: setQuery, disabled: disabled, error: error, ghost: ghost, transparent: transparent, fluid: true, maxItems: 8, label: function (c) { return (React.createElement(Selected, null,
|
|
92
|
+
React.createElement(SelectedCountry, null,
|
|
93
|
+
React.createElement(CountryFormatter, { type: "both", value: c, locale: locale })),
|
|
94
|
+
React.createElement(Code, null,
|
|
95
|
+
"+",
|
|
96
|
+
DIAL_BY_ISO[c]))); } },
|
|
97
|
+
React.createElement(Dropdown.Column, null, function (c) { return (React.createElement(CountryFormatter, { type: "both", value: c, locale: locale })); }),
|
|
98
|
+
React.createElement(Dropdown.Column, { width: "40px", align: "right" }, function (c) { return (React.createElement(Code, null,
|
|
99
|
+
"+",
|
|
100
|
+
DIAL_BY_ISO[c])); }))),
|
|
101
|
+
React.createElement(Number, null,
|
|
102
|
+
React.createElement(Input, { name: name, value: national, onChange: handleNational, disabled: disabled, error: error, ghost: ghost, transparent: transparent, fluid: true, clearable: clearable, type: "text", autocomplete: "off", placeholder: placeholder }))));
|
|
103
|
+
};
|
|
104
|
+
PhoneInput.displayName = 'PhoneInput';
|
|
105
|
+
var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n width: ", ";\n"], ["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n width: ", ";\n"])), function (p) { return (p.$fluid ? '100%' : 'auto'); });
|
|
106
|
+
var Prefix = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n flex: 0 0 auto;\n width: 220px;\n"], ["\n flex: 0 0 auto;\n width: 220px;\n"])));
|
|
107
|
+
var Number = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: 1 1 auto;\n min-width: 0;\n"], ["\n flex: 1 1 auto;\n min-width: 0;\n"])));
|
|
108
|
+
var Selected = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 6px;\n min-width: 0;\n white-space: nowrap;\n"], ["\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 6px;\n min-width: 0;\n white-space: nowrap;\n"])));
|
|
109
|
+
/* Lets the country name ellipsize so the dialing code stays visible. */
|
|
110
|
+
var SelectedCountry = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-width: 0;\n overflow: hidden;\n"], ["\n min-width: 0;\n overflow: hidden;\n"])));
|
|
111
|
+
var Code = styled.span(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n flex: 0 0 auto;\n opacity: 0.7;\n"], ["\n flex: 0 0 auto;\n opacity: 0.7;\n"])));
|
|
112
|
+
export { PhoneInput };
|
|
113
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PhoneInput } from './PhoneInput';
|
|
@@ -26,6 +26,11 @@ interface IProps extends ISelectorProps, ITestable {
|
|
|
26
26
|
* If set, checkbox has a dark label.
|
|
27
27
|
*/
|
|
28
28
|
dark?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional inline styles applied to the outer element, for one-off overrides
|
|
31
|
+
* of the default styling.
|
|
32
|
+
*/
|
|
33
|
+
style?: React.CSSProperties;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* A Selector can be used to create either a HTML checkbox or a HTML radio button.
|
|
@@ -30,9 +30,12 @@ import { Checkbox } from './widgets/Checkbox';
|
|
|
30
30
|
import { Toggle } from './widgets/Toggle';
|
|
31
31
|
import { Circle } from './widgets/Circle';
|
|
32
32
|
var SelectorBase = function (props) {
|
|
33
|
+
// Holds a boolean for checkboxes, or the selected value for radios.
|
|
33
34
|
var _a = React.useState(props.checked), checked = _a[0], setChecked = _a[1];
|
|
34
35
|
var inputRef = React.useRef(null);
|
|
35
36
|
React.useEffect(function () {
|
|
37
|
+
if (!inputRef.current)
|
|
38
|
+
return;
|
|
36
39
|
if (props.indeterminate === true)
|
|
37
40
|
inputRef.current.indeterminate = true;
|
|
38
41
|
if (props.indeterminate === false)
|
|
@@ -61,7 +64,7 @@ var SelectorBase = function (props) {
|
|
|
61
64
|
default: return React.createElement(Checkbox, __assign({}, otherProps));
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
|
-
return (React.createElement("label", { "data-testid": props['data-testid'] || "Selector", className: props.className },
|
|
67
|
+
return (React.createElement("label", { "data-testid": props['data-testid'] || "Selector", className: props.className, style: props.style },
|
|
65
68
|
React.createElement("input", { ref: inputRef, name: props.name, type: props.radio ? "radio" : "checkbox", value: props.value === null ? undefined : props.value, checked: checked === null ? false : checked, disabled: props.disabled, onChange: handleChange }),
|
|
66
69
|
getWidget(),
|
|
67
70
|
React.createElement("span", null, props.label)));
|