@headless-adminapp/app 1.4.9 → 1.4.11

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.
@@ -108,6 +108,9 @@ function useFormSave() {
108
108
  await client.invalidateQueries({
109
109
  queryKey: ['data', 'retriveRecords'],
110
110
  });
111
+ await client.invalidateQueries({
112
+ queryKey: ['data', 'recordset'],
113
+ });
111
114
  showMessageAfterSave({
112
115
  mode: record ? 'update' : 'create',
113
116
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStorageState = useStorageState;
4
4
  const react_1 = require("react");
5
+ const localStorage_1 = require("../utils/localStorage");
5
6
  function getStorageValue(key, store) {
6
7
  const value = store.getItem(key);
7
8
  if (value) {
@@ -12,7 +13,7 @@ function getStorageValue(key, store) {
12
13
  function setStorageValue(key, value, store) {
13
14
  store.setItem(key, JSON.stringify(value));
14
15
  }
15
- function useStorageState(initialState, key, store = localStorage) {
16
+ function useStorageState(initialState, key, store = localStorage_1.safeLocalStorage) {
16
17
  const [state, setState] = (0, react_1.useState)(getStorageValue(key, store) ?? initialState);
17
18
  const setStoredState = (0, react_1.useCallback)((value) => {
18
19
  setState((prevState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -38,5 +38,5 @@
38
38
  "uuid": "11.0.3",
39
39
  "yup": "^1.4.0"
40
40
  },
41
- "gitHead": "39e62181f5436c5ceeaca2aa88d132593d53607a"
41
+ "gitHead": "a021ad89086df820727f8dc87e57a039b0126bf2"
42
42
  }
@@ -15,6 +15,7 @@ export declare class RecentItemStore implements IRecentItemStore {
15
15
  private readonly storageKey;
16
16
  private readonly maxItems;
17
17
  private listeners;
18
+ private readonly localStorage;
18
19
  constructor();
19
20
  private init;
20
21
  private sync;
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RecentItemStore = void 0;
4
+ const localStorage_1 = require("../utils/localStorage");
4
5
  class RecentItemStore {
5
6
  data = {};
6
7
  storageKey = 'recent_items';
7
8
  maxItems = 5;
8
9
  listeners = {};
10
+ localStorage = localStorage_1.safeLocalStorage;
9
11
  constructor() {
10
12
  this.init();
11
13
  }
12
14
  init() {
13
- const _data = localStorage.getItem(this.storageKey);
15
+ const _data = this.localStorage.getItem(this.storageKey);
14
16
  if (_data) {
15
17
  this.data = JSON.parse(_data);
16
18
  }
@@ -19,7 +21,7 @@ class RecentItemStore {
19
21
  }
20
22
  }
21
23
  sync() {
22
- localStorage.setItem(this.storageKey, JSON.stringify(this.data));
24
+ this.localStorage.setItem(this.storageKey, JSON.stringify(this.data));
23
25
  }
24
26
  getItems(cacheKey, limit) {
25
27
  if (!this.data[cacheKey]) {
@@ -0,0 +1 @@
1
+ export declare const safeLocalStorage: Storage;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeLocalStorage = void 0;
4
+ function getLocalStorage() {
5
+ if (typeof window !== 'undefined' && window.localStorage) {
6
+ return window.localStorage;
7
+ }
8
+ return undefined;
9
+ }
10
+ exports.safeLocalStorage = {
11
+ clear: () => {
12
+ getLocalStorage()?.clear();
13
+ },
14
+ get length() {
15
+ return getLocalStorage()?.length || 0;
16
+ },
17
+ getItem: (key) => {
18
+ return getLocalStorage()?.getItem(key) || null;
19
+ },
20
+ setItem: (key, value) => {
21
+ getLocalStorage()?.setItem(key, value);
22
+ },
23
+ removeItem: (key) => {
24
+ getLocalStorage()?.removeItem(key);
25
+ },
26
+ key: (index) => {
27
+ return getLocalStorage()?.key(index) || null;
28
+ },
29
+ };