@elliemae/ds-zustand-helpers 3.34.0-next.3 → 3.34.0-next.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/builders.js.map +2 -2
- package/dist/cjs/createInternalAndPropsContext.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/useInternalStoreCreator.js.map +2 -2
- package/dist/cjs/usePropsStoreCreator.js.map +2 -2
- package/dist/cjs/withZustand.js.map +2 -2
- package/dist/esm/builders.js.map +2 -2
- package/dist/esm/createInternalAndPropsContext.js.map +2 -2
- package/dist/esm/useInternalStoreCreator.js.map +2 -2
- package/dist/esm/usePropsStoreCreator.js.map +2 -2
- package/dist/esm/withZustand.js.map +2 -2
- package/dist/types/builders.d.ts +3 -3
- package/dist/types/createInternalAndPropsContext.d.ts +9 -9
- package/dist/types/types.d.ts +44 -44
- package/dist/types/useInternalStoreCreator.d.ts +4 -4
- package/dist/types/usePropsStoreCreator.d.ts +2 -2
- package/dist/types/withZustand.d.ts +7 -1
- package/package.json +5 -5
package/dist/cjs/builders.js.map
CHANGED
@@ -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 = <
|
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,
|
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
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,qBAA0B;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,QACvD,eAAAA,
|
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
|
}
|
package/dist/cjs/types.js.map
CHANGED
@@ -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//
|
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 = <
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAuC;AACvC,qBAAuB;AACvB,wBAAsC;AACtC,mBAAsB;AACtB,sBAAoE;AAepE,MAAM,sBAAsB,
|
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 = <
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAC5B,qBAAuB;AACvB,mBAAsB;AAGtB,MAAM,mBAAmB,
|
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
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
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
|
}
|
package/dist/esm/builders.js.map
CHANGED
@@ -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 = <
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,aAAa,CAAC,QAAgB,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAE7E,MAAM,UAAU,
|
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
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAO,mBAAmB;AAGnB,MAAM,gCAAgC,MAMtC;AACL,QAAM,EAAE,UAAU,eAAe,UAAU,cAAc,IACvD,
|
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 = <
|
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,
|
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 = <
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AAGtB,MAAM,mBAAmB,
|
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
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
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
|
}
|
package/dist/types/builders.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { ZustandT } from './types.js';
|
2
|
-
export declare const buildGetters: <
|
3
|
-
export declare const buildSetters: <
|
4
|
-
export declare const buildRefGetterAndSetter: <
|
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: <
|
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<
|
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<
|
7
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.PropsStore<PropsType & AutoCalculatedValuesType>> | undefined>>;
|
8
8
|
usePropsStore: {
|
9
|
-
(): ZustandT.PropsStore<
|
10
|
-
<U>(selector: (state: ZustandT.PropsStore<
|
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<
|
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<
|
15
|
+
}) => import("react").FunctionComponentElement<import("react").ProviderProps<ZustandT.ZustandStore<ZustandT.InternalStore<AtomValuesType, SelectorsType, ReducersType>> | undefined>>;
|
16
16
|
useInternalStore: {
|
17
|
-
(): ZustandT.InternalStore<
|
18
|
-
<U_1>(selector: (state: ZustandT.InternalStore<
|
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
|
};
|
package/dist/types/types.d.ts
CHANGED
@@ -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<
|
7
|
-
type ImmerSetter<
|
8
|
-
setState: (nextStateOrUpdater:
|
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<
|
10
|
+
type StoreSubscribeWithSelector<StateType> = {
|
11
11
|
subscribe: {
|
12
|
-
(listener: (selectedState:
|
13
|
-
<
|
14
|
-
equalityFn?: (a:
|
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<
|
20
|
-
type StoreWithImmerAndSubscriber<
|
21
|
-
export type ZustandStore<
|
22
|
-
export type Getter<
|
23
|
-
export type Setter<
|
24
|
-
export type InternalStore<
|
25
|
-
get: Getter<InternalStore<
|
26
|
-
set: Setter<InternalStore<
|
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<
|
30
|
+
apiRef: React.MutableRefObject<ZustandStore<InternalStore<AtomValuesType, SelectorsType, ReducersType>>>;
|
31
31
|
};
|
32
|
-
export type PropsStore<
|
33
|
-
get: Getter<PropsStore<
|
34
|
-
set: Setter<PropsStore<
|
32
|
+
export type PropsStore<PropsType> = PropsType & {
|
33
|
+
get: Getter<PropsStore<PropsType>>;
|
34
|
+
set: Setter<PropsStore<PropsType>>;
|
35
35
|
};
|
36
|
-
export type AtomGetters<
|
37
|
-
[key in keyof
|
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<
|
40
|
-
[key in keyof
|
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<
|
43
|
-
export type ReducerObject<
|
44
|
-
export type Subscribers<
|
45
|
-
export type InternalParameters<
|
46
|
-
internalAtomDefaultValues:
|
47
|
-
selectors: SelectorObject<InternalStore<
|
48
|
-
reducers: ReducerObject<InternalStore<
|
49
|
-
subscribers: Subscribers<InternalStore<
|
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<
|
52
|
-
defaultProps:
|
53
|
-
internalAtomDefaultValues:
|
54
|
-
useAutoCalculated: (props:
|
55
|
-
selectors?: SelectorObject<InternalStore<
|
56
|
-
reducers?: ReducerObject<InternalStore<
|
57
|
-
subscribers?: Subscribers<InternalStore<
|
58
|
-
PropsProvider: ReturnType<typeof createContext<ZustandStore<PropsStore<
|
59
|
-
InternalProvider: ReturnType<typeof createContext<ZustandStore<InternalStore<
|
60
|
-
usePropsStore: ReturnType<typeof createContext<ZustandStore<PropsStore<
|
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 = <
|
63
|
-
autoCalculatedData:
|
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:
|
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: <
|
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<
|
5
|
-
<U>(selector: (state: ZustandT.InternalStore<
|
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<
|
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: <
|
3
|
-
setState(nextStateOrUpdater: ZustandT.PropsStore<
|
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
|
-
|
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
|
+
"version": "3.34.0-next.5",
|
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.
|
45
|
+
"@elliemae/ds-props-helpers": "3.34.0-next.5"
|
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.
|
50
|
+
"@elliemae/ds-monorepo-devops": "3.34.0-next.5"
|
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/*\"",
|