@jobber/components 7.14.2 → 7.15.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.
Files changed (65) hide show
  1. package/dist/Autocomplete/index.cjs +4 -3
  2. package/dist/Autocomplete/index.mjs +3 -2
  3. package/dist/DataList/components/DataListSearch/index.cjs +2 -1
  4. package/dist/DataList/components/DataListSearch/index.mjs +2 -1
  5. package/dist/DataList/index.cjs +2 -1
  6. package/dist/DataList/index.mjs +2 -1
  7. package/dist/DataTable/index.cjs +2 -1
  8. package/dist/DataTable/index.mjs +2 -1
  9. package/dist/DatePicker/index.cjs +0 -1
  10. package/dist/DatePicker/index.mjs +0 -1
  11. package/dist/DatePicker-cjs.js +782 -4
  12. package/dist/DatePicker-es.js +782 -4
  13. package/dist/FormField/index.cjs +14 -13
  14. package/dist/FormField/index.mjs +5 -4
  15. package/dist/FormField-cjs.js +4 -3
  16. package/dist/FormField-es.js +2 -1
  17. package/dist/FormFieldPostFix-cjs.js +2 -237
  18. package/dist/FormFieldPostFix-es.js +3 -228
  19. package/dist/FormFieldWrapper-cjs.js +242 -0
  20. package/dist/FormFieldWrapper-es.js +231 -0
  21. package/dist/InputDate/index.cjs +2 -2
  22. package/dist/InputDate/index.mjs +2 -2
  23. package/dist/InputEmail/index.cjs +2 -1
  24. package/dist/InputEmail/index.mjs +2 -1
  25. package/dist/InputEmail-cjs.js +3 -2
  26. package/dist/InputEmail-es.js +2 -1
  27. package/dist/InputNumber/index.cjs +2 -1
  28. package/dist/InputNumber/index.mjs +2 -1
  29. package/dist/InputPassword/index.cjs +2 -1
  30. package/dist/InputPassword/index.mjs +2 -1
  31. package/dist/InputPhoneNumber/index.cjs +2 -1
  32. package/dist/InputPhoneNumber/index.mjs +2 -1
  33. package/dist/InputPhoneNumber-cjs.js +3 -2
  34. package/dist/InputPhoneNumber-es.js +2 -1
  35. package/dist/InputText/index.cjs +3 -2
  36. package/dist/InputText/index.mjs +2 -1
  37. package/dist/InputTime/InputTime.d.ts +1 -1
  38. package/dist/InputTime/InputTime.types.d.ts +10 -24
  39. package/dist/InputTime/hooks/useInputTimeActions.d.ts +2 -2
  40. package/dist/InputTime/index.cjs +16 -350
  41. package/dist/InputTime/index.d.ts +2 -4
  42. package/dist/InputTime/index.mjs +15 -353
  43. package/dist/InputTime-cjs.js +300 -0
  44. package/dist/InputTime-es.js +298 -0
  45. package/dist/RecurringSelect/index.cjs +2 -1
  46. package/dist/RecurringSelect/index.mjs +2 -1
  47. package/dist/Select/index.cjs +2 -1
  48. package/dist/Select/index.mjs +2 -1
  49. package/dist/Select-cjs.js +3 -2
  50. package/dist/Select-es.js +2 -1
  51. package/dist/Tabs-es.js +1 -1
  52. package/dist/_baseEach-es.js +2 -2
  53. package/dist/_getAllKeys-es.js +1 -1
  54. package/dist/debounce-es.js +1 -1
  55. package/dist/docs/InputTime/InputTime.md +45 -27
  56. package/dist/docs/usage-guidelines/usage-guidelines.md +0 -1
  57. package/dist/index.cjs +13 -13
  58. package/dist/index.mjs +3 -3
  59. package/dist/isTypedArray-es.js +1 -1
  60. package/dist/styles.css +7 -2
  61. package/dist/useScrollToActive-es.js +1 -1
  62. package/package.json +2 -2
  63. package/dist/InputTime/InputTime.rebuilt.d.ts +0 -3
  64. package/dist/omit-cjs.js +0 -783
  65. package/dist/omit-es.js +0 -781
