@jobber/components 6.104.0 → 6.105.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/Autocomplete/Autocomplete.types.d.ts +9 -51
- package/dist/Autocomplete/index.cjs +10 -20
- package/dist/Autocomplete/index.mjs +10 -20
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +1 -1
- package/dist/Autocomplete/useAutocomplete.d.ts +2 -2
- package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
- package/dist/Checkbox/Checkbox.types.d.ts +24 -18
- package/dist/Checkbox/index.cjs +9 -2
- package/dist/Checkbox/index.mjs +9 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
- package/dist/Chips/index.cjs +2 -2
- package/dist/Chips/index.mjs +2 -2
- package/dist/DataList/components/DataListHeader/index.cjs +1 -0
- package/dist/DataList/components/DataListHeader/index.mjs +1 -0
- package/dist/DataList/components/DataListItem/index.cjs +1 -0
- package/dist/DataList/components/DataListItem/index.mjs +1 -0
- package/dist/DataList/components/DataListItems/index.cjs +1 -0
- package/dist/DataList/components/DataListItems/index.mjs +1 -0
- package/dist/DataList/components/DataListLayout/index.cjs +1 -0
- package/dist/DataList/components/DataListLayout/index.mjs +1 -0
- package/dist/DataList/components/DataListSearch/index.cjs +2 -12
- package/dist/DataList/components/DataListSearch/index.mjs +2 -12
- package/dist/DataList/index.cjs +1 -8
- package/dist/DataList/index.mjs +1 -8
- package/dist/DataTable/index.cjs +3 -2
- package/dist/DataTable/index.mjs +3 -2
- package/dist/DatePicker/index.cjs +2 -2
- package/dist/DatePicker/index.mjs +2 -2
- package/dist/FormField/FormFieldTypes.d.ts +0 -2
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +7 -2
- package/dist/FormField-cjs.js +0 -1
- package/dist/FormField-es.js +1 -1
- package/dist/InputDate/InputDate.types.d.ts +12 -7
- package/dist/InputDate/index.cjs +6 -9
- package/dist/InputDate/index.mjs +6 -9
- package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
- package/dist/InputEmail/InputEmail.types.d.ts +10 -20
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
- package/dist/InputEmail/index.cjs +43 -49
- package/dist/InputEmail/index.mjs +43 -49
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
- package/dist/InputNumber/index.cjs +6 -4
- package/dist/InputNumber/index.mjs +6 -4
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
- package/dist/InputPhoneNumber/index.cjs +48 -36
- package/dist/InputPhoneNumber/index.mjs +48 -36
- package/dist/InputText/InputText.types.d.ts +31 -25
- package/dist/InputText/index.cjs +66 -62
- package/dist/InputText/index.mjs +67 -63
- package/dist/InputText/useInputTextActions.d.ts +10 -4
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +13 -4
- package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
- package/dist/InputTime/index.cjs +91 -30
- package/dist/InputTime/index.mjs +94 -33
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/MultiSelect/index.cjs +1 -0
- package/dist/MultiSelect/index.mjs +1 -0
- package/dist/RecurringSelect/index.cjs +3 -2
- package/dist/RecurringSelect/index.mjs +3 -2
- package/dist/Select/Select.types.d.ts +7 -3
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/index.cjs +27 -41
- package/dist/Select/index.mjs +29 -43
- package/dist/Tabs-es.js +1 -1
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +1 -1
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
- package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
- package/dist/debounce-es.js +1 -1
- package/dist/filterDataAttributes-cjs.js +26 -0
- package/dist/filterDataAttributes-es.js +24 -0
- package/dist/index.cjs +3 -2
- package/dist/index.mjs +3 -2
- package/dist/omit-cjs.js +14 -14
- package/dist/omit-es.js +1 -1
- package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
- package/dist/sharedHelpers/types.d.ts +231 -0
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +2 -2
- package/package.json +2 -2
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
- package/dist/InputText/useInputTextFormField.d.ts +0 -366
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React__default, { forwardRef, useId, useRef } from 'react';
|
|
2
2
|
import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix } from '../FormField-es.js';
|
|
3
3
|
import 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import '../tslib.es6-es.js';
|
|
5
5
|
import 'react-hook-form';
|
|
6
6
|
import '@jobber/hooks';
|
|
7
7
|
import 'framer-motion';
|
|
8
8
|
import '@jobber/design';
|
|
9
9
|
import '../Button-es.js';
|
|
10
|
-
import {
|
|
10
|
+
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
11
11
|
import '../Icon-es.js';
|
|
12
12
|
import '../Text-es.js';
|
|
13
13
|
import '../Typography-es.js';
|
|
@@ -15,17 +15,6 @@ import '../useFormFieldFocus-es.js';
|
|
|
15
15
|
import '../InputValidation-es.js';
|
|
16
16
|
import '../Spinner-es.js';
|
|
17
17
|
import 'react-router-dom';
|
|
18
|
-
import '../_commonjsHelpers-es.js';
|
|
19
|
-
import '../_baseGet-es.js';
|
|
20
|
-
import '../isTypedArray-es.js';
|
|
21
|
-
import '../isObjectLike-es.js';
|
|
22
|
-
import '../identity-es.js';
|
|
23
|
-
import '../_getTag-es.js';
|
|
24
|
-
import '../isSymbol-es.js';
|
|
25
|
-
import '../keysIn-es.js';
|
|
26
|
-
import '../_baseAssignValue-es.js';
|
|
27
|
-
import '../_baseFlatten-es.js';
|
|
28
|
-
import '../_setToString-es.js';
|
|
29
18
|
|
|
30
19
|
const validationMessage = "Please enter a valid email";
|
|
31
20
|
|
|
@@ -44,10 +33,9 @@ function InputEmail$1(props) {
|
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
36
|
+
function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
48
37
|
function handleClear() {
|
|
49
38
|
var _a;
|
|
50
|
-
handleBlur();
|
|
51
39
|
onChange === null || onChange === void 0 ? void 0 : onChange("");
|
|
52
40
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
53
41
|
}
|
|
@@ -72,28 +60,43 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
|
|
|
72
60
|
function handleBlur(event) {
|
|
73
61
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
74
62
|
}
|
|
63
|
+
function handleKeyUp(event) {
|
|
64
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
|
|
65
|
+
}
|
|
66
|
+
function handleClick(event) {
|
|
67
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
68
|
+
}
|
|
69
|
+
function handleMouseDown(event) {
|
|
70
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
71
|
+
}
|
|
72
|
+
function handleMouseUp(event) {
|
|
73
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
74
|
+
}
|
|
75
|
+
function handlePointerDown(event) {
|
|
76
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
77
|
+
}
|
|
78
|
+
function handlePointerUp(event) {
|
|
79
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
80
|
+
}
|
|
75
81
|
return {
|
|
76
82
|
handleClear,
|
|
77
83
|
handleChange,
|
|
78
84
|
handleKeyDown,
|
|
85
|
+
handleKeyUp,
|
|
79
86
|
handleFocus,
|
|
80
87
|
handleBlur,
|
|
88
|
+
handleClick,
|
|
89
|
+
handleMouseDown,
|
|
90
|
+
handleMouseUp,
|
|
91
|
+
handlePointerDown,
|
|
92
|
+
handlePointerUp,
|
|
81
93
|
};
|
|
82
94
|
}
|
|
83
95
|
|
|
84
|
-
function useInputEmailFormField(_a) {
|
|
85
|
-
var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = __rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
|
|
86
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
87
|
-
const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
|
|
88
|
-
name,
|
|
89
|
-
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
|
|
90
|
-
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
91
|
-
return { fieldProps, descriptionIdentifier };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
96
|
const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
|
|
95
97
|
var _a, _b, _c;
|
|
96
|
-
const
|
|
98
|
+
const generatedId = useId();
|
|
99
|
+
const id = props.id || generatedId;
|
|
97
100
|
const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : useRef(null);
|
|
98
101
|
const wrapperRef = useRef(null);
|
|
99
102
|
const { inputStyle } = useFormFieldWrapperStyles({
|
|
@@ -104,7 +107,6 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
|
|
|
104
107
|
value: props.value,
|
|
105
108
|
invalid: props.invalid,
|
|
106
109
|
error: props.error,
|
|
107
|
-
maxLength: props.maxLength,
|
|
108
110
|
disabled: props.disabled,
|
|
109
111
|
placeholder: props.placeholder,
|
|
110
112
|
});
|
|
@@ -112,35 +114,27 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
|
|
|
112
114
|
nameProp: props.name,
|
|
113
115
|
id,
|
|
114
116
|
});
|
|
115
|
-
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputEmailActions({
|
|
117
|
+
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputEmailActions({
|
|
116
118
|
onChange: props.onChange,
|
|
117
119
|
onBlur: props.onBlur,
|
|
118
120
|
onFocus: props.onFocus,
|
|
119
121
|
onKeyDown: props.onKeyDown,
|
|
122
|
+
onKeyUp: props.onKeyUp,
|
|
120
123
|
onEnter: props.onEnter,
|
|
124
|
+
onClick: props.onClick,
|
|
125
|
+
onMouseDown: props.onMouseDown,
|
|
126
|
+
onMouseUp: props.onMouseUp,
|
|
127
|
+
onPointerDown: props.onPointerDown,
|
|
128
|
+
onPointerUp: props.onPointerUp,
|
|
121
129
|
inputRef,
|
|
122
130
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"prefix",
|
|
131
|
-
"suffix",
|
|
132
|
-
"version",
|
|
133
|
-
]);
|
|
134
|
-
const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
135
|
-
name,
|
|
136
|
-
handleChange,
|
|
137
|
-
handleBlur,
|
|
138
|
-
handleFocus,
|
|
139
|
-
handleKeyDown }));
|
|
140
|
-
return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: props.identifier || id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
|
|
141
|
-
React__default.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
|
|
142
|
-
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
143
|
-
props.children));
|
|
131
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
132
|
+
const descriptionVisible = props.description && !props.inline;
|
|
133
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
134
|
+
const dataAttrs = filterDataAttributes(props);
|
|
135
|
+
return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, name: name },
|
|
136
|
+
React__default.createElement("input", Object.assign({ id: id, name: name, type: "email", ref: inputRef, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, "data-testid": "ATL-InputEmail-input" }, dataAttrs)),
|
|
137
|
+
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false })));
|
|
144
138
|
});
|
|
145
139
|
|
|
146
140
|
function isNewInputEmailProps(props) {
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import type React from "react";
|
|
3
|
-
import type {
|
|
2
|
+
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
4
3
|
export type InputNumberVersion = 1 | 2 | undefined;
|
|
5
|
-
export interface InputNumberRebuiltProps extends
|
|
6
|
-
readonly align?: "center" | "right";
|
|
7
|
-
readonly autocomplete?: boolean;
|
|
8
|
-
readonly autoFocus?: boolean;
|
|
4
|
+
export interface InputNumberRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, MouseEvents<HTMLInputElement>, Omit<RebuiltInputCommonProps, "clearable" | "suffix" | "prefix"> {
|
|
9
5
|
readonly defaultValue?: number;
|
|
10
|
-
readonly description?: ReactNode;
|
|
11
|
-
readonly error?: string;
|
|
12
6
|
readonly formatOptions?: Intl.NumberFormatOptions;
|
|
13
|
-
readonly identifier?: string;
|
|
14
|
-
readonly inline?: boolean;
|
|
15
|
-
readonly invalid?: boolean;
|
|
16
7
|
readonly maxValue?: number;
|
|
17
8
|
readonly minValue?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Callback for value changes.
|
|
11
|
+
* @param newValue - The new numeric value
|
|
12
|
+
* @param event - Optional change event
|
|
13
|
+
*/
|
|
18
14
|
readonly onChange?: (newValue: number, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
15
|
readonly showMiniLabel?: boolean;
|
|
20
16
|
readonly value?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
23
|
-
*/
|
|
24
|
-
readonly version: 2;
|
|
25
17
|
}
|
|
26
18
|
export interface InputNumberRebuiltRef {
|
|
27
19
|
focus: () => void;
|
|
@@ -7,6 +7,7 @@ require('react-dom');
|
|
|
7
7
|
var classnames = require('classnames');
|
|
8
8
|
var Icon = require('../Icon-cjs.js');
|
|
9
9
|
var Text = require('../Text-cjs.js');
|
|
10
|
+
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
10
11
|
var FormField = require('../FormField-cjs.js');
|
|
11
12
|
require('react-hook-form');
|
|
12
13
|
require('@jobber/hooks');
|
|
@@ -2740,14 +2741,15 @@ const InputNumberRebuilt = React.forwardRef((props, ref) => {
|
|
|
2740
2741
|
}
|
|
2741
2742
|
},
|
|
2742
2743
|
}));
|
|
2743
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
2744
|
+
const { align, description, disabled, error, inline, invalid, placeholder, readOnly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = tslib_es6.__rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue"]);
|
|
2745
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
2744
2746
|
const stringDescription = typeof description === "string";
|
|
2745
|
-
return (React.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly:
|
|
2747
|
+
return (React.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly: readOnly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onClick: props.onClick, onMouseDown: props.onMouseDown, onMouseUp: props.onMouseUp, onPointerDown: props.onPointerDown, onPointerUp: props.onPointerUp, onChange: handleChange }),
|
|
2746
2748
|
React.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2747
2749
|
React.createElement("div", { className: styles.horizontalWrapper },
|
|
2748
2750
|
React.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
2749
|
-
React.createElement($3985021b0ad6602f$export$f5b8910cec6cf069, { className: styles.input, placeholder: " " // used for CSS minilabel
|
|
2750
|
-
, ref: inputRef }),
|
|
2751
|
+
React.createElement($3985021b0ad6602f$export$f5b8910cec6cf069, Object.assign({ className: styles.input, placeholder: " " // used for CSS minilabel
|
|
2752
|
+
, ref: inputRef }, dataAttrs)),
|
|
2751
2753
|
React.createElement($01b77f81d0f07f68$export$b04be29aa201d4f5, { className: styles.label }, placeholder)))),
|
|
2752
2754
|
description && (React.createElement(Tree.$514c0188e459b4c0$export$5f1af8db9871e1d6, { className: styles.description, elementType: "div", slot: "description" }, stringDescription ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description))),
|
|
2753
2755
|
error && (React.createElement($ee014567cb39d3f0$export$f551688fc98f2e09, { className: styles.fieldError },
|
|
@@ -5,6 +5,7 @@ import 'react-dom';
|
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
import { I as Icon } from '../Icon-es.js';
|
|
7
7
|
import { T as Text } from '../Text-es.js';
|
|
8
|
+
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
8
9
|
import { k as FormField } from '../FormField-es.js';
|
|
9
10
|
import 'react-hook-form';
|
|
10
11
|
import '@jobber/hooks';
|
|
@@ -2738,14 +2739,15 @@ const InputNumberRebuilt = forwardRef((props, ref) => {
|
|
|
2738
2739
|
}
|
|
2739
2740
|
},
|
|
2740
2741
|
}));
|
|
2741
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
2742
|
+
const { align, description, disabled, error, inline, invalid, placeholder, readOnly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = __rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue"]);
|
|
2743
|
+
const dataAttrs = filterDataAttributes(props);
|
|
2742
2744
|
const stringDescription = typeof description === "string";
|
|
2743
|
-
return (React__default.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly:
|
|
2745
|
+
return (React__default.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly: readOnly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onClick: props.onClick, onMouseDown: props.onMouseDown, onMouseUp: props.onMouseUp, onPointerDown: props.onPointerDown, onPointerUp: props.onPointerUp, onChange: handleChange }),
|
|
2744
2746
|
React__default.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2745
2747
|
React__default.createElement("div", { className: styles.horizontalWrapper },
|
|
2746
2748
|
React__default.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
2747
|
-
React__default.createElement($3985021b0ad6602f$export$f5b8910cec6cf069, { className: styles.input, placeholder: " " // used for CSS minilabel
|
|
2748
|
-
, ref: inputRef }),
|
|
2749
|
+
React__default.createElement($3985021b0ad6602f$export$f5b8910cec6cf069, Object.assign({ className: styles.input, placeholder: " " // used for CSS minilabel
|
|
2750
|
+
, ref: inputRef }, dataAttrs)),
|
|
2749
2751
|
React__default.createElement($01b77f81d0f07f68$export$b04be29aa201d4f5, { className: styles.label }, placeholder)))),
|
|
2750
2752
|
description && (React__default.createElement($514c0188e459b4c0$export$5f1af8db9871e1d6, { className: styles.description, elementType: "div", slot: "description" }, stringDescription ? (React__default.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description))),
|
|
2751
2753
|
error && (React__default.createElement($ee014567cb39d3f0$export$f551688fc98f2e09, { className: styles.fieldError },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Clearable } from "@jobber/hooks";
|
|
2
1
|
import type { InputMaskProps } from "./InputMask";
|
|
3
2
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
3
|
+
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
4
4
|
export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps, "align">, Pick<FormFieldProps, "autocomplete" | "onEnter" | "onFocus" | "onBlur" | "validations" | "readonly" | "prefix" | "suffix"> {
|
|
5
5
|
readonly value: string;
|
|
6
6
|
readonly onChange: (value: string) => void;
|
|
@@ -16,20 +16,19 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
|
|
|
16
16
|
*/
|
|
17
17
|
readonly required?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export interface InputPhoneNumberRebuiltProps extends Omit<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readonly autocomplete?: boolean | string;
|
|
24
|
-
readonly loading?: boolean;
|
|
25
|
-
readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
26
|
-
readonly children?: React.ReactNode;
|
|
27
|
-
readonly clearable?: Clearable;
|
|
19
|
+
export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "type" | "maxLength" | "minLength">, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, MouseEvents<HTMLInputElement>, RebuiltInputCommonProps {
|
|
20
|
+
/**
|
|
21
|
+
* The current value of the input.
|
|
22
|
+
*/
|
|
28
23
|
readonly value: string;
|
|
24
|
+
/**
|
|
25
|
+
* Custom onChange handler that provides the new value as the first argument.
|
|
26
|
+
*/
|
|
29
27
|
readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
30
|
+
*/
|
|
31
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
33
32
|
/**
|
|
34
33
|
* A pattern to specify the format to display the phone number in.
|
|
35
34
|
* For example if you want to display the format for [Denmark](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#Denmark)
|
|
@@ -37,20 +36,5 @@ export interface InputPhoneNumberRebuiltProps extends Omit<React.InputHTMLAttrib
|
|
|
37
36
|
* @default "(***) ***-****"
|
|
38
37
|
*/
|
|
39
38
|
readonly pattern?: InputMaskProps["pattern"];
|
|
40
|
-
/**
|
|
41
|
-
* Shows a "required" validation message when the component is left empty.
|
|
42
|
-
*/
|
|
43
|
-
readonly required?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
|
|
46
|
-
*/
|
|
47
|
-
readonly version: 2;
|
|
48
|
-
readonly size?: FormFieldProps["size"];
|
|
49
|
-
readonly inline?: FormFieldProps["inline"];
|
|
50
|
-
readonly align?: FormFieldProps["align"];
|
|
51
|
-
readonly prefix?: FormFieldProps["prefix"];
|
|
52
|
-
readonly suffix?: FormFieldProps["suffix"];
|
|
53
|
-
readonly description?: FormFieldProps["description"];
|
|
54
|
-
readonly readonly?: boolean;
|
|
55
39
|
}
|
|
56
40
|
export declare const DEFAULT_PATTERN = "(***) ***-****";
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
|
|
2
2
|
import type { InputPhoneNumberRebuiltProps } from "../InputPhoneNumber.types";
|
|
3
|
-
export interface useInputPhoneActionsProps extends Pick<InputPhoneNumberRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown"> {
|
|
3
|
+
export interface useInputPhoneActionsProps extends Pick<InputPhoneNumberRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown" | "onClick" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp"> {
|
|
4
4
|
inputRef?: React.RefObject<HTMLInputElement>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
|
|
8
8
|
* Do not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
9
9
|
*/
|
|
10
|
-
export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }: useInputPhoneActionsProps): {
|
|
10
|
+
export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }: useInputPhoneActionsProps): {
|
|
11
11
|
handleClear: () => void;
|
|
12
12
|
handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
13
13
|
handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
14
|
-
handleBlur: (event
|
|
14
|
+
handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
15
|
handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
|
+
handleClick: (event: MouseEvent<HTMLInputElement>) => void;
|
|
17
|
+
handleMouseDown: (event: MouseEvent<HTMLInputElement>) => void;
|
|
18
|
+
handleMouseUp: (event: MouseEvent<HTMLInputElement>) => void;
|
|
19
|
+
handlePointerDown: (event: PointerEvent<HTMLInputElement>) => void;
|
|
20
|
+
handlePointerUp: (event: PointerEvent<HTMLInputElement>) => void;
|
|
16
21
|
};
|
|
@@ -7,6 +7,7 @@ var FormField = require('../FormField-cjs.js');
|
|
|
7
7
|
var reactHookForm = require('react-hook-form');
|
|
8
8
|
require('../Button-cjs.js');
|
|
9
9
|
require('@jobber/design');
|
|
10
|
+
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
10
11
|
require('@jobber/hooks');
|
|
11
12
|
require('framer-motion');
|
|
12
13
|
require('../Icon-cjs.js');
|
|
@@ -112,10 +113,9 @@ const DEFAULT_PATTERN = "(***) ***-****";
|
|
|
112
113
|
* Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
|
|
113
114
|
* Do not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
114
115
|
*/
|
|
115
|
-
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
|
|
116
|
+
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
116
117
|
function handleClear() {
|
|
117
118
|
var _a;
|
|
118
|
-
handleBlur();
|
|
119
119
|
onChange && onChange("");
|
|
120
120
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
121
121
|
}
|
|
@@ -140,35 +140,51 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
|
|
|
140
140
|
function handleBlur(event) {
|
|
141
141
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
142
142
|
}
|
|
143
|
+
function handleClick(event) {
|
|
144
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
145
|
+
}
|
|
146
|
+
function handleMouseDown(event) {
|
|
147
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
148
|
+
}
|
|
149
|
+
function handleMouseUp(event) {
|
|
150
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
151
|
+
}
|
|
152
|
+
function handlePointerDown(event) {
|
|
153
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
154
|
+
}
|
|
155
|
+
function handlePointerUp(event) {
|
|
156
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
157
|
+
}
|
|
143
158
|
return {
|
|
144
159
|
handleClear,
|
|
145
160
|
handleChange,
|
|
146
161
|
handleFocus,
|
|
147
162
|
handleBlur,
|
|
148
163
|
handleKeyDown,
|
|
164
|
+
handleClick,
|
|
165
|
+
handleMouseDown,
|
|
166
|
+
handleMouseUp,
|
|
167
|
+
handlePointerDown,
|
|
168
|
+
handlePointerUp,
|
|
149
169
|
};
|
|
150
170
|
}
|
|
151
171
|
|
|
152
|
-
/**
|
|
153
|
-
* Provides the props for the html fields rendered by the html input.
|
|
154
|
-
* DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
155
|
-
*/
|
|
156
|
-
function useInputPhoneFormField(_a) {
|
|
157
|
-
var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error", "disabled", "autofocus", "value", "readonly"]);
|
|
158
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
159
|
-
const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id,
|
|
160
|
-
name,
|
|
161
|
-
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
|
|
162
|
-
!inline && { "aria-describedby": descriptionIdentifier })), { readOnly: readonly });
|
|
163
|
-
return { fieldProps, descriptionIdentifier };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
172
|
const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
167
173
|
var _b, _c, _d, _e;
|
|
168
174
|
var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
|
|
169
175
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
|
|
170
176
|
const wrapperRef = React.useRef(null);
|
|
171
|
-
const { inputStyle } = FormField.useFormFieldWrapperStyles(
|
|
177
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
178
|
+
size: props.size,
|
|
179
|
+
align: props.align,
|
|
180
|
+
placeholder: props.placeholder,
|
|
181
|
+
value: props.value,
|
|
182
|
+
invalid: props.invalid,
|
|
183
|
+
error: props.error,
|
|
184
|
+
disabled: props.disabled,
|
|
185
|
+
inline: props.inline,
|
|
186
|
+
type: "tel",
|
|
187
|
+
});
|
|
172
188
|
const generatedId = React.useId();
|
|
173
189
|
const id = props.id || generatedId;
|
|
174
190
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
@@ -181,32 +197,28 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
|
|
|
181
197
|
strict: false,
|
|
182
198
|
onChange: props.onChange,
|
|
183
199
|
});
|
|
184
|
-
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, } = useInputPhoneActions({
|
|
200
|
+
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
|
|
185
201
|
onChange: maskedOnChange,
|
|
186
202
|
onBlur: props.onBlur,
|
|
187
203
|
onFocus: props.onFocus,
|
|
188
204
|
onEnter: props.onEnter,
|
|
205
|
+
onKeyDown: props.onKeyDown,
|
|
206
|
+
onClick: props.onClick,
|
|
207
|
+
onMouseDown: props.onMouseDown,
|
|
208
|
+
onMouseUp: props.onMouseUp,
|
|
209
|
+
onPointerDown: props.onPointerDown,
|
|
210
|
+
onPointerUp: props.onPointerUp,
|
|
189
211
|
inputRef: inputPhoneNumberRef,
|
|
190
212
|
});
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
handleFocus,
|
|
197
|
-
handleKeyDown,
|
|
198
|
-
autofocus: props.autoFocus,
|
|
199
|
-
disabled: props.disabled,
|
|
200
|
-
readonly: props.readonly,
|
|
201
|
-
invalid: props.invalid,
|
|
202
|
-
error: props.error,
|
|
203
|
-
description: props.description,
|
|
204
|
-
inline: props.inline,
|
|
205
|
-
});
|
|
206
|
-
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readonly, loading: props.loading },
|
|
207
|
-
React.createElement("input", Object.assign({ type: "tel" }, fieldProps, { ref: inputPhoneNumberRef, className: classnames(inputStyle, {
|
|
213
|
+
const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
|
|
214
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
215
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
216
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
|
|
217
|
+
React.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
|
|
208
218
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
209
|
-
}), value: formattedValue
|
|
219
|
+
}), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
220
|
+
? descriptionIdentifier
|
|
221
|
+
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
|
|
210
222
|
React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
211
223
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
212
224
|
});
|
|
@@ -5,6 +5,7 @@ import { j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as For
|
|
|
5
5
|
import { useFormContext, useForm } from 'react-hook-form';
|
|
6
6
|
import '../Button-es.js';
|
|
7
7
|
import '@jobber/design';
|
|
8
|
+
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
8
9
|
import '@jobber/hooks';
|
|
9
10
|
import 'framer-motion';
|
|
10
11
|
import '../Icon-es.js';
|
|
@@ -110,10 +111,9 @@ const DEFAULT_PATTERN = "(***) ***-****";
|
|
|
110
111
|
* Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
|
|
111
112
|
* Do not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
112
113
|
*/
|
|
113
|
-
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
|
|
114
|
+
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
114
115
|
function handleClear() {
|
|
115
116
|
var _a;
|
|
116
|
-
handleBlur();
|
|
117
117
|
onChange && onChange("");
|
|
118
118
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
119
119
|
}
|
|
@@ -138,35 +138,51 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
|
|
|
138
138
|
function handleBlur(event) {
|
|
139
139
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
140
140
|
}
|
|
141
|
+
function handleClick(event) {
|
|
142
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
143
|
+
}
|
|
144
|
+
function handleMouseDown(event) {
|
|
145
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
146
|
+
}
|
|
147
|
+
function handleMouseUp(event) {
|
|
148
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
149
|
+
}
|
|
150
|
+
function handlePointerDown(event) {
|
|
151
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
152
|
+
}
|
|
153
|
+
function handlePointerUp(event) {
|
|
154
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
155
|
+
}
|
|
141
156
|
return {
|
|
142
157
|
handleClear,
|
|
143
158
|
handleChange,
|
|
144
159
|
handleFocus,
|
|
145
160
|
handleBlur,
|
|
146
161
|
handleKeyDown,
|
|
162
|
+
handleClick,
|
|
163
|
+
handleMouseDown,
|
|
164
|
+
handleMouseUp,
|
|
165
|
+
handlePointerDown,
|
|
166
|
+
handlePointerUp,
|
|
147
167
|
};
|
|
148
168
|
}
|
|
149
169
|
|
|
150
|
-
/**
|
|
151
|
-
* Provides the props for the html fields rendered by the html input.
|
|
152
|
-
* DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
153
|
-
*/
|
|
154
|
-
function useInputPhoneFormField(_a) {
|
|
155
|
-
var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly } = _a, rest = __rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error", "disabled", "autofocus", "value", "readonly"]);
|
|
156
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
157
|
-
const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id,
|
|
158
|
-
name,
|
|
159
|
-
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
|
|
160
|
-
!inline && { "aria-describedby": descriptionIdentifier })), { readOnly: readonly });
|
|
161
|
-
return { fieldProps, descriptionIdentifier };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
170
|
const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
165
171
|
var _b, _c, _d, _e;
|
|
166
172
|
var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
|
|
167
173
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
|
|
168
174
|
const wrapperRef = React__default.useRef(null);
|
|
169
|
-
const { inputStyle } = useFormFieldWrapperStyles(
|
|
175
|
+
const { inputStyle } = useFormFieldWrapperStyles({
|
|
176
|
+
size: props.size,
|
|
177
|
+
align: props.align,
|
|
178
|
+
placeholder: props.placeholder,
|
|
179
|
+
value: props.value,
|
|
180
|
+
invalid: props.invalid,
|
|
181
|
+
error: props.error,
|
|
182
|
+
disabled: props.disabled,
|
|
183
|
+
inline: props.inline,
|
|
184
|
+
type: "tel",
|
|
185
|
+
});
|
|
170
186
|
const generatedId = useId();
|
|
171
187
|
const id = props.id || generatedId;
|
|
172
188
|
const { name } = useAtlantisFormFieldName({
|
|
@@ -179,32 +195,28 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
|
|
|
179
195
|
strict: false,
|
|
180
196
|
onChange: props.onChange,
|
|
181
197
|
});
|
|
182
|
-
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, } = useInputPhoneActions({
|
|
198
|
+
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
|
|
183
199
|
onChange: maskedOnChange,
|
|
184
200
|
onBlur: props.onBlur,
|
|
185
201
|
onFocus: props.onFocus,
|
|
186
202
|
onEnter: props.onEnter,
|
|
203
|
+
onKeyDown: props.onKeyDown,
|
|
204
|
+
onClick: props.onClick,
|
|
205
|
+
onMouseDown: props.onMouseDown,
|
|
206
|
+
onMouseUp: props.onMouseUp,
|
|
207
|
+
onPointerDown: props.onPointerDown,
|
|
208
|
+
onPointerUp: props.onPointerUp,
|
|
187
209
|
inputRef: inputPhoneNumberRef,
|
|
188
210
|
});
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
handleFocus,
|
|
195
|
-
handleKeyDown,
|
|
196
|
-
autofocus: props.autoFocus,
|
|
197
|
-
disabled: props.disabled,
|
|
198
|
-
readonly: props.readonly,
|
|
199
|
-
invalid: props.invalid,
|
|
200
|
-
error: props.error,
|
|
201
|
-
description: props.description,
|
|
202
|
-
inline: props.inline,
|
|
203
|
-
});
|
|
204
|
-
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readonly, loading: props.loading },
|
|
205
|
-
React__default.createElement("input", Object.assign({ type: "tel" }, fieldProps, { ref: inputPhoneNumberRef, className: classnames(inputStyle, {
|
|
211
|
+
const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
|
|
212
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
213
|
+
const dataAttrs = filterDataAttributes(props);
|
|
214
|
+
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
|
|
215
|
+
React__default.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
|
|
206
216
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
207
|
-
}), value: formattedValue
|
|
217
|
+
}), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
218
|
+
? descriptionIdentifier
|
|
219
|
+
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
|
|
208
220
|
React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
209
221
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
210
222
|
});
|