@legendapp/state 3.0.0-beta.4 → 3.0.0-beta.41
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.
- package/.DS_Store +0 -0
- package/README.md +2 -2
- package/config/enableReactComponents.js +3 -1
- package/config/enableReactComponents.mjs +3 -1
- package/config/enableReactTracking.d.mts +2 -1
- package/config/enableReactTracking.d.ts +2 -1
- package/config/enableReactTracking.js +32 -13
- package/config/enableReactTracking.mjs +32 -13
- package/index.d.mts +46 -8
- package/index.d.ts +46 -8
- package/index.js +267 -75
- package/index.mjs +267 -75
- package/package.json +35 -1
- package/persist-plugins/async-storage.js +17 -9
- package/persist-plugins/async-storage.mjs +17 -9
- package/persist-plugins/expo-sqlite.d.mts +19 -0
- package/persist-plugins/expo-sqlite.d.ts +19 -0
- package/persist-plugins/expo-sqlite.js +72 -0
- package/persist-plugins/expo-sqlite.mjs +69 -0
- package/persist-plugins/indexeddb.js +13 -3
- package/persist-plugins/indexeddb.mjs +13 -3
- package/react-native.d.mts +4 -0
- package/react-native.d.ts +4 -0
- package/react-native.js +53 -0
- package/react-native.mjs +40 -0
- package/react-reactive/Components.d.mts +19 -0
- package/react-reactive/Components.d.ts +19 -0
- package/react-reactive/Components.js +53 -0
- package/react-reactive/Components.mjs +40 -0
- package/react-reactive/enableReactComponents.d.mts +3 -2
- package/react-reactive/enableReactComponents.d.ts +3 -2
- package/react-reactive/enableReactComponents.js +10 -3
- package/react-reactive/enableReactComponents.mjs +10 -3
- package/react-reactive/enableReactNativeComponents.d.mts +3 -20
- package/react-reactive/enableReactNativeComponents.d.ts +3 -20
- package/react-reactive/enableReactNativeComponents.js +8 -3
- package/react-reactive/enableReactNativeComponents.mjs +8 -3
- package/react-reactive/enableReactive.js +10 -3
- package/react-reactive/enableReactive.mjs +10 -3
- package/react-reactive/enableReactive.native.js +8 -3
- package/react-reactive/enableReactive.native.mjs +8 -3
- package/react-reactive/enableReactive.web.js +8 -3
- package/react-reactive/enableReactive.web.mjs +8 -3
- package/react-web.d.mts +7 -0
- package/react-web.d.ts +7 -0
- package/react-web.js +39 -0
- package/react-web.mjs +37 -0
- package/react.d.mts +59 -26
- package/react.d.ts +59 -26
- package/react.js +136 -87
- package/react.mjs +135 -89
- package/sync-plugins/crud.d.mts +24 -9
- package/sync-plugins/crud.d.ts +24 -9
- package/sync-plugins/crud.js +267 -123
- package/sync-plugins/crud.mjs +268 -124
- package/sync-plugins/firebase.d.mts +7 -3
- package/sync-plugins/firebase.d.ts +7 -3
- package/sync-plugins/firebase.js +214 -64
- package/sync-plugins/firebase.mjs +215 -65
- package/sync-plugins/keel.d.mts +12 -13
- package/sync-plugins/keel.d.ts +12 -13
- package/sync-plugins/keel.js +60 -52
- package/sync-plugins/keel.mjs +61 -48
- package/sync-plugins/supabase.d.mts +10 -5
- package/sync-plugins/supabase.d.ts +10 -5
- package/sync-plugins/supabase.js +90 -33
- package/sync-plugins/supabase.mjs +91 -34
- package/sync-plugins/tanstack-query.d.mts +3 -3
- package/sync-plugins/tanstack-query.d.ts +3 -3
- package/sync-plugins/tanstack-query.js +1 -1
- package/sync-plugins/tanstack-query.mjs +1 -1
- package/sync.d.mts +17 -8
- package/sync.d.ts +17 -8
- package/sync.js +448 -307
- package/sync.mjs +446 -307
- package/trace.js +5 -6
- package/trace.mjs +5 -6
- package/types/reactive-native.d.ts +19 -0
- package/types/reactive-web.d.ts +7 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// src/react-reactive/enableReactComponents.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var isEnabled = false;
|
|
3
|
+
function enableReactComponents_(config) {
|
|
4
|
+
if (isEnabled) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
isEnabled = true;
|
|
8
|
+
const bindInfo = {
|
|
9
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
10
|
+
};
|
|
4
11
|
const bindInfoInput = Object.assign(
|
|
5
12
|
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
6
13
|
bindInfo
|
|
@@ -14,4 +21,4 @@ function enableReactComponents(config) {
|
|
|
14
21
|
});
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
export {
|
|
24
|
+
export { enableReactComponents_ };
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
|
|
1
|
+
import { configureReactive } from '@legendapp/state/react';
|
|
3
2
|
|
|
4
|
-
declare function
|
|
5
|
-
declare module '@legendapp/state/react' {
|
|
6
|
-
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
7
|
-
ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
|
|
8
|
-
Button: FCReactive<Button, ButtonProps>;
|
|
9
|
-
FlatList: FCReactive<FlatList, FlatListProps<any>>;
|
|
10
|
-
Image: FCReactive<Image, ImageProps>;
|
|
11
|
-
Pressable: FCReactive<typeof Pressable, PressableProps>;
|
|
12
|
-
ScrollView: FCReactive<ScrollView, ScrollViewProps>;
|
|
13
|
-
SectionList: FCReactive<SectionList, SectionListProps<any>>;
|
|
14
|
-
Switch: FCReactive<Switch, SwitchProps>;
|
|
15
|
-
Text: FCReactive<Text, TextProps>;
|
|
16
|
-
TextInput: FCReactive<TextInput, TextInputProps>;
|
|
17
|
-
TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
|
|
18
|
-
View: FCReactive<View, ViewProps>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
3
|
+
declare function enableReactNativeComponents_(configure: typeof configureReactive): void;
|
|
21
4
|
|
|
22
|
-
export {
|
|
5
|
+
export { enableReactNativeComponents_ };
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
|
|
1
|
+
import { configureReactive } from '@legendapp/state/react';
|
|
3
2
|
|
|
4
|
-
declare function
|
|
5
|
-
declare module '@legendapp/state/react' {
|
|
6
|
-
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
7
|
-
ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
|
|
8
|
-
Button: FCReactive<Button, ButtonProps>;
|
|
9
|
-
FlatList: FCReactive<FlatList, FlatListProps<any>>;
|
|
10
|
-
Image: FCReactive<Image, ImageProps>;
|
|
11
|
-
Pressable: FCReactive<typeof Pressable, PressableProps>;
|
|
12
|
-
ScrollView: FCReactive<ScrollView, ScrollViewProps>;
|
|
13
|
-
SectionList: FCReactive<SectionList, SectionListProps<any>>;
|
|
14
|
-
Switch: FCReactive<Switch, SwitchProps>;
|
|
15
|
-
Text: FCReactive<Text, TextProps>;
|
|
16
|
-
TextInput: FCReactive<TextInput, TextInputProps>;
|
|
17
|
-
TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
|
|
18
|
-
View: FCReactive<View, ViewProps>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
3
|
+
declare function enableReactNativeComponents_(configure: typeof configureReactive): void;
|
|
21
4
|
|
|
22
|
-
export {
|
|
5
|
+
export { enableReactNativeComponents_ };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var react = require('react');
|
|
4
3
|
var react$1 = require('@legendapp/state/react');
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
7
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
-
|
|
8
|
+
var isEnabled = false;
|
|
9
|
+
function enableReactNativeComponents_(configure) {
|
|
10
|
+
if (isEnabled) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
isEnabled = true;
|
|
9
14
|
configure({
|
|
10
15
|
components: {
|
|
11
16
|
ActivityIndicator: reactNative.ActivityIndicator,
|
|
@@ -50,4 +55,4 @@ function enableReactNativeComponents(configure) {
|
|
|
50
55
|
});
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
exports.
|
|
58
|
+
exports.enableReactNativeComponents_ = enableReactNativeComponents_;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
1
|
import { useSelector } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
3
|
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
-
|
|
6
|
+
var isEnabled = false;
|
|
7
|
+
function enableReactNativeComponents_(configure) {
|
|
8
|
+
if (isEnabled) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
isEnabled = true;
|
|
7
12
|
configure({
|
|
8
13
|
components: {
|
|
9
14
|
ActivityIndicator,
|
|
@@ -48,4 +53,4 @@ function enableReactNativeComponents(configure) {
|
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
export {
|
|
56
|
+
export { enableReactNativeComponents_ };
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/react-reactive/enableReactComponents.ts
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var isEnabled = false;
|
|
5
|
+
function enableReactComponents_(config) {
|
|
6
|
+
if (isEnabled) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
isEnabled = true;
|
|
10
|
+
const bindInfo = {
|
|
11
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
12
|
+
};
|
|
6
13
|
const bindInfoInput = Object.assign(
|
|
7
14
|
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
8
15
|
bindInfo
|
|
@@ -18,7 +25,7 @@ function enableReactComponents(config) {
|
|
|
18
25
|
|
|
19
26
|
// src/react-reactive/enableReactive.ts
|
|
20
27
|
function enableReactive(config) {
|
|
21
|
-
|
|
28
|
+
enableReactComponents_(config);
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
exports.enableReactive = enableReactive;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// src/react-reactive/enableReactComponents.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var isEnabled = false;
|
|
3
|
+
function enableReactComponents_(config) {
|
|
4
|
+
if (isEnabled) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
isEnabled = true;
|
|
8
|
+
const bindInfo = {
|
|
9
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
10
|
+
};
|
|
4
11
|
const bindInfoInput = Object.assign(
|
|
5
12
|
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
6
13
|
bindInfo
|
|
@@ -16,7 +23,7 @@ function enableReactComponents(config) {
|
|
|
16
23
|
|
|
17
24
|
// src/react-reactive/enableReactive.ts
|
|
18
25
|
function enableReactive(config) {
|
|
19
|
-
|
|
26
|
+
enableReactComponents_(config);
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
export { enableReactive };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var react = require('react');
|
|
4
3
|
var react$1 = require('@legendapp/state/react');
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
7
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
-
|
|
8
|
+
var isEnabled = false;
|
|
9
|
+
function enableReactNativeComponents_(configure) {
|
|
10
|
+
if (isEnabled) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
isEnabled = true;
|
|
9
14
|
configure({
|
|
10
15
|
components: {
|
|
11
16
|
ActivityIndicator: reactNative.ActivityIndicator,
|
|
@@ -52,7 +57,7 @@ function enableReactNativeComponents(configure) {
|
|
|
52
57
|
|
|
53
58
|
// src/react-reactive/enableReactive.native.ts
|
|
54
59
|
function enableReactive(configure) {
|
|
55
|
-
|
|
60
|
+
enableReactNativeComponents_(configure);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
exports.enableReactive = enableReactive;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
1
|
import { useSelector } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
3
|
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
-
|
|
6
|
+
var isEnabled = false;
|
|
7
|
+
function enableReactNativeComponents_(configure) {
|
|
8
|
+
if (isEnabled) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
isEnabled = true;
|
|
7
12
|
configure({
|
|
8
13
|
components: {
|
|
9
14
|
ActivityIndicator,
|
|
@@ -50,7 +55,7 @@ function enableReactNativeComponents(configure) {
|
|
|
50
55
|
|
|
51
56
|
// src/react-reactive/enableReactive.native.ts
|
|
52
57
|
function enableReactive(configure) {
|
|
53
|
-
|
|
58
|
+
enableReactNativeComponents_(configure);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
export { enableReactive };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var react = require('react');
|
|
4
3
|
var react$1 = require('@legendapp/state/react');
|
|
4
|
+
var react = require('react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
7
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
-
|
|
8
|
+
var isEnabled = false;
|
|
9
|
+
function enableReactNativeComponents_(configure) {
|
|
10
|
+
if (isEnabled) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
isEnabled = true;
|
|
9
14
|
configure({
|
|
10
15
|
components: {
|
|
11
16
|
ActivityIndicator: reactNative.ActivityIndicator,
|
|
@@ -52,7 +57,7 @@ function enableReactNativeComponents(configure) {
|
|
|
52
57
|
|
|
53
58
|
// src/react-reactive/enableReactive.web.ts
|
|
54
59
|
function enableReactive(configure) {
|
|
55
|
-
|
|
60
|
+
enableReactNativeComponents_(configure);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
exports.enableReactive = enableReactive;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
1
|
import { useSelector } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
3
|
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
-
|
|
6
|
+
var isEnabled = false;
|
|
7
|
+
function enableReactNativeComponents_(configure) {
|
|
8
|
+
if (isEnabled) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
isEnabled = true;
|
|
7
12
|
configure({
|
|
8
13
|
components: {
|
|
9
14
|
ActivityIndicator,
|
|
@@ -50,7 +55,7 @@ function enableReactNativeComponents(configure) {
|
|
|
50
55
|
|
|
51
56
|
// src/react-reactive/enableReactive.web.ts
|
|
52
57
|
function enableReactive(configure) {
|
|
53
|
-
|
|
58
|
+
enableReactNativeComponents_(configure);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
export { enableReactive };
|
package/react-web.d.mts
ADDED
package/react-web.d.ts
ADDED
package/react-web.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@legendapp/state');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
// src/react-web/$React.tsx
|
|
8
|
+
var bindInfoOneWay = {
|
|
9
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
10
|
+
};
|
|
11
|
+
var bindInfoInput = Object.assign(
|
|
12
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
13
|
+
bindInfoOneWay
|
|
14
|
+
);
|
|
15
|
+
var binders = /* @__PURE__ */ new Map([
|
|
16
|
+
["input", bindInfoInput],
|
|
17
|
+
["textarea", bindInfoOneWay],
|
|
18
|
+
["select", bindInfoOneWay]
|
|
19
|
+
]);
|
|
20
|
+
var $React = new Proxy(
|
|
21
|
+
{},
|
|
22
|
+
{
|
|
23
|
+
get(target, p) {
|
|
24
|
+
if (!target[p]) {
|
|
25
|
+
const render = react.forwardRef((props, ref) => {
|
|
26
|
+
const propsOut = { ...props };
|
|
27
|
+
if (ref && (state.isFunction(ref) || !state.isEmpty(ref))) {
|
|
28
|
+
propsOut.ref = ref;
|
|
29
|
+
}
|
|
30
|
+
return react.createElement(p, propsOut);
|
|
31
|
+
});
|
|
32
|
+
target[p] = react$1.reactive(render, [], binders.get(p));
|
|
33
|
+
}
|
|
34
|
+
return target[p];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
exports.$React = $React;
|
package/react-web.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isFunction, isEmpty } from '@legendapp/state';
|
|
2
|
+
import { reactive } from '@legendapp/state/react';
|
|
3
|
+
import { forwardRef, createElement } from 'react';
|
|
4
|
+
|
|
5
|
+
// src/react-web/$React.tsx
|
|
6
|
+
var bindInfoOneWay = {
|
|
7
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
8
|
+
};
|
|
9
|
+
var bindInfoInput = Object.assign(
|
|
10
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
11
|
+
bindInfoOneWay
|
|
12
|
+
);
|
|
13
|
+
var binders = /* @__PURE__ */ new Map([
|
|
14
|
+
["input", bindInfoInput],
|
|
15
|
+
["textarea", bindInfoOneWay],
|
|
16
|
+
["select", bindInfoOneWay]
|
|
17
|
+
]);
|
|
18
|
+
var $React = new Proxy(
|
|
19
|
+
{},
|
|
20
|
+
{
|
|
21
|
+
get(target, p) {
|
|
22
|
+
if (!target[p]) {
|
|
23
|
+
const render = forwardRef((props, ref) => {
|
|
24
|
+
const propsOut = { ...props };
|
|
25
|
+
if (ref && (isFunction(ref) || !isEmpty(ref))) {
|
|
26
|
+
propsOut.ref = ref;
|
|
27
|
+
}
|
|
28
|
+
return createElement(p, propsOut);
|
|
29
|
+
});
|
|
30
|
+
target[p] = reactive(render, [], binders.get(p));
|
|
31
|
+
}
|
|
32
|
+
return target[p];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export { $React };
|
package/react.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { ReactNode, ReactElement, FC, LegacyRef, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction, ComponentClass } from 'react';
|
|
3
|
-
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactNode, ReactElement, FC, NamedExoticComponent, LegacyRef, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction, ComponentClass } from 'react';
|
|
3
|
+
import { ObservableParam, Observable, ObservableBoolean, Selector, GetOptions, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
|
|
4
4
|
|
|
5
5
|
declare function Computed({ children }: {
|
|
6
6
|
children: ObservableParam | (() => ReactNode);
|
|
@@ -22,11 +22,14 @@ declare function For<T, TProps>({ each, optimized: isOptimized, item, itemProps,
|
|
|
22
22
|
declare function usePauseProvider(): {
|
|
23
23
|
PauseProvider: ({ children }: {
|
|
24
24
|
children: ReactNode;
|
|
25
|
-
}) =>
|
|
25
|
+
}) => React.FunctionComponentElement<React.ProviderProps<ObservableBoolean>>;
|
|
26
26
|
isPaused$: ObservableBoolean;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
declare const Memo:
|
|
29
|
+
declare const Memo: NamedExoticComponent<{
|
|
30
|
+
children: any;
|
|
31
|
+
scoped?: boolean;
|
|
32
|
+
}>;
|
|
30
33
|
|
|
31
34
|
interface IReactive {
|
|
32
35
|
}
|
|
@@ -43,7 +46,9 @@ interface PropsIfReady<T> {
|
|
|
43
46
|
interface PropsBase<T> {
|
|
44
47
|
else?: ReactNode | (() => ReactNode);
|
|
45
48
|
$value?: Observable<T>;
|
|
46
|
-
wrap?: FC
|
|
49
|
+
wrap?: FC<{
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
}>;
|
|
47
52
|
children: ReactNode | ((value?: T) => ReactNode);
|
|
48
53
|
}
|
|
49
54
|
type Props<T> = PropsBase<T> & (PropsIf<T> | PropsIfReady<T>);
|
|
@@ -54,11 +59,11 @@ declare function Switch<T extends object>({ value, children, }: {
|
|
|
54
59
|
children: Partial<Record<keyof T | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
55
60
|
}): ReactElement | null;
|
|
56
61
|
declare function Switch<T extends string | number | symbol>({ value, children, }: {
|
|
57
|
-
value?: Selector<T>;
|
|
62
|
+
value?: Selector<T | undefined | null>;
|
|
58
63
|
children: Partial<Record<T | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
59
64
|
}): ReactElement | null;
|
|
60
65
|
declare function Switch<T extends boolean>({ value, children, }: {
|
|
61
|
-
value?: Selector<T>;
|
|
66
|
+
value?: Selector<T | undefined | null>;
|
|
62
67
|
children: Partial<Record<'false' | 'true' | 'null' | 'undefined' | 'default', () => ReactNode>>;
|
|
63
68
|
}): ReactElement | null;
|
|
64
69
|
declare function Switch<T>({ value, children, }: {
|
|
@@ -71,41 +76,59 @@ type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
|
71
76
|
} & {
|
|
72
77
|
children?: Selector<ReactNode>;
|
|
73
78
|
};
|
|
74
|
-
interface BindKey<P> {
|
|
75
|
-
handler?:
|
|
76
|
-
getValue?: (e: any) => any;
|
|
79
|
+
interface BindKey<P, K extends keyof P = keyof P> {
|
|
80
|
+
handler?: K;
|
|
81
|
+
getValue?: P[K] extends infer T ? T extends (...args: any) => any ? (params: Parameters<T>[0]) => any : (e: any) => any : (e: any) => any;
|
|
77
82
|
defaultValue?: any;
|
|
78
83
|
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
79
84
|
}
|
|
80
|
-
type BindKeys<P = any> = Partial<Record<
|
|
85
|
+
type BindKeys<P = any, K extends keyof P = keyof P> = Partial<Record<K, BindKey<P>>>;
|
|
81
86
|
type FCReactiveObject<T> = {
|
|
82
87
|
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
83
88
|
};
|
|
84
89
|
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
85
90
|
ref?: LegacyRef<P> | undefined;
|
|
86
91
|
}>;
|
|
87
|
-
interface UseSelectorOptions {
|
|
92
|
+
interface UseSelectorOptions extends GetOptions {
|
|
88
93
|
suspense?: boolean;
|
|
89
94
|
skipCheck?: boolean;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
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>> & {
|
|
96
107
|
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
97
108
|
};
|
|
98
109
|
type ObjectShapeWith$<T> = {
|
|
99
110
|
[K in keyof T]: T[K] extends FC<infer P> ? FC<ShapeWith$<P>> : T[K];
|
|
100
111
|
};
|
|
101
|
-
type
|
|
112
|
+
type ReactifyProps<T, K extends keyof T> = T & {
|
|
113
|
+
[P in K as `$${string & P}`]?: Selector<T[P]>;
|
|
114
|
+
};
|
|
102
115
|
declare const hasSymbol: false | ((key: string) => symbol);
|
|
103
116
|
declare function observer<P extends FC<any>>(component: P): P;
|
|
104
|
-
declare function reactive<T extends
|
|
105
|
-
declare function reactive<T extends FC<
|
|
106
|
-
declare function
|
|
107
|
-
declare function
|
|
108
|
-
declare function
|
|
117
|
+
declare function reactive<T extends object>(component: React.ComponentClass<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
|
|
118
|
+
declare function reactive<T extends object>(component: React.FC<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
|
|
119
|
+
declare function reactive<T extends object>(component: React.ForwardRefExoticComponent<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
|
|
120
|
+
declare function reactive<T extends object, K extends keyof T>(component: React.FC<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.FC<ReactifyProps<T, K>>;
|
|
121
|
+
declare function reactive<T extends object, K extends keyof T>(component: React.ForwardRefExoticComponent<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.ForwardRefExoticComponent<ReactifyProps<T, K>>;
|
|
122
|
+
declare function reactive<T extends object>(component: React.ComponentClass<T>): React.ComponentClass<ShapeWith$<T>>;
|
|
123
|
+
declare function reactive<T extends object>(component: React.FC<T>): React.FC<ShapeWith$<T>>;
|
|
124
|
+
declare function reactive<T extends object>(component: React.ForwardRefExoticComponent<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
|
|
125
|
+
declare function reactiveObserver<T extends object>(component: React.FC<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.FC<ShapeWith$<T>>;
|
|
126
|
+
declare function reactiveObserver<T extends object>(component: React.ForwardRefExoticComponent<T>, keys: undefined | null, bindKeys?: BindKeys<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
|
|
127
|
+
declare function reactiveObserver<T extends object, K extends keyof T>(component: React.FC<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.FC<ReactifyProps<T, K>>;
|
|
128
|
+
declare function reactiveObserver<T extends object, K extends keyof T>(component: React.ForwardRefExoticComponent<T>, keys: K[] | (keyof T)[], bindKeys?: BindKeys<T, K>): React.ForwardRefExoticComponent<ReactifyProps<T, K>>;
|
|
129
|
+
declare function reactiveObserver<T extends object>(component: React.FC<T>): React.FC<ShapeWith$<T>>;
|
|
130
|
+
declare function reactiveObserver<T extends object>(component: React.ForwardRefExoticComponent<T>): React.ForwardRefExoticComponent<ShapeWith$<T>>;
|
|
131
|
+
declare function reactiveComponents<P extends Record<string, any>>(components: P): ObjectShapeWith$<P>;
|
|
109
132
|
|
|
110
133
|
declare function useComputed<T>(get: () => T | Promise<T>): Observable<T>;
|
|
111
134
|
declare function useComputed<T>(get: () => T | Promise<T>, deps: any[]): Observable<T>;
|
|
@@ -140,23 +163,33 @@ declare function useObservableReducer<R extends Reducer<any, any>>(reducer: R, i
|
|
|
140
163
|
interface UseObserveOptions extends ObserveOptions {
|
|
141
164
|
deps?: any[];
|
|
142
165
|
}
|
|
166
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void): () => void;
|
|
167
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, deps?: any[]): () => void;
|
|
143
168
|
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): () => void;
|
|
169
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions, deps?: any[]): () => void;
|
|
144
170
|
declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): () => void;
|
|
171
|
+
declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions, deps?: any[]): () => void;
|
|
145
172
|
|
|
173
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void): void;
|
|
174
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, deps?: any[]): void;
|
|
146
175
|
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): void;
|
|
176
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions, deps?: any[]): void;
|
|
147
177
|
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): void;
|
|
178
|
+
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions, deps?: any[]): void;
|
|
148
179
|
|
|
149
180
|
declare function useSelector<T>(selector: Selector<T>, options?: UseSelectorOptions): T;
|
|
150
181
|
|
|
151
182
|
declare function useUnmount(fn: () => void): void;
|
|
152
183
|
declare const useUnmountOnce: typeof useUnmount;
|
|
153
184
|
|
|
154
|
-
declare function useWhen<T>(predicate: Selector<T
|
|
155
|
-
declare function
|
|
185
|
+
declare function useWhen<T>(predicate: Selector<T>): Promise<T>;
|
|
186
|
+
declare function useWhen<T, T2>(predicate: Selector<T>, effect: (value: T) => T2): Promise<T2>;
|
|
187
|
+
declare function useWhenReady<T>(predicate: Selector<T>): Promise<T>;
|
|
188
|
+
declare function useWhenReady<T, T2>(predicate: Selector<T>, effect: (value: T) => T2 | (() => T2)): Promise<T2>;
|
|
156
189
|
|
|
157
190
|
declare function configureReactive({ components, binders, }: {
|
|
158
191
|
components?: Record<string, FC | ComponentClass<any>>;
|
|
159
192
|
binders?: Record<string, BindKeys>;
|
|
160
193
|
}): void;
|
|
161
194
|
|
|
162
|
-
export { type BindKey, type BindKeys, Computed, type
|
|
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 };
|