@@ -0,0 +1,298 @@
1
+ import { _ as __rest } from './tslib.es6-es.js';
2
+ import React__default, { useState, useCallback, useEffect, useId, useRef } from 'react';
3
+ import { d as debounce } from './debounce-es.js';
4
+ import { c as FormFieldWrapper, g as formFieldStyles } from './FormFieldWrapper-es.js';
5
+ import 'classnames';
6
+ import '@jobber/design';
7
+ import 'react-hook-form';
8
+ import { m as mergeRefs } from './mergeRefs-es.js';
9
+ import './Button-es.js';
10
+ import { f as filterDataAttributes } from './filterDataAttributes-es.js';
11
+
12
+ const DEBOUNCE_TIME = 300;
13
+ function useTimePredict({ value, handleChange }) {
14
+ const [IS_12_HOUR_FORMAT, set12HourFormat] = useState(false);
15
+ const [typedTime, setTypedTime] = useState("");
16
+ const predictTime = useCallback(debounce(() => {
17
+ if (value)
18
+ return;
19
+ handleChange(predictHours(typedTime, IS_12_HOUR_FORMAT));
20
+ }, DEBOUNCE_TIME), [typedTime, value, handleChange, IS_12_HOUR_FORMAT]);
21
+ useEffect(() => {
22
+ set12HourFormat(Boolean(Intl.DateTimeFormat(navigator.language, {
23
+ hour: "numeric",
24
+ }).resolvedOptions().hour12));
25
+ }, []);
26
+ /**
27
+ * Predict the hour when user types a number
28
+ */
29
+ useEffect(() => {
30
+ /**
31
+ * Don't try to predict if the user types 0 as the user would almost always
32
+ * type another number after 0.
33
+ */
34
+ if (typedTime && typedTime !== "0") {
35
+ predictTime();
36
+ if ((IS_12_HOUR_FORMAT && typedTime !== "1") || typedTime.length === 2) {
37
+ // Immediately predict the hour
38
+ predictTime.flush();
39
+ }
40
+ }
41
+ return predictTime.cancel;
42
+ }, [typedTime]);
43
+ /**
44
+ * Reset typed time when the value changed
45
+ */
46
+ useEffect(() => {
47
+ setTypedTime("");
48
+ }, [value]);
49
+ return {
50
+ setTypedTime,
51
+ };
52
+ }
53
+ function predictHours(time, is12HourFormat = false) {
54
+ const today = new Date();
55
+ const currentHour = today.getHours();
56
+ const parsedTime = parseInt(time, 10);
57
+ let predictedTime;
58
+ if (is12HourFormat) {
59
+ predictedTime = predict12Hours(parsedTime, currentHour);
60
+ }
61
+ else {
62
+ predictedTime = predict24Hours(time, parsedTime, currentHour);
63
+ }
64
+ return formatHour(predictedTime);
65
+ }
66
+ function predict12Hours(parsedTime, currentHour) {
67
+ /**
68
+ * We need to predict what the user wants when they type 1 since it could be
69
+ * 10, 11, 12, or 1.
70
+ *
71
+ * If the current hour is over 12PM, we can skip this and go to the next logic.
72
+ */
73
+ if (parsedTime === 1 && currentHour < 12) {
74
+ if (currentHour < 10) {
75
+ return 10;
76
+ }
77
+ else {
78
+ return currentHour + 1;
79
+ }
80
+ }
81
+ /**
82
+ * Typing 1-5 predicts that the user want that exact hour on the afternoon.
83
+ */
84
+ if (parsedTime <= 5) {
85
+ return parsedTime + 12;
86
+ }
87
+ /**
88
+ * Typing 13-15 predicts that the user want the 2nd number as the minute interval.
89
+ */
90
+ if (parsedTime > 12 && parsedTime <= 15) {
91
+ const timeArray = parsedTime.toString().split("").map(Number); // 13 -> [1, 3]
92
+ const convertToHoursAndMinutes = timeArray.map((time, i) => {
93
+ if (i === 0)
94
+ return time + 12; // 1 -> 13 as 1PM
95
+ if (i === 1)
96
+ return time * 10; // 3 -> 30 as 30 minutes
97
+ });
98
+ return Number(convertToHoursAndMinutes.join("")); // [13, 30] -> 1330
99
+ }
100
+ /**
101
+ * Anything after 5 will be predicted to be set as AM.
102
+ */
103
+ return parsedTime;
104
+ }
105
+ function predict24Hours(time, parsedTime, currentHour) {
106
+ /**
107
+ * Typing 1 could be predicted from 10 to 19.
108
+ * Typing 01 skips this logic and sets the time to 01:00.
109
+ */
110
+ if (parsedTime === 1 && time !== "01") {
111
+ if (currentHour < 10 || currentHour > 19) {
112
+ return 10;
113
+ }
114
+ else {
115
+ return currentHour + 1;
116
+ }
117
+ }
118
+ /**
119
+ * Typing 2 could be predicted from 20 to 24.
120
+ * Typing 02 skips this logic and sets the time to 02:00.
121
+ */
122
+ if (parsedTime === 2 && time !== "02") {
123
+ if (currentHour < 20) {
124
+ return 20;
125
+ }
126
+ else {
127
+ return currentHour + 1;
128
+ }
129
+ }
130
+ /**
131
+ * Typing 24 or 00 is set to midnight. This ensures the time doesn't get set
132
+ * to 24 as that would be invalid.
133
+ */
134
+ if (parsedTime === 24 || time === "00") {
135
+ return 0;
136
+ }
137
+ return parsedTime;
138
+ }
139
+ function formatHour(time) {
140
+ if (time > 99) {
141
+ const splitTime = time.toString().split("");
142
+ if (splitTime.length === 3)
143
+ splitTime.unshift("0"); // 130 -> 0130
144
+ splitTime.splice(2, 0, ":"); // 0130 -> 01:30
145
+ return splitTime.join("");
146
+ }
147
+ if (time < 10) {
148
+ return `0${time}:00`;
149
+ }
150
+ return `${time}:00`;
151
+ }
152
+
153
+ function dateToTimeString(date, includeSeconds = false) {
154
+ if (!(date instanceof Date)) {
155
+ return "";
156
+ }
157
+ const hours = date.getHours().toString().padStart(2, "0");
158
+ const minutes = date.getMinutes().toString().padStart(2, "0");
159
+ if (includeSeconds) {
160
+ const seconds = date.getSeconds().toString().padStart(2, "0");
161
+ return `${hours}:${minutes}:${seconds}`;
162
+ }
163
+ return `${hours}:${minutes}`;
164
+ }
165
+ function timeStringToDate(timeString, baseDate) {
166
+ try {
167
+ const [hours, minutes, seconds = 0] = timeString.split(":").map(Number);
168
+ if (isNaN(hours) ||
169
+ isNaN(minutes) ||
170
+ isNaN(seconds) ||
171
+ hours < 0 ||
172
+ hours > 24 ||
173
+ minutes < 0 ||
174
+ minutes > 60 ||
175
+ seconds < 0 ||
176
+ seconds > 60) {
177
+ return undefined;
178
+ }
179
+ // Try to preserve the Date part of the Date object as long as it is valid
180
+ const date = baseDate instanceof Date && !isNaN(baseDate.getTime())
181
+ ? new Date(baseDate)
182
+ : new Date();
183
+ date.setHours(hours, minutes, seconds, 0);
184
+ return date;
185
+ }
186
+ catch (_a) {
187
+ return undefined;
188
+ }
189
+ }
190
+
191
+ function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
192
+ function handleChangeEvent(event) {
193
+ handleChange(event.target.value);
194
+ }
195
+ function handleChange(newValue) {
196
+ onChange === null || onChange === void 0 ? void 0 : onChange(timeStringToDate(newValue, value));
197
+ }
198
+ function handleBlur(event) {
199
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
200
+ if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
201
+ if (!inputRef.current.checkValidity()) {
202
+ inputRef.current.value = "";
203
+ inputRef.current.valueAsDate = null;
204
+ // Remove validation error. This is mainly needed for Safari
205
+ inputRef.current.setCustomValidity("");
206
+ }
207
+ }
208
+ }
209
+ function handleClear() {
210
+ var _a;
211
+ // Clear the value and refocus without triggering blur event
212
+ onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
213
+ (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
214
+ }
215
+ function handleFocus(event) {
216
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
217
+ }
218
+ function handleKeyDown(event) {
219
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
220
+ }
221
+ function handleClick(event) {
222
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
223
+ }
224
+ function handleMouseDown(event) {
225
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
226
+ }
227
+ function handleMouseUp(event) {
228
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
229
+ }
230
+ function handlePointerDown(event) {
231
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
232
+ }
233
+ function handlePointerUp(event) {
234
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
235
+ }
236
+ return {
237
+ handleChangeEvent,
238
+ handleChange,
239
+ handleBlur,
240
+ handleClear,
241
+ handleFocus,
242
+ handleKeyDown,
243
+ handleClick,
244
+ handleMouseDown,
245
+ handleMouseUp,
246
+ handlePointerDown,
247
+ handlePointerUp,
248
+ };
249
+ }
250
+
251
+ function InputTime(_a) {
252
+ var _b;
253
+ var { value, onChange, readOnly, autoComplete, inputRef, step = 60 } = _a, props = __rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef", "step"]);
254
+ const { internalRef, mergedRef, wrapperRef } = useInputTimeRefs(inputRef);
255
+ const generatedId = useId();
256
+ const id = props.id || generatedId;
257
+ const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputTimeActions({
258
+ onChange,
259
+ value,
260
+ readOnly,
261
+ disabled: props.disabled,
262
+ inputRef: internalRef,
263
+ onFocus: props.onFocus,
264
+ onBlur: props.onBlur,
265
+ onKeyDown: props.onKeyDown,
266
+ onClick: props.onClick,
267
+ onMouseDown: props.onMouseDown,
268
+ onMouseUp: props.onMouseUp,
269
+ onPointerDown: props.onPointerDown,
270
+ onPointerUp: props.onPointerUp,
271
+ });
272
+ const { setTypedTime } = useTimePredict({
273
+ value,
274
+ handleChange,
275
+ });
276
+ // Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
277
+ function handleKeyUp(event) {
278
+ var _a;
279
+ (_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
280
+ if (props.disabled || readOnly)
281
+ return;
282
+ !isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
283
+ }
284
+ const dataAttrs = filterDataAttributes(props);
285
+ const descriptionIdentifier = `descriptionUUID--${id}`;
286
+ const descriptionVisible = props.description && !props.inline;
287
+ const isInvalid = Boolean(props.error || props.invalid);
288
+ 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, step % 60 !== 0), wrapperRef: wrapperRef },
289
+ 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, required: props.required, max: props.max, min: props.min, step: step, value: dateToTimeString(value, step % 60 !== 0), 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))));
290
+ }
291
+ function useInputTimeRefs(inputRef) {
292
+ const internalRef = useRef(null);
293
+ const mergedRef = mergeRefs([internalRef, inputRef]);
294
+ const wrapperRef = useRef(null);
295
+ return { internalRef, mergedRef, wrapperRef };
296
+ }
297
+
298
+ export { InputTime as I };
@@ -7,7 +7,7 @@ require('../Text-cjs.js');
7
7
  require('../Typography-cjs.js');
