@e1011/es-kit 1.0.180 → 1.0.182

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.
Files changed (22) hide show
  1. package/dist/hooks/esm/index.css +43 -43
  2. package/dist/hooks/index.css +43 -43
  3. package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js +1 -1
  4. package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js.map +1 -1
  5. package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js +1 -1
  6. package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
  7. package/dist/lib/src/core/utils/appState/store/simpleComponent/SimpleComponent2.js +62 -0
  8. package/dist/lib/src/core/utils/appState/store/simpleComponent/SimpleComponent2.js.map +1 -0
  9. package/dist/lib/src/core/utils/appState/store/useStore.react.js +8 -3
  10. package/dist/lib/src/core/utils/appState/store/useStore.react.js.map +1 -1
  11. package/dist/lib/tsconfig.tsbuildinfo +1 -1
  12. package/dist/types/src/core/utils/appState/store/simpleComponent/SimpleComponent2.d.ts +13 -0
  13. package/dist/types/src/core/utils/appState/store/simpleComponent/SimpleComponent2.d.ts.map +1 -0
  14. package/dist/types/src/core/utils/appState/store/useStore.react.d.ts +6 -8
  15. package/dist/types/src/core/utils/appState/store/useStore.react.d.ts.map +1 -1
  16. package/dist/utils/esm/index.css +43 -43
  17. package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js +1 -1
  18. package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
  19. package/dist/utils/index.css +43 -43
  20. package/dist/utils/src/core/utils/appState/store/useStore.react.js +1 -1
  21. package/dist/utils/src/core/utils/appState/store/useStore.react.js.map +1 -1
  22. package/package.json +1 -1
@@ -1,22 +1,3 @@
1
- .divider-module_divider-line__6CesR {
2
- position: relative;
3
- display: block;
4
- transition: opacity, width, height 250ms ease-in-out;
5
- background-color: var(--color);
6
- opacity: var(--opacity);
7
- }
8
- .divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
9
- height: var(--length);
10
- left: var(--left);
11
- width: var(--width);
12
- margin: var(--margin);
13
- }
14
- .divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
15
- width: var(--length);
16
- left: var(--left);
17
- height: var(--height);
18
- margin: var(--margin);
19
- }
20
1
  .icon-module_icon-base-parent__nOMvW {
21
2
  line-height: 1px !important;
22
3
  }
@@ -47,6 +28,49 @@
47
28
  width: var(--height);
48
29
  height: var(--width);
49
30
  }
31
+ .layoutBox-module_layout-box__faPND {
32
+ display: flex;
33
+ position: relative;
34
+ flex-direction: row;
35
+ flex: 0;
36
+ flex-grow: 0;
37
+ flex-shrink: 0;
38
+ flex-basis: auto;
39
+ flex-wrap: nowrap;
40
+ gap: 0;
41
+ text-align: left;
42
+ justify-content: flex-start;
43
+ align-items: flex-start;
44
+ align-self: auto;
45
+ margin: 0;
46
+ padding: 0;
47
+ width: auto;
48
+ height: auto;
49
+ max-width: none;
50
+ max-height: none;
51
+ min-width: 0;
52
+ min-height: 0;
53
+ border-radius: initial;
54
+ }
55
+ .divider-module_divider-line__6CesR {
56
+ position: relative;
57
+ display: block;
58
+ transition: opacity, width, height 250ms ease-in-out;
59
+ background-color: var(--color);
60
+ opacity: var(--opacity);
61
+ }
62
+ .divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
63
+ height: var(--length);
64
+ left: var(--left);
65
+ width: var(--width);
66
+ margin: var(--margin);
67
+ }
68
+ .divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
69
+ width: var(--length);
70
+ left: var(--left);
71
+ height: var(--height);
72
+ margin: var(--margin);
73
+ }
50
74
  .CollapsibleContainer-module_collapsible-container__u0Jmm {
51
75
  transform-origin: 0% 0%;
52
76
  opacity: 0;
@@ -80,30 +104,6 @@
80
104
  max-width: var(--prop-value);
81
105
  opacity: 1;
82
106
  }
83
- .layoutBox-module_layout-box__faPND {
84
- display: flex;
85
- position: relative;
86
- flex-direction: row;
87
- flex: 0;
88
- flex-grow: 0;
89
- flex-shrink: 0;
90
- flex-basis: auto;
91
- flex-wrap: nowrap;
92
- gap: 0;
93
- text-align: left;
94
- justify-content: flex-start;
95
- align-items: flex-start;
96
- align-self: auto;
97
- margin: 0;
98
- padding: 0;
99
- width: auto;
100
- height: auto;
101
- max-width: none;
102
- max-height: none;
103
- min-width: 0;
104
- min-height: 0;
105
- border-radius: initial;
106
- }
107
107
  .flowLayout-module_flowLayout__VHpnY {
108
108
  overflow: auto;
109
109
  }
