@jobber/components 6.103.2-JOB-135467-8ed574a.0 → 6.103.2-JOB-140609-9051081.26
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 +12 -1
- package/dist/Autocomplete/index.cjs +1 -13
- package/dist/Autocomplete/index.mjs +1 -13
- package/dist/Button/Button.d.ts +6 -757
- package/dist/Button-cjs.js +9 -15
- package/dist/Button-es.js +10 -16
- package/dist/Checkbox/Checkbox.types.d.ts +2 -9
- package/dist/Checkbox/index.cjs +3 -2
- package/dist/Checkbox/index.mjs +3 -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/DataListSearch/index.cjs +1 -12
- package/dist/DataList/components/DataListSearch/index.mjs +1 -12
- package/dist/DataList/index.cjs +0 -8
- package/dist/DataList/index.mjs +0 -8
- 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 +217 -1
- package/dist/FormField-cjs.js +0 -1
- package/dist/FormField-es.js +1 -1
- package/dist/InputDate/index.cjs +8 -4
- package/dist/InputDate/index.mjs +8 -4
- package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
- package/dist/InputEmail/InputEmail.types.d.ts +16 -21
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
- package/dist/InputEmail/index.cjs +10 -45
- package/dist/InputEmail/index.mjs +10 -45
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +23 -2
- package/dist/InputNumber/index.cjs +5 -2
- package/dist/InputNumber/index.mjs +5 -2
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +15 -26
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
- package/dist/InputPhoneNumber/index.cjs +20 -35
- package/dist/InputPhoneNumber/index.mjs +20 -35
- package/dist/InputText/InputText.d.ts +2 -2
- package/dist/InputText/InputText.types.d.ts +27 -24
- package/dist/InputText/index.cjs +26 -55
- package/dist/InputText/index.mjs +27 -56
- package/dist/InputText/useInputTextActions.d.ts +1 -1
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +21 -1
- package/dist/InputTime/index.cjs +30 -25
- package/dist/InputTime/index.d.ts +1 -1
- package/dist/InputTime/index.mjs +32 -27
- 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 +14 -1
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/index.cjs +27 -41
- package/dist/Select/index.d.ts +7 -5
- package/dist/Select/index.mjs +29 -43
- 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/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
- 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 -352
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
|
@@ -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
|
+
// Don't call blur handler when programmatically clearing
|
|
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,28 +147,25 @@ 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
|
-
|
|
164
150
|
const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
165
151
|
var _b, _c, _d, _e;
|
|
166
152
|
var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
|
|
167
153
|
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
|
|
168
154
|
const wrapperRef = React__default.useRef(null);
|
|
169
|
-
const { inputStyle } = useFormFieldWrapperStyles(
|
|
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
|
+
});
|
|
170
167
|
const generatedId = useId();
|
|
171
|
-
const id = props.id || generatedId;
|
|
168
|
+
const id = props.identifier || props.id || generatedId;
|
|
172
169
|
const { name } = useAtlantisFormFieldName({
|
|
173
170
|
nameProp: props.name,
|
|
174
171
|
id: id,
|
|
@@ -186,25 +183,13 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
|
|
|
186
183
|
onEnter: props.onEnter,
|
|
187
184
|
inputRef: inputPhoneNumberRef,
|
|
188
185
|
});
|
|
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, {
|
|
186
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
187
|
+
const hasDescription = props.description && !props.inline;
|
|
188
|
+
const isInvalid = Boolean(props.ariaInvalid || props.error || props.invalid);
|
|
189
|
+
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 },
|
|
190
|
+
React__default.createElement("input", { id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
|
|
206
191
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
207
|
-
}), value: formattedValue })
|
|
192
|
+
}), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown }),
|
|
208
193
|
React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
209
194
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
210
195
|
});
|
|
@@ -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;
|
|
27
28
|
readonly autofocus?: boolean | undefined;
|
|
28
29
|
readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
|
|
29
30
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
30
31
|
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;
|
|
61
62
|
readonly autofocus?: boolean | undefined;
|
|
62
63
|
readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
|
|
63
64
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
64
65
|
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,6 +1,5 @@
|
|
|
1
|
-
import type { Clearable } from "@jobber/hooks";
|
|
2
1
|
import type { XOR } from "ts-xor";
|
|
3
|
-
import type {
|
|
2
|
+
import type { CommonFormFieldProps, FocusEvents, FormFieldProps, FormFieldTypes, HTMLInputBaseProps, KeyboardEvents, RebuiltInputCommonProps } from "../FormField";
|
|
4
3
|
export interface RowRange {
|
|
5
4
|
min: number;
|
|
6
5
|
max: number;
|
|
@@ -10,15 +9,7 @@ export type InputTextVersion = 1 | 2 | undefined;
|
|
|
10
9
|
* Experimental version 2 of the InputText component.
|
|
11
10
|
* Do not use unless you have talked with Atlantis first.
|
|
12
11
|
*/
|
|
13
|
-
export interface InputTextRebuiltProps extends
|
|
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;
|
|
12
|
+
export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps {
|
|
22
13
|
/**
|
|
23
14
|
* Use this when you're expecting a long answer.
|
|
24
15
|
*/
|
|
@@ -30,24 +21,36 @@ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
30
21
|
* maximum number of visible rows.
|
|
31
22
|
*/
|
|
32
23
|
readonly rows?: number | RowRange;
|
|
24
|
+
/**
|
|
25
|
+
* Determines what kind of form field should the component give you.
|
|
26
|
+
*/
|
|
33
27
|
readonly type?: FormFieldTypes;
|
|
34
28
|
/**
|
|
35
|
-
*
|
|
29
|
+
* Toolbar to render content below the input.
|
|
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.
|
|
36
42
|
*/
|
|
37
|
-
readonly version: 2;
|
|
38
43
|
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
|
+
*/
|
|
39
49
|
readonly onEnter?: FormFieldProps["onEnter"];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
readonly
|
|
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"];
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use `id` instead. This prop will be removed in a future version.
|
|
52
|
+
*/
|
|
53
|
+
readonly identifier?: string;
|
|
51
54
|
}
|
|
52
55
|
interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
|
|
53
56
|
multiline?: boolean;
|
package/dist/InputText/index.cjs
CHANGED
|
@@ -4,12 +4,11 @@ var React = require('react');
|
|
|
4
4
|
var jobberHooks = require('@jobber/hooks');
|
|
5
5
|
var FormField = require('../FormField-cjs.js');
|
|
6
6
|
require('classnames');
|
|
7
|
-
|
|
7
|
+
require('../tslib.es6-cjs.js');
|
|
8
8
|
require('react-hook-form');
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('@jobber/design');
|
|
11
11
|
require('../Button-cjs.js');
|
|
12
|
-
var omit = require('../omit-cjs.js');
|
|
13
12
|
require('../Icon-cjs.js');
|
|
14
13
|
require('../Text-cjs.js');
|
|
15
14
|
require('../Typography-cjs.js');
|
|
@@ -17,17 +16,6 @@ require('../useFormFieldFocus-cjs.js');
|
|
|
17
16
|
require('../InputValidation-cjs.js');
|
|
18
17
|
require('../Spinner-cjs.js');
|
|
19
18
|
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');
|
|
31
19
|
|
|
32
20
|
/**
|
|
33
21
|
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
@@ -162,7 +150,7 @@ function insertAtCursor(input, newText) {
|
|
|
162
150
|
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
163
151
|
function handleClear() {
|
|
164
152
|
var _a;
|
|
165
|
-
|
|
153
|
+
// Don't call blur handler when programmatically clearing
|
|
166
154
|
onChange && onChange("");
|
|
167
155
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
168
156
|
}
|
|
@@ -196,23 +184,10 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
|
|
|
196
184
|
};
|
|
197
185
|
}
|
|
198
186
|
|
|
199
|
-
/**
|
|
200
|
-
* Provides the props for the html fields rendered by the html input.
|
|
201
|
-
* 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.
|
|
202
|
-
*/
|
|
203
|
-
function useInputTextFormField(_a) {
|
|
204
|
-
var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
|
|
205
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
206
|
-
const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id, className: FormField.styles.input, name, disabled: rest.disabled, inputMode: rest.inputMode, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }), (description &&
|
|
207
|
-
!inline && { "aria-describedby": descriptionIdentifier })), { "aria-invalid": rest["aria-invalid"] || error || rest.invalid ? true : undefined, autoFocus: rest.autoFocus, invalid: error || rest.invalid ? "true" : undefined, onKeyDown: handleKeyDown });
|
|
208
|
-
return { fieldProps, descriptionIdentifier };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
187
|
const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRefs) {
|
|
212
188
|
var _a, _b, _c;
|
|
213
189
|
const inputTextRef = React.useRef(null);
|
|
214
190
|
const wrapperRef = React.useRef(null);
|
|
215
|
-
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
216
191
|
const id = useInputTextId(props);
|
|
217
192
|
const { rowRange } = useTextAreaResize({
|
|
218
193
|
rows: props.rows,
|
|
@@ -220,8 +195,19 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
220
195
|
inputRef: inputTextRef,
|
|
221
196
|
wrapperRef: wrapperRef,
|
|
222
197
|
});
|
|
223
|
-
const
|
|
224
|
-
|
|
198
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
199
|
+
size: props.size,
|
|
200
|
+
align: props.align,
|
|
201
|
+
placeholder: props.placeholder,
|
|
202
|
+
value: props.value,
|
|
203
|
+
invalid: props.invalid,
|
|
204
|
+
error: props.error,
|
|
205
|
+
max: typeof props.max === "string" ? parseFloat(props.max) : props.max,
|
|
206
|
+
maxLength: undefined, // v2: maxLength is for HTML validation only, not for width styling
|
|
207
|
+
type: props.multiline ? "textarea" : "text",
|
|
208
|
+
disabled: props.disabled,
|
|
209
|
+
inline: props.inline,
|
|
210
|
+
});
|
|
225
211
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
226
212
|
nameProp: props.name,
|
|
227
213
|
id: id,
|
|
@@ -234,40 +220,25 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
234
220
|
onEnter: props.onEnter,
|
|
235
221
|
inputRef: inputTextRef,
|
|
236
222
|
});
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
"onFocus",
|
|
241
|
-
"onEnter",
|
|
242
|
-
"size",
|
|
243
|
-
"placeholder",
|
|
244
|
-
"multiline",
|
|
245
|
-
"prefix",
|
|
246
|
-
"suffix",
|
|
247
|
-
"version",
|
|
248
|
-
]);
|
|
249
|
-
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
250
|
-
name,
|
|
251
|
-
handleChange,
|
|
252
|
-
handleBlur,
|
|
253
|
-
handleFocus,
|
|
254
|
-
handleKeyDown }));
|
|
223
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
224
|
+
const hasDescription = props.description && !props.inline;
|
|
225
|
+
const isInvalid = Boolean(props.ariaInvalid || props.error || props.invalid);
|
|
255
226
|
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: props.autoFocus, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
|
|
256
227
|
React.createElement(React.Fragment, null,
|
|
257
|
-
|
|
228
|
+
props.multiline ? (React.createElement(TextArea, { id: id, name: name, className: inputStyle, value: props.value, rows: rowRange.min, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, invalid: isInvalid ? "true" : undefined, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, ref: FormField.mergeRefs([inputRefs, inputTextRef]) })) : (React.createElement(TextInput, { id: id, name: name, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, max: props.max, min: props.min, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, invalid: isInvalid ? "true" : undefined, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, ref: FormField.mergeRefs([inputRefs, inputTextRef]) })),
|
|
258
229
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
259
230
|
props.children)));
|
|
260
231
|
});
|
|
261
232
|
function useInputTextId(props) {
|
|
262
233
|
const generatedId = React.useId();
|
|
263
|
-
return props.id || generatedId;
|
|
264
|
-
}
|
|
265
|
-
function TextArea({ fieldProps, rowRange, inputRefs, value, inputStyle, }) {
|
|
266
|
-
return (React.createElement("textarea", Object.assign({}, fieldProps, { rows: rowRange.min, ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
267
|
-
}
|
|
268
|
-
function TextInput({ fieldProps, inputRefs, value, inputStyle, }) {
|
|
269
|
-
return (React.createElement("input", Object.assign({}, fieldProps, { ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
234
|
+
return props.identifier || props.id || generatedId;
|
|
270
235
|
}
|
|
236
|
+
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
237
|
+
return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
238
|
+
});
|
|
239
|
+
const TextInput = React.forwardRef(function TextInput(props, ref) {
|
|
240
|
+
return React.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
241
|
+
});
|
|
271
242
|
|
|
272
243
|
function isNewInputTextProps(props) {
|
|
273
244
|
return props.version === 2;
|
package/dist/InputText/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React__default, { forwardRef, useRef, useImperativeHandle, useId } from 'react';
|
|
2
2
|
import { useSafeLayoutEffect } from '@jobber/hooks';
|
|
3
|
-
import { k as FormField,
|
|
3
|
+
import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, m as mergeRefs, l as FormFieldPostFix } from '../FormField-es.js';
|
|
4
4
|
import 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import '../tslib.es6-es.js';
|
|
6
6
|
import 'react-hook-form';
|
|
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';
|
|
11
10
|
import '../Icon-es.js';
|
|
12
11
|
import '../Text-es.js';
|
|
13
12
|
import '../Typography-es.js';
|
|
@@ -15,17 +14,6 @@ import '../useFormFieldFocus-es.js';
|
|
|
15
14
|
import '../InputValidation-es.js';
|
|
16
15
|
import '../Spinner-es.js';
|
|
17
16
|
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
17
|
|
|
30
18
|
/**
|
|
31
19
|
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
@@ -160,7 +148,7 @@ function insertAtCursor(input, newText) {
|
|
|
160
148
|
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
161
149
|
function handleClear() {
|
|
162
150
|
var _a;
|
|
163
|
-
|
|
151
|
+
// Don't call blur handler when programmatically clearing
|
|
164
152
|
onChange && onChange("");
|
|
165
153
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
166
154
|
}
|
|
@@ -194,23 +182,10 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
|
|
|
194
182
|
};
|
|
195
183
|
}
|
|
196
184
|
|
|
197
|
-
/**
|
|
198
|
-
* Provides the props for the html fields rendered by the html input.
|
|
199
|
-
* 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.
|
|
200
|
-
*/
|
|
201
|
-
function useInputTextFormField(_a) {
|
|
202
|
-
var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = __rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
|
|
203
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
204
|
-
const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id, className: styles.input, name, disabled: rest.disabled, inputMode: rest.inputMode, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }), (description &&
|
|
205
|
-
!inline && { "aria-describedby": descriptionIdentifier })), { "aria-invalid": rest["aria-invalid"] || error || rest.invalid ? true : undefined, autoFocus: rest.autoFocus, invalid: error || rest.invalid ? "true" : undefined, onKeyDown: handleKeyDown });
|
|
206
|
-
return { fieldProps, descriptionIdentifier };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
185
|
const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
210
186
|
var _a, _b, _c;
|
|
211
187
|
const inputTextRef = React__default.useRef(null);
|
|
212
188
|
const wrapperRef = React__default.useRef(null);
|
|
213
|
-
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
214
189
|
const id = useInputTextId(props);
|
|
215
190
|
const { rowRange } = useTextAreaResize({
|
|
216
191
|
rows: props.rows,
|
|
@@ -218,8 +193,19 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
|
218
193
|
inputRef: inputTextRef,
|
|
219
194
|
wrapperRef: wrapperRef,
|
|
220
195
|
});
|
|
221
|
-
const
|
|
222
|
-
|
|
196
|
+
const { inputStyle } = useFormFieldWrapperStyles({
|
|
197
|
+
size: props.size,
|
|
198
|
+
align: props.align,
|
|
199
|
+
placeholder: props.placeholder,
|
|
200
|
+
value: props.value,
|
|
201
|
+
invalid: props.invalid,
|
|
202
|
+
error: props.error,
|
|
203
|
+
max: typeof props.max === "string" ? parseFloat(props.max) : props.max,
|
|
204
|
+
maxLength: undefined, // v2: maxLength is for HTML validation only, not for width styling
|
|
205
|
+
type: props.multiline ? "textarea" : "text",
|
|
206
|
+
disabled: props.disabled,
|
|
207
|
+
inline: props.inline,
|
|
208
|
+
});
|
|
223
209
|
const { name } = useAtlantisFormFieldName({
|
|
224
210
|
nameProp: props.name,
|
|
225
211
|
id: id,
|
|
@@ -232,40 +218,25 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
|
232
218
|
onEnter: props.onEnter,
|
|
233
219
|
inputRef: inputTextRef,
|
|
234
220
|
});
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
"onFocus",
|
|
239
|
-
"onEnter",
|
|
240
|
-
"size",
|
|
241
|
-
"placeholder",
|
|
242
|
-
"multiline",
|
|
243
|
-
"prefix",
|
|
244
|
-
"suffix",
|
|
245
|
-
"version",
|
|
246
|
-
]);
|
|
247
|
-
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
248
|
-
name,
|
|
249
|
-
handleChange,
|
|
250
|
-
handleBlur,
|
|
251
|
-
handleFocus,
|
|
252
|
-
handleKeyDown }));
|
|
221
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
222
|
+
const hasDescription = props.description && !props.inline;
|
|
223
|
+
const isInvalid = Boolean(props.ariaInvalid || props.error || props.invalid);
|
|
253
224
|
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: props.autoFocus, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
|
|
254
225
|
React__default.createElement(React__default.Fragment, null,
|
|
255
|
-
|
|
226
|
+
props.multiline ? (React__default.createElement(TextArea, { id: id, name: name, className: inputStyle, value: props.value, rows: rowRange.min, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, invalid: isInvalid ? "true" : undefined, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, ref: mergeRefs([inputRefs, inputTextRef]) })) : (React__default.createElement(TextInput, { id: id, name: name, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, max: props.max, min: props.min, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, invalid: isInvalid ? "true" : undefined, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, ref: mergeRefs([inputRefs, inputTextRef]) })),
|
|
256
227
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
257
228
|
props.children)));
|
|
258
229
|
});
|
|
259
230
|
function useInputTextId(props) {
|
|
260
231
|
const generatedId = useId();
|
|
261
|
-
return props.id || generatedId;
|
|
262
|
-
}
|
|
263
|
-
function TextArea({ fieldProps, rowRange, inputRefs, value, inputStyle, }) {
|
|
264
|
-
return (React__default.createElement("textarea", Object.assign({}, fieldProps, { rows: rowRange.min, ref: mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
265
|
-
}
|
|
266
|
-
function TextInput({ fieldProps, inputRefs, value, inputStyle, }) {
|
|
267
|
-
return (React__default.createElement("input", Object.assign({}, fieldProps, { ref: mergeRefs(inputRefs), className: inputStyle, value: value })));
|
|
232
|
+
return props.identifier || props.id || generatedId;
|
|
268
233
|
}
|
|
234
|
+
const TextArea = forwardRef(function TextArea(props, ref) {
|
|
235
|
+
return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
236
|
+
});
|
|
237
|
+
const TextInput = forwardRef(function TextInput(props, ref) {
|
|
238
|
+
return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
239
|
+
});
|
|
269
240
|
|
|
270
241
|
function isNewInputTextProps(props) {
|
|
271
242
|
return props.version === 2;
|
|
@@ -12,5 +12,5 @@ export declare function useInputTextActions({ onChange, inputRef, onEnter, onFoc
|
|
|
12
12
|
handleChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
13
13
|
handleKeyDown: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
14
14
|
handleFocus: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
15
|
-
handleBlur: (event
|
|
15
|
+
handleBlur: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
16
16
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { InputTimeRebuiltProps } from "./InputTime.types";
|
|
3
|
-
export declare
|
|
3
|
+
export declare const InputTimeRebuilt: React.ForwardRefExoticComponent<InputTimeRebuiltProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
+
import type { AriaInputProps, FocusEvents, KeyboardEvents } from "../FormField/FormFieldTypes";
|
|
2
3
|
export interface InputTimeProps extends Pick<CommonFormFieldProps, "id" | "align" | "description" | "disabled" | "invalid" | "inline" | "loading" | "name" | "onValidation" | "placeholder" | "size" | "clearable">, Pick<FormFieldProps, "maxLength" | "readonly" | "autocomplete" | "max" | "min" | "onEnter" | "onFocus" | "onBlur" | "inputRef" | "validations"> {
|
|
3
4
|
/**
|
|
4
5
|
* Intial value of the input. Only use this when you need to prepopulate the
|
|
@@ -18,10 +19,29 @@ export interface InputTimeProps extends Pick<CommonFormFieldProps, "id" | "align
|
|
|
18
19
|
export interface InputTimeLegacyProps extends InputTimeProps {
|
|
19
20
|
version?: 1;
|
|
20
21
|
}
|
|
21
|
-
export interface InputTimeRebuiltProps extends Omit<InputTimeProps, "defaultValue" | "version" | "validations" | "onValidation"> {
|
|
22
|
+
export interface InputTimeRebuiltProps extends Omit<InputTimeProps, "defaultValue" | "version" | "validations" | "onValidation" | "readonly" | "autocomplete" | "inputRef" | "onFocus" | "onBlur" | "onEnter">, AriaInputProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement> {
|
|
22
23
|
/**
|
|
23
24
|
* Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
|
|
24
25
|
*/
|
|
25
26
|
version: 2;
|
|
27
|
+
/**
|
|
28
|
+
* Error message to display.
|
|
29
|
+
*/
|
|
26
30
|
error?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the input is read-only.
|
|
33
|
+
*/
|
|
34
|
+
readonly readOnly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* HTML autocomplete attribute for browser autofill.
|
|
37
|
+
*/
|
|
38
|
+
readonly autoComplete?: string;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `ref` instead. Note: `ref` support requires React 18+ forwardRef.
|
|
41
|
+
*/
|
|
42
|
+
readonly inputRef?: FormFieldProps["inputRef"];
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
45
|
+
*/
|
|
46
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
27
47
|
}
|
package/dist/InputTime/index.cjs
CHANGED
|
@@ -21,7 +21,7 @@ require('../useFormFieldFocus-cjs.js');
|
|
|
21
21
|
require('../InputValidation-cjs.js');
|
|
22
22
|
require('../Spinner-cjs.js');
|
|
23
23
|
require('react-router-dom');
|
|
24
|
-
require('../
|
|
24
|
+
require('../_getAllKeys-cjs.js');
|
|
25
25
|
require('../isTypedArray-cjs.js');
|
|
26
26
|
require('../identity-cjs.js');
|
|
27
27
|
require('../_getTag-cjs.js');
|
|
@@ -204,23 +204,32 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
function InputTimeRebuilt(_a) {
|
|
208
|
-
var _b
|
|
209
|
-
var { value, onChange
|
|
210
|
-
|
|
207
|
+
const InputTimeRebuilt = React.forwardRef(function InputTimeRebuilt(_a, forwardedRef) {
|
|
208
|
+
var _b;
|
|
209
|
+
var { value, onChange, readOnly, autoComplete,
|
|
210
|
+
// Deprecated props
|
|
211
|
+
inputRef: deprecatedInputRef } = _a, params = tslib_es6.__rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef"]);
|
|
212
|
+
const internalRef = React.useRef(null);
|
|
213
|
+
const mergedRef = FormField.mergeRefs([
|
|
214
|
+
internalRef,
|
|
215
|
+
deprecatedInputRef,
|
|
216
|
+
forwardedRef,
|
|
217
|
+
]);
|
|
218
|
+
const id = params.id || React.useId();
|
|
219
|
+
const wrapperRef = React.useRef(null);
|
|
220
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(params);
|
|
211
221
|
const { setTypedTime } = useTimePredict({
|
|
212
222
|
value,
|
|
213
223
|
handleChange,
|
|
214
224
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (params.disabled || params.readonly)
|
|
225
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: params.disabled, size: params.size, align: params.align, inline: params.inline, name: params.name, error: params.error || "", identifier: id, descriptionIdentifier: `descriptionUUID--${id}`, invalid: Boolean(params.invalid), description: params.description, clearable: (_b = params.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
226
|
+
React.createElement("input", { ref: mergedRef, type: "time", name: params.name, className: inputStyle, onBlur: handleBlur, id: id, disabled: params.disabled, readOnly: readOnly, autoComplete: autoComplete, onChange: handleChangeEvent, onFocus: handleFocus, onKeyDown: params.onKeyDown, onKeyUp: e => {
|
|
227
|
+
var _a;
|
|
228
|
+
(_a = params.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(params, e);
|
|
229
|
+
if (params.disabled || readOnly)
|
|
221
230
|
return;
|
|
222
231
|
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
223
|
-
}, value: dateToTimeString(value) })));
|
|
232
|
+
}, "data-testid": "ATL-InputTime-input", value: dateToTimeString(value), "aria-label": params.ariaLabel, "aria-describedby": params.ariaDescribedBy, "aria-invalid": params.ariaInvalid, "aria-required": params.ariaRequired })));
|
|
224
233
|
function handleChangeEvent(event) {
|
|
225
234
|
handleChange(event.target.value);
|
|
226
235
|
}
|
|
@@ -230,27 +239,23 @@ function InputTimeRebuilt(_a) {
|
|
|
230
239
|
function handleBlur(event) {
|
|
231
240
|
var _a;
|
|
232
241
|
(_a = params.onBlur) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
233
|
-
if (
|
|
234
|
-
if (!
|
|
235
|
-
|
|
242
|
+
if (internalRef.current) {
|
|
243
|
+
if (!internalRef.current.checkValidity()) {
|
|
244
|
+
internalRef.current.value = "";
|
|
236
245
|
}
|
|
237
246
|
}
|
|
238
247
|
}
|
|
239
248
|
function handleClear() {
|
|
240
249
|
var _a;
|
|
241
|
-
|
|
250
|
+
// Clear the value and refocus without triggering blur event
|
|
242
251
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
243
|
-
(_a =
|
|
252
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
244
253
|
}
|
|
245
254
|
function handleFocus(event) {
|
|
246
255
|
var _a;
|
|
247
256
|
(_a = params.onFocus) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
248
257
|
}
|
|
249
|
-
|
|
250
|
-
const generatedId = React.useId();
|
|
251
|
-
return props.id || generatedId;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
258
|
+
});
|
|
254
259
|
|
|
255
260
|
function InputTime$1(_a) {
|
|
256
261
|
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
@@ -282,13 +287,13 @@ function InputTime$1(_a) {
|
|
|
282
287
|
function isNewInputTimeProps(props) {
|
|
283
288
|
return props.version === 2;
|
|
284
289
|
}
|
|
285
|
-
|
|
290
|
+
const InputTime = React.forwardRef(function InputTimeShim(props, ref) {
|
|
286
291
|
if (isNewInputTimeProps(props)) {
|
|
287
|
-
return React.createElement(InputTimeRebuilt, Object.assign({}, props));
|
|
292
|
+
return React.createElement(InputTimeRebuilt, Object.assign({}, props, { ref: ref }));
|
|
288
293
|
}
|
|
289
294
|
else {
|
|
290
295
|
return React.createElement(InputTime$1, Object.assign({}, props));
|
|
291
296
|
}
|
|
292
|
-
}
|
|
297
|
+
});
|
|
293
298
|
|
|
294
299
|
exports.InputTime = InputTime;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { InputTimeLegacyProps, InputTimeRebuiltProps } from "./InputTime.types";
|
|
3
3
|
export type InputTimeShimProps = InputTimeLegacyProps | InputTimeRebuiltProps;
|
|
4
|
-
export declare
|
|
4
|
+
export declare const InputTime: React.ForwardRefExoticComponent<InputTimeShimProps & React.RefAttributes<HTMLInputElement>>;
|