8
8
  require('classnames');
9
9
  require('../Select-cjs.js');
10
- require('../FormFieldPostFix-cjs.js');
10
+ require('../FormFieldWrapper-cjs.js');
11
11
  require('@jobber/hooks');
12
12
  require('framer-motion');
13
13
  require('@jobber/design');
@@ -17,6 +17,7 @@ require('react-router-dom');
17
17
  require('../Icon-cjs.js');
18
18
  require('../useFormFieldFocus-cjs.js');
19
19
  require('../InputValidation-cjs.js');
20
+ require('../FormFieldPostFix-cjs.js');
20
21
  require('../Spinner-cjs.js');
21
22
  require('../useAtlantisFormFieldName-cjs.js');
22
23
  require('react-hook-form');
@@ -5,7 +5,7 @@ import '../Text-es.js';
5
5
  import '../Typography-es.js';
6
6
  import 'classnames';
7
7
  import '../Select-es.js';
8
- import '../FormFieldPostFix-es.js';
8
+ import '../FormFieldWrapper-es.js';
9
9
  import '@jobber/hooks';
10
10
  import 'framer-motion';
11
11
  import '@jobber/design';
@@ -15,6 +15,7 @@ import 'react-router-dom';
15
15
  import '../Icon-es.js';
16
16
  import '../useFormFieldFocus-es.js';