@@ -1,22 +1,3 @@
1
- .divider-module_divider-line__6CesR {
2
- position: relative;
3
- display: block;
4
- transition: opacity, width, height 250ms ease-in-out;
5
- background-color: var(--color);
6
- opacity: var(--opacity);
7
- }
8
- .divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
9
- height: var(--length);
10
- left: var(--left);
11
- width: var(--width);
12
- margin: var(--margin);
13
- }
14
- .divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
15
- width: var(--length);
16
- left: var(--left);
17
- height: var(--height);
18
- margin: var(--margin);
19
- }
20
1
  .icon-module_icon-base-parent__nOMvW {
21
2
  line-height: 1px !important;
22
3
  }
@@ -47,6 +28,49 @@
47
28
  width: var(--height);
48
29
  height: var(--width);
49
30
  }
31
+ .layoutBox-module_layout-box__faPND {
32
+ display: flex;
33
+ position: relative;
34
+ flex-direction: row;
35
+ flex: 0;
36
+ flex-grow: 0;
37
+ flex-shrink: 0;
38
+ flex-basis: auto;
39
+ flex-wrap: nowrap;
40
+ gap: 0;
41
+ text-align: left;
42
+ justify-content: flex-start;
43
+ align-items: flex-start;
44
+ align-self: auto;
45
+ margin: 0;
46
+ padding: 0;
47
+ width: auto;
48
+ height: auto;
49
+ max-width: none;
50
+ max-height: none;
51
+ min-width: 0;
52
+ min-height: 0;
53
+ border-radius: initial;
54
+ }
55
+ .divider-module_divider-line__6CesR {
56
+ position: relative;
57
+ display: block;
58
+ transition: opacity, width, height 250ms ease-in-out;
59
+ background-color: var(--color);
60
+ opacity: var(--opacity);
61
+ }
62
+ .divider-module_divider-line__6CesR.divider-module_vertical__qSVWD {
63
+ height: var(--length);
64
+ left: var(--left);
65
+ width: var(--width);
66
+ margin: var(--margin);
67
+ }
68
+ .divider-module_divider-line__6CesR.divider-module_horizontal__Gz-Oj {
69
+ width: var(--length);
70
+ left: var(--left);
71
+ height: var(--height);
72
+ margin: var(--margin);
73
+ }
50
74
  .CollapsibleContainer-module_collapsible-container__u0Jmm {
51
75
  transform-origin: 0% 0%;
52
76
  opacity: 0;
@@ -80,30 +104,6 @@
80
104
  max-width: var(--prop-value);
81
105
  opacity: 1;
82
106
  }
83
- .layoutBox-module_layout-box__faPND {
84
- display: flex;
85
- position: relative;
86
- flex-direction: row;
87
- flex: 0;
88
- flex-grow: 0;
89
- flex-shrink: 0;
90
- flex-basis: auto;
91
- flex-wrap: nowrap;
92
- gap: 0;
93
- text-align: left;
94
- justify-content: flex-start;
95
- align-items: flex-start;
96
- align-self: auto;
97
- margin: 0;
98
- padding: 0;
99
- width: auto;
100
- height: auto;
101
- max-width: none;
102
- max-height: none;
103
- min-width: 0;
104
- min-height: 0;
105
- border-radius: initial;
106
- }
107
107
  .flowLayout-module_flowLayout__VHpnY {
108
108
  overflow: auto;
109
109
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;return e.useSyncExternalStore(t.subscribe,(()=>r(t.getState())))}exports.useStore=t,exports.useStoreApi=function(e){return[t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e),e.getState,e.setState,e.actions]};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=e.useSyncExternalStore(t.subscribe,(()=>r(t.getState())));return o?[s,t.setState]:s}exports.useStore=t,exports.useStoreApi=function(e){return[t(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e),e.getState,e.setState,e.actions]};
2
2
  //# sourceMappingURL=useStore.react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\n/**\n * Represents the type for the partial store state used in the `useStore` hook.\n */\nexport type useStoreType<T> = Partial<T>\n\n/**\n * Custom hook to subscribe to a store and retrieve the selected state.\n * @param store - The store to subscribe to.\n * @param selector - Optional selector function to transform the store state.\n * @returns The selected state from the store.\n */\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> {\n return useSyncExternalStore(store.subscribe, () => (selector(store.getState()) as Partial<T>))\n}\n\n/**\n * Represents the type for the API returned by the `useStoreApi` hook.\n */\nexport type useStoreApiType<T> = [\n ReturnType<typeof useStore>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n/**\n * Custom hook to retrieve the store API including state, getters, setters, and actions (if applicable).\n * @param store - The store to retrieve the API from.\n * @param selector - Optional selector function to transform the store state.\n * @returns The store API including state, getters, setters, and actions (if applicable).\n */\nexport function useStoreApi<T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> {\n return [\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n}\n"],"names":["useStore","store","selector","arguments","length","undefined","state","useSyncExternalStore","subscribe","getState","setState","actions"],"mappings":"2FAgBO,SAASA,EACdC,GAKiB,IAJjBC,EAAqBC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,EAK/C,OAAOC,EAAoBA,qBAACN,EAAMO,WAAW,IAAON,EAASD,EAAMQ,aACrE,wCAkBO,SACLR,GAGA,MAAO,CACLD,EAASC,EAHUE,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,GAI7CL,EAAMQ,SACNR,EAAMS,SACLT,EAA8BU,QAEnC"}
