@jobber/components 6.103.2-JOB-140609-8386817.45 → 6.103.3
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 +13 -1
- package/dist/Autocomplete/index.mjs +13 -1
- package/dist/Checkbox/Checkbox.types.d.ts +9 -2
- package/dist/Checkbox/index.cjs +2 -4
- package/dist/Checkbox/index.mjs +2 -4
- 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 +2 -0
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +2 -7
- package/dist/FormField-cjs.js +6 -1
- package/dist/FormField-es.js +6 -2
- package/dist/InputDate/index.cjs +9 -5
- package/dist/InputDate/index.mjs +9 -5
- package/dist/InputDate/useInputDateActivatorActions.d.ts +8 -4
- package/dist/InputEmail/InputEmail.types.d.ts +20 -12
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +32 -0
- package/dist/InputEmail/index.cjs +44 -8
- package/dist/InputEmail/index.mjs +44 -8
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +3 -20
- package/dist/InputNumber/index.cjs +3 -3
- package/dist/InputNumber/index.mjs +3 -3
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +27 -13
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +71 -0
- package/dist/InputPhoneNumber/index.cjs +34 -17
- package/dist/InputPhoneNumber/index.mjs +34 -17
- package/dist/InputText/InputText.types.d.ts +24 -24
- package/dist/InputText/index.cjs +54 -54
- package/dist/InputText/index.mjs +55 -55
- 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 +33 -63
- package/dist/InputTime/index.d.ts +1 -1
- package/dist/InputTime/index.mjs +36 -66
- 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 -28
- package/dist/Select/index.d.ts +5 -7
- package/dist/Select/index.mjs +43 -30
- 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/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
- package/dist/{_getAllKeys-es.js → _baseGet-es.js} +182 -182
- package/dist/debounce-es.js +1 -1
- 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/sharedHelpers/types.d.ts +0 -235
- package/dist/styles.css +18 -20
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +2 -2
- package/package.json +2 -2
- package/dist/InputTime/hooks/useInputTimeActions.d.ts +0 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Clearable } from "@jobber/hooks";
|
|
1
2
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
-
import type { FocusEvents, HTMLInputBaseProps, InputLengthConstraint, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
3
3
|
export type InputEmailLegacyProps = CommonFormFieldProps & Pick<FormFieldProps, "maxLength" | "readonly" | "validations" | "defaultValue">;
|
|
4
4
|
export declare const validationMessage = "Please enter a valid email";
|
|
5
5
|
export type InputEmailVersion = 1 | 2 | undefined;
|
|
@@ -7,19 +7,27 @@ export type InputEmailVersion = 1 | 2 | undefined;
|
|
|
7
7
|
* Experimental version 2 of the InputEmail component.
|
|
8
8
|
* Do not use unless you have talked with Atlantis first.
|
|
9
9
|
*/
|
|
10
|
-
export interface InputEmailRebuiltProps extends
|
|
10
|
+
export interface InputEmailRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "onBlur" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue"> {
|
|
11
|
+
readonly error?: string;
|
|
12
|
+
readonly invalid?: boolean;
|
|
13
|
+
readonly identifier?: string;
|
|
14
|
+
readonly autocomplete?: boolean | string;
|
|
15
|
+
readonly loading?: boolean;
|
|
16
|
+
readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
17
|
+
readonly children?: React.ReactNode;
|
|
18
|
+
readonly clearable?: Clearable;
|
|
11
19
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
readonly value?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Custom onChange handler that provides the new value as the first argument.
|
|
20
|
+
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
17
21
|
*/
|
|
22
|
+
readonly version: 2;
|
|
18
23
|
readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
-
/**
|
|
20
|
-
* A callback to handle "Enter" keypress. This will only run
|
|
21
|
-
* if Enter is the only key. Will not run if Shift or Control
|
|
22
|
-
* are being held.
|
|
23
|
-
*/
|
|
24
24
|
readonly onEnter?: FormFieldProps["onEnter"];
|
|
25
|
+
readonly onBlur?: FormFieldProps["onBlur"];
|
|
26
|
+
readonly value?: string;
|
|
27
|
+
readonly size?: FormFieldProps["size"];
|
|
28
|
+
readonly inline?: FormFieldProps["inline"];
|
|
29
|
+
readonly align?: FormFieldProps["align"];
|
|
30
|
+
readonly prefix?: FormFieldProps["prefix"];
|
|
31
|
+
readonly suffix?: FormFieldProps["suffix"];
|
|
32
|
+
readonly description?: FormFieldProps["description"];
|
|
25
33
|
}
|
|
@@ -8,5 +8,5 @@ export declare function useInputEmailActions({ onChange, inputRef, onEnter, onFo
|
|
|
8
8
|
handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
9
9
|
handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
10
10
|
handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
11
|
-
handleBlur: (event
|
|
11
|
+
handleBlur: (event?: FocusEvent) => void;
|
|
12
12
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from "react";
|
|
2
|
+
export interface UseInputEmailFormFieldProps {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly autofocus?: boolean;
|
|
7
|
+
readonly error?: string;
|
|
8
|
+
readonly inline?: boolean;
|
|
9
|
+
readonly description?: ReactNode;
|
|
10
|
+
readonly invalid?: boolean;
|
|
11
|
+
readonly value?: string;
|
|
12
|
+
readonly handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
13
|
+
readonly handleBlur: (event?: FocusEvent<HTMLInputElement>) => void;
|
|
14
|
+
readonly handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
|
+
readonly handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface UseInputEmailFormFieldReturn {
|
|
18
|
+
readonly fieldProps: {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly disabled?: boolean;
|
|
22
|
+
readonly autofocus?: boolean;
|
|
23
|
+
readonly onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
24
|
+
readonly onBlur: (event?: FocusEvent<HTMLInputElement>) => void;
|
|
25
|
+
readonly onFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
26
|
+
readonly onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
27
|
+
readonly value?: string;
|
|
28
|
+
readonly "aria-describedby"?: string;
|
|
29
|
+
};
|
|
30
|
+
readonly descriptionIdentifier: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function useInputEmailFormField({ id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error, ...rest }: UseInputEmailFormFieldProps): UseInputEmailFormFieldReturn;
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var FormField = require('../FormField-cjs.js');
|
|
5
5
|
require('classnames');
|
|
6
|
-
require('../tslib.es6-cjs.js');
|
|
6
|
+
var tslib_es6 = require('../tslib.es6-cjs.js');
|
|
7
7
|
require('react-hook-form');
|
|
8
8
|
require('@jobber/hooks');
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('@jobber/design');
|
|
11
11
|
require('../Button-cjs.js');
|
|
12
|
+
var omit = require('../omit-cjs.js');
|
|
12
13
|
require('../Icon-cjs.js');
|
|
13
14
|
require('../Text-cjs.js');
|
|
14
15
|
require('../Typography-cjs.js');
|
|
@@ -16,6 +17,17 @@ require('../useFormFieldFocus-cjs.js');
|
|
|
16
17
|
require('../InputValidation-cjs.js');
|
|
17
18
|
require('../Spinner-cjs.js');
|
|
18
19
|
require('react-router-dom');
|
|
20
|
+
require('../_commonjsHelpers-cjs.js');
|
|
21
|
+
require('../_baseGet-cjs.js');
|
|
22
|
+
require('../isTypedArray-cjs.js');
|
|
23
|
+
require('../isObjectLike-cjs.js');
|
|
24
|
+
require('../identity-cjs.js');
|
|
25
|
+
require('../_getTag-cjs.js');
|
|
26
|
+
require('../isSymbol-cjs.js');
|
|
27
|
+
require('../keysIn-cjs.js');
|
|
28
|
+
require('../_baseAssignValue-cjs.js');
|
|
29
|
+
require('../_baseFlatten-cjs.js');
|
|
30
|
+
require('../_setToString-cjs.js');
|
|
19
31
|
|
|
20
32
|
const validationMessage = "Please enter a valid email";
|
|
21
33
|
|
|
@@ -37,6 +49,7 @@ function InputEmail$1(props) {
|
|
|
37
49
|
function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
38
50
|
function handleClear() {
|
|
39
51
|
var _a;
|
|
52
|
+
handleBlur();
|
|
40
53
|
onChange === null || onChange === void 0 ? void 0 : onChange("");
|
|
41
54
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
42
55
|
}
|
|
@@ -70,10 +83,19 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
|
|
|
70
83
|
};
|
|
71
84
|
}
|
|
72
85
|
|
|
86
|
+
function useInputEmailFormField(_a) {
|
|
87
|
+
var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
|
|
88
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
89
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
|
|
90
|
+
name,
|
|
91
|
+
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
|
|
92
|
+
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
93
|
+
return { fieldProps, descriptionIdentifier };
|
|
94
|
+
}
|
|
95
|
+
|
|
73
96
|
const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, ref) {
|
|
74
97
|
var _a, _b, _c;
|
|
75
|
-
const
|
|
76
|
-
const id = props.id || generatedId;
|
|
98
|
+
const id = React.useId();
|
|
77
99
|
const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : React.useRef(null);
|
|
78
100
|
const wrapperRef = React.useRef(null);
|
|
79
101
|
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
@@ -100,11 +122,25 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
|
|
|
100
122
|
onEnter: props.onEnter,
|
|
101
123
|
inputRef,
|
|
102
124
|
});
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
const inputProps = omit.omit(props, [
|
|
126
|
+
"placeholder",
|
|
127
|
+
"onChange",
|
|
128
|
+
"onBlur",
|
|
129
|
+
"onFocus",
|
|
130
|
+
"onEnter",
|
|
131
|
+
"size",
|
|
132
|
+
"prefix",
|
|
133
|
+
"suffix",
|
|
134
|
+
"version",
|
|
135
|
+
]);
|
|
136
|
+
const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
137
|
+
name,
|
|
138
|
+
handleChange,
|
|
139
|
+
handleBlur,
|
|
140
|
+
handleFocus,
|
|
141
|
+
handleKeyDown }));
|
|
142
|
+
return (React.createElement(FormField.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 },
|
|
143
|
+
React.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
|
|
108
144
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
109
145
|
props.children));
|
|
110
146
|
});
|
|
@@ -1,12 +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 '../tslib.es6-es.js';
|
|
4
|
+
import { _ as __rest } from '../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 { o as omit } from '../omit-es.js';
|
|
10
11
|
import '../Icon-es.js';
|
|
11
12
|
import '../Text-es.js';
|
|
12
13
|
import '../Typography-es.js';
|
|
@@ -14,6 +15,17 @@ import '../useFormFieldFocus-es.js';
|
|
|
14
15
|
import '../InputValidation-es.js';
|
|
15
16
|
import '../Spinner-es.js';
|
|
16
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';
|
|
17
29
|
|
|
18
30
|
const validationMessage = "Please enter a valid email";
|
|
19
31
|
|
|
@@ -35,6 +47,7 @@ function InputEmail$1(props) {
|
|
|
35
47
|
function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
36
48
|
function handleClear() {
|
|
37
49
|
var _a;
|
|
50
|
+
handleBlur();
|
|
38
51
|
onChange === null || onChange === void 0 ? void 0 : onChange("");
|
|
39
52
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
40
53
|
}
|
|
@@ -68,10 +81,19 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
|
|
|
68
81
|
};
|
|
69
82
|
}
|
|
70
83
|
|
|
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
|
+
|
|
71
94
|
const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
|
|
72
95
|
var _a, _b, _c;
|
|
73
|
-
const
|
|
74
|
-
const id = props.id || generatedId;
|
|
96
|
+
const id = useId();
|
|
75
97
|
const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : useRef(null);
|
|
76
98
|
const wrapperRef = useRef(null);
|
|
77
99
|
const { inputStyle } = useFormFieldWrapperStyles({
|
|
@@ -98,11 +120,25 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
|
|
|
98
120
|
onEnter: props.onEnter,
|
|
99
121
|
inputRef,
|
|
100
122
|
});
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
123
|
+
const inputProps = omit(props, [
|
|
124
|
+
"placeholder",
|
|
125
|
+
"onChange",
|
|
126
|
+
"onBlur",
|
|
127
|
+
"onFocus",
|
|
128
|
+
"onEnter",
|
|
129
|
+
"size",
|
|
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" })),
|
|
106
142
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
107
143
|
props.children));
|
|
108
144
|
});
|
|
@@ -1,39 +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, InputConstraintProps, KeyboardEvents } from "../sharedHelpers/types";
|
|
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
|
-
* The ID of the input element.
|
|
19
|
-
*/
|
|
20
|
-
readonly id?: string;
|
|
13
|
+
readonly identifier?: string;
|
|
21
14
|
readonly inline?: boolean;
|
|
22
15
|
readonly invalid?: boolean;
|
|
23
16
|
readonly maxValue?: number;
|
|
24
17
|
readonly minValue?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Callback for value changes.
|
|
27
|
-
* @param newValue - The new numeric value
|
|
28
|
-
* @param event - Optional change event
|
|
29
|
-
*/
|
|
30
18
|
readonly onChange?: (newValue: number, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Whether the input is read-only.
|
|
33
|
-
*/
|
|
34
|
-
readonly readOnly?: boolean;
|
|
35
19
|
readonly showMiniLabel?: boolean;
|
|
36
|
-
readonly size?: FormFieldProps["size"];
|
|
37
20
|
readonly value?: number;
|
|
38
21
|
/**
|
|
39
22
|
* Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
|
|
@@ -2740,9 +2740,9 @@ const InputNumberRebuilt = React.forwardRef((props, ref) => {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
},
|
|
2742
2742
|
}));
|
|
2743
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
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"]);
|
|
2744
2744
|
const stringDescription = typeof description === "string";
|
|
2745
|
-
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 }),
|
|
2746
2746
|
React.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2747
2747
|
React.createElement("div", { className: styles.horizontalWrapper },
|
|
2748
2748
|
React.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
@@ -2773,7 +2773,7 @@ function InputNumberInternal(props, ref) {
|
|
|
2773
2773
|
}
|
|
2774
2774
|
},
|
|
2775
2775
|
}));
|
|
2776
|
-
return (React.createElement(FormField.FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
|
|
2776
|
+
return (React.createElement(FormField.FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
|
|
2777
2777
|
function customValidators(validators) {
|
|
2778
2778
|
if (validators == null) {
|
|
2779
2779
|
return getOverLimitMessage;
|
|
@@ -2738,9 +2738,9 @@ const InputNumberRebuilt = forwardRef((props, ref) => {
|
|
|
2738
2738
|
}
|
|
2739
2739
|
},
|
|
2740
2740
|
}));
|
|
2741
|
-
const { align, description, disabled, error, inline, invalid, placeholder,
|
|
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"]);
|
|
2742
2742
|
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,
|
|
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 }),
|
|
2744
2744
|
React__default.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
|
|
2745
2745
|
React__default.createElement("div", { className: styles.horizontalWrapper },
|
|
2746
2746
|
React__default.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
|
|
@@ -2771,7 +2771,7 @@ function InputNumberInternal(props, ref) {
|
|
|
2771
2771
|
}
|
|
2772
2772
|
},
|
|
2773
2773
|
}));
|
|
2774
|
-
return (React__default.createElement(FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
|
|
2774
|
+
return (React__default.createElement(FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
|
|
2775
2775
|
function customValidators(validators) {
|
|
2776
2776
|
if (validators == null) {
|
|
2777
2777
|
return getOverLimitMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Clearable } from "@jobber/hooks";
|
|
1
2
|
import type { InputMaskProps } from "./InputMask";
|
|
2
3
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
3
|
-
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, 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,21 +16,20 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
|
|
|
16
16
|
*/
|
|
17
17
|
readonly required?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export interface InputPhoneNumberRebuiltProps extends Omit<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
23
28
|
readonly value: string;
|
|
24
|
-
/**
|
|
25
|
-
* Custom onChange handler that provides the new value as the first argument.
|
|
26
|
-
*/
|
|
27
29
|
readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
-
|
|
29
|
-
* A callback to handle "Enter" keypress. This will only run
|
|
30
|
-
* if Enter is the only key. Will not run if Shift or Control
|
|
31
|
-
* are being held.
|
|
32
|
-
*/
|
|
30
|
+
readonly onBlur?: (event?: React.FocusEvent<HTMLInputElement>) => void;
|
|
33
31
|
readonly onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
32
|
+
readonly onFocus?: (event?: React.FocusEvent<HTMLInputElement>) => void;
|
|
34
33
|
/**
|
|
35
34
|
* A pattern to specify the format to display the phone number in.
|
|
36
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,5 +37,20 @@ export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "
|
|
|
38
37
|
* @default "(***) ***-****"
|
|
39
38
|
*/
|
|
40
39
|
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;
|
|
41
55
|
}
|
|
42
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,6 +115,7 @@ const DEFAULT_PATTERN = "(***) ***-****";
|
|
|
115
115
|
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
|
|
116
116
|
function handleClear() {
|
|
117
117
|
var _a;
|
|
118
|
+
handleBlur();
|
|
118
119
|
onChange && onChange("");
|
|
119
120
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
120
121
|
}
|
|
@@ -148,22 +149,26 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
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
|
+
|
|
151
166
|
const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
152
167
|
var _b, _c, _d, _e;
|
|
153
168
|
var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
|
|
154
169
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
|
|
155
170
|
const wrapperRef = React.useRef(null);
|
|
156
|
-
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
157
|
-
size: props.size,
|
|
158
|
-
align: props.align,
|
|
159
|
-
placeholder: props.placeholder,
|
|
160
|
-
value: props.value,
|
|
161
|
-
invalid: props.invalid,
|
|
162
|
-
error: props.error,
|
|
163
|
-
disabled: props.disabled,
|
|
164
|
-
inline: props.inline,
|
|
165
|
-
type: "tel",
|
|
166
|
-
});
|
|
171
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
|
|
167
172
|
const generatedId = React.useId();
|
|
168
173
|
const id = props.id || generatedId;
|
|
169
174
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
@@ -183,13 +188,25 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
|
|
|
183
188
|
onEnter: props.onEnter,
|
|
184
189
|
inputRef: inputPhoneNumberRef,
|
|
185
190
|
});
|
|
186
|
-
const descriptionIdentifier =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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, {
|
|
191
208
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
192
|
-
}), value: formattedValue
|
|
209
|
+
}), value: formattedValue })),
|
|
193
210
|
React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
194
211
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
195
212
|
});
|