17
17
  import '../InputValidation-es.js';
18
+ import '../FormFieldPostFix-es.js';
18
19
  import '../Spinner-es.js';
19
20
  import '../useAtlantisFormFieldName-es.js';
20
21
  import 'react-hook-form';
@@ -3,7 +3,7 @@
3
3
  var Select = require('../Select-cjs.js');
4
4
  require('react');
5
5
  require('classnames');
6
- require('../FormFieldPostFix-cjs.js');
6
+ require('../FormFieldWrapper-cjs.js');
7
7
  require('@jobber/hooks');
8
8
  require('framer-motion');
9
9
  require('@jobber/design');
@@ -15,6 +15,7 @@ require('../Typography-cjs.js');
15
15
  require('../Text-cjs.js');
16
16
  require('../useFormFieldFocus-cjs.js');
17
17
  require('../InputValidation-cjs.js');
18
+ require('../FormFieldPostFix-cjs.js');
18
19
  require('../Spinner-cjs.js');
19
20
  require('../useAtlantisFormFieldName-cjs.js');
20
21
  require('react-hook-form');
@@ -1,7 +1,7 @@
1
1
  export { S as Option, a as Select } from '../Select-es.js';
2
2
  import 'react';
3
3
  import 'classnames';
4
- import '../FormFieldPostFix-es.js';
4
+ import '../FormFieldWrapper-es.js';
5
5
  import '@jobber/hooks';
6
6
  import 'framer-motion';
7
7
  import '@jobber/design';
@@ -13,6 +13,7 @@ import '../Typography-es.js';
13
13
  import '../Text-es.js';
14
14
  import '../useFormFieldFocus-es.js';
15
15
  import '../InputValidation-es.js';
16
+ import '../FormFieldPostFix-es.js';
16
17
  import '../Spinner-es.js';
17
18
  import '../useAtlantisFormFieldName-es.js';
18
19
  import 'react-hook-form';
@@ -2,6 +2,7 @@
2
2
 
3
3
  var React = require('react');
4
4
  var classnames = require('classnames');
5
+ var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
5
6
  var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
6
7
  var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
7
8
  require('./tslib.es6-cjs.js');
@@ -60,11 +61,11 @@ function Select(props) {
60
61
  });
61
62
  const descriptionVisible = props.description && !props.inline;
62
63
  const isInvalid = Boolean(props.error || props.invalid);
63
- return (React.createElement(FormFieldPostFix.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" },
64
+ return (React.createElement(FormFieldWrapper.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" },
64
65
  React.createElement(React.Fragment, null,
65
66
  React.createElement("select", Object.assign({ id: id, name: name, disabled: props.disabled, autoFocus: props.autoFocus, required: props.required, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value: props.value, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
66
67
  ? descriptionIdentifier
67
- : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], ref: mergedRef, className: classnames(FormFieldPostFix.formFieldStyles.input, props.UNSAFE_experimentalStyles && styles.select) }, dataAttrs), props.children),
68
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], ref: mergedRef, className: classnames(FormFieldWrapper.formFieldStyles.input, props.UNSAFE_experimentalStyles && styles.select) }, dataAttrs), props.children),
68
69
  React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "select", className: styles.selectPostfix }))));
69
70
  }
