@codezee/sixtify-brahma 0.2.198 → 0.2.199
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 -3
- package/packages/shared-components/dist/ActionButtons/ActionButtons.d.ts.map +1 -1
- package/packages/shared-components/dist/ActionButtons/ActionButtons.js +7 -6
- package/packages/shared-components/dist/ActionButtons/FormActionButton.d.ts.map +1 -1
- package/packages/shared-components/dist/ActionButtons/FormActionButton.js +12 -13
- package/packages/shared-components/dist/ActionButtons/types.d.ts +0 -10
- package/packages/shared-components/dist/ActionButtons/types.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/Autocomplete/Autocomplete.js +18 -21
- package/packages/shared-components/dist/utils/helper.d.ts +7 -0
- package/packages/shared-components/dist/utils/helper.d.ts.map +1 -1
- package/packages/shared-components/dist/utils/helper.js +13 -1
- 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 +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StackProps, SxProps } from "@mui/material";
|
|
2
|
-
import type { ActionButton
|
|
3
|
-
export type ActionButtonsProps =
|
|
2
|
+
import type { ActionButton } from "./types";
|
|
3
|
+
export type ActionButtonsProps = {
|
|
4
4
|
buttons: ActionButton[];
|
|
5
5
|
justifyContent?: StackProps["justifyContent"];
|
|
6
6
|
sx?: SxProps;
|
|
@@ -9,5 +9,5 @@ export type ActionButtonsProps = DataProps & {
|
|
|
9
9
|
disable?: boolean;
|
|
10
10
|
shortcutKey?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare const ActionButtons: ({ buttons, justifyContent, sx, buttonSx, shouldOpenMenuOnShortcut, disable, shortcutKey, }: ActionButtonsProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
//# 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;AAKzD,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
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,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,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,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,4FAQ3B,kBAAkB,4CAgLpB,CAAC"}
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ActionButtons =
|
|
6
|
+
exports.ActionButtons = void 0;
|
|
7
7
|
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
11
|
const utils_1 = require("../utils");
|
|
12
|
-
|
|
12
|
+
const ActionButtons = ({ buttons, justifyContent = "end", sx, buttonSx, shouldOpenMenuOnShortcut = false, disable = false, shortcutKey = "a", }) => {
|
|
13
13
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
14
14
|
const [openMenuKey, setOpenMenuKey] = (0, react_1.useState)(null);
|
|
15
15
|
const buttonRefs = (0, react_1.useRef)({});
|
|
@@ -59,8 +59,8 @@ function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOp
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", sx: sx, gap: "1.6rem", justifyContent: justifyContent, children: buttons
|
|
62
|
-
.filter((button) => !button.hidden)
|
|
63
|
-
.map(({ menuItems, key, ...button }) => {
|
|
62
|
+
.filter(({ button }) => !button.hidden)
|
|
63
|
+
.map(({ menuItems, key, menuPlacement, ...button }) => {
|
|
64
64
|
const visibleMenuItems = menuItems?.filter((menuItem) => !menuItem.hidden);
|
|
65
65
|
const isMenuOpen = openMenuKey === key;
|
|
66
66
|
const onClick = visibleMenuItems && visibleMenuItems.length > 0
|
|
@@ -76,7 +76,7 @@ function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOp
|
|
|
76
76
|
buttonRefs.current[key] = el;
|
|
77
77
|
}, ...buttonProps, children: button.icon }, key)), isMenuOpen && visibleMenuItems && ((0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl && isMenuOpen), onClose: handleMenuClose, anchorOrigin: {
|
|
78
78
|
vertical: "bottom",
|
|
79
|
-
horizontal:
|
|
79
|
+
horizontal: menuPlacement === "left" ? "left" : "right",
|
|
80
80
|
}, sx: {
|
|
81
81
|
top: "3px",
|
|
82
82
|
}, children: visibleMenuItems.map((item) => {
|
|
@@ -94,4 +94,5 @@ function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOp
|
|
|
94
94
|
}, children: [item.icon, item.label] }, item.key));
|
|
95
95
|
}) }))] }, key));
|
|
96
96
|
}) }));
|
|
97
|
-
}
|
|
97
|
+
};
|
|
98
|
+
exports.ActionButtons = ActionButtons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormActionButton.d.ts","sourceRoot":"","sources":["../../src/ActionButtons/FormActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhE,KAAK,qBAAqB,GAAG,WAAW,GAAG;IACzC,OAAO,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,CAAC;IACR,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC,CAAC;AAEL,eAAO,MAAM,gBAAgB,GAAI,6HAW9B,QAAQ,CAAC,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"FormActionButton.d.ts","sourceRoot":"","sources":["../../src/ActionButtons/FormActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEhE,KAAK,qBAAqB,GAAG,WAAW,GAAG;IACzC,OAAO,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,CAAC;IACR,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC,CAAC;AAEL,eAAO,MAAM,gBAAgB,GAAI,6HAW9B,QAAQ,CAAC,qBAAqB,CAAC,4CA8DjC,CAAC"}
|
|
@@ -32,19 +32,18 @@ const FormActionButton = ({ actionType, onClick, shortcutKey, label, withoutModi
|
|
|
32
32
|
}
|
|
33
33
|
return variant;
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
35
|
+
(0, utils_1.useGlobalKeyboardShortcut)({
|
|
36
|
+
key: getShortcutKey(),
|
|
37
|
+
enabled: !disableKeyboardShortcut && !loading && !disabled,
|
|
38
|
+
withoutModifiers: actionType == "cancel" ? true : withoutModifiers,
|
|
39
|
+
modifierKeys: actionType != "cancel" ? ["ctrl", "shift"] : undefined,
|
|
40
|
+
onTrigger: () => {
|
|
41
|
+
if (disabled || loading) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
onClick();
|
|
45
|
+
},
|
|
46
|
+
});
|
|
48
47
|
return ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onClick, variant: getVariant(), loading: loading, disabled: disabled, ...rest, children: getLabel() }));
|
|
49
48
|
};
|
|
50
49
|
exports.FormActionButton = FormActionButton;
|
|
@@ -5,8 +5,6 @@ export type SubMenuItem = {
|
|
|
5
5
|
label: ReactNode;
|
|
6
6
|
onClick?: OnAction;
|
|
7
7
|
icon?: ReactNode;
|
|
8
|
-
dataPTag?: string;
|
|
9
|
-
dataCy?: string;
|
|
10
8
|
hidden?: boolean;
|
|
11
9
|
};
|
|
12
10
|
export type MenuItem = {
|
|
@@ -14,8 +12,6 @@ export type MenuItem = {
|
|
|
14
12
|
label: ReactNode;
|
|
15
13
|
onClick?: OnAction;
|
|
16
14
|
icon?: ReactNode;
|
|
17
|
-
dataPTag?: string;
|
|
18
|
-
dataCy?: string;
|
|
19
15
|
divider?: boolean;
|
|
20
16
|
hidden?: boolean;
|
|
21
17
|
subMenuItems?: SubMenuItem[];
|
|
@@ -30,15 +26,9 @@ export type ActionButton = {
|
|
|
30
26
|
endIcon?: ReactNode;
|
|
31
27
|
menuPlacement?: "left" | "right";
|
|
32
28
|
size?: "small" | "medium" | "large";
|
|
33
|
-
dataPTag?: string;
|
|
34
|
-
dataCy?: string;
|
|
35
29
|
hidden?: boolean;
|
|
36
30
|
disableElevation?: boolean;
|
|
37
31
|
[x: string]: any;
|
|
38
32
|
disabled?: boolean;
|
|
39
33
|
};
|
|
40
|
-
export type DataProps = {
|
|
41
|
-
dataPTag?: string;
|
|
42
|
-
dataCy?: string;
|
|
43
|
-
};
|
|
44
34
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ActionButtons/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,
|
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AM,GAAG,GAAG,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,IAAI,oBAAoB,EACzC,UAAU,EACX,MAAM,eAAe,CAAC;AAyBvB,OAAO,EAML,KAAK,SAAS,EAGd,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../src/FormFields/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,IAAI,oBAAoB,EACzC,UAAU,EACX,MAAM,eAAe,CAAC;AAyBvB,OAAO,EAML,KAAK,SAAS,EAGd,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAU3D,MAAM,MAAM,MAAM,GAAG;IACnB,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,EA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AE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC9B,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAG9B,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEJ,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,EAClD,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAgB,EAChB,KAAK,EACL,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,wBAAgC,EAChC,UAAU,EACV,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,SAAiB,EACjB,aAAa,EACb,gBAA0C,EAC1C,cAAc,EACd,QAAQ,EACR,SAAa,EACb,OAAkB,EAClB,aAAqB,EACrB,cAAc,EACd,cAAsB,EACtB,GAAG,SAAS,EACb,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAk0BtB"}
|
|
@@ -20,6 +20,7 @@ const react_i18next_1 = require("react-i18next");
|
|
|
20
20
|
const Actions_1 = require("../../Actions");
|
|
21
21
|
const Toast_1 = require("../../Toast");
|
|
22
22
|
const Tooltip_1 = require("../../Tooltip");
|
|
23
|
+
const utils_1 = require("../../utils");
|
|
23
24
|
const useAutocompleteScrollToSelected_1 = require("../../utils/hooks/useAutocompleteScrollToSelected");
|
|
24
25
|
const useFormFieldFocus_1 = require("../../utils/hooks/useFormFieldFocus");
|
|
25
26
|
const CheckBox_styled_1 = require("../CheckBox/CheckBox.styled");
|
|
@@ -35,7 +36,6 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
35
36
|
rules,
|
|
36
37
|
});
|
|
37
38
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
38
|
-
const [inputValue, setInputValue] = (0, react_1.useState)("");
|
|
39
39
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
40
40
|
const { open: controlledOpen, onOpen: externalOnOpen, onClose: externalOnClose, ...restMuiProps } = restProps;
|
|
41
41
|
const isControlledOpen = controlledOpen !== undefined;
|
|
@@ -124,12 +124,6 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
124
124
|
...options,
|
|
125
125
|
];
|
|
126
126
|
}, [multiple, isShowSelectAll, options]);
|
|
127
|
-
const filteredOptions = (0, react_1.useMemo)(() => {
|
|
128
|
-
if (inputValue.length < 3) {
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
return options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
132
|
-
}, [inputValue]);
|
|
133
127
|
(0, react_1.useMemo)(() => {
|
|
134
128
|
if ((0, isFunction_1.default)(setValue) && required && options.length === 1 && !value) {
|
|
135
129
|
setValue(name, options[0]?.value, {
|
|
@@ -221,7 +215,21 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
221
215
|
borderRadius: "50%",
|
|
222
216
|
},
|
|
223
217
|
width: "100%",
|
|
224
|
-
}, open: internalOpen, onOpen: handleOpen, onClose: handleClose, disableCloseOnSelect: multiple && !shouldCloseOnSelect, disabled: disabled, freeSolo: freeSolo,
|
|
218
|
+
}, open: internalOpen, onOpen: handleOpen, onClose: handleClose, disableCloseOnSelect: multiple && !shouldCloseOnSelect, disabled: disabled, freeSolo: freeSolo, filterOptions: (options, state) => {
|
|
219
|
+
const { inputValue } = state;
|
|
220
|
+
if (!inputValue && isShowOptionsOnType) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const lowerTerm = inputValue.toLowerCase();
|
|
224
|
+
const fieldsToSearch = isShowOptionsOnType || isShowEmployeeData
|
|
225
|
+
? ["label", "punch_code", "employee_code"]
|
|
226
|
+
: ["label"];
|
|
227
|
+
return (0, utils_1.filterByFields)({
|
|
228
|
+
data: options,
|
|
229
|
+
fieldsToSearch,
|
|
230
|
+
term: lowerTerm,
|
|
231
|
+
});
|
|
232
|
+
}, ...restMuiProps, ...restField, disableClearable: disableClearable, slotProps: {
|
|
225
233
|
clearIndicator: {
|
|
226
234
|
tabIndex: disableClearable ||
|
|
227
235
|
(multiple
|
|
@@ -402,12 +410,8 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
402
410
|
}
|
|
403
411
|
externalOnClose?.(event, "escape");
|
|
404
412
|
}, internalOpen);
|
|
405
|
-
}, onChange: (e) => {
|
|
406
|
-
if (isShowOptionsOnType) {
|
|
407
|
-
setInputValue(e.target.value);
|
|
408
|
-
}
|
|
409
413
|
} }));
|
|
410
|
-
}, blurOnSelect: !multiple, multiple: multiple, options:
|
|
414
|
+
}, blurOnSelect: !multiple, multiple: multiple, options: memoizedOptions, isOptionEqualToValue: (option, value) => freeSolo ? false : option.value === value.value, getOptionLabel: (option) => {
|
|
411
415
|
if (getOptionLabel) {
|
|
412
416
|
return getOptionLabel(option);
|
|
413
417
|
}
|
|
@@ -418,9 +422,6 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
418
422
|
}, value: selectedValue,
|
|
419
423
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
420
424
|
onChange: (_, newValue) => {
|
|
421
|
-
if (!newValue) {
|
|
422
|
-
setInputValue("");
|
|
423
|
-
}
|
|
424
425
|
if (withLabel) {
|
|
425
426
|
onChange(newValue);
|
|
426
427
|
formatValueForCustomOnChange(newValue, false);
|
|
@@ -478,11 +479,7 @@ function Autocomplete({ control, defaultValue, name, required = false, label, mu
|
|
|
478
479
|
return (0, jsx_runtime_1.jsx)(material_1.Box, { children: params.children });
|
|
479
480
|
}
|
|
480
481
|
return ((0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)(GroupHeader, { children: params.group }), (0, jsx_runtime_1.jsx)(GroupItems, { children: params.children })] }, params.key));
|
|
481
|
-
}, getOptionDisabled: (option) => !!option.disabled,
|
|
482
|
-
if (!multiple) {
|
|
483
|
-
setInputValue("");
|
|
484
|
-
}
|
|
485
|
-
}, autoHighlight: true }), onAction &&
|
|
482
|
+
}, getOptionDisabled: (option) => !!option.disabled, autoHighlight: true }), onAction &&
|
|
486
483
|
!actionInsideAutocomplete &&
|
|
487
484
|
(onActionClick ? ((0, jsx_runtime_1.jsx)(Actions_1.EditIconAction, { disabled: disabled, onClick: () => {
|
|
488
485
|
onActionClick();
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type { FieldValues } from "react-hook-form";
|
|
1
2
|
export declare const getZIndex: (element: HTMLElement) => number;
|
|
2
3
|
export declare const hslToRgb: (h: number, s: number, l: number) => [number, number, number];
|
|
4
|
+
export type FilterByFields<T extends FieldValues> = {
|
|
5
|
+
data: T[];
|
|
6
|
+
fieldsToSearch: (keyof T)[];
|
|
7
|
+
term: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const filterByFields: <T extends FieldValues>({ data, fieldsToSearch, term, }: FilterByFields<T>) => T[];
|
|
3
10
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/utils/helper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,SAAS,WAAW,WAI7C,CAAC;AAEF,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,GAAG,MAAM,KACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CA8BzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/utils/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAO,MAAM,SAAS,GAAI,SAAS,WAAW,WAI7C,CAAC;AAEF,eAAO,MAAM,QAAQ,GACnB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,GAAG,MAAM,KACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CA8BzB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI;IAClD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,cAAc,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,WAAW,EAAE,iCAInD,cAAc,CAAC,CAAC,CAAC,KAAG,CAAC,EAgBvB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hslToRgb = exports.getZIndex = void 0;
|
|
3
|
+
exports.filterByFields = exports.hslToRgb = exports.getZIndex = void 0;
|
|
4
4
|
const getZIndex = (element) => {
|
|
5
5
|
const parsed = parseInt(window.getComputedStyle(element).zIndex ?? "", 10);
|
|
6
6
|
return isNaN(parsed) ? 0 : parsed;
|
|
@@ -36,3 +36,15 @@ const hslToRgb = (h, s, l) => {
|
|
|
36
36
|
];
|
|
37
37
|
};
|
|
38
38
|
exports.hslToRgb = hslToRgb;
|
|
39
|
+
const filterByFields = ({ data, fieldsToSearch, term, }) => {
|
|
40
|
+
const clonedData = [...data];
|
|
41
|
+
if (!term) {
|
|
42
|
+
return clonedData;
|
|
43
|
+
}
|
|
44
|
+
const lowerTerm = term.toLowerCase();
|
|
45
|
+
return clonedData.filter((obj) => fieldsToSearch.some((key) => {
|
|
46
|
+
const value = obj[key];
|
|
47
|
+
return value && String(value).toLowerCase().includes(lowerTerm);
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
exports.filterByFields = filterByFields;
|
|
@@ -5,7 +5,8 @@ type UseGlobalKeyboardShortcutArgs = {
|
|
|
5
5
|
onTrigger: OnAction;
|
|
6
6
|
modifierKeys?: ModifierType | ModifierType[];
|
|
7
7
|
withoutModifiers?: boolean;
|
|
8
|
+
enabled?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export declare const useGlobalKeyboardShortcut: ({ key, onTrigger, modifierKeys, withoutModifiers, }: UseGlobalKeyboardShortcutArgs) => void;
|
|
10
|
+
export declare const useGlobalKeyboardShortcut: ({ key, onTrigger, modifierKeys, withoutModifiers, enabled, }: UseGlobalKeyboardShortcutArgs) => void;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=useGlobalKeyboardShortcut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalKeyboardShortcut.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useGlobalKeyboardShortcut.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAEpD,KAAK,6BAA6B,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useGlobalKeyboardShortcut.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/useGlobalKeyboardShortcut.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAEpD,KAAK,6BAA6B,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,8DAMvC,6BAA6B,SA4H/B,CAAC"}
|
|
@@ -8,8 +8,11 @@ exports.useGlobalKeyboardShortcut = void 0;
|
|
|
8
8
|
const castArray_1 = __importDefault(require("lodash/castArray"));
|
|
9
9
|
const every_1 = __importDefault(require("lodash/every"));
|
|
10
10
|
const react_1 = require("react");
|
|
11
|
-
const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", withoutModifiers = false, }) => {
|
|
11
|
+
const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", withoutModifiers = false, enabled = true, }) => {
|
|
12
12
|
(0, react_1.useEffect)(() => {
|
|
13
|
+
if (!enabled) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
13
16
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
14
17
|
const handler = (e) => {
|
|
15
18
|
const eventTarget = e.target;
|
|
@@ -86,6 +89,6 @@ const useGlobalKeyboardShortcut = ({ key, onTrigger, modifierKeys = "ctrl", with
|
|
|
86
89
|
};
|
|
87
90
|
window.addEventListener("keydown", handler, true);
|
|
88
91
|
return () => window.removeEventListener("keydown", handler, true);
|
|
89
|
-
}, [key, modifierKeys, onTrigger, withoutModifiers]);
|
|
92
|
+
}, [key, modifierKeys, onTrigger, withoutModifiers, enabled]);
|
|
90
93
|
};
|
|
91
94
|
exports.useGlobalKeyboardShortcut = useGlobalKeyboardShortcut;
|