@elliemae/ds-zustand-helpers 3.16.0 → 3.16.1

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 (37) hide show
  1. package/dist/cjs/AutoUpdaterComponent.js +4 -0
  2. package/dist/cjs/AutoUpdaterComponent.js.map +2 -2
  3. package/dist/cjs/builders.js +4 -0
  4. package/dist/cjs/builders.js.map +2 -2
  5. package/dist/cjs/createInternalAndPropsContext.js +4 -0
  6. package/dist/cjs/createInternalAndPropsContext.js.map +2 -2
  7. package/dist/cjs/index.js +6 -2
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/package.json +7 -0
  10. package/dist/cjs/types.js +4 -0
  11. package/dist/cjs/types.js.map +2 -2
  12. package/dist/cjs/useInternalStoreCreator.js +8 -1
  13. package/dist/cjs/useInternalStoreCreator.js.map +2 -2
  14. package/dist/cjs/usePropsStoreCreator.js +4 -0
  15. package/dist/cjs/usePropsStoreCreator.js.map +2 -2
  16. package/dist/cjs/withZustand.js +7 -3
  17. package/dist/cjs/withZustand.js.map +2 -2
  18. package/dist/esm/AutoUpdaterComponent.js.map +1 -1
  19. package/dist/esm/builders.js.map +2 -2
  20. package/dist/esm/createInternalAndPropsContext.js.map +1 -1
  21. package/dist/esm/index.js +2 -2
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/package.json +7 -0
  24. package/dist/esm/useInternalStoreCreator.js +5 -2
  25. package/dist/esm/useInternalStoreCreator.js.map +2 -2
  26. package/dist/esm/usePropsStoreCreator.js.map +1 -1
  27. package/dist/esm/withZustand.js +3 -3
  28. package/dist/esm/withZustand.js.map +1 -1
  29. package/dist/types/AutoUpdaterComponent.d.ts +1 -1
  30. package/dist/types/builders.d.ts +1 -1
  31. package/dist/types/createInternalAndPropsContext.d.ts +1 -1
  32. package/dist/types/index.d.ts +3 -3
  33. package/dist/types/types.d.ts +2 -1
  34. package/dist/types/useInternalStoreCreator.d.ts +1 -1
  35. package/dist/types/usePropsStoreCreator.d.ts +1 -1
  36. package/dist/types/withZustand.d.ts +2 -1
  37. package/package.json +5 -5
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/AutoUpdaterComponent.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useCallback, useEffect } from 'react';\nimport type { ZustandT } from './types';\n\nexport const AutoUpdaterComponent: ZustandT.AutoUpdaterComponentT = (props) => {\n const { usePropsStore, autoCalculatedData, propsWithDefault, Component } = props;\n const setProps = usePropsStore(useCallback((state) => state.set, []));\n\n useEffect(() => {\n setProps({ ...propsWithDefault, ...autoCalculatedData });\n }, [propsWithDefault, setProps, autoCalculatedData]);\n\n return <Component />;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWd;AAXT,mBAA8C;AAGvC,MAAM,uBAAuD,CAAC,UAAU;AAC7E,QAAM,EAAE,eAAe,oBAAoB,kBAAkB,UAAU,IAAI;AAC3E,QAAM,WAAW,kBAAc,0BAAY,CAAC,UAAU,MAAM,KAAK,CAAC,CAAC,CAAC;AAEpE,8BAAU,MAAM;AACd,aAAS,EAAE,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAAA,EACzD,GAAG,CAAC,kBAAkB,UAAU,kBAAkB,CAAC;AAEnD,SAAO,4CAAC,aAAU;AACpB;",
4
+ "sourcesContent": ["import React, { useCallback, useEffect } from 'react';\nimport type { ZustandT } from './types.js';\n\nexport const AutoUpdaterComponent: ZustandT.AutoUpdaterComponentT = (props) => {\n const { usePropsStore, autoCalculatedData, propsWithDefault, Component } = props;\n const setProps = usePropsStore(useCallback((state) => state.set, []));\n\n useEffect(() => {\n setProps({ ...propsWithDefault, ...autoCalculatedData });\n }, [propsWithDefault, setProps, autoCalculatedData]);\n\n return <Component />;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWd;AAXT,mBAA8C;AAGvC,MAAM,uBAAuD,CAAC,UAAU;AAC7E,QAAM,EAAE,eAAe,oBAAoB,kBAAkB,UAAU,IAAI;AAC3E,QAAM,WAAW,kBAAc,0BAAY,CAAC,UAAU,MAAM,KAAK,CAAC,CAAC,CAAC;AAEpE,8BAAU,MAAM;AACd,aAAS,EAAE,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAAA,EACzD,GAAG,CAAC,kBAAkB,UAAU,kBAAkB,CAAC;AAEnD,SAAO,4CAAC,aAAU;AACpB;",
6
6
  "names": []
7
7
  }
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/builders.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type { ZustandT } from './types';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <T extends object>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const buildGetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<A> = {} as ZustandT.AtomGetters<A>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<A>;\n\n const getter = (() => get()[key]) as ZustandT.AtomGetters<A>[keyof ZustandT.AtomGetters<A>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<A, S, R> = {} as ZustandT.AtomSetters<A, S, R>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<A, S, R>;\n\n const setter = ((newVal: A[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 A[typeof key] } as Partial<ZustandT.InternalStore<A, S, R>>);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<A, S, R>>);\n }\n }) as ZustandT.AtomSetters<A, S, R>[keyof ZustandT.AtomSetters<A, S, R>];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <A extends object, S extends object, R extends object>(\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\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 };\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,CAAmB,QAAW,OAAO,KAAK,GAAG;AAEtD,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA+C,CAAC;AAEtD,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,MAAM,IAAI,EAAE;AAE5B,wBAAoB,gBAAgB;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBAAqD,CAAC;AAE5D,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,CAAC,WAA0B;AACzC,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,IAAI,CAAC,EAAmB,CAA6C;AAAA,MACvG,OAAO;AAEL,YAAI,EAAE,CAAC,MAAM,OAAO,CAA6C;AAAA,MACnE;AAAA,IACF;AAGA,wBAAoB,gBAAgB;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG;AAE3F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB;AAAK;AAClD,YAAM,cAAc,MAAM;AAC1B,aAAO;AAAA,QACL,aAAa;AAAA,UACX,GAAG;AAAA,UACH,CAAC,IAAI,KAAK,GAAG,IAAI;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,CAAC,eAAe,aAAa;AACtC;",
4
+ "sourcesContent": ["import type { ZustandT } from './types.js';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <T extends object>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const buildGetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<A> = {} as ZustandT.AtomGetters<A>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<A>;\n\n const getter = (() => get()[key]) as ZustandT.AtomGetters<A>[keyof ZustandT.AtomGetters<A>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<A, S, R> = {} as ZustandT.AtomSetters<A, S, R>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<A, S, R>;\n\n const setter = ((newVal: A[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 A[typeof key] } as Partial<ZustandT.InternalStore<A, S, R>>);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<A, S, R>>);\n }\n }) as ZustandT.AtomSetters<A, S, R>[keyof ZustandT.AtomSetters<A, S, R>];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <A extends object, S extends object, R extends object>(\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\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 };\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,CAAmB,QAAW,OAAO,KAAK,GAAG;AAEtD,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA+C,CAAC;AAEtD,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,MAAM,IAAI,EAAE,GAAG;AAE/B,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBAAqD,CAAC;AAE5D,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,CAAC,WAA0B;AACzC,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAmB,CAA6C;AAAA,MACvG,OAAO;AAEL,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAA6C;AAAA,MACnE;AAAA,IACF;AAGA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,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;AAAK;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
  }
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createInternalAndPropsContext.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import createContext from 'zustand/context';\nimport type { ZustandT } from './types';\n\nexport const createInternalAndPropsContext = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>();\n\n return { PropsProvider, usePropsStore, InternalProvider, useInternalStore };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,qBAA0B;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,QACvD,eAAAA,SAAiE;AAEnE,QAAM,EAAE,UAAU,kBAAkB,UAAU,iBAAiB,QAC7D,eAAAA,SAAsE;AAExE,SAAO,EAAE,eAAe,eAAe,kBAAkB,iBAAiB;AAC5E;",
4
+ "sourcesContent": ["import createContext from 'zustand/context';\nimport type { ZustandT } from './types.js';\n\nexport const createInternalAndPropsContext = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>();\n\n return { PropsProvider, usePropsStore, InternalProvider, useInternalStore };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,qBAA0B;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,QACvD,eAAAA,SAAiE;AAEnE,QAAM,EAAE,UAAU,kBAAkB,UAAU,iBAAiB,QAC7D,eAAAA,SAAsE;AAExE,SAAO,EAAE,eAAe,eAAe,kBAAkB,iBAAiB;AAC5E;",
6
6
  "names": ["createContext"]
7
7
  }
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -29,6 +33,6 @@ __export(src_exports, {
29
33
  });
