@legendapp/state 3.0.0-beta.39 → 3.0.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/react.d.mts +13 -8
  3. package/react.d.ts +13 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/state",
3
- "version": "3.0.0-beta.39",
3
+ "version": "3.0.0-beta.40",
4
4
  "description": "legend-state",
5
5
  "sideEffects": false,
6
6
  "private": false,
package/react.d.mts CHANGED
@@ -94,19 +94,24 @@ interface UseSelectorOptions extends GetOptions {
94
94
  skipCheck?: boolean;
95
95
  }
96
96
 
97
- type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
98
- [K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
99
- };
100
- type ShapeWith$<T> = Partial<T> & {
97
+ type WithSelectorChildren<T> = T extends any ? T extends {
98
+ children?: infer C;
99
+ } ? Omit<T, 'children'> & {
100
+ children?: C | Selector<C>;
101
+ } : T extends {
102
+ children: infer C;
103
+ } ? Omit<T, 'children'> & {
104
+ children: C | Selector<C>;
105
+ } : T : never;
106
+ type ShapeWith$<T> = WithSelectorChildren<Partial<T>> & {
101
107
  [K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
102
108
  };
103
109
  type ObjectShapeWith$<T> = {
104
110
  [K in keyof T]: T[K] extends FC<infer P> ? FC<ShapeWith$<P>> : T[K];
105
111
  };
106
- type ExtractFCPropsType<T> = T extends FC<infer P> ? P : never;
107
- type ReactifyProps<T, K extends keyof T> = Omit<T, K> & {
112
+ type ReactifyProps<T, K extends keyof T> = WithSelectorChildren<Omit<T, K> & {
108
113
  [P in K]: Selector<T[P]>;
109
- };
114
+ }>;
110
115
  declare const hasSymbol: false | ((key: string) => symbol);
111
116
  declare function observer<P extends FC<any>>(component: P): P;
112
117
  declare function reactive<T extends object>(component: React.ComponentClass<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
@@ -187,4 +192,4 @@ declare function configureReactive({ components, binders, }: {
187
192
  binders?: Record<string, BindKeys>;
188
193
  }): void;
189
194
 
190
- export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, type ReactifyProps, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useSelector as use$, useComputed, useEffectOnce, useIsMounted, useObservable as useLocalObservable, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useSelector as useValue, useWhen, useWhenReady };
195
+ export { type BindKey, type BindKeys, Computed, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, type ReactifyProps, Reactive, type ShapeWith$, type ShapeWithNew$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useSelector as use$, useComputed, useEffectOnce, useIsMounted, useObservable as useLocalObservable, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useSelector as useValue, useWhen, useWhenReady };
package/react.d.ts CHANGED
@@ -94,19 +94,24 @@ interface UseSelectorOptions extends GetOptions {
94
94
  skipCheck?: boolean;
95
95
  }
96
96
 
97
- type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
98
- [K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
99
- };
100
- type ShapeWith$<T> = Partial<T> & {
97
+ type WithSelectorChildren<T> = T extends any ? T extends {
98
+ children?: infer C;
99
+ } ? Omit<T, 'children'> & {
100
+ children?: C | Selector<C>;
101
+ } : T extends {
102
+ children: infer C;
103
+ } ? Omit<T, 'children'> & {
104
+ children: C | Selector<C>;
105
+ } : T : never;
106
+ type ShapeWith$<T> = WithSelectorChildren<Partial<T>> & {
101
107
  [K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
102
108
  };
103
109
  type ObjectShapeWith$<T> = {
104
110
  [K in keyof T]: T[K] extends FC<infer P> ? FC<ShapeWith$<P>> : T[K];
105
111
  };
106
- type ExtractFCPropsType<T> = T extends FC<infer P> ? P : never;
107
- type ReactifyProps<T, K extends keyof T> = Omit<T, K> & {
112
+ type ReactifyProps<T, K extends keyof T> = WithSelectorChildren<Omit<T, K> & {
108
113
  [P in K]: Selector<T[P]>;
109
- };
114
+ }>;
110
115
  declare const hasSymbol: false | ((key: string) => symbol);
111
116
  declare function observer<P extends FC<any>>(component: P): P;
112
117
  declare function reactive<T extends object>(component: React.ComponentClass<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
@@ -187,4 +192,4 @@ declare function configureReactive({ components, binders, }: {
187
192
  binders?: Record<string, BindKeys>;
188
193
  }): void;
189
194
 
190
- export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, type ReactifyProps, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useSelector as use$, useComputed, useEffectOnce, useIsMounted, useObservable as useLocalObservable, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useSelector as useValue, useWhen, useWhenReady };
195
+ export { type BindKey, type BindKeys, Computed, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, type ReactifyProps, Reactive, type ShapeWith$, type ShapeWithNew$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useSelector as use$, useComputed, useEffectOnce, useIsMounted, useObservable as useLocalObservable, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useSelector as useValue, useWhen, useWhenReady };