1
+ {"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\n/**\n * Represents the type for the partial store state used in the `useStore` hook.\n */\nexport type useStoreType<T> = Partial<T>\n\nexport type useStoreWithSetterType<T> = [Partial<T>, Store<T>['setState']]\n\ntype returnSetterTrueType = true\n\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T>): useStoreType<T>\n\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T>,\n returnSetter: returnSetterTrueType): useStoreWithSetterType<T>\n/**\n * Custom hook to subscribe to a store and retrieve the selected state.\n * @param store - The store to subscribe to.\n * @param selector - Optional selector function to transform the store state.\n * @param returnSetter - Optional flag to have setState returned\n * @returns The selected state from the store. or selected state and seState tuple\n */\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n returnSetter = false,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> | useStoreWithSetterType<T> {\n const getter = useSyncExternalStore(store.subscribe, () => (selector(store.getState()) as Partial<T>))\n\n if (returnSetter) {\n return [getter, store.setState] as useStoreWithSetterType<T>\n }\n\n return getter as useStoreType<T>\n}\n\n/**\n * Represents the type for the API returned by the `useStoreApi` hook.\n */\nexport type useStoreApiType<T> = [\n useStoreType<T>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n/**\n * Custom hook to retrieve the store API including state, getters, setters, and actions (if applicable).\n * @param store - The store to retrieve the API from.\n * @param selector - Optional selector function to transform the store state.\n * @returns The store API including state, getters, setters, and actions (if applicable).\n */\nexport function useStoreApi<T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> {\n return [\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n}\n"],"names":["useStore","store","selector","arguments","length","undefined","state","returnSetter","getter","useSyncExternalStore","subscribe","getState","setState","actions"],"mappings":"2FA6BO,SAASA,EACdC,GAM6C,IAL7CC,EAAqBC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,EAC/CC,EAAYJ,UAAAC,OAAA,QAAAC,IAAAF,UAAA,IAAAA,UAAA,GAKZ,MAAMK,EAASC,uBAAqBR,EAAMS,WAAW,IAAOR,EAASD,EAAMU,cAE3E,OAAIJ,EACK,CAACC,EAAQP,EAAMW,UAGjBJ,CACT,wCAkBO,SACLP,GAGA,MAAO,CACLD,EAASC,EAHUE,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,GAI7CL,EAAMU,SACNV,EAAMW,SACLX,EAA8BY,QAEnC"}
@@ -1,2 +1,2 @@
1
- import{useSyncExternalStore as t}from"react";function e(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t;return t(e.subscribe,(()=>n(e.getState())))}function n(t){return[e(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t),t.getState,t.setState,t.actions]}export{e as useStore,n as useStoreApi};
1
+ import{useSyncExternalStore as t}from"react";function e(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=t(e.subscribe,(()=>n(e.getState())));return o?[r,e.setState]:r}function n(t){return[e(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t),t.getState,t.setState,t.actions]}export{e as useStore,n as useStoreApi};
2
2
  //# sourceMappingURL=useStore.react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\n/**\n * Represents the type for the partial store state used in the `useStore` hook.\n */\nexport type useStoreType<T> = Partial<T>\n\n/**\n * Custom hook to subscribe to a store and retrieve the selected state.\n * @param store - The store to subscribe to.\n * @param selector - Optional selector function to transform the store state.\n * @returns The selected state from the store.\n */\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> {\n return useSyncExternalStore(store.subscribe, () => (selector(store.getState()) as Partial<T>))\n}\n\n/**\n * Represents the type for the API returned by the `useStoreApi` hook.\n */\nexport type useStoreApiType<T> = [\n ReturnType<typeof useStore>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n/**\n * Custom hook to retrieve the store API including state, getters, setters, and actions (if applicable).\n * @param store - The store to retrieve the API from.\n * @param selector - Optional selector function to transform the store state.\n * @returns The store API including state, getters, setters, and actions (if applicable).\n */\nexport function useStoreApi<T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> {\n return [\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n}\n"],"names":["useStore","store","selector","arguments","length","undefined","state","useSyncExternalStore","subscribe","getState","useStoreApi","setState","actions"],"mappings":"6CAgBO,SAASA,EACdC,GAKiB,IAJjBC,EAAqBC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,EAK/C,OAAOC,EAAqBN,EAAMO,WAAW,IAAON,EAASD,EAAMQ,aACrE,CAkBO,SAASC,EACdT,GAGA,MAAO,CACLD,EAASC,EAHUE,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,GAI7CL,EAAMQ,SACNR,EAAMU,SACLV,EAA8BW,QAEnC"}
