@elliemae/ds-zustand-helpers 3.57.0-next.9 → 3.57.0-rc.0
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/cjs/builders.js +3 -3
- package/dist/cjs/builders.js.map +1 -1
- package/dist/esm/builders.js +3 -3
- package/dist/esm/builders.js.map +1 -1
- package/package.json +22 -21
package/dist/cjs/builders.js
CHANGED
|
@@ -40,7 +40,7 @@ const buildGetters = (internalAtomDefaultValues, get) => {
|
|
|
40
40
|
const internalAtomGetters = {};
|
|
41
41
|
getKeys(internalAtomDefaultValues).forEach((key) => {
|
|
42
42
|
const keyForGetter = `get${capitalize(key)}`;
|
|
43
|
-
const getter = () => get()[key];
|
|
43
|
+
const getter = (() => get()[key]);
|
|
44
44
|
internalAtomGetters[keyForGetter] = getter;
|
|
45
45
|
});
|
|
46
46
|
return internalAtomGetters;
|
|
@@ -49,13 +49,13 @@ const buildSetters = (internalAtomDefaultValues, get, set) => {
|
|
|
49
49
|
const internalAtomSetters = {};
|
|
50
50
|
getKeys(internalAtomDefaultValues).forEach((key) => {
|
|
51
51
|
const keyForSetter = `set${capitalize(key)}`;
|
|
52
|
-
const setter = (newVal) => {
|
|
52
|
+
const setter = ((newVal) => {
|
|
53
53
|
if (typeof newVal === "function") {
|
|
54
54
|
set({ [key]: newVal(get()[key], get()) });
|
|
55
55
|
} else {
|
|
56
56
|
set({ [key]: newVal });
|
|
57
57
|
}
|
|
58
|
-
};
|
|
58
|
+
});
|
|
59
59
|
internalAtomSetters[keyForSetter] = setter;
|
|
60
60
|
});
|
|
61
61
|
return internalAtomSetters;
|
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;\n // eslint-disable-next-line consistent-return\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 };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,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,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,MAAM,aAAa,CAAC,QAAgB,IAAI,OAAO,CA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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/builders.js
CHANGED
|
@@ -5,7 +5,7 @@ const buildGetters = (internalAtomDefaultValues, get) => {
|
|
|
5
5
|
const internalAtomGetters = {};
|
|
6
6
|
getKeys(internalAtomDefaultValues).forEach((key) => {
|
|
7
7
|
const keyForGetter = `get${capitalize(key)}`;
|
|
8
|
-
const getter = () => get()[key];
|
|
8
|
+
const getter = (() => get()[key]);
|
|
9
9
|
internalAtomGetters[keyForGetter] = getter;
|
|
10
10
|
});
|
|
11
11
|
return internalAtomGetters;
|
|
@@ -14,13 +14,13 @@ const buildSetters = (internalAtomDefaultValues, get, set) => {
|
|
|
14
14
|
const internalAtomSetters = {};
|
|
15
15
|
getKeys(internalAtomDefaultValues).forEach((key) => {
|
|
16
16
|
const keyForSetter = `set${capitalize(key)}`;
|
|
17
|
-
const setter = (newVal) => {
|
|
17
|
+
const setter = ((newVal) => {
|
|
18
18
|
if (typeof newVal === "function") {
|
|
19
19
|
set({ [key]: newVal(get()[key], get()) });
|
|
20
20
|
} else {
|
|
21
21
|
set({ [key]: newVal });
|
|
22
22
|
}
|
|
23
|
-
};
|
|
23
|
+
});
|
|
24
24
|
internalAtomSetters[keyForSetter] = setter;
|
|
25
25
|
});
|
|
26
26
|
return internalAtomSetters;
|
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;\n // eslint-disable-next-line consistent-return\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,CAAC;AAEpD,UAAM,
|
|
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,UAAU,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,UAAU,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,EAAE,YAAY,IAAI;AAExB,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-zustand-helpers",
|
|
3
|
-
"version": "3.57.0-
|
|
3
|
+
"version": "3.57.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Zustand Helpers",
|
|
6
6
|
"files": [
|
|
@@ -35,33 +35,34 @@
|
|
|
35
35
|
"reportFile": "tests.xml",
|
|
36
36
|
"indent": 4
|
|
37
37
|
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"test": "pui-cli test --passWithNoTests --coverage=\"false\"",
|
|
40
|
+
"lint": "node ../../../scripts/lint.mjs --fix",
|
|
41
|
+
"lint:strict": "node ../../../scripts/lint-strict.mjs",
|
|
42
|
+
"dts": "node ../../../scripts/dts.mjs",
|
|
43
|
+
"build": "cross-env NODE_ENV=production node ../../../scripts/build/build.mjs",
|
|
44
|
+
"checkDeps": "npm exec ../../util/ds-codemods -- check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\"",
|
|
45
|
+
"dev": "cross-env NODE_ENV=development node ../../../scripts/build/build.mjs --watch"
|
|
46
|
+
},
|
|
38
47
|
"publishConfig": {
|
|
39
48
|
"access": "public",
|
|
40
49
|
"typeSafety": false
|
|
41
50
|
},
|
|
42
51
|
"dependencies": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
52
|
+
"@elliemae/ds-props-helpers": "3.57.0-rc.0",
|
|
53
|
+
"immer": "catalog:",
|
|
54
|
+
"zustand": "catalog:"
|
|
46
55
|
},
|
|
47
56
|
"devDependencies": {
|
|
48
|
-
"@elliemae/
|
|
49
|
-
"
|
|
50
|
-
"jest
|
|
51
|
-
"
|
|
52
|
-
"
|
|
57
|
+
"@elliemae/ds-monorepo-devops": "3.57.0-rc.0",
|
|
58
|
+
"@elliemae/pui-cli": "catalog:",
|
|
59
|
+
"jest": "catalog:",
|
|
60
|
+
"jest-cli": "catalog:",
|
|
61
|
+
"styled-components": "catalog:"
|
|
53
62
|
},
|
|
54
63
|
"peerDependencies": {
|
|
55
|
-
"react": "
|
|
56
|
-
"react-dom": "
|
|
64
|
+
"react": "catalog:",
|
|
65
|
+
"react-dom": "catalog:"
|
|
57
66
|
},
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
"lint": "node ../../../scripts/lint.mjs --fix",
|
|
61
|
-
"lint:strict": "node ../../../scripts/lint-strict.mjs",
|
|
62
|
-
"dts": "node ../../../scripts/dts.mjs",
|
|
63
|
-
"build": "cross-env NODE_ENV=production node ../../../scripts/build/build.mjs",
|
|
64
|
-
"checkDeps": "npm exec ../../util/ds-codemods -- check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\"",
|
|
65
|
-
"dev": "cross-env NODE_ENV=development node ../../../scripts/build/build.mjs --watch"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
67
|
+
"gitHead": "7e95aacd3d36427e4659f360714c3e0bbc4378bc"
|
|
68
|
+
}
|