@jobber/components 6.103.2-JOB-141426-1b49367.0 → 6.103.2-JOB-140609-8386817.45
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 +3 -24
- package/dist/Autocomplete/index.mjs +3 -24
- package/dist/Autocomplete/useAutocomplete.d.ts +0 -1
- package/dist/Checkbox/Checkbox.types.d.ts +2 -9
- package/dist/Checkbox/index.cjs +4 -2
- package/dist/Checkbox/index.mjs +4 -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 +0 -2
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +7 -2
- package/dist/FormField-cjs.js +0 -1
- package/dist/FormField-es.js +1 -1
- package/dist/InputDate/index.cjs +5 -9
- package/dist/InputDate/index.mjs +5 -9
- package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
- package/dist/InputEmail/InputEmail.types.d.ts +12 -20
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
- package/dist/InputEmail/index.cjs +8 -44
- package/dist/InputEmail/index.mjs +8 -44
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +20 -3
- package/dist/InputNumber/index.cjs +2 -2
- package/dist/InputNumber/index.mjs +2 -2
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +13 -27
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
- package/dist/InputPhoneNumber/index.cjs +17 -34
- package/dist/InputPhoneNumber/index.mjs +17 -34
- 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/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +21 -1
- package/dist/InputTime/hooks/useInputTimeActions.d.ts +16 -0
- package/dist/InputTime/index.cjs +63 -33
- package/dist/InputTime/index.d.ts +1 -1
- package/dist/InputTime/index.mjs +66 -36
- 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 +28 -41
- package/dist/Select/index.d.ts +7 -5
- package/dist/Select/index.mjs +30 -43
- package/dist/Tabs-es.js +1 -1
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +1 -1
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
- package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
- package/dist/debounce-es.js +1 -1
- package/dist/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 +235 -0
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +2 -2
- package/package.json +2 -2
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
- package/dist/InputText/useInputTextFormField.d.ts +0 -352
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Clearable } from "@jobber/hooks";
|
|
2
1
|
import type { XOR } from "ts-xor";
|
|
3
|
-
import type {
|
|
2
|
+
import type { CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
|
|
3
|
+
import type { FocusEvents, HTMLInputBaseProps, InputLengthConstraint, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
4
4
|
export interface RowRange {
|
|
5
5
|
min: number;
|
|
6
6
|
max: number;
|
|
@@ -10,15 +10,7 @@ export type InputTextVersion = 1 | 2 | undefined;
|
|
|
10
10
|
* Experimental version 2 of the InputText component.
|
|
11
11
|
* Do not use unless you have talked with Atlantis first.
|
|
12
12
|
*/
|
|
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;
|
|
13
|
+
export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps, InputLengthConstraint {
|
|
22
14
|
/**
|
|
23
15
|
* Use this when you're expecting a long answer.
|
|
24
16
|
*/
|
|
@@ -30,24 +22,32 @@ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
30
22
|
* maximum number of visible rows.
|
|
31
23
|
*/
|
|
32
24
|
readonly rows?: number | RowRange;
|
|
25
|
+
/**
|
|
26
|
+
* Determines what kind of form field should the component give you.
|
|
27
|
+
*/
|
|
33
28
|
readonly type?: FormFieldTypes;
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
30
|
+
* Toolbar to render content below the input.
|
|
31
|
+
*/
|
|
32
|
+
readonly toolbar?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Determines the visibility of the toolbar.
|
|
35
|
+
*/
|
|
36
|
+
readonly toolbarVisibility?: "always" | "while-editing";
|
|
37
|
+
/**
|
|
38
|
+
* The current value of the input.
|
|
39
|
+
*/
|
|
40
|
+
readonly value: string;
|
|
41
|
+
/**
|
|
42
|
+
* Custom onChange handler that provides the new value as the first argument.
|
|
36
43
|
*/
|
|
37
|
-
readonly version: 2;
|
|
38
44
|
readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* A callback to handle "Enter" keypress. This will only run
|
|
47
|
+
* if Enter is the only key. Will not run if Shift or Control
|
|
48
|
+
* are being held.
|
|
49
|
+
*/
|
|
39
50
|
readonly onEnter?: FormFieldProps["onEnter"];
|
|
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"];
|
|
51
51
|
}
|
|
52
52
|
interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
|
|
53
53
|
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,6 @@ function insertAtCursor(input, newText) {
|
|
|
162
150
|
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
163
151
|
function handleClear() {
|
|
164
152
|
var _a;
|
|
165
|
-
handleBlur();
|
|
166
153
|
onChange && onChange("");
|
|
167
154
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
168
155
|
}
|
|
@@ -196,23 +183,10 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
|
|
|
196
183
|
};
|
|
197
184
|
}
|
|
198
185
|
|
|
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
186
|
const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRefs) {
|
|
212
187
|
var _a, _b, _c;
|
|
213
188
|
const inputTextRef = React.useRef(null);
|
|
214
189
|
const wrapperRef = React.useRef(null);
|
|
215
|
-
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
216
190
|
const id = useInputTextId(props);
|
|
217
191
|
const { rowRange } = useTextAreaResize({
|
|
218
192
|
rows: props.rows,
|
|
@@ -220,8 +194,18 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
220
194
|
inputRef: inputTextRef,
|
|
221
195
|
wrapperRef: wrapperRef,
|
|
222
196
|
});
|
|
223
|
-
const
|
|
224
|
-
|
|
197
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles({
|
|
198
|
+
size: props.size,
|
|
199
|
+
align: props.align,
|
|
200
|
+
placeholder: props.placeholder,
|
|
201
|
+
value: props.value,
|
|
202
|
+
invalid: props.invalid,
|
|
203
|
+
error: props.error,
|
|
204
|
+
maxLength: props.maxLength,
|
|
205
|
+
type: props.multiline ? "textarea" : "text",
|
|
206
|
+
disabled: props.disabled,
|
|
207
|
+
inline: props.inline,
|
|
208
|
+
});
|
|
225
209
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
226
210
|
nameProp: props.name,
|
|
227
211
|
id: id,
|
|
@@ -234,27 +218,43 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
234
218
|
onEnter: props.onEnter,
|
|
235
219
|
inputRef: inputTextRef,
|
|
236
220
|
});
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
"placeholder",
|
|
244
|
-
"multiline",
|
|
245
|
-
"prefix",
|
|
246
|
-
"suffix",
|
|
247
|
-
"version",
|
|
248
|
-
]);
|
|
249
|
-
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
221
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
222
|
+
const hasDescription = props.description && !props.inline;
|
|
223
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
224
|
+
// Shared props for both TextArea and TextInput
|
|
225
|
+
const commonInputProps = {
|
|
226
|
+
id,
|
|
250
227
|
name,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
228
|
+
className: inputStyle,
|
|
229
|
+
value: props.value,
|
|
230
|
+
disabled: props.disabled,
|
|
231
|
+
readOnly: props.readOnly,
|
|
232
|
+
autoFocus: props.autoFocus,
|
|
233
|
+
autoComplete: props.autoComplete,
|
|
234
|
+
inputMode: props.inputMode,
|
|
235
|
+
tabIndex: props.tabIndex,
|
|
236
|
+
maxLength: props.maxLength,
|
|
237
|
+
role: props.role,
|
|
238
|
+
"aria-label": props.ariaLabel,
|
|
239
|
+
"aria-describedby": hasDescription
|
|
240
|
+
? descriptionIdentifier
|
|
241
|
+
: props.ariaDescribedBy,
|
|
242
|
+
"aria-invalid": isInvalid ? true : undefined,
|
|
243
|
+
"aria-controls": props.ariaControls,
|
|
244
|
+
"aria-expanded": props.ariaExpanded,
|
|
245
|
+
"aria-activedescendant": props.ariaActiveDescendant,
|
|
246
|
+
"aria-autocomplete": props.ariaAutocomplete,
|
|
247
|
+
"aria-required": props.ariaRequired,
|
|
248
|
+
onChange: handleChange,
|
|
249
|
+
onBlur: handleBlur,
|
|
250
|
+
onFocus: handleFocus,
|
|
251
|
+
onKeyDown: handleKeyDown,
|
|
252
|
+
onKeyUp: props.onKeyUp,
|
|
253
|
+
ref: FormField.mergeRefs([inputRefs, inputTextRef]),
|
|
254
|
+
};
|
|
255
|
+
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", maxLength: props.maxLength, 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
256
|
React.createElement(React.Fragment, null,
|
|
257
|
-
|
|
257
|
+
props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
258
258
|
React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
259
259
|
props.children)));
|
|
260
260
|
});
|
|
@@ -262,12 +262,12 @@ function useInputTextId(props) {
|
|
|
262
262
|
const generatedId = React.useId();
|
|
263
263
|
return props.id || generatedId;
|
|
264
264
|
}
|
|
265
|
-
|
|
266
|
-
return
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return
|
|
270
|
-
}
|
|
265
|
+
const TextArea = React.forwardRef(function TextArea(props, ref) {
|
|
266
|
+
return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
267
|
+
});
|
|
268
|
+
const TextInput = React.forwardRef(function TextInput(props, ref) {
|
|
269
|
+
return React.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
270
|
+
});
|
|
271
271
|
|
|
272
272
|
function isNewInputTextProps(props) {
|
|
273
273
|
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, m as mergeRefs, f as FormFieldWrapper, 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,6 @@ function insertAtCursor(input, newText) {
|
|
|
160
148
|
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
161
149
|
function handleClear() {
|
|
162
150
|
var _a;
|
|
163
|
-
handleBlur();
|
|
164
151
|
onChange && onChange("");
|
|
165
152
|
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
166
153
|
}
|
|
@@ -194,23 +181,10 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
|
|
|
194
181
|
};
|
|
195
182
|
}
|
|
196
183
|
|
|
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
184
|
const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
210
185
|
var _a, _b, _c;
|
|
211
186
|
const inputTextRef = React__default.useRef(null);
|
|
212
187
|
const wrapperRef = React__default.useRef(null);
|
|
213
|
-
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
214
188
|
const id = useInputTextId(props);
|
|
215
189
|
const { rowRange } = useTextAreaResize({
|
|
216
190
|
rows: props.rows,
|
|
@@ -218,8 +192,18 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
|
218
192
|
inputRef: inputTextRef,
|
|
219
193
|
wrapperRef: wrapperRef,
|
|
220
194
|
});
|
|
221
|
-
const
|
|
222
|
-
|
|
195
|
+
const { inputStyle } = useFormFieldWrapperStyles({
|
|
196
|
+
size: props.size,
|
|
197
|
+
align: props.align,
|
|
198
|
+
placeholder: props.placeholder,
|
|
199
|
+
value: props.value,
|
|
200
|
+
invalid: props.invalid,
|
|
201
|
+
error: props.error,
|
|
202
|
+
maxLength: props.maxLength,
|
|
203
|
+
type: props.multiline ? "textarea" : "text",
|
|
204
|
+
disabled: props.disabled,
|
|
205
|
+
inline: props.inline,
|
|
206
|
+
});
|
|
223
207
|
const { name } = useAtlantisFormFieldName({
|
|
224
208
|
nameProp: props.name,
|
|
225
209
|
id: id,
|
|
@@ -232,27 +216,43 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
|
232
216
|
onEnter: props.onEnter,
|
|
233
217
|
inputRef: inputTextRef,
|
|
234
218
|
});
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"placeholder",
|
|
242
|
-
"multiline",
|
|
243
|
-
"prefix",
|
|
244
|
-
"suffix",
|
|
245
|
-
"version",
|
|
246
|
-
]);
|
|
247
|
-
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
219
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
220
|
+
const hasDescription = props.description && !props.inline;
|
|
221
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
222
|
+
// Shared props for both TextArea and TextInput
|
|
223
|
+
const commonInputProps = {
|
|
224
|
+
id,
|
|
248
225
|
name,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
226
|
+
className: inputStyle,
|
|
227
|
+
value: props.value,
|
|
228
|
+
disabled: props.disabled,
|
|
229
|
+
readOnly: props.readOnly,
|
|
230
|
+
autoFocus: props.autoFocus,
|
|
231
|
+
autoComplete: props.autoComplete,
|
|
232
|
+
inputMode: props.inputMode,
|
|
233
|
+
tabIndex: props.tabIndex,
|
|
234
|
+
maxLength: props.maxLength,
|
|
235
|
+
role: props.role,
|
|
236
|
+
"aria-label": props.ariaLabel,
|
|
237
|
+
"aria-describedby": hasDescription
|
|
238
|
+
? descriptionIdentifier
|
|
239
|
+
: props.ariaDescribedBy,
|
|
240
|
+
"aria-invalid": isInvalid ? true : undefined,
|
|
241
|
+
"aria-controls": props.ariaControls,
|
|
242
|
+
"aria-expanded": props.ariaExpanded,
|
|
243
|
+
"aria-activedescendant": props.ariaActiveDescendant,
|
|
244
|
+
"aria-autocomplete": props.ariaAutocomplete,
|
|
245
|
+
"aria-required": props.ariaRequired,
|
|
246
|
+
onChange: handleChange,
|
|
247
|
+
onBlur: handleBlur,
|
|
248
|
+
onFocus: handleFocus,
|
|
249
|
+
onKeyDown: handleKeyDown,
|
|
250
|
+
onKeyUp: props.onKeyUp,
|
|
251
|
+
ref: mergeRefs([inputRefs, inputTextRef]),
|
|
252
|
+
};
|
|
253
|
+
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", maxLength: props.maxLength, 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
254
|
React__default.createElement(React__default.Fragment, null,
|
|
255
|
-
|
|
255
|
+
props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
256
256
|
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
|
|
257
257
|
props.children)));
|
|
258
258
|
});
|
|
@@ -260,12 +260,12 @@ function useInputTextId(props) {
|
|
|
260
260
|
const generatedId = useId();
|
|
261
261
|
return props.id || generatedId;
|
|
262
262
|
}
|
|
263
|
-
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return
|
|
268
|
-
}
|
|
263
|
+
const TextArea = forwardRef(function TextArea(props, ref) {
|
|
264
|
+
return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
265
|
+
});
|
|
266
|
+
const TextInput = forwardRef(function TextInput(props, ref) {
|
|
267
|
+
return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
268
|
+
});
|
|
269
269
|
|
|
270
270
|
function isNewInputTextProps(props) {
|
|
271
271
|
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, InputConstraintProps, InputLengthConstraint, KeyboardEvents } from "../sharedHelpers/types";
|
|
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" | "max" | "min" | "maxLength">, AriaInputProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, InputLengthConstraint, InputConstraintProps {
|
|
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
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
|
|
2
|
+
import type { InputTimeRebuiltProps } from "../InputTime.types";
|
|
3
|
+
export interface UseInputTimeActionsProps extends Pick<InputTimeRebuiltProps, "onChange" | "onFocus" | "onBlur" | "onKeyDown"> {
|
|
4
|
+
readonly value?: Date;
|
|
5
|
+
readonly readOnly?: boolean;
|
|
6
|
+
readonly disabled?: boolean;
|
|
7
|
+
readonly inputRef?: React.RefObject<HTMLInputElement>;
|
|
8
|
+
}
|
|
9
|
+
export declare function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, }: UseInputTimeActionsProps): {
|
|
10
|
+
handleChangeEvent: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
11
|
+
handleChange: (newValue: string) => void;
|
|
12
|
+
handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
13
|
+
handleClear: () => void;
|
|
14
|
+
handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
|
+
handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
16
|
+
};
|
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,7 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
function
|
|
208
|
-
var _b, _c;
|
|
209
|
-
var { value, onChange } = _a, params = tslib_es6.__rest(_a, ["value", "onChange"]);
|
|
210
|
-
const ref = (_b = params.inputRef) !== null && _b !== void 0 ? _b : React.useRef(null);
|
|
211
|
-
const { setTypedTime } = useTimePredict({
|
|
212
|
-
value,
|
|
213
|
-
handleChange,
|
|
214
|
-
});
|
|
215
|
-
const { inputStyle } = FormField.useFormFieldWrapperStyles(params);
|
|
216
|
-
const wrapperRef = React.useRef(null);
|
|
217
|
-
const id = getId(params);
|
|
218
|
-
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: (_c = params.clearable) !== null && _c !== void 0 ? _c : "never", onClear: handleClear, type: "time", readonly: params.readonly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
219
|
-
React.createElement("input", { ref: ref, type: "time", name: params.name, className: inputStyle, onBlur: handleBlur, id: id, disabled: params.disabled, readOnly: params.readonly, onChange: handleChangeEvent, onFocus: handleFocus, "data-testid": "ATL-InputTime-input", onKeyUp: e => {
|
|
220
|
-
if (params.disabled || params.readonly)
|
|
221
|
-
return;
|
|
222
|
-
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
223
|
-
}, value: dateToTimeString(value) })));
|
|
207
|
+
function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, }) {
|
|
224
208
|
function handleChangeEvent(event) {
|
|
225
209
|
handleChange(event.target.value);
|
|
226
210
|
}
|
|
@@ -228,30 +212,76 @@ function InputTimeRebuilt(_a) {
|
|
|
228
212
|
onChange === null || onChange === void 0 ? void 0 : onChange(timeStringToDate(newValue, value));
|
|
229
213
|
}
|
|
230
214
|
function handleBlur(event) {
|
|
231
|
-
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
ref.current.value = "";
|
|
215
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
216
|
+
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
217
|
+
if (!inputRef.current.checkValidity()) {
|
|
218
|
+
inputRef.current.value = "";
|
|
236
219
|
}
|
|
237
220
|
}
|
|
238
221
|
}
|
|
239
222
|
function handleClear() {
|
|
240
223
|
var _a;
|
|
241
|
-
|
|
224
|
+
// Clear the value and refocus without triggering blur event
|
|
242
225
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
243
|
-
(_a =
|
|
226
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
244
227
|
}
|
|
245
228
|
function handleFocus(event) {
|
|
246
|
-
|
|
247
|
-
(_a = params.onFocus) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
229
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
248
230
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
return props.id || generatedId;
|
|
231
|
+
function handleKeyDown(event) {
|
|
232
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
252
233
|
}
|
|
234
|
+
return {
|
|
235
|
+
handleChangeEvent,
|
|
236
|
+
handleChange,
|
|
237
|
+
handleBlur,
|
|
238
|
+
handleClear,
|
|
239
|
+
handleFocus,
|
|
240
|
+
handleKeyDown,
|
|
241
|
+
};
|
|
253
242
|
}
|
|
254
243
|
|
|
244
|
+
const InputTimeRebuilt = React.forwardRef(function InputTimeRebuilt(_a, forwardedRef) {
|
|
245
|
+
var _b;
|
|
246
|
+
var { value, onChange, readOnly, autoComplete,
|
|
247
|
+
// Deprecated props
|
|
248
|
+
inputRef: deprecatedInputRef } = _a, params = tslib_es6.__rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef"]);
|
|
249
|
+
const internalRef = React.useRef(null);
|
|
250
|
+
const mergedRef = FormField.mergeRefs([
|
|
251
|
+
internalRef,
|
|
252
|
+
deprecatedInputRef,
|
|
253
|
+
forwardedRef,
|
|
254
|
+
]);
|
|
255
|
+
const id = params.id || React.useId();
|
|
256
|
+
const wrapperRef = React.useRef(null);
|
|
257
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(params);
|
|
258
|
+
const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, } = useInputTimeActions({
|
|
259
|
+
onChange,
|
|
260
|
+
value,
|
|
261
|
+
readOnly,
|
|
262
|
+
disabled: params.disabled,
|
|
263
|
+
inputRef: internalRef,
|
|
264
|
+
onFocus: params.onFocus,
|
|
265
|
+
onBlur: params.onBlur,
|
|
266
|
+
onKeyDown: params.onKeyDown,
|
|
267
|
+
});
|
|
268
|
+
const { setTypedTime } = useTimePredict({
|
|
269
|
+
value,
|
|
270
|
+
handleChange,
|
|
271
|
+
});
|
|
272
|
+
// Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
|
|
273
|
+
function handleKeyUp(event) {
|
|
274
|
+
var _a;
|
|
275
|
+
(_a = params.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
276
|
+
if (params.disabled || readOnly)
|
|
277
|
+
return;
|
|
278
|
+
!isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
|
|
279
|
+
}
|
|
280
|
+
const isInvalid = Boolean(params.error || params.invalid);
|
|
281
|
+
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, maxLength: params.maxLength, clearable: (_b = params.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
282
|
+
React.createElement("input", { ref: mergedRef, type: "time", name: params.name, className: inputStyle, id: id, disabled: params.disabled, readOnly: readOnly, autoComplete: autoComplete, maxLength: params.maxLength, max: params.max, min: params.min, value: dateToTimeString(value), onChange: handleChangeEvent, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, "data-testid": "ATL-InputTime-input", "aria-label": params.ariaLabel, "aria-describedby": params.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-required": params.ariaRequired })));
|
|
283
|
+
});
|
|
284
|
+
|
|
255
285
|
function InputTime$1(_a) {
|
|
256
286
|
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
257
287
|
const ref = React.useRef(null);
|
|
@@ -282,13 +312,13 @@ function InputTime$1(_a) {
|
|
|
282
312
|
function isNewInputTimeProps(props) {
|
|
283
313
|
return props.version === 2;
|
|
284
314
|
}
|
|
285
|
-
|
|
315
|
+
const InputTime = React.forwardRef(function InputTimeShim(props, ref) {
|
|
286
316
|
if (isNewInputTimeProps(props)) {
|
|
287
|
-
return React.createElement(InputTimeRebuilt, Object.assign({}, props));
|
|
317
|
+
return React.createElement(InputTimeRebuilt, Object.assign({}, props, { ref: ref }));
|
|
288
318
|
}
|
|
289
319
|
else {
|
|
290
320
|
return React.createElement(InputTime$1, Object.assign({}, props));
|
|
291
321
|
}
|
|
292
|
-
}
|
|
322
|
+
});
|
|
293
323
|
|
|
294
324
|
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>>;
|