@jobber/components 6.103.1 → 6.103.2-JOB-140609-fafe469.18
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 +0 -12
- package/dist/Autocomplete/index.mjs +0 -12
- package/dist/Checkbox/Checkbox.types.d.ts +2 -9
- package/dist/Checkbox/index.cjs +3 -2
- package/dist/Checkbox/index.mjs +3 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
- package/dist/Chips/index.cjs +2 -2
- package/dist/Chips/index.mjs +2 -2
- package/dist/DataList/components/DataListSearch/index.cjs +1 -12
- package/dist/DataList/components/DataListSearch/index.mjs +1 -12
- package/dist/DataList/index.cjs +0 -8
- package/dist/DataList/index.mjs +0 -8
- package/dist/DataTable/index.cjs +2 -2
- package/dist/DataTable/index.mjs +2 -2
- package/dist/DatePicker/index.cjs +2 -2
- package/dist/DatePicker/index.mjs +2 -2
- package/dist/FormField/FormFieldTypes.d.ts +195 -0
- package/dist/FormField-cjs.js +0 -1
- package/dist/FormField-es.js +1 -1
- package/dist/InputDate/index.cjs +8 -4
- package/dist/InputDate/index.mjs +8 -4
- package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
- package/dist/InputEmail/InputEmail.types.d.ts +28 -21
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
- package/dist/InputEmail/index.cjs +10 -45
- package/dist/InputEmail/index.mjs +10 -45
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +30 -1
- package/dist/InputNumber/index.cjs +10 -2
- package/dist/InputNumber/index.mjs +10 -2
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +25 -24
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
- package/dist/InputPhoneNumber/index.cjs +24 -36
- package/dist/InputPhoneNumber/index.mjs +24 -36
- package/dist/InputText/InputText.d.ts +2 -2
- package/dist/InputText/InputText.types.d.ts +39 -24
- package/dist/InputText/index.cjs +26 -55
- package/dist/InputText/index.mjs +27 -56
- package/dist/InputText/useInputTextActions.d.ts +1 -1
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +29 -1
- package/dist/InputTime/index.cjs +32 -25
- package/dist/InputTime/index.d.ts +1 -1
- package/dist/InputTime/index.mjs +34 -27
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/RecurringSelect/index.cjs +2 -2
- package/dist/RecurringSelect/index.mjs +2 -2
- package/dist/Select/Select.rebuilt.d.ts +1 -1
- package/dist/Select/Select.types.d.ts +18 -1
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/index.cjs +27 -41
- package/dist/Select/index.d.ts +7 -5
- package/dist/Select/index.mjs +29 -43
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +1 -1
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
- package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/omit-cjs.js +14 -14
- package/dist/omit-es.js +1 -1
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +1 -1
- package/package.json +2 -2
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
- package/dist/InputText/useInputTextFormField.d.ts +0 -352
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
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,34 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
function InputTimeRebuilt(_a) {
|
|
208
|
-
var _b
|
|
209
|
-
var { value, onChange
|
|
210
|
-
|
|
207
|
+
const InputTimeRebuilt = React.forwardRef(function InputTimeRebuilt(_a, forwardedRef) {
|
|
208
|
+
var _b;
|
|
209
|
+
var { value, onChange,
|
|
210
|
+
// Support both old and new prop names
|
|
211
|
+
readonly, readOnly = readonly, autocomplete, autoComplete = typeof autocomplete === "string" ? autocomplete : undefined,
|
|
212
|
+
// Deprecated props
|
|
213
|
+
inputRef: deprecatedInputRef } = _a, params = tslib_es6.__rest(_a, ["value", "onChange", "readonly", "readOnly", "autocomplete", "autoComplete", "inputRef"]);
|
|
214
|
+
const internalRef = React.useRef(null);
|
|
215
|
+
const mergedRef = FormField.mergeRefs([
|
|
216
|
+
internalRef,
|
|
217
|
+
deprecatedInputRef,
|
|
218
|
+
forwardedRef,
|
|
219
|
+
]);
|
|
220
|
+
const id = params.id || React.useId();
|
|
221
|
+
const wrapperRef = React.useRef(null);
|
|
222
|
+
const { inputStyle } = FormField.useFormFieldWrapperStyles(params);
|
|
211
223
|
const { setTypedTime } = useTimePredict({
|
|
212
224
|
value,
|
|
213
225
|
handleChange,
|
|
214
226
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (params.disabled || params.readonly)
|
|
227
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: params.disabled, size: params.size, align: params.align, inline: params.inline, name: params.name, error: params.error || "", identifier: id, descriptionIdentifier: `descriptionUUID--${id}`, invalid: Boolean(params.invalid), description: params.description, clearable: (_b = params.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
228
|
+
React.createElement("input", { ref: mergedRef, type: "time", name: params.name, className: inputStyle, onBlur: handleBlur, id: id, disabled: params.disabled, readOnly: readOnly, autoComplete: autoComplete, onChange: handleChangeEvent, onFocus: handleFocus, onKeyDown: params.onKeyDown, onKeyUp: e => {
|
|
229
|
+
var _a;
|
|
230
|
+
(_a = params.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(params, e);
|
|
231
|
+
if (params.disabled || readOnly)
|
|
221
232
|
return;
|
|
222
233
|
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
223
|
-
}, value: dateToTimeString(value) })));
|
|
234
|
+
}, "data-testid": "ATL-InputTime-input", value: dateToTimeString(value), "aria-label": params["aria-label"], "aria-describedby": params["aria-describedby"], "aria-invalid": params["aria-invalid"], "aria-required": params["aria-required"] })));
|
|
224
235
|
function handleChangeEvent(event) {
|
|
225
236
|
handleChange(event.target.value);
|
|
226
237
|
}
|
|
@@ -230,27 +241,23 @@ function InputTimeRebuilt(_a) {
|
|
|
230
241
|
function handleBlur(event) {
|
|
231
242
|
var _a;
|
|
232
243
|
(_a = params.onBlur) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
233
|
-
if (
|
|
234
|
-
if (!
|
|
235
|
-
|
|
244
|
+
if (internalRef.current) {
|
|
245
|
+
if (!internalRef.current.checkValidity()) {
|
|
246
|
+
internalRef.current.value = "";
|
|
236
247
|
}
|
|
237
248
|
}
|
|
238
249
|
}
|
|
239
250
|
function handleClear() {
|
|
240
251
|
var _a;
|
|
241
|
-
|
|
252
|
+
// Clear the value and refocus without triggering blur event
|
|
242
253
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
243
|
-
(_a =
|
|
254
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
244
255
|
}
|
|
245
256
|
function handleFocus(event) {
|
|
246
257
|
var _a;
|
|
247
258
|
(_a = params.onFocus) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
248
259
|
}
|
|
249
|
-
|
|
250
|
-
const generatedId = React.useId();
|
|
251
|
-
return props.id || generatedId;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
260
|
+
});
|
|
254
261
|
|
|
255
262
|
function InputTime$1(_a) {
|
|
256
263
|
var { defaultValue, value, onChange } = _a, params = tslib_es6.__rest(_a, ["defaultValue", "value", "onChange"]);
|
|
@@ -282,13 +289,13 @@ function InputTime$1(_a) {
|
|
|
282
289
|
function isNewInputTimeProps(props) {
|
|
283
290
|
return props.version === 2;
|
|
284
291
|
}
|
|
285
|
-
|
|
292
|
+
const InputTime = React.forwardRef(function InputTimeShim(props, ref) {
|
|
286
293
|
if (isNewInputTimeProps(props)) {
|
|
287
|
-
return React.createElement(InputTimeRebuilt, Object.assign({}, props));
|
|
294
|
+
return React.createElement(InputTimeRebuilt, Object.assign({}, props, { ref: ref }));
|
|
288
295
|
}
|
|
289
296
|
else {
|
|
290
297
|
return React.createElement(InputTime$1, Object.assign({}, props));
|
|
291
298
|
}
|
|
292
|
-
}
|
|
299
|
+
});
|
|
293
300
|
|
|
294
301
|
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>>;
|
package/dist/InputTime/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React__default, { useState, useCallback, useEffect, useRef, useId } from 'react';
|
|
1
|
+
import React__default, { useState, useCallback, useEffect, forwardRef, useRef, useId } from 'react';
|
|
2
2
|
import { _ as __rest } from '../tslib.es6-es.js';
|
|
3
3
|
import { d as debounce } from '../debounce-es.js';
|
|
4
|
-
import { j as useFormFieldWrapperStyles, f as FormFieldWrapper, k as FormField } from '../FormField-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';
|
|
@@ -19,7 +19,7 @@ import '../useFormFieldFocus-es.js';
|
|
|
19
19
|
import '../InputValidation-es.js';
|
|
20
20
|
import '../Spinner-es.js';
|
|
21
21
|
import 'react-router-dom';
|
|
22
|
-
import '../
|
|
22
|
+
import '../_getAllKeys-es.js';
|
|
23
23
|
import '../isTypedArray-es.js';
|
|
24
24
|
import '../identity-es.js';
|
|
25
25
|
import '../_getTag-es.js';
|
|
@@ -202,23 +202,34 @@ function timeStringToDate(timeString, baseDate) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function InputTimeRebuilt(_a) {
|
|
206
|
-
var _b
|
|
207
|
-
var { value, onChange
|
|
208
|
-
|
|
205
|
+
const InputTimeRebuilt = forwardRef(function InputTimeRebuilt(_a, forwardedRef) {
|
|
206
|
+
var _b;
|
|
207
|
+
var { value, onChange,
|
|
208
|
+
// Support both old and new prop names
|
|
209
|
+
readonly, readOnly = readonly, autocomplete, autoComplete = typeof autocomplete === "string" ? autocomplete : undefined,
|
|
210
|
+
// Deprecated props
|
|
211
|
+
inputRef: deprecatedInputRef } = _a, params = __rest(_a, ["value", "onChange", "readonly", "readOnly", "autocomplete", "autoComplete", "inputRef"]);
|
|
212
|
+
const internalRef = useRef(null);
|
|
213
|
+
const mergedRef = mergeRefs([
|
|
214
|
+
internalRef,
|
|
215
|
+
deprecatedInputRef,
|
|
216
|
+
forwardedRef,
|
|
217
|
+
]);
|
|
218
|
+
const id = params.id || useId();
|
|
219
|
+
const wrapperRef = React__default.useRef(null);
|
|
220
|
+
const { inputStyle } = useFormFieldWrapperStyles(params);
|
|
209
221
|
const { setTypedTime } = useTimePredict({
|
|
210
222
|
value,
|
|
211
223
|
handleChange,
|
|
212
224
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (params.disabled || params.readonly)
|
|
225
|
+
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: (_b = params.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
|
|
226
|
+
React__default.createElement("input", { ref: mergedRef, type: "time", name: params.name, className: inputStyle, onBlur: handleBlur, id: id, disabled: params.disabled, readOnly: readOnly, autoComplete: autoComplete, onChange: handleChangeEvent, onFocus: handleFocus, onKeyDown: params.onKeyDown, onKeyUp: e => {
|
|
227
|
+
var _a;
|
|
228
|
+
(_a = params.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(params, e);
|
|
229
|
+
if (params.disabled || readOnly)
|
|
219
230
|
return;
|
|
220
231
|
!isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
|
|
221
|
-
}, value: dateToTimeString(value) })));
|
|
232
|
+
}, "data-testid": "ATL-InputTime-input", value: dateToTimeString(value), "aria-label": params["aria-label"], "aria-describedby": params["aria-describedby"], "aria-invalid": params["aria-invalid"], "aria-required": params["aria-required"] })));
|
|
222
233
|
function handleChangeEvent(event) {
|
|
223
234
|
handleChange(event.target.value);
|
|
224
235
|
}
|
|
@@ -228,27 +239,23 @@ function InputTimeRebuilt(_a) {
|
|
|
228
239
|
function handleBlur(event) {
|
|
229
240
|
var _a;
|
|
230
241
|
(_a = params.onBlur) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
231
|
-
if (
|
|
232
|
-
if (!
|
|
233
|
-
|
|
242
|
+
if (internalRef.current) {
|
|
243
|
+
if (!internalRef.current.checkValidity()) {
|
|
244
|
+
internalRef.current.value = "";
|
|
234
245
|
}
|
|
235
246
|
}
|
|
236
247
|
}
|
|
237
248
|
function handleClear() {
|
|
238
249
|
var _a;
|
|
239
|
-
|
|
250
|
+
// Clear the value and refocus without triggering blur event
|
|
240
251
|
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
241
|
-
(_a =
|
|
252
|
+
(_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
242
253
|
}
|
|
243
254
|
function handleFocus(event) {
|
|
244
255
|
var _a;
|
|
245
256
|
(_a = params.onFocus) === null || _a === void 0 ? void 0 : _a.call(params, event);
|
|
246
257
|
}
|
|
247
|
-
|
|
248
|
-
const generatedId = useId();
|
|
249
|
-
return props.id || generatedId;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
258
|
+
});
|
|
252
259
|
|
|
253
260
|
function InputTime$1(_a) {
|
|
254
261
|
var { defaultValue, value, onChange } = _a, params = __rest(_a, ["defaultValue", "value", "onChange"]);
|
|
@@ -280,13 +287,13 @@ function InputTime$1(_a) {
|
|
|
280
287
|
function isNewInputTimeProps(props) {
|
|
281
288
|
return props.version === 2;
|
|
282
289
|
}
|
|
283
|
-
|
|
290
|
+
const InputTime = forwardRef(function InputTimeShim(props, ref) {
|
|
284
291
|
if (isNewInputTimeProps(props)) {
|
|
285
|
-
return React__default.createElement(InputTimeRebuilt, Object.assign({}, props));
|
|
292
|
+
return React__default.createElement(InputTimeRebuilt, Object.assign({}, props, { ref: ref }));
|
|
286
293
|
}
|
|
287
294
|
else {
|
|
288
295
|
return React__default.createElement(InputTime$1, Object.assign({}, props));
|
|
289
296
|
}
|
|
290
|
-
}
|
|
297
|
+
});
|
|
291
298
|
|
|
292
299
|
export { InputTime };
|
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');
|
|
@@ -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';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { SelectRebuiltProps } from "./Select.types";
|
|
3
|
-
export declare
|
|
3
|
+
export declare const SelectRebuilt: React.ForwardRefExoticComponent<SelectRebuiltProps & React.RefAttributes<HTMLSelectElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
+
import type { AriaInputProps, FocusEvents } from "../FormField/FormFieldTypes";
|
|
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,28 @@ 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<SelectLegacyProps, "defaultValue" | "version" | "onChange" | "value" | "validations" | "onValidation"> {
|
|
12
|
+
export interface SelectRebuiltProps extends Omit<SelectLegacyProps, "defaultValue" | "version" | "onChange" | "value" | "validations" | "onValidation" | "autofocus" | "inputRef" | "onEnter" | "onBlur" | "onFocus">, AriaInputProps, FocusEvents<HTMLSelectElement> {
|
|
12
13
|
defaultValue?: never;
|
|
13
14
|
readonly value?: string | number;
|
|
14
15
|
onChange?(newValue?: string | number): void;
|
|
15
16
|
version: 2;
|
|
16
17
|
error?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `autoFocus` (camelCase) instead.
|
|
20
|
+
*/
|
|
21
|
+
readonly autofocus?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Automatically focus the select when mounted.
|
|
24
|
+
*/
|
|
25
|
+
readonly autoFocus?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `ref` instead. Note: `ref` support requires React 18+ forwardRef.
|
|
28
|
+
*/
|
|
29
|
+
readonly inputRef?: FormFieldProps["inputRef"];
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
32
|
+
*/
|
|
33
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
17
34
|
/**
|
|
18
35
|
* Opt-in to the customizable select UI (Chromium 123+).
|
|
19
36
|
* 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
|
@@ -11,12 +11,12 @@ require('framer-motion');
|
|
|
11
11
|
require('@jobber/design');
|
|
12
12
|
require('../Button-cjs.js');
|
|
13
13
|
require('../_commonjsHelpers-cjs.js');
|
|
14
|
-
require('../
|
|
14
|
+
require('../_getAllKeys-cjs.js');
|
|
15
15
|
require('../isTypedArray-cjs.js');
|
|
16
16
|
require('../isObjectLike-cjs.js');
|
|
17
|
+
require('../isSymbol-cjs.js');
|
|
17
18
|
require('../identity-cjs.js');
|
|
18
19
|
require('../_getTag-cjs.js');
|
|
19
|
-
require('../isSymbol-cjs.js');
|
|
20
20
|
require('../keysIn-cjs.js');
|
|
21
21
|
require('../_baseAssignValue-cjs.js');
|
|
22
22
|
require('../_baseFlatten-cjs.js');
|
|
@@ -42,11 +42,11 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
42
42
|
const newValue = event.currentTarget.value;
|
|
43
43
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
44
44
|
}
|
|
45
|
-
function handleBlur() {
|
|
46
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
45
|
+
function handleBlur(event) {
|
|
46
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
47
47
|
}
|
|
48
|
-
function handleFocus() {
|
|
49
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
48
|
+
function handleFocus(event) {
|
|
49
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
50
50
|
}
|
|
51
51
|
return {
|
|
52
52
|
handleChange,
|
|
@@ -55,27 +55,22 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
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
58
|
var styles = {"select":"-hmXAsAfH9U-","selectPostfix":"_5ST4c1fXDYU-","spinning":"oOACJmrVDf0-"};
|
|
72
59
|
|
|
73
|
-
function SelectRebuilt(props) {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
|
|
60
|
+
const SelectRebuilt = React.forwardRef(function SelectRebuilt(props, forwardedRef) {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
// Deprecated props
|
|
63
|
+
const { inputRef: deprecatedInputRef } = props;
|
|
64
|
+
const internalRef = React.useRef(null);
|
|
65
|
+
const mergedRef = FormField.mergeRefs([
|
|
66
|
+
internalRef,
|
|
67
|
+
deprecatedInputRef,
|
|
68
|
+
forwardedRef,
|
|
69
|
+
]);
|
|
76
70
|
const wrapperRef = React.useRef(null);
|
|
77
71
|
const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign({}, omit.omit(props, ["version"])));
|
|
78
72
|
const id = useSelectId(props);
|
|
73
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
79
74
|
const { name } = FormField.useAtlantisFormFieldName({
|
|
80
75
|
nameProp: props.name,
|
|
81
76
|
id: id,
|
|
@@ -85,24 +80,14 @@ function SelectRebuilt(props) {
|
|
|
85
80
|
onBlur: props.onBlur,
|
|
86
81
|
onFocus: props.onFocus,
|
|
87
82
|
});
|
|
88
|
-
|
|
89
|
-
"onChange",
|
|
90
|
-
"onBlur",
|
|
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 },
|
|
83
|
+
return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: (_a = props.autoFocus) !== null && _a !== void 0 ? _a : 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 },
|
|
102
84
|
React.createElement(React.Fragment, null,
|
|
103
|
-
React.createElement("select",
|
|
85
|
+
React.createElement("select", { id: id, name: name, disabled: props.disabled, autoFocus: (_c = props.autoFocus) !== null && _c !== void 0 ? _c : props.autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value: props.value, "aria-label": props["aria-label"], "aria-describedby": props["aria-describedby"] ||
|
|
86
|
+
(props.description && !props.inline
|
|
87
|
+
? descriptionIdentifier
|
|
88
|
+
: undefined), "aria-invalid": props["aria-invalid"], "aria-required": props["aria-required"], ref: mergedRef, className: classnames(inputStyle, props.UNSAFE_experimentalStyles && styles.select) }, props.children),
|
|
104
89
|
React.createElement(FormField.FormFieldPostFix, { variation: "select", className: styles.selectPostfix }))));
|
|
105
|
-
}
|
|
90
|
+
});
|
|
106
91
|
function useSelectId(props) {
|
|
107
92
|
const generatedId = React.useId();
|
|
108
93
|
return props.id || generatedId;
|
|
@@ -119,14 +104,15 @@ function OptionGroup({ children, label, disabled, UNSAFE_className, UNSAFE_style
|
|
|
119
104
|
function isNewSelectProps(props) {
|
|
120
105
|
return props.version === 2;
|
|
121
106
|
}
|
|
122
|
-
function
|
|
107
|
+
const SelectBase = React.forwardRef(function SelectShim(props, ref) {
|
|
123
108
|
if (isNewSelectProps(props)) {
|
|
124
|
-
return React.createElement(SelectRebuilt, Object.assign({}, props));
|
|
109
|
+
return React.createElement(SelectRebuilt, Object.assign({}, props, { ref: ref }));
|
|
125
110
|
}
|
|
126
111
|
else {
|
|
127
112
|
return React.createElement(Select$1, Object.assign({}, props));
|
|
128
113
|
}
|
|
129
|
-
}
|
|
114
|
+
});
|
|
115
|
+
const Select = SelectBase;
|
|
130
116
|
Select.Option = SelectOption;
|
|
131
117
|
Select.OptionGroup = OptionGroup;
|
|
132
118
|
|
package/dist/Select/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Option } from "./Option";
|
|
3
|
+
import { OptionGroup } from "./OptionGroup";
|
|
2
4
|
import { type SelectLegacyProps, type SelectRebuiltProps } from "./Select.types";
|
|
3
5
|
export { Option } from "./Option";
|
|
4
6
|
export type SelectShimProps = SelectLegacyProps | SelectRebuiltProps;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type SelectComponent = React.ForwardRefExoticComponent<SelectShimProps & React.RefAttributes<HTMLSelectElement>> & {
|
|
8
|
+
Option: typeof Option;
|
|
9
|
+
OptionGroup: typeof OptionGroup;
|
|
10
|
+
};
|
|
11
|
+
export declare const Select: SelectComponent;
|
|
10
12
|
export type { SelectRebuiltProps, SelectLegacyProps };
|
package/dist/Select/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React__default, { useRef, useId } from 'react';
|
|
1
|
+
import React__default, { forwardRef, useRef, useId } from 'react';
|
|
2
2
|
import { o as omit } from '../omit-es.js';
|
|
3
|
-
import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix } from '../FormField-es.js';
|
|
3
|
+
import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix, m as mergeRefs } from '../FormField-es.js';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import '../tslib.es6-es.js';
|
|
6
6
|
import 'react-hook-form';
|
|
@@ -9,12 +9,12 @@ import 'framer-motion';
|
|
|
9
9
|
import '@jobber/design';
|
|
10
10
|
import '../Button-es.js';
|
|
11
11
|
import '../_commonjsHelpers-es.js';
|
|
12
|
-
import '../
|
|
12
|
+
import '../_getAllKeys-es.js';
|
|
13
13
|
import '../isTypedArray-es.js';
|
|
14
14
|
import '../isObjectLike-es.js';
|
|
15
|
+
import '../isSymbol-es.js';
|
|
15
16
|
import '../identity-es.js';
|
|
16
17
|
import '../_getTag-es.js';
|
|
17
|
-
import '../isSymbol-es.js';
|
|
18
18
|
import '../keysIn-es.js';
|
|
19
19
|
import '../_baseAssignValue-es.js';
|
|
20
20
|
import '../_baseFlatten-es.js';
|
|
@@ -40,11 +40,11 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
40
40
|
const newValue = event.currentTarget.value;
|
|
41
41
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
42
42
|
}
|
|
43
|
-
function handleBlur() {
|
|
44
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
43
|
+
function handleBlur(event) {
|
|
44
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
45
45
|
}
|
|
46
|
-
function handleFocus() {
|
|
47
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
46
|
+
function handleFocus(event) {
|
|
47
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
50
|
handleChange,
|
|
@@ -53,27 +53,22 @@ function useSelectActions({ onChange, onBlur, onFocus, }) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Hook for managing the props of a Select component.
|
|
58
|
-
* Extracted from FormField's useAtlantisFormField.
|
|
59
|
-
*/
|
|
60
|
-
function useSelectFormField({ id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, }) {
|
|
61
|
-
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
62
|
-
const fieldProps = Object.assign({ id,
|
|
63
|
-
name,
|
|
64
|
-
disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value }, (description &&
|
|
65
|
-
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
66
|
-
return { fieldProps, descriptionIdentifier };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
56
|
var styles = {"select":"-hmXAsAfH9U-","selectPostfix":"_5ST4c1fXDYU-","spinning":"oOACJmrVDf0-"};
|
|
70
57
|
|
|
71
|
-
function SelectRebuilt(props) {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
|
|
58
|
+
const SelectRebuilt = forwardRef(function SelectRebuilt(props, forwardedRef) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
// Deprecated props
|
|
61
|
+
const { inputRef: deprecatedInputRef } = props;
|
|
62
|
+
const internalRef = useRef(null);
|
|
63
|
+
const mergedRef = mergeRefs([
|
|
64
|
+
internalRef,
|
|
65
|
+
deprecatedInputRef,
|
|
66
|
+
forwardedRef,
|
|
67
|
+
]);
|
|
74
68
|
const wrapperRef = useRef(null);
|
|
75
69
|
const { inputStyle } = useFormFieldWrapperStyles(Object.assign({}, omit(props, ["version"])));
|
|
76
70
|
const id = useSelectId(props);
|
|
71
|
+
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
77
72
|
const { name } = useAtlantisFormFieldName({
|
|
78
73
|
nameProp: props.name,
|
|
79
74
|
id: id,
|
|
@@ -83,24 +78,14 @@ function SelectRebuilt(props) {
|
|
|
83
78
|
onBlur: props.onBlur,
|
|
84
79
|
onFocus: props.onFocus,
|
|
85
80
|
});
|
|
86
|
-
|
|
87
|
-
"onChange",
|
|
88
|
-
"onBlur",
|
|
89
|
-
"onFocus",
|
|
90
|
-
"size",
|
|
91
|
-
"placeholder",
|
|
92
|
-
"version",
|
|
93
|
-
]);
|
|
94
|
-
const { fieldProps, descriptionIdentifier } = useSelectFormField(Object.assign(Object.assign({}, inputProps), { id,
|
|
95
|
-
name,
|
|
96
|
-
handleChange,
|
|
97
|
-
handleBlur,
|
|
98
|
-
handleFocus }));
|
|
99
|
-
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: (_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 },
|
|
81
|
+
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: (_a = props.autoFocus) !== null && _a !== void 0 ? _a : 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 },
|
|
100
82
|
React__default.createElement(React__default.Fragment, null,
|
|
101
|
-
React__default.createElement("select",
|
|
83
|
+
React__default.createElement("select", { id: id, name: name, disabled: props.disabled, autoFocus: (_c = props.autoFocus) !== null && _c !== void 0 ? _c : props.autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value: props.value, "aria-label": props["aria-label"], "aria-describedby": props["aria-describedby"] ||
|
|
84
|
+
(props.description && !props.inline
|
|
85
|
+
? descriptionIdentifier
|
|
86
|
+
: undefined), "aria-invalid": props["aria-invalid"], "aria-required": props["aria-required"], ref: mergedRef, className: classnames(inputStyle, props.UNSAFE_experimentalStyles && styles.select) }, props.children),
|
|
102
87
|
React__default.createElement(FormFieldPostFix, { variation: "select", className: styles.selectPostfix }))));
|
|
103
|
-
}
|
|
88
|
+
});
|
|
104
89
|
function useSelectId(props) {
|
|
105
90
|
const generatedId = useId();
|
|
106
91
|
return props.id || generatedId;
|
|
@@ -117,14 +102,15 @@ function OptionGroup({ children, label, disabled, UNSAFE_className, UNSAFE_style
|
|
|
117
102
|
function isNewSelectProps(props) {
|
|
118
103
|
return props.version === 2;
|
|
119
104
|
}
|
|
120
|
-
function
|
|
105
|
+
const SelectBase = forwardRef(function SelectShim(props, ref) {
|
|
121
106
|
if (isNewSelectProps(props)) {
|
|
122
|
-
return React__default.createElement(SelectRebuilt, Object.assign({}, props));
|
|
107
|
+
return React__default.createElement(SelectRebuilt, Object.assign({}, props, { ref: ref }));
|
|
123
108
|
}
|
|
124
109
|
else {
|
|
125
110
|
return React__default.createElement(Select$1, Object.assign({}, props));
|
|
126
111
|
}
|
|
127
|
-
}
|
|
112
|
+
});
|
|
113
|
+
const Select = SelectBase;
|
|
128
114
|
Select.Option = SelectOption;
|
|
129
115
|
Select.OptionGroup = OptionGroup;
|
|
130
116
|
|