@codezee/sixtify-brahma 0.2.175 → 0.2.177
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/package.json +2 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts +6 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.js +146 -11
- package/packages/shared-components/dist/FormFields/CheckBox/CheckBox.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/CheckBox/CheckBox.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/CheckBox/CheckBox.js +23 -6
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.js +14 -5
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.js +14 -5
- package/packages/shared-components/dist/FormFields/DecimalTextField/DecimalTextField.d.ts +18 -0
- package/packages/shared-components/dist/FormFields/DecimalTextField/DecimalTextField.d.ts.map +1 -0
- package/packages/shared-components/dist/FormFields/DecimalTextField/DecimalTextField.js +227 -0
- package/packages/shared-components/dist/FormFields/DecimalTextField/index.d.ts +2 -0
- package/packages/shared-components/dist/FormFields/DecimalTextField/index.d.ts.map +1 -0
- package/packages/shared-components/dist/FormFields/DecimalTextField/index.js +17 -0
- package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.js +1 -1
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/ImageUpload/ImageUpload.js +3 -1
- package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/PhoneInputField/PhoneInputField.js +7 -3
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/RadioGroupField/RadioGroupField.js +34 -14
- package/packages/shared-components/dist/FormFields/Rating/Ratting.js +1 -1
- package/packages/shared-components/dist/FormFields/Select/Select.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/Select/Select.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/Select/Select.js +12 -6
- package/packages/shared-components/dist/FormFields/SwitchField/SwitchField.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/SwitchField/SwitchField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/SwitchField/SwitchField.js +10 -4
- package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TextField/TextField.js +7 -6
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.js +6 -3
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts +3 -1
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.js +51 -3
- package/packages/shared-components/dist/FormFields/index.d.ts +1 -0
- package/packages/shared-components/dist/FormFields/index.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/index.js +1 -0
- package/packages/shared-components/dist/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/packages/shared-components/dist/SmartGrid/Components/TableRowComponent.js +2 -2
- package/packages/shared-components/dist/utils/context/NavigationKeyContext.d.ts +13 -0
- package/packages/shared-components/dist/utils/context/NavigationKeyContext.d.ts.map +1 -0
- package/packages/shared-components/dist/utils/context/NavigationKeyContext.js +15 -0
- package/packages/shared-components/dist/utils/context/index.d.ts +2 -0
- package/packages/shared-components/dist/utils/context/index.d.ts.map +1 -0
- package/packages/shared-components/dist/utils/context/index.js +6 -0
- package/packages/shared-components/dist/utils/hooks/useFormFieldFocus.d.ts +8 -1
- package/packages/shared-components/dist/utils/hooks/useFormFieldFocus.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/hooks/useFormFieldFocus.js +94 -2
- package/packages/shared-components/dist/utils/index.d.ts +3 -2
- package/packages/shared-components/dist/utils/index.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/index.js +3 -2
- package/packages/shared-components/dist/utils/regex.d.ts +1 -0
- package/packages/shared-components/dist/utils/regex.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/regex.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codezee/sixtify-brahma",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.177",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
|
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
"react-date-range": "^2.0.1",
|
|
134
134
|
"react-i18next": "^14.1.2",
|
|
135
135
|
"react-multi-carousel": "^2.8.5",
|
|
136
|
+
"react-number-format": "^5.4.4",
|
|
136
137
|
"react-phone-input-2": "^2.15.1",
|
|
137
138
|
"react-syntax-highlighter": "^16.1.0",
|
|
138
139
|
"react-toastify": "^10.0.5",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AutocompleteValue, AutocompleteProps as MuiAutocompleteProps, StackProps } from "@mui/material";
|
|
2
2
|
import { type ControllerRenderProps, type FieldValues, type UseControllerProps, type UseFormSetValue } from "react-hook-form";
|
|
3
|
+
import { type NavigationKey } from "../../utils/hooks/useFormFieldFocus";
|
|
3
4
|
import type { OnAction } from "../../utils/types";
|
|
4
5
|
export type Option = {
|
|
5
6
|
heading?: string;
|
|
@@ -19,6 +20,9 @@ export type AutocompleteProps<P extends FieldValues> = UseControllerProps<P> & O
|
|
|
19
20
|
placeholder?: string;
|
|
20
21
|
isShowAvatar?: boolean;
|
|
21
22
|
shouldCloseOnSelect?: boolean;
|
|
23
|
+
actionInsideAutocomplete?: boolean;
|
|
24
|
+
actionIcon?: React.ReactNode;
|
|
25
|
+
onActionClick?: () => void;
|
|
22
26
|
onAction?: OnAction;
|
|
23
27
|
isShowSelectAll?: boolean;
|
|
24
28
|
isShowOptionsOnType?: boolean;
|
|
@@ -34,7 +38,8 @@ export type AutocompleteProps<P extends FieldValues> = UseControllerProps<P> & O
|
|
|
34
38
|
setValue?: UseFormSetValue<P>;
|
|
35
39
|
containerProps?: StackProps;
|
|
36
40
|
styling?: "custom" | "default";
|
|
41
|
+
navigationKey?: NavigationKey;
|
|
37
42
|
customOnChange?: (selected: any) => void;
|
|
38
43
|
};
|
|
39
|
-
export declare function Autocomplete<P extends FieldValues>({ control, defaultValue, name, required, label, multiple, disabled, options, rules, loading, helperText, error, withLabel, placeholder, freeSolo, isShowOptionsOnType, isShowSelectAll, isShowAvatar, isShowEmployeeData, shouldCloseOnSelect, onAction, renderOption, getOptionLabel, maxLimit, autoFocus, defaultOption, disableClearable, containerProps, setValue, limitTags, styling, customOnChange, ...restProps }: AutocompleteProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare function Autocomplete<P extends FieldValues>({ control, defaultValue, name, required, label, multiple, disabled, options, rules, loading, helperText, error, withLabel, placeholder, freeSolo, isShowOptionsOnType, isShowSelectAll, isShowAvatar, isShowEmployeeData, shouldCloseOnSelect, actionInsideAutocomplete, actionIcon, onActionClick, onAction, renderOption, getOptionLabel, maxLimit, autoFocus, defaultOption, disableClearable, containerProps, setValue, limitTags, styling, navigationKey, customOnChange, ...restProps }: AutocompleteProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
40
45
|
//# sourceMappingURL=Autocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"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"}
|
|
@@ -27,7 +27,7 @@ const commonStyles_1 = require("../commonStyles");
|
|
|
27
27
|
const ChipV2_styled_1 = require("./ChipV2.styled");
|
|
28
28
|
const Skeleton_1 = require("./Skeleton");
|
|
29
29
|
const Tags_1 = require("./Tags");
|
|
30
|
-
function Autocomplete({ control, defaultValue, name, required = false, label, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, withLabel = false, placeholder = "", freeSolo, isShowOptionsOnType = false, isShowSelectAll = true, isShowAvatar = false, isShowEmployeeData = false, shouldCloseOnSelect = false, onAction, renderOption, getOptionLabel, maxLimit, autoFocus = false, defaultOption, disableClearable = required ? true : false, containerProps, setValue, limitTags = 0, styling = "custom", customOnChange, ...restProps }) {
|
|
30
|
+
function Autocomplete({ control, defaultValue, name, required = false, label, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, withLabel = false, placeholder = "", freeSolo, isShowOptionsOnType = false, isShowSelectAll = true, isShowAvatar = false, isShowEmployeeData = false, shouldCloseOnSelect = false, actionInsideAutocomplete = false, actionIcon, onActionClick, onAction, renderOption, getOptionLabel, maxLimit, autoFocus = false, defaultOption, disableClearable = required ? true : false, containerProps, setValue, limitTags = 0, styling = "custom", navigationKey = "tab", customOnChange, ...restProps }) {
|
|
31
31
|
const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
|
|
32
32
|
name,
|
|
33
33
|
control,
|
|
@@ -40,13 +40,16 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
40
40
|
const { open: controlledOpen, onOpen: externalOnOpen, onClose: externalOnClose, ...restMuiProps } = restProps;
|
|
41
41
|
const isControlledOpen = controlledOpen !== undefined;
|
|
42
42
|
const internalOpen = isControlledOpen ? controlledOpen : open;
|
|
43
|
-
const { setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown } = (0, useFormFieldFocus_1.useFormFieldFocus)(internalOpen);
|
|
43
|
+
const { inputRef, setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown, handleEnterNavigation, } = (0, useFormFieldFocus_1.useFormFieldFocus)({ isOpen: internalOpen, navigationKey });
|
|
44
44
|
const handleOpen = (0, react_1.useCallback)((event) => {
|
|
45
45
|
if (!isControlledOpen) {
|
|
46
46
|
setOpen(true);
|
|
47
47
|
}
|
|
48
48
|
externalOnOpen?.(event);
|
|
49
|
-
|
|
49
|
+
if (inputRef.current) {
|
|
50
|
+
inputRef.current.blur();
|
|
51
|
+
}
|
|
52
|
+
}, [isControlledOpen, externalOnOpen, inputRef]);
|
|
50
53
|
const handleClose = (0, react_1.useCallback)((event, reason) => {
|
|
51
54
|
if (!isControlledOpen) {
|
|
52
55
|
setOpen(false);
|
|
@@ -218,7 +221,35 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
218
221
|
borderRadius: "50%",
|
|
219
222
|
},
|
|
220
223
|
width: "100%",
|
|
221
|
-
}, open: internalOpen, onOpen: handleOpen, onClose: handleClose, disableCloseOnSelect: multiple || !shouldCloseOnSelect, disabled: disabled, freeSolo: freeSolo, ...restMuiProps, ...restField, disableClearable: disableClearable,
|
|
224
|
+
}, open: internalOpen, onOpen: handleOpen, onClose: handleClose, disableCloseOnSelect: multiple || !shouldCloseOnSelect, disabled: disabled, freeSolo: freeSolo, ...restMuiProps, ...restField, disableClearable: disableClearable, slotProps: {
|
|
225
|
+
clearIndicator: {
|
|
226
|
+
tabIndex: disableClearable ||
|
|
227
|
+
(multiple
|
|
228
|
+
? !Array.isArray(value) || value.length === 0
|
|
229
|
+
: !value || value === "")
|
|
230
|
+
? -1
|
|
231
|
+
: 0,
|
|
232
|
+
onKeyDown: (event) => {
|
|
233
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
234
|
+
handleEnterNavigation(event);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
onMouseDown: (event) => {
|
|
238
|
+
event.stopPropagation();
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
popupIndicator: {
|
|
242
|
+
tabIndex: disabled ? -1 : 0,
|
|
243
|
+
onKeyDown: (event) => {
|
|
244
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
245
|
+
handleEnterNavigation(event);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
onMouseDown: (event) => {
|
|
249
|
+
event.stopPropagation();
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
}, renderTags: (value, getTagProps) => {
|
|
222
253
|
const visibleTags = limitTags ? value.slice(0, limitTags) : value;
|
|
223
254
|
const hiddenCount = value.length - visibleTags.length;
|
|
224
255
|
const hiddenTags = limitTags ? value.slice(limitTags) : value;
|
|
@@ -242,7 +273,9 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
242
273
|
borderColor: color.butterflyBlue[900],
|
|
243
274
|
},
|
|
244
275
|
} })), !isSelectAll && isShowEmployeeData ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { sx: { width: 25, height: 25 }, src: avatar, alt: label }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: `${label} (${punch_code ?? "-"})` }), employee_code && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: color.iron[800], children: employee_code }))] })] })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { children: label }))] }), isSelectAll && (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { width: "280px" } })] }) }, key));
|
|
245
|
-
},
|
|
276
|
+
},
|
|
277
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
278
|
+
renderInput: (params) => {
|
|
246
279
|
let startAdornment = params.InputProps.startAdornment;
|
|
247
280
|
if (!multiple && selectedValue?.avatar && getOptionLabel) {
|
|
248
281
|
startAdornment = ((0, jsx_runtime_1.jsx)(material_1.Box, { width: "20px", marginLeft: "10px", children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: selectedValue.avatar, alt: selectedValue.label, sx: { width: 24, height: 24 } }) }));
|
|
@@ -253,10 +286,107 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
253
286
|
}
|
|
254
287
|
return placeholder || `Select ${label}`;
|
|
255
288
|
};
|
|
256
|
-
|
|
289
|
+
let endAdornment = params.InputProps.endAdornment;
|
|
290
|
+
if (actionInsideAutocomplete && (onActionClick || onAction)) {
|
|
291
|
+
const handleActionClick = (event) => {
|
|
292
|
+
event.stopPropagation();
|
|
293
|
+
onActionClick?.();
|
|
294
|
+
onAction?.();
|
|
295
|
+
};
|
|
296
|
+
const handleMouseDown = (event) => {
|
|
297
|
+
event.stopPropagation();
|
|
298
|
+
};
|
|
299
|
+
const handleKeyDown = (event) => {
|
|
300
|
+
if (![
|
|
301
|
+
"Enter",
|
|
302
|
+
" ",
|
|
303
|
+
"ArrowRight",
|
|
304
|
+
"ArrowLeft",
|
|
305
|
+
"ArrowUp",
|
|
306
|
+
"ArrowDown",
|
|
307
|
+
].includes(event.key)) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
inputRef.current?.focus();
|
|
311
|
+
if (navigationKey === "enter") {
|
|
312
|
+
if (event.key === " ") {
|
|
313
|
+
event.stopPropagation();
|
|
314
|
+
event.preventDefault();
|
|
315
|
+
onActionClick?.();
|
|
316
|
+
onAction?.();
|
|
317
|
+
}
|
|
318
|
+
else if (event.key === "Enter") {
|
|
319
|
+
handleEnterNavigation(event);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (event.key === "Enter" || event.key === " ") {
|
|
323
|
+
event.stopPropagation();
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
onActionClick?.();
|
|
326
|
+
onAction?.();
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const actionIconElement = actionIcon ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { tabIndex: disabled ? -1 : 0, onClick: handleActionClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, sx: {
|
|
330
|
+
width: "28px",
|
|
331
|
+
height: "28px",
|
|
332
|
+
margin: "0px",
|
|
333
|
+
padding: "0px",
|
|
334
|
+
}, children: actionIcon })) : ((0, jsx_runtime_1.jsx)(Actions_1.AddIconAction, { disabled: disabled, onClick: handleActionClick, onMouseDown: handleMouseDown, onKeyDown: handleKeyDown, tabIndex: disabled ? -1 : 0, "aria-label": "Add", sx: {
|
|
335
|
+
display: "flex",
|
|
336
|
+
alignItems: "center",
|
|
337
|
+
justifyContent: "center",
|
|
338
|
+
height: "28px",
|
|
339
|
+
width: "28px",
|
|
340
|
+
} }));
|
|
341
|
+
const actionAdornment = ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: {
|
|
342
|
+
maxWidth: "25px",
|
|
343
|
+
maxHeight: "25px",
|
|
344
|
+
margin: "0px",
|
|
345
|
+
padding: "0px",
|
|
346
|
+
}, children: actionIconElement }));
|
|
347
|
+
if (endAdornment) {
|
|
348
|
+
endAdornment = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [endAdornment, actionAdornment] }));
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
endAdornment = actionAdornment;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, placeholder: multiple && selectedValue?.length ? "" : getPlaceholder(), label: styling === "default" ? label : undefined, required: styling === "default" ? required : undefined, error: error, autoFocus: !multiple ? autoFocus : false, helperText: helperText, sx: {
|
|
355
|
+
...(0, commonStyles_1.getDefaultTextFieldSx)(styling),
|
|
356
|
+
"& .MuiAutocomplete-clearIndicator": {
|
|
357
|
+
visibility: "visible !important",
|
|
358
|
+
},
|
|
359
|
+
...restProps.sx,
|
|
360
|
+
}, InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling), inputRef: setInputRef, InputProps: {
|
|
257
361
|
...params.InputProps,
|
|
258
362
|
startAdornment,
|
|
363
|
+
endAdornment,
|
|
364
|
+
}, onBlur: (event) => {
|
|
365
|
+
const relatedTarget = event.relatedTarget;
|
|
366
|
+
if (relatedTarget &&
|
|
367
|
+
(relatedTarget.closest(".MuiAutocomplete-clearIndicator") ||
|
|
368
|
+
relatedTarget.closest(".MuiAutocomplete-popupIndicator") ||
|
|
369
|
+
(actionInsideAutocomplete &&
|
|
370
|
+
// eslint-disable-next-line quotes
|
|
371
|
+
(relatedTarget.closest('[role="button"]') ||
|
|
372
|
+
relatedTarget.closest(".MuiIconButton-root"))))) {
|
|
373
|
+
event.preventDefault();
|
|
374
|
+
}
|
|
259
375
|
}, onKeyDown: (event) => {
|
|
376
|
+
if (internalOpen && event.key === "Tab") {
|
|
377
|
+
const input = event.currentTarget.querySelector("input");
|
|
378
|
+
if (input) {
|
|
379
|
+
input.blur();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (navigationKey === "enter" &&
|
|
383
|
+
event.key === "Enter" &&
|
|
384
|
+
!internalOpen) {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
event.stopPropagation();
|
|
387
|
+
handleEnterNavigation(event);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
260
390
|
handleKeyDown(event, () => {
|
|
261
391
|
if (!isControlledOpen) {
|
|
262
392
|
setOpen(false);
|
|
@@ -285,7 +415,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
285
415
|
if (withLabel) {
|
|
286
416
|
onChange(newValue);
|
|
287
417
|
formatValueForCustomOnChange(newValue, false);
|
|
288
|
-
if (shouldCloseOnSelect || !multiple) {
|
|
418
|
+
if ((shouldCloseOnSelect || !multiple) && !internalOpen) {
|
|
289
419
|
maintainFocus();
|
|
290
420
|
}
|
|
291
421
|
return;
|
|
@@ -314,7 +444,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
314
444
|
}
|
|
315
445
|
onChange(mergedValues);
|
|
316
446
|
formatValueForCustomOnChange(newValue, true, mergedValues);
|
|
317
|
-
if (shouldCloseOnSelect) {
|
|
447
|
+
if (shouldCloseOnSelect && !internalOpen) {
|
|
318
448
|
maintainFocus();
|
|
319
449
|
}
|
|
320
450
|
return;
|
|
@@ -322,7 +452,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
322
452
|
if (typeof newValue === "string") {
|
|
323
453
|
onChange(newValue ?? null);
|
|
324
454
|
formatValueForCustomOnChange(newValue, false);
|
|
325
|
-
if (shouldCloseOnSelect || !multiple) {
|
|
455
|
+
if ((shouldCloseOnSelect || !multiple) && !internalOpen) {
|
|
326
456
|
maintainFocus();
|
|
327
457
|
}
|
|
328
458
|
return;
|
|
@@ -331,7 +461,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
331
461
|
onChange(finalValue);
|
|
332
462
|
formatValueForCustomOnChange(newValue, false);
|
|
333
463
|
setLastSelectedValue(finalValue);
|
|
334
|
-
if (shouldCloseOnSelect || !multiple) {
|
|
464
|
+
if ((shouldCloseOnSelect || !multiple) && !internalOpen) {
|
|
335
465
|
maintainFocus();
|
|
336
466
|
}
|
|
337
467
|
}, groupBy: (option) => option.heading ?? "", renderGroup: (params) => {
|
|
@@ -343,5 +473,10 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
343
473
|
if (!multiple) {
|
|
344
474
|
setInputValue("");
|
|
345
475
|
}
|
|
346
|
-
}, autoHighlight: true }), onAction &&
|
|
476
|
+
}, autoHighlight: true }), onAction &&
|
|
477
|
+
!actionInsideAutocomplete &&
|
|
478
|
+
(onActionClick ? ((0, jsx_runtime_1.jsx)(Actions_1.EditIconAction, { disabled: disabled, onClick: () => {
|
|
479
|
+
onActionClick();
|
|
480
|
+
onAction();
|
|
481
|
+
} })) : ((0, jsx_runtime_1.jsx)(Actions_1.EditIconAction, { disabled: disabled, onClick: onAction })))] })] }));
|
|
347
482
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type CheckboxProps as MuiCheckboxProps } from "@mui/material/Checkbox";
|
|
2
2
|
import type { ChangeEvent } from "react";
|
|
3
3
|
import { type ControllerRenderProps, type FieldValues, type UseControllerProps } from "react-hook-form";
|
|
4
|
+
import { type NavigationKey } from "../../utils/hooks/useFormFieldFocus";
|
|
4
5
|
export type CheckBoxProps<P extends FieldValues> = UseControllerProps<P> & Omit<Omit<MuiCheckboxProps, "checked">, keyof ControllerRenderProps<P>> & {
|
|
5
6
|
loading?: boolean;
|
|
6
7
|
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
7
8
|
checked?: boolean;
|
|
9
|
+
navigationKey?: NavigationKey;
|
|
8
10
|
};
|
|
9
|
-
export declare function CheckBox<P extends FieldValues>({ name, rules, control, defaultValue, size, loading, ...restCheckBoxProps }: CheckBoxProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function CheckBox<P extends FieldValues>({ name, rules, control, defaultValue, size, loading, navigationKey, ...restCheckBoxProps }: CheckBoxProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
//# sourceMappingURL=CheckBox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBox.d.ts","sourceRoot":"","sources":["../../../src/FormFields/CheckBox/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAiB,EACf,KAAK,aAAa,IAAI,gBAAgB,EACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"CheckBox.d.ts","sourceRoot":"","sources":["../../../src/FormFields/CheckBox/CheckBox.tsx"],"names":[],"mappings":"AAAA,OAAiB,EACf,KAAK,aAAa,IAAI,gBAAgB,EACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,OAAO,CAAC;AACxD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACtE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEJ,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,EAC9C,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,OAAe,EACf,aAAqB,EACrB,GAAG,iBAAiB,EACrB,EAAE,aAAa,CAAC,CAAC,CAAC,2CAkDlB"}
|
|
@@ -7,17 +7,34 @@ exports.CheckBox = CheckBox;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const Checkbox_1 = __importDefault(require("@mui/material/Checkbox"));
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
-
const
|
|
10
|
+
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
11
11
|
const CheckBox_styled_1 = require("./CheckBox.styled");
|
|
12
12
|
const Skeleton_1 = require("./Skeleton");
|
|
13
|
-
function CheckBox({ name, rules, control, defaultValue, size, loading = false, ...restCheckBoxProps }) {
|
|
14
|
-
const { field: { value = false, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
15
|
-
const { maintainFocus } = (0,
|
|
13
|
+
function CheckBox({ name, rules, control, defaultValue, size, loading = false, navigationKey = "tab", ...restCheckBoxProps }) {
|
|
14
|
+
const { field: { value = false, onChange, ref, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
15
|
+
const { inputRef, maintainFocus, handleKeyDown: handleNavigationKeyDown, } = (0, useFormFieldFocus_1.useFormFieldFocus)({ navigationKey });
|
|
16
|
+
const handleKeyDown = (event) => {
|
|
17
|
+
handleNavigationKeyDown(event, undefined, false);
|
|
18
|
+
if (restCheckBoxProps.onKeyDown) {
|
|
19
|
+
restCheckBoxProps.onKeyDown(event);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const handleInputRef = (el) => {
|
|
23
|
+
inputRef.current = el;
|
|
24
|
+
if (ref) {
|
|
25
|
+
if (typeof ref === "function") {
|
|
26
|
+
ref(el);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
ref.current = el;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
16
33
|
if (loading) {
|
|
17
34
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {});
|
|
18
35
|
}
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBox_styled_1.BoxStyled, { size: size }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_styled_1.CheckStyled, { size: size }), checked: value, onChange: (event) => {
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(Checkbox_1.default, { icon: (0, jsx_runtime_1.jsx)(CheckBox_styled_1.BoxStyled, { size: size }), checkedIcon: (0, jsx_runtime_1.jsx)(CheckBox_styled_1.CheckStyled, { size: size }), checked: value, inputRef: handleInputRef, onChange: (event) => {
|
|
20
37
|
onChange(event.target.checked);
|
|
21
38
|
maintainFocus();
|
|
22
|
-
}, ...restField, ...restCheckBoxProps }));
|
|
39
|
+
}, onKeyDown: handleKeyDown, ...restField, ...restCheckBoxProps }));
|
|
23
40
|
}
|
|
@@ -3,6 +3,7 @@ import type { DatePickerProps as MuiDatePickerProps } from "@mui/x-date-pickers/
|
|
|
3
3
|
import type { DateView, PickerValidDate } from "@mui/x-date-pickers/models";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import type { FieldError, FieldValues, UseControllerProps } from "react-hook-form";
|
|
6
|
+
import { type NavigationKey } from "../../utils/hooks/useFormFieldFocus";
|
|
6
7
|
export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & MuiDatePickerProps<PickerValidDate> & Partial<{
|
|
7
8
|
label?: string;
|
|
8
9
|
required: boolean;
|
|
@@ -21,6 +22,7 @@ export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & Mui
|
|
|
21
22
|
}) => void;
|
|
22
23
|
containerProps?: StackProps;
|
|
23
24
|
styling?: "custom" | "default";
|
|
25
|
+
navigationKey?: NavigationKey;
|
|
24
26
|
}>;
|
|
25
27
|
export declare const dateFormats: {
|
|
26
28
|
dateWithISO8601: string;
|
|
@@ -28,5 +30,5 @@ export declare const dateFormats: {
|
|
|
28
30
|
};
|
|
29
31
|
export declare const LeftArrowIcon: React.FC;
|
|
30
32
|
export declare const RightArrowIcon: React.FC;
|
|
31
|
-
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, setOnFinalChange, views, format, containerProps, styling, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, setOnFinalChange, views, format, containerProps, styling, navigationKey, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
32
34
|
//# sourceMappingURL=DatePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAO7C,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACxE,kBAAkB,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;IACV,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC,CAAC;AAEL,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAclC,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,SAAmC,EACnC,KAAK,EACL,oBAA4B,EAC5B,gBAAwB,EACxB,KAAgC,EAChC,MAAqC,EACrC,cAAc,EACd,OAAkB,EAClB,aAAqB,EACrB,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CAkOpB"}
|
|
@@ -15,7 +15,7 @@ const luxon_1 = require("luxon");
|
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const react_hook_form_1 = require("react-hook-form");
|
|
17
17
|
const Actions_1 = require("../../Actions");
|
|
18
|
-
const
|
|
18
|
+
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
19
19
|
const commonStyles_1 = require("../commonStyles");
|
|
20
20
|
const Skeleton_1 = require("./Skeleton");
|
|
21
21
|
exports.dateFormats = {
|
|
@@ -42,11 +42,11 @@ const RightArrowIcon = () => {
|
|
|
42
42
|
} }));
|
|
43
43
|
};
|
|
44
44
|
exports.RightArrowIcon = RightArrowIcon;
|
|
45
|
-
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, disableKeyboardInput = false, setOnFinalChange = false, views = ["year", "month", "day"], format = exports.dateFormats.dateWithEuropean, containerProps, styling = "custom", ...restProps }) {
|
|
45
|
+
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, disableKeyboardInput = false, setOnFinalChange = false, views = ["year", "month", "day"], format = exports.dateFormats.dateWithEuropean, containerProps, styling = "custom", navigationKey = "tab", ...restProps }) {
|
|
46
46
|
const [localError, setLocalError] = (0, react_1.useState)();
|
|
47
47
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
48
48
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
49
|
-
const { setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown } = (0,
|
|
49
|
+
const { setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown, handleEnterNavigation, } = (0, useFormFieldFocus_1.useFormFieldFocus)({ isOpen: open, navigationKey });
|
|
50
50
|
const theme = (0, material_1.useTheme)();
|
|
51
51
|
const { iron, butterflyBlue, mirage } = theme.palette.app.color;
|
|
52
52
|
const finalValue = (0, react_1.useMemo)(() => {
|
|
@@ -77,7 +77,12 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
77
77
|
readOnly: disableKeyboardInput,
|
|
78
78
|
},
|
|
79
79
|
clearButton: {
|
|
80
|
-
tabIndex: -1,
|
|
80
|
+
tabIndex: clearable ? 0 : -1,
|
|
81
|
+
onKeyDown: (event) => {
|
|
82
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
83
|
+
handleEnterNavigation(event);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
81
86
|
},
|
|
82
87
|
textField: {
|
|
83
88
|
disabled,
|
|
@@ -89,7 +94,11 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
89
94
|
InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling),
|
|
90
95
|
inputRef: setInputRef,
|
|
91
96
|
InputProps: {
|
|
92
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { disabled: disabled, onClick: () => setOpen(true), showTooltip: false
|
|
97
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { disabled: disabled, onClick: () => setOpen(true), showTooltip: false, onKeyDown: (event) => {
|
|
98
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
99
|
+
handleEnterNavigation(event);
|
|
100
|
+
}
|
|
101
|
+
} })),
|
|
93
102
|
sx: {
|
|
94
103
|
"& .MuiInputAdornment-root": {
|
|
95
104
|
width: "30px",
|
|
@@ -2,6 +2,7 @@ import type { DateTimePickerProps as MuiDateTimePickerProps } from "@mui/x-date-
|
|
|
2
2
|
import type { PickerValidDate } from "@mui/x-date-pickers/models";
|
|
3
3
|
import { type ReactElement } from "react";
|
|
4
4
|
import type { FieldError, FieldValues, UseControllerProps } from "react-hook-form";
|
|
5
|
+
import { type NavigationKey } from "../../utils/hooks/useFormFieldFocus";
|
|
5
6
|
export type DateTimePickerProps<P extends FieldValues> = UseControllerProps<P> & MuiDateTimePickerProps<PickerValidDate> & Partial<{
|
|
6
7
|
label: string;
|
|
7
8
|
required: boolean;
|
|
@@ -19,6 +20,7 @@ export type DateTimePickerProps<P extends FieldValues> = UseControllerProps<P> &
|
|
|
19
20
|
message?: string;
|
|
20
21
|
}) => void;
|
|
21
22
|
styling?: "custom" | "default";
|
|
23
|
+
navigationKey?: NavigationKey;
|
|
22
24
|
}>;
|
|
23
|
-
export declare function DateTimePicker<P extends FieldValues>({ control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, format, helperIcon, toolTipText, timeStepsMinutes, styling, ...restProps }: DateTimePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function DateTimePicker<P extends FieldValues>({ control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, format, helperIcon, toolTipText, timeStepsMinutes, styling, navigationKey, ...restProps }: DateTimePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
//# sourceMappingURL=DateTimePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DateTimePicker/DateTimePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAExG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAc,EAAY,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DateTimePicker/DateTimePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,IAAI,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAExG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAc,EAAY,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAO7C,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAC5E,sBAAsB,CAAC,eAAe,CAAC,GACvC,OAAO,CAAC;IACN,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC,CAAC;AAwCL,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,EAAE,EACpD,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,SAAmC,EACnC,KAAK,EACL,MAA2B,EAC3B,UAAU,EACV,WAAW,EACX,gBAAoB,EACpB,OAAkB,EAClB,aAAqB,EACrB,GAAG,SAAS,EACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,2CAwOxB"}
|
|
@@ -13,7 +13,7 @@ const luxon_1 = require("luxon");
|
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const react_hook_form_1 = require("react-hook-form");
|
|
15
15
|
const Actions_1 = require("../../Actions");
|
|
16
|
-
const
|
|
16
|
+
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
17
17
|
const commonStyles_1 = require("../commonStyles");
|
|
18
18
|
const Skeleton_1 = require("./Skeleton");
|
|
19
19
|
const hoverTextStyle = (color) => ({
|
|
@@ -39,10 +39,10 @@ const RightArrowIcon = () => {
|
|
|
39
39
|
p: "4px",
|
|
40
40
|
} }));
|
|
41
41
|
};
|
|
42
|
-
function DateTimePicker({ control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, format = "dd-MM-yyyy HH:mm", helperIcon, toolTipText, timeStepsMinutes = 1, styling = "custom", ...restProps }) {
|
|
42
|
+
function DateTimePicker({ control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, format = "dd-MM-yyyy HH:mm", helperIcon, toolTipText, timeStepsMinutes = 1, styling = "custom", navigationKey = "tab", ...restProps }) {
|
|
43
43
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
44
44
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
45
|
-
const { setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown } = (0,
|
|
45
|
+
const { setInputRef, maintainFocus, maintainFocusAfterClose, handleKeyDown, handleEnterNavigation, } = (0, useFormFieldFocus_1.useFormFieldFocus)({ isOpen: open, navigationKey });
|
|
46
46
|
if (error && value && typeof value === "object") {
|
|
47
47
|
helperText = "Invalid time";
|
|
48
48
|
}
|
|
@@ -69,7 +69,12 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
71
|
clearButton: {
|
|
72
|
-
tabIndex: -1,
|
|
72
|
+
tabIndex: clearable ? 0 : -1,
|
|
73
|
+
onKeyDown: (event) => {
|
|
74
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
75
|
+
handleEnterNavigation(event);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
73
78
|
},
|
|
74
79
|
textField: {
|
|
75
80
|
disabled,
|
|
@@ -79,7 +84,11 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
79
84
|
required: styling === "default" ? required : undefined,
|
|
80
85
|
inputRef: setInputRef,
|
|
81
86
|
InputProps: {
|
|
82
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { showTooltip: false, disabled: disabled, onClick: () => setOpen(true)
|
|
87
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { showTooltip: false, disabled: disabled, onClick: () => setOpen(true), onKeyDown: (event) => {
|
|
88
|
+
if (navigationKey === "enter" && event.key === "Enter") {
|
|
89
|
+
handleEnterNavigation(event);
|
|
90
|
+
}
|
|
91
|
+
} })),
|
|
83
92
|
sx: {
|
|
84
93
|
"& .MuiInputAdornment-root": {
|
|
85
94
|
width: "30px",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type TextFieldProps as MuiTextFieldProps, type StackProps } from "@mui/material";
|
|
2
|
+
import type { FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
+
import { type NavigationKey } from "../../utils/hooks/useFormFieldFocus";
|
|
4
|
+
export type DecimalTextFieldProps<P extends FieldValues> = UseControllerProps<P> & Omit<MuiTextFieldProps, keyof UseControllerProps<P> | "type" | "value" | "onChange"> & {
|
|
5
|
+
label?: string;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
containerProps?: StackProps;
|
|
8
|
+
styling?: "custom" | "default";
|
|
9
|
+
infoMessage?: React.ReactNode;
|
|
10
|
+
decimalScale: number;
|
|
11
|
+
defaultFallbackValue?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
customOnChange?: (value: number) => void;
|
|
15
|
+
navigationKey?: NavigationKey;
|
|
16
|
+
};
|
|
17
|
+
export declare function DecimalTextField<P extends FieldValues>({ control, name, decimalScale, defaultFallbackValue, min, max, defaultValue, label, required, disabled, loading, placeholder, containerProps, styling, infoMessage, customOnChange, navigationKey, ...restProps }: DecimalTextFieldProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=DecimalTextField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecimalTextField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DecimalTextField/DecimalTextField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,cAAc,IAAI,iBAAiB,EACxC,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIvE,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAO7C,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,WAAW,IACrD,kBAAkB,CAAC,CAAC,CAAC,GACnB,IAAI,CACF,iBAAiB,EACjB,MAAM,kBAAkB,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAC5D,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEN,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,EAAE,EACtD,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,oBAAwB,EACxB,GAAG,EACH,GAAG,EACH,YAAY,EACZ,KAAU,EACV,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,WAAgB,EAChB,cAAc,EACd,OAAkB,EAClB,WAAW,EACX,cAAc,EACd,aAAqB,EACrB,GAAG,SAAS,EACb,EAAE,qBAAqB,CAAC,CAAC,CAAC,2CAsW1B"}
|