30
34
  module.exports = __toCommonJS(src_exports);
31
35
  var React = __toESM(require("react"));
32
- var import_createInternalAndPropsContext = require("./createInternalAndPropsContext");
33
- var import_withZustand = require("./withZustand");
36
+ var import_createInternalAndPropsContext = require("./createInternalAndPropsContext.js");
37
+ var import_withZustand = require("./withZustand.js");
34
38
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export { createInternalAndPropsContext } from './createInternalAndPropsContext';\nexport { withZustand } from './withZustand';\nexport type { ZustandT } from './types';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,2CAA8C;AAC9C,yBAA4B;",
4
+ "sourcesContent": ["export { createInternalAndPropsContext } from './createInternalAndPropsContext.js';\nexport { withZustand } from './withZustand.js';\nexport type { ZustandT } from './types.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,2CAA8C;AAC9C,yBAA4B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "commonjs",
3
+ "sideEffects": [
4
+ "*.css",
5
+ "*.scss"
6
+ ]
7
+ }
package/dist/cjs/types.js CHANGED
@@ -14,6 +14,10 @@ var __copyProps = (to, from, except, desc) => {
14
14
  return to;
15
15
  };
16
16
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
17
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
22
  mod
19
23
  ));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable no-use-before-define */\nimport type { Draft } from 'immer';\nimport type { StoreApi, UseBoundStore } from 'zustand';\nimport type createContext from 'zustand/context';\n\n// U is a generic assigned to the user props for clarity\n// P is a generic assigned to the internal props for clarity\n// A is a generic assigned to the atoms for clarity\n// C is a generic assigned to the auto-calculated values for clarity\n// S is a generic assigned to selectors for clarity\n// R is a generic assigned to reducers for clarity\n\nexport namespace ZustandT {\n type Write<T, U> = Omit<T, keyof U> & U;\n\n type ImmerSetter<T extends object> = {\n setState: (\n nextStateOrUpdater: T | Partial<T> | ((state: Draft<T>) => void),\n shouldReplace?: boolean | undefined,\n ) => void;\n };\n\n type StoreSubscribeWithSelector<T> = {\n subscribe: {\n (listener: (selectedState: T, previousSelectedState: T) => void): () => void;\n <U>(\n selector: (state: T) => U,\n listener: (selectedState: U, previousSelectedState: U) => void,\n options?: {\n equalityFn?: (a: U, b: U) => boolean;\n fireImmediately?: boolean;\n },\n ): () => void;\n };\n };\n\n // We add the immer setter method type\n type StoreWithImmer<T extends object> = Write<StoreApi<T>, ImmerSetter<T>>;\n\n // We add the subscribe with selector method type\n type StoreWithImmerAndSubscriber<T extends object> = Write<StoreWithImmer<T>, StoreSubscribeWithSelector<T>>;\n\n export type ZustandStore<T extends object> = UseBoundStore<StoreWithImmerAndSubscriber<T>>;\n\n export type Getter<T extends object> = StoreWithImmerAndSubscriber<T>['getState'];\n export type Setter<T extends object> = StoreWithImmerAndSubscriber<T>['setState'];\n\n export type InternalStore<A extends object, S extends object, R extends object> = A &\n AtomGetters<A> &\n AtomSetters<A, S, R> &\n S &\n R & {\n get: Getter<InternalStore<A, S, R>>;\n set: Setter<InternalStore<A, S, R>>;\n zustandRefs: Record<string, HTMLElement | null>;\n getZustandRef: (key: string[]) => HTMLElement | null;\n setZustandRef: (key: string[], value: HTMLElement | null) => void;\n };\n\n export type PropsStore<T> = T & {\n set: Setter<PropsStore<T>>;\n };\n\n export type AtomGetters<A extends object> = {\n [key in keyof A as `get${Capitalize<string & key>}`]: () => A[key];\n };\n\n export type AtomSetters<A extends object, S extends object, R extends object> = {\n [key in keyof A as `set${Capitalize<string & key>}`]: (\n newVal: A[key] | ((arg: A[key], store: InternalStore<A, S, R>) => A[key]),\n ) => void;\n };\n\n export type SelectorObject<T extends object, S extends object> = (get: Getter<T>) => S;\n export type ReducerObject<T extends object, R extends object> = (get: Getter<T>, set: Setter<T>) => R;\n export type Subscribers<T extends object> = (api: StoreWithImmerAndSubscriber<T>) => void;\n\n export type InternalParameters<A extends object, S extends object, R extends object> = {\n internalAtomDefaultValues: A;\n selectors: SelectorObject<InternalStore<A, S, R>, S>;\n reducers: ReducerObject<InternalStore<A, S, R>, R>;\n subscribers: Subscribers<InternalStore<A, S, R>>;\n };\n\n export type Config<P extends object, A extends object, C extends object, S extends object, R extends object> = {\n defaultProps: P;\n internalAtomDefaultValues: A;\n useAutoCalculated: (props: P) => C;\n selectors?: SelectorObject<InternalStore<A, S, R>, S>;\n reducers?: ReducerObject<InternalStore<A, S, R>, R>;\n subscribers?: Subscribers<InternalStore<A, S, R>>;\n PropsProvider: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['Provider'];\n InternalProvider: ReturnType<typeof createContext<ZustandStore<InternalStore<A, S, R>>>>['Provider'];\n usePropsStore: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['useStore'];\n };\n\n export type AutoUpdaterComponentT = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n >(\n props: Pick<Config<P, A, C, S, R>, 'usePropsStore'> & { autoCalculatedData: C } & {\n propsWithDefault: P;\n } & { Component: React.ComponentType<Record<string, never>> },\n ) => JSX.Element;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
