@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.
@@ -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
- return {
12
- items: state.items.map((item) => {
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
- return {
24
- items: state.items.filter((item) => item.id !== id),
25
- };
26
- });
26
+ setValue((state) => ({
27
+ items: excludeDialogItemById(state.items, id),
28
+ }));
27
29
  }, 1000);
28
30
  }, [setValue]);
29
31
  return closeDialog;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- 'use client';
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.useDebouncedValue = useDebouncedValue;
5
4
  const react_1 = require("react");
@@ -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.useEffect)(() => {
7
+ (0, react_1.useLayoutEffect)(() => {
8
8
  function updateSize() {
9
9
  if (elementRef.current) {
10
10
  const element = elementRef.current;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- 'use client';
3
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
4
  };
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- 'use client';
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.useSystemColorScheme = useSystemColorScheme;
5
4
  const react_1 = require("react");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.17-alpha.48",
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": "e8887232802a525648c316b2b8526b2571bc8b8c"
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
- return {
12
- items: state.items.map((item) => {
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
- return {
24
- items: state.items.filter((item) => item.id !== id),
25
- };
26
- });
26
+ setValue((state) => ({
27
+ items: excludeToastNotificationItemById(state.items, id),
28
+ }));
27
29
  }, 1000);
28
30
  }, [setValue]);
29
31
  return closeDialog;