@jobber/components 6.101.4 → 6.101.5-JOB-140604-4487daa.55
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 +11 -51
- package/dist/Autocomplete/components/MenuList.d.ts +3 -2
- package/dist/Autocomplete/components/PersistentRegion.d.ts +3 -2
- package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +3 -2
- package/dist/Autocomplete/index.cjs +95 -51
- package/dist/Autocomplete/index.mjs +97 -53
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +14 -1
- package/dist/Autocomplete/useAutocomplete.d.ts +4 -3
- package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
- package/dist/Card-cjs.js +1 -1
- package/dist/Card-es.js +1 -1
- package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
- package/dist/Checkbox/Checkbox.types.d.ts +24 -18
- package/dist/Checkbox/index.cjs +9 -2
- package/dist/Checkbox/index.mjs +9 -2
- package/dist/Chip/Chip.d.ts +1 -2
- package/dist/Chip/hooks/useChildComponent.d.ts +4 -3
- package/dist/Chip/index.cjs +1 -1
- package/dist/Chip-cjs.js +5 -4
- package/dist/Chip-es.js +5 -4
- package/dist/ChipDismissible-cjs.js +4 -4
- package/dist/ChipDismissible-es.js +5 -5
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/useInView.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useScrollToActive.d.ts +1 -1
- 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/Combobox/Combobox.d.ts +2 -1
- package/dist/Combobox/Combobox.types.d.ts +2 -2
- package/dist/Combobox/ComboboxProvider.d.ts +3 -3
- package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +1 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +2 -1
- package/dist/Combobox/hooks/useCombobox.d.ts +1 -1
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -2
- package/dist/Combobox/hooks/useComboboxContent.d.ts +2 -1
- package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +1 -1
- package/dist/ComboboxActivator-cjs.js +2 -2
- package/dist/ComboboxActivator-es.js +3 -3
- package/dist/ComboboxTrigger-cjs.js +1 -1
- package/dist/ComboboxTrigger-es.js +2 -2
- package/dist/DataList/DataList.types.d.ts +2 -2
- package/dist/DataList/DataList.utils.d.ts +2 -2
- package/dist/DataList/components/DataListHeader/index.cjs +1 -0
- package/dist/DataList/components/DataListHeader/index.mjs +1 -0
- package/dist/DataList/components/DataListHeaderTile/components/DataListSortingOptions.d.ts +2 -2
- package/dist/DataList/components/DataListItem/DataListItemInternal.d.ts +2 -2
- package/dist/DataList/components/DataListItem/index.cjs +1 -0
- package/dist/DataList/components/DataListItem/index.mjs +1 -0
- package/dist/DataList/components/DataListItems/index.cjs +1 -0
- package/dist/DataList/components/DataListItems/index.mjs +1 -0
- package/dist/DataList/components/DataListLayout/index.cjs +1 -0
- package/dist/DataList/components/DataListLayout/index.mjs +1 -0
- package/dist/DataList/components/DataListSearch/index.cjs +2 -12
- package/dist/DataList/components/DataListSearch/index.mjs +2 -12
- package/dist/DataList/hooks/useGetItemActions.d.ts +1 -1
- package/dist/DataList/index.cjs +1 -8
- package/dist/DataList/index.mjs +1 -8
- package/dist/DataListActions-cjs.js +4 -2
- package/dist/DataListActions-es.js +4 -2
- package/dist/DataListItem-cjs.js +8 -7
- package/dist/DataListItem-es.js +9 -8
- package/dist/DataListSort-cjs.js +1 -1
- package/dist/DataListSort-es.js +2 -2
- package/dist/DataTable/SortIcon.d.ts +2 -1
- package/dist/DataTable/components/DataTableSortableHeader.d.ts +1 -1
- package/dist/DataTable/index.cjs +3 -2
- package/dist/DataTable/index.mjs +3 -2
- package/dist/DatePicker/DatePicker.d.ts +5 -1
- package/dist/DatePicker/index.cjs +2 -2
- package/dist/DatePicker/index.mjs +2 -2
- package/dist/DatePicker/useFocusOnSelectedDate.d.ts +1 -2
- package/dist/DatePicker-cjs.js +4 -2
- package/dist/DatePicker-es.js +5 -3
- package/dist/FormField/FormFieldAffix.d.ts +2 -2
- package/dist/FormField/FormFieldTypes.d.ts +3 -5
- package/dist/FormField/FormFieldWrapper.d.ts +5 -1
- package/dist/FormField/hooks/useFormFieldFocus.d.ts +1 -1
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +9 -4
- package/dist/FormField-cjs.js +35 -31
- package/dist/FormField-es.js +35 -31
- package/dist/InputDate/InputDate.types.d.ts +12 -7
- package/dist/InputDate/index.cjs +35 -12
- package/dist/InputDate/index.mjs +35 -12
- package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
- package/dist/InputEmail/InputEmail.types.d.ts +10 -20
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
- package/dist/InputEmail/index.cjs +43 -60
- package/dist/InputEmail/index.mjs +44 -61
- package/dist/InputFile-cjs.js +5 -2
- package/dist/InputFile-es.js +5 -2
- package/dist/InputGroup-cjs.js +5 -2
- package/dist/InputGroup-es.js +5 -2
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
- package/dist/InputNumber/index.cjs +7 -5
- package/dist/InputNumber/index.mjs +7 -5
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
- package/dist/InputPhoneNumber/index.cjs +37 -36
- package/dist/InputPhoneNumber/index.mjs +38 -37
- package/dist/InputText/InputText.d.ts +2 -2
- package/dist/InputText/InputText.types.d.ts +30 -25
- package/dist/InputText/index.cjs +54 -62
- package/dist/InputText/index.mjs +55 -63
- package/dist/InputText/useInputTextActions.d.ts +11 -5
- package/dist/InputText/useTextAreaResize.d.ts +2 -2
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +13 -4
- package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
- package/dist/InputTime/index.cjs +90 -30
- package/dist/InputTime/index.mjs +93 -33
- package/dist/InternalChipDismissible-cjs.js +3 -3
- package/dist/InternalChipDismissible-es.js +4 -4
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/Menu/Menu.d.ts +2 -4
- package/dist/Menu/Menu.types.d.ts +21 -5
- package/dist/Menu-cjs.js +9 -9
- package/dist/Menu-es.js +9 -9
- package/dist/Modal/Modal.types.d.ts +3 -3
- package/dist/Modal/ModalContext.rebuilt.d.ts +2 -2
- package/dist/MultiSelect/DropDownMenu.d.ts +1 -1
- package/dist/MultiSelect/index.cjs +1 -0
- package/dist/MultiSelect/index.mjs +1 -0
- package/dist/MultiSelect-cjs.js +13 -7
- package/dist/MultiSelect-es.js +13 -7
- package/dist/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/RadioGroup/RadioOption.d.ts +1 -1
- package/dist/RecurringSelect/index.cjs +3 -2
- package/dist/RecurringSelect/index.mjs +3 -2
- package/dist/Select/Select.types.d.ts +7 -3
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/index.cjs +27 -42
- package/dist/Select/index.mjs +29 -44
- package/dist/StatusLabel/StatusLabel.d.ts +2 -1
- package/dist/Tabs/hooks/useTabsOverflow.d.ts +2 -2
- package/dist/Tabs-cjs.js +4 -2
- package/dist/Tabs-es.js +5 -3
- package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +1 -1
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
- package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
- package/dist/debounce-es.js +1 -1
- package/dist/filterDataAttributes-cjs.js +26 -0
- package/dist/filterDataAttributes-es.js +24 -0
- package/dist/floating-ui.react-cjs.js +115 -0
- package/dist/floating-ui.react-es.js +115 -1
- package/dist/helpers-cjs.js +1 -1
- package/dist/helpers-es.js +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.mjs +3 -2
- package/dist/omit-cjs.js +14 -14
- package/dist/omit-es.js +1 -1
- package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
- package/dist/sharedHelpers/types.d.ts +231 -0
- package/dist/showToast-cjs.js +2 -2
- package/dist/showToast-es.js +2 -2
- package/dist/styles.css +32 -23
- package/dist/useChildComponent-cjs.js +1 -1
- package/dist/useChildComponent-es.js +1 -1
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +2 -2
- package/dist/utils/mergeRefs.d.ts +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
package/dist/InputText/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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, b as useAtlantisFormFieldName, l as formFieldStyles, n as mergeRefs, f as FormFieldWrapper, m 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 {
|
|
10
|
+
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
11
11
|
import '../Icon-es.js';
|
|
12
12
|
import '../Text-es.js';
|
|
13
13
|
import '../Typography-es.js';
|
|
@@ -15,17 +15,6 @@ import '../useFormFieldFocus-es.js';
|
|
|
15
15
|
import '../InputValidation-es.js';
|
|
16
16
|
import '../Spinner-es.js';
|
|
17
17
|
import 'react-router-dom';
|
|
18
|
-
import '../_commonjsHelpers-es.js';
|
|
19
|
-
import '../_baseGet-es.js';
|
|
20
|
-
import '../isTypedArray-es.js';
|
|
21
|
-
import '../isObjectLike-es.js';
|
|
22
|
-
import '../identity-es.js';
|
|
23
|
-
import '../_getTag-es.js';
|
|
24
|
-
import '../isSymbol-es.js';
|
|
25
|
-
import '../keysIn-es.js';
|
|
26
|
-
import '../_baseAssignValue-es.js';
|
|
27
|
-
import '../_baseFlatten-es.js';
|
|
28
|
-
import '../_setToString-es.js';
|
|
29
18
|
|
|
30
19
|
/**
|
|
31
20
|
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
@@ -157,10 +146,9 @@ function insertAtCursor(input, newText) {
|
|
|
157
146
|
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
158
147
|
* 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.
|
|
159
148
|
*/
|
|
160
|
-
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
|
|
149
|
+
function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
|
|
161
150
|
function handleClear() {
|
|
162
151
|
var _a;
|
|
163
|
-
handleBlur();
|
|
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
|
}
|
|
@@ -179,38 +167,48 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
|
|
|
179
167
|
event.preventDefault();
|
|
180
168
|
onEnter && onEnter(event);
|
|
181
169
|
}
|
|
170
|
+
function handleKeyUp(event) {
|
|
171
|
+
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
|
|
172
|
+
}
|
|
182
173
|
function handleFocus(event) {
|
|
183
174
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
184
175
|
}
|
|
185
176
|
function handleBlur(event) {
|
|
186
177
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
187
178
|
}
|
|
179
|
+
function handleMouseDown(event) {
|
|
180
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
181
|
+
}
|
|
182
|
+
function handleMouseUp(event) {
|
|
183
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
184
|
+
}
|
|
185
|
+
function handlePointerDown(event) {
|
|
186
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
187
|
+
}
|
|
188
|
+
function handlePointerUp(event) {
|
|
189
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
190
|
+
}
|
|
191
|
+
function handleClick(event) {
|
|
192
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
193
|
+
}
|
|
188
194
|
return {
|
|
189
195
|
handleClear,
|
|
190
196
|
handleChange,
|
|
191
197
|
handleKeyDown,
|
|
198
|
+
handleKeyUp,
|
|
192
199
|
handleFocus,
|
|
193
200
|
handleBlur,
|
|
201
|
+
handleMouseDown,
|
|
202
|
+
handleMouseUp,
|
|
203
|
+
handlePointerDown,
|
|
204
|
+
handlePointerUp,
|
|
205
|
+
handleClick,
|
|
194
206
|
};
|
|
195
207
|
}
|
|
196
208
|
|
|
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
|
-
const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
209
|
+
const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRef) {
|
|
210
210
|
var _a, _b, _c;
|
|
211
|
-
const inputTextRef = React__default.useRef(null);
|
|
212
|
-
const wrapperRef = React__default.useRef(null);
|
|
213
|
-
const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
|
|
211
|
+
const inputTextRef = React__default.useRef(null), wrapperRef = React__default.useRef(null);
|
|
214
212
|
const id = useInputTextId(props);
|
|
215
213
|
const { rowRange } = useTextAreaResize({
|
|
216
214
|
rows: props.rows,
|
|
@@ -218,54 +216,48 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
|
|
|
218
216
|
inputRef: inputTextRef,
|
|
219
217
|
wrapperRef: wrapperRef,
|
|
220
218
|
});
|
|
221
|
-
const type = props.multiline ? "textarea" : "text";
|
|
222
|
-
const { inputStyle } = useFormFieldWrapperStyles(legacyPropHelper);
|
|
223
219
|
const { name } = useAtlantisFormFieldName({
|
|
224
220
|
nameProp: props.name,
|
|
225
221
|
id: id,
|
|
226
222
|
});
|
|
227
|
-
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
|
|
223
|
+
const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
|
|
228
224
|
onChange: props.onChange,
|
|
229
225
|
onBlur: props.onBlur,
|
|
230
226
|
onFocus: props.onFocus,
|
|
227
|
+
onMouseDown: props.onMouseDown,
|
|
228
|
+
onMouseUp: props.onMouseUp,
|
|
229
|
+
onPointerDown: props.onPointerDown,
|
|
230
|
+
onPointerUp: props.onPointerUp,
|
|
231
|
+
onClick: props.onClick,
|
|
231
232
|
onKeyDown: props.onKeyDown,
|
|
233
|
+
onKeyUp: props.onKeyUp,
|
|
232
234
|
onEnter: props.onEnter,
|
|
233
235
|
inputRef: inputTextRef,
|
|
234
236
|
});
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
"version",
|
|
246
|
-
]);
|
|
247
|
-
const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
248
|
-
name,
|
|
249
|
-
handleChange,
|
|
250
|
-
handleBlur,
|
|
251
|
-
handleFocus,
|
|
252
|
-
handleKeyDown }));
|
|
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", 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 },
|
|
237
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
238
|
+
const descriptionVisible = props.description && !props.inline;
|
|
239
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
240
|
+
const dataAttrs = filterDataAttributes(props);
|
|
241
|
+
// Shared props for both TextArea and TextInput
|
|
242
|
+
const commonInputProps = Object.assign({ id,
|
|
243
|
+
name, className: formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
244
|
+
? descriptionIdentifier
|
|
245
|
+
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
|
|
246
|
+
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, 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, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
|
|
254
247
|
React__default.createElement(React__default.Fragment, null,
|
|
255
|
-
|
|
256
|
-
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false })
|
|
257
|
-
props.children)));
|
|
248
|
+
props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
249
|
+
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
258
250
|
});
|
|
259
251
|
function useInputTextId(props) {
|
|
260
252
|
const generatedId = useId();
|
|
261
253
|
return props.id || generatedId;
|
|
262
254
|
}
|
|
263
|
-
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return
|
|
268
|
-
}
|
|
255
|
+
const TextArea = forwardRef(function TextArea(props, ref) {
|
|
256
|
+
return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
|
|
257
|
+
});
|
|
258
|
+
const TextInput = forwardRef(function TextInput(props, ref) {
|
|
259
|
+
return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
|
|
260
|
+
});
|
|
269
261
|
|
|
270
262
|
function isNewInputTextProps(props) {
|
|
271
263
|
return props.version === 2;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
|
|
2
2
|
import type { InputTextRebuiltProps } from "./InputText.types";
|
|
3
|
-
export interface useInputTextActionsProps extends Pick<InputTextRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown"> {
|
|
4
|
-
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement>;
|
|
3
|
+
export interface useInputTextActionsProps extends Pick<InputTextRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp" | "onClick"> {
|
|
4
|
+
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
|
|
8
8
|
* DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
9
9
|
*/
|
|
10
|
-
export declare function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }: useInputTextActionsProps): {
|
|
10
|
+
export declare function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }: useInputTextActionsProps): {
|
|
11
11
|
handleClear: () => void;
|
|
12
12
|
handleChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
13
13
|
handleKeyDown: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
14
|
+
handleKeyUp: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
14
15
|
handleFocus: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
15
|
-
handleBlur: (event
|
|
16
|
+
handleBlur: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
17
|
+
handleMouseDown: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
18
|
+
handleMouseUp: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
19
|
+
handlePointerDown: (event: PointerEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
20
|
+
handlePointerUp: (event: PointerEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
21
|
+
handleClick: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
16
22
|
};
|
|
@@ -6,8 +6,8 @@ import type { RowRange } from "./InputText.types";
|
|
|
6
6
|
export declare function useTextAreaResize({ rows, value, inputRef, wrapperRef, }: {
|
|
7
7
|
rows?: number | RowRange;
|
|
8
8
|
value: string | number | Date | undefined;
|
|
9
|
-
inputRef: RefObject<HTMLTextAreaElement | HTMLInputElement>;
|
|
10
|
-
wrapperRef: RefObject<HTMLDivElement>;
|
|
9
|
+
inputRef: RefObject<HTMLTextAreaElement | HTMLInputElement | null>;
|
|
10
|
+
wrapperRef: RefObject<HTMLDivElement | null>;
|
|
11
11
|
}): {
|
|
12
12
|
resize: () => void;
|
|
13
13
|
rowRange: RowRange;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { InputTimeRebuiltProps } from "./InputTime.types";
|
|
3
|
-
export declare function InputTimeRebuilt({ value, onChange, ...
|
|
3
|
+
export declare function InputTimeRebuilt({ value, onChange, readOnly, autoComplete, inputRef, ...props }: InputTimeRebuiltProps): React.JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
+
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } 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,18 @@ 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
|
|
22
|
+
export interface InputTimeRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, MouseEvents<HTMLInputElement>, RebuiltInputCommonProps, Pick<InputTimeProps, "value" | "onChange"> {
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Maximum numerical or date value.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
readonly max?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Minimum numerical or date value.
|
|
29
|
+
*/
|
|
30
|
+
readonly min?: number;
|
|
31
|
+
readonly inputRef?: FormFieldProps["inputRef"];
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
34
|
+
*/
|
|
35
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
27
36
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
|
|
2
|
+
import type { InputTimeRebuiltProps } from "../InputTime.types";
|
|
3
|
+
export interface UseInputTimeActionsProps extends Pick<InputTimeRebuiltProps, "onChange" | "onFocus" | "onBlur" | "onKeyDown" | "onClick" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp"> {
|
|
4
|
+
readonly value?: Date;
|
|
5
|
+
readonly readOnly?: boolean;
|
|
6
|
+
readonly disabled?: boolean;
|
|
7
|
+
readonly inputRef?: React.RefObject<HTMLInputElement | null>;
|
|
8
|
+
}
|
|
9
|
+
export declare function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }: 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
|
+
handleClick: (event: MouseEvent<HTMLInputElement>) => void;
|
|
17
|
+
handleMouseDown: (event: MouseEvent<HTMLInputElement>) => void;
|
|
18
|
+
handleMouseUp: (event: MouseEvent<HTMLInputElement>) => void;
|
|
19
|
+
handlePointerDown: (event: PointerEvent<HTMLInputElement>) => void;
|
|
20
|
+
handlePointerUp: (event: PointerEvent<HTMLInputElement>) => void;
|
|
21
|
+
};
|
package/dist/InputTime/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ require('classnames');
|
|
|
8
8
|
require('@jobber/design');
|
|
9
9
|
require('react-hook-form');
|
|
10
10
|
require('../Button-cjs.js');
|
|
11
|
+
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
11
12
|
var omit = require('../omit-cjs.js');
|
|
12
13
|
require('@jobber/hooks');
|
|
13
14
|
require('framer-motion');
|
|
@@ -21,7 +22,7 @@ require('../useFormFieldFocus-cjs.js');
|
|
|
21
22
|
require('../InputValidation-cjs.js');
|
|
22
23
|
require('../Spinner-cjs.js');
|
|
23
24
|
require('react-router-dom');
|
|
24
|
-
require('../
|
|
25
|
+
require('../_getAllKeys-cjs.js');
|
|
25
26
|
require('../isTypedArray-cjs.js');
|
|
26
27
|
require('../identity-cjs.js');
|
|
27
28
|
require('../_getTag-cjs.js');
|
|
@@ -204,23 +205,7 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
204
205
|
}
|
|
205
206
|
}
|
|
206
207
|
|
|
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) })));
|
|
208
|
+
function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
224
209
|
function handleChangeEvent(event) {
|
|
225
210
|
handleChange(event.target.value);
|
|
226
211
|
}
|
|
@@ -228,28 +213,103 @@ function InputTimeRebuilt(_a) {
|
|
|
228
213
|
onChange === null || onChange === void 0 ? void 0 : onChange(timeStringToDate(newValue, value));
|
|
229
214
|
}
|
|
230
215
|
function handleBlur(event) {
|
|
231
|
-
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
ref.current.value = "";
|
|
216
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
217
|
+
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
218
|
+
if (!inputRef.current.checkValidity()) {
|
|
219
|
+
inputRef.current.value = "";
|
|
236
220
|
}
|
|
237
221
|
}
|
|
238
222
|
}
|
|
239
223
|
function handleClear() {
|
|
240
224
|
var _a;
|
|
241
|
-
|
|
225
|
+
// Clear the value and refocus without triggering blur event
|
|
242
226
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
243
|
-
(_a =
|
|
227
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
244
228
|
}
|
|
245
229
|
function handleFocus(event) {
|
|
246
|
-
|
|
247
|
-
|
|
230
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
231
|
+
}
|
|
232
|
+
function handleKeyDown(event) {
|
|
233
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
234
|
+
}
|
|
235
|
+
function handleClick(event) {
|
|
236
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
248
237
|
}
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
return props.id || generatedId;
|
|
238
|
+
function handleMouseDown(event) {
|
|
239
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
252
240
|
}
|
|
241
|
+
function handleMouseUp(event) {
|
|
242
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
243
|
+
}
|
|
244
|
+
function handlePointerDown(event) {
|
|
245
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
246
|
+
}
|
|
247
|
+
function handlePointerUp(event) {
|
|
248
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
handleChangeEvent,
|
|
252
|
+
handleChange,
|
|
253
|
+
handleBlur,
|
|
254
|
+
handleClear,
|
|
255
|
+
handleFocus,
|
|
256
|
+
handleKeyDown,
|
|
257
|
+
handleClick,
|
|
258
|
+
handleMouseDown,
|
|
259
|
+
handleMouseUp,
|
|
260
|
+
handlePointerDown,
|
|
261
|
+
handlePointerUp,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function InputTimeRebuilt(_a) {
|
|
266
|
+
var _b;
|
|
267
|
+
var { value, onChange, readOnly, autoComplete, inputRef } = _a, props = tslib_es6.__rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef"]);
|
|
268
|
+
const { internalRef, mergedRef, wrapperRef } = useInputTimeRefs(inputRef);
|
|
269
|
+
const generatedId = React.useId();
|
|
270
|
+
const id = props.id || generatedId;
|
|
271
|
+
const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputTimeActions({
|
|
272
|
+
onChange,
|
|
273
|
+
value,
|
|
274
|
+
readOnly,
|
|
275
|
+
disabled: props.disabled,
|
|
276
|
+
inputRef: internalRef,
|
|
277
|
+
onFocus: props.onFocus,
|
|
278
|
+
onBlur: props.onBlur,
|
|
279
|
+
onKeyDown: props.onKeyDown,
|
|
280
|
+
onClick: props.onClick,
|
|
281
|
+
onMouseDown: props.onMouseDown,
|
|
282
|
+
onMouseUp: props.onMouseUp,
|
|
283
|
+
onPointerDown: props.onPointerDown,
|
|
284
|
+
onPointerUp: props.onPointerUp,
|
|
285
|
+
});
|
|
286
|
+
const { setTypedTime } = useTimePredict({
|
|
287
|
+
value,
|
|
288
|
+
handleChange,
|
|
289
|
+
});
|
|
290
|
+
// Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
|
|
291
|
+
function handleKeyUp(event) {
|
|
292
|
+
var _a;
|
|
293
|
+
(_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
294
|
+
if (props.disabled || readOnly)
|
|
295
|
+
return;
|
|
296
|
+
!isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
|
|
297
|
+
}
|
|
298
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
299
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
300
|
+
const descriptionVisible = props.description && !props.inline;
|
|
301
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
302
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: props.name, error: props.error || "", identifier: id, descriptionIdentifier: descriptionIdentifier, invalid: props.invalid, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: props.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
303
|
+
React.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: FormField.formFieldStyles.input, id: id, disabled: props.disabled, readOnly: readOnly, autoComplete: autoComplete, autoFocus: props.autoFocus, max: props.max, min: props.min, value: dateToTimeString(value), onChange: handleChangeEvent, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, "data-testid": "ATL-InputTime-input", "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"] }, dataAttrs))));
|
|
304
|
+
}
|
|
305
|
+
function useInputTimeRefs(inputRef) {
|
|
306
|
+
const internalRef = React.useRef(null);
|
|
307
|
+
const mergedRef = FormField.mergeRefs([
|
|
308
|
+
internalRef,
|
|
309
|
+
inputRef,
|
|
310
|
+
]);
|
|
311
|
+
const wrapperRef = React.useRef(null);
|
|
312
|
+
return { internalRef, mergedRef, wrapperRef };
|
|
253
313
|
}
|
|
254
314
|
|
|
255
315
|
function InputTime$1(_a) {
|
package/dist/InputTime/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React__default, { useState, useCallback, useEffect,
|
|
1
|
+
import React__default, { useState, useCallback, useEffect, useId, useRef } from 'react';
|
|
2
2
|
import { _ as __rest } from '../tslib.es6-es.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { a as debounce } from '../debounce-es.js';
|
|
4
|
+
import { f as FormFieldWrapper, l as formFieldStyles, n as mergeRefs, k as FormField } from '../FormField-es.js';
|
|
5
5
|
import 'classnames';
|
|
6
6
|
import '@jobber/design';
|
|
7
7
|
import 'react-hook-form';
|
|
8
8
|
import '../Button-es.js';
|
|
9
|
+
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
9
10
|
import { o as omit } from '../omit-es.js';
|
|
10
11
|
import '@jobber/hooks';
|
|
11
12
|
import 'framer-motion';
|
|
@@ -19,7 +20,7 @@ import '../useFormFieldFocus-es.js';
|
|
|
19
20
|
import '../InputValidation-es.js';
|
|
20
21
|
import '../Spinner-es.js';
|
|
21
22
|
import 'react-router-dom';
|
|
22
|
-
import '../
|
|
23
|
+
import '../_getAllKeys-es.js';
|
|
23
24
|
import '../isTypedArray-es.js';
|
|
24
25
|
import '../identity-es.js';
|
|
25
26
|
import '../_getTag-es.js';
|
|
@@ -202,23 +203,7 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
function
|
|
206
|
-
var _b, _c;
|
|
207
|
-
var { value, onChange } = _a, params = __rest(_a, ["value", "onChange"]);
|
|
208
|
-
const ref = (_b = params.inputRef) !== null && _b !== void 0 ? _b : useRef(null);
|
|
209
|
-
const { setTypedTime } = useTimePredict({
|
|
210
|
-
value,
|
|
211
|
-
handleChange,
|
|
212
|
-
});
|
|
213
|
-
const { inputStyle } = useFormFieldWrapperStyles(params);
|
|
214
|
-
const wrapperRef = React__default.useRef(null);
|
|
215
|
-
const id = getId(params);
|
|
216
|
-
return (React__default.createElement(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 },
|
|
217
|
-
React__default.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 => {
|
|
218
|
-
if (params.disabled || params.readonly)
|
|
219
|
-
return;
|
|
220
|
-
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
221
|
-
}, value: dateToTimeString(value) })));
|
|
206
|
+
function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
222
207
|
function handleChangeEvent(event) {
|
|
223
208
|
handleChange(event.target.value);
|
|
224
209
|
}
|
|
@@ -226,28 +211,103 @@ function InputTimeRebuilt(_a) {
|
|
|
226
211
|
onChange === null || onChange === void 0 ? void 0 : onChange(timeStringToDate(newValue, value));
|
|
227
212
|
}
|
|
228
213
|
function handleBlur(event) {
|
|
229
|
-
|
|
230
|
-
(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
ref.current.value = "";
|
|
214
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
215
|
+
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
216
|
+
if (!inputRef.current.checkValidity()) {
|
|
217
|
+
inputRef.current.value = "";
|
|
234
218
|
}
|
|
235
219
|
}
|
|
236
220
|
}
|
|
237
221
|
function handleClear() {
|
|
238
222
|
var _a;
|
|
239
|
-
|
|
223
|
+
// Clear the value and refocus without triggering blur event
|
|
240
224
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
241
|
-
(_a =
|
|
225
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
242
226
|
}
|
|
243
227
|
function handleFocus(event) {
|
|
244
|
-
|
|
245
|
-
|
|
228
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
229
|
+
}
|
|
230
|
+
function handleKeyDown(event) {
|
|
231
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
232
|
+
}
|
|
233
|
+
function handleClick(event) {
|
|
234
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
246
235
|
}
|
|
247
|
-
function
|
|
248
|
-
|
|
249
|
-
return props.id || generatedId;
|
|
236
|
+
function handleMouseDown(event) {
|
|
237
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
250
238
|
}
|
|
239
|
+
function handleMouseUp(event) {
|
|
240
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
241
|
+
}
|
|
242
|
+
function handlePointerDown(event) {
|
|
243
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
244
|
+
}
|
|
245
|
+
function handlePointerUp(event) {
|
|
246
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
handleChangeEvent,
|
|
250
|
+
handleChange,
|
|
251
|
+
handleBlur,
|
|
252
|
+
handleClear,
|
|
253
|
+
handleFocus,
|
|
254
|
+
handleKeyDown,
|
|
255
|
+
handleClick,
|
|
256
|
+
handleMouseDown,
|
|
257
|
+
handleMouseUp,
|
|
258
|
+
handlePointerDown,
|
|
259
|
+
handlePointerUp,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function InputTimeRebuilt(_a) {
|
|
264
|
+
var _b;
|
|
265
|
+
var { value, onChange, readOnly, autoComplete, inputRef } = _a, props = __rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef"]);
|
|
266
|
+
const { internalRef, mergedRef, wrapperRef } = useInputTimeRefs(inputRef);
|
|
267
|
+
const generatedId = useId();
|
|
268
|
+
const id = props.id || generatedId;
|
|
269
|
+
const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputTimeActions({
|
|
270
|
+
onChange,
|
|
271
|
+
value,
|
|
272
|
+
readOnly,
|
|
273
|
+
disabled: props.disabled,
|
|
274
|
+
inputRef: internalRef,
|
|
275
|
+
onFocus: props.onFocus,
|
|
276
|
+
onBlur: props.onBlur,
|
|
277
|
+
onKeyDown: props.onKeyDown,
|
|
278
|
+
onClick: props.onClick,
|
|
279
|
+
onMouseDown: props.onMouseDown,
|
|
280
|
+
onMouseUp: props.onMouseUp,
|
|
281
|
+
onPointerDown: props.onPointerDown,
|
|
282
|
+
onPointerUp: props.onPointerUp,
|
|
283
|
+
});
|
|
284
|
+
const { setTypedTime } = useTimePredict({
|
|
285
|
+
value,
|
|
286
|
+
handleChange,
|
|
287
|
+
});
|
|
288
|
+
// Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
|
|
289
|
+
function handleKeyUp(event) {
|
|
290
|
+
var _a;
|
|
291
|
+
(_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
292
|
+
if (props.disabled || readOnly)
|
|
293
|
+
return;
|
|
294
|
+
!isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
|
|
295
|
+
}
|
|
296
|
+
const dataAttrs = filterDataAttributes(props);
|
|
297
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
298
|
+
const descriptionVisible = props.description && !props.inline;
|
|
299
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
300
|
+
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: props.name, error: props.error || "", identifier: id, descriptionIdentifier: descriptionIdentifier, invalid: props.invalid, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: props.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
301
|
+
React__default.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: formFieldStyles.input, id: id, disabled: props.disabled, readOnly: readOnly, autoComplete: autoComplete, autoFocus: props.autoFocus, max: props.max, min: props.min, value: dateToTimeString(value), onChange: handleChangeEvent, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, "data-testid": "ATL-InputTime-input", "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"] }, dataAttrs))));
|
|
302
|
+
}
|
|
303
|
+
function useInputTimeRefs(inputRef) {
|
|
304
|
+
const internalRef = useRef(null);
|
|
305
|
+
const mergedRef = mergeRefs([
|
|
306
|
+
internalRef,
|
|
307
|
+
inputRef,
|
|
308
|
+
]);
|
|
309
|
+
const wrapperRef = React__default.useRef(null);
|
|
310
|
+
return { internalRef, mergedRef, wrapperRef };
|
|
251
311
|
}
|
|
252
312
|
|
|
253
313
|
function InputTime$1(_a) {
|
|
@@ -14,9 +14,9 @@ var Chip = require('./Chip-cjs.js');
|
|
|
14
14
|
require('./tslib.es6-cjs.js');
|
|
15
15
|
|
|
16
16
|
function InternalChip({ label, active = false, disabled = false, invalid = false, prefix, suffix, tabIndex, ariaLabel, onClick, onKeyDown, }) {
|
|
17
|
-
return (React.createElement(Chip.
|
|
18
|
-
prefix && React.createElement(Chip.
|
|
19
|
-
suffix && React.createElement(Chip.
|
|
17
|
+
return (React.createElement(Chip.Chip, { disabled: disabled, invalid: invalid, onKeyDown: onKeyDown, testID: "ATL-InternalChip", ariaLabel: ariaLabel, tabIndex: tabIndex, variation: active ? "base" : "subtle", role: tabIndex !== undefined ? "option" : undefined, onClick: onClick ? (_, ev) => onClick(ev) : undefined, label: label },
|
|
18
|
+
prefix && React.createElement(Chip.Chip.Prefix, null, prefix),
|
|
19
|
+
suffix && React.createElement(Chip.Chip.Suffix, null, suffix)));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
var styles = {"wrapper":"XRnU90M2-fs-","input":"Dq-yFHd1zK0-","menu":"F7CpurjKzBI-","menuListOption":"_9SAK31TqNDY-","loadingIndicator":"s5vFJVv0t0Q-","activeOption":"_8d0w-JzgzS4-","spinning":"hDJGLX6kE-U-"};
|