70
71
  function useSelectRefs(inputRef) {
package/dist/Select-es.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import React__default, { useId, useRef } from 'react';
2
2
  import classnames from 'classnames';
3
- import { c as FormFieldWrapper, g as formFieldStyles, h as FormFieldPostFix } from './FormFieldPostFix-es.js';
3
+ import { c as FormFieldWrapper, g as formFieldStyles } from './FormFieldWrapper-es.js';
4
+ import { F as FormFieldPostFix } from './FormFieldPostFix-es.js';
4
5
  import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
5
6
  import './tslib.es6-es.js';
6
7
  import 'react-hook-form';
package/dist/Tabs-es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React__default, { useState, useRef, useCallback, useEffect } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers-es.js';
4
- import { d as debounce_1 } from './debounce-es.js';
4
+ import { a as debounce_1 } from './debounce-es.js';
5
5
  import { a as isObject_1 } from './isObjectLike-es.js';
6
6
  import { T as Typography } from './Typography-es.js';
7
7
 
@@ -1,8 +1,8 @@
1
1
  import { g as _MapCache, d as _Uint8Array, e as eq_1, c as _Stack, a as _isIndex, i as identity_1 } from './identity-es.js';
2
2
  import { b as _Symbol, i as isObjectLike_1, a as isObject_1 } from './isObjectLike-es.js';
3
- import { e as _getAllKeys, k as keys_1, b as _baseGet, f as _castPath, g as _toKey, h as _isKey } from './_getAllKeys-es.js';
3
+ import { c as _getAllKeys, k as keys_1, b as _baseGet, d as _castPath, e as _toKey, f as _isKey } from './_getAllKeys-es.js';
4
4
  import { a as _getTag } from './_getTag-es.js';
5
- import { c as isBufferExports, d as isTypedArray_1, a as isArray_1, i as isArguments_1, m as isLength_1, b as isArrayLike_1 } from './isTypedArray-es.js';
5
+ import { c as isBufferExports, d as isTypedArray_1, a as isArray_1, i as isArguments_1, l as isLength_1, b as isArrayLike_1 } from './isTypedArray-es.js';
6
6
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers-es.js';
7
7
  import { _ as _baseFor } from './_baseFor-es.js';
8
8
 
@@ -503,4 +503,4 @@ function getAllKeys(object) {
503
503
 
504
504
  var _getAllKeys = getAllKeys;
505
505
 
506
- export { _arrayPush as _, _arrayMap as a, _baseGet as b, _getSymbols as c, _baseGetAllKeys as d, _getAllKeys as e, _castPath as f, _toKey as g, _isKey as h, keys_1 as k, stubArray_1 as s };
506
+ export { _arrayPush as _, _arrayMap as a, _baseGet as b, _getAllKeys as c, _castPath as d, _toKey as e, _isKey as f, _getSymbols as g, _baseGetAllKeys as h, keys_1 as k, stubArray_1 as s };
@@ -326,4 +326,4 @@ var debounce_1 = debounce;
326
326
 
327
327
  var debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(debounce_1);
328
328
 
329
- export { debounce$1 as a, debounce_1 as d };
329
+ export { debounce_1 as a, debounce$1 as d };
@@ -22,16 +22,12 @@ state will indicate that the input is not valid. This can be used when the input
22
22
  is required and the user has not entered a value.
23
23
 
24
24
 
25
- ## Controlled & Uncontrolled
25
+ ## Time typeahead
26
26
 
27
- ### Controlled component
28
-
29
- Web's
30
- [Controlled](/storybook/web/?path=/story/components-forms-and-inputs-inputtime--controlled)
31
- version includes a type-ahead feature where typing at least 1 number
32
- automatically fills in the rest of the time. For example, typing `2` will fill
33
- in `2:00 PM` and typing `1` waits for a few milliseconds in case the user wants
34
- to type `10`, `11`, or `12`.
27
+ The InputTime component includes a type-ahead feature where typing at least 1
28
+ number automatically fills in the rest of the time. For example, typing `2` will
29
+ fill in `2:00 PM` and typing `1` waits for a few milliseconds in case the user
30
+ wants to type `10`, `11`, or `12`.
35
31
 
36
32
 
37
33
  ## Props
@@ -41,27 +37,49 @@ to type `10`, `11`, or `12`.
41
37
  | Prop | Type | Required | Default | Description |
42
38
  |------|------|----------|---------|-------------|
43
39
  | `align` | `"center" | "right"` | No | — | Determines the alignment of the text inside the input. |
44
- | `autocomplete` | `AutocompleteTypes | boolean` | No | — | Determines if browser form autocomplete is enabled. Note that "one-time-code" is experimental and should not be used ... |
45
- | `clearable` | `Clearable` | No | | Add a clear action on the input that clears the value. You should always use `while-editing` if you want the input t... |
46
- | `defaultValue` | `Date` | No | — | Intial value of the input. Only use this when you need to prepopulate the field with a data that is not controlled by... |
40
+ | `aria-activedescendant` | `string` | No | — | ID of the currently active descendant element. Used for composite widgets like combobox or listbox. @see {@link https... |
41
+ | `aria-autocomplete` | `"both" | "inline" | "list" | "none"` | No | | Indicates the type of autocomplete interaction. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-autocomplete} |
42
+ | `aria-controls` | `string` | No | — | Indicates the element that controls the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-controls} |
43
+ | `aria-describedby` | `string` | No | — | Identifies the element (or elements) that describes the object. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-... |
44
+ | `aria-details` | `string` | No | — | Identifies the element (or elements) that provide a detailed, extended description. @see {@link https://www.w3.org/TR... |
45
+ | `aria-expanded` | `Booleanish` | No | — | Indicates whether the element is expanded or collapsed. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-expanded} |
46
+ | `aria-label` | `string` | No | — | Defines a string value that labels the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-label} |
47
+ | `aria-labelledby` | `string` | No | — | Identifies the element (or elements) that labels the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/... |
48
+ | `aria-required` | `Booleanish` | No | — | Indicates that user input is required before form submission. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-re... |
49
+ | `autoComplete` | `string` | No | — | Autocomplete behavior for the input (React casing, string values only). Use standard HTML autocomplete values or "on"... |
50
+ | `autoFocus` | `boolean` | No | — | Whether the input should be auto-focused (React casing). |
51
+ | `clearable` | `Clearable` | No | — | Add a clear action on the input that clears the value. |
47
52
  | `description` | `ReactNode` | No | — | Further description of the input, can be used for a hint. |
