@codezee/sixtify-brahma 0.2.121 → 0.2.123
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/FilterList/FilterListV2.d.ts.map +1 -1
- package/packages/shared-components/dist/FilterList/FilterListV2.js +15 -2
- 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 +10 -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 +8 -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 +7 -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 +93 -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 +3 -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 +7 -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 +7 -2
- package/packages/shared-components/dist/FormFields/commonStyles.d.ts +8 -0
- package/packages/shared-components/dist/FormFields/commonStyles.d.ts.map +1 -0
- package/packages/shared-components/dist/FormFields/commonStyles.js +70 -0
- 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) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterListV2.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterListV2.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterListV2.d.ts","sourceRoot":"","sources":["../../src/FilterList/FilterListV2.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsBnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,eAAe,EAAE,cAAc,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAiB7B;AAED,eAAO,MAAM,YAAY,GAAI,8EAO1B,iBAAiB,4CA8qBnB,CAAC"}
|
|
@@ -59,6 +59,7 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
59
59
|
const [openFilterPopup, setOpenFilterPopup] = (0, react_1.useState)(false);
|
|
60
60
|
const [datePickerPopup, setDatePickerPopup] = (0, react_1.useState)(false);
|
|
61
61
|
const [currentFilter, setCurrentFilter] = (0, react_1.useState)(null);
|
|
62
|
+
const filterListV2AnchorRef = (0, react_1.useRef)(null);
|
|
62
63
|
const [isPopupOpen, setIsPopupOpen] = (0, react_1.useState)(false);
|
|
63
64
|
const handleDateRange = (filter) => {
|
|
64
65
|
setCurrentFilter(filter);
|
|
@@ -154,7 +155,8 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
154
155
|
handleClose();
|
|
155
156
|
};
|
|
156
157
|
const handleClick = (event) => {
|
|
157
|
-
|
|
158
|
+
const element = event instanceof HTMLElement ? event : event.currentTarget;
|
|
159
|
+
setAnchorEl(element);
|
|
158
160
|
};
|
|
159
161
|
const onSubmit = (data) => {
|
|
160
162
|
setOpenFilterPopup(false);
|
|
@@ -266,6 +268,17 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
266
268
|
} }, key));
|
|
267
269
|
});
|
|
268
270
|
};
|
|
271
|
+
(0, utils_1.useGlobalKeyboardShortcut)({
|
|
272
|
+
key: "f",
|
|
273
|
+
modifierKeys: ["ctrl", "shift"],
|
|
274
|
+
onTrigger: () => {
|
|
275
|
+
if (isDisabled) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const buttonElement = filterListV2AnchorRef.current ?? document.createElement("button");
|
|
279
|
+
handleClick(buttonElement);
|
|
280
|
+
},
|
|
281
|
+
});
|
|
269
282
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { flexGrow: 1 }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: { xs: "end", md: "space-between" }, spacing: 1, children: [isDesktop && ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", alignItems: "center", sx: {
|
|
270
283
|
maxWidth: {
|
|
271
284
|
xs: "40vw",
|
|
@@ -276,7 +289,7 @@ const FilterListV2 = ({ filterListItems, isDisabled = false, filterListData, onA
|
|
|
276
289
|
Object.values(filterListData).some((value) => value) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", sx: {
|
|
277
290
|
minWidth: "50px",
|
|
278
291
|
}, children: "Filters:" }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", gap: "5px", alignItems: "center", sx: { flexWrap: "wrap", maxWidth: "100%" }, children: renderChips(filterListData) })] })) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "flex-start", children: [filterListData &&
|
|
279
|
-
Object.values(filterListData).some((value) => value) && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => handlerReset(), variant: "text", sx: { minWidth: { xs: "60px", sm: "100px" } }, children: !isMobile ? "Clear Filter" : "Clear" })), !isDisabled && ((0, jsx_runtime_1.jsx)(Actions_1.FilterIconAction, { isFiltered: !(0, isEmpty_1.default)(filterListData), onClick: handleClick }))] })] }), (0, jsx_runtime_1.jsx)("form", { onSubmit: (e) => {
|
|
292
|
+
Object.values(filterListData).some((value) => value) && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => handlerReset(), variant: "text", sx: { minWidth: { xs: "60px", sm: "100px" } }, children: !isMobile ? "Clear Filter" : "Clear" })), !isDisabled && ((0, jsx_runtime_1.jsx)(Actions_1.FilterIconAction, { isFiltered: !(0, isEmpty_1.default)(filterListData), onClick: handleClick, ref: filterListV2AnchorRef }))] })] }), (0, jsx_runtime_1.jsx)("form", { onSubmit: (e) => {
|
|
280
293
|
e.preventDefault();
|
|
281
294
|
if (!shouldFormSubmit) {
|
|
282
295
|
handleSubmit((data) => {
|
|
@@ -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;AAkBvB,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WA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,CAAC,CAAC,CAAC,2CAubtB"}
|
|
@@ -15,10 +15,11 @@ const Actions_1 = require("../../Actions");
|
|
|
15
15
|
const Toast_1 = require("../../Toast");
|
|
16
16
|
const Tooltip_1 = require("../../Tooltip");
|
|
17
17
|
const CheckBox_styled_1 = require("../CheckBox/CheckBox.styled");
|
|
18
|
+
const commonStyles_1 = require("../commonStyles");
|
|
18
19
|
const ChipV2_styled_1 = require("./ChipV2.styled");
|
|
19
20
|
const Skeleton_1 = require("./Skeleton");
|
|
20
21
|
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 }) {
|
|
22
|
+
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
23
|
const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
|
|
23
24
|
name,
|
|
24
25
|
control,
|
|
@@ -123,7 +124,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
123
124
|
if (loading) {
|
|
124
125
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
125
126
|
}
|
|
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: {
|
|
127
|
+
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
128
|
"& .MuiAutocomplete-tag": {
|
|
128
129
|
backgroundColor: (0, styles_1.alpha)(color.iron[700], 0.6),
|
|
129
130
|
color: color.black[900],
|
|
@@ -169,7 +170,13 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
169
170
|
if (!multiple && selectedValue?.avatar && getOptionLabel) {
|
|
170
171
|
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
172
|
}
|
|
172
|
-
|
|
173
|
+
const getPlaceholder = () => {
|
|
174
|
+
if (styling === "default") {
|
|
175
|
+
return placeholder;
|
|
176
|
+
}
|
|
177
|
+
return placeholder || `Select ${label}`;
|
|
178
|
+
};
|
|
179
|
+
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, sx: (0, commonStyles_1.getDefaultTextFieldSx)(styling), InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling), InputProps: {
|
|
173
180
|
...params.InputProps,
|
|
174
181
|
startAdornment,
|
|
175
182
|
}, 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,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C;CAChC,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,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CA2MpB"}
|
|
@@ -15,6 +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 commonStyles_1 = require("../commonStyles");
|
|
18
19
|
const Skeleton_1 = require("./Skeleton");
|
|
19
20
|
exports.dateFormats = {
|
|
20
21
|
dateWithISO8601: "yyyy-MM-dd",
|
|
@@ -40,7 +41,7 @@ const RightArrowIcon = () => {
|
|
|
40
41
|
} }));
|
|
41
42
|
};
|
|
42
43
|
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 }) {
|
|
44
|
+
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
45
|
const [localError, setLocalError] = (0, react_1.useState)();
|
|
45
46
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
46
47
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
@@ -64,19 +65,23 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
64
65
|
if (loading) {
|
|
65
66
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
66
67
|
}
|
|
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: {
|
|
68
|
+
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
69
|
field: {
|
|
69
70
|
clearable,
|
|
70
71
|
onClear: () => onChange(null),
|
|
71
72
|
readOnly: disableKeyboardInput,
|
|
72
73
|
},
|
|
73
74
|
clearButton: {
|
|
74
|
-
tabIndex: -1,
|
|
75
|
+
tabIndex: -1,
|
|
75
76
|
},
|
|
76
77
|
textField: {
|
|
77
78
|
disabled,
|
|
78
79
|
error: !!localError || error,
|
|
79
80
|
helperText: localError ?? helperText,
|
|
81
|
+
label: styling === "default" ? label : undefined,
|
|
82
|
+
required: styling === "default" ? required : undefined,
|
|
83
|
+
sx: (0, commonStyles_1.getDefaultTextFieldSx)(styling),
|
|
84
|
+
InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling),
|
|
80
85
|
InputProps: {
|
|
81
86
|
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { disabled: disabled, onClick: () => setOpen(true), showTooltip: false })),
|
|
82
87
|
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,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AgB,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,2CA+LxB"}
|
|
@@ -13,6 +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 commonStyles_1 = require("../commonStyles");
|
|
16
17
|
const Skeleton_1 = require("./Skeleton");
|
|
17
18
|
const hoverTextStyle = (color) => ({
|
|
18
19
|
"&:hover": {
|
|
@@ -37,7 +38,7 @@ const RightArrowIcon = () => {
|
|
|
37
38
|
p: "4px",
|
|
38
39
|
} }));
|
|
39
40
|
};
|
|
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 }) {
|
|
41
|
+
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
42
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
42
43
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
43
44
|
if (error && value && typeof value === "object") {
|
|
@@ -52,7 +53,7 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
52
53
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: { width: "350px" }, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label }) }));
|
|
53
54
|
}
|
|
54
55
|
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: {
|
|
56
|
+
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
57
|
field: {
|
|
57
58
|
clearable,
|
|
58
59
|
onClear: () => onChange(null),
|
|
@@ -64,6 +65,8 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
64
65
|
disabled,
|
|
65
66
|
helperText,
|
|
66
67
|
error,
|
|
68
|
+
label: styling === "default" ? label : undefined,
|
|
69
|
+
required: styling === "default" ? required : undefined,
|
|
67
70
|
InputProps: {
|
|
68
71
|
endAdornment: ((0, jsx_runtime_1.jsx)(Actions_1.CalendarIconAction, { showTooltip: false, disabled: disabled, onClick: () => setOpen(true) })),
|
|
69
72
|
sx: {
|
|
@@ -72,6 +75,8 @@ function DateTimePicker({ control, defaultValue, disabled = false, label, readOn
|
|
|
72
75
|
},
|
|
73
76
|
},
|
|
74
77
|
},
|
|
78
|
+
sx: (0, commonStyles_1.getDefaultTextFieldSx)(styling),
|
|
79
|
+
InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling),
|
|
75
80
|
},
|
|
76
81
|
popper: {
|
|
77
82
|
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;AAWzB,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,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACpE,IAAI,CACF,cAAc,EACd,MAAM,qBAAqB,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CACnE,GAAG;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC,CAAC;AAEJ,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,EAC5C,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,QAAgB,EAChB,OAAY,EACZ,KAAK,EACL,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,2CAuchB"}
|
|
@@ -11,7 +11,8 @@ 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
|
-
|
|
14
|
+
const commonStyles_1 = require("../commonStyles");
|
|
15
|
+
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
16
|
const { field: { onChange, value, ...restField }, } = (0, react_hook_form_1.useController)({
|
|
16
17
|
name,
|
|
17
18
|
control,
|
|
@@ -51,14 +52,24 @@ function Select({ control, defaultValue, name, required = false, multiple = fals
|
|
|
51
52
|
const renderValue = (selected) => {
|
|
52
53
|
if (!multiple) {
|
|
53
54
|
const selectedOption = options.find((option) => option.value === selected);
|
|
55
|
+
const placeholderText = () => {
|
|
56
|
+
if (selectedOption) {
|
|
57
|
+
return selectedOption.label;
|
|
58
|
+
}
|
|
59
|
+
if (styling === "default" && label) {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
return placeholder;
|
|
63
|
+
};
|
|
54
64
|
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
65
|
"-webkit-text-fill-color": disabledColor,
|
|
56
|
-
}, noWrap: true, children:
|
|
66
|
+
}, noWrap: true, children: placeholderText() })] }));
|
|
57
67
|
}
|
|
58
68
|
if (!Array.isArray(selected) || selected.length === 0) {
|
|
69
|
+
const shouldShowPlaceholder = styling !== "default" || !label || placeholder;
|
|
59
70
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
|
|
60
71
|
"-webkit-text-fill-color": disabledColor,
|
|
61
|
-
}, color: disabledColor, variant: "body2", noWrap: true, children: placeholder }));
|
|
72
|
+
}, color: disabledColor, variant: "body2", noWrap: true, children: shouldShowPlaceholder ? placeholder : "" }));
|
|
62
73
|
}
|
|
63
74
|
const visibleItems = selectedOptions.slice(0, maxDisplayItems);
|
|
64
75
|
const overflowCount = selectedOptions.length - maxDisplayItems;
|
|
@@ -127,72 +138,89 @@ function Select({ control, defaultValue, name, required = false, multiple = fals
|
|
|
127
138
|
});
|
|
128
139
|
return items;
|
|
129
140
|
};
|
|
130
|
-
return ((0, jsx_runtime_1.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
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"
|
|
142
|
+
? {
|
|
143
|
+
...(0, commonStyles_1.getDefaultFormControlSx)(styling),
|
|
144
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
145
|
+
"& legend": {
|
|
146
|
+
maxWidth: 0,
|
|
147
|
+
"& span": {
|
|
148
|
+
padding: "0 5px",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
"& .MuiInputLabel-root.MuiInputLabel-shrink + .MuiInputBase-root .MuiOutlinedInput-notchedOutline legend": {
|
|
153
|
+
maxWidth: "100%",
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
: undefined, children: [label && styling === "default" && ((0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: `${name}-label`, sx: (0, commonStyles_1.getDefaultInputLabelSx)(styling), 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: {
|
|
157
|
+
"aria-label": styling === "custom" && label ? label : undefined,
|
|
158
|
+
},
|
|
159
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
160
|
+
onChange: (event) => {
|
|
161
|
+
const newValue = event.target.value;
|
|
162
|
+
if (setOnFinalChange) {
|
|
163
|
+
hasPendingChange.current = true;
|
|
164
|
+
if (multiple &&
|
|
165
|
+
Array.isArray(newValue) &&
|
|
166
|
+
newValue.includes("select-all")) {
|
|
167
|
+
setPendingValue(Array.isArray(pendingValue) &&
|
|
168
|
+
pendingValue.length ===
|
|
169
|
+
options.filter(({ disabled }) => !disabled).length
|
|
170
|
+
? []
|
|
171
|
+
: options
|
|
172
|
+
.filter(({ disabled }) => !disabled)
|
|
173
|
+
.map(({ value }) => value));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
setPendingValue(newValue);
|
|
177
|
+
}
|
|
146
178
|
}
|
|
147
179
|
else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
title: t("common.select.limitExceed", { maxLimit }),
|
|
161
|
-
});
|
|
162
|
-
return;
|
|
180
|
+
if (multiple && Array.isArray(newValue)) {
|
|
181
|
+
const isSelectAllIncluded = newValue.includes("select-all");
|
|
182
|
+
if (isSelectAllIncluded) {
|
|
183
|
+
handleSelectAll(!isAllSelected);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (maxLimit && newValue.length > maxLimit) {
|
|
187
|
+
Toast_1.toasts.error({
|
|
188
|
+
title: t("common.select.limitExceed", { maxLimit }),
|
|
189
|
+
});
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
163
192
|
}
|
|
193
|
+
onChange(newValue);
|
|
164
194
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
paddingBottom: 0,
|
|
195
|
+
}, onClose: () => {
|
|
196
|
+
if (setOnFinalChange && hasPendingChange.current) {
|
|
197
|
+
onChange(pendingValue);
|
|
198
|
+
hasPendingChange.current = false;
|
|
199
|
+
setPendingValue(null);
|
|
200
|
+
}
|
|
201
|
+
}, renderValue: restProps.renderValue ?? renderValue,
|
|
202
|
+
// eslint-disable-next-line sonarjs/no-unstable-nested-components
|
|
203
|
+
IconComponent: (props) => ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
204
|
+
display: "flex",
|
|
205
|
+
alignItems: "center",
|
|
206
|
+
gap: 0.5,
|
|
207
|
+
pr: 2.5,
|
|
208
|
+
}, children: [value &&
|
|
209
|
+
((Array.isArray(value) && value.length > 0) ||
|
|
210
|
+
(!Array.isArray(value) && value !== "")) &&
|
|
211
|
+
!disableClearable && ((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: (e) => {
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
onChange(multiple ? [] : "");
|
|
214
|
+
}, 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: {
|
|
215
|
+
PaperProps: {
|
|
216
|
+
sx: {
|
|
217
|
+
width: "inherit",
|
|
218
|
+
maxHeight: 300,
|
|
219
|
+
"& .MuiList-root": {
|
|
220
|
+
paddingTop: 0,
|
|
221
|
+
paddingBottom: 0,
|
|
222
|
+
},
|
|
194
223
|
},
|
|
195
224
|
},
|
|
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 })] }) }));
|
|
225
|
+
}, 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
226
|
}
|
|
@@ -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;AAOzB,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,2CAmHnB"}
|
|
@@ -4,13 +4,14 @@ exports.TextField = TextField;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
+
const commonStyles_1 = require("../commonStyles");
|
|
7
8
|
const Skeleton_1 = require("./Skeleton");
|
|
8
9
|
const characterTypeMessages = {
|
|
9
10
|
string: "Only alphabetic characters are allowed.",
|
|
10
11
|
"string-number": "Only letters and numbers are allowed.",
|
|
11
12
|
"string-number-special": "Special characters are allowed.",
|
|
12
13
|
};
|
|
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 }) {
|
|
14
|
+
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
15
|
const { field: { value, onChange, ...restField }, fieldState: { error }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
15
16
|
const handleKeyDown = (event) => {
|
|
16
17
|
if (event.key === "-" && type === "number") {
|
|
@@ -49,7 +50,7 @@ function TextField({ control, name, defaultValue, label = "", rules, type, requi
|
|
|
49
50
|
if (loading) {
|
|
50
51
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label, rows: rows });
|
|
51
52
|
}
|
|
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, inputProps: {
|
|
53
|
+
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, sx: (0, commonStyles_1.getDefaultTextFieldSx)(styling), InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling), inputProps: {
|
|
53
54
|
min: 0,
|
|
54
55
|
}, error: Boolean(error), helperText: error?.message, onChange: (event) => {
|
|
55
56
|
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;AAQzB,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,2CAkFnB"}
|
|
@@ -6,8 +6,9 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
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
|
+
const commonStyles_1 = require("../commonStyles");
|
|
9
10
|
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 }) {
|
|
11
|
+
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
12
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
12
13
|
const theme = (0, material_1.useTheme)();
|
|
13
14
|
const { butterflyBlue } = theme.palette.app.color;
|
|
@@ -20,7 +21,7 @@ function TimeField({ control, defaultValue, disabled = false, label, name, error
|
|
|
20
21
|
if (loading) {
|
|
21
22
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
22
23
|
}
|
|
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) => {
|
|
24
|
+
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
25
|
if (value?.isValid) {
|
|
25
26
|
if (isReturnLocalTime) {
|
|
26
27
|
return onChange(value.toFormat(format));
|
|
@@ -38,7 +39,11 @@ function TimeField({ control, defaultValue, disabled = false, label, name, error
|
|
|
38
39
|
disabled,
|
|
39
40
|
helperText,
|
|
40
41
|
error,
|
|
42
|
+
label: styling === "default" ? label : undefined,
|
|
43
|
+
required: styling === "default" ? required : undefined,
|
|
44
|
+
InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling),
|
|
41
45
|
sx: {
|
|
46
|
+
...(0, commonStyles_1.getDefaultTextFieldSx)(styling),
|
|
42
47
|
backgroundColor: "white",
|
|
43
48
|
"& .Mui-selected": {
|
|
44
49
|
backgroundColor: butterflyBlue[900],
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,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,eAAe,CAAC,CAAC,CAAC,2CA4HpB"}
|
|
@@ -7,8 +7,9 @@ const TimePicker_1 = require("@mui/x-date-pickers/TimePicker");
|
|
|
7
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
|
+
const commonStyles_1 = require("../commonStyles");
|
|
10
11
|
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 }) {
|
|
12
|
+
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
13
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
13
14
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
14
15
|
if (error && value && typeof value === "object") {
|
|
@@ -22,12 +23,16 @@ function TimePicker({ control, defaultValue, disabled = false, label, readOnly =
|
|
|
22
23
|
if (loading) {
|
|
23
24
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { label: label });
|
|
24
25
|
}
|
|
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: {
|
|
26
|
+
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
27
|
textField: {
|
|
27
28
|
disabled,
|
|
28
29
|
helperText,
|
|
29
30
|
error,
|
|
31
|
+
label: styling === "default" ? label : undefined,
|
|
32
|
+
required: styling === "default" ? required : undefined,
|
|
33
|
+
InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling),
|
|
30
34
|
sx: {
|
|
35
|
+
...(0, commonStyles_1.getDefaultTextFieldSx)(styling),
|
|
31
36
|
backgroundColor: "white",
|
|
32
37
|
"& .Mui-selected": {
|
|
33
38
|
backgroundColor: butterflyBlue[900],
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SxProps, Theme } from "@mui/material";
|
|
2
|
+
export declare const getDefaultInputLabelProps: (styling?: "custom" | "default") => {
|
|
3
|
+
sx?: SxProps<Theme>;
|
|
4
|
+
} | undefined;
|
|
5
|
+
export declare const getDefaultTextFieldSx: (styling?: "custom" | "default") => SxProps<Theme> | undefined;
|
|
6
|
+
export declare const getDefaultFormControlSx: (styling?: "custom" | "default") => SxProps<Theme> | undefined;
|
|
7
|
+
export declare const getDefaultInputLabelSx: (styling?: "custom" | "default") => SxProps<Theme> | undefined;
|
|
8
|
+
//# sourceMappingURL=commonStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonStyles.d.ts","sourceRoot":"","sources":["../../src/FormFields/commonStyles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,yBAAyB,GACpC,UAAU,QAAQ,GAAG,SAAS,KAC7B;IAAE,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,SAkB5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,UAAU,QAAQ,GAAG,SAAS,KAE7B,OAAO,CAAC,KAAK,CAAC,GAAG,SAanB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,QAAQ,GAAG,SAAS,KAE7B,OAAO,CAAC,KAAK,CAAC,GAAG,SAUnB,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,UAAU,QAAQ,GAAG,SAAS,KAE7B,OAAO,CAAC,KAAK,CAAC,GAAG,SAgBnB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultInputLabelSx = exports.getDefaultFormControlSx = exports.getDefaultTextFieldSx = exports.getDefaultInputLabelProps = void 0;
|
|
4
|
+
const getDefaultInputLabelProps = (styling) => {
|
|
5
|
+
if (styling !== "default") {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
sx: {
|
|
10
|
+
opacity: 0.8,
|
|
11
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
12
|
+
fontSize: "14px",
|
|
13
|
+
top: "calc(var(--input-base-height, 56px) / 2)",
|
|
14
|
+
transform: "translate(14px, -90%)",
|
|
15
|
+
},
|
|
16
|
+
"&.MuiInputLabel-shrink": {
|
|
17
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.getDefaultInputLabelProps = getDefaultInputLabelProps;
|
|
23
|
+
const getDefaultTextFieldSx = (styling
|
|
24
|
+
// eslint-disable-next-line sonarjs/function-return-type
|
|
25
|
+
) => {
|
|
26
|
+
if (styling !== "default") {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
"& .MuiInputBase-root": {
|
|
31
|
+
"--input-base-height": "100%",
|
|
32
|
+
},
|
|
33
|
+
"&.MuiTextField-sizeSmall .MuiInputBase-root": {
|
|
34
|
+
"--input-base-height-small": "40px",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.getDefaultTextFieldSx = getDefaultTextFieldSx;
|
|
39
|
+
const getDefaultFormControlSx = (styling
|
|
40
|
+
// eslint-disable-next-line sonarjs/function-return-type
|
|
41
|
+
) => {
|
|
42
|
+
if (styling !== "default") {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
"& .MuiInputBase-root": {
|
|
47
|
+
"--input-base-height": "100%",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.getDefaultFormControlSx = getDefaultFormControlSx;
|
|
52
|
+
const getDefaultInputLabelSx = (styling
|
|
53
|
+
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
|
+
) => {
|
|
55
|
+
if (styling !== "default") {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
opacity: 0.8,
|
|
60
|
+
"&:not(.MuiInputLabel-shrink)": {
|
|
61
|
+
fontSize: "14px",
|
|
62
|
+
top: "calc(var(--input-base-height, 56px) / 2)",
|
|
63
|
+
transform: "translate(14px, -90%)",
|
|
64
|
+
},
|
|
65
|
+
"&.MuiInputLabel-shrink": {
|
|
66
|
+
transform: "translate(14px, -9px) scale(0.75)",
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.getDefaultInputLabelSx = getDefaultInputLabelSx;
|
|
@@ -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;
|