4
+ "sourcesContent": ["/* eslint-disable no-use-before-define */\nimport type React from 'react';\nimport type { Draft } from 'immer';\nimport type { StoreApi, UseBoundStore } from 'zustand';\nimport type createContext from 'zustand/context';\n\n// U is a generic assigned to the user props for clarity\n// P is a generic assigned to the internal props for clarity\n// A is a generic assigned to the atoms for clarity\n// C is a generic assigned to the auto-calculated values for clarity\n// S is a generic assigned to selectors for clarity\n// R is a generic assigned to reducers for clarity\n\nexport namespace ZustandT {\n type Write<T, U> = Omit<T, keyof U> & U;\n\n type ImmerSetter<T extends object> = {\n setState: (\n nextStateOrUpdater: T | Partial<T> | ((state: Draft<T>) => void),\n shouldReplace?: boolean | undefined,\n ) => void;\n };\n\n type StoreSubscribeWithSelector<T> = {\n subscribe: {\n (listener: (selectedState: T, previousSelectedState: T) => void): () => void;\n <U>(\n selector: (state: T) => U,\n listener: (selectedState: U, previousSelectedState: U) => void,\n options?: {\n equalityFn?: (a: U, b: U) => boolean;\n fireImmediately?: boolean;\n },\n ): () => void;\n };\n };\n\n // We add the immer setter method type\n type StoreWithImmer<T extends object> = Write<StoreApi<T>, ImmerSetter<T>>;\n\n // We add the subscribe with selector method type\n type StoreWithImmerAndSubscriber<T extends object> = Write<StoreWithImmer<T>, StoreSubscribeWithSelector<T>>;\n\n export type ZustandStore<T extends object> = UseBoundStore<StoreWithImmerAndSubscriber<T>>;\n\n export type Getter<T extends object> = StoreWithImmerAndSubscriber<T>['getState'];\n export type Setter<T extends object> = StoreWithImmerAndSubscriber<T>['setState'];\n\n export type InternalStore<A extends object, S extends object, R extends object> = A &\n AtomGetters<A> &\n AtomSetters<A, S, R> &\n S &\n R & {\n get: Getter<InternalStore<A, S, R>>;\n set: Setter<InternalStore<A, S, R>>;\n zustandRefs: Record<string, HTMLElement | null>;\n getZustandRef: (key: string[]) => HTMLElement | null;\n setZustandRef: (key: string[], value: HTMLElement | null) => void;\n apiRef: React.MutableRefObject<ZustandStore<InternalStore<A, S, R>>>;\n };\n\n export type PropsStore<T> = T & {\n set: Setter<PropsStore<T>>;\n };\n\n export type AtomGetters<A extends object> = {\n [key in keyof A as `get${Capitalize<string & key>}`]: () => A[key];\n };\n\n export type AtomSetters<A extends object, S extends object, R extends object> = {\n [key in keyof A as `set${Capitalize<string & key>}`]: (\n newVal: A[key] | ((arg: A[key], store: InternalStore<A, S, R>) => A[key]),\n ) => void;\n };\n\n export type SelectorObject<T extends object, S extends object> = (get: Getter<T>) => S;\n export type ReducerObject<T extends object, R extends object> = (get: Getter<T>, set: Setter<T>) => R;\n export type Subscribers<T extends object> = (api: StoreWithImmerAndSubscriber<T>) => void;\n\n export type InternalParameters<A extends object, S extends object, R extends object> = {\n internalAtomDefaultValues: A;\n selectors: SelectorObject<InternalStore<A, S, R>, S>;\n reducers: ReducerObject<InternalStore<A, S, R>, R>;\n subscribers: Subscribers<InternalStore<A, S, R>>;\n };\n\n export type Config<P extends object, A extends object, C extends object, S extends object, R extends object> = {\n defaultProps: P;\n internalAtomDefaultValues: A;\n useAutoCalculated: (props: P) => C;\n selectors?: SelectorObject<InternalStore<A, S, R>, S>;\n reducers?: ReducerObject<InternalStore<A, S, R>, R>;\n subscribers?: Subscribers<InternalStore<A, S, R>>;\n PropsProvider: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['Provider'];\n InternalProvider: ReturnType<typeof createContext<ZustandStore<InternalStore<A, S, R>>>>['Provider'];\n usePropsStore: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['useStore'];\n };\n\n export type AutoUpdaterComponentT = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n >(\n props: Pick<Config<P, A, C, S, R>, 'usePropsStore'> & { autoCalculatedData: C } & {\n propsWithDefault: P;\n } & { Component: React.ComponentType<Record<string, never>> },\n ) => JSX.Element;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -32,13 +36,14 @@ var import_react = require("react");
32
36
  var import_zustand = __toESM(require("zustand"));
33
37
  var import_middleware = require("zustand/middleware");
34
38
  var import_immer = require("zustand/middleware/immer");
35
- var import_builders = require("./builders");
39
+ var import_builders = require("./builders.js");
36
40
  const createInternalStore = ({
37
41
  internalAtomDefaultValues,
38
42
  selectors,
39
43
  reducers,
40
44
  subscribers
41
45
  }) => {
46
+ const apiRef = (0, import_react.createRef)();
42
47
  const store = (0, import_zustand.default)(
43
48
  (0, import_middleware.subscribeWithSelector)(
44
49
  (0, import_immer.immer)((set, get) => {
@@ -51,6 +56,7 @@ const createInternalStore = ({
51
56
  ...internalAtomSetters,
52
57
  ...selectors(get),
53
58
  ...reducers(get, set),
59
+ apiRef,
54
60
  zustandRefs: {},
55
61
  getZustandRef,
56
62
  setZustandRef,
@@ -61,6 +67,7 @@ const createInternalStore = ({
61
67
  )
62
68
  );
63
69
  subscribers(store);
70
+ apiRef.current = store;
64
71
  return store;
65
72
  };
66
73
  const useInternalStoreCreator = ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/useInternalStoreCreator.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useCallback } from 'react';\nimport create from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { buildGetters, buildRefGetterAndSetter, buildSetters } from './builders';\nimport type { ZustandT } from './types';\n\n// Function that will create the store, putting:\n// 1) the atoms\n// 2) the getters for the atoms (which we auto-calculate and are mutable)\n// 3) the setters for the atoms (which we auto-calculate)\n// 4) the auto-calculated values\n// 5) selectors\n// 6) reducers\n// 7) ref object, getters and setters\n// 8) the get function\n// 9) the set function\n// After that, we configure the subscribers\n// The store is fully typed, and the setters are typed as well\nconst createInternalStore = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<A, S, R>>((set, get) => {\n // We build the atom getters\n const internalAtomGetters = buildGetters(internalAtomDefaultValues, get);\n\n // We build the atom setters\n const internalAtomSetters = buildSetters(internalAtomDefaultValues, get, set);\n\n // We build an object to store references to elements\n const [getZustandRef, setZustandRef] = buildRefGetterAndSetter(get, set);\n\n return {\n ...internalAtomDefaultValues,\n ...internalAtomGetters,\n ...internalAtomSetters,\n ...selectors(get),\n ...reducers(get, set),\n zustandRefs: {},\n getZustandRef,\n setZustandRef,\n get,\n set,\n };\n }),\n ),\n );\n\n // We setup all subscribers\n subscribers(store);\n\n return store;\n};\n\nexport const useInternalStoreCreator = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const storeCreator = useCallback(\n () => createInternalStore({ internalAtomDefaultValues, selectors, reducers, subscribers }),\n [internalAtomDefaultValues, selectors, reducers, subscribers],\n );\n\n return storeCreator;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAC5B,qBAAmB;AACnB,wBAAsC;AACtC,mBAAsB;AACtB,sBAAoE;AAepE,MAAM,sBAAsB,CAAuD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,YAAQ,eAAAA;AAAA,QACZ;AAAA,UACE,oBAAuC,CAAC,KAAK,QAAQ;AAEnD,cAAM,0BAAsB,8BAAa,2BAA2B,GAAG;AAGvE,cAAM,0BAAsB,8BAAa,2BAA2B,KAAK,GAAG;AAG5E,cAAM,CAAC,eAAe,aAAa,QAAI,yCAAwB,KAAK,GAAG;AAEvE,eAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG,UAAU,GAAG;AAAA,UAChB,GAAG,SAAS,KAAK,GAAG;AAAA,UACpB,aAAa,CAAC;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAGA,cAAY,KAAK;AAEjB,SAAO;AACT;AAEO,MAAM,0BAA0B,CAAuD;AAAA,EAC5F;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,mBAAe;AAAA,IACnB,MAAM,oBAAoB,EAAE,2BAA2B,WAAW,UAAU,YAAY,CAAC;AAAA,IACzF,CAAC,2BAA2B,WAAW,UAAU,WAAW;AAAA,EAC9D;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { useCallback, createRef } from 'react';\nimport create from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { buildGetters, buildRefGetterAndSetter, buildSetters } from './builders.js';\nimport type { ZustandT } from './types.js';\n\n// Function that will create the store, putting:\n// 1) the atoms\n// 2) the getters for the atoms (which we auto-calculate and are mutable)\n// 3) the setters for the atoms (which we auto-calculate)\n// 4) the auto-calculated values\n// 5) selectors\n// 6) reducers\n// 7) ref object, getters and setters\n// 8) the get function\n// 9) the set function\n// After that, we configure the subscribers\n// The store is fully typed, and the setters are typed as well\nconst createInternalStore = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const apiRef = createRef() as React.MutableRefObject<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>;\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<A, S, R>>((set, get) => {\n // We build the atom getters\n const internalAtomGetters = buildGetters(internalAtomDefaultValues, get);\n\n // We build the atom setters\n const internalAtomSetters = buildSetters(internalAtomDefaultValues, get, set);\n\n // We build an object to store references to elements\n const [getZustandRef, setZustandRef] = buildRefGetterAndSetter(get, set);\n\n return {\n ...internalAtomDefaultValues,\n ...internalAtomGetters,\n ...internalAtomSetters,\n ...selectors(get),\n ...reducers(get, set),\n apiRef,\n zustandRefs: {},\n getZustandRef,\n setZustandRef,\n get,\n set,\n };\n }),\n ),\n );\n\n // We setup all subscribers\n subscribers(store);\n apiRef.current = store;\n\n return store;\n};\n\nexport const useInternalStoreCreator = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const storeCreator = useCallback(\n () => createInternalStore({ internalAtomDefaultValues, selectors, reducers, subscribers }),\n [internalAtomDefaultValues, selectors, reducers, subscribers],\n );\n\n return storeCreator;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAuC;AACvC,qBAAmB;AACnB,wBAAsC;AACtC,mBAAsB;AACtB,sBAAoE;AAepE,MAAM,sBAAsB,CAAuD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,aAAS,wBAAU;AACzB,QAAM,YAAQ,eAAAA;AAAA,QACZ;AAAA,UACE,oBAAuC,CAAC,KAAK,QAAQ;AAEnD,cAAM,0BAAsB,8BAAa,2BAA2B,GAAG;AAGvE,cAAM,0BAAsB,8BAAa,2BAA2B,KAAK,GAAG;AAG5E,cAAM,CAAC,eAAe,aAAa,QAAI,yCAAwB,KAAK,GAAG;AAEvE,eAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG,UAAU,GAAG;AAAA,UAChB,GAAG,SAAS,KAAK,GAAG;AAAA,UACpB;AAAA,UACA,aAAa,CAAC;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAGA,cAAY,KAAK;AACjB,SAAO,UAAU;AAEjB,SAAO;AACT;AAEO,MAAM,0BAA0B,CAAuD;AAAA,EAC5F;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,mBAAe;AAAA,IACnB,MAAM,oBAAoB,EAAE,2BAA2B,WAAW,UAAU,YAAY,CAAC;AAAA,IACzF,CAAC,2BAA2B,WAAW,UAAU,WAAW;AAAA,EAC9D;AAEA,SAAO;AACT;",
6
6
  "names": ["create"]
7
7
  }
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/usePropsStoreCreator.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useCallback } from 'react';\nimport create from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport type { ZustandT } from './types';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set) => ({\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <P extends object, C extends object>(props: P, autoCalculatedData: C) => {\n // we want to memoize the creation of the store,\n // it doesn't make sense to create a new store every time the props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const storeCreator = useCallback(() => createPropsStore(props, autoCalculatedData), []);\n\n return storeCreator;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAC5B,qBAAmB;AACnB,mBAAsB;AAGtB,MAAM,mBAAmB,CAAqC,kBAAqB,2BACjF,eAAAA;AAAA,MACE,oBAAkC,CAAC,SAAS;AAAA,IAC1C;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACL,EAAE;AACJ;AAEK,MAAM,uBAAuB,CAAqC,OAAU,uBAA0B;AAI3G,QAAM,mBAAe,0BAAY,MAAM,iBAAiB,OAAO,kBAAkB,GAAG,CAAC,CAAC;AAEtF,SAAO;AACT;",
4
+ "sourcesContent": ["import { useCallback } from 'react';\nimport create from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport type { ZustandT } from './types.js';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set) => ({\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <P extends object, C extends object>(props: P, autoCalculatedData: C) => {\n // we want to memoize the creation of the store,\n // it doesn't make sense to create a new store every time the props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const storeCreator = useCallback(() => createPropsStore(props, autoCalculatedData), []);\n\n return storeCreator;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAC5B,qBAAmB;AACnB,mBAAsB;AAGtB,MAAM,mBAAmB,CAAqC,kBAAqB,2BACjF,eAAAA;AAAA,MACE,oBAAkC,CAAC,SAAS;AAAA,IAC1C;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACL,EAAE;AACJ;AAEK,MAAM,uBAAuB,CAAqC,OAAU,uBAA0B;AAI3G,QAAM,mBAAe,0BAAY,MAAM,iBAAiB,OAAO,kBAAkB,GAAG,CAAC,CAAC;AAEtF,SAAO;AACT;",
6
6
  "names": ["create"]
7
7
  }
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  return to;
19
19
  };
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -30,9 +34,9 @@ module.exports = __toCommonJS(withZustand_exports);
30
34
  var React = __toESM(require("react"));
31
35
  var import_jsx_runtime = require("react/jsx-runtime");
32
36
  var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
33
- var import_useInternalStoreCreator = require("./useInternalStoreCreator");
34
- var import_AutoUpdaterComponent = require("./AutoUpdaterComponent");
35
- var import_usePropsStoreCreator = require("./usePropsStoreCreator");
37
+ var import_useInternalStoreCreator = require("./useInternalStoreCreator.js");
38
+ var import_AutoUpdaterComponent = require("./AutoUpdaterComponent.js");
39
+ var import_usePropsStoreCreator = require("./usePropsStoreCreator.js");
36
40
  const noopish = () => ({});
37
41
  const withZustand = (Component, config) => {
38
42
  const {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/withZustand.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable indent */\n\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { useInternalStoreCreator } from './useInternalStoreCreator';\nimport type { ZustandT } from './types';\nimport { AutoUpdaterComponent } from './AutoUpdaterComponent';\nimport { usePropsStoreCreator } from './usePropsStoreCreator';\n\nconst noopish = <T extends object>() => ({} as T);\n\nexport const withZustand = <\n U extends object,\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<P, A, C, S, R>,\n) => {\n const {\n defaultProps,\n internalAtomDefaultValues,\n useAutoCalculated,\n selectors = noopish,\n reducers = noopish,\n subscribers = noopish,\n PropsProvider,\n InternalProvider,\n usePropsStore,\n } = config;\n\n const ComponentWithStore = (props: U) => {\n const propsWithDefault = useMemoMergePropsWithDefault<P>(props, defaultProps);\n\n const autoCalculatedData = useAutoCalculated(propsWithDefault);\n\n const internalStoreCreator = useInternalStoreCreator({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n });\n\n const propsStoreCreator = usePropsStoreCreator(propsWithDefault, autoCalculatedData);\n\n return (\n <PropsProvider createStore={propsStoreCreator}>\n <InternalProvider createStore={internalStoreCreator}>\n <AutoUpdaterComponent\n Component={Component}\n usePropsStore={usePropsStore}\n autoCalculatedData={autoCalculatedData}\n propsWithDefault={propsWithDefault}\n />\n </InternalProvider>\n </PropsProvider>\n );\n };\n return ComponentWithStore;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADkDb;AAhDV,8BAA6C;AAC7C,qCAAwC;AAExC,kCAAqC;AACrC,kCAAqC;AAErC,MAAM,UAAU,OAAyB,CAAC;AAEnC,MAAM,cAAc,CAQzB,WACA,WACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,qBAAqB,CAAC,UAAa;AACvC,UAAM,uBAAmB,sDAAgC,OAAO,YAAY;AAE5E,UAAM,qBAAqB,kBAAkB,gBAAgB;AAE7D,UAAM,2BAAuB,wDAAwB;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,wBAAoB,kDAAqB,kBAAkB,kBAAkB;AAEnF,WACE,4CAAC,iBAAc,aAAa,mBAC1B,sDAAC,oBAAiB,aAAa,sBAC7B;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF,GACF;AAAA,EAEJ;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable indent */\nimport React from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { useInternalStoreCreator } from './useInternalStoreCreator.js';\nimport type { ZustandT } from './types.js';\nimport { AutoUpdaterComponent } from './AutoUpdaterComponent.js';\nimport { usePropsStoreCreator } from './usePropsStoreCreator.js';\n\nconst noopish = <T extends object>() => ({} as T);\n\nexport const withZustand = <\n U extends object,\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<P, A, C, S, R>,\n) => {\n const {\n defaultProps,\n internalAtomDefaultValues,\n useAutoCalculated,\n selectors = noopish,\n reducers = noopish,\n subscribers = noopish,\n PropsProvider,\n InternalProvider,\n usePropsStore,\n } = config;\n\n const ComponentWithStore = (props: U) => {\n const propsWithDefault = useMemoMergePropsWithDefault<P>(props, defaultProps);\n\n const autoCalculatedData = useAutoCalculated(propsWithDefault);\n\n const internalStoreCreator = useInternalStoreCreator({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n });\n\n const propsStoreCreator = usePropsStoreCreator(propsWithDefault, autoCalculatedData);\n\n return (\n <PropsProvider createStore={propsStoreCreator}>\n <InternalProvider createStore={internalStoreCreator}>\n <AutoUpdaterComponent\n Component={Component}\n usePropsStore={usePropsStore}\n autoCalculatedData={autoCalculatedData}\n propsWithDefault={propsWithDefault}\n />\n </InternalProvider>\n </PropsProvider>\n );\n };\n return ComponentWithStore;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADkDb;AAhDV,8BAA6C;AAC7C,qCAAwC;AAExC,kCAAqC;AACrC,kCAAqC;AAErC,MAAM,UAAU,OAAyB,CAAC;AAEnC,MAAM,cAAc,CAQzB,WACA,WACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,qBAAqB,CAAC,UAAa;AACvC,UAAM,uBAAmB,sDAAgC,OAAO,YAAY;AAE5E,UAAM,qBAAqB,kBAAkB,gBAAgB;AAE7D,UAAM,2BAAuB,wDAAwB;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,wBAAoB,kDAAqB,kBAAkB,kBAAkB;AAEnF,WACE,4CAAC,iBAAc,aAAa,mBAC1B,sDAAC,oBAAiB,aAAa,sBAC7B;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF,GACF;AAAA,EAEJ;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/AutoUpdaterComponent.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useEffect } from 'react';\nimport type { ZustandT } from './types';\n\nexport const AutoUpdaterComponent: ZustandT.AutoUpdaterComponentT = (props) => {\n const { usePropsStore, autoCalculatedData, propsWithDefault, Component } = props;\n const setProps = usePropsStore(useCallback((state) => state.set, []));\n\n useEffect(() => {\n setProps({ ...propsWithDefault, ...autoCalculatedData });\n }, [propsWithDefault, setProps, autoCalculatedData]);\n\n return <Component />;\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useEffect } from 'react';\nimport type { ZustandT } from './types.js';\n\nexport const AutoUpdaterComponent: ZustandT.AutoUpdaterComponentT = (props) => {\n const { usePropsStore, autoCalculatedData, propsWithDefault, Component } = props;\n const setProps = usePropsStore(useCallback((state) => state.set, []));\n\n useEffect(() => {\n setProps({ ...propsWithDefault, ...autoCalculatedData });\n }, [propsWithDefault, setProps, autoCalculatedData]);\n\n return <Component />;\n};\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACWd;AAXT,SAAgB,aAAa,iBAAiB;AAGvC,MAAM,uBAAuD,CAAC,UAAU;AAC7E,QAAM,EAAE,eAAe,oBAAoB,kBAAkB,UAAU,IAAI;AAC3E,QAAM,WAAW,cAAc,YAAY,CAAC,UAAU,MAAM,KAAK,CAAC,CAAC,CAAC;AAEpE,YAAU,MAAM;AACd,aAAS,EAAE,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAAA,EACzD,GAAG,CAAC,kBAAkB,UAAU,kBAAkB,CAAC;AAEnD,SAAO,oBAAC,aAAU;AACpB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/builders.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { ZustandT } from './types';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <T extends object>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const buildGetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<A> = {} as ZustandT.AtomGetters<A>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<A>;\n\n const getter = (() => get()[key]) as ZustandT.AtomGetters<A>[keyof ZustandT.AtomGetters<A>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<A, S, R> = {} as ZustandT.AtomSetters<A, S, R>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<A, S, R>;\n\n const setter = ((newVal: A[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 A[typeof key] } as Partial<ZustandT.InternalStore<A, S, R>>);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<A, S, R>>);\n }\n }) as ZustandT.AtomSetters<A, S, R>[keyof ZustandT.AtomSetters<A, S, R>];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <A extends object, S extends object, R extends object>(\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\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,CAAmB,QAAW,OAAO,KAAK,GAAG;AAEtD,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA+C,CAAC;AAEtD,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,MAAM,IAAI,EAAE;AAE5B,wBAAoB,gBAAgB;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBAAqD,CAAC;AAE5D,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,CAAC,WAA0B;AACzC,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,MAAM,OAAO,IAAI,EAAE,MAAM,IAAI,CAAC,EAAmB,CAA6C;AAAA,MACvG,OAAO;AAEL,YAAI,EAAE,CAAC,MAAM,OAAO,CAA6C;AAAA,MACnE;AAAA,IACF;AAGA,wBAAoB,gBAAgB;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG;AAE3F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB;AAAK;AAClD,YAAM,cAAc,MAAM;AAC1B,aAAO;AAAA,QACL,aAAa;AAAA,UACX,GAAG;AAAA,UACH,CAAC,IAAI,KAAK,GAAG,IAAI;AAAA,QACnB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,CAAC,eAAe,aAAa;AACtC;",
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 = <T extends object>(obj: T) => Object.keys(obj) as (keyof T)[];\n\nexport const buildGetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<A> = {} as ZustandT.AtomGetters<A>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<A>;\n\n const getter = (() => get()[key]) as ZustandT.AtomGetters<A>[keyof ZustandT.AtomGetters<A>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <A extends object, S extends object, R extends object>(\n internalAtomDefaultValues: A,\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<A, S, R> = {} as ZustandT.AtomSetters<A, S, R>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<A, S, R>;\n\n const setter = ((newVal: A[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 A[typeof key] } as Partial<ZustandT.InternalStore<A, S, R>>);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<A, S, R>>);\n }\n }) as ZustandT.AtomSetters<A, S, R>[keyof ZustandT.AtomSetters<A, S, R>];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <A extends object, S extends object, R extends object>(\n get: ZustandT.Getter<ZustandT.InternalStore<A, S, R>>,\n set: ZustandT.Setter<ZustandT.InternalStore<A, S, R>>,\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,CAAmB,QAAW,OAAO,KAAK,GAAG;AAEtD,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA+C,CAAC;AAEtD,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,MAAM,IAAI,EAAE,GAAG;AAE/B,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBAAqD,CAAC;AAE5D,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,CAAC,WAA0B;AACzC,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAmB,CAA6C;AAAA,MACvG,OAAO;AAEL,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAA6C;AAAA,MACnE;AAAA,IACF;AAGA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,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;AAAK;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
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/createInternalAndPropsContext.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import createContext from 'zustand/context';\nimport type { ZustandT } from './types';\n\nexport const createInternalAndPropsContext = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>();\n\n return { PropsProvider, usePropsStore, InternalProvider, useInternalStore };\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import createContext from 'zustand/context';\nimport type { ZustandT } from './types.js';\n\nexport const createInternalAndPropsContext = <\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>();\n\n return { PropsProvider, usePropsStore, InternalProvider, useInternalStore };\n};\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAO,mBAAmB;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,IACvD,cAAiE;AAEnE,QAAM,EAAE,UAAU,kBAAkB,UAAU,iBAAiB,IAC7D,cAAsE;AAExE,SAAO,EAAE,eAAe,eAAe,kBAAkB,iBAAiB;AAC5E;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import { createInternalAndPropsContext } from "./createInternalAndPropsContext";
3
- import { withZustand } from "./withZustand";
2
+ import { createInternalAndPropsContext } from "./createInternalAndPropsContext.js";
3
+ import { withZustand } from "./withZustand.js";
4
4
  export {
5
5
  createInternalAndPropsContext,
6
6
  withZustand
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { createInternalAndPropsContext } from './createInternalAndPropsContext';\nexport { withZustand } from './withZustand';\nexport type { ZustandT } from './types';\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { createInternalAndPropsContext } from './createInternalAndPropsContext.js';\nexport { withZustand } from './withZustand.js';\nexport type { ZustandT } from './types.js';\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qCAAqC;AAC9C,SAAS,mBAAmB;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": [
4
+ "*.css",
5
+ "*.scss"
6
+ ]
7
+ }
@@ -1,15 +1,16 @@
1
1
  import * as React from "react";
2
- import { useCallback } from "react";
2
+ import { useCallback, createRef } from "react";
3
3
  import create from "zustand";
4
4
  import { subscribeWithSelector } from "zustand/middleware";
5
5
  import { immer } from "zustand/middleware/immer";
6
- import { buildGetters, buildRefGetterAndSetter, buildSetters } from "./builders";
6
+ import { buildGetters, buildRefGetterAndSetter, buildSetters } from "./builders.js";
7
7
  const createInternalStore = ({
8
8
  internalAtomDefaultValues,
9
9
  selectors,
10
10
  reducers,
11
11
  subscribers
12
12
  }) => {
13
+ const apiRef = createRef();
13
14
  const store = create(
14
15
  subscribeWithSelector(
15
16
  immer((set, get) => {
@@ -22,6 +23,7 @@ const createInternalStore = ({
22
23
  ...internalAtomSetters,
23
24
  ...selectors(get),
24
25
  ...reducers(get, set),
26
+ apiRef,
25
27
  zustandRefs: {},
26
28
  getZustandRef,
27
29
  setZustandRef,
@@ -32,6 +34,7 @@ const createInternalStore = ({
32
34
  )
33
35
  );
34
36
  subscribers(store);
37
+ apiRef.current = store;
35
38
  return store;
36
39
  };
37
40
  const useInternalStoreCreator = ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/useInternalStoreCreator.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback } from 'react';\nimport create from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { buildGetters, buildRefGetterAndSetter, buildSetters } from './builders';\nimport type { ZustandT } from './types';\n\n// Function that will create the store, putting:\n// 1) the atoms\n// 2) the getters for the atoms (which we auto-calculate and are mutable)\n// 3) the setters for the atoms (which we auto-calculate)\n// 4) the auto-calculated values\n// 5) selectors\n// 6) reducers\n// 7) ref object, getters and setters\n// 8) the get function\n// 9) the set function\n// After that, we configure the subscribers\n// The store is fully typed, and the setters are typed as well\nconst createInternalStore = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<A, S, R>>((set, get) => {\n // We build the atom getters\n const internalAtomGetters = buildGetters(internalAtomDefaultValues, get);\n\n // We build the atom setters\n const internalAtomSetters = buildSetters(internalAtomDefaultValues, get, set);\n\n // We build an object to store references to elements\n const [getZustandRef, setZustandRef] = buildRefGetterAndSetter(get, set);\n\n return {\n ...internalAtomDefaultValues,\n ...internalAtomGetters,\n ...internalAtomSetters,\n ...selectors(get),\n ...reducers(get, set),\n zustandRefs: {},\n getZustandRef,\n setZustandRef,\n get,\n set,\n };\n }),\n ),\n );\n\n // We setup all subscribers\n subscribers(store);\n\n return store;\n};\n\nexport const useInternalStoreCreator = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const storeCreator = useCallback(\n () => createInternalStore({ internalAtomDefaultValues, selectors, reducers, subscribers }),\n [internalAtomDefaultValues, selectors, reducers, subscribers],\n );\n\n return storeCreator;\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,mBAAmB;AAC5B,OAAO,YAAY;AACnB,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,cAAc,yBAAyB,oBAAoB;AAepE,MAAM,sBAAsB,CAAuD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,QAAQ;AAAA,IACZ;AAAA,MACE,MAAuC,CAAC,KAAK,QAAQ;AAEnD,cAAM,sBAAsB,aAAa,2BAA2B,GAAG;AAGvE,cAAM,sBAAsB,aAAa,2BAA2B,KAAK,GAAG;AAG5E,cAAM,CAAC,eAAe,aAAa,IAAI,wBAAwB,KAAK,GAAG;AAEvE,eAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG,UAAU,GAAG;AAAA,UAChB,GAAG,SAAS,KAAK,GAAG;AAAA,UACpB,aAAa,CAAC;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAGA,cAAY,KAAK;AAEjB,SAAO;AACT;AAEO,MAAM,0BAA0B,CAAuD;AAAA,EAC5F;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,eAAe;AAAA,IACnB,MAAM,oBAAoB,EAAE,2BAA2B,WAAW,UAAU,YAAY,CAAC;AAAA,IACzF,CAAC,2BAA2B,WAAW,UAAU,WAAW;AAAA,EAC9D;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, createRef } from 'react';\nimport create from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { buildGetters, buildRefGetterAndSetter, buildSetters } from './builders.js';\nimport type { ZustandT } from './types.js';\n\n// Function that will create the store, putting:\n// 1) the atoms\n// 2) the getters for the atoms (which we auto-calculate and are mutable)\n// 3) the setters for the atoms (which we auto-calculate)\n// 4) the auto-calculated values\n// 5) selectors\n// 6) reducers\n// 7) ref object, getters and setters\n// 8) the get function\n// 9) the set function\n// After that, we configure the subscribers\n// The store is fully typed, and the setters are typed as well\nconst createInternalStore = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const apiRef = createRef() as React.MutableRefObject<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>;\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<A, S, R>>((set, get) => {\n // We build the atom getters\n const internalAtomGetters = buildGetters(internalAtomDefaultValues, get);\n\n // We build the atom setters\n const internalAtomSetters = buildSetters(internalAtomDefaultValues, get, set);\n\n // We build an object to store references to elements\n const [getZustandRef, setZustandRef] = buildRefGetterAndSetter(get, set);\n\n return {\n ...internalAtomDefaultValues,\n ...internalAtomGetters,\n ...internalAtomSetters,\n ...selectors(get),\n ...reducers(get, set),\n apiRef,\n zustandRefs: {},\n getZustandRef,\n setZustandRef,\n get,\n set,\n };\n }),\n ),\n );\n\n // We setup all subscribers\n subscribers(store);\n apiRef.current = store;\n\n return store;\n};\n\nexport const useInternalStoreCreator = <A extends object, S extends object, R extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<A, S, R>) => {\n const storeCreator = useCallback(\n () => createInternalStore({ internalAtomDefaultValues, selectors, reducers, subscribers }),\n [internalAtomDefaultValues, selectors, reducers, subscribers],\n );\n\n return storeCreator;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,iBAAiB;AACvC,OAAO,YAAY;AACnB,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,cAAc,yBAAyB,oBAAoB;AAepE,MAAM,sBAAsB,CAAuD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ;AAAA,IACZ;AAAA,MACE,MAAuC,CAAC,KAAK,QAAQ;AAEnD,cAAM,sBAAsB,aAAa,2BAA2B,GAAG;AAGvE,cAAM,sBAAsB,aAAa,2BAA2B,KAAK,GAAG;AAG5E,cAAM,CAAC,eAAe,aAAa,IAAI,wBAAwB,KAAK,GAAG;AAEvE,eAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,GAAG,UAAU,GAAG;AAAA,UAChB,GAAG,SAAS,KAAK,GAAG;AAAA,UACpB;AAAA,UACA,aAAa,CAAC;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAGA,cAAY,KAAK;AACjB,SAAO,UAAU;AAEjB,SAAO;AACT;AAEO,MAAM,0BAA0B,CAAuD;AAAA,EAC5F;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4C;AAC1C,QAAM,eAAe;AAAA,IACnB,MAAM,oBAAoB,EAAE,2BAA2B,WAAW,UAAU,YAAY,CAAC;AAAA,IACzF,CAAC,2BAA2B,WAAW,UAAU,WAAW;AAAA,EAC9D;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/usePropsStoreCreator.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback } from 'react';\nimport create from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport type { ZustandT } from './types';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set) => ({\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <P extends object, C extends object>(props: P, autoCalculatedData: C) => {\n // we want to memoize the creation of the store,\n // it doesn't make sense to create a new store every time the props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const storeCreator = useCallback(() => createPropsStore(props, autoCalculatedData), []);\n\n return storeCreator;\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback } from 'react';\nimport create from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport type { ZustandT } from './types.js';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set) => ({\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <P extends object, C extends object>(props: P, autoCalculatedData: C) => {\n // we want to memoize the creation of the store,\n // it doesn't make sense to create a new store every time the props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const storeCreator = useCallback(() => createPropsStore(props, autoCalculatedData), []);\n\n return storeCreator;\n};\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,mBAAmB;AAC5B,OAAO,YAAY;AACnB,SAAS,aAAa;AAGtB,MAAM,mBAAmB,CAAqC,kBAAqB,uBACjF;AAAA,EACE,MAAkC,CAAC,SAAS;AAAA,IAC1C;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACL,EAAE;AACJ;AAEK,MAAM,uBAAuB,CAAqC,OAAU,uBAA0B;AAI3G,QAAM,eAAe,YAAY,MAAM,iBAAiB,OAAO,kBAAkB,GAAG,CAAC,CAAC;AAEtF,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
4
- import { useInternalStoreCreator } from "./useInternalStoreCreator";
5
- import { AutoUpdaterComponent } from "./AutoUpdaterComponent";
6
- import { usePropsStoreCreator } from "./usePropsStoreCreator";
4
+ import { useInternalStoreCreator } from "./useInternalStoreCreator.js";
5
+ import { AutoUpdaterComponent } from "./AutoUpdaterComponent.js";
6
+ import { usePropsStoreCreator } from "./usePropsStoreCreator.js";
7
7
  const noopish = () => ({});
8
8
  const withZustand = (Component, config) => {
9
9
  const {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/withZustand.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\n\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { useInternalStoreCreator } from './useInternalStoreCreator';\nimport type { ZustandT } from './types';\nimport { AutoUpdaterComponent } from './AutoUpdaterComponent';\nimport { usePropsStoreCreator } from './usePropsStoreCreator';\n\nconst noopish = <T extends object>() => ({} as T);\n\nexport const withZustand = <\n U extends object,\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<P, A, C, S, R>,\n) => {\n const {\n defaultProps,\n internalAtomDefaultValues,\n useAutoCalculated,\n selectors = noopish,\n reducers = noopish,\n subscribers = noopish,\n PropsProvider,\n InternalProvider,\n usePropsStore,\n } = config;\n\n const ComponentWithStore = (props: U) => {\n const propsWithDefault = useMemoMergePropsWithDefault<P>(props, defaultProps);\n\n const autoCalculatedData = useAutoCalculated(propsWithDefault);\n\n const internalStoreCreator = useInternalStoreCreator({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n });\n\n const propsStoreCreator = usePropsStoreCreator(propsWithDefault, autoCalculatedData);\n\n return (\n <PropsProvider createStore={propsStoreCreator}>\n <InternalProvider createStore={internalStoreCreator}>\n <AutoUpdaterComponent\n Component={Component}\n usePropsStore={usePropsStore}\n autoCalculatedData={autoCalculatedData}\n propsWithDefault={propsWithDefault}\n />\n </InternalProvider>\n </PropsProvider>\n );\n };\n return ComponentWithStore;\n};\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport React from 'react';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { useInternalStoreCreator } from './useInternalStoreCreator.js';\nimport type { ZustandT } from './types.js';\nimport { AutoUpdaterComponent } from './AutoUpdaterComponent.js';\nimport { usePropsStoreCreator } from './usePropsStoreCreator.js';\n\nconst noopish = <T extends object>() => ({} as T);\n\nexport const withZustand = <\n U extends object,\n P extends object,\n A extends object,\n C extends object,\n S extends object,\n R extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<P, A, C, S, R>,\n) => {\n const {\n defaultProps,\n internalAtomDefaultValues,\n useAutoCalculated,\n selectors = noopish,\n reducers = noopish,\n subscribers = noopish,\n PropsProvider,\n InternalProvider,\n usePropsStore,\n } = config;\n\n const ComponentWithStore = (props: U) => {\n const propsWithDefault = useMemoMergePropsWithDefault<P>(props, defaultProps);\n\n const autoCalculatedData = useAutoCalculated(propsWithDefault);\n\n const internalStoreCreator = useInternalStoreCreator({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n });\n\n const propsStoreCreator = usePropsStoreCreator(propsWithDefault, autoCalculatedData);\n\n return (\n <PropsProvider createStore={propsStoreCreator}>\n <InternalProvider createStore={internalStoreCreator}>\n <AutoUpdaterComponent\n Component={Component}\n usePropsStore={usePropsStore}\n autoCalculatedData={autoCalculatedData}\n propsWithDefault={propsWithDefault}\n />\n </InternalProvider>\n </PropsProvider>\n );\n };\n return ComponentWithStore;\n};\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACkDb;AAhDV,SAAS,oCAAoC;AAC7C,SAAS,+BAA+B;AAExC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AAErC,MAAM,UAAU,OAAyB,CAAC;AAEnC,MAAM,cAAc,CAQzB,WACA,WACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,qBAAqB,CAAC,UAAa;AACvC,UAAM,mBAAmB,6BAAgC,OAAO,YAAY;AAE5E,UAAM,qBAAqB,kBAAkB,gBAAgB;AAE7D,UAAM,uBAAuB,wBAAwB;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,oBAAoB,qBAAqB,kBAAkB,kBAAkB;AAEnF,WACE,oBAAC,iBAAc,aAAa,mBAC1B,8BAAC,oBAAiB,aAAa,sBAC7B;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF,GACF;AAAA,EAEJ;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- import type { ZustandT } from './types';
1
+ import type { ZustandT } from './types.js';
2
2
  export declare const AutoUpdaterComponent: ZustandT.AutoUpdaterComponentT;
@@ -1,4 +1,4 @@
1
- import type { ZustandT } from './types';
1
+ import type { ZustandT } from './types.js';
2
2
  export declare const buildGetters: <A extends object, S extends object, R extends object>(internalAtomDefaultValues: A, get: () => ZustandT.InternalStore<A, S, R>) => ZustandT.AtomGetters<A>;
3
3
  export declare const buildSetters: <A extends object, S extends object, R extends object>(internalAtomDefaultValues: A, get: () => ZustandT.InternalStore<A, S, R>, set: (nextStateOrUpdater: ZustandT.InternalStore<A, S, R> | Partial<ZustandT.InternalStore<A, S, R>> | ((state: import("immer").Draft<ZustandT.InternalStore<A, S, R>>) => void), shouldReplace?: boolean | undefined) => void) => ZustandT.AtomSetters<A, S, R>;
4
4
  export declare const buildRefGetterAndSetter: <A extends object, S extends object, R extends object>(get: () => ZustandT.InternalStore<A, S, R>, set: (nextStateOrUpdater: ZustandT.InternalStore<A, S, R> | Partial<ZustandT.InternalStore<A, S, R>> | ((state: import("immer").Draft<ZustandT.InternalStore<A, S, R>>) => void), shouldReplace?: boolean | undefined) => void) => readonly [(key: string[]) => HTMLElement | null, (key: string[], value: HTMLElement | null) => void];
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { ZustandT } from './types';
2
+ import type { ZustandT } from './types.js';
3
3
  export declare const createInternalAndPropsContext: <P extends object, A extends object, C extends object, S extends object, R extends object>() => {
4
4
  PropsProvider: ({ createStore, children, }: {
5
5
  createStore: () => ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>;
@@ -1,3 +1,3 @@
1
- export { createInternalAndPropsContext } from './createInternalAndPropsContext';
2
- export { withZustand } from './withZustand';
3
- export type { ZustandT } from './types';
1
+ export { createInternalAndPropsContext } from './createInternalAndPropsContext.js';
2
+ export { withZustand } from './withZustand.js';
3
+ export type { ZustandT } from './types.js';
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import type React from 'react';
2
2
  import type { Draft } from 'immer';
3
3
  import type { StoreApi, UseBoundStore } from 'zustand';
4
4
  import type createContext from 'zustand/context';
@@ -27,6 +27,7 @@ export declare namespace ZustandT {
27
27
  zustandRefs: Record<string, HTMLElement | null>;
28
28
  getZustandRef: (key: string[]) => HTMLElement | null;
29
29
  setZustandRef: (key: string[], value: HTMLElement | null) => void;
30
+ apiRef: React.MutableRefObject<ZustandStore<InternalStore<A, S, R>>>;
30
31
  };
31
32
  export type PropsStore<T> = T & {
32
33
  set: Setter<PropsStore<T>>;
@@ -1,4 +1,4 @@
1
- import type { ZustandT } from './types';
1
+ import type { ZustandT } from './types.js';
2
2
  export declare const useInternalStoreCreator: <A extends object, S extends object, R extends object>({ internalAtomDefaultValues, selectors, reducers, subscribers, }: ZustandT.InternalParameters<A, S, R>) => () => import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<ZustandT.InternalStore<A, S, R>>, "subscribe"> & {
3
3
  subscribe: {
4
4
  (listener: (selectedState: ZustandT.InternalStore<A, S, R>, previousSelectedState: ZustandT.InternalStore<A, S, R>) => void): () => void;
@@ -1,4 +1,4 @@
1
- import type { ZustandT } from './types';
1
+ import type { ZustandT } from './types.js';
2
2
  export declare const usePropsStoreCreator: <P extends object, C extends object>(props: P, autoCalculatedData: C) => () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ZustandT.PropsStore<P & C>>, "setState"> & {
3
3
  setState(nextStateOrUpdater: ZustandT.PropsStore<P & C> | Partial<ZustandT.PropsStore<P & C>> | ((state: import("immer").Draft<ZustandT.PropsStore<P & C>>) => void), shouldReplace?: boolean | undefined): void;
4
4
  }>;
@@ -1,2 +1,3 @@
1
- import type { ZustandT } from './types';
1
+ import React from 'react';
2
+ import type { ZustandT } from './types.js';
2
3
  export declare const withZustand: <U extends object, P extends object, A extends object, C extends object, S extends object, R extends object>(Component: React.ComponentType<Record<string, never>>, config: ZustandT.Config<P, A, C, S, R>) => (props: U) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-zustand-helpers",
3
- "version": "3.16.0",
3
+ "version": "3.16.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Zustand Helpers",
6
6
  "files": [
@@ -39,10 +39,10 @@
39
39
  "typeSafety": false
40
40
  },
41
41
  "dependencies": {
42
- "immer": "9.0.19",
43
- "zustand": "4.1.4",
44
- "@elliemae/ds-props-helpers": "3.16.0",
45
- "@elliemae/ds-utilities": "3.16.0"
42
+ "immer": "9.0.21",
43
+ "zustand": "4.3.6",
44
+ "@elliemae/ds-props-helpers": "3.16.1",
45
+ "@elliemae/ds-utilities": "3.16.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@testing-library/jest-dom": "~5.16.5",