@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.
- package/dist/hooks/esm/index.css +43 -43
- package/dist/hooks/index.css +43 -43
- package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/lib/cjs/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/lib/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/src/core/utils/appState/store/simpleComponent/SimpleComponent2.js +62 -0
- package/dist/lib/src/core/utils/appState/store/simpleComponent/SimpleComponent2.js.map +1 -0
- package/dist/lib/src/core/utils/appState/store/useStore.react.js +8 -3
- package/dist/lib/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/core/utils/appState/store/simpleComponent/SimpleComponent2.d.ts +13 -0
- package/dist/types/src/core/utils/appState/store/simpleComponent/SimpleComponent2.d.ts.map +1 -0
- package/dist/types/src/core/utils/appState/store/useStore.react.d.ts +6 -8
- package/dist/types/src/core/utils/appState/store/useStore.react.d.ts.map +1 -1
- package/dist/utils/esm/index.css +43 -43
- package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/utils/esm/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/dist/utils/index.css +43 -43
- package/dist/utils/src/core/utils/appState/store/useStore.react.js +1 -1
- package/dist/utils/src/core/utils/appState/store/useStore.react.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { StoreWithActions } from '../store.vanillajs';
|
|
3
|
+
export type SimpleState = {
|
|
4
|
+
title: string;
|
|
5
|
+
count: number;
|
|
6
|
+
data: number[];
|
|
7
|
+
};
|
|
8
|
+
export type SimpleComponentType = PropsWithChildren;
|
|
9
|
+
export declare const simpleStore2: StoreWithActions<SimpleState>;
|
|
10
|
+
export declare const getRenderCount: () => number;
|
|
11
|
+
export declare const setRenderCount: (count: number) => void;
|
|
12
|
+
export declare const SimpleComponent2: FC<SimpleComponentType>;
|
|
13
|
+
//# sourceMappingURL=SimpleComponent2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleComponent2.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/utils/appState/store/simpleComponent/SimpleComponent2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAqB,MAAM,OAAO,CAAA;AAIhE,OAAO,EAAE,gBAAgB,EAAe,MAAM,oBAAoB,CAAA;AAKlE,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,EAAE,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAA;AAEnD,eAAO,MAAM,YAAY,EAAE,gBAAgB,CAAC,WAAW,CAsBpB,CAAA;AAInC,eAAO,MAAM,cAAc,QAAO,MAAqB,CAAA;AACvD,eAAO,MAAM,cAAc,UAAW,MAAM,SAE3C,CAAA;AAwBD,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,mBAAmB,CA2BnD,CAAA"}
|
|
@@ -3,18 +3,15 @@ import { Store, StoreWithActions, Selector } from './store.vanillajs';
|
|
|
3
3
|
* Represents the type for the partial store state used in the `useStore` hook.
|
|
4
4
|
*/
|
|
5
5
|
export type useStoreType<T> = Partial<T>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @returns The selected state from the store.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useStore<T>(store: Store<T> | StoreWithActions<T>, selector?: Selector<T>): useStoreType<T>;
|
|
6
|
+
export type useStoreWithSetterType<T> = [Partial<T>, Store<T>['setState']];
|
|
7
|
+
type returnSetterTrueType = true;
|
|
8
|
+
export declare function useStore<T>(store: Store<T> | StoreWithActions<T>, selector: Selector<T>): useStoreType<T>;
|
|
9
|
+
export declare function useStore<T>(store: Store<T> | StoreWithActions<T>, selector: Selector<T>, returnSetter: returnSetterTrueType): useStoreWithSetterType<T>;
|
|
13
10
|
/**
|
|
14
11
|
* Represents the type for the API returned by the `useStoreApi` hook.
|
|
15
12
|
*/
|
|
16
13
|
export type useStoreApiType<T> = [
|
|
17
|
-
|
|
14
|
+
useStoreType<T>,
|
|
18
15
|
Store<T>['getState'],
|
|
19
16
|
Store<T>['setState'],
|
|
20
17
|
StoreWithActions<T>['actions']
|
|
@@ -26,4 +23,5 @@ export type useStoreApiType<T> = [
|
|
|
26
23
|
* @returns The store API including state, getters, setters, and actions (if applicable).
|
|
27
24
|
*/
|
|
28
25
|
export declare function useStoreApi<T>(store: Store<T>, selector?: Selector<T>): useStoreApiType<T>;
|
|
26
|
+
export {};
|
|
29
27
|
//# sourceMappingURL=useStore.react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.react.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGrE;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAA;AAExC
|
|
1
|
+
{"version":3,"file":"useStore.react.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/utils/appState/store/useStore.react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGrE;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAA;AAExC,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;AAE1E,KAAK,oBAAoB,GAAG,IAAI,CAAA;AAEhC,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACrC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;AAEzC,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACrC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,YAAY,EAAE,oBAAoB,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAA;AAyBhE;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,YAAY,CAAC,CAAC,CAAC;IACf,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACpB,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IACpB,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;CAC/B,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,QAAQ,GAAE,QAAQ,CAAC,CAAC,CAAgC,GACnD,eAAe,CAAC,CAAC,CAAC,CAOpB"}
|
package/dist/utils/esm/index.css
CHANGED
|
@@ -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
|
-
import{useSyncExternalStore as t}from"react";function e(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t=>t;
|
|
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
|
|
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"}
|
package/dist/utils/index.css
CHANGED
|
@@ -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;
|
|
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
|
|
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"}
|