@headless-adminapp/app 0.0.17-alpha.50 → 0.0.17-alpha.52

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.
@@ -2,17 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOpenDialog = useOpenDialog;
4
4
  const react_1 = require("react");
5
+ const uuid_1 = require("uuid");
5
6
  const context_1 = require("../../mutable/context");
6
7
  const context_2 = require("../context");
7
8
  const useCloseDialog_1 = require("./useCloseDialog");
8
- function randomId() {
9
- return Math.random().toString(36).substring(2);
10
- }
11
9
  function useOpenDialog() {
12
10
  const setValue = (0, context_1.useContextSetValue)(context_2.DialogContext);
13
11
  const closeDialog = (0, useCloseDialog_1.useCloseDialog)();
14
12
  const openDialog = (0, react_1.useCallback)((options) => {
15
- const id = randomId();
13
+ const id = (0, uuid_1.v4)();
16
14
  setValue((state) => {
17
15
  return {
18
16
  items: [
package/hooks/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './useElementLayout';
3
3
  export * from './useIsMobile';
4
4
  export * from './useStorageState';
5
5
  export * from './useSystemColorScheme';
6
+ export { useItemsWithKey } from './useItemsWithKey';
package/hooks/index.js CHANGED
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.useItemsWithKey = void 0;
17
18
  __exportStar(require("./useDebouncedValue"), exports);
18
19
  __exportStar(require("./useElementLayout"), exports);
19
20
  __exportStar(require("./useIsMobile"), exports);
20
21
  __exportStar(require("./useStorageState"), exports);
21
22
  __exportStar(require("./useSystemColorScheme"), exports);
23
+ var useItemsWithKey_1 = require("./useItemsWithKey");
24
+ Object.defineProperty(exports, "useItemsWithKey", { enumerable: true, get: function () { return useItemsWithKey_1.useItemsWithKey; } });
@@ -0,0 +1,7 @@
1
+ import { ItemWithKey } from '@headless-adminapp/core/types';
2
+ export declare function useItemsWithKey<T>(value: T[]): ItemWithKey<T>[];
3
+ export declare function useItemsWithKey(value: null): null;
4
+ export declare function useItemsWithKey(value: undefined): undefined;
5
+ export declare function useItemsWithKey<T>(value: T[] | null): ItemWithKey<T>[] | null;
6
+ export declare function useItemsWithKey<T>(value: T[] | undefined): ItemWithKey<T>[] | undefined;
7
+ export declare function useItemsWithKey<T>(value: T[] | null | undefined): ItemWithKey<T>[] | null | undefined;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useItemsWithKey = useItemsWithKey;
4
+ const utils_1 = require("@headless-adminapp/core/utils");
5
+ const react_1 = require("react");
6
+ function useItemsWithKey(value) {
7
+ return (0, react_1.useMemo)(() => {
8
+ if (!value) {
9
+ return value;
10
+ }
11
+ return (0, utils_1.createItemsWithKey)(value);
12
+ }, [value]);
13
+ }
package/mutable/utils.js CHANGED
@@ -12,20 +12,13 @@ function createMutableValue(initialValue, isArray) {
12
12
  value: storeValue,
13
13
  setValue: (value) => {
14
14
  if (typeof value === 'function') {
15
- if (isArray) {
16
- storeValue.current = value(storeValue.current);
17
- }
18
- else {
19
- storeValue.current = Object.assign(Object.assign({}, storeValue.current), value(storeValue.current));
20
- }
15
+ value = value(storeValue.current);
16
+ }
17
+ if (isArray) {
18
+ storeValue.current = value;
21
19
  }
22
20
  else {
23
- if (isArray) {
24
- storeValue.current = value;
25
- }
26
- else {
27
- storeValue.current = Object.assign(Object.assign({}, storeValue.current), value);
28
- }
21
+ storeValue.current = Object.assign(Object.assign({}, storeValue.current), value);
29
22
  }
30
23
  listeners.forEach((listener) => listener(storeValue.current));
31
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.17-alpha.50",
3
+ "version": "0.0.17-alpha.52",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -37,7 +37,8 @@
37
37
  "lodash": "^4.17.21",
38
38
  "react-custom-scrollbars-2": "^4.5.0",
39
39
  "react-hook-form": "7.52.2",
40
+ "uuid": "11.0.3",
40
41
  "yup": "^1.4.0"
41
42
  },
42
- "gitHead": "aaa62f2c8f6edb9dad521d9bb254a3c1811b5aff"
43
+ "gitHead": "d51866b6ef09087e30a44a6a63f099075c6aea89"
43
44
  }
@@ -2,17 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useOpenToastNotification = useOpenToastNotification;
4
4
  const react_1 = require("react");
5
+ const uuid_1 = require("uuid");
5
6
  const context_1 = require("../../mutable/context");
6
7
  const context_2 = require("../context");
7
8
  const useCloseToastNotification_1 = require("./useCloseToastNotification");
8
- function randomId() {
9
- return Math.random().toString(36).substring(2);
10
- }
11
9
  function useOpenToastNotification() {
12
10
  const setValue = (0, context_1.useContextSetValue)(context_2.ToastNotificationContext);
13
11
  const closeDialog = (0, useCloseToastNotification_1.useCloseToastNotification)();
14
12
  const openToastNotification = (0, react_1.useCallback)((options) => {
15
- const id = randomId();
13
+ const id = (0, uuid_1.v4)();
16
14
  setValue((state) => {
17
15
  return {
18
16
  items: [