@elliemae/ds-zustand-helpers 3.34.0-next.3 → 3.34.0-next.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.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;",
4
+ "sourcesContent": ["import type { ZustandT } from './types.js';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <ObjectType extends object>(obj: ObjectType) => Object.keys(obj) as (keyof ObjectType)[];\n\nexport const buildGetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<AtomValuesType> = {} as ZustandT.AtomGetters<AtomValuesType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<AtomValuesType>;\n\n const getter = (() =>\n get()[key]) as ZustandT.AtomGetters<AtomValuesType>[keyof ZustandT.AtomGetters<AtomValuesType>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType> =\n {} as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >;\n\n const setter = ((newVal: AtomValuesType[typeof key]) => {\n if (typeof newVal === 'function') {\n // If it's a function, we call it with the current store value, and the full store. We try to mimic react-setState's behavior\n set({ [key]: newVal(get()[key], get()) as AtomValuesType[typeof key] } as Partial<\n ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>\n >);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>);\n }\n }) as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>[keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const getZustandRef = (key: string[]): HTMLElement | null => get().zustandRefs[key.join(',')];\n\n const setZustandRef = (key: string[], value: HTMLElement | null) => {\n set((state) => {\n if (state instanceof Map || state instanceof Set) return;\n const zustandRefs = state.zustandRefs;\n return {\n zustandRefs: {\n ...zustandRefs,\n [key.join(',')]: value,\n },\n };\n });\n };\n\n return [getZustandRef, setZustandRef] as const;\n};\n", "import * as React from 'react';\nexport { React };\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;AAEnD,UAAM,SAAU,MACd,IAAI,EAAE,GAAG;AAEX,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBACJ,CAAC;AAEH,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAMnD,UAAM,SAAU,CAAC,WAAuC;AACtD,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAgC,CAEpE;AAAA,MACH,OAAO;AAEL,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAAiF;AAAA,MACvG;AAAA,IACF;AAOA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CAKrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG,CAAC;AAE5F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB;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": ["../../src/createInternalAndPropsContext.ts", "../../../../../scripts/build/transpile/react-shim.js"],
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;",
4
+ "sourcesContent": ["import createContext from 'zustand/context';\nimport type { ZustandT } from './types.js';\n\nexport const createInternalAndPropsContext = <\n PropsType extends object,\n AtomValuesType extends object,\n AutoCalculatedValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>>();\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,SAAgG;AAElG,QAAM,EAAE,UAAU,kBAAkB,UAAU,iBAAiB,QAC7D,eAAAA,SAA0G;AAE5G,SAAO,EAAE,eAAe,eAAe,kBAAkB,iBAAiB;AAC5E;",
6
6
  "names": ["createContext"]
7
7
  }
@@ -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 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 get: Getter<PropsStore<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 | (() => 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"],
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// UserPropsType is a generic assigned to the user props for clarity\n// InternalPropsType is a generic assigned to the internal props for clarity\n// AtomValuesType is a generic assigned to the atoms for clarity\n// AutoCalculatedValuesType is a generic assigned to the auto-calculated values for clarity\n// SelectorsType is a generic assigned to selectors for clarity\n// ReducersType is a generic assigned to reducers for clarity\n\nexport namespace ZustandT {\n type Write<OriginalType, OverwriteType> = Omit<OriginalType, keyof OverwriteType> & OverwriteType;\n\n type ImmerSetter<StateType extends object> = {\n setState: (\n nextStateOrUpdater: StateType | Partial<StateType> | ((state: Draft<StateType>) => void),\n shouldReplace?: boolean | undefined,\n ) => void;\n };\n\n type StoreSubscribeWithSelector<StateType> = {\n subscribe: {\n (listener: (selectedState: StateType, previousSelectedState: StateType) => void): () => void;\n <SelectedStateType>(\n selector: (state: StateType) => SelectedStateType,\n listener: (selectedState: SelectedStateType, previousSelectedState: SelectedStateType) => void,\n options?: {\n equalityFn?: (a: SelectedStateType, b: SelectedStateType) => boolean;\n fireImmediately?: boolean;\n },\n ): () => void;\n };\n };\n\n // We add the immer setter method type\n type StoreWithImmer<StateType extends object> = Write<StoreApi<StateType>, ImmerSetter<StateType>>;\n\n // We add the subscribe with selector method type\n type StoreWithImmerAndSubscriber<StateType extends object> = Write<\n StoreWithImmer<StateType>,\n StoreSubscribeWithSelector<StateType>\n >;\n\n export type ZustandStore<StateType extends object> = UseBoundStore<StoreWithImmerAndSubscriber<StateType>>;\n\n export type Getter<StateType extends object> = StoreWithImmerAndSubscriber<StateType>['getState'];\n export type Setter<StateType extends object> = StoreWithImmerAndSubscriber<StateType>['setState'];\n\n export type InternalStore<\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n > = AtomValuesType &\n AtomGetters<AtomValuesType> &\n AtomSetters<AtomValuesType, SelectorsType, ReducersType> &\n SelectorsType &\n ReducersType & {\n get: Getter<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;\n set: Setter<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;\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<AtomValuesType, SelectorsType, ReducersType>>>;\n };\n\n export type PropsStore<PropsType> = PropsType & {\n get: Getter<PropsStore<PropsType>>;\n set: Setter<PropsStore<PropsType>>;\n };\n\n export type AtomGetters<AtomValuesType extends object> = {\n [key in keyof AtomValuesType as `get${Capitalize<string & key>}`]: () => AtomValuesType[key];\n };\n\n export type AtomSetters<AtomValuesType extends object, SelectorsType extends object, ReducersType extends object> = {\n [key in keyof AtomValuesType as `set${Capitalize<string & key>}`]: (\n newVal:\n | AtomValuesType[key]\n | ((\n arg: AtomValuesType[key],\n store: InternalStore<AtomValuesType, SelectorsType, ReducersType>,\n ) => AtomValuesType[key]),\n ) => void;\n };\n\n export type SelectorObject<StoreType extends object, SelectorsType extends object> = (\n get: Getter<StoreType>,\n ) => SelectorsType;\n export type ReducerObject<StoreType extends object, ReducersType extends object> = (\n get: Getter<StoreType>,\n set: Setter<StoreType>,\n ) => ReducersType;\n export type Subscribers<StoreType extends object> = (api: StoreWithImmerAndSubscriber<StoreType>) => void;\n\n export type InternalParameters<\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n > = {\n internalAtomDefaultValues: AtomValuesType;\n selectors: SelectorObject<InternalStore<AtomValuesType, SelectorsType, ReducersType>, SelectorsType>;\n reducers: ReducerObject<InternalStore<AtomValuesType, SelectorsType, ReducersType>, ReducersType>;\n subscribers: Subscribers<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;\n };\n\n export type Config<\n DefaultPropsType extends object,\n AtomDefaultValuesType extends object,\n AutoCalculatedPropsType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n > = {\n defaultProps: DefaultPropsType;\n internalAtomDefaultValues: AtomDefaultValuesType;\n useAutoCalculated: (props: DefaultPropsType) => AutoCalculatedPropsType;\n selectors?: SelectorObject<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>, SelectorsType>;\n reducers?: ReducerObject<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>, ReducersType>;\n subscribers?: Subscribers<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>>;\n PropsProvider: ReturnType<\n typeof createContext<ZustandStore<PropsStore<DefaultPropsType & AutoCalculatedPropsType>>>\n >['Provider'];\n InternalProvider: ReturnType<\n typeof createContext<ZustandStore<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>>>\n >['Provider'];\n usePropsStore: ReturnType<\n typeof createContext<ZustandStore<PropsStore<DefaultPropsType & AutoCalculatedPropsType>>>\n >['useStore'];\n };\n\n export type AutoUpdaterComponentT = <\n UserPropsType extends object,\n AtomValuesType extends object,\n AutoCalculatedValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n >(\n props: Pick<\n Config<UserPropsType, AtomValuesType, AutoCalculatedValuesType, SelectorsType, ReducersType>,\n 'usePropsStore'\n > & { autoCalculatedData: AutoCalculatedValuesType } & {\n propsWithDefault: UserPropsType;\n } & { Component: React.ComponentType<Record<string, never>> },\n ) => JSX.Element;\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -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, 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,qBAAuB;AACvB,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;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;",
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 = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<AtomValuesType, SelectorsType, ReducersType>) => {\n const apiRef = createRef() as React.MutableRefObject<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>;\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>((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 = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<AtomValuesType, SelectorsType, ReducersType>) => {\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,qBAAuB;AACvB,wBAAsC;AACtC,mBAAsB;AACtB,sBAAoE;AAepE,MAAM,sBAAsB,CAA2F;AAAA,EACrH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgF;AAC9E,QAAM,aAAS,wBAAU;AACzB,QAAM,YAAQ;AAAA,QACZ;AAAA,UACE,oBAA2E,CAAC,KAAK,QAAQ;AAEvF,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,CAIrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgF;AAC9E,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": []
7
7
  }
@@ -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.js';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set, get) => ({\n get,\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,qBAAuB;AACvB,mBAAsB;AAGtB,MAAM,mBAAmB,CAAqC,kBAAqB,2BACjF;AAAA,MACE,oBAAkC,CAAC,KAAK,SAAS;AAAA,IAC/C;AAAA,IACA;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 = <PropsWithDefaultType extends object, AutoCalculatedDataType extends object>(\n propsWithDefault: PropsWithDefaultType,\n autoCalculatedData: AutoCalculatedDataType,\n) =>\n create(\n immer<ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType>>((set, get) => ({\n get,\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <PropsWithDefaultType extends object, AutoCalculatedDataType extends object>(\n props: PropsWithDefaultType,\n autoCalculatedData: AutoCalculatedDataType,\n) => {\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,qBAAuB;AACvB,mBAAsB;AAGtB,MAAM,mBAAmB,CACvB,kBACA,2BAEA;AAAA,MACE,oBAA0E,CAAC,KAAK,SAAS;AAAA,IACvF;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACL,EAAE;AACJ;AAEK,MAAM,uBAAuB,CAClC,OACA,uBACG;AAIH,QAAM,mBAAe,0BAAY,MAAM,iBAAiB,OAAO,kBAAkB,GAAG,CAAC,CAAC;AAEtF,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -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 */\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: React.ComponentType<U> = (props) => {\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,qBAA6C,CAAC,UAAU;AAC5D,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\n/**\n * A higher order component that wraps a component with Zustand store providers.\n * @param Component - The component to wrap.\n * @param config - The configuration object for the store.\n * @returns The wrapped component.\n */\nexport const withZustand = <\n UserPropsType extends object,\n InternalPropsType extends object,\n AtomValuesType extends object,\n AutoCalculatedValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<InternalPropsType, AtomValuesType, AutoCalculatedValuesType, SelectorsType, ReducersType>,\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: React.ComponentType<UserPropsType> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<InternalPropsType>(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;ADwDb;AAtDV,8BAA6C;AAC7C,qCAAwC;AAExC,kCAAqC;AACrC,kCAAqC;AAErC,MAAM,UAAU,OAAyB,CAAC;AAQnC,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,qBAAyD,CAAC,UAAU;AACxE,UAAM,uBAAmB,sDAAgD,OAAO,YAAY;AAE5F,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/builders.ts"],
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;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { ZustandT } from './types.js';\n\nconst capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);\n\nconst getKeys = <ObjectType extends object>(obj: ObjectType) => Object.keys(obj) as (keyof ObjectType)[];\n\nexport const buildGetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomGetters: ZustandT.AtomGetters<AtomValuesType> = {} as ZustandT.AtomGetters<AtomValuesType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForGetter = `get${capitalize(key as string)}` as keyof ZustandT.AtomGetters<AtomValuesType>;\n\n const getter = (() =>\n get()[key]) as ZustandT.AtomGetters<AtomValuesType>[keyof ZustandT.AtomGetters<AtomValuesType>];\n\n internalAtomGetters[keyForGetter] = getter;\n });\n\n return internalAtomGetters;\n};\n\nexport const buildSetters = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(\n internalAtomDefaultValues: AtomValuesType,\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const internalAtomSetters: ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType> =\n {} as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;\n\n getKeys(internalAtomDefaultValues).forEach((key) => {\n const keyForSetter = `set${capitalize(key as string)}` as keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >;\n\n const setter = ((newVal: AtomValuesType[typeof key]) => {\n if (typeof newVal === 'function') {\n // If it's a function, we call it with the current store value, and the full store. We try to mimic react-setState's behavior\n set({ [key]: newVal(get()[key], get()) as AtomValuesType[typeof key] } as Partial<\n ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>\n >);\n } else {\n // We just received the new value, set it\n set({ [key]: newVal } as Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>);\n }\n }) as ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>[keyof ZustandT.AtomSetters<\n AtomValuesType,\n SelectorsType,\n ReducersType\n >];\n\n // We add the setter to the internalAtomSetters object\n internalAtomSetters[keyForSetter] = setter;\n });\n\n return internalAtomSetters;\n};\n\nexport const buildRefGetterAndSetter = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n get: ZustandT.Getter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n set: ZustandT.Setter<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>,\n) => {\n const getZustandRef = (key: string[]): HTMLElement | null => get().zustandRefs[key.join(',')];\n\n const setZustandRef = (key: string[], value: HTMLElement | null) => {\n set((state) => {\n if (state instanceof Map || state instanceof Set) return;\n const zustandRefs = state.zustandRefs;\n return {\n zustandRefs: {\n ...zustandRefs,\n [key.join(',')]: value,\n },\n };\n });\n };\n\n return [getZustandRef, setZustandRef] as const;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,aAAa,CAAC,QAAgB,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAE7E,MAAM,UAAU,CAA4B,QAAoB,OAAO,KAAK,GAAG;AAExE,MAAM,eAAe,CAC1B,2BACA,QACG;AACH,QAAM,sBAA4D,CAAC;AAEnE,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAEnD,UAAM,SAAU,MACd,IAAI,EAAE,GAAG;AAEX,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,eAAe,CAC1B,2BACA,KACA,QACG;AACH,QAAM,sBACJ,CAAC;AAEH,UAAQ,yBAAyB,EAAE,QAAQ,CAAC,QAAQ;AAClD,UAAM,eAAe,MAAM,WAAW,GAAa;AAMnD,UAAM,SAAU,CAAC,WAAuC;AACtD,UAAI,OAAO,WAAW,YAAY;AAEhC,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAgC,CAEpE;AAAA,MACH,OAAO;AAEL,YAAI,EAAE,CAAC,GAAG,GAAG,OAAO,CAAiF;AAAA,MACvG;AAAA,IACF;AAOA,wBAAoB,YAAY,IAAI;AAAA,EACtC,CAAC;AAED,SAAO;AACT;AAEO,MAAM,0BAA0B,CAKrC,KACA,QACG;AACH,QAAM,gBAAgB,CAAC,QAAsC,IAAI,EAAE,YAAY,IAAI,KAAK,GAAG,CAAC;AAE5F,QAAM,gBAAgB,CAAC,KAAe,UAA8B;AAClE,QAAI,CAAC,UAAU;AACb,UAAI,iBAAiB,OAAO,iBAAiB;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.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
- "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;",
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 PropsType extends object,\n AtomValuesType extends object,\n AutoCalculatedValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>() => {\n const { Provider: PropsProvider, useStore: usePropsStore } =\n createContext<ZustandT.ZustandStore<ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>>>();\n\n const { Provider: InternalProvider, useStore: useInternalStore } =\n createContext<ZustandT.ZustandStore<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>>();\n\n return { PropsProvider, usePropsStore, InternalProvider, useInternalStore };\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAO,mBAAmB;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,IACvD,cAAgG;AAElG,QAAM,EAAE,UAAU,kBAAkB,UAAU,iBAAiB,IAC7D,cAA0G;AAE5G,SAAO,EAAE,eAAe,eAAe,kBAAkB,iBAAiB;AAC5E;",
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/useInternalStoreCreator.ts"],
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,SAAS,cAAc;AACvB,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;",
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 = <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<AtomValuesType, SelectorsType, ReducersType>) => {\n const apiRef = createRef() as React.MutableRefObject<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>>;\n const store = create(\n subscribeWithSelector(\n immer<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>((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 = <\n AtomValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>({\n internalAtomDefaultValues,\n selectors,\n reducers,\n subscribers,\n}: ZustandT.InternalParameters<AtomValuesType, SelectorsType, ReducersType>) => {\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,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,cAAc,yBAAyB,oBAAoB;AAepE,MAAM,sBAAsB,CAA2F;AAAA,EACrH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgF;AAC9E,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ;AAAA,IACZ;AAAA,MACE,MAA2E,CAAC,KAAK,QAAQ;AAEvF,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,CAIrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAgF;AAC9E,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.js';\n\nconst createPropsStore = <P extends object, C extends object>(propsWithDefault: P, autoCalculatedData: C) =>\n create(\n immer<ZustandT.PropsStore<P & C>>((set, get) => ({\n get,\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
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,MAAM,mBAAmB,CAAqC,kBAAqB,uBACjF;AAAA,EACE,MAAkC,CAAC,KAAK,SAAS;AAAA,IAC/C;AAAA,IACA;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;",
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 = <PropsWithDefaultType extends object, AutoCalculatedDataType extends object>(\n propsWithDefault: PropsWithDefaultType,\n autoCalculatedData: AutoCalculatedDataType,\n) =>\n create(\n immer<ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType>>((set, get) => ({\n get,\n set,\n ...propsWithDefault,\n ...autoCalculatedData,\n })),\n );\n\nexport const usePropsStoreCreator = <PropsWithDefaultType extends object, AutoCalculatedDataType extends object>(\n props: PropsWithDefaultType,\n autoCalculatedData: AutoCalculatedDataType,\n) => {\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
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,MAAM,mBAAmB,CACvB,kBACA,uBAEA;AAAA,EACE,MAA0E,CAAC,KAAK,SAAS;AAAA,IACvF;AAAA,IACA;AAAA,IACA,GAAG;AAAA,IACH,GAAG;AAAA,EACL,EAAE;AACJ;AAEK,MAAM,uBAAuB,CAClC,OACA,uBACG;AAIH,QAAM,eAAe,YAAY,MAAM,iBAAiB,OAAO,kBAAkB,GAAG,CAAC,CAAC;AAEtF,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/withZustand.tsx"],
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: React.ComponentType<U> = (props) => {\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
- "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,qBAA6C,CAAC,UAAU;AAC5D,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;",
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\n/**\n * A higher order component that wraps a component with Zustand store providers.\n * @param Component - The component to wrap.\n * @param config - The configuration object for the store.\n * @returns The wrapped component.\n */\nexport const withZustand = <\n UserPropsType extends object,\n InternalPropsType extends object,\n AtomValuesType extends object,\n AutoCalculatedValuesType extends object,\n SelectorsType extends object,\n ReducersType extends object,\n>(\n Component: React.ComponentType<Record<string, never>>,\n config: ZustandT.Config<InternalPropsType, AtomValuesType, AutoCalculatedValuesType, SelectorsType, ReducersType>,\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: React.ComponentType<UserPropsType> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<InternalPropsType>(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
+ "mappings": "AAAA,YAAY,WAAW;ACwDb;AAtDV,SAAS,oCAAoC;AAC7C,SAAS,+BAA+B;AAExC,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AAErC,MAAM,UAAU,OAAyB,CAAC;AAQnC,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,qBAAyD,CAAC,UAAU;AACxE,UAAM,mBAAmB,6BAAgD,OAAO,YAAY;AAE5F,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,4 +1,4 @@
1
1
  import type { ZustandT } from './types.js';
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
- 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
- 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];
2
+ export declare const buildGetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get: () => ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>) => ZustandT.AtomGetters<AtomValuesType>;
3
+ export declare const buildSetters: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(internalAtomDefaultValues: AtomValuesType, get: () => ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>, set: (nextStateOrUpdater: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType> | Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>> | ((state: import("immer").Draft<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => void), shouldReplace?: boolean | undefined) => void) => ZustandT.AtomSetters<AtomValuesType, SelectorsType, ReducersType>;
4
+ export declare const buildRefGetterAndSetter: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>(get: () => ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>, set: (nextStateOrUpdater: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType> | Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>> | ((state: import("immer").Draft<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => void), shouldReplace?: boolean | undefined) => void) => readonly [(key: string[]) => HTMLElement | null, (key: string[], value: HTMLElement | null) => void];
@@ -1,20 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  import type { ZustandT } from './types.js';
3
- export declare const createInternalAndPropsContext: <P extends object, A extends object, C extends object, S extends object, R extends object>() => {
3
+ export declare const createInternalAndPropsContext: <PropsType extends object, AtomValuesType extends object, AutoCalculatedValuesType extends object, SelectorsType extends object, ReducersType extends object>() => {
4
4
  PropsProvider: ({ createStore, children, }: {
5
- createStore: () => ZustandT.ZustandStore<ZustandT.PropsStore<P & C>>;
5
+ createStore: () => ZustandT.ZustandStore<ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>>;
6
6
  children: import("react").ReactNode;
7
- }) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.PropsStore<P & C>> | undefined>>;
7
+ }) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>> | undefined>>;
8
8
  usePropsStore: {
9
- (): ZustandT.PropsStore<P & C>;
10
- <U>(selector: (state: ZustandT.PropsStore<P & C>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined): U;
9
+ (): ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>;
10
+ <U>(selector: (state: ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>) => U, equalityFn?: ((a: U, b: U) => boolean) | undefined): U;
11
11
  };
12
12
  InternalProvider: ({ createStore, children, }: {
13
- createStore: () => ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>>;
13
+ createStore: () => ZustandT.ZustandStore<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>;
14
14
  children: import("react").ReactNode;
15
- }) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.InternalStore<A, S, R>> | undefined>>;
15
+ }) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>> | undefined>>;
16
16
  useInternalStore: {
17
- (): ZustandT.InternalStore<A, S, R>;
18
- <U_1>(selector: (state: ZustandT.InternalStore<A, S, R>) => U_1, equalityFn?: ((a: U_1, b: U_1) => boolean) | undefined): U_1;
17
+ (): ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>;
18
+ <U_1>(selector: (state: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>) => U_1, equalityFn?: ((a: U_1, b: U_1) => boolean) | undefined): U_1;
19
19
  };
20
20
  };
@@ -3,66 +3,66 @@ import type { Draft } from 'immer';
3
3
  import type { StoreApi, UseBoundStore } from 'zustand';
4
4
  import type createContext from 'zustand/context';
5
5
  export declare namespace ZustandT {
6
- type Write<T, U> = Omit<T, keyof U> & U;
7
- type ImmerSetter<T extends object> = {
8
- setState: (nextStateOrUpdater: T | Partial<T> | ((state: Draft<T>) => void), shouldReplace?: boolean | undefined) => void;
6
+ type Write<OriginalType, OverwriteType> = Omit<OriginalType, keyof OverwriteType> & OverwriteType;
7
+ type ImmerSetter<StateType extends object> = {
8
+ setState: (nextStateOrUpdater: StateType | Partial<StateType> | ((state: Draft<StateType>) => void), shouldReplace?: boolean | undefined) => void;
9
9
  };
10
- type StoreSubscribeWithSelector<T> = {
10
+ type StoreSubscribeWithSelector<StateType> = {
11
11
  subscribe: {
12
- (listener: (selectedState: T, previousSelectedState: T) => void): () => void;
13
- <U>(selector: (state: T) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
14
- equalityFn?: (a: U, b: U) => boolean;
12
+ (listener: (selectedState: StateType, previousSelectedState: StateType) => void): () => void;
13
+ <SelectedStateType>(selector: (state: StateType) => SelectedStateType, listener: (selectedState: SelectedStateType, previousSelectedState: SelectedStateType) => void, options?: {
14
+ equalityFn?: (a: SelectedStateType, b: SelectedStateType) => boolean;
15
15
  fireImmediately?: boolean;
16
16
  }): () => void;
17
17
  };
18
18
  };
19
- type StoreWithImmer<T extends object> = Write<StoreApi<T>, ImmerSetter<T>>;
20
- type StoreWithImmerAndSubscriber<T extends object> = Write<StoreWithImmer<T>, StoreSubscribeWithSelector<T>>;
21
- export type ZustandStore<T extends object> = UseBoundStore<StoreWithImmerAndSubscriber<T>>;
22
- export type Getter<T extends object> = StoreWithImmerAndSubscriber<T>['getState'];
23
- export type Setter<T extends object> = StoreWithImmerAndSubscriber<T>['setState'];
24
- export type InternalStore<A extends object, S extends object, R extends object> = A & AtomGetters<A> & AtomSetters<A, S, R> & S & R & {
25
- get: Getter<InternalStore<A, S, R>>;
26
- set: Setter<InternalStore<A, S, R>>;
19
+ type StoreWithImmer<StateType extends object> = Write<StoreApi<StateType>, ImmerSetter<StateType>>;
20
+ type StoreWithImmerAndSubscriber<StateType extends object> = Write<StoreWithImmer<StateType>, StoreSubscribeWithSelector<StateType>>;
21
+ export type ZustandStore<StateType extends object> = UseBoundStore<StoreWithImmerAndSubscriber<StateType>>;
22
+ export type Getter<StateType extends object> = StoreWithImmerAndSubscriber<StateType>['getState'];
23
+ export type Setter<StateType extends object> = StoreWithImmerAndSubscriber<StateType>['setState'];
24
+ export type InternalStore<AtomValuesType extends object, SelectorsType extends object, ReducersType extends object> = AtomValuesType & AtomGetters<AtomValuesType> & AtomSetters<AtomValuesType, SelectorsType, ReducersType> & SelectorsType & ReducersType & {
25
+ get: Getter<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;
26
+ set: Setter<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;
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
+ apiRef: React.MutableRefObject<ZustandStore<InternalStore<AtomValuesType, SelectorsType, ReducersType>>>;
31
31
  };
32
- export type PropsStore<T> = T & {
33
- get: Getter<PropsStore<T>>;
34
- set: Setter<PropsStore<T>>;
32
+ export type PropsStore<PropsType> = PropsType & {
33
+ get: Getter<PropsStore<PropsType>>;
34
+ set: Setter<PropsStore<PropsType>>;
35
35
  };
36
- export type AtomGetters<A extends object> = {
37
- [key in keyof A as `get${Capitalize<string & key>}`]: () => A[key];
36
+ export type AtomGetters<AtomValuesType extends object> = {
37
+ [key in keyof AtomValuesType as `get${Capitalize<string & key>}`]: () => AtomValuesType[key];
38
38
  };
39
- export type AtomSetters<A extends object, S extends object, R extends object> = {
40
- [key in keyof A as `set${Capitalize<string & key>}`]: (newVal: A[key] | ((arg: A[key], store: InternalStore<A, S, R>) => A[key])) => void;
39
+ export type AtomSetters<AtomValuesType extends object, SelectorsType extends object, ReducersType extends object> = {
40
+ [key in keyof AtomValuesType as `set${Capitalize<string & key>}`]: (newVal: AtomValuesType[key] | ((arg: AtomValuesType[key], store: InternalStore<AtomValuesType, SelectorsType, ReducersType>) => AtomValuesType[key])) => void;
41
41
  };
42
- export type SelectorObject<T extends object, S extends object> = (get: Getter<T>) => S;
43
- export type ReducerObject<T extends object, R extends object> = (get: Getter<T>, set: Setter<T>) => R;
44
- export type Subscribers<T extends object> = (api: StoreWithImmerAndSubscriber<T>) => void;
45
- export type InternalParameters<A extends object, S extends object, R extends object> = {
46
- internalAtomDefaultValues: A;
47
- selectors: SelectorObject<InternalStore<A, S, R>, S>;
48
- reducers: ReducerObject<InternalStore<A, S, R>, R>;
49
- subscribers: Subscribers<InternalStore<A, S, R>>;
42
+ export type SelectorObject<StoreType extends object, SelectorsType extends object> = (get: Getter<StoreType>) => SelectorsType;
43
+ export type ReducerObject<StoreType extends object, ReducersType extends object> = (get: Getter<StoreType>, set: Setter<StoreType>) => ReducersType;
44
+ export type Subscribers<StoreType extends object> = (api: StoreWithImmerAndSubscriber<StoreType>) => void;
45
+ export type InternalParameters<AtomValuesType extends object, SelectorsType extends object, ReducersType extends object> = {
46
+ internalAtomDefaultValues: AtomValuesType;
47
+ selectors: SelectorObject<InternalStore<AtomValuesType, SelectorsType, ReducersType>, SelectorsType>;
48
+ reducers: ReducerObject<InternalStore<AtomValuesType, SelectorsType, ReducersType>, ReducersType>;
49
+ subscribers: Subscribers<InternalStore<AtomValuesType, SelectorsType, ReducersType>>;
50
50
  };
51
- export type Config<P extends object, A extends object, C extends object, S extends object, R extends object> = {
52
- defaultProps: P | (() => P);
53
- internalAtomDefaultValues: A;
54
- useAutoCalculated: (props: P) => C;
55
- selectors?: SelectorObject<InternalStore<A, S, R>, S>;
56
- reducers?: ReducerObject<InternalStore<A, S, R>, R>;
57
- subscribers?: Subscribers<InternalStore<A, S, R>>;
58
- PropsProvider: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['Provider'];
59
- InternalProvider: ReturnType<typeof createContext<ZustandStore<InternalStore<A, S, R>>>>['Provider'];
60
- usePropsStore: ReturnType<typeof createContext<ZustandStore<PropsStore<P & C>>>>['useStore'];
51
+ export type Config<DefaultPropsType extends object, AtomDefaultValuesType extends object, AutoCalculatedPropsType extends object, SelectorsType extends object, ReducersType extends object> = {
52
+ defaultProps: DefaultPropsType;
53
+ internalAtomDefaultValues: AtomDefaultValuesType;
54
+ useAutoCalculated: (props: DefaultPropsType) => AutoCalculatedPropsType;
55
+ selectors?: SelectorObject<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>, SelectorsType>;
56
+ reducers?: ReducerObject<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>, ReducersType>;
57
+ subscribers?: Subscribers<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>>;
58
+ PropsProvider: ReturnType<typeof createContext<ZustandStore<PropsStore<DefaultPropsType & AutoCalculatedPropsType>>>>['Provider'];
59
+ InternalProvider: ReturnType<typeof createContext<ZustandStore<InternalStore<AtomDefaultValuesType, SelectorsType, ReducersType>>>>['Provider'];
60
+ usePropsStore: ReturnType<typeof createContext<ZustandStore<PropsStore<DefaultPropsType & AutoCalculatedPropsType>>>>['useStore'];
61
61
  };
62
- export type AutoUpdaterComponentT = <P extends object, A extends object, C extends object, S extends object, R extends object>(props: Pick<Config<P, A, C, S, R>, 'usePropsStore'> & {
63
- autoCalculatedData: C;
62
+ export type AutoUpdaterComponentT = <UserPropsType extends object, AtomValuesType extends object, AutoCalculatedValuesType extends object, SelectorsType extends object, ReducersType extends object>(props: Pick<Config<UserPropsType, AtomValuesType, AutoCalculatedValuesType, SelectorsType, ReducersType>, 'usePropsStore'> & {
63
+ autoCalculatedData: AutoCalculatedValuesType;
64
64
  } & {
65
- propsWithDefault: P;
65
+ propsWithDefault: UserPropsType;
66
66
  } & {
67
67
  Component: React.ComponentType<Record<string, never>>;
68
68
  }) => JSX.Element;
@@ -1,12 +1,12 @@
1
1
  import type { ZustandT } from './types.js';
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"> & {
2
+ export declare const useInternalStoreCreator: <AtomValuesType extends object, SelectorsType extends object, ReducersType extends object>({ internalAtomDefaultValues, selectors, reducers, subscribers, }: ZustandT.InternalParameters<AtomValuesType, SelectorsType, ReducersType>) => () => import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>, "subscribe"> & {
3
3
  subscribe: {
4
- (listener: (selectedState: ZustandT.InternalStore<A, S, R>, previousSelectedState: ZustandT.InternalStore<A, S, R>) => void): () => void;
5
- <U>(selector: (state: ZustandT.InternalStore<A, S, R>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
4
+ (listener: (selectedState: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>, previousSelectedState: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>) => void): () => void;
5
+ <U>(selector: (state: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
6
6
  equalityFn?: ((a: U, b: U) => boolean) | undefined;
7
7
  fireImmediately?: boolean | undefined;
8
8
  } | undefined): () => void;
9
9
  };
10
10
  }, "setState"> & {
11
- setState(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;
11
+ setState(nextStateOrUpdater: ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType> | Partial<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>> | ((state: import("immer").Draft<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>>) => void), shouldReplace?: boolean | undefined): void;
12
12
  }>;
@@ -1,4 +1,4 @@
1
1
  import type { ZustandT } from './types.js';
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
- setState(nextStateOrUpdater: ZustandT.PropsStore<P & C> | Partial<ZustandT.PropsStore<P & C>> | ((state: import("immer").Draft<ZustandT.PropsStore<P & C>>) => void), shouldReplace?: boolean | undefined): void;
2
+ export declare const usePropsStoreCreator: <PropsWithDefaultType extends object, AutoCalculatedDataType extends object>(props: PropsWithDefaultType, autoCalculatedData: AutoCalculatedDataType) => () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType>>, "setState"> & {
3
+ setState(nextStateOrUpdater: ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType> | Partial<ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType>> | ((state: import("immer").Draft<ZustandT.PropsStore<PropsWithDefaultType & AutoCalculatedDataType>>) => void), shouldReplace?: boolean | undefined): void;
4
4
  }>;
@@ -1,3 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { ZustandT } from './types.js';
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>) => React.FunctionComponent<U>;
3
+ /**
4
+ * A higher order component that wraps a component with Zustand store providers.
5
+ * @param Component - The component to wrap.
6
+ * @param config - The configuration object for the store.
7
+ * @returns The wrapped component.
8
+ */
9
+ export declare const withZustand: <UserPropsType extends object, InternalPropsType extends object, AtomValuesType extends object, AutoCalculatedValuesType extends object, SelectorsType extends object, ReducersType extends object>(Component: React.ComponentType<Record<string, never>>, config: ZustandT.Config<InternalPropsType, AtomValuesType, AutoCalculatedValuesType, SelectorsType, ReducersType>) => React.FunctionComponent<UserPropsType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-zustand-helpers",
3
- "version": "3.34.0-next.3",
3
+ "version": "3.34.0-next.4",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Zustand Helpers",
6
6
  "files": [
@@ -11,6 +11,7 @@
11
11
  "types": "./dist/types/index.d.ts",
12
12
  "exports": {
13
13
  ".": {
14
+ "types": "./dist/types/index.d.ts",
14
15
  "import": "./dist/esm/index.js",
15
16
  "require": "./dist/cjs/index.js"
16
17
  }
@@ -41,12 +42,12 @@
41
42
  "dependencies": {
42
43
  "immer": "9.0.21",
43
44
  "zustand": "4.3.6",
44
- "@elliemae/ds-props-helpers": "3.34.0-next.3"
45
+ "@elliemae/ds-props-helpers": "3.34.0-next.4"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@elliemae/pui-cli": "~9.0.0-next.31",
48
49
  "styled-components": "~5.3.9",
49
- "@elliemae/ds-monorepo-devops": "3.34.0-next.3"
50
+ "@elliemae/ds-monorepo-devops": "3.34.0-next.4"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "react": "~17.0.2",
@@ -54,8 +55,7 @@
54
55
  },
55
56
  "scripts": {
56
57
  "test": "pui-cli test --passWithNoTests --coverage=\"false\"",
57
- "lint": "node ../../../scripts/lint.mjs",
58
- "eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../../.eslintrc.js' src/",
58
+ "lint": "node ../../../scripts/lint.mjs --fix",
59
59
  "dts": "node ../../../scripts/dts.mjs",
60
60
  "build": "cross-env NODE_ENV=production node ../../../scripts/build/build.mjs",
61
61
  "checkDeps": "npm exec ../../util/ds-codemods -- check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\"",