@bigbinary/neeto-commons-frontend 2.0.40 → 2.0.42
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/initializers.cjs.js +8 -0
- package/initializers.js +8 -0
- package/package.json +1 -1
- package/react-utils.cjs.js +31 -21
- package/react-utils.d.ts +3 -3
- package/react-utils.js +31 -21
- package/utils.cjs.js +0 -14
- package/utils.js +1 -14
package/initializers.cjs.js
CHANGED
|
@@ -126,6 +126,14 @@ var showSuccessToastr = function showSuccessToastr(response) {
|
|
|
126
126
|
icon: "👍",
|
|
127
127
|
className: "w-20"
|
|
128
128
|
});
|
|
129
|
+
} else if (pure.matches({
|
|
130
|
+
noticeCode: "thumbs_up"
|
|
131
|
+
}, response.data)) {
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
neetoui.Toastr.success("", {
|
|
134
|
+
icon: "👍",
|
|
135
|
+
className: "w-20"
|
|
136
|
+
});
|
|
129
137
|
} else if (shouldShowToastr(response.data)) {
|
|
130
138
|
neetoui.Toastr.success(response.data);
|
|
131
139
|
}
|
package/initializers.js
CHANGED
|
@@ -116,6 +116,14 @@ var showSuccessToastr = function showSuccessToastr(response) {
|
|
|
116
116
|
icon: "👍",
|
|
117
117
|
className: "w-20"
|
|
118
118
|
});
|
|
119
|
+
} else if (matches({
|
|
120
|
+
noticeCode: "thumbs_up"
|
|
121
|
+
}, response.data)) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
Toastr.success("", {
|
|
124
|
+
icon: "👍",
|
|
125
|
+
className: "w-20"
|
|
126
|
+
});
|
|
119
127
|
} else if (shouldShowToastr(response.data)) {
|
|
120
128
|
Toastr.success(response.data);
|
|
121
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.42",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
package/react-utils.cjs.js
CHANGED
|
@@ -3532,14 +3532,18 @@ var useHotKeys = function useHotKeys(hotkey, handler, userConfig) {
|
|
|
3532
3532
|
var convertedHotkey = convertHotkeyToUsersPlatform(hotkey);
|
|
3533
3533
|
var config = ramda.mergeLeft(userConfig, DEFAULT_CONFIG);
|
|
3534
3534
|
React.useEffect(function () {
|
|
3535
|
-
config.enabled && bindHotKey({
|
|
3535
|
+
var mousetrapInstance = config.enabled && bindHotKey({
|
|
3536
3536
|
mode: config.mode,
|
|
3537
3537
|
hotkey: convertedHotkey,
|
|
3538
3538
|
handler: handler,
|
|
3539
3539
|
ref: ref
|
|
3540
3540
|
});
|
|
3541
3541
|
return function () {
|
|
3542
|
-
config.unbindOnUnmount && unBindHotKey(
|
|
3542
|
+
config.unbindOnUnmount && unBindHotKey({
|
|
3543
|
+
mousetrapInstance: mousetrapInstance,
|
|
3544
|
+
mode: config.mode,
|
|
3545
|
+
hotkey: convertedHotkey
|
|
3546
|
+
});
|
|
3543
3547
|
};
|
|
3544
3548
|
}, [handler, config.mode, convertedHotkey, config]);
|
|
3545
3549
|
return config.mode === MODES$1.scoped ? ref : null;
|
|
@@ -3549,19 +3553,24 @@ var bindHotKey = function bindHotKey(_ref) {
|
|
|
3549
3553
|
hotkey = _ref.hotkey,
|
|
3550
3554
|
handler = _ref.handler,
|
|
3551
3555
|
ref = _ref.ref;
|
|
3556
|
+
var mousetrapInstance;
|
|
3552
3557
|
switch (mode) {
|
|
3553
3558
|
case MODES$1.global:
|
|
3554
3559
|
Mousetrap$1.bindGlobal(hotkey, handler);
|
|
3555
3560
|
break;
|
|
3556
3561
|
case MODES$1.scoped:
|
|
3557
|
-
Mousetrap$1(ref.current).bind(hotkey, handler);
|
|
3562
|
+
mousetrapInstance = Mousetrap$1(ref.current).bind(hotkey, handler);
|
|
3558
3563
|
break;
|
|
3559
3564
|
default:
|
|
3560
|
-
Mousetrap$1.bind(hotkey, handler);
|
|
3565
|
+
mousetrapInstance = Mousetrap$1.bind(hotkey, handler);
|
|
3561
3566
|
}
|
|
3567
|
+
return mousetrapInstance;
|
|
3562
3568
|
};
|
|
3563
|
-
var unBindHotKey = function unBindHotKey(
|
|
3564
|
-
|
|
3569
|
+
var unBindHotKey = function unBindHotKey(_ref2) {
|
|
3570
|
+
var mousetrapInstance = _ref2.mousetrapInstance,
|
|
3571
|
+
mode = _ref2.mode,
|
|
3572
|
+
hotkey = _ref2.hotkey;
|
|
3573
|
+
return mode === MODES$1.global ? Mousetrap$1.unbindGlobal(hotkey) : mousetrapInstance === null || mousetrapInstance === void 0 ? void 0 : mousetrapInstance.unbind(hotkey);
|
|
3565
3574
|
};
|
|
3566
3575
|
|
|
3567
3576
|
var useForceUpdate = function useForceUpdate() {
|
|
@@ -7915,19 +7924,6 @@ var IpRestriction = function IpRestriction() {
|
|
|
7915
7924
|
}, /*#__PURE__*/React__default["default"].createElement(CurrentIp, null), /*#__PURE__*/React__default["default"].createElement(AllowedIpRanges, null)));
|
|
7916
7925
|
};
|
|
7917
7926
|
|
|
7918
|
-
var getGlobalShortcuts = function getGlobalShortcuts() {
|
|
7919
|
-
return _defineProperty({}, i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
7920
|
-
openKeyboardShortcutsPane: {
|
|
7921
|
-
sequence: "shift+/",
|
|
7922
|
-
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
7923
|
-
},
|
|
7924
|
-
close: {
|
|
7925
|
-
sequence: "esc",
|
|
7926
|
-
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.close")
|
|
7927
|
-
}
|
|
7928
|
-
});
|
|
7929
|
-
};
|
|
7930
|
-
|
|
7931
7927
|
var DisplayHotKey = function DisplayHotKey(_ref) {
|
|
7932
7928
|
var hotkey = _ref.hotkey;
|
|
7933
7929
|
var isSequentialHotkey = hotkey.includes(" ");
|
|
@@ -7970,6 +7966,18 @@ var shortenHotKey = function shortenHotKey(hotkey) {
|
|
|
7970
7966
|
});
|
|
7971
7967
|
return result;
|
|
7972
7968
|
};
|
|
7969
|
+
var getGlobalShortcuts = function getGlobalShortcuts() {
|
|
7970
|
+
return _defineProperty({}, i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
7971
|
+
openKeyboardShortcutsPane: {
|
|
7972
|
+
sequence: "shift+/",
|
|
7973
|
+
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
7974
|
+
},
|
|
7975
|
+
close: {
|
|
7976
|
+
sequence: "esc",
|
|
7977
|
+
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.close")
|
|
7978
|
+
}
|
|
7979
|
+
});
|
|
7980
|
+
};
|
|
7973
7981
|
|
|
7974
7982
|
var HotKeyList = function HotKeyList(_ref) {
|
|
7975
7983
|
var hotkeys = _ref.hotkeys;
|
|
@@ -8013,7 +8021,9 @@ var KeyboardShortcutsPane = function KeyboardShortcutsPane(_ref) {
|
|
|
8013
8021
|
setIsOpen = _useKeyboardShortcuts2[1];
|
|
8014
8022
|
var hasOverlays = managers.manager.hasOverlays();
|
|
8015
8023
|
var GLOBAL_SHORTCUTS = getGlobalShortcuts();
|
|
8016
|
-
var
|
|
8024
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
8025
|
+
t = _useTranslation.t;
|
|
8026
|
+
var shortcuts = GLOBAL_SHORTCUTS[t("neetoCommons.keyboardShortcuts.global.categoryName")];
|
|
8017
8027
|
useHotKeys(shortcuts.openKeyboardShortcutsPane.sequence, function () {
|
|
8018
8028
|
return setIsOpen(function (prevIsOpen) {
|
|
8019
8029
|
return !prevIsOpen;
|
|
@@ -8039,7 +8049,7 @@ var KeyboardShortcutsPane = function KeyboardShortcutsPane(_ref) {
|
|
|
8039
8049
|
className: "neeto-ui-border-gray-300 my-2 flex items-center justify-between border-b px-4 pb-2"
|
|
8040
8050
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
8041
8051
|
style: "h4"
|
|
8042
|
-
},
|
|
8052
|
+
}, t("neetoCommons.keyboardShortcuts.title")), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
8043
8053
|
icon: neetoIcons.Close,
|
|
8044
8054
|
style: "text",
|
|
8045
8055
|
onClick: function onClick() {
|
package/react-utils.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ export const Columns: React.FC<{
|
|
|
131
131
|
noColumnMessage?: string;
|
|
132
132
|
onChange: (columns: any[]) => any[];
|
|
133
133
|
searchProps?: InputProps;
|
|
134
|
-
}
|
|
134
|
+
}>;
|
|
135
135
|
|
|
136
136
|
type ZustandConfigType = (
|
|
137
137
|
set: (data: any) => void,
|
|
@@ -269,8 +269,8 @@ type ConfigType = {
|
|
|
269
269
|
enabled?: boolean;
|
|
270
270
|
};
|
|
271
271
|
export function useHotKeys(
|
|
272
|
-
hotkey: string,
|
|
273
|
-
handler: () => void,
|
|
272
|
+
hotkey: string | string[],
|
|
273
|
+
handler: (event: React.KeyboardEvent) => void,
|
|
274
274
|
config?: ConfigType
|
|
275
275
|
): React.MutableRefObject | null;
|
|
276
276
|
|
package/react-utils.js
CHANGED
|
@@ -3495,14 +3495,18 @@ var useHotKeys = function useHotKeys(hotkey, handler, userConfig) {
|
|
|
3495
3495
|
var convertedHotkey = convertHotkeyToUsersPlatform(hotkey);
|
|
3496
3496
|
var config = mergeLeft(userConfig, DEFAULT_CONFIG);
|
|
3497
3497
|
useEffect(function () {
|
|
3498
|
-
config.enabled && bindHotKey({
|
|
3498
|
+
var mousetrapInstance = config.enabled && bindHotKey({
|
|
3499
3499
|
mode: config.mode,
|
|
3500
3500
|
hotkey: convertedHotkey,
|
|
3501
3501
|
handler: handler,
|
|
3502
3502
|
ref: ref
|
|
3503
3503
|
});
|
|
3504
3504
|
return function () {
|
|
3505
|
-
config.unbindOnUnmount && unBindHotKey(
|
|
3505
|
+
config.unbindOnUnmount && unBindHotKey({
|
|
3506
|
+
mousetrapInstance: mousetrapInstance,
|
|
3507
|
+
mode: config.mode,
|
|
3508
|
+
hotkey: convertedHotkey
|
|
3509
|
+
});
|
|
3506
3510
|
};
|
|
3507
3511
|
}, [handler, config.mode, convertedHotkey, config]);
|
|
3508
3512
|
return config.mode === MODES$1.scoped ? ref : null;
|
|
@@ -3512,19 +3516,24 @@ var bindHotKey = function bindHotKey(_ref) {
|
|
|
3512
3516
|
hotkey = _ref.hotkey,
|
|
3513
3517
|
handler = _ref.handler,
|
|
3514
3518
|
ref = _ref.ref;
|
|
3519
|
+
var mousetrapInstance;
|
|
3515
3520
|
switch (mode) {
|
|
3516
3521
|
case MODES$1.global:
|
|
3517
3522
|
Mousetrap$1.bindGlobal(hotkey, handler);
|
|
3518
3523
|
break;
|
|
3519
3524
|
case MODES$1.scoped:
|
|
3520
|
-
Mousetrap$1(ref.current).bind(hotkey, handler);
|
|
3525
|
+
mousetrapInstance = Mousetrap$1(ref.current).bind(hotkey, handler);
|
|
3521
3526
|
break;
|
|
3522
3527
|
default:
|
|
3523
|
-
Mousetrap$1.bind(hotkey, handler);
|
|
3528
|
+
mousetrapInstance = Mousetrap$1.bind(hotkey, handler);
|
|
3524
3529
|
}
|
|
3530
|
+
return mousetrapInstance;
|
|
3525
3531
|
};
|
|
3526
|
-
var unBindHotKey = function unBindHotKey(
|
|
3527
|
-
|
|
3532
|
+
var unBindHotKey = function unBindHotKey(_ref2) {
|
|
3533
|
+
var mousetrapInstance = _ref2.mousetrapInstance,
|
|
3534
|
+
mode = _ref2.mode,
|
|
3535
|
+
hotkey = _ref2.hotkey;
|
|
3536
|
+
return mode === MODES$1.global ? Mousetrap$1.unbindGlobal(hotkey) : mousetrapInstance === null || mousetrapInstance === void 0 ? void 0 : mousetrapInstance.unbind(hotkey);
|
|
3528
3537
|
};
|
|
3529
3538
|
|
|
3530
3539
|
var useForceUpdate = function useForceUpdate() {
|
|
@@ -7878,19 +7887,6 @@ var IpRestriction = function IpRestriction() {
|
|
|
7878
7887
|
}, /*#__PURE__*/React__default.createElement(CurrentIp, null), /*#__PURE__*/React__default.createElement(AllowedIpRanges, null)));
|
|
7879
7888
|
};
|
|
7880
7889
|
|
|
7881
|
-
var getGlobalShortcuts = function getGlobalShortcuts() {
|
|
7882
|
-
return _defineProperty({}, i18next.t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
7883
|
-
openKeyboardShortcutsPane: {
|
|
7884
|
-
sequence: "shift+/",
|
|
7885
|
-
description: i18next.t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
7886
|
-
},
|
|
7887
|
-
close: {
|
|
7888
|
-
sequence: "esc",
|
|
7889
|
-
description: i18next.t("neetoCommons.keyboardShortcuts.global.close")
|
|
7890
|
-
}
|
|
7891
|
-
});
|
|
7892
|
-
};
|
|
7893
|
-
|
|
7894
7890
|
var DisplayHotKey = function DisplayHotKey(_ref) {
|
|
7895
7891
|
var hotkey = _ref.hotkey;
|
|
7896
7892
|
var isSequentialHotkey = hotkey.includes(" ");
|
|
@@ -7933,6 +7929,18 @@ var shortenHotKey = function shortenHotKey(hotkey) {
|
|
|
7933
7929
|
});
|
|
7934
7930
|
return result;
|
|
7935
7931
|
};
|
|
7932
|
+
var getGlobalShortcuts = function getGlobalShortcuts() {
|
|
7933
|
+
return _defineProperty({}, i18next.t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
7934
|
+
openKeyboardShortcutsPane: {
|
|
7935
|
+
sequence: "shift+/",
|
|
7936
|
+
description: i18next.t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
7937
|
+
},
|
|
7938
|
+
close: {
|
|
7939
|
+
sequence: "esc",
|
|
7940
|
+
description: i18next.t("neetoCommons.keyboardShortcuts.global.close")
|
|
7941
|
+
}
|
|
7942
|
+
});
|
|
7943
|
+
};
|
|
7936
7944
|
|
|
7937
7945
|
var HotKeyList = function HotKeyList(_ref) {
|
|
7938
7946
|
var hotkeys = _ref.hotkeys;
|
|
@@ -7976,7 +7984,9 @@ var KeyboardShortcutsPane = function KeyboardShortcutsPane(_ref) {
|
|
|
7976
7984
|
setIsOpen = _useKeyboardShortcuts2[1];
|
|
7977
7985
|
var hasOverlays = manager.hasOverlays();
|
|
7978
7986
|
var GLOBAL_SHORTCUTS = getGlobalShortcuts();
|
|
7979
|
-
var
|
|
7987
|
+
var _useTranslation = useTranslation(),
|
|
7988
|
+
t = _useTranslation.t;
|
|
7989
|
+
var shortcuts = GLOBAL_SHORTCUTS[t("neetoCommons.keyboardShortcuts.global.categoryName")];
|
|
7980
7990
|
useHotKeys(shortcuts.openKeyboardShortcutsPane.sequence, function () {
|
|
7981
7991
|
return setIsOpen(function (prevIsOpen) {
|
|
7982
7992
|
return !prevIsOpen;
|
|
@@ -8002,7 +8012,7 @@ var KeyboardShortcutsPane = function KeyboardShortcutsPane(_ref) {
|
|
|
8002
8012
|
className: "neeto-ui-border-gray-300 my-2 flex items-center justify-between border-b px-4 pb-2"
|
|
8003
8013
|
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
8004
8014
|
style: "h4"
|
|
8005
|
-
},
|
|
8015
|
+
}, t("neetoCommons.keyboardShortcuts.title")), /*#__PURE__*/React__default.createElement(Button, {
|
|
8006
8016
|
icon: Close,
|
|
8007
8017
|
style: "text",
|
|
8008
8018
|
onClick: function onClick() {
|
package/utils.cjs.js
CHANGED
|
@@ -2702,24 +2702,10 @@ var hasAllPermissions = function hasAllPermissions() {
|
|
|
2702
2702
|
return permissions.every(hasPermission);
|
|
2703
2703
|
};
|
|
2704
2704
|
|
|
2705
|
-
var getGlobalShortcuts = function getGlobalShortcuts() {
|
|
2706
|
-
return _defineProperty({}, i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
2707
|
-
openKeyboardShortcutsPane: {
|
|
2708
|
-
sequence: "shift+/",
|
|
2709
|
-
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
2710
|
-
},
|
|
2711
|
-
close: {
|
|
2712
|
-
sequence: "esc",
|
|
2713
|
-
description: i18next__default["default"].t("neetoCommons.keyboardShortcuts.global.close")
|
|
2714
|
-
}
|
|
2715
|
-
});
|
|
2716
|
-
};
|
|
2717
|
-
|
|
2718
2705
|
exports.buildUrl = buildUrl;
|
|
2719
2706
|
exports.copyToClipboard = copyToClipboard;
|
|
2720
2707
|
exports.dateFormat = dateFormat;
|
|
2721
2708
|
exports.debounce = debounce;
|
|
2722
|
-
exports.getGlobalShortcuts = getGlobalShortcuts;
|
|
2723
2709
|
exports.getQueryParams = getQueryParams;
|
|
2724
2710
|
exports.getSubdomain = getSubdomain;
|
|
2725
2711
|
exports.hasAllPermissions = hasAllPermissions;
|
package/utils.js
CHANGED
|
@@ -2689,17 +2689,4 @@ var hasAllPermissions = function hasAllPermissions() {
|
|
|
2689
2689
|
return permissions.every(hasPermission);
|
|
2690
2690
|
};
|
|
2691
2691
|
|
|
2692
|
-
|
|
2693
|
-
return _defineProperty({}, i18next.t("neetoCommons.keyboardShortcuts.global.categoryName"), {
|
|
2694
|
-
openKeyboardShortcutsPane: {
|
|
2695
|
-
sequence: "shift+/",
|
|
2696
|
-
description: i18next.t("neetoCommons.keyboardShortcuts.global.openKeyboardShortcutsPane")
|
|
2697
|
-
},
|
|
2698
|
-
close: {
|
|
2699
|
-
sequence: "esc",
|
|
2700
|
-
description: i18next.t("neetoCommons.keyboardShortcuts.global.close")
|
|
2701
|
-
}
|
|
2702
|
-
});
|
|
2703
|
-
};
|
|
2704
|
-
|
|
2705
|
-
export { buildUrl, copyToClipboard, dateFormat, debounce, getGlobalShortcuts, getQueryParams, getSubdomain, hasAllPermissions, hasAnyPermission, hasPermission, joinHyphenCase, resetAuthTokens, simulateApiCall, timeFormat, toLocale, withEventTargetValue };
|
|
2692
|
+
export { buildUrl, copyToClipboard, dateFormat, debounce, getQueryParams, getSubdomain, hasAllPermissions, hasAnyPermission, hasPermission, joinHyphenCase, resetAuthTokens, simulateApiCall, timeFormat, toLocale, withEventTargetValue };
|