@jobber/components 6.104.0 → 6.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Autocomplete/Autocomplete.types.d.ts +9 -51
- package/dist/Autocomplete/index.cjs +10 -20
- package/dist/Autocomplete/index.mjs +10 -20
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +1 -1
- package/dist/Autocomplete/useAutocomplete.d.ts +2 -2
- 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/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/DataListHeader/index.cjs +1 -0
- package/dist/DataList/components/DataListHeader/index.mjs +1 -0
- 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/index.cjs +1 -8
- package/dist/DataList/index.mjs +1 -8
- package/dist/DataTable/index.cjs +3 -2
- package/dist/DataTable/index.mjs +3 -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/InputDate.types.d.ts +12 -7
- package/dist/InputDate/index.cjs +6 -9
- package/dist/InputDate/index.mjs +6 -9
- 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 -49
- package/dist/InputEmail/index.mjs +43 -49
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
- package/dist/InputNumber/index.cjs +6 -4
- package/dist/InputNumber/index.mjs +6 -4
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
- package/dist/InputPhoneNumber/index.cjs +48 -36
- package/dist/InputPhoneNumber/index.mjs +48 -36
- package/dist/InputText/InputText.types.d.ts +31 -25
- package/dist/InputText/index.cjs +66 -62
- package/dist/InputText/index.mjs +67 -63
- package/dist/InputText/useInputTextActions.d.ts +10 -4
- 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 +91 -30
- package/dist/InputTime/index.mjs +94 -33
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/MultiSelect/index.cjs +1 -0
- package/dist/MultiSelect/index.mjs +1 -0
- 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 -41
- package/dist/Select/index.mjs +29 -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/filterDataAttributes-cjs.js +26 -0
- package/dist/filterDataAttributes-es.js +24 -0
- package/dist/index.cjs +3 -2
- 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/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 -366
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
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,104 @@ 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 { inputStyle } = FormField.useFormFieldWrapperStyles(props);
|
|
272
|
+
const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputTimeActions({
|
|
273
|
+
onChange,
|
|
274
|
+
value,
|
|
275
|
+
readOnly,
|
|
276
|
+
disabled: props.disabled,
|
|
277
|
+
inputRef: internalRef,
|
|
278
|
+
onFocus: props.onFocus,
|
|
279
|
+
onBlur: props.onBlur,
|
|
280
|
+
onKeyDown: props.onKeyDown,
|
|
281
|
+
onClick: props.onClick,
|
|
282
|
+
onMouseDown: props.onMouseDown,
|
|
283
|
+
onMouseUp: props.onMouseUp,
|
|
284
|
+
onPointerDown: props.onPointerDown,
|
|
285
|
+
onPointerUp: props.onPointerUp,
|
|
286
|
+
});
|
|
287
|
+
const { setTypedTime } = useTimePredict({
|
|
288
|
+
value,
|
|
289
|
+
handleChange,
|
|
290
|
+
});
|
|
291
|
+
// Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
|
|
292
|
+
function handleKeyUp(event) {
|
|
293
|
+
var _a;
|
|
294
|
+
(_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
295
|
+
if (props.disabled || readOnly)
|
|
296
|
+
return;
|
|
297
|
+
!isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
|
|
298
|
+
}
|
|
299
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
300
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
301
|
+
const descriptionVisible = props.description && !props.inline;
|
|
302
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
303
|
+
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 },
|
|
304
|
+
React.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: inputStyle, 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))));
|
|
305
|
+
}
|
|
306
|
+
function useInputTimeRefs(inputRef) {
|
|
307
|
+
const internalRef = React.useRef(null);
|
|
308
|
+
const mergedRef = FormField.mergeRefs([
|
|
309
|
+
internalRef,
|
|
310
|
+
inputRef,
|
|
311
|
+
]);
|
|
312
|
+
const wrapperRef = React.useRef(null);
|
|
313
|
+
return { internalRef, mergedRef, wrapperRef };
|
|
253
314
|
}
|
|
254
315
|
|
|
255
316
|
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 { j as useFormFieldWrapperStyles, f as FormFieldWrapper, k as FormField } from '../FormField-es.js';
|
|
3
|
+
import { a as debounce } from '../debounce-es.js';
|
|
4
|
+
import { j as useFormFieldWrapperStyles, f as FormFieldWrapper, m 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,104 @@ 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 { inputStyle } = useFormFieldWrapperStyles(props);
|
|
270
|
+
const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputTimeActions({
|
|
271
|
+
onChange,
|
|
272
|
+
value,
|
|
273
|
+
readOnly,
|
|
274
|
+
disabled: props.disabled,
|
|
275
|
+
inputRef: internalRef,
|
|
276
|
+
onFocus: props.onFocus,
|
|
277
|
+
onBlur: props.onBlur,
|
|
278
|
+
onKeyDown: props.onKeyDown,
|
|
279
|
+
onClick: props.onClick,
|
|
280
|
+
onMouseDown: props.onMouseDown,
|
|
281
|
+
onMouseUp: props.onMouseUp,
|
|
282
|
+
onPointerDown: props.onPointerDown,
|
|
283
|
+
onPointerUp: props.onPointerUp,
|
|
284
|
+
});
|
|
285
|
+
const { setTypedTime } = useTimePredict({
|
|
286
|
+
value,
|
|
287
|
+
handleChange,
|
|
288
|
+
});
|
|
289
|
+
// Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
|
|
290
|
+
function handleKeyUp(event) {
|
|
291
|
+
var _a;
|
|
292
|
+
(_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
293
|
+
if (props.disabled || readOnly)
|
|
294
|
+
return;
|
|
295
|
+
!isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
|
|
296
|
+
}
|
|
297
|
+
const dataAttrs = filterDataAttributes(props);
|
|
298
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
299
|
+
const descriptionVisible = props.description && !props.inline;
|
|
300
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
301
|
+
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 },
|
|
302
|
+
React__default.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: inputStyle, 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))));
|
|
303
|
+
}
|
|
304
|
+
function useInputTimeRefs(inputRef) {
|
|
305
|
+
const internalRef = useRef(null);
|
|
306
|
+
const mergedRef = mergeRefs([
|
|
307
|
+
internalRef,
|
|
308
|
+
inputRef,
|
|
309
|
+
]);
|
|
310
|
+
const wrapperRef = React__default.useRef(null);
|
|
311
|
+
return { internalRef, mergedRef, wrapperRef };
|
|
251
312
|
}
|
|
252
313
|
|
|
253
314
|
function InputTime$1(_a) {
|
package/dist/List/index.cjs
CHANGED
|
@@ -8,9 +8,9 @@ require('../identity-cjs.js');
|
|
|
8
8
|
require('../isTypedArray-cjs.js');
|
|
9
9
|
require('../isObjectLike-cjs.js');
|
|
10
10
|
require('../_commonjsHelpers-cjs.js');
|
|
11
|
-
require('../
|
|
12
|
-
require('../_getTag-cjs.js');
|
|
11
|
+
require('../_getAllKeys-cjs.js');
|
|
13
12
|
require('../isSymbol-cjs.js');
|
|
13
|
+
require('../_getTag-cjs.js');
|
|
14
14
|
require('../_baseFor-cjs.js');
|
|
15
15
|
require('../_baseAssignValue-cjs.js');
|
|
16
16
|
require('../Typography-cjs.js');
|
package/dist/List/index.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import '../identity-es.js';
|
|
|
6
6
|
import '../isTypedArray-es.js';
|
|
7
7
|
import '../isObjectLike-es.js';
|
|
8
8
|
import '../_commonjsHelpers-es.js';
|
|
9
|
-
import '../
|
|
10
|
-
import '../_getTag-es.js';
|
|
9
|
+
import '../_getAllKeys-es.js';
|
|
11
10
|
import '../isSymbol-es.js';
|
|
11
|
+
import '../_getTag-es.js';
|
|
12
12
|
import '../_baseFor-es.js';
|
|
13
13
|
import '../_baseAssignValue-es.js';
|
|
14
14
|
import '../Typography-es.js';
|
|
@@ -9,12 +9,12 @@ require('classnames');
|
|
|
9
9
|
require('../Select/index.cjs');
|
|
10
10
|
require('../omit-cjs.js');
|
|
11
11
|
require('../_commonjsHelpers-cjs.js');
|
|
12
|
-
require('../
|
|
12
|
+
require('../_getAllKeys-cjs.js');
|
|
13
13
|
require('../isTypedArray-cjs.js');
|
|
14
14
|
require('../isObjectLike-cjs.js');
|
|
15
|
+
require('../isSymbol-cjs.js');
|
|
15
16
|
require('../identity-cjs.js');
|
|
16
17
|
require('../_getTag-cjs.js');
|
|
17
|
-
require('../isSymbol-cjs.js');
|
|
18
18
|
require('../keysIn-cjs.js');
|
|
19
19
|
require('../_baseAssignValue-cjs.js');
|
|
20
20
|
require('../_baseFlatten-cjs.js');
|
|
@@ -31,6 +31,7 @@ require('../useFormFieldFocus-cjs.js');
|
|
|
31
31
|
require('../InputValidation-cjs.js');
|
|
32
32
|
require('../Spinner-cjs.js');
|
|
33
33
|
require('react-hook-form');
|
|
34
|
+
require('../filterDataAttributes-cjs.js');
|
|
34
35
|
require('../InputNumber/index.cjs');
|
|
35
36
|
require('../Tree-cjs.js');
|
|
36
37
|
require('react-dom');
|
|
@@ -7,12 +7,12 @@ import 'classnames';
|
|
|
7
7
|
import '../Select/index.mjs';
|
|
8
8
|
import '../omit-es.js';
|
|
9
9
|
import '../_commonjsHelpers-es.js';
|
|
10
|
-
import '../
|
|
10
|
+
import '../_getAllKeys-es.js';
|
|
11
11
|
import '../isTypedArray-es.js';
|
|
12
12
|
import '../isObjectLike-es.js';
|
|
13
|
+
import '../isSymbol-es.js';
|
|
13
14
|
import '../identity-es.js';
|
|
14
15
|
import '../_getTag-es.js';
|
|
15
|
-
import '../isSymbol-es.js';
|
|
16
16
|
import '../keysIn-es.js';
|
|
17
17
|
import '../_baseAssignValue-es.js';
|
|
18
18
|
import '../_baseFlatten-es.js';
|
|
@@ -29,6 +29,7 @@ import '../useFormFieldFocus-es.js';
|
|
|
29
29
|
import '../InputValidation-es.js';
|
|
30
30
|
import '../Spinner-es.js';
|
|
31
31
|
import 'react-hook-form';
|
|
32
|
+
import '../filterDataAttributes-es.js';
|
|
32
33
|
import '../InputNumber/index.mjs';
|
|
33
34
|
import '../Tree-es.js';
|
|
34
35
|
import 'react-dom';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
+
import type { FocusEvents, HTMLInputBaseProps, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
2
3
|
export interface SelectLegacyProps extends Pick<CommonFormFieldProps, "id" | "align" | "description" | "disabled" | "invalid" | "inline" | "name" | "onValidation" | "placeholder" | "size" | "value" | "onChange">, Pick<FormFieldProps, "autofocus" | "onEnter" | "onBlur" | "onFocus" | "inputRef" | "wrapperRef" | "validations" | "children" | "prefix" | "suffix" | "defaultValue" | "version"> {
|
|
3
4
|
/**
|
|
4
5
|
* Changes the width to roughly the same size as the maximum character length
|
|
@@ -8,12 +9,15 @@ export interface SelectLegacyProps extends Pick<CommonFormFieldProps, "id" | "al
|
|
|
8
9
|
/**
|
|
9
10
|
* Rebuilt version of the Select component without React Hook Form dependency.
|
|
10
11
|
*/
|
|
11
|
-
export interface SelectRebuiltProps extends Omit<
|
|
12
|
+
export interface SelectRebuiltProps extends Omit<HTMLInputBaseProps, "readOnly">, FocusEvents<HTMLSelectElement>, Omit<RebuiltInputCommonProps, "clearable" | "prefix" | "suffix" | "align">, Pick<SelectLegacyProps, "prefix" | "suffix" | "align" | "children"> {
|
|
12
13
|
defaultValue?: never;
|
|
13
14
|
readonly value?: string | number;
|
|
14
15
|
onChange?(newValue?: string | number): void;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
readonly inputRef?: FormFieldProps["inputRef"];
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
19
|
+
*/
|
|
20
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
17
21
|
/**
|
|
18
22
|
* Opt-in to the customizable select UI (Chromium 123+).
|
|
19
23
|
* When true, the component will apply the custom select styles
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { ChangeEvent } from "react";
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from "react";
|
|
2
2
|
interface UseSelectActionsProps {
|
|
3
3
|
readonly onChange?: (newValue: string | number, event?: ChangeEvent<HTMLSelectElement>) => void;
|
|
4
|
-
readonly onBlur?: () => void;
|
|
5
|
-
readonly onFocus?: () => void;
|
|
4
|
+
readonly onBlur?: (event: FocusEvent<HTMLSelectElement>) => void;
|
|
5
|
+
readonly onFocus?: (event: FocusEvent<HTMLSelectElement>) => void;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Hook with actions on the Select component.
|
|
9
9
|
*/
|
|
10
10
|
export declare function useSelectActions({ onChange, onBlur, onFocus, }: UseSelectActionsProps): {
|
|
11
11
|
handleChange: (event: ChangeEvent<HTMLSelectElement>) => void;
|
|
12
|
-
handleBlur: () => void;
|
|
13
|
-
handleFocus: () => void;
|
|
12
|
+
handleBlur: (event: FocusEvent<HTMLSelectElement>) => void;
|
|
13
|
+
handleFocus: (event: FocusEvent<HTMLSelectElement>) => void;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
package/dist/Select/index.cjs
CHANGED
|
@@ -10,13 +10,14 @@ require('@jobber/hooks');
|
|
|
10
10
|
require('framer-motion');
|
|
11
11
|
require('@jobber/design');
|
|
12
12
|
require('../Button-cjs.js');
|
|
13
|
+
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
13
14
|
require('../_commonjsHelpers-cjs.js');
|
|
14
|
-
require('../
|
|
15
|
+
require('../_getAllKeys-cjs.js');
|
|
15
16
|
require('../isTypedArray-cjs.js');
|
|
16
17
|
require('../isObjectLike-cjs.js');
|
|
18
|
+
require('../isSymbol-cjs.js');
|
|
17
19
|
require('../identity-cjs.js');
|
|
18
20
|
require('../_getTag-cjs.js');
|
|
19
|
-
require('../isSymbol-cjs.js');
|
|
20
21
|
require('../keysIn-cjs.js');
|
|
21
22
|
require('../_baseAssignValue-cjs.js');
|
|
22
23
|
require('../_baseFlatten-cjs.js');
|
|
@@ -42,11 +43,11 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
42
43
|
const newValue = event.currentTarget.value;
|
|
43
44
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
44
45
|
}
|
|
45
|
-
function handleBlur() {
|
|
46
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
46
|
+
function handleBlur(event) {
|
|
47
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
47
48
|
}
|
|
48
|
-
function handleFocus() {
|
|
49
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
49
|
+
function handleFocus(event) {
|
|
50
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
50
51
|
}
|
|
51
52
|
return {
|
|
52
53
|
handleChange,
|
|
@@ -55,27 +56,16 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
/**
|
|
59
|
-
* Hook for managing the props of a Select component.
|
|
60
|
-
* Extracted from FormField's useAtlantisFormField.
|
|
61
|
-
*/
|
|
62
|
-
function useSelectFormField({ id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, }) {
|
|
63
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
64
|
-
const fieldProps = Object.assign({ id,
|
|
65
|
-
name,
|
|
66
|
-
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value }, (description &&
|
|
67
|
-
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
68
|
-
return { fieldProps, descriptionIdentifier };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
59
|
var styles = {"select":"-hmXAsAfH9U-","selectPostfix":"_5ST4c1fXDYU-","spinning":"oOACJmrVDf0-"};
|
|
72
60
|
|
|
73
61
|
function SelectRebuilt(props) {
|
|
74
|
-
var _a
|
|
75
|
-
const
|
|
76
|
-
const wrapperRef = React.useRef(null);
|
|
62
|
+
var _a;
|
|
63
|
+
const { mergedRef, wrapperRef } = useSelectRefs(props.inputRef);
|
|
77
64
|
const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign({}, omit.omit(props, ["version"])));
|
|
78
|
-
const
|
|
65
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
66
|
+
const generatedId = React.useId();
|
|
67
|
+
const id = props.id || generatedId;
|
|
68
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
79
69
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
80
70
|
nameProp: props.name,
|
|
81
71
|
id: id,
|
|
@@ -85,27 +75,23 @@ function SelectRebuilt(props) {
|
|
|
85
75
|
onBlur: props.onBlur,
|
|
86
76
|
onFocus: props.onFocus,
|
|
87
77
|
});
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"onFocus",
|
|
92
|
-
"size",
|
|
93
|
-
"placeholder",
|
|
94
|
-
"version",
|
|
95
|
-
]);
|
|
96
|
-
const { fieldProps, descriptionIdentifier } = useSelectFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
97
|
-
name,
|
|
98
|
-
handleChange,
|
|
99
|
-
handleBlur,
|
|
100
|
-
handleFocus }));
|
|
101
|
-
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: (_b = props.error) !== null && _b !== void 0 ? _b : "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, type: "select", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, clearable: "never", maxLength: props.maxLength },
|
|
78
|
+
const descriptionVisible = props.description && !props.inline;
|
|
79
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
80
|
+
return (React.createElement(FormField.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: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, type: "select", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, clearable: "never" },
|
|
102
81
|
React.createElement(React.Fragment, null,
|
|
103
|
-
React.createElement("select", Object.assign({
|
|
82
|
+
React.createElement("select", Object.assign({ id: id, name: name, disabled: props.disabled, autoFocus: props.autoFocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value: props.value, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
83
|
+
? descriptionIdentifier
|
|
84
|
+
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], ref: mergedRef, className: classnames(inputStyle, props.UNSAFE_experimentalStyles && styles.select) }, dataAttrs), props.children),
|
|
104
85
|
React.createElement(FormField.FormFieldPostFix, { variation: "select", className: styles.selectPostfix }))));
|
|
105
86
|
}
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
|
|
87
|
+
function useSelectRefs(inputRef) {
|
|
88
|
+
const internalRef = React.useRef(null);
|
|
89
|
+
const mergedRef = FormField.mergeRefs([
|
|
90
|
+
internalRef,
|
|
91
|
+
inputRef,
|
|
92
|
+
]);
|
|
93
|
+
const wrapperRef = React.useRef(null);
|
|
94
|
+
return { mergedRef, wrapperRef };
|
|
109
95
|
}
|
|
110
96
|
|
|
111
97
|
function SelectOption({ children, disabled, value }) {
|