@zayne-labs/toolkit-react 0.9.53 → 0.9.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-Cmnj4LWo.js";
1
+ import { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect } from "../index-44MAU7Zb.js";
2
2
  export { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
@@ -1,7 +1,7 @@
1
1
  import { AnyFunction, CallbackFn, NonEmptyArray, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
2
2
  import * as react5 from "react";
3
3
  import { RefCallback, useEffect } from "react";
4
- import * as _zayne_labs_toolkit_core15 from "@zayne-labs/toolkit-core";
4
+ import * as _zayne_labs_toolkit_core7 from "@zayne-labs/toolkit-core";
5
5
  import { AnimationIntervalOptions, LocationInfo, LocationStoreApi, LocationStoreOptions, ScrollObserverOptions, StorageOptions, StorageStoreApi, StoreApi, URLSearchParamsInit } from "@zayne-labs/toolkit-core";
6
6
 
7
7
  //#region src/hooks/createCustomContext.d.ts
@@ -138,13 +138,13 @@ declare const useIsServer: () => boolean;
138
138
  //#endregion
139
139
  //#region src/hooks/useLocationState.d.ts
140
140
  type UseLocationResult<TSlice> = [state: TSlice, actions: LocationStoreApi];
141
- declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core15.StoreApi<_zayne_labs_toolkit_core15.URLInfoObject>, "setState" | "resetState"> & {
142
- push: (url: string | _zayne_labs_toolkit_core15.PartialURLInfo, options?: {
143
- state?: _zayne_labs_toolkit_core15.PartialURLInfo["state"];
141
+ declare const createUseLocationState: (options?: LocationStoreOptions) => Omit<_zayne_labs_toolkit_core7.StoreApi<_zayne_labs_toolkit_core7.URLInfoObject>, "setState" | "resetState"> & {
142
+ push: (url: string | _zayne_labs_toolkit_core7.PartialURLInfo, options?: {
143
+ state?: _zayne_labs_toolkit_core7.PartialURLInfo["state"];
144
144
  }) => void;
145
145
  replace: LocationStoreApi["push"];
146
146
  triggerPopstateEvent: (nextLocationState?: LocationInfo["state"]) => void;
147
- } & (<TSlice = _zayne_labs_toolkit_core15.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
147
+ } & (<TSlice = _zayne_labs_toolkit_core7.URLInfoObject>(selector?: SelectorFn<LocationInfo, TSlice>) => UseLocationResult<TSlice>);
148
148
  declare const useLocationState: <TSlice = LocationInfo>(selector?: SelectorFn<LocationInfo, TSlice>, options?: LocationStoreOptions) => UseLocationResult<TSlice>;
149
149
  //#endregion
150
150
  //#region src/hooks/useToggle.d.ts
@@ -208,11 +208,11 @@ type UseSearchParamsOptions = LocationStoreOptions & {
208
208
  };
209
209
  declare const useSearchParams: <TSearchParams extends URLSearchParamsInit>(options?: UseSearchParamsOptions) => readonly [URLSearchParams, {
210
210
  (newQueryParams: TSearchParams | ((prev: URLSearchParams) => TSearchParams)): void;
211
- triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core15.LocationInfo["state"]) => void;
211
+ triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core7.LocationInfo["state"]) => void;
212
212
  }];
213
213
  declare const useSearchParamsObject: <TSearchParams extends Record<string, string>>(options?: UseSearchParamsOptions) => readonly [TSearchParams, {
214
214
  (newQueryParams: TSearchParams | ((prev: TSearchParams) => TSearchParams)): void;
215
- triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core15.LocationInfo["state"]) => void;
215
+ triggerPopstateEvent: (nextLocationState?: _zayne_labs_toolkit_core7.LocationInfo["state"]) => void;
216
216
  }];
217
217
  //#endregion
218
218
  //#region src/hooks/useStorageState.d.ts
@@ -221,7 +221,7 @@ type UseStorageResult<TState, TSlice = TState> = [state: TSlice, actions: Storag
221
221
  * @description Creates a custom hook that returns a storage state and actions to modify it. You can use this if you need shared options.
222
222
  * @note You must use this if you want to be able to prevent syncing state across tabs.
223
223
  */
224
- declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core15.StoreApi<TState> & {
224
+ declare const createUseStorageState: <TState>(baseOptions: StorageOptions<TState>) => _zayne_labs_toolkit_core7.StoreApi<TState> & {
225
225
  removeState: () => void;
226
226
  } & (<TSlice = TState>(selector?: SelectorFn<TState, TSlice>) => UseStorageResult<TState, TSlice>);
227
227
  type UseStorageStateOptions<TValue> = Omit<StorageOptions<TValue>, "initialValue" | "key">;
@@ -244,4 +244,4 @@ declare const useThrottleByFrame: <TParams>(callbackFn: CallbackFn<TParams>) =>
244
244
  };
245
245
  //#endregion
246
246
  export { ContextError, CustomContextOptions, createCustomContext, createUseLocationState, createUseStorageState, getErrorMessage, useAfterMountEffect, useAnimateElementRefs, useAnimationInterval, useAsyncEffect, useCallbackRef, useClickOutside, useConstant, useCopyToClipboard, useDebouncedFn, useDebouncedState, useDisclosure, useEffectOnce, useIsServer, useLifeCycle, useLocationState, useMountEffect, usePresence, useScrollObserver, useSearch, useSearchParams, useSearchParamsObject, useStorageState, useStore, useThrottleByFrame, useThrottleBySetTimeout, useThrottleByTimer, useToggle, useUnmountEffect };
247
- //# sourceMappingURL=index-Cmnj4LWo.d.ts.map
247
+ //# sourceMappingURL=index-44MAU7Zb.d.ts.map
@@ -1,4 +1,4 @@
1
- import { CustomContextOptions } from "../index-Cmnj4LWo.js";
1
+ import { CustomContextOptions } from "../index-44MAU7Zb.js";
2
2
  import { AnyObject, Prettify, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
3
3
  import * as react0 from "react";
4
4
  import { StoreApi } from "@zayne-labs/toolkit-core";
@@ -6,21 +6,15 @@ import * as zustand2 from "zustand";
6
6
  import { Mutate, StateCreator as StateCreator$1, StoreApi as StoreApi$1, StoreMutatorIdentifier, UseBoundStore } from "zustand";
7
7
 
8
8
  //#region src/zustand/createZustandContext.d.ts
9
- declare const createZustandContext: <TState extends Record<string, unknown>, TUseBoundStore extends UseBoundStore<StoreApi$1<TState>> = UseBoundStore<StoreApi$1<TState>>, TStore extends StoreApi$1<TState> = StoreApi$1<TState>>(options?: CustomContextOptions<TUseBoundStore, true>) => [ZustandProvider: (props: ({
9
+ declare const createZustandContext: <TState extends Record<string, unknown>, TStore extends StoreApi$1<TState> = StoreApi$1<TState>>(options?: CustomContextOptions<TStore, true>) => [ZustandStoreContextProvider: (props: ({
10
10
  store: TStore;
11
11
  storeCreator?: undefined;
12
- value?: undefined;
13
12
  } | {
14
- storeCreator: () => TUseBoundStore;
13
+ storeCreator: () => TStore;
15
14
  store?: undefined;
16
- value?: undefined;
17
- } | {
18
- value: TUseBoundStore;
19
- store?: undefined;
20
- storeCreator?: undefined;
21
15
  }) & {
22
16
  children: React.ReactNode;
23
- }) => react0.DetailedReactHTMLElement<react0.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, useBoundStore: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
17
+ }) => react0.DetailedReactHTMLElement<react0.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, useZustandStoreContext: <TResult = TState>(selector?: SelectorFn<TState, TResult>) => TResult];
24
18
  //#endregion
25
19
  //#region src/zustand/createZustandStoreWithCombine.d.ts
26
20
  type Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;
@@ -6,27 +6,22 @@ import { create, createStore as createStore$1, useStore as useStore$1 } from "zu
6
6
  //#region src/zustand/createZustandContext.ts
7
7
  const createZustandContext = (options) => {
8
8
  const [Provider, useCustomContext] = createCustomContext(options);
9
- function ZustandProvider(props) {
10
- const { children, store, storeCreator, value } = props;
9
+ function ZustandStoreContextProvider(props) {
10
+ const { children, store, storeCreator } = props;
11
11
  const useZustandStore = useConstant(() => {
12
12
  switch (true) {
13
13
  case Boolean(storeCreator): return storeCreator();
14
- case Boolean(value): return value;
15
- case Boolean(store): {
16
- const useBoundStore$1 = (selector) => useStore$1(store, selector);
17
- Object.assign(useBoundStore$1, store);
18
- return useBoundStore$1;
19
- }
14
+ case Boolean(store): return store;
20
15
  default: throw new Error("No store provided");
21
16
  }
22
17
  });
23
18
  return createElement(Provider, { value: useZustandStore }, children);
24
19
  }
25
- const useBoundStore = (selector) => {
26
- const useZustandStore = useCustomContext();
27
- return useZustandStore(selector);
20
+ const useZustandStoreContext = (selector) => {
21
+ const zustandStore = useCustomContext();
22
+ return useStore$1(zustandStore, selector);
28
23
  };
29
- return [ZustandProvider, useBoundStore];
24
+ return [ZustandStoreContextProvider, useZustandStoreContext];
30
25
  };
31
26
 
32
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options?: CustomContextOptions<TUseBoundStore, true>","props: ZustandProviderProps","useBoundStore","selector: SelectorFn<TState, unknown>","selector?: SelectorFn<TState, TResult>","initialState: TInitialState","storeCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>","stateInitializer: StateCreator<TState> | undefined","createState: StateCreator<TState>","selector?: SelectorFn<TState, unknown>"],"sources":["../../../src/zustand/createZustandContext.ts","../../../src/zustand/createZustandStoreWithCombine.ts","../../../src/zustand/createZustandStoreWithSubscribe.ts"],"sourcesContent":["import type { SelectorFn, UnionDiscriminator } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { type StoreApi, type UseBoundStore, useStore } from \"zustand\";\nimport { type CustomContextOptions, createCustomContext, useConstant } from \"../hooks\";\n\nconst createZustandContext = <\n\tTState extends Record<string, unknown>,\n\tTUseBoundStore extends UseBoundStore<StoreApi<TState>> = UseBoundStore<StoreApi<TState>>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TUseBoundStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandProviderProps = UnionDiscriminator<\n\t\t[{ store: TStore }, { storeCreator: () => TUseBoundStore }, { value: TUseBoundStore }]\n\t> & { children: React.ReactNode };\n\n\tfunction ZustandProvider(props: ZustandProviderProps) {\n\t\tconst { children, store, storeCreator, value } = props;\n\n\t\tconst useZustandStore = useConstant(() => {\n\t\t\tswitch (true) {\n\t\t\t\tcase Boolean(storeCreator): {\n\t\t\t\t\treturn storeCreator();\n\t\t\t\t}\n\t\t\t\tcase Boolean(value): {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t\tcase Boolean(store): {\n\t\t\t\t\tconst useBoundStore = (selector: SelectorFn<TState, unknown>) => useStore(store, selector);\n\t\t\t\t\tObject.assign(useBoundStore, store);\n\t\t\t\t\treturn useBoundStore as TUseBoundStore;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"No store provided\");\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn createElement(Provider, { value: useZustandStore }, children);\n\t}\n\n\tconst useBoundStore = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst useZustandStore = useCustomContext();\n\n\t\treturn useZustandStore(selector as never);\n\t};\n\n\treturn [ZustandProvider, useBoundStore] as [\n\t\tZustandProvider: typeof ZustandProvider,\n\t\tuseBoundStore: typeof useBoundStore,\n\t];\n};\n\nexport { createZustandContext };\n","import type { AnyFunction, AnyObject, Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { type StateCreator, type StoreMutatorIdentifier, create, createStore } from \"zustand\";\n\ntype Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;\n\nexport const combine =\n\t<\n\t\tTInitialState extends AnyObject,\n\t\tTExtraState extends AnyObject,\n\t\tMps extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t\tMcs extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t>(\n\t\tinitialState: TInitialState,\n\t\tstoreCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>\n\t): StateCreator<Write<TInitialState, TExtraState>, Mps, Mcs> =>\n\t// eslint-disable-next-line ts-eslint/no-unsafe-return -- We don't know what the storeCreator will return\n\t(...params) => ({\n\t\t...initialState,\n\t\t...(storeCreator as AnyFunction)(...params),\n\t});\n\nexport const createStoreWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => createStore(combine(...params));\n\nexport const createWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => create(combine(...params));\n","import { useStore } from \"@/hooks\";\nimport { type StoreApi, createStore } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { Mutate, StoreMutatorIdentifier, UseBoundStore } from \"zustand\";\n\ntype Get<T, K, F> = K extends keyof T ? T[K] : F;\n\nexport type StateCreator<\n\tT,\n\tMis extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tMos extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tU = T,\n> = { $$storeMutators?: Mos } & ((\n\tsetState: Get<Mutate<StoreApi<T>, Mis>, \"setState\", never>,\n\tgetState: Get<Mutate<StoreApi<T>, Mis>, \"getState\", never>,\n\tstore: Mutate<StoreApi<T>, Mis>\n) => U);\n\ntype CreateStoreWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): Mutate<StoreApi<T>, Mos>;\n\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => Mutate<StoreApi<T>, Mos>;\n};\n\nexport const createStoreWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ? createStore(stateInitializer) : createStore) as CreateStoreWithSubscribe;\n\ntype CreateWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n};\n\nconst createWithSubscribeImpl = <TState>(createState: StateCreator<TState>) => {\n\tconst store = createStore(createState);\n\n\tconst useBoundStore = (selector?: SelectorFn<TState, unknown>) => useStore(store, selector);\n\n\tObject.assign(useBoundStore, store);\n\n\treturn useBoundStore;\n};\n\nexport const createWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ?\n\t\tcreateWithSubscribeImpl(stateInitializer)\n\t:\tcreateWithSubscribeImpl) as CreateWithSubscribe;\n"],"mappings":";;;;;;AAKA,MAAM,uBAAuB,CAK5BA,YACI;CACJ,MAAM,CAAC,UAAU,iBAAiB,GAAG,oBAAoB,QAAQ;CAMjE,SAAS,gBAAgBC,OAA6B;EACrD,MAAM,EAAE,UAAU,OAAO,cAAc,OAAO,GAAG;EAEjD,MAAM,kBAAkB,YAAY,MAAM;AACzC,WAAQ,MAAR;IACC,KAAK,QAAQ,aAAa,CACzB,QAAO,cAAc;IAEtB,KAAK,QAAQ,MAAM,CAClB,QAAO;IAER,KAAK,QAAQ,MAAM,EAAE;KACpB,MAAMC,kBAAgB,CAACC,aAA0C,WAAS,OAAO,SAAS;AAC1F,YAAO,OAAOD,iBAAe,MAAM;AACnC,YAAOA;IACP;IACD,QACC,OAAM,IAAI,MAAM;GAEjB;EACD,EAAC;AAEF,SAAO,cAAc,UAAU,EAAE,OAAO,gBAAiB,GAAE,SAAS;CACpE;CAED,MAAM,gBAAgB,CAAmBE,aAAoD;EAC5F,MAAM,kBAAkB,kBAAkB;AAE1C,SAAO,gBAAgB,SAAkB;CACzC;AAED,QAAO,CAAC,iBAAiB,aAAc;AAIvC;;;;AChDD,MAAa,UACZ,CAMCC,cACAC,iBAGD,CAAC,GAAG,YAAY;CACf,GAAG;CACH,GAAG,AAAC,aAA6B,GAAG,OAAO;AAC3C;AAEF,MAAa,yBAAyB,CACrC,GAAG,WACC,cAAY,QAAQ,GAAG,OAAO,CAAC;AAEpC,MAAa,oBAAoB,CAChC,GAAG,WACC,OAAO,QAAQ,GAAG,OAAO,CAAC;;;;ACC/B,MAAa,2BAA4B,CAASC,qBACjD,mBAAmB,YAAY,iBAAiB,GAAG;AAWpD,MAAM,0BAA0B,CAASC,gBAAsC;CAC9E,MAAM,QAAQ,YAAY,YAAY;CAEtC,MAAM,gBAAgB,CAACC,aAA2C,SAAS,OAAO,SAAS;AAE3F,QAAO,OAAO,eAAe,MAAM;AAEnC,QAAO;AACP;AAED,MAAa,sBAAuB,CAASF,qBAC5C,mBACC,wBAAwB,iBAAiB,GACxC"}
1
+ {"version":3,"file":"index.js","names":["options?: CustomContextOptions<TStore, true>","props: ZustandStoreContextProviderProps","selector?: SelectorFn<TState, TResult>","initialState: TInitialState","storeCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>","stateInitializer: StateCreator<TState> | undefined","createState: StateCreator<TState>","selector?: SelectorFn<TState, unknown>"],"sources":["../../../src/zustand/createZustandContext.ts","../../../src/zustand/createZustandStoreWithCombine.ts","../../../src/zustand/createZustandStoreWithSubscribe.ts"],"sourcesContent":["import type { SelectorFn, UnionDiscriminator } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport { type StoreApi, useStore } from \"zustand\";\nimport { type CustomContextOptions, createCustomContext, useConstant } from \"../hooks\";\n\nconst createZustandContext = <\n\tTState extends Record<string, unknown>,\n\tTStore extends StoreApi<TState> = StoreApi<TState>,\n>(\n\toptions?: CustomContextOptions<TStore, true>\n) => {\n\tconst [Provider, useCustomContext] = createCustomContext(options);\n\n\ttype ZustandStoreContextProviderProps = UnionDiscriminator<\n\t\t[{ store: TStore }, { storeCreator: () => TStore }]\n\t> & { children: React.ReactNode };\n\n\tfunction ZustandStoreContextProvider(props: ZustandStoreContextProviderProps) {\n\t\tconst { children, store, storeCreator } = props;\n\n\t\tconst useZustandStore = useConstant(() => {\n\t\t\tswitch (true) {\n\t\t\t\tcase Boolean(storeCreator): {\n\t\t\t\t\treturn storeCreator();\n\t\t\t\t}\n\t\t\t\tcase Boolean(store): {\n\t\t\t\t\treturn store;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"No store provided\");\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn createElement(Provider, { value: useZustandStore }, children);\n\t}\n\n\tconst useZustandStoreContext = <TResult = TState>(selector?: SelectorFn<TState, TResult>): TResult => {\n\t\tconst zustandStore = useCustomContext();\n\n\t\treturn useStore(zustandStore, selector as never);\n\t};\n\n\treturn [ZustandStoreContextProvider, useZustandStoreContext] as [\n\t\tZustandStoreContextProvider: typeof ZustandStoreContextProvider,\n\t\tuseZustandStoreContext: typeof useZustandStoreContext,\n\t];\n};\n\nexport { createZustandContext };\n","import type { AnyFunction, AnyObject, Prettify } from \"@zayne-labs/toolkit-type-helpers\";\nimport { create, createStore, type StateCreator, type StoreMutatorIdentifier } from \"zustand\";\n\ntype Write<TInitialState, TExtraState> = Prettify<Omit<TInitialState, keyof TExtraState> & TExtraState>;\n\nexport const combine =\n\t<\n\t\tTInitialState extends AnyObject,\n\t\tTExtraState extends AnyObject,\n\t\tMps extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t\tMcs extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\t>(\n\t\tinitialState: TInitialState,\n\t\tstoreCreator: StateCreator<TInitialState, Mps, Mcs, TExtraState>\n\t): StateCreator<Write<TInitialState, TExtraState>, Mps, Mcs> =>\n\t// eslint-disable-next-line ts-eslint/no-unsafe-return -- We don't know what the storeCreator will return\n\t(...params) => ({\n\t\t...initialState,\n\t\t...(storeCreator as AnyFunction)(...params),\n\t});\n\nexport const createStoreWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => createStore(combine(...params));\n\nexport const createWithCombine = <TInitialState extends AnyObject, TExtraState extends AnyObject>(\n\t...params: Parameters<typeof combine<TInitialState, TExtraState>>\n) => create(combine(...params));\n","import { createStore, type StoreApi } from \"@zayne-labs/toolkit-core\";\nimport type { SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { Mutate, StoreMutatorIdentifier, UseBoundStore } from \"zustand\";\nimport { useStore } from \"@/hooks\";\n\ntype Get<T, K, F> = K extends keyof T ? T[K] : F;\n\nexport type StateCreator<\n\tT,\n\tMis extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tMos extends Array<[StoreMutatorIdentifier, unknown]> = [],\n\tU = T,\n> = { $$storeMutators?: Mos } & ((\n\tsetState: Get<Mutate<StoreApi<T>, Mis>, \"setState\", never>,\n\tgetState: Get<Mutate<StoreApi<T>, Mis>, \"getState\", never>,\n\tstore: Mutate<StoreApi<T>, Mis>\n) => U);\n\ntype CreateStoreWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): Mutate<StoreApi<T>, Mos>;\n\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => Mutate<StoreApi<T>, Mos>;\n};\n\nexport const createStoreWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ? createStore(stateInitializer) : createStore) as CreateStoreWithSubscribe;\n\ntype CreateWithSubscribe = {\n\t<T, Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t): UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n\t<T>(): <Mos extends Array<[StoreMutatorIdentifier, unknown]> = []>(\n\t\tinitializer: StateCreator<T, [], Mos>\n\t) => UseBoundStore<Mutate<StoreApi<T>, Mos>>;\n};\n\nconst createWithSubscribeImpl = <TState>(createState: StateCreator<TState>) => {\n\tconst store = createStore(createState);\n\n\tconst useBoundStore = (selector?: SelectorFn<TState, unknown>) => useStore(store, selector);\n\n\tObject.assign(useBoundStore, store);\n\n\treturn useBoundStore;\n};\n\nexport const createWithSubscribe = (<TState>(stateInitializer: StateCreator<TState> | undefined) =>\n\tstateInitializer ?\n\t\tcreateWithSubscribeImpl(stateInitializer)\n\t:\tcreateWithSubscribeImpl) as CreateWithSubscribe;\n"],"mappings":";;;;;;AAKA,MAAM,uBAAuB,CAI5BA,YACI;CACJ,MAAM,CAAC,UAAU,iBAAiB,GAAG,oBAAoB,QAAQ;CAMjE,SAAS,4BAA4BC,OAAyC;EAC7E,MAAM,EAAE,UAAU,OAAO,cAAc,GAAG;EAE1C,MAAM,kBAAkB,YAAY,MAAM;AACzC,WAAQ,MAAR;IACC,KAAK,QAAQ,aAAa,CACzB,QAAO,cAAc;IAEtB,KAAK,QAAQ,MAAM,CAClB,QAAO;IAER,QACC,OAAM,IAAI,MAAM;GAEjB;EACD,EAAC;AAEF,SAAO,cAAc,UAAU,EAAE,OAAO,gBAAiB,GAAE,SAAS;CACpE;CAED,MAAM,yBAAyB,CAAmBC,aAAoD;EACrG,MAAM,eAAe,kBAAkB;AAEvC,SAAO,WAAS,cAAc,SAAkB;CAChD;AAED,QAAO,CAAC,6BAA6B,sBAAuB;AAI5D;;;;AC1CD,MAAa,UACZ,CAMCC,cACAC,iBAGD,CAAC,GAAG,YAAY;CACf,GAAG;CACH,GAAG,AAAC,aAA6B,GAAG,OAAO;AAC3C;AAEF,MAAa,yBAAyB,CACrC,GAAG,WACC,cAAY,QAAQ,GAAG,OAAO,CAAC;AAEpC,MAAa,oBAAoB,CAChC,GAAG,WACC,OAAO,QAAQ,GAAG,OAAO,CAAC;;;;ACC/B,MAAa,2BAA4B,CAASC,qBACjD,mBAAmB,YAAY,iBAAiB,GAAG;AAWpD,MAAM,0BAA0B,CAASC,gBAAsC;CAC9E,MAAM,QAAQ,YAAY,YAAY;CAEtC,MAAM,gBAAgB,CAACC,aAA2C,SAAS,OAAO,SAAS;AAE3F,QAAO,OAAO,eAAe,MAAM;AAEnC,QAAO;AACP;AAED,MAAa,sBAAuB,CAASF,qBAC5C,mBACC,wBAAwB,iBAAiB,GACxC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zayne-labs/toolkit-react",
3
3
  "type": "module",
4
- "version": "0.9.53",
4
+ "version": "0.9.55",
5
5
  "description": "A collection of utility functions, types and composables used by my other projects. Nothing too fancy but can be useful.",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -47,8 +47,8 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@zayne-labs/toolkit-core": "0.9.53",
51
- "@zayne-labs/toolkit-type-helpers": "0.9.53"
50
+ "@zayne-labs/toolkit-core": "0.9.55",
51
+ "@zayne-labs/toolkit-type-helpers": "0.9.55"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@arethetypeswrong/cli": "^0.18.2",