@codezee/sixtify-brahma 0.2.121 → 0.2.122
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 +1 -1
- package/packages/shared-components/dist/ActionButtons/ActionButtons.d.ts +3 -1
- package/packages/shared-components/dist/ActionButtons/ActionButtons.d.ts.map +1 -1
- package/packages/shared-components/dist/ActionButtons/ActionButtons.js +27 -6
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.js +22 -3
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.js +20 -3
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DateTimePicker/DateTimePicker.js +19 -2
- package/packages/shared-components/dist/FormFields/SearchField/SearchField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/SearchField/SearchField.js +12 -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 +101 -65
- package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts +3 -2
- package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TextField/TextField.js +16 -2
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts +3 -2
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TimeField/TimeField.js +19 -2
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/TimePicker/TimePicker.js +19 -2
- package/packages/shared-components/dist/utils/hooks/useGlobalKeyboardShortcut.d.ts +2 -1
- package/packages/shared-components/dist/utils/hooks/useGlobalKeyboardShortcut.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/hooks/useGlobalKeyboardShortcut.js +11 -2
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ export type ActionButtonsProps = DataProps & {
|
|
|
5
5
|
justifyContent?: StackProps["justifyContent"];
|
|
6
6
|
sx?: SxProps;
|
|
7
7
|
buttonSx?: SxProps;
|
|
8
|
+
shouldOpenMenuOnShortcut?: boolean;
|
|
9
|
+
shortcutKey?: string;
|
|
8
10
|
};
|
|
9
|
-
export declare function ActionButtons({ buttons, justifyContent, sx, buttonSx, }: ActionButtonsProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ActionButtons({ buttons, justifyContent, sx, buttonSx, shouldOpenMenuOnShortcut, shortcutKey, }: ActionButtonsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
//# sourceMappingURL=ActionButtons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButtons.d.ts","sourceRoot":"","sources":["../../src/ActionButtons/ActionButtons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionButtons.d.ts","sourceRoot":"","sources":["../../src/ActionButtons/ActionButtons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAKzD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG;IAC3C,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC9C,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,cAAsB,EACtB,EAAE,EACF,QAAQ,EACR,wBAAgC,EAChC,WAAiB,GAClB,EAAE,kBAAkB,2CA0IpB"}
|
|
@@ -8,31 +8,52 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const material_1 = require("@mui/material");
|
|
9
9
|
const noop_1 = __importDefault(require("lodash/noop"));
|
|
10
10
|
const react_1 = require("react");
|
|
11
|
-
|
|
12
|
-
function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, }) {
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOpenMenuOnShortcut = false, shortcutKey = "a", }) {
|
|
13
13
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
14
14
|
const [openMenuKey, setOpenMenuKey] = (0, react_1.useState)(null);
|
|
15
|
+
const buttonRefs = (0, react_1.useRef)({});
|
|
15
16
|
const handleMenuOpen = (event, key) => {
|
|
16
|
-
|
|
17
|
+
const element = event instanceof HTMLElement ? event : event.currentTarget;
|
|
18
|
+
setAnchorEl(element);
|
|
17
19
|
setOpenMenuKey(key);
|
|
18
20
|
};
|
|
19
21
|
const handleMenuClose = () => {
|
|
20
22
|
setAnchorEl(null);
|
|
21
23
|
setOpenMenuKey(null);
|
|
22
24
|
};
|
|
25
|
+
(0, utils_1.useGlobalKeyboardShortcut)({
|
|
26
|
+
key: shortcutKey,
|
|
27
|
+
modifierKeys: ["ctrl", "alt"],
|
|
28
|
+
onTrigger: () => {
|
|
29
|
+
if (shouldOpenMenuOnShortcut) {
|
|
30
|
+
const buttonWithMenu = buttons.find((button) => !!button.menuItems?.length && !button.hidden);
|
|
31
|
+
if (buttonWithMenu) {
|
|
32
|
+
const buttonElement = buttonRefs.current[buttonWithMenu.key];
|
|
33
|
+
if (buttonElement) {
|
|
34
|
+
handleMenuOpen(buttonElement, buttonWithMenu.key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
});
|
|
23
40
|
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", sx: sx, gap: "1.6rem", justifyContent: justifyContent, children: buttons
|
|
24
41
|
.filter((button) => !button.hidden)
|
|
25
42
|
.map(({ menuItems, key, ...button }) => {
|
|
26
43
|
const visibleMenuItems = menuItems?.filter((menuItem) => !menuItem.hidden);
|
|
27
|
-
const isMenuOpen = openMenuKey ===
|
|
44
|
+
const isMenuOpen = openMenuKey === key;
|
|
28
45
|
const onClick = visibleMenuItems && visibleMenuItems.length > 0
|
|
29
|
-
? (e) => handleMenuOpen(e,
|
|
46
|
+
? (e) => handleMenuOpen(e, key)
|
|
30
47
|
: (button.onClick ?? noop_1.default);
|
|
31
48
|
const buttonProps = {
|
|
32
49
|
...button,
|
|
33
50
|
onClick,
|
|
34
51
|
};
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [button.label ? ((0, jsx_runtime_1.jsx)(material_1.Button, { sx: buttonSx, ...buttonProps,
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [button.label ? ((0, jsx_runtime_1.jsx)(material_1.Button, { sx: buttonSx, ...buttonProps, ref: (el) => {
|
|
53
|
+
buttonRefs.current[key] = el;
|
|
54
|
+
}, children: button.label }, key)) : ((0, jsx_runtime_1.jsx)(material_1.IconButton, { ref: (el) => {
|
|
55
|
+
buttonRefs.current[key] = el;
|
|
56
|
+
}, ...buttonProps, children: button.icon }, key)), isMenuOpen && visibleMenuItems && ((0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl && isMenuOpen), onClose: handleMenuClose, anchorOrigin: {
|
|
36
57
|
vertical: "bottom",
|
|
37
58
|
horizontal: button.menuPlacement === "left" ? "left" : "right",
|
|
38
59
|
}, children: visibleMenuItems.map((item) => {
|
|
@@ -32,6 +32,7 @@ export type AutocompleteProps<P extends FieldValues> = UseControllerProps<P> & O
|
|
|
32
32
|
disableClearable?: boolean;
|
|
33
33
|
setValue?: UseFormSetValue<P>;
|
|
34
34
|
containerProps?: StackProps;
|
|
35
|
+
styling?: "custom" | "default";
|
|
35
36
|
};
|
|
36
|
-
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, ...restProps }: AutocompleteProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
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, ...restProps }: AutocompleteProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
37
38
|
//# sourceMappingURL=Autocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,IAAI,oBAAoB,EACzC,UAAU,EACX,MAAM,eAAe,CAAC;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L,QAAgB,EAChB,QAAgB,EAChB,OAAY,EACZ,KAAK,EACL,OAAe,EACf,UAAU,EACV,KAAK,EACL,SAAiB,EACjB,WAAgB,EAChB,QAAQ,EACR,mBAA2B,EAC3B,eAAsB,EACtB,YAAoB,EACpB,kBAA0B,EAC1B,mBAA2B,EAC3B,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAiB,EACjB,aAAa,EACb,gBAA0C,EAC1C,cAAc,EACd,QAAQ,EACR,SAAa,EACb,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAqctB"}
|
|
@@ -18,7 +18,7 @@ const CheckBox_styled_1 = require("../CheckBox/CheckBox.styled");
|
|
|
18
18
|
const ChipV2_styled_1 = require("./ChipV2.styled");
|
|
19
19
|
const Skeleton_1 = require("./Skeleton");
|
|
20
20
|
const Tags_1 = require("./Tags");
|
|
21
|
-
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, ...restProps }) {
|
|
21
|
+
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", ...restProps }) {
|
|
22
22
|
const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
|
|
23
23
|
name,
|
|
24
24
|
control,
|
|
@@ -123,7 +123,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
123
123
|
if (loading) {
|
|
124
124
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
125
125
|
}
|
|
126
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", gap: "10px", alignItems: "start", children: [(0, jsx_runtime_1.jsx)(material_1.Autocomplete, { PopperComponent: material_1.Popper, PaperComponent: StyledPaper, sx: {
|
|
126
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && styling === "custom" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", gap: "10px", alignItems: "start", children: [(0, jsx_runtime_1.jsx)(material_1.Autocomplete, { PopperComponent: material_1.Popper, PaperComponent: StyledPaper, sx: {
|
|
127
127
|
"& .MuiAutocomplete-tag": {
|
|
128
128
|
backgroundColor: (0, styles_1.alpha)(color.iron[700], 0.6),
|
|
129
129
|
color: color.black[900],
|
|
@@ -169,7 +169,26 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
169
169
|
if (!multiple && selectedValue?.avatar && getOptionLabel) {
|
|
170
170
|
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 } }) }));
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
const getPlaceholder = () => {
|
|
173
|
+
if (styling === "default") {
|
|
174
|
+
return placeholder;
|
|
175
|
+
}
|
|
176
|
+
return placeholder || `Select ${label}`;
|
|
177
|
+
};
|
|
178
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, { ...params, placeholder: getPlaceholder(), label: styling === "default" ? label : undefined, required: styling === "default" ? required : undefined, error: error, autoFocus: autoFocus, helperText: helperText, InputLabelProps: styling === "default"
|
|
179
|
+
? {
|
|
180
|
+
sx: {
|
|
181
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
182
|
+
fontSize: "14px",
|
|
183
|
+
top: "50%",
|
|
184
|
+
transform: "translate(14px, -50%)",
|
|
185
|
+
},
|
|
186
|
+
"&.MuiInputLabel-shrink": {
|
|
187
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
: undefined, InputProps: {
|
|
173
192
|
...params.InputProps,
|
|
174
193
|
startAdornment,
|
|
175
194
|
}, onChange: (e) => {
|
|
@@ -20,6 +20,7 @@ export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & Mui
|
|
|
20
20
|
message?: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
containerProps?: StackProps;
|
|
23
|
+
styling?: "custom" | "default";
|
|
23
24
|
}>;
|
|
24
25
|
export declare const dateFormats: {
|
|
25
26
|
dateWithISO8601: string;
|
|
@@ -27,5 +28,5 @@ export declare const dateFormats: {
|
|
|
27
28
|
};
|
|
28
29
|
export declare const LeftArrowIcon: React.FC;
|
|
29
30
|
export declare const RightArrowIcon: React.FC;
|
|
30
|
-
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, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
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;
|
|
31
32
|
//# 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,EAAqB,KAAK,UAAU,EAAY,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;AAKzB,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;
|
|
1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AAO,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,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CAyNpB"}
|
|
@@ -40,7 +40,7 @@ const RightArrowIcon = () => {
|
|
|
40
40
|
} }));
|
|
41
41
|
};
|
|
42
42
|
exports.RightArrowIcon = RightArrowIcon;
|
|
43
|
-
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, ...restProps }) {
|
|
43
|
+
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 }) {
|
|
44
44
|
const [localError, setLocalError] = (0, react_1.useState)();
|
|
45
45
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
46
46
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
@@ -64,19 +64,36 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
64
64
|
if (loading) {
|
|
65
65
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
66
66
|
}
|
|
67
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { ...restField, ...restProps, disabled: disabled, views: views, format: format, value: finalValue, readOnly: readOnly, open: open && !readOnly, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && styling === "custom" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, { ...restField, ...restProps, disabled: disabled, views: views, format: format, value: finalValue, readOnly: readOnly, open: open && !readOnly, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
68
68
|
field: {
|
|
69
69
|
clearable,
|
|
70
70
|
onClear: () => onChange(null),
|
|
71
71
|
readOnly: disableKeyboardInput,
|
|
72
72
|
},
|
|
73
73
|
clearButton: {
|
|
74
|
-
tabIndex: -1,
|
|
74
|
+
tabIndex: -1,
|
|
75
75
|
},
|
|
76
76
|
textField: {
|
|
77
77
|
disabled,
|
|
78
78
|
error: !!localError || error,
|
|
79
79
|
helperText: localError ?? helperText,
|
|
80
|
+
label: styling === "default" ? label : undefined,
|
|
81
|
+
required: styling === "default" ? required : undefined,
|
|
82
|
+
InputLabelProps: styling === "default"
|
|
83
|
+
? {
|
|
84
|
+
sx: {
|
|
85
|
+
opacity: 0.8,
|
|
86
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
87
|
+
fontSize: "14px",
|
|
88
|
+
top: "50%",
|
|
89
|
+
transform: "translate(14px, -50%)",
|
|
90
|
+
},
|
|
91
|
+
"&.MuiInputLabel-shrink": {
|
|
92
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
: undefined,
|
|
80
97
|
InputProps: {
|
|
81
98
|
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { disabled: disabled, onClick: () => setOpen(true), showTooltip: false })),
|
|
82
99
|
sx: {
|
|
@@ -18,6 +18,7 @@ export type DateTimePickerProps<P extends FieldValues> = UseControllerProps<P> &
|
|
|
18
18
|
type: string;
|
|
19
19
|
message?: string;
|
|
20
20
|
}) => void;
|
|
21
|
+
styling?: "custom" | "default";
|
|
21
22
|
}>;
|
|
22
|
-
export declare function DateTimePicker<P extends FieldValues>({ control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, format, helperIcon, toolTipText, timeStepsMinutes, ...restProps }: DateTimePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
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;
|
|
23
24
|
//# 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,EAAE,KAAK,YAAY,EAAY,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC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AE,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;CAChC,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,GAAG,SAAS,EACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,2CA6MxB"}
|
|
@@ -37,7 +37,7 @@ const RightArrowIcon = () => {
|
|
|
37
37
|
p: "4px",
|
|
38
38
|
} }));
|
|
39
39
|
};
|
|
40
|
-
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, ...restProps }) {
|
|
40
|
+
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 }) {
|
|
41
41
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
42
42
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
43
43
|
if (error && value && typeof value === "object") {
|
|
@@ -52,7 +52,7 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
52
52
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: "350px" }, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label }) }));
|
|
53
53
|
}
|
|
54
54
|
const EmptyIcon = () => null;
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { alignItems: "center", flexDirection: "row", gap: "5px", children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), helperIcon && toolTipText && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: toolTipText, placement: "bottom", children: helperIcon }))] })), (0, jsx_runtime_1.jsx)(DateTimePicker_1.DateTimePicker, { ...restField, ...restProps, disabled: disabled, readOnly: readOnly, open: open, ampm: false, value: pickerValue, timeSteps: { minutes: timeStepsMinutes }, format: format, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && styling === "custom" && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { alignItems: "center", flexDirection: "row", gap: "5px", children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), helperIcon && toolTipText && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: toolTipText, placement: "bottom", children: helperIcon }))] })), (0, jsx_runtime_1.jsx)(DateTimePicker_1.DateTimePicker, { ...restField, ...restProps, disabled: disabled, readOnly: readOnly, open: open, ampm: false, value: pickerValue, timeSteps: { minutes: timeStepsMinutes }, format: format, onOpen: () => setOpen(true), onClose: () => setOpen(false), slotProps: {
|
|
56
56
|
field: {
|
|
57
57
|
clearable,
|
|
58
58
|
onClear: () => onChange(null),
|
|
@@ -64,6 +64,8 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
64
64
|
disabled,
|
|
65
65
|
helperText,
|
|
66
66
|
error,
|
|
67
|
+
label: styling === "default" ? label : undefined,
|
|
68
|
+
required: styling === "default" ? required : undefined,
|
|
67
69
|
InputProps: {
|
|
68
70
|
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { showTooltip: false, disabled: disabled, onClick: () => setOpen(true) })),
|
|
69
71
|
sx: {
|
|
@@ -72,6 +74,21 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
72
74
|
},
|
|
73
75
|
},
|
|
74
76
|
},
|
|
77
|
+
InputLabelProps: styling === "default"
|
|
78
|
+
? {
|
|
79
|
+
sx: {
|
|
80
|
+
opacity: 0.8,
|
|
81
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
82
|
+
fontSize: "14px",
|
|
83
|
+
top: "50%",
|
|
84
|
+
transform: "translate(14px, -50%)",
|
|
85
|
+
},
|
|
86
|
+
"&.MuiInputLabel-shrink": {
|
|
87
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
: undefined,
|
|
75
92
|
},
|
|
76
93
|
popper: {
|
|
77
94
|
sx: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/SearchField/SearchField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/SearchField/SearchField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,2CA6B1E"}
|
|
@@ -9,7 +9,18 @@ const SearchOutlined_1 = __importDefault(require("@mui/icons-material/SearchOutl
|
|
|
9
9
|
const material_1 = require("@mui/material");
|
|
10
10
|
const TextField_1 = require("../TextField");
|
|
11
11
|
function SearchField(props) {
|
|
12
|
+
const { styling = "custom" } = props;
|
|
12
13
|
return ((0, jsx_runtime_1.jsx)(TextField_1.TextField, { placeholder: "Search", InputProps: {
|
|
13
14
|
startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "start", children: (0, jsx_runtime_1.jsx)(SearchOutlined_1.default, { fontSize: "small" }) })),
|
|
14
|
-
},
|
|
15
|
+
}, InputLabelProps: styling === "default"
|
|
16
|
+
? {
|
|
17
|
+
sx: {
|
|
18
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
19
|
+
fontSize: "14px",
|
|
20
|
+
top: "50%",
|
|
21
|
+
transform: "translate(14px, -50%)",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
: undefined, ...props }));
|
|
15
26
|
}
|
|
@@ -11,6 +11,7 @@ export type SelectOption = {
|
|
|
11
11
|
};
|
|
12
12
|
export type SelectProps<P extends FieldValues> = UseControllerProps<P> & Omit<MuiSelectProps, keyof ControllerRenderProps<P> | "multiple" | "value" | "onChange"> & {
|
|
13
13
|
required?: boolean;
|
|
14
|
+
label?: string;
|
|
14
15
|
helperText?: string;
|
|
15
16
|
error?: boolean;
|
|
16
17
|
placeholder?: string;
|
|
@@ -25,6 +26,7 @@ export type SelectProps<P extends FieldValues> = UseControllerProps<P> & Omit<Mu
|
|
|
25
26
|
maxDisplayItems?: number;
|
|
26
27
|
disableClearable?: boolean;
|
|
27
28
|
setOnFinalChange?: boolean;
|
|
29
|
+
styling?: "custom" | "default";
|
|
28
30
|
};
|
|
29
|
-
export declare function Select<P extends FieldValues>({ control, defaultValue, name, required, multiple, disabled, options, rules, loading, helperText, error, placeholder, isShowSelectAll, isShowAvatar, onAction, renderOption, maxLimit, maxDisplayItems, disableClearable, setOnFinalChange, ...restProps }: SelectProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function Select<P extends FieldValues>({ control, defaultValue, name, required, label, multiple, disabled, options, rules, loading, helperText, error, placeholder, isShowSelectAll, isShowAvatar, onAction, renderOption, maxLimit, maxDisplayItems, disableClearable, setOnFinalChange, styling, ...restProps }: SelectProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,eAAe,CAAC;AAmBnE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAOzB,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,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ACL,OAAe,EACf,UAAU,EACV,KAAK,EACL,WAAgB,EAChB,eAAsB,EACtB,YAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,eAAmB,EACnB,gBAA0C,EAC1C,gBAAwB,EACxB,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,CAAC,CAAC,2CAgdhB"}
|
|
@@ -11,7 +11,7 @@ const Actions_1 = require("../../Actions");
|
|
|
11
11
|
const Toast_1 = require("../../Toast");
|
|
12
12
|
const CheckBox_styled_1 = require("../CheckBox/CheckBox.styled");
|
|
13
13
|
const Select_styled_1 = require("./Select.styled");
|
|
14
|
-
function Select({ control, defaultValue, name, required = false, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, placeholder = "", isShowSelectAll = true, isShowAvatar = false, onAction, renderOption, maxLimit, maxDisplayItems = 2, disableClearable = required ? true : false, setOnFinalChange = false, ...restProps }) {
|
|
14
|
+
function Select({ control, defaultValue, name, required = false, label, multiple = false, disabled = false, options = [], rules, loading = false, helperText, error, placeholder = "", isShowSelectAll = true, isShowAvatar = false, onAction, renderOption, maxLimit, maxDisplayItems = 2, disableClearable = required ? true : false, setOnFinalChange = false, styling = "custom", ...restProps }) {
|
|
15
15
|
const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
|
|
16
16
|
name,
|
|
17
17
|
control,
|
|
@@ -51,14 +51,24 @@ function Select({ control, defaultValue, name, required = false, multiple = fals
|
|
|
51
51
|
const renderValue = (selected) => {
|
|
52
52
|
if (!multiple) {
|
|
53
53
|
const selectedOption = options.find((option) => option.value === selected);
|
|
54
|
+
const placeholderText = () => {
|
|
55
|
+
if (selectedOption) {
|
|
56
|
+
return selectedOption.label;
|
|
57
|
+
}
|
|
58
|
+
if (styling === "default" && label) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return placeholder;
|
|
62
|
+
};
|
|
54
63
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [isShowAvatar && selectedOption?.avatar && ((0, jsx_runtime_1.jsx)(material_1.Avatar, { src: selectedOption.avatar ?? "", sx: { width: 20, height: 20 } })), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: disabledColor, sx: {
|
|
55
64
|
"-webkit-text-fill-color": disabledColor,
|
|
56
|
-
}, noWrap: true, children:
|
|
65
|
+
}, noWrap: true, children: placeholderText() })] }));
|
|
57
66
|
}
|
|
58
67
|
if (!Array.isArray(selected) || selected.length === 0) {
|
|
68
|
+
const shouldShowPlaceholder = styling !== "default" || !label || placeholder;
|
|
59
69
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
|
|
60
70
|
"-webkit-text-fill-color": disabledColor,
|
|
61
|
-
}, color: disabledColor, variant: "body2", noWrap: true, children: placeholder }));
|
|
71
|
+
}, color: disabledColor, variant: "body2", noWrap: true, children: shouldShowPlaceholder ? placeholder : "" }));
|
|
62
72
|
}
|
|
63
73
|
const visibleItems = selectedOptions.slice(0, maxDisplayItems);
|
|
64
74
|
const overflowCount = selectedOptions.length - maxDisplayItems;
|
|
@@ -127,72 +137,98 @@ function Select({ control, defaultValue, name, required = false, multiple = fals
|
|
|
127
137
|
});
|
|
128
138
|
return items;
|
|
129
139
|
};
|
|
130
|
-
return ((0, jsx_runtime_1.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && styling === "custom" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", gap: "10px", alignItems: "start", children: [(0, jsx_runtime_1.jsxs)(Select_styled_1.StyledFormControl, { fullWidth: true, error: error, disabled: disabled, required: required, sx: styling === "default"
|
|
141
|
+
? {
|
|
142
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
143
|
+
"& legend": {
|
|
144
|
+
maxWidth: 0,
|
|
145
|
+
"& span": {
|
|
146
|
+
padding: "0 5px",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
"& .MuiInputLabel-root.MuiInputLabel-shrink + .MuiInputBase-root .MuiOutlinedInput-notchedOutline legend": {
|
|
151
|
+
maxWidth: "100%",
|
|
152
|
+
},
|
|
153
|
+
}
|
|
154
|
+
: undefined, children: [label && styling === "default" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: `${name}-label`, sx: {
|
|
155
|
+
opacity: 0.8,
|
|
156
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
157
|
+
fontSize: "14px",
|
|
158
|
+
top: "50%",
|
|
159
|
+
transform: "translate(14px, -50%)",
|
|
160
|
+
},
|
|
161
|
+
"&.MuiInputLabel-shrink": {
|
|
162
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
163
|
+
},
|
|
164
|
+
}, children: label })), (0, jsx_runtime_1.jsx)(material_1.Select, { ...restField, ...restProps, multiple: multiple, value: getDisplayValue() ?? (multiple ? [] : ""), label: styling === "default" ? label : undefined, labelId: styling === "default" && label ? `${name}-label` : undefined, inputProps: {
|
|
165
|
+
"aria-label": styling === "custom" && label ? label : undefined,
|
|
166
|
+
},
|
|
167
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
168
|
+
onChange: (event) => {
|
|
169
|
+
const newValue = event.target.value;
|
|
170
|
+
if (setOnFinalChange) {
|
|
171
|
+
hasPendingChange.current = true;
|
|
172
|
+
if (multiple &&
|
|
173
|
+
Array.isArray(newValue) &&
|
|
174
|
+
newValue.includes("select-all")) {
|
|
175
|
+
setPendingValue(Array.isArray(pendingValue) &&
|
|
176
|
+
pendingValue.length ===
|
|
177
|
+
options.filter(({ disabled }) => !disabled).length
|
|
178
|
+
? []
|
|
179
|
+
: options
|
|
180
|
+
.filter(({ disabled }) => !disabled)
|
|
181
|
+
.map(({ value }) => value));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
setPendingValue(newValue);
|
|
185
|
+
}
|
|
146
186
|
}
|
|
147
187
|
else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
title: t("common.select.limitExceed", { maxLimit }),
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
188
|
+
if (multiple && Array.isArray(newValue)) {
|
|
189
|
+
const isSelectAllIncluded = newValue.includes("select-all");
|
|
190
|
+
if (isSelectAllIncluded) {
|
|
191
|
+
handleSelectAll(!isAllSelected);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (maxLimit && newValue.length > maxLimit) {
|
|
195
|
+
Toast_1.toasts.error({
|
|
196
|
+
title: t("common.select.limitExceed", { maxLimit }),
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
163
200
|
}
|
|
201
|
+
onChange(newValue);
|
|
202
|
+
}
|
|
203
|
+
}, onClose: () => {
|
|
204
|
+
if (setOnFinalChange && hasPendingChange.current) {
|
|
205
|
+
onChange(pendingValue);
|
|
206
|
+
hasPendingChange.current = false;
|
|
207
|
+
setPendingValue(null);
|
|
164
208
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
PaperProps: {
|
|
188
|
-
sx: {
|
|
189
|
-
width: "inherit",
|
|
190
|
-
maxHeight: 300,
|
|
191
|
-
"& .MuiList-root": {
|
|
192
|
-
paddingTop: 0,
|
|
193
|
-
paddingBottom: 0,
|
|
209
|
+
}, renderValue: restProps.renderValue ?? renderValue,
|
|
210
|
+
// eslint-disable-next-line sonarjs/no-unstable-nested-components
|
|
211
|
+
IconComponent: (props) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
212
|
+
display: "flex",
|
|
213
|
+
alignItems: "center",
|
|
214
|
+
gap: 0.5,
|
|
215
|
+
pr: 2.5,
|
|
216
|
+
}, children: [value &&
|
|
217
|
+
((Array.isArray(value) && value.length > 0) ||
|
|
218
|
+
(!Array.isArray(value) && value !== "")) &&
|
|
219
|
+
!disableClearable && ((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: (e) => {
|
|
220
|
+
e.stopPropagation();
|
|
221
|
+
onChange(multiple ? [] : "");
|
|
222
|
+
}, children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.ClearIcon, { sx: { fontSize: "14px" } }) })), (0, jsx_runtime_1.jsx)(x_date_pickers_1.ArrowDropDownIcon, { ...props })] })), displayEmpty: true, MenuProps: {
|
|
223
|
+
PaperProps: {
|
|
224
|
+
sx: {
|
|
225
|
+
width: "inherit",
|
|
226
|
+
maxHeight: 300,
|
|
227
|
+
"& .MuiList-root": {
|
|
228
|
+
paddingTop: 0,
|
|
229
|
+
paddingBottom: 0,
|
|
230
|
+
},
|
|
194
231
|
},
|
|
195
232
|
},
|
|
196
|
-
},
|
|
197
|
-
}, children: Object.entries(groupedOptions).length ? (renderMenuItems()) : ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { disabled: true, children: (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "No options" }) })) }), helperText && (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: helperText })] }), onAction && (0, jsx_runtime_1.jsx)(Actions_1.EditIconAction, { disabled: disabled, onClick: onAction })] }) }));
|
|
233
|
+
}, children: Object.entries(groupedOptions).length ? (renderMenuItems()) : ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { disabled: true, children: (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: "No options" }) })) }), helperText && (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: helperText })] }), onAction && (0, jsx_runtime_1.jsx)(Actions_1.EditIconAction, { disabled: disabled, onClick: onAction })] })] }));
|
|
198
234
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TextFieldProps as MuiTextFieldProps, type StackProps } from "@mui/material";
|
|
2
2
|
import { type ControllerRenderProps, type FieldError, type FieldValues, type UseControllerProps } from "react-hook-form";
|
|
3
3
|
export type AllowedCharacterType = "string" | "string-number" | "string-number-special";
|
|
4
4
|
export type LetterCase = "uppercase" | "lowercase" | "mixed";
|
|
@@ -15,6 +15,7 @@ export type TextFieldProps<P extends FieldValues> = UseControllerProps<P> & Omit
|
|
|
15
15
|
message?: string;
|
|
16
16
|
}) => void;
|
|
17
17
|
containerProps?: StackProps;
|
|
18
|
+
styling?: "custom" | "default";
|
|
18
19
|
};
|
|
19
|
-
export declare function TextField<P extends FieldValues>({ control, name, defaultValue, label, rules, type, required, disabled, loading, placeholder, isCapitalize, isTrimStartDisabled, rows, characterType, letterCase, setError, containerProps, ...inputFieldProps }: TextFieldProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function TextField<P extends FieldValues>({ control, name, defaultValue, label, rules, type, required, disabled, loading, placeholder, isCapitalize, isTrimStartDisabled, rows, characterType, letterCase, setError, containerProps, styling, ...inputFieldProps }: TextFieldProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
//# sourceMappingURL=TextField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,IAAI,iBAAiB,EACxC,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,eAAe,GACf,uBAAuB,CAAC;AAE5B,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;AAQ7D,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACvE,IAAI,CAAC,iBAAiB,EAAE,MAAM,qBAAqB,CAAC,CAAC,CAAC,CAAC,GAAG;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,CACT,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;CAChC,CAAC;AAEJ,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,EAC/C,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,KAAU,EACV,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,WAAgB,EAChB,YAAoB,EACpB,mBAA2B,EAC3B,IAAI,EACJ,aAAuC,EACvC,UAAoB,EACpB,QAAQ,EACR,cAAc,EACd,OAAkB,EAClB,GAAG,eAAe,EACnB,EAAE,cAAc,CAAC,CAAC,CAAC,2CAkInB"}
|
|
@@ -10,7 +10,7 @@ const characterTypeMessages = {
|
|
|
10
10
|
"string-number": "Only letters and numbers are allowed.",
|
|
11
11
|
"string-number-special": "Special characters are allowed.",
|
|
12
12
|
};
|
|
13
|
-
function TextField({ control, name, defaultValue, label = "", rules, type, required, disabled, loading = false, placeholder = "", isCapitalize = false, isTrimStartDisabled = false, rows, characterType = "string-number-special", letterCase = "mixed", setError, containerProps, ...inputFieldProps }) {
|
|
13
|
+
function TextField({ control, name, defaultValue, label = "", rules, type, required, disabled, loading = false, placeholder = "", isCapitalize = false, isTrimStartDisabled = false, rows, characterType = "string-number-special", letterCase = "mixed", setError, containerProps, styling = "custom", ...inputFieldProps }) {
|
|
14
14
|
const { field: { value, onChange, ...restField }, fieldState: { error }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
15
15
|
const handleKeyDown = (event) => {
|
|
16
16
|
if (event.key === "-" && type === "number") {
|
|
@@ -49,7 +49,21 @@ function TextField({ control, name, defaultValue, label = "", rules, type, requi
|
|
|
49
49
|
if (loading) {
|
|
50
50
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label, rows: rows });
|
|
51
51
|
}
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { ...containerProps, gap: "10px", children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(material_1.TextField, { disabled: disabled, required: required, fullWidth: true, onKeyDown: handleKeyDown, placeholder: placeholder || label, type: type,
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { ...containerProps, gap: "10px", children: [label && styling === "custom" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(material_1.TextField, { disabled: disabled, required: required, fullWidth: true, onKeyDown: handleKeyDown, placeholder: styling === "default" ? placeholder : placeholder || label, type: type, label: styling === "default" ? label : undefined, InputLabelProps: styling === "default"
|
|
53
|
+
? {
|
|
54
|
+
sx: {
|
|
55
|
+
opacity: 0.8,
|
|
56
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
57
|
+
fontSize: "14px",
|
|
58
|
+
top: "50%",
|
|
59
|
+
transform: "translate(14px, -50%)",
|
|
60
|
+
},
|
|
61
|
+
"&.MuiInputLabel-shrink": {
|
|
62
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: undefined, inputProps: {
|
|
53
67
|
min: 0,
|
|
54
68
|
}, error: Boolean(error), helperText: error?.message, onChange: (event) => {
|
|
55
69
|
let value = event.target.value || null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { PickerValidDate } from "@mui/x-date-pickers/models";
|
|
1
2
|
import { type TimeFieldProps as MuiTimeFieldProps } from "@mui/x-date-pickers/TimeField";
|
|
2
3
|
import type { FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
-
import type { PickerValidDate } from "@mui/x-date-pickers/models";
|
|
4
4
|
export type TimeFieldProps<P extends FieldValues> = UseControllerProps<P> & MuiTimeFieldProps<PickerValidDate> & Partial<{
|
|
5
5
|
label: string;
|
|
6
6
|
required: boolean;
|
|
@@ -11,6 +11,7 @@ export type TimeFieldProps<P extends FieldValues> = UseControllerProps<P> & MuiT
|
|
|
11
11
|
format: string;
|
|
12
12
|
isReturnLocalTime: boolean;
|
|
13
13
|
isReturnDateWithTime: boolean;
|
|
14
|
+
styling?: "custom" | "default";
|
|
14
15
|
}>;
|
|
15
|
-
export declare function TimeField<P extends FieldValues>({ control, defaultValue, disabled, label, name, error, helperText, loading, required, rules, format, isReturnLocalTime, isReturnDateWithTime, ...restProps }: TimeFieldProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function TimeField<P extends FieldValues>({ control, defaultValue, disabled, label, name, error, helperText, loading, required, rules, format, isReturnLocalTime, isReturnDateWithTime, styling, ...restProps }: TimeFieldProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
//# sourceMappingURL=TimeField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TimeField/TimeField.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,cAAc,IAAI,iBAAiB,EACzC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TimeField/TimeField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAEL,KAAK,cAAc,IAAI,iBAAiB,EACzC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACvE,iBAAiB,CAAC,eAAe,CAAC,GAClC,OAAO,CAAC;IACN,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;IAC3B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC,CAAC,CAAC;AAEL,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,EAC/C,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,KAAK,EACL,MAAgB,EAChB,iBAAyB,EACzB,oBAA4B,EAC5B,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,cAAc,CAAC,CAAC,CAAC,2CAgGnB"}
|
|
@@ -7,7 +7,7 @@ const TimeField_1 = require("@mui/x-date-pickers/TimeField");
|
|
|
7
7
|
const luxon_1 = require("luxon");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const Skeleton_1 = require("./Skeleton");
|
|
10
|
-
function TimeField({ control, defaultValue, disabled = false, label, name, error, helperText, loading = false, required = false, rules, format = "HH:mm", isReturnLocalTime = false, isReturnDateWithTime = false, ...restProps }) {
|
|
10
|
+
function TimeField({ control, defaultValue, disabled = false, label, name, error, helperText, loading = false, required = false, rules, format = "HH:mm", isReturnLocalTime = false, isReturnDateWithTime = false, styling = "custom", ...restProps }) {
|
|
11
11
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
12
12
|
const theme = (0, material_1.useTheme)();
|
|
13
13
|
const { butterflyBlue } = theme.palette.app.color;
|
|
@@ -20,7 +20,7 @@ function TimeField({ control, defaultValue, disabled = false, label, name, error
|
|
|
20
20
|
if (loading) {
|
|
21
21
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
22
22
|
}
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(TimeField_1.TimeField, { ...restField, ...restProps, disabled: disabled, value: pickerValue, onChange: (value) => {
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", children: [label && styling === "custom" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label })), (0, jsx_runtime_1.jsx)(TimeField_1.TimeField, { ...restField, ...restProps, disabled: disabled, value: pickerValue, onChange: (value) => {
|
|
24
24
|
if (value?.isValid) {
|
|
25
25
|
if (isReturnLocalTime) {
|
|
26
26
|
return onChange(value.toFormat(format));
|
|
@@ -38,6 +38,23 @@ function TimeField({ control, defaultValue, disabled = false, label, name, error
|
|
|
38
38
|
disabled,
|
|
39
39
|
helperText,
|
|
40
40
|
error,
|
|
41
|
+
label: styling === "default" ? label : undefined,
|
|
42
|
+
required: styling === "default" ? required : undefined,
|
|
43
|
+
InputLabelProps: styling === "default"
|
|
44
|
+
? {
|
|
45
|
+
sx: {
|
|
46
|
+
opacity: 0.8,
|
|
47
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
48
|
+
fontSize: "14px",
|
|
49
|
+
top: "50%",
|
|
50
|
+
transform: "translate(14px, -50%)",
|
|
51
|
+
},
|
|
52
|
+
"&.MuiInputLabel-shrink": {
|
|
53
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
: undefined,
|
|
41
58
|
sx: {
|
|
42
59
|
backgroundColor: "white",
|
|
43
60
|
"& .Mui-selected": {
|
|
@@ -17,6 +17,7 @@ export type TimePickerProps<P extends FieldValues> = UseControllerProps<P> & Mui
|
|
|
17
17
|
toolTipText?: string;
|
|
18
18
|
timeStepsMinutes?: number;
|
|
19
19
|
containerProps?: StackProps;
|
|
20
|
+
styling?: "custom" | "default";
|
|
20
21
|
}>;
|
|
21
|
-
export declare function TimePicker<P extends FieldValues>({ control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, rules, format, isReturnLocalTime, isReturnDateWithTime, timeStepsMinutes, helperIcon, toolTipText, containerProps, ...restProps }: TimePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function TimePicker<P extends FieldValues>({ control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, rules, format, isReturnLocalTime, isReturnDateWithTime, timeStepsMinutes, helperIcon, toolTipText, containerProps, styling, ...restProps }: TimePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
//# sourceMappingURL=TimePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EACV,WAAW,EAGX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACxE,kBAAkB,CAAC,eAAe,CAAC,GACnC,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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AE,UAAU,CAAC;IAC5B,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC,CAAC,CAAC;AAEL,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,KAAK,EACL,MAAgB,EAChB,iBAAyB,EACzB,oBAA4B,EAC5B,gBAAoB,EACpB,UAAU,EACV,WAAW,EACX,cAAc,EACd,OAAkB,EAClB,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CA0IpB"}
|
|
@@ -8,7 +8,7 @@ const luxon_1 = require("luxon");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
10
|
const Skeleton_1 = require("./Skeleton");
|
|
11
|
-
function TimePicker({ control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, rules, format = "HH:mm", isReturnLocalTime = false, isReturnDateWithTime = false, timeStepsMinutes = 1, helperIcon, toolTipText, containerProps, ...restProps }) {
|
|
11
|
+
function TimePicker({ control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, rules, format = "HH:mm", isReturnLocalTime = false, isReturnDateWithTime = false, timeStepsMinutes = 1, helperIcon, toolTipText, containerProps, styling = "custom", ...restProps }) {
|
|
12
12
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
13
13
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
14
14
|
if (error && value && typeof value === "object") {
|
|
@@ -22,11 +22,28 @@ function TimePicker({ control, defaultValue, disabled = false, label, readOnly =
|
|
|
22
22
|
if (loading) {
|
|
23
23
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
24
24
|
}
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { alignItems: "center", flexDirection: "row", gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label }), helperIcon && toolTipText && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: toolTipText, placement: "bottom", children: helperIcon }))] })), (0, jsx_runtime_1.jsx)(TimePicker_1.TimePicker, { ...restField, ...restProps, disabled: disabled, readOnly: readOnly, open: open, ampm: false, value: pickerValue, format: format, onOpen: () => setOpen(true), onClose: () => setOpen(false), timeSteps: { minutes: timeStepsMinutes }, slotProps: {
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "10px", ...containerProps, children: [label && styling === "custom" && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { alignItems: "center", flexDirection: "row", gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { sx: { fontSize: { xs: "14px", md: "16px" } }, required: required, disabled: disabled, children: label }), helperIcon && toolTipText && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: toolTipText, placement: "bottom", children: helperIcon }))] })), (0, jsx_runtime_1.jsx)(TimePicker_1.TimePicker, { ...restField, ...restProps, disabled: disabled, readOnly: readOnly, open: open, ampm: false, value: pickerValue, format: format, onOpen: () => setOpen(true), onClose: () => setOpen(false), timeSteps: { minutes: timeStepsMinutes }, slotProps: {
|
|
26
26
|
textField: {
|
|
27
27
|
disabled,
|
|
28
28
|
helperText,
|
|
29
29
|
error,
|
|
30
|
+
label: styling === "default" ? label : undefined,
|
|
31
|
+
required: styling === "default" ? required : undefined,
|
|
32
|
+
InputLabelProps: styling === "default"
|
|
33
|
+
? {
|
|
34
|
+
sx: {
|
|
35
|
+
opacity: 0.8,
|
|
36
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
37
|
+
fontSize: "14px",
|
|
38
|
+
top: "50%",
|
|
39
|
+
transform: "translate(14px, -50%)",
|
|
40
|
+
},
|
|
41
|
+
"&.MuiInputLabel-shrink": {
|
|
42
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
30
47
|
sx: {
|
|
31
48
|
backgroundColor: "white",
|
|
32
49
|
"& .Mui-selected": {
|
|
@@ -3,7 +3,8 @@ type UseGlobalKeyboardShortcutArgs = {
|
|
|
3
3
|
key: string;
|
|
4
4
|
onTrigger: () => void;
|
|
5
5
|
modifierKeys?: ModifierType | ModifierType[];
|
|
6
|
+
withoutModifiers?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const useGlobalKeyboardShortcut: ({ key, onTrigger, modifierKeys, }: UseGlobalKeyboardShortcutArgs) => void;
|
|
8
|
+
export declare const useGlobalKeyboardShortcut: ({ key, onTrigger, modifierKeys, withoutModifiers, }: UseGlobalKeyboardShortcutArgs) => void;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=useGlobalKeyboardShortcut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalKeyboardShortcut.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useGlobalKeyboardShortcut.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7D,KAAK,6BAA6B,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"useGlobalKeyboardShortcut.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useGlobalKeyboardShortcut.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7D,KAAK,6BAA6B,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,qDAKvC,6BAA6B,SAmF/B,CAAC"}
|
|
@@ -7,12 +7,21 @@ exports.useGlobalKeyboardShortcut = void 0;
|
|
|
7
7
|
const castArray_1 = __importDefault(require("lodash/castArray"));
|
|
8
8
|
const every_1 = __importDefault(require("lodash/every"));
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
-
const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", }) => {
|
|
10
|
+
const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", withoutModifiers = false, }) => {
|
|
11
11
|
(0, react_1.useEffect)(() => {
|
|
12
12
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
13
13
|
const handler = (e) => {
|
|
14
14
|
const normalizedCode = key.length === 1 ? `Key${key.toUpperCase()}` : key;
|
|
15
15
|
const keyMatch = e.code?.toLowerCase() === normalizedCode?.toLowerCase();
|
|
16
|
+
if (withoutModifiers) {
|
|
17
|
+
const hasNoModifiers = !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey;
|
|
18
|
+
if (keyMatch && hasNoModifiers && !e.repeat) {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
onTrigger();
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
16
25
|
const normalizedModifierKeys = (0, castArray_1.default)(modifierKeys);
|
|
17
26
|
const modifierMatch = (0, every_1.default)(normalizedModifierKeys, (mod) => {
|
|
18
27
|
switch (mod) {
|
|
@@ -57,6 +66,6 @@ const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", }) =
|
|
|
57
66
|
};
|
|
58
67
|
window.addEventListener("keydown", handler, true);
|
|
59
68
|
return () => window.removeEventListener("keydown", handler, true);
|
|
60
|
-
}, [key, modifierKeys, onTrigger]);
|
|
69
|
+
}, [key, modifierKeys, onTrigger, withoutModifiers]);
|
|
61
70
|
};
|
|
62
71
|
exports.useGlobalKeyboardShortcut = useGlobalKeyboardShortcut;
|