1
+ {"version":3,"file":"useStore.react.js","sources":["../../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react'\n\nimport { Store, StoreWithActions, Selector } from './store.vanillajs'\n\n\n/**\n * Represents the type for the partial store state used in the `useStore` hook.\n */\nexport type useStoreType<T> = Partial<T>\n\nexport type useStoreWithSetterType<T> = [Partial<T>, Store<T>['setState']]\n\ntype returnSetterTrueType = true\n\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T>): useStoreType<T>\n\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T>,\n returnSetter: returnSetterTrueType): useStoreWithSetterType<T>\n/**\n * Custom hook to subscribe to a store and retrieve the selected state.\n * @param store - The store to subscribe to.\n * @param selector - Optional selector function to transform the store state.\n * @param returnSetter - Optional flag to have setState returned\n * @returns The selected state from the store. or selected state and seState tuple\n */\nexport function useStore<T>(\n store: Store<T> | StoreWithActions<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n returnSetter = false,\n // TODO pass selector\n // useSyncExternalStore((...args) => {\n // args[0].selector?? store.subscribe(...args) }, () => selector(store.getState()));\n): useStoreType<T> | useStoreWithSetterType<T> {\n const getter = useSyncExternalStore(store.subscribe, () => (selector(store.getState()) as Partial<T>))\n\n if (returnSetter) {\n return [getter, store.setState] as useStoreWithSetterType<T>\n }\n\n return getter as useStoreType<T>\n}\n\n/**\n * Represents the type for the API returned by the `useStoreApi` hook.\n */\nexport type useStoreApiType<T> = [\n useStoreType<T>,\n Store<T>['getState'],\n Store<T>['setState'],\n StoreWithActions<T>['actions'],\n]\n\n/**\n * Custom hook to retrieve the store API including state, getters, setters, and actions (if applicable).\n * @param store - The store to retrieve the API from.\n * @param selector - Optional selector function to transform the store state.\n * @returns The store API including state, getters, setters, and actions (if applicable).\n */\nexport function useStoreApi<T>(\n store: Store<T>,\n selector: Selector<T> = (state: Partial<T>) => state,\n): useStoreApiType<T> {\n return [\n useStore(store, selector),\n store.getState,\n store.setState,\n (store as StoreWithActions<T>).actions,\n ]\n}\n"],"names":["useStore","store","selector","arguments","length","undefined","state","returnSetter","getter","useSyncExternalStore","subscribe","getState","setState","useStoreApi","actions"],"mappings":"6CA6BO,SAASA,EACdC,GAM6C,IAL7CC,EAAqBC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,EAC/CC,EAAYJ,UAAAC,OAAA,QAAAC,IAAAF,UAAA,IAAAA,UAAA,GAKZ,MAAMK,EAASC,EAAqBR,EAAMS,WAAW,IAAOR,EAASD,EAAMU,cAE3E,OAAIJ,EACK,CAACC,EAAQP,EAAMW,UAGjBJ,CACT,CAkBO,SAASK,EACdZ,GAGA,MAAO,CACLD,EAASC,EAHUE,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAIG,GAAAA,GAAsBA,GAI7CL,EAAMU,SACNV,EAAMW,SACLX,EAA8Ba,QAEnC"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useCallback } from 'react';
3
+ import { createSelector } from 'reselect';
4
+ import { useStore } from '../useStore.react';
5
+ import { createStore } from '../store.vanillajs';
6
+ import { LayoutBox } from '../../../../ui/components/container/LayoutBox';
7
+ import { delay } from '../../../helpers/other';
8
+ export const simpleStore2 = createStore({
9
+ title: 'Initial Title',
10
+ count: 0,
11
+ data: [1, 2, 3],
12
+ }, {
13
+ addData: async (getState, setState) => {
14
+ console.log('addData start');
15
+ await delay(1000);
16
+ console.log('addData end');
17
+ setState({
18
+ ...getState(),
19
+ title: 'Added Data Title',
20
+ });
21
+ },
22
+ addCount: (getState, setState) => {
23
+ const prevState = getState();
24
+ setState({
25
+ ...prevState,
26
+ count: (prevState.count || 0) + 1,
27
+ });
28
+ },
29
+ });
30
+ let renderCount = 0;
31
+ export const getRenderCount = () => renderCount;
32
+ export const setRenderCount = (count) => {
33
+ renderCount = count;
34
+ };
35
+ const titleSelector = (state) => state.title;
36
+ const countSelector = (state) => state.count;
37
+ // const dataSelector = (state: Partial<SimpleState>) => state.data
38
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
+ // @ts-ignore
40
+ const simpleSelector = createSelector(titleSelector, countSelector,
41
+ // dataSelector,
42
+ (title, count, data) => {
43
+ console.log('simpleSelector called');
44
+ return {
45
+ title,
46
+ count,
47
+ data,
48
+ };
49
+ });
50
+ export const SimpleComponent2 = memo(({ children }) => {
51
+ renderCount += 1;
52
+ const [{ title, count, data }, setState] = useStore(simpleStore2, simpleSelector, true);
53
+ const simpleComponentButtonClickHandler = useCallback(() => {
54
+ setState({
55
+ ...simpleStore2.getState(),
56
+ count: 111,
57
+ });
58
+ }, [setState]);
59
+ return (_jsxs(LayoutBox, { direction: 'column', children: [_jsx("h3", { children: title }), _jsx("p", { children: count }), _jsx("p", { children: JSON.stringify(data) }), _jsx("button", { type: 'button', id: 'simpleComponentButton', onClick: simpleComponentButtonClickHandler, children: "Add Count" }), children && (_jsx(LayoutBox, { children: children }))] }));
60
+ });
61
+ SimpleComponent2.displayName = 'SimpleComponent2';
62
+ //# sourceMappingURL=SimpleComponent2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleComponent2.js","sourceRoot":"","sources":["../../../../../../../../src/core/utils/appState/store/simpleComponent/SimpleComponent2.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAyB,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,EAA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,15 @@ import { useSyncExternalStore } from 'react';
3
3
  * Custom hook to subscribe to a store and retrieve the selected state.
