@elliemae/ds-zustand-helpers 3.36.0-next.0 → 3.36.0-next.2
Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/builders.js
CHANGED
@@ -64,8 +64,7 @@ const buildRefGetterAndSetter = (get, set) => {
|
|
64
64
|
const getZustandRef = (key) => get().zustandRefs[key.join(",")];
|
65
65
|
const setZustandRef = (key, value) => {
|
66
66
|
set((state) => {
|
67
|
-
if (state instanceof Map || state instanceof Set)
|
68
|
-
return;
|
67
|
+
if (state instanceof Map || state instanceof Set) return;
|
69
68
|
const zustandRefs = state.zustandRefs;
|
70
69
|
return {
|
71
70
|
zustandRefs: {
|
package/dist/cjs/builders.js.map
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/builders.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["import type { ZustandT } from './types.js';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <ObjectType extends object>(obj: ObjectType) => Object.keys(obj) as (keyof ObjectType)[];\n\nexport const buildGetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<AtomValuesType> = {} as ZustandT.AtomGetters<AtomValuesType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<AtomValuesType>;\n\n const getter = (() =>\n get()[key]) as ZustandT.AtomGetters<AtomValuesType>[keyof ZustandT.AtomGetters<AtomValuesType>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType> =\n {} as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >;\n\n const setter = ((newVal: AtomValuesType[typeof key]) => {\n if (typeof newVal === 'function') {\n // If it's a function, we call it with the current store value, and the full store. We try to mimic react-setState's behavior\n set({ [key]: newVal(get()[key], get()) as AtomValuesType[typeof key] } as Partial<\n ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>\n >);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>);\n }\n }) as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>[keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const getZustandRef = (key: string[]): HTMLElement | null => get().zustandRefs[key.join(',')];\n\n const setZustandRef = (key: string[], value: HTMLElement | null) => {\n set((state) => {\n if (state instanceof Map || state instanceof Set) return;\n const zustandRefs = state.zustandRefs;\n return {\n zustandRefs: {\n ...zustandRefs,\n [key.join(',')]: value,\n },\n };\n });\n };\n\n return [getZustandRef, setZustandRef] as const;\n};\n", "import * as React from 'react';\nexport { React };\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AAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAAiF;AAAA,MACvG;AAAA,IACF;AAOA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CAKrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG,CAAC;AAE5F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB,IAAK;AAClD,YAAM,cAAc,MAAM;AAC1B,aAAO;AAAA,QACL,aAAa;AAAA,UACX,GAAG;AAAA,UACH,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,CAAC,eAAe,aAAa;AACtC;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/dist/esm/builders.js
CHANGED
@@ -29,8 +29,7 @@ const buildRefGetterAndSetter = (get, set) => {
|
|
29
29
|
const getZustandRef = (key) => get().zustandRefs[key.join(",")];
|
30
30
|
const setZustandRef = (key, value) => {
|
31
31
|
set((state) => {
|
32
|
-
if (state instanceof Map || state instanceof Set)
|
33
|
-
return;
|
32
|
+
if (state instanceof Map || state instanceof Set) return;
|
34
33
|
const zustandRefs = state.zustandRefs;
|
35
34
|
return {
|
36
35
|
zustandRefs: {
|
package/dist/esm/builders.js.map
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/builders.ts"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { ZustandT } from './types.js';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <ObjectType extends object>(obj: ObjectType) => Object.keys(obj) as (keyof ObjectType)[];\n\nexport const buildGetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<AtomValuesType> = {} as ZustandT.AtomGetters<AtomValuesType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<AtomValuesType>;\n\n const getter = (() =>\n get()[key]) as ZustandT.AtomGetters<AtomValuesType>[keyof ZustandT.AtomGetters<AtomValuesType>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType> =\n {} as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >;\n\n const setter = ((newVal: AtomValuesType[typeof key]) => {\n if (typeof newVal === 'function') {\n // If it's a function, we call it with the current store value, and the full store. We try to mimic react-setState's behavior\n set({ [key]: newVal(get()[key], get()) as AtomValuesType[typeof key] } as Partial<\n ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>\n >);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>);\n }\n }) as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>[keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const getZustandRef = (key: string[]): HTMLElement | null => get().zustandRefs[key.join(',')];\n\n const setZustandRef = (key: string[], value: HTMLElement | null) => {\n set((state) => {\n if (state instanceof Map || state instanceof Set) return;\n const zustandRefs = state.zustandRefs;\n return {\n zustandRefs: {\n ...zustandRefs,\n [key.join(',')]: value,\n },\n };\n });\n };\n\n return [getZustandRef, setZustandRef] as const;\n};\n"],
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,aAAa,CAAC,QAAgB,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAE7E,MAAM,UAAU,CAA4B,QAAoB,OAAO,KAAK,GAAG;AAExE,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA4D,CAAC;AAEnE,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,aAAa,CAAC,QAAgB,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAE7E,MAAM,UAAU,CAA4B,QAAoB,OAAO,KAAK,GAAG;AAExE,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA4D,CAAC;AAEnE,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa,CAAC;AAEpD,UAAM,SAAU,MACd,IAAI,EAAE,GAAG;AAEX,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBACJ,CAAC;AAEH,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa,CAAC;AAMpD,UAAM,SAAU,CAAC,WAAuC;AACtD,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAgC,CAEpE;AAAA,MACH,OAAO;AAEL,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAAiF;AAAA,MACvG;AAAA,IACF;AAOA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CAKrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG,CAAC;AAE5F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB,IAAK;AAClD,YAAM,cAAc,MAAM;AAC1B,aAAO;AAAA,QACL,aAAa;AAAA,UACX,GAAG;AAAA,UACH,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,CAAC,eAAe,aAAa;AACtC;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/dist/types/builders.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { ZustandT } from './types.js';
|
2
|
-
export declare const buildGetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get:
|
3
|
-
export declare const buildSetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get:
|
4
|
-
export declare const buildRefGetterAndSetter: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(get:
|
2
|
+
export declare const buildGetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => ZustandT.AtomGetters<AtomValuesType>;
|
3
|
+
export declare const buildSetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>, set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;
|
4
|
+
export declare const buildRefGetterAndSetter: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>, set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => readonly [(key: string[]) => HTMLElement | null, (key: string[], value: HTMLElement | null) => void];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-zustand-helpers",
|
3
|
-
"version": "3.36.0-next.
|
3
|
+
"version": "3.36.0-next.2",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Zustand Helpers",
|
6
6
|
"files": [
|
@@ -42,12 +42,12 @@
|
|
42
42
|
"dependencies": {
|
43
43
|
"immer": "9.0.21",
|
44
44
|
"zustand": "4.3.6",
|
45
|
-
"@elliemae/ds-props-helpers": "3.36.0-next.
|
45
|
+
"@elliemae/ds-props-helpers": "3.36.0-next.2"
|
46
46
|
},
|
47
47
|
"devDependencies": {
|
48
48
|
"@elliemae/pui-cli": "~9.0.0-next.31",
|
49
49
|
"styled-components": "~5.3.9",
|
50
|
-
"@elliemae/ds-monorepo-devops": "3.36.0-next.
|
50
|
+
"@elliemae/ds-monorepo-devops": "3.36.0-next.2"
|
51
51
|
},
|
52
52
|
"peerDependencies": {
|
53
53
|
"react": "~17.0.2",
|