48
- | `disabled` | `boolean` | No | — | Disable the input |
49
- | `id` | `string` | No | — | A unique identifier for the input. |
50
- | `inline` | `boolean` | No | — | Adjusts the form field to go inline with a content. This also silences the given `validations` prop. You'd have to us... |
51
- | `inputRef` | `RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>` | No | | |
53
+ | `disabled` | `boolean` | No | — | Whether the input is disabled. |
54
+ | `error` | `string` | No | — | Error message to display. This also highlights the field red. |
55
+ | `id` | `string` | No | — | The unique identifier for the input element. |
56
+ | `inline` | `boolean` | No | | Adjusts the form field to go inline with content. |
57
+ | `inputMode` | `"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url"` | No | — | Input mode hint for virtual keyboards. |
58
+ | `inputRef` | `Ref<HTMLInputElement>` | No | — | |
52
59
  | `invalid` | `boolean` | No | — | Highlights the field red to indicate an error. |
53
- | `loading` | `boolean` | No | — | Show a spinner to indicate loading |
54
- | `max` | `number` | No | — | Specifies the maximum numerical or date value that a user can type |
55
- | `maxLength` | `number` | No | — | Maximum character length for an input. This also changes the width to roughly the same size as the max length. This i... |
56
- | `min` | `number` | No | — | Specifies the minimum numerical or date value that a user can type |
57
- | `name` | `string` | No | — | Name of the input. |
58
- | `onBlur` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Blur callback. |
60
+ | `loading` | `boolean` | No | — | Show a spinner to indicate loading. |
61
+ | `max` | `number` | No | — | Maximum numerical or date value. |
62
+ | `min` | `number` | No | — | Minimum numerical or date value. |
63
+ | `name` | `string` | No | — | The name attribute for the input element. |
64
+ | `onBlur` | `(event: FocusEvent<HTMLInputElement, Element>) => void` | No | — | Blur event handler. |
59
65
  | `onChange` | `(newValue?: Date) => void` | No | — | Function called when user changes input value. |
60
- | `onEnter` | `(event: KeyboardEvent<Element>) => void` | No | — | A callback to handle "Enter" keypress. This will only run if Enter is the only key. Will not run if Shift or Control ... |
61
- | `onFocus` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Focus callback. |
62
- | `onValidation` | `(message: string) => void` | No | — | Callback to get the the status and message when validating a field @param message |
66
+ | `onClick` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Click event handler. |
67
+ | `onEnter` | `(event: KeyboardEvent<Element>) => void` | No | — | @deprecated Use `onKeyDown` or `onKeyUp` instead. |
68
+ | `onFocus` | `(event: FocusEvent<HTMLInputElement, Element>) => void` | No | — | Focus event handler. |
69
+ | `onKeyDown` | `(event: KeyboardEvent<HTMLInputElement>) => void` | No | — | Key down event handler. |
70
+ | `onKeyUp` | `(event: KeyboardEvent<HTMLInputElement>) => void` | No | — | Key up event handler. |
71
+ | `onMouseDown` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Mouse down event handler. |
72
+ | `onMouseUp` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Mouse up event handler. |
73
+ | `onPointerDown` | `(event: PointerEvent<HTMLInputElement>) => void` | No | — | Pointer down event handler. |
74
+ | `onPointerUp` | `(event: PointerEvent<HTMLInputElement>) => void` | No | — | Pointer up event handler. |
75
+ | `pattern` | `string` | No | — | Validation pattern (regex) for the input. |
63
76
  | `placeholder` | `string` | No | — | Text that appears inside the input when empty and floats above the value as a mini label once the user enters a value... |
