@jobber/components 6.103.2-JOB-140609-9051081.26 → 6.103.2-JOB-141426-1b49367.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 +1 -12
- package/dist/Autocomplete/index.cjs +24 -3
- package/dist/Autocomplete/index.mjs +24 -3
- package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
- package/dist/Checkbox/Checkbox.types.d.ts +9 -2
- package/dist/Checkbox/index.cjs +2 -3
- package/dist/Checkbox/index.mjs +2 -3
- 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/DataListSearch/index.cjs +12 -1
- package/dist/DataList/components/DataListSearch/index.mjs +12 -1
- package/dist/DataList/index.cjs +8 -0
- package/dist/DataList/index.mjs +8 -0
- package/dist/DataTable/index.cjs +2 -2
- package/dist/DataTable/index.mjs +2 -2
- package/dist/DatePicker/index.cjs +2 -2
- package/dist/DatePicker/index.mjs +2 -2
- package/dist/FormField/FormFieldTypes.d.ts +1 -217
- package/dist/FormField-cjs.js +1 -0
- package/dist/FormField-es.js +1 -1
- package/dist/InputDate/index.cjs +4 -8
- package/dist/InputDate/index.mjs +4 -8
- package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
- package/dist/InputEmail/InputEmail.types.d.ts +21 -16
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +32 -0
- package/dist/InputEmail/index.cjs +45 -10
- package/dist/InputEmail/index.mjs +45 -10
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +2 -23
- package/dist/InputNumber/index.cjs +2 -5
- package/dist/InputNumber/index.mjs +2 -5
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +26 -15
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +71 -0
- package/dist/InputPhoneNumber/index.cjs +35 -20
- package/dist/InputPhoneNumber/index.mjs +35 -20
- package/dist/InputText/InputText.d.ts +2 -2
- package/dist/InputText/InputText.types.d.ts +24 -27
- package/dist/InputText/index.cjs +55 -26
- package/dist/InputText/index.mjs +56 -27
- package/dist/InputText/useInputTextActions.d.ts +1 -1
- package/dist/InputText/useInputTextFormField.d.ts +352 -0
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +1 -21
- package/dist/InputTime/index.cjs +25 -30
- package/dist/InputTime/index.d.ts +1 -1
- package/dist/InputTime/index.mjs +27 -32
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/RecurringSelect/index.cjs +2 -2
- package/dist/RecurringSelect/index.mjs +2 -2
- package/dist/Select/Select.rebuilt.d.ts +1 -1
- package/dist/Select/Select.types.d.ts +1 -14
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/hooks/useSelectFormField.d.ts +34 -0
- package/dist/Select/index.cjs +41 -27
- package/dist/Select/index.d.ts +5 -7
- package/dist/Select/index.mjs +43 -29
- 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/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
- package/dist/{_getAllKeys-es.js → _baseGet-es.js} +182 -182
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/omit-cjs.js +14 -14
- package/dist/omit-es.js +1 -1
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +1 -1
- package/package.json +2 -2
|
@@ -1,43 +1,22 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
4
|
-
import type { AriaInputProps, FocusEvents, KeyboardEvents } from "../FormField/FormFieldTypes";
|
|
5
4
|
export type InputNumberVersion = 1 | 2 | undefined;
|
|
6
|
-
export interface InputNumberRebuiltProps extends Omit<CommonFormFieldProps, "version">,
|
|
5
|
+
export interface InputNumberRebuiltProps extends Omit<CommonFormFieldProps, "version">, Pick<FormFieldProps, "onFocus" | "onBlur" | "inputRef" | "readonly" | "size"> {
|
|
7
6
|
readonly align?: "center" | "right";
|
|
8
|
-
|
|
9
|
-
* HTML autocomplete attribute for browser autofill.
|
|
10
|
-
*/
|
|
11
|
-
readonly autoComplete?: string;
|
|
7
|
+
readonly autocomplete?: boolean;
|
|
12
8
|
readonly autoFocus?: boolean;
|
|
13
9
|
readonly defaultValue?: number;
|
|
14
10
|
readonly description?: ReactNode;
|
|
15
11
|
readonly error?: string;
|
|
16
12
|
readonly formatOptions?: Intl.NumberFormatOptions;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use `id` instead.
|
|
19
|
-
*/
|
|
20
13
|
readonly identifier?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The ID of the input element.
|
|
23
|
-
*/
|
|
24
|
-
readonly id?: string;
|
|
25
14
|
readonly inline?: boolean;
|
|
26
15
|
readonly invalid?: boolean;
|
|
27
16
|
readonly maxValue?: number;
|
|
28
17
|
readonly minValue?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Callback for value changes.
|
|
31
|
-
* @param newValue - The new numeric value
|
|
32
|
-
* @param event - Optional change event
|
|
33
|
-
*/
|
|
34
18
|
readonly onChange?: (newValue: number, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the input is read-only.
|
|
37
|
-
*/
|
|
38
|
-
readonly readOnly?: boolean;
|
|
39
19
|
readonly showMiniLabel?: boolean;
|
|
40
|
-
readonly size?: FormFieldProps["size"];
|
|
41
20
|
readonly value?: number;
|
|
42
21
|
/**
|
|
43
22
|
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
@@ -2740,12 +2740,9 @@ const InputNumberRebuilt = React.forwardRef((props, ref) => {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
},
|
|
2742
2742
|
}));
|
|
2743
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
2744
|
-
// Deprecated props (filter out to avoid spreading to React Aria)
|
|
2745
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2746
|
-
identifier: _deprecatedIdentifier } = props, ariaNumberFieldProps = tslib_es6.__rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue", "identifier"]);
|
|
2743
|
+
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"]);
|
|
2747
2744
|
const stringDescription = typeof description === "string";
|
|
2748
|
-
return (React.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions,
|
|
2745
|
+
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); }, onChange: handleChange }),
|
|
2749
2746
|
React.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2750
2747
|
React.createElement("div", { className: styles.horizontalWrapper },
|
|
2751
2748
|
React.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
@@ -2738,12 +2738,9 @@ const InputNumberRebuilt = forwardRef((props, ref) => {
|
|
|
2738
2738
|
}
|
|
2739
2739
|
},
|
|
2740
2740
|
}));
|
|
2741
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
2742
|
-
// Deprecated props (filter out to avoid spreading to React Aria)
|
|
2743
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2744
|
-
identifier: _deprecatedIdentifier } = props, ariaNumberFieldProps = __rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue", "identifier"]);
|
|
2741
|
+
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"]);
|
|
2745
2742
|
const stringDescription = typeof description === "string";
|
|
2746
|
-
return (React__default.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions,
|
|
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: 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); }, onChange: handleChange }),
|
|
2747
2744
|
React__default.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2748
2745
|
React__default.createElement("div", { className: styles.horizontalWrapper },
|
|
2749
2746
|
React__default.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Clearable } from "@jobber/hooks";
|
|
1
2
|
import type { InputMaskProps } from "./InputMask";
|
|
2
|
-
import type { CommonFormFieldProps,
|
|
3
|
+
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
3
4
|
export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps, "align">, Pick<FormFieldProps, "autocomplete" | "onEnter" | "onFocus" | "onBlur" | "validations" | "readonly" | "prefix" | "suffix"> {
|
|
4
5
|
readonly value: string;
|
|
5
6
|
readonly onChange: (value: string) => void;
|
|
@@ -15,21 +16,20 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
|
|
|
15
16
|
*/
|
|
16
17
|
readonly required?: boolean;
|
|
17
18
|
}
|
|
18
|
-
export interface InputPhoneNumberRebuiltProps extends Omit<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export interface InputPhoneNumberRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "onBlur" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue" | "readOnly" | "type" | "maxLength" | "minLength"> {
|
|
20
|
+
readonly error?: string;
|
|
21
|
+
readonly invalid?: boolean;
|
|
22
|
+
readonly identifier?: string;
|
|
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;
|
|
22
28
|
readonly value: string;
|
|
23
|
-
/**
|
|
24
|
-
* Custom onChange handler that provides the new value as the first argument.
|
|
25
|
-
*/
|
|
26
29
|
readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
27
|
-
|
|
28
|
-
* A callback to handle "Enter" keypress. This will only run
|
|
29
|
-
* if Enter is the only key. Will not run if Shift or Control
|
|
30
|
-
* are being held.
|
|
31
|
-
*/
|
|
30
|
+
readonly onBlur?: (event?: React.FocusEvent<HTMLInputElement>) => void;
|
|
32
31
|
readonly onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
32
|
+
readonly onFocus?: (event?: React.FocusEvent<HTMLInputElement>) => void;
|
|
33
33
|
/**
|
|
34
34
|
* A pattern to specify the format to display the phone number in.
|
|
35
35
|
* For example if you want to display the format for [Denmark](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#Denmark)
|
|
@@ -38,8 +38,19 @@ export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "
|
|
|
38
38
|
*/
|
|
39
39
|
readonly pattern?: InputMaskProps["pattern"];
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Shows a "required" validation message when the component is left empty.
|
|
42
42
|
*/
|
|
43
|
-
readonly
|
|
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;
|
|
44
55
|
}
|
|
45
56
|
export declare const DEFAULT_PATTERN = "(***) ***-****";
|
|
@@ -11,6 +11,6 @@ export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBl
|
|
|
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
16
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from "react";
|
|
2
|
+
export interface useInputPhoneFormFieldProps {
|
|
3
|
+
/**
|
|
4
|
+
* The html id for the field
|
|
5
|
+
*/
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/**
|
|
8
|
+
* The auto-generated name for the html input field if a nameProp is not provided
|
|
9
|
+
*/
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* The error message for the field
|
|
13
|
+
*/
|
|
14
|
+
readonly error?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Adjusts the form field to go inline with a content. This also silences the
|
|
17
|
+
* given `validations` prop. You'd have to used the `onValidate` prop to
|
|
18
|
+
* capture the message and render it somewhere else using the
|
|
19
|
+
* `InputValidation` component.
|
|
20
|
+
*/
|
|
21
|
+
readonly inline?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Further description of the input, can be used for a hint.
|
|
24
|
+
*/
|
|
25
|
+
readonly description?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Callback for when the field value changes
|
|
28
|
+
*/
|
|
29
|
+
handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Callback for when the field loses focus
|
|
32
|
+
*/
|
|
33
|
+
handleBlur: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Callback for when the field gains focus
|
|
36
|
+
*/
|
|
37
|
+
handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Callback for when keydown event is triggered on the field
|
|
40
|
+
*/
|
|
41
|
+
handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
42
|
+
readonly invalid?: boolean;
|
|
43
|
+
readonly disabled?: boolean;
|
|
44
|
+
readonly autofocus?: boolean;
|
|
45
|
+
readonly value?: string;
|
|
46
|
+
readonly readonly?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface UseInputPhoneFormFieldReturn {
|
|
49
|
+
fieldProps: React.InputHTMLAttributes<HTMLInputElement>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provides the props for the html fields rendered by the html input.
|
|
53
|
+
* 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.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useInputPhoneFormField({ id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly, ...rest }: useInputPhoneFormFieldProps): {
|
|
56
|
+
fieldProps: {
|
|
57
|
+
readOnly: boolean | undefined;
|
|
58
|
+
"aria-describedby"?: string | undefined;
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
disabled: boolean | undefined;
|
|
62
|
+
autoFocus: boolean | undefined;
|
|
63
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
64
|
+
onBlur: () => void;
|
|
65
|
+
onFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
66
|
+
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
67
|
+
value: string | undefined;
|
|
68
|
+
invalid: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
descriptionIdentifier: string;
|
|
71
|
+
};
|
|
@@ -115,7 +115,7 @@ const DEFAULT_PATTERN = "(***) ***-****";
|
|
|
115
115
|
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
|
|
116
116
|
function handleClear() {
|
|
117
117
|
var _a;
|
|
118
|
-
|
|
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
|
}
|
|
@@ -149,25 +149,28 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
|
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
|
+
|
|
152
166
|
const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
153
167
|
var _b, _c, _d, _e;
|
|
154
168
|
var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
|
|
155
169
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
|
|
156
170
|
const wrapperRef = React.useRef(null);
|
|
157
|
-
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
158
|
-
size: props.size,
|
|
159
|
-
align: props.align,
|
|
160
|
-
placeholder: props.placeholder,
|
|
161
|
-
value: props.value,
|
|
162
|
-
invalid: props.invalid,
|
|
163
|
-
error: props.error,
|
|
164
|
-
maxLength: undefined, // v2: maxLength not used for width styling
|
|
165
|
-
disabled: props.disabled,
|
|
166
|
-
inline: props.inline,
|
|
167
|
-
type: "tel",
|
|
168
|
-
});
|
|
171
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
|
|
169
172
|
const generatedId = React.useId();
|
|
170
|
-
const id = props.
|
|
173
|
+
const id = props.id || generatedId;
|
|
171
174
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
172
175
|
nameProp: props.name,
|
|
173
176
|
id: id,
|
|
@@ -185,13 +188,25 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
|
|
|
185
188
|
onEnter: props.onEnter,
|
|
186
189
|
inputRef: inputPhoneNumberRef,
|
|
187
190
|
});
|
|
188
|
-
const descriptionIdentifier =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const { fieldProps, descriptionIdentifier } = useInputPhoneFormField({
|
|
192
|
+
id,
|
|
193
|
+
name,
|
|
194
|
+
handleChange,
|
|
195
|
+
handleBlur,
|
|
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, {
|
|
193
208
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
194
|
-
}), value: formattedValue
|
|
209
|
+
}), value: formattedValue })),
|
|
195
210
|
React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
196
211
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
197
212
|
});
|
|
@@ -113,7 +113,7 @@ const DEFAULT_PATTERN = "(***) ***-****";
|
|
|
113
113
|
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
|
|
114
114
|
function handleClear() {
|
|
115
115
|
var _a;
|
|
116
|
-
|
|
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
|
}
|
|
@@ -147,25 +147,28 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
|
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
|
|
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
|
+
|
|
150
164
|
const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
151
165
|
var _b, _c, _d, _e;
|
|
152
166
|
var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
|
|
153
167
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
|
|
154
168
|
const wrapperRef = React__default.useRef(null);
|
|
155
|
-
const { inputStyle } = useFormFieldWrapperStyles({
|
|
156
|
-
size: props.size,
|
|
157
|
-
align: props.align,
|
|
158
|
-
placeholder: props.placeholder,
|
|
159
|
-
value: props.value,
|
|
160
|
-
invalid: props.invalid,
|
|
161
|
-
error: props.error,
|
|
162
|
-
maxLength: undefined, // v2: maxLength not used for width styling
|
|
163
|
-
disabled: props.disabled,
|
|
164
|
-
inline: props.inline,
|
|
165
|
-
type: "tel",
|
|
166
|
-
});
|
|
169
|
+
const { inputStyle } = useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
|
|
167
170
|
const generatedId = useId();
|
|
168
|
-
const id = props.
|
|
171
|
+
const id = props.id || generatedId;
|
|
169
172
|
const { name } = useAtlantisFormFieldName({
|
|
170
173
|
nameProp: props.name,
|
|
171
174
|
id: id,
|
|
@@ -183,13 +186,25 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
|
|
|
183
186
|
onEnter: props.onEnter,
|
|
184
187
|
inputRef: inputPhoneNumberRef,
|
|
185
188
|
});
|
|
186
|
-
const descriptionIdentifier =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
const { fieldProps, descriptionIdentifier } = useInputPhoneFormField({
|
|
190
|
+
id,
|
|
191
|
+
name,
|
|
192
|
+
handleChange,
|
|
193
|
+
handleBlur,
|
|
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, {
|
|
191
206
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
192
|
-
}), value: formattedValue
|
|
207
|
+
}), value: formattedValue })),
|
|
193
208
|
React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
194
209
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
195
210
|
});
|
|
@@ -24,11 +24,11 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
24
24
|
readonly toolbar?: React.ReactNode;
|
|
25
25
|
readonly defaultValue?: (string | Date) | undefined;
|
|
26
26
|
readonly prefix?: import("../FormField").Affix | undefined;
|
|
27
|
-
readonly maxLength?: number | undefined;
|
|
28
27
|
readonly autofocus?: boolean | undefined;
|
|
29
28
|
readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
|
|
30
29
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
31
30
|
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
31
|
+
readonly maxLength?: number | undefined;
|
|
32
32
|
readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
33
33
|
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
34
34
|
readonly readonly?: boolean | undefined;
|
|
@@ -58,11 +58,11 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
58
58
|
readonly toolbar?: React.ReactNode;
|
|
59
59
|
readonly defaultValue?: (string | Date) | undefined;
|
|
60
60
|
readonly prefix?: import("../FormField").Affix | undefined;
|
|
61
|
-
readonly maxLength?: number | undefined;
|
|
62
61
|
readonly autofocus?: boolean | undefined;
|
|
63
62
|
readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
|
|
64
63
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
65
64
|
readonly keyboard?: ("numeric" | "decimal") | undefined;
|
|
65
|
+
readonly maxLength?: number | undefined;
|
|
66
66
|
readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
|
|
67
67
|
onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
|
|
68
68
|
readonly readonly?: boolean | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Clearable } from "@jobber/hooks";
|
|
1
2
|
import type { XOR } from "ts-xor";
|
|
2
|
-
import type {
|
|
3
|
+
import type { AutocompleteTypes, CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
|
|
3
4
|
export interface RowRange {
|
|
4
5
|
min: number;
|
|
5
6
|
max: number;
|
|
@@ -9,7 +10,15 @@ export type InputTextVersion = 1 | 2 | undefined;
|
|
|
9
10
|
* Experimental version 2 of the InputText component.
|
|
10
11
|
* Do not use unless you have talked with Atlantis first.
|
|
11
12
|
*/
|
|
12
|
-
export interface InputTextRebuiltProps extends
|
|
13
|
+
export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>, "onChange" | "onBlur" | "maxLength" | "rows" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue"> {
|
|
14
|
+
readonly error?: string;
|
|
15
|
+
readonly invalid?: boolean;
|
|
16
|
+
readonly identifier?: string;
|
|
17
|
+
readonly autocomplete?: boolean | AutocompleteTypes;
|
|
18
|
+
readonly loading?: boolean;
|
|
19
|
+
readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
|
+
readonly children?: React.ReactNode;
|
|
21
|
+
readonly clearable?: Clearable;
|
|
13
22
|
/**
|
|
14
23
|
* Use this when you're expecting a long answer.
|
|
15
24
|
*/
|
|
@@ -21,36 +30,24 @@ export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<H
|
|
|
21
30
|
* maximum number of visible rows.
|
|
22
31
|
*/
|
|
23
32
|
readonly rows?: number | RowRange;
|
|
24
|
-
/**
|
|
25
|
-
* Determines what kind of form field should the component give you.
|
|
26
|
-
*/
|
|
27
33
|
readonly type?: FormFieldTypes;
|
|
28
34
|
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
readonly toolbar?: React.ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* Determines the visibility of the toolbar.
|
|
34
|
-
*/
|
|
35
|
-
readonly toolbarVisibility?: "always" | "while-editing";
|
|
36
|
-
/**
|
|
37
|
-
* The current value of the input.
|
|
38
|
-
*/
|
|
39
|
-
readonly value: string;
|
|
40
|
-
/**
|
|
41
|
-
* Custom onChange handler that provides the new value as the first argument.
|
|
35
|
+
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
42
36
|
*/
|
|
37
|
+
readonly version: 2;
|
|
43
38
|
readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
44
|
-
/**
|
|
45
|
-
* A callback to handle "Enter" keypress. This will only run
|
|
46
|
-
* if Enter is the only key. Will not run if Shift or Control
|
|
47
|
-
* are being held.
|
|
48
|
-
*/
|
|
49
39
|
readonly onEnter?: FormFieldProps["onEnter"];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
readonly
|
|
40
|
+
readonly onBlur?: FormFieldProps["onBlur"];
|
|
41
|
+
readonly value: string;
|
|
42
|
+
readonly maxLength?: number;
|
|
43
|
+
readonly size?: FormFieldProps["size"];
|
|
44
|
+
readonly inline?: FormFieldProps["inline"];
|
|
45
|
+
readonly align?: FormFieldProps["align"];
|
|
46
|
+
readonly toolbar?: FormFieldProps["toolbar"];
|
|
47
|
+
readonly toolbarVisibility?: FormFieldProps["toolbarVisibility"];
|
|
48
|
+
readonly prefix?: FormFieldProps["prefix"];
|
|
49
|
+
readonly suffix?: FormFieldProps["suffix"];
|
|
50
|
+
readonly description?: FormFieldProps["description"];
|
|
54
51
|
}
|
|
55
52
|
interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
|
|
56
53
|
multiline?: boolean;
|