4
4
  * @param store - The store to subscribe to.
5
5
  * @param selector - Optional selector function to transform the store state.
6
- * @returns The selected state from the store.
6
+ * @param returnSetter - Optional flag to have setState returned
7
+ * @returns The selected state from the store. or selected state and seState tuple
7
8
  */
8
- export function useStore(store, selector = (state) => state) {
9
- return useSyncExternalStore(store.subscribe, () => selector(store.getState()));
9
+ export function useStore(store, selector = (state) => state, returnSetter = false) {
10
+ const getter = useSyncExternalStore(store.subscribe, () => selector(store.getState()));
11
+ if (returnSetter) {
12
+ return [getter, store.setState];
13
+ }
14
+ return getter;
10
15
  }
11
16
  /**
12
17
  * Custom hook to retrieve the store API including state, getters, setters, and actions (if applicable).
@@ -1 +1 @@
1
- {"version":3,"file":"useStore.react.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAU5C;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAqC,EACrC,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK;IAKpD,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,CAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAgB,CAAC,CAAA;AAChG,CAAC;AAYD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,KAAe,EACf,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK;IAEpD,OAAO;QACL,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;QACzB,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,QAAQ;QACb,KAA6B,CAAC,OAAO;KACvC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"useStore.react.js","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAsB5C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAqC,EACrC,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK,EACpD,YAAY,GAAG,KAAK;IAKpB,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,CAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAgB,CAAC,CAAA;IAEtG,IAAI,YAAY,EAAE;QAChB,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAA8B,CAAA;KAC7D;IAED,OAAO,MAAyB,CAAA;AAClC,CAAC;AAYD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,KAAe,EACf,WAAwB,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK;IAEpD,OAAO;QACL,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;QACzB,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,QAAQ;QACb,KAA6B,CAAC,OAAO;KACvC,CAAA;AACH,CAAC"}