@legendapp/state 3.0.0-alpha.8 → 3.0.0-beta.0
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/config/configureLegendState.d.mts +13 -0
- package/config/configureLegendState.d.ts +13 -0
- package/config/configureLegendState.js +45 -0
- package/config/configureLegendState.mjs +43 -0
- package/config/enable$GetSet.js +2 -1
- package/config/enable$GetSet.mjs +2 -1
- package/config/enableReactTracking.js +2 -1
- package/config/enableReactTracking.mjs +2 -1
- package/config/enableReactUse.js +2 -1
- package/config/enableReactUse.mjs +2 -1
- package/config/enable_PeekAssign.js +2 -1
- package/config/enable_PeekAssign.mjs +2 -1
- package/helpers/trackHistory.js +2 -2
- package/helpers/trackHistory.mjs +2 -2
- package/index.d.mts +104 -80
- package/index.d.ts +104 -80
- package/index.js +328 -318
- package/index.mjs +325 -316
- package/package.json +36 -1
- package/persist-plugins/async-storage.d.mts +6 -3
- package/persist-plugins/async-storage.d.ts +6 -3
- package/persist-plugins/async-storage.js +8 -4
- package/persist-plugins/async-storage.mjs +8 -5
- package/persist-plugins/indexeddb.d.mts +6 -4
- package/persist-plugins/indexeddb.d.ts +6 -4
- package/persist-plugins/indexeddb.js +35 -15
- package/persist-plugins/indexeddb.mjs +35 -16
- package/persist-plugins/mmkv.d.mts +5 -1
- package/persist-plugins/mmkv.d.ts +5 -1
- package/persist-plugins/mmkv.js +10 -5
- package/persist-plugins/mmkv.mjs +10 -6
- package/react-reactive/enableReactComponents.d.mts +9 -0
- package/react-reactive/enableReactComponents.d.ts +9 -0
- package/react-reactive/enableReactComponents.js +19 -0
- package/react-reactive/enableReactComponents.mjs +17 -0
- package/react-reactive/enableReactNativeComponents.d.mts +22 -0
- package/react-reactive/enableReactNativeComponents.d.ts +22 -0
- package/react-reactive/enableReactNativeComponents.js +53 -0
- package/react-reactive/enableReactNativeComponents.mjs +51 -0
- package/react-reactive/enableReactive.d.mts +5 -0
- package/react-reactive/enableReactive.d.ts +5 -0
- package/react-reactive/enableReactive.js +24 -0
- package/react-reactive/enableReactive.mjs +22 -0
- package/react-reactive/enableReactive.native.d.mts +5 -0
- package/react-reactive/enableReactive.native.d.ts +5 -0
- package/react-reactive/enableReactive.native.js +58 -0
- package/react-reactive/enableReactive.native.mjs +56 -0
- package/react-reactive/enableReactive.web.d.mts +5 -0
- package/react-reactive/enableReactive.web.d.ts +5 -0
- package/react-reactive/enableReactive.web.js +58 -0
- package/react-reactive/enableReactive.web.mjs +56 -0
- package/react.d.mts +39 -34
- package/react.d.ts +39 -34
- package/react.js +39 -17
- package/react.mjs +39 -17
- package/sync-plugins/crud.d.mts +21 -24
- package/sync-plugins/crud.d.ts +21 -24
- package/sync-plugins/crud.js +241 -140
- package/sync-plugins/crud.mjs +243 -142
- package/sync-plugins/fetch.js +12 -8
- package/sync-plugins/fetch.mjs +13 -9
- package/sync-plugins/firebase.d.mts +27 -0
- package/sync-plugins/firebase.d.ts +27 -0
- package/sync-plugins/firebase.js +373 -0
- package/sync-plugins/firebase.mjs +368 -0
- package/sync-plugins/keel.d.mts +43 -26
- package/sync-plugins/keel.d.ts +43 -26
- package/sync-plugins/keel.js +145 -100
- package/sync-plugins/keel.mjs +147 -100
- package/sync-plugins/supabase.d.mts +19 -9
- package/sync-plugins/supabase.d.ts +19 -9
- package/sync-plugins/supabase.js +52 -22
- package/sync-plugins/supabase.mjs +53 -23
- package/sync-plugins/tanstack-query.d.mts +2 -2
- package/sync-plugins/tanstack-query.d.ts +2 -2
- package/sync-plugins/tanstack-query.js +22 -5
- package/sync-plugins/tanstack-query.mjs +22 -5
- package/sync-plugins/tanstack-react-query.d.mts +1 -1
- package/sync-plugins/tanstack-react-query.d.ts +1 -1
- package/sync-plugins/tanstack-react-query.js +8 -1
- package/sync-plugins/tanstack-react-query.mjs +8 -1
- package/sync.d.mts +74 -200
- package/sync.d.ts +74 -200
- package/sync.js +492 -293
- package/sync.mjs +498 -299
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
10
|
+
components: {
|
|
11
|
+
ActivityIndicator: reactNative.ActivityIndicator,
|
|
12
|
+
Button: reactNative.Button,
|
|
13
|
+
FlatList: reactNative.FlatList,
|
|
14
|
+
Image: reactNative.Image,
|
|
15
|
+
Pressable: reactNative.Pressable,
|
|
16
|
+
ScrollView: reactNative.ScrollView,
|
|
17
|
+
SectionList: reactNative.SectionList,
|
|
18
|
+
Switch: reactNative.Switch,
|
|
19
|
+
Text: reactNative.Text,
|
|
20
|
+
TextInput: reactNative.TextInput,
|
|
21
|
+
TouchableWithoutFeedback: reactNative.TouchableWithoutFeedback,
|
|
22
|
+
View: reactNative.View
|
|
23
|
+
},
|
|
24
|
+
binders: {
|
|
25
|
+
TextInput: {
|
|
26
|
+
value: {
|
|
27
|
+
handler: "onChange",
|
|
28
|
+
getValue: (e) => e.nativeEvent.text,
|
|
29
|
+
defaultValue: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
Switch: {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onValueChange",
|
|
35
|
+
getValue: (e) => e,
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
FlatList: {
|
|
40
|
+
data: {
|
|
41
|
+
selector: (propsOut, p) => {
|
|
42
|
+
const state = react.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.enableReactNativeComponents = enableReactNativeComponents;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { enableReactNativeComponents };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/react-reactive/enableReactComponents.ts
|
|
4
|
+
function enableReactComponents(config) {
|
|
5
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
6
|
+
const bindInfoInput = Object.assign(
|
|
7
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
8
|
+
bindInfo
|
|
9
|
+
);
|
|
10
|
+
config({
|
|
11
|
+
binders: {
|
|
12
|
+
input: bindInfoInput,
|
|
13
|
+
textarea: bindInfo,
|
|
14
|
+
select: bindInfo
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/react-reactive/enableReactive.ts
|
|
20
|
+
function enableReactive(config) {
|
|
21
|
+
enableReactComponents(config);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/react-reactive/enableReactComponents.ts
|
|
2
|
+
function enableReactComponents(config) {
|
|
3
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
4
|
+
const bindInfoInput = Object.assign(
|
|
5
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
6
|
+
bindInfo
|
|
7
|
+
);
|
|
8
|
+
config({
|
|
9
|
+
binders: {
|
|
10
|
+
input: bindInfoInput,
|
|
11
|
+
textarea: bindInfo,
|
|
12
|
+
select: bindInfo
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/react-reactive/enableReactive.ts
|
|
18
|
+
function enableReactive(config) {
|
|
19
|
+
enableReactComponents(config);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { enableReactive };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
10
|
+
components: {
|
|
11
|
+
ActivityIndicator: reactNative.ActivityIndicator,
|
|
12
|
+
Button: reactNative.Button,
|
|
13
|
+
FlatList: reactNative.FlatList,
|
|
14
|
+
Image: reactNative.Image,
|
|
15
|
+
Pressable: reactNative.Pressable,
|
|
16
|
+
ScrollView: reactNative.ScrollView,
|
|
17
|
+
SectionList: reactNative.SectionList,
|
|
18
|
+
Switch: reactNative.Switch,
|
|
19
|
+
Text: reactNative.Text,
|
|
20
|
+
TextInput: reactNative.TextInput,
|
|
21
|
+
TouchableWithoutFeedback: reactNative.TouchableWithoutFeedback,
|
|
22
|
+
View: reactNative.View
|
|
23
|
+
},
|
|
24
|
+
binders: {
|
|
25
|
+
TextInput: {
|
|
26
|
+
value: {
|
|
27
|
+
handler: "onChange",
|
|
28
|
+
getValue: (e) => e.nativeEvent.text,
|
|
29
|
+
defaultValue: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
Switch: {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onValueChange",
|
|
35
|
+
getValue: (e) => e,
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
FlatList: {
|
|
40
|
+
data: {
|
|
41
|
+
selector: (propsOut, p) => {
|
|
42
|
+
const state = react.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/react-reactive/enableReactive.native.ts
|
|
54
|
+
function enableReactive(configure) {
|
|
55
|
+
enableReactNativeComponents(configure);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/react-reactive/enableReactive.native.ts
|
|
52
|
+
function enableReactive(configure) {
|
|
53
|
+
enableReactNativeComponents(configure);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { enableReactive };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
10
|
+
components: {
|
|
11
|
+
ActivityIndicator: reactNative.ActivityIndicator,
|
|
12
|
+
Button: reactNative.Button,
|
|
13
|
+
FlatList: reactNative.FlatList,
|
|
14
|
+
Image: reactNative.Image,
|
|
15
|
+
Pressable: reactNative.Pressable,
|
|
16
|
+
ScrollView: reactNative.ScrollView,
|
|
17
|
+
SectionList: reactNative.SectionList,
|
|
18
|
+
Switch: reactNative.Switch,
|
|
19
|
+
Text: reactNative.Text,
|
|
20
|
+
TextInput: reactNative.TextInput,
|
|
21
|
+
TouchableWithoutFeedback: reactNative.TouchableWithoutFeedback,
|
|
22
|
+
View: reactNative.View
|
|
23
|
+
},
|
|
24
|
+
binders: {
|
|
25
|
+
TextInput: {
|
|
26
|
+
value: {
|
|
27
|
+
handler: "onChange",
|
|
28
|
+
getValue: (e) => e.nativeEvent.text,
|
|
29
|
+
defaultValue: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
Switch: {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onValueChange",
|
|
35
|
+
getValue: (e) => e,
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
FlatList: {
|
|
40
|
+
data: {
|
|
41
|
+
selector: (propsOut, p) => {
|
|
42
|
+
const state = react.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/react-reactive/enableReactive.web.ts
|
|
54
|
+
function enableReactive(configure) {
|
|
55
|
+
enableReactNativeComponents(configure);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/react-reactive/enableReactive.web.ts
|
|
52
|
+
function enableReactive(configure) {
|
|
53
|
+
enableReactNativeComponents(configure);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { enableReactive };
|
package/react.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, ReactElement, FC, LegacyRef,
|
|
3
|
-
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction,
|
|
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';
|
|
4
4
|
|
|
5
5
|
declare function Computed({ children }: {
|
|
6
6
|
children: ObservableParam | (() => ReactNode);
|
|
@@ -28,36 +28,9 @@ declare function usePauseProvider(): {
|
|
|
28
28
|
|
|
29
29
|
declare const Memo: react.MemoExoticComponent<typeof Computed>;
|
|
30
30
|
|
|
31
|
-
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
32
|
-
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
children?: Selector<ReactNode>;
|
|
35
|
-
};
|
|
36
|
-
interface BindKey<P> {
|
|
37
|
-
handler?: keyof P;
|
|
38
|
-
getValue?: (e: any) => any;
|
|
39
|
-
defaultValue?: any;
|
|
40
|
-
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
41
|
-
}
|
|
42
|
-
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
43
|
-
type FCReactiveObject<T> = {
|
|
44
|
-
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
45
|
-
};
|
|
46
|
-
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
47
|
-
ref?: LegacyRef<P> | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
interface UseSelectorOptions {
|
|
50
|
-
suspense?: boolean;
|
|
51
|
-
skipCheck?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
31
|
interface IReactive {
|
|
55
32
|
}
|
|
56
33
|
declare const Reactive: IReactive;
|
|
57
|
-
declare function configureReactive({ components, binders, }: {
|
|
58
|
-
components?: Record<string, FC | ComponentClass<any>>;
|
|
59
|
-
binders?: Record<string, BindKeys>;
|
|
60
|
-
}): void;
|
|
61
34
|
|
|
62
35
|
interface PropsIf<T> {
|
|
63
36
|
if: Selector<T>;
|
|
@@ -69,6 +42,7 @@ interface PropsIfReady<T> {
|
|
|
69
42
|
}
|
|
70
43
|
interface PropsBase<T> {
|
|
71
44
|
else?: ReactNode | (() => ReactNode);
|
|
45
|
+
$value?: Observable<T>;
|
|
72
46
|
wrap?: FC;
|
|
73
47
|
children: ReactNode | ((value?: T) => ReactNode);
|
|
74
48
|
}
|
|
@@ -92,6 +66,29 @@ declare function Switch<T>({ value, children, }: {
|
|
|
92
66
|
children: Partial<Record<'undefined' | 'default', () => ReactNode>>;
|
|
93
67
|
}): ReactElement | null;
|
|
94
68
|
|
|
69
|
+
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
70
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
71
|
+
} & {
|
|
72
|
+
children?: Selector<ReactNode>;
|
|
73
|
+
};
|
|
74
|
+
interface BindKey<P> {
|
|
75
|
+
handler?: keyof P;
|
|
76
|
+
getValue?: (e: any) => any;
|
|
77
|
+
defaultValue?: any;
|
|
78
|
+
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
79
|
+
}
|
|
80
|
+
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
81
|
+
type FCReactiveObject<T> = {
|
|
82
|
+
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
83
|
+
};
|
|
84
|
+
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
85
|
+
ref?: LegacyRef<P> | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
interface UseSelectorOptions {
|
|
88
|
+
suspense?: boolean;
|
|
89
|
+
skipCheck?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
95
92
|
type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
|
|
96
93
|
[K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
97
94
|
};
|
|
@@ -140,11 +137,14 @@ declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R
|
|
|
140
137
|
declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R, initializerArg: I, initializer: (arg: I) => ReducerState<R>): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
141
138
|
declare function useObservableReducer<R extends Reducer<any, any>>(reducer: R, initialState: ReducerState<R>, initializer?: undefined): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
interface UseObserveOptions extends ObserveOptions {
|
|
141
|
+
deps?: any[];
|
|
142
|
+
}
|
|
143
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): () => void;
|
|
144
|
+
declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): () => void;
|
|
145
145
|
|
|
146
|
-
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?:
|
|
147
|
-
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?:
|
|
146
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): void;
|
|
147
|
+
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): void;
|
|
148
148
|
|
|
149
149
|
declare function useSelector<T>(selector: Selector<T>, options?: UseSelectorOptions): T;
|
|
150
150
|
|
|
@@ -154,4 +154,9 @@ declare const useUnmountOnce: typeof useUnmount;
|
|
|
154
154
|
declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
155
155
|
declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
declare function configureReactive({ components, binders, }: {
|
|
158
|
+
components?: Record<string, FC | ComponentClass<any>>;
|
|
159
|
+
binders?: Record<string, BindKeys>;
|
|
160
|
+
}): void;
|
|
161
|
+
|
|
162
|
+
export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
|
package/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, ReactElement, FC, LegacyRef,
|
|
3
|
-
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction,
|
|
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';
|
|
4
4
|
|
|
5
5
|
declare function Computed({ children }: {
|
|
6
6
|
children: ObservableParam | (() => ReactNode);
|
|
@@ -28,36 +28,9 @@ declare function usePauseProvider(): {
|
|
|
28
28
|
|
|
29
29
|
declare const Memo: react.MemoExoticComponent<typeof Computed>;
|
|
30
30
|
|
|
31
|
-
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
32
|
-
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
children?: Selector<ReactNode>;
|
|
35
|
-
};
|
|
36
|
-
interface BindKey<P> {
|
|
37
|
-
handler?: keyof P;
|
|
38
|
-
getValue?: (e: any) => any;
|
|
39
|
-
defaultValue?: any;
|
|
40
|
-
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
41
|
-
}
|
|
42
|
-
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
43
|
-
type FCReactiveObject<T> = {
|
|
44
|
-
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
45
|
-
};
|
|
46
|
-
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
47
|
-
ref?: LegacyRef<P> | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
interface UseSelectorOptions {
|
|
50
|
-
suspense?: boolean;
|
|
51
|
-
skipCheck?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
31
|
interface IReactive {
|
|
55
32
|
}
|
|
56
33
|
declare const Reactive: IReactive;
|
|
57
|
-
declare function configureReactive({ components, binders, }: {
|
|
58
|
-
components?: Record<string, FC | ComponentClass<any>>;
|
|
59
|
-
binders?: Record<string, BindKeys>;
|
|
60
|
-
}): void;
|
|
61
34
|
|
|
62
35
|
interface PropsIf<T> {
|
|
63
36
|
if: Selector<T>;
|
|
@@ -69,6 +42,7 @@ interface PropsIfReady<T> {
|
|
|
69
42
|
}
|
|
70
43
|
interface PropsBase<T> {
|
|
71
44
|
else?: ReactNode | (() => ReactNode);
|
|
45
|
+
$value?: Observable<T>;
|
|
72
46
|
wrap?: FC;
|
|
73
47
|
children: ReactNode | ((value?: T) => ReactNode);
|
|
74
48
|
}
|
|
@@ -92,6 +66,29 @@ declare function Switch<T>({ value, children, }: {
|
|
|
92
66
|
children: Partial<Record<'undefined' | 'default', () => ReactNode>>;
|
|
93
67
|
}): ReactElement | null;
|
|
94
68
|
|
|
69
|
+
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
70
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
71
|
+
} & {
|
|
72
|
+
children?: Selector<ReactNode>;
|
|
73
|
+
};
|
|
74
|
+
interface BindKey<P> {
|
|
75
|
+
handler?: keyof P;
|
|
76
|
+
getValue?: (e: any) => any;
|
|
77
|
+
defaultValue?: any;
|
|
78
|
+
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
79
|
+
}
|
|
80
|
+
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
81
|
+
type FCReactiveObject<T> = {
|
|
82
|
+
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
83
|
+
};
|
|
84
|
+
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
85
|
+
ref?: LegacyRef<P> | undefined;
|
|
86
|
+
}>;
|
|
87
|
+
interface UseSelectorOptions {
|
|
88
|
+
suspense?: boolean;
|
|
89
|
+
skipCheck?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
95
92
|
type ShapeWithPick$<T, T2 extends keyof T = keyof T> = Partial<T> & {
|
|
96
93
|
[K in T2 as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
97
94
|
};
|
|
@@ -140,11 +137,14 @@ declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R
|
|
|
140
137
|
declare function useObservableReducer<R extends Reducer<any, any>, I>(reducer: R, initializerArg: I, initializer: (arg: I) => ReducerState<R>): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
141
138
|
declare function useObservableReducer<R extends Reducer<any, any>>(reducer: R, initialState: ReducerState<R>, initializer?: undefined): [Observable<ReducerState<R>>, Dispatch<ReducerAction<R>>];
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
interface UseObserveOptions extends ObserveOptions {
|
|
141
|
+
deps?: any[];
|
|
142
|
+
}
|
|
143
|
+
declare function useObserve<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): () => void;
|
|
144
|
+
declare function useObserve<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): () => void;
|
|
145
145
|
|
|
146
|
-
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?:
|
|
147
|
-
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?:
|
|
146
|
+
declare function useObserveEffect<T>(run: (e: ObserveEvent<T>) => T | void, options?: UseObserveOptions): void;
|
|
147
|
+
declare function useObserveEffect<T>(selector: Selector<T>, reaction?: (e: ObserveEventCallback<T>) => any, options?: UseObserveOptions): void;
|
|
148
148
|
|
|
149
149
|
declare function useSelector<T>(selector: Selector<T>, options?: UseSelectorOptions): T;
|
|
150
150
|
|
|
@@ -154,4 +154,9 @@ declare const useUnmountOnce: typeof useUnmount;
|
|
|
154
154
|
declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
155
155
|
declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
declare function configureReactive({ components, binders, }: {
|
|
158
|
+
components?: Record<string, FC | ComponentClass<any>>;
|
|
159
|
+
binders?: Record<string, BindKeys>;
|
|
160
|
+
}): void;
|
|
161
|
+
|
|
162
|
+
export { type BindKey, type BindKeys, Computed, type ExtractFCPropsType, type FCReactive, type FCReactiveObject, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithNew$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, type UseSelectorOptions, configureReactive, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
|