64
- | `readonly` | `boolean` | No | — | Prevents users from editing the value. |
77
+ | `prefix` | `Affix` | No | — | Adds a prefix label and icon to the field. |
78
+ | `readOnly` | `boolean` | No | — | Whether the input is read-only (HTML standard casing). |
79
+ | `required` | `boolean` | No | — | Whether the input is required before form submission. |
80
+ | `role` | `string` | No | — | Role attribute for accessibility. |
65
81
  | `size` | `"large" | "small"` | No | — | Adjusts the interface to either have small or large spacing. |
66
- | `validations` | `RegisterOptions` | No | | Show an error message above the field. This also highlights the the field red if an error message shows up. |
82
+ | `step` | `number` | No | `60` | Granularity of the time input, in seconds. Matches the native HTML `step` attribute. Defaults to `60` so the input di... |
83
+ | `suffix` | `{ onClick: () => void; readonly ariaLabel: string; readonly icon: IconNames; readonly label?: string; } | { onClick?: never; ariaLabel?: never; readonly label?: string; readonly icon?: IconNames; }` | No | — | Adds a suffix label and icon with an optional action to the field. |
84
+ | `tabIndex` | `number` | No | — | Tab index for keyboard navigation. |
67
85
  | `value` | `Date` | No | — | Set the component to the given value. |
@@ -16,7 +16,6 @@ deprecated.
16
16
  | Autocomplete | `import { Autocomplete } from "@jobber/components/Autocomplete"` | `version={2}` — fully controlled, async support |
17
17
  | InputNumber | `import { InputNumber } from "@jobber/components/InputNumber"` | `version={2}` |
18
18
  | InputText | `import { InputText } from "@jobber/components/InputText"` | `version={2}` |
19
- | InputTime | `import { InputTime } from "@jobber/components/InputTime"` | `version={2}` |
20
19
  | Modal | `import { Modal } from "@jobber/components/Modal"` | `version={2}` — uses `Modal.Provider` composition |
21
20
 
22
21
  ## Deprecated components — do not use
package/dist/index.cjs CHANGED
@@ -44,7 +44,7 @@ var Flex = require('./Flex-cjs.js');
44
44
  var Form = require('./Form-cjs.js');
45
45
  var FormField = require('./FormField-cjs.js');
46
46
  var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
47
- var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
47
+ var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
48
48
  var FormatDate = require('./FormatDate-cjs.js');
49
49
  var FormatEmail = require('./FormatEmail-cjs.js');
50
50
  var FormatFile = require('./FormatFile-cjs.js');
@@ -65,7 +65,7 @@ var InputNumber_index = require('./InputNumber/index.cjs');
65
65
  var InputPassword = require('./InputPassword-cjs.js');
66
66
  var InputPhoneNumber = require('./InputPhoneNumber-cjs.js');
67
67
  var InputText_index = require('./InputText/index.cjs');
68
- var InputTime_index = require('./InputTime/index.cjs');
68
+ var InputTime = require('./InputTime-cjs.js');
69
69
  var InputValidation = require('./InputValidation-cjs.js');
70
70
  var LightBox = require('./LightBox-cjs.js');
71
71
  var Link = require('./Link-cjs.js');
@@ -180,7 +180,7 @@ require('./DataListAction-cjs.js');
180
180
  require('./DataListLayoutActions-cjs.js');
181
181
  require('./DataListStatusBar-cjs.js');
182
182
  require('./clsx-cjs.js');
183
- require('./omit-cjs.js');
183
+ require('./FormFieldPostFix-cjs.js');
184
184
  require('./useFormFieldFocus-cjs.js');
185
185
  require('filesize');
186
186
  require('./GridCell-cjs.js');
@@ -266,15 +266,15 @@ exports.useAtlantisFormField = FormField.useAtlantisFormField;
266
266
  exports.useAtlantisFormFieldActions = FormField.useAtlantisFormFieldActions;
267
267
  exports.useAtlantisReactHookForm = FormField.useAtlantisReactHookForm;
268
268
  exports.useAtlantisFormFieldName = useAtlantisFormFieldName.useAtlantisFormFieldName;
