@headless-adminapp/app 0.0.17-alpha.48 → 0.0.17-alpha.49
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/dialog/hooks/useCloseDialog.js +17 -15
- package/hooks/useDebouncedValue.js +0 -1
- package/hooks/useElementLayout.js +1 -1
- package/hooks/useIsMobile.js +0 -1
- package/hooks/useSystemColorScheme.js +0 -1
- package/package.json +2 -2
- package/toast-notification/hooks/useCloseToastNotification.js +17 -15
|
@@ -4,26 +4,28 @@ exports.useCloseDialog = useCloseDialog;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const context_1 = require("../../mutable/context");
|
|
6
6
|
const context_2 = require("../context");
|
|
7
|
+
function markDialogAsClosed(items, id) {
|
|
8
|
+
return items.map((item) => {
|
|
9
|
+
if (item.id === id) {
|
|
10
|
+
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
11
|
+
}
|
|
12
|
+
return item;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function excludeDialogItemById(items, id) {
|
|
16
|
+
return items.filter((item) => item.id !== id);
|
|
17
|
+
}
|
|
7
18
|
function useCloseDialog() {
|
|
8
19
|
const setValue = (0, context_1.useContextSetValue)(context_2.DialogContext);
|
|
9
20
|
const closeDialog = (0, react_1.useCallback)((id) => {
|
|
10
|
-
setValue((state) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (item.id === id) {
|
|
14
|
-
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
15
|
-
}
|
|
16
|
-
return item;
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
21
|
+
setValue((state) => ({
|
|
22
|
+
items: markDialogAsClosed(state.items, id),
|
|
23
|
+
}));
|
|
20
24
|
// Simulate a delay to show the dialog closing animation
|
|
21
25
|
setTimeout(() => {
|
|
22
|
-
setValue((state) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
});
|
|
26
|
+
setValue((state) => ({
|
|
27
|
+
items: excludeDialogItemById(state.items, id),
|
|
28
|
+
}));
|
|
27
29
|
}, 1000);
|
|
28
30
|
}, [setValue]);
|
|
29
31
|
return closeDialog;
|
|
@@ -4,7 +4,7 @@ exports.useElementSize = useElementSize;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useElementSize(elementRef, interval) {
|
|
6
6
|
const [size, setSize] = (0, react_1.useState)({ width: 0, height: 0 });
|
|
7
|
-
(0, react_1.
|
|
7
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
8
8
|
function updateSize() {
|
|
9
9
|
if (elementRef.current) {
|
|
10
10
|
const element = elementRef.current;
|
package/hooks/useIsMobile.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-hook-form": "7.52.2",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8546e02107f006000bc8855d6a462e3a64f9ae9e"
|
|
43
43
|
}
|
|
@@ -4,26 +4,28 @@ exports.useCloseToastNotification = useCloseToastNotification;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const context_1 = require("../../mutable/context");
|
|
6
6
|
const context_2 = require("../context");
|
|
7
|
+
function markToastNotificationAsClosed(items, id) {
|
|
8
|
+
return items.map((item) => {
|
|
9
|
+
if (item.id === id) {
|
|
10
|
+
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
11
|
+
}
|
|
12
|
+
return item;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function excludeToastNotificationItemById(items, id) {
|
|
16
|
+
return items.filter((item) => item.id !== id);
|
|
17
|
+
}
|
|
7
18
|
function useCloseToastNotification() {
|
|
8
19
|
const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
|
|
9
20
|
const closeDialog = (0, react_1.useCallback)((id) => {
|
|
10
|
-
setValue((state) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (item.id === id) {
|
|
14
|
-
return Object.assign(Object.assign({}, item), { isOpen: false });
|
|
15
|
-
}
|
|
16
|
-
return item;
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
21
|
+
setValue((state) => ({
|
|
22
|
+
items: markToastNotificationAsClosed(state.items, id),
|
|
23
|
+
}));
|
|
20
24
|
// Simulate a delay to show the dialog closing animation
|
|
21
25
|
setTimeout(() => {
|
|
22
|
-
setValue((state) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
});
|
|
26
|
+
setValue((state) => ({
|
|
27
|
+
items: excludeToastNotificationItemById(state.items, id),
|
|
28
|
+
}));
|
|
27
29
|
}, 1000);
|
|
28
30
|
}, [setValue]);
|
|
29
31
|
return closeDialog;
|