269
- exports.AffixIcon = FormFieldPostFix.AffixIcon;
270
- exports.AffixLabel = FormFieldPostFix.AffixLabel;
271
- exports.FormFieldInputHorizontalWrapper = FormFieldPostFix.FormFieldInputHorizontalWrapper;
272
- exports.FormFieldInputWrapperStyles = FormFieldPostFix.FormFieldInputWrapperStyles;
273
- exports.FormFieldLabel = FormFieldPostFix.FormFieldLabel;
274
- exports.FormFieldWrapper = FormFieldPostFix.FormFieldWrapper;
275
- exports.FormFieldWrapperMain = FormFieldPostFix.FormFieldWrapperMain;
276
- exports.FormFieldWrapperToolbar = FormFieldPostFix.FormFieldWrapperToolbar;
277
- exports.useFormFieldWrapperStyles = FormFieldPostFix.useFormFieldWrapperStyles;
269
+ exports.AffixIcon = FormFieldWrapper.AffixIcon;
270
+ exports.AffixLabel = FormFieldWrapper.AffixLabel;
271
+ exports.FormFieldInputHorizontalWrapper = FormFieldWrapper.FormFieldInputHorizontalWrapper;
272
+ exports.FormFieldInputWrapperStyles = FormFieldWrapper.FormFieldInputWrapperStyles;
273
+ exports.FormFieldLabel = FormFieldWrapper.FormFieldLabel;
274
+ exports.FormFieldWrapper = FormFieldWrapper.FormFieldWrapper;
275
+ exports.FormFieldWrapperMain = FormFieldWrapper.FormFieldWrapperMain;
276
+ exports.FormFieldWrapperToolbar = FormFieldWrapper.FormFieldWrapperToolbar;
277
+ exports.useFormFieldWrapperStyles = FormFieldWrapper.useFormFieldWrapperStyles;
278
278
  exports.FormatDate = FormatDate.FormatDate;
279
279
  exports.strFormatDate = FormatDate.strFormatDate;
280
280
  exports.FormatEmail = FormatEmail.FormatEmail;
@@ -303,7 +303,7 @@ exports.InputNumber = InputNumber_index.InputNumber;
303
303
  exports.InputPassword = InputPassword.InputPassword;
304
304
  exports.InputPhoneNumber = InputPhoneNumber.InputPhoneNumber;
305
305
  exports.InputText = InputText_index.InputText;
306
- exports.InputTime = InputTime_index.InputTime;
306
+ exports.InputTime = InputTime.InputTime;
307
307
  exports.InputValidation = InputValidation.InputValidation;
308
308
  exports.LightBox = LightBox.LightBox;
309
309
  exports.useLightBoxContext = LightBox.useLightBoxContext;
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ export { F as Flex } from './Flex-es.js';
42
42
  export { F as Form } from './Form-es.js';
43
43
  export { F as FormField, u as useAtlantisFormField, a as useAtlantisFormFieldActions, b as useAtlantisReactHookForm } from './FormField-es.js';
44
44
  export { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
45
- export { A as AffixIcon, f as AffixLabel, F as FormFieldInputHorizontalWrapper, a as FormFieldInputWrapperStyles, b as FormFieldLabel, c as FormFieldWrapper, d as FormFieldWrapperMain, e as FormFieldWrapperToolbar, u as useFormFieldWrapperStyles } from './FormFieldPostFix-es.js';
45
+ export { A as AffixIcon, f as AffixLabel, F as FormFieldInputHorizontalWrapper, a as FormFieldInputWrapperStyles, b as FormFieldLabel, c as FormFieldWrapper, d as FormFieldWrapperMain, e as FormFieldWrapperToolbar, u as useFormFieldWrapperStyles } from './FormFieldWrapper-es.js';
46
46
  export { F as FormatDate, s as strFormatDate } from './FormatDate-es.js';
47
47
  export { F as FormatEmail } from './FormatEmail-es.js';
48
48
  export { F as FormatFile, u as useFormatFile, a as useFormatFileStyles } from './FormatFile-es.js';
@@ -63,7 +63,7 @@ export { InputNumber } from './InputNumber/index.mjs';
63
63
  export { I as InputPassword } from './InputPassword-es.js';
64
64
  export { I as InputPhoneNumber } from './InputPhoneNumber-es.js';
65
65
  export { InputText } from './InputText/index.mjs';
66
- export { InputTime } from './InputTime/index.mjs';
66
+ export { I as InputTime } from './InputTime-es.js';
67
67
  export { I as InputValidation } from './InputValidation-es.js';
68
68
  export { L as LightBox, u as useLightBoxContext } from './LightBox-es.js';
69
69
  export { L as Link } from './Link-es.js';
@@ -178,7 +178,7 @@ import './DataListAction-es.js';
178
178
  import './DataListLayoutActions-es.js';
179
179
  import './DataListStatusBar-es.js';
180
180
  import './clsx-es.js';
181
- import './omit-es.js';
181
+ import './FormFieldPostFix-es.js';
182
182
  import './useFormFieldFocus-es.js';
183
183
  import 'filesize';
184
184
  import './GridCell-es.js';
@@ -586,4 +586,4 @@ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedA
586
586
 
587
587
  var isTypedArray_1 = isTypedArray;
588
588
 
589
- export { _isPrototype as _, isArray_1 as a, isArrayLike_1 as b, isBufferExports as c, isTypedArray_1 as d, _overArg as e, _getNative as f, _Map as g, _toSource as h, isArguments_1 as i, isFunction_1 as j, _baseUnary as k, _nodeUtilExports as l, isLength_1 as m };
589
+ export { _isPrototype as _, isArray_1 as a, isArrayLike_1 as b, isBufferExports as c, isTypedArray_1 as d, _overArg as e, _getNative as f, _Map as g, _toSource as h, isArguments_1 as i, isFunction_1 as j, _baseUnary as k, isLength_1 as l, _nodeUtilExports as m };