@fluentui/react-context-selector 9.0.0-nightly.b5b7401007.0 → 9.0.0-rc.3
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/CHANGELOG.json +116 -8
- package/CHANGELOG.md +45 -6
- package/lib/createContext.js +53 -40
- package/lib/createContext.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/useContextSelector.js +66 -49
- package/lib/useContextSelector.js.map +1 -1
- package/lib/useHasParentContext.js +8 -5
- package/lib/useHasParentContext.js.map +1 -1
- package/lib-commonjs/createContext.js +64 -44
- package/lib-commonjs/createContext.js.map +1 -1
- package/lib-commonjs/index.js +34 -8
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.js +4 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/useContextSelector.js +76 -52
- package/lib-commonjs/useContextSelector.js.map +1 -1
- package/lib-commonjs/useHasParentContext.js +16 -7
- package/lib-commonjs/useHasParentContext.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.json
CHANGED
@@ -2,22 +2,130 @@
|
|
2
2
|
"name": "@fluentui/react-context-selector",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-context-selector_v9.0.0-
|
7
|
-
"version": "9.0.0-
|
5
|
+
"date": "Fri, 18 Feb 2022 13:33:46 GMT",
|
6
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-rc.3",
|
7
|
+
"version": "9.0.0-rc.3",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
11
|
-
"author": "
|
11
|
+
"author": "lingfangao@hotmail.com",
|
12
12
|
"package": "@fluentui/react-context-selector",
|
13
|
-
"
|
14
|
-
"
|
13
|
+
"commit": "1aa9e691fcccd9a64168cea7941c0f1e71fa1d14",
|
14
|
+
"comment": "fix: Source maps contain original source code"
|
15
15
|
},
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-context-selector",
|
19
|
-
"comment": "Bump @fluentui/react-utilities to v9.0.0-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-rc.3",
|
20
|
+
"commit": "3b9c1e931c23173da3d1af0c696cdc58516ce504"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"date": "Thu, 10 Feb 2022 08:51:09 GMT",
|
27
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-rc.1",
|
28
|
+
"version": "9.0.0-rc.1",
|
29
|
+
"comments": {
|
30
|
+
"none": [
|
31
|
+
{
|
32
|
+
"author": "martinhochel@microsoft.com",
|
33
|
+
"package": "@fluentui/react-context-selector",
|
34
|
+
"commit": "8dfa712156b70414205b87b5b6d099367b0c297d",
|
35
|
+
"comment": "chore: use storybook runner for all vNext packages"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"author": "olfedias@microsoft.com",
|
39
|
+
"package": "@fluentui/react-context-selector",
|
40
|
+
"commit": "c061e98be4b4a718c72a144a1f60bb5515824612",
|
41
|
+
"comment": "remove inline-style-expand-shorthand from tsconfigs"
|
42
|
+
}
|
43
|
+
],
|
44
|
+
"prerelease": [
|
45
|
+
{
|
46
|
+
"author": "lingfangao@hotmail.com",
|
47
|
+
"package": "@fluentui/react-context-selector",
|
48
|
+
"commit": "c00913d50e2dd15bbfbb0757cefe43b192ff1d7f",
|
49
|
+
"comment": "Bump Fluent UI packages to 9.0.0-rc"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"author": "tristan.watanabe@gmail.com",
|
53
|
+
"package": "@fluentui/react-context-selector",
|
54
|
+
"commit": "13f940ea4687d769dd2faf61edc27ff75f6bb565",
|
55
|
+
"comment": "Allow React 17 in peerDependencies."
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"author": "beachball",
|
59
|
+
"package": "@fluentui/react-context-selector",
|
60
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-rc.1",
|
61
|
+
"commit": "e6c855f6d9019d6c73668d15fc9bc3a13291a6c8"
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"date": "Thu, 25 Nov 2021 08:34:13 GMT",
|
68
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-beta.4",
|
69
|
+
"version": "9.0.0-beta.4",
|
70
|
+
"comments": {
|
71
|
+
"none": [
|
72
|
+
{
|
73
|
+
"author": "olfedias@microsoft.com",
|
74
|
+
"package": "@fluentui/react-context-selector",
|
75
|
+
"commit": "59b3bebb1944aa35f8e8754beec16dcc95f1d5fb",
|
76
|
+
"comment": "update tooling configs"
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"prerelease": [
|
80
|
+
{
|
81
|
+
"author": "beachball",
|
82
|
+
"package": "@fluentui/react-context-selector",
|
83
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.4",
|
84
|
+
"commit": "48d236ac53a4950fabc3ddd52f91dac93ca0195b"
|
85
|
+
}
|
86
|
+
]
|
87
|
+
}
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"date": "Fri, 12 Nov 2021 13:25:22 GMT",
|
91
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-beta.3",
|
92
|
+
"version": "9.0.0-beta.3",
|
93
|
+
"comments": {
|
94
|
+
"none": [
|
95
|
+
{
|
96
|
+
"author": "lingfangao@hotmail.com",
|
97
|
+
"package": "@fluentui/react-context-selector",
|
98
|
+
"commit": "00f70581480b536e723fb69edf0ae617beac4807",
|
99
|
+
"comment": "Remove beta release tag"
|
100
|
+
}
|
101
|
+
],
|
102
|
+
"prerelease": [
|
103
|
+
{
|
104
|
+
"author": "gcox@microsoft.com",
|
105
|
+
"package": "@fluentui/react-context-selector",
|
106
|
+
"commit": "c9bd5b5a02ae94a8239ce1b56cac2f0d0dbd3586",
|
107
|
+
"comment": "Updated beta and RC components to ES2019"
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"author": "beachball",
|
111
|
+
"package": "@fluentui/react-context-selector",
|
112
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.3",
|
113
|
+
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
}
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"date": "Wed, 27 Oct 2021 12:14:24 GMT",
|
120
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-beta.2",
|
121
|
+
"version": "9.0.0-beta.2",
|
122
|
+
"comments": {
|
123
|
+
"prerelease": [
|
124
|
+
{
|
125
|
+
"author": "beachball",
|
126
|
+
"package": "@fluentui/react-context-selector",
|
127
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.2",
|
128
|
+
"commit": "0f8f1ae7c2d908e51e29dd342d79e041f86fac08"
|
21
129
|
}
|
22
130
|
]
|
23
131
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,18 +1,57 @@
|
|
1
1
|
# Change Log - @fluentui/react-context-selector
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 18 Feb 2022 13:33:46 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [9.0.0-
|
7
|
+
## [9.0.0-rc.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-rc.3)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-
|
9
|
+
Fri, 18 Feb 2022 13:33:46 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-rc.1..@fluentui/react-context-selector_v9.0.0-rc.3)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
|
-
-
|
15
|
-
- Bump @fluentui/react-utilities to v9.0.0-
|
14
|
+
- fix: Source maps contain original source code ([PR #21690](https://github.com/microsoft/fluentui/pull/21690) by lingfangao@hotmail.com)
|
15
|
+
- Bump @fluentui/react-utilities to v9.0.0-rc.3 ([PR #21800](https://github.com/microsoft/fluentui/pull/21800) by beachball)
|
16
|
+
|
17
|
+
## [9.0.0-rc.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-rc.1)
|
18
|
+
|
19
|
+
Thu, 10 Feb 2022 08:51:09 GMT
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.4..@fluentui/react-context-selector_v9.0.0-rc.1)
|
21
|
+
|
22
|
+
### Changes
|
23
|
+
|
24
|
+
- Bump Fluent UI packages to 9.0.0-rc ([PR #21623](https://github.com/microsoft/fluentui/pull/21623) by lingfangao@hotmail.com)
|
25
|
+
- Allow React 17 in peerDependencies. ([PR #21544](https://github.com/microsoft/fluentui/pull/21544) by tristan.watanabe@gmail.com)
|
26
|
+
- Bump @fluentui/react-utilities to v9.0.0-rc.1 ([commit](https://github.com/microsoft/fluentui/commit/e6c855f6d9019d6c73668d15fc9bc3a13291a6c8) by beachball)
|
27
|
+
|
28
|
+
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.4)
|
29
|
+
|
30
|
+
Thu, 25 Nov 2021 08:34:13 GMT
|
31
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.3..@fluentui/react-context-selector_v9.0.0-beta.4)
|
32
|
+
|
33
|
+
### Changes
|
34
|
+
|
35
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.4 ([PR #20762](https://github.com/microsoft/fluentui/pull/20762) by beachball)
|
36
|
+
|
37
|
+
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.3)
|
38
|
+
|
39
|
+
Fri, 12 Nov 2021 13:25:22 GMT
|
40
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.2..@fluentui/react-context-selector_v9.0.0-beta.3)
|
41
|
+
|
42
|
+
### Changes
|
43
|
+
|
44
|
+
- Updated beta and RC components to ES2019 ([PR #20405](https://github.com/microsoft/fluentui/pull/20405) by gcox@microsoft.com)
|
45
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
|
46
|
+
|
47
|
+
## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.2)
|
48
|
+
|
49
|
+
Wed, 27 Oct 2021 12:14:24 GMT
|
50
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.1..@fluentui/react-context-selector_v9.0.0-beta.2)
|
51
|
+
|
52
|
+
### Changes
|
53
|
+
|
54
|
+
- Bump @fluentui/react-utilities to v9.0.0-beta.2 ([PR #20353](https://github.com/microsoft/fluentui/pull/20353) by beachball)
|
16
55
|
|
17
56
|
## [9.0.0-beta.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.1)
|
18
57
|
|
package/lib/createContext.js
CHANGED
@@ -1,47 +1,60 @@
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
2
2
|
import * as React from 'react';
|
3
3
|
import { unstable_NormalPriority as NormalPriority, unstable_runWithPriority as runWithPriority } from 'scheduler';
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
valueRef.current = props.value;
|
21
|
-
versionRef.current += 1;
|
22
|
-
runWithPriority(NormalPriority, function () {
|
23
|
-
contextValue.current.listeners.forEach(function (listener) {
|
24
|
-
listener([versionRef.current, props.value]);
|
25
|
-
});
|
26
|
-
});
|
27
|
-
}, [props.value]);
|
28
|
-
return React.createElement(Original, { value: contextValue.current }, props.children);
|
29
|
-
};
|
30
|
-
/* istanbul ignore else */
|
31
|
-
if (process.env.NODE_ENV !== 'production') {
|
32
|
-
Provider.displayName = 'ContextSelector.Provider';
|
4
|
+
|
5
|
+
const createProvider = Original => {
|
6
|
+
const Provider = props => {
|
7
|
+
// Holds an actual "props.value"
|
8
|
+
const valueRef = React.useRef(props.value); // Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.
|
9
|
+
|
10
|
+
const versionRef = React.useRef(0); // A stable object, is used to avoid context updates via mutation of its values.
|
11
|
+
|
12
|
+
const contextValue = React.useRef();
|
13
|
+
|
14
|
+
if (!contextValue.current) {
|
15
|
+
contextValue.current = {
|
16
|
+
value: valueRef,
|
17
|
+
version: versionRef,
|
18
|
+
listeners: []
|
19
|
+
};
|
33
20
|
}
|
34
|
-
|
21
|
+
|
22
|
+
useIsomorphicLayoutEffect(() => {
|
23
|
+
valueRef.current = props.value;
|
24
|
+
versionRef.current += 1;
|
25
|
+
runWithPriority(NormalPriority, () => {
|
26
|
+
contextValue.current.listeners.forEach(listener => {
|
27
|
+
listener([versionRef.current, props.value]);
|
28
|
+
});
|
29
|
+
});
|
30
|
+
}, [props.value]);
|
31
|
+
return /*#__PURE__*/React.createElement(Original, {
|
32
|
+
value: contextValue.current
|
33
|
+
}, props.children);
|
34
|
+
};
|
35
|
+
/* istanbul ignore else */
|
36
|
+
|
37
|
+
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
39
|
+
Provider.displayName = 'ContextSelector.Provider';
|
40
|
+
}
|
41
|
+
|
42
|
+
return Provider;
|
35
43
|
};
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
|
45
|
+
export const createContext = defaultValue => {
|
46
|
+
const context = /*#__PURE__*/React.createContext({
|
47
|
+
value: {
|
48
|
+
current: defaultValue
|
49
|
+
},
|
50
|
+
version: {
|
51
|
+
current: -1
|
52
|
+
},
|
53
|
+
listeners: []
|
54
|
+
});
|
55
|
+
context.Provider = createProvider(context.Provider); // We don't support Consumer API
|
56
|
+
|
57
|
+
delete context.Consumer;
|
58
|
+
return context;
|
46
59
|
};
|
47
60
|
//# sourceMappingURL=createContext.js.map
|
package/lib/createContext.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["createContext.ts"],"names":[],"mappings":"AAAA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,uBAAuB,IAAI,cAApC,EAAoD,wBAAwB,IAAI,eAAhF,QAAuG,WAAvG;;AAIA,MAAM,cAAc,GAAW,QAAR,IAAyD;AAC9E,QAAM,QAAQ,GAAyC,KAAK,IAAG;AAC7D;AACA,UAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAK,CAAC,KAAnB,CAAjB,CAF6D,CAG7D;;AACA,UAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAa,CAAb,CAAnB,CAJ6D,CAM7D;;AACA,UAAM,YAAY,GAAG,KAAK,CAAC,MAAN,EAArB;;AAEA,QAAI,CAAC,YAAY,CAAC,OAAlB,EAA2B;AACzB,MAAA,YAAY,CAAC,OAAb,GAAuB;AACrB,QAAA,KAAK,EAAE,QADc;AAErB,QAAA,OAAO,EAAE,UAFY;AAGrB,QAAA,SAAS,EAAE;AAHU,OAAvB;AAKD;;AAED,IAAA,yBAAyB,CAAC,MAAK;AAC7B,MAAA,QAAQ,CAAC,OAAT,GAAmB,KAAK,CAAC,KAAzB;AACA,MAAA,UAAU,CAAC,OAAX,IAAsB,CAAtB;AAEA,MAAA,eAAe,CAAC,cAAD,EAAiB,MAAK;AAClC,QAAA,YAAY,CAAC,OAAb,CAA6C,SAA7C,CAAuD,OAAvD,CAA+D,QAAQ,IAAG;AACzE,UAAA,QAAQ,CAAC,CAAC,UAAU,CAAC,OAAZ,EAAqB,KAAK,CAAC,KAA3B,CAAD,CAAR;AACD,SAFA;AAGF,OAJc,CAAf;AAKD,KATwB,EAStB,CAAC,KAAK,CAAC,KAAP,CATsB,CAAzB;AAWA,wBAAO,KAAK,CAAC,aAAN,CAAoB,QAApB,EAA8B;AAAE,MAAA,KAAK,EAAE,YAAY,CAAC;AAAtB,KAA9B,EAA+D,KAAK,CAAC,QAArE,CAAP;AACD,GA7BD;AA+BA;;;AACA,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,IAAA,QAAQ,CAAC,WAAT,GAAuB,0BAAvB;AACD;;AAED,SAAQ,QAAR;AACD,CAtCD;;AAwCA,OAAO,MAAM,aAAa,GAAW,YAAR,IAA+C;AAC1E,QAAM,OAAO,gBAAG,KAAK,CAAC,aAAN,CAAyC;AACvD,IAAA,KAAK,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KADgD;AAEvD,IAAA,OAAO,EAAE;AAAE,MAAA,OAAO,EAAE,CAAC;AAAZ,KAF8C;AAGvD,IAAA,SAAS,EAAE;AAH4C,GAAzC,CAAhB;AAMA,EAAA,OAAO,CAAC,QAAR,GAAmB,cAAc,CAAQ,OAAO,CAAC,QAAhB,CAAjC,CAP0E,CAS1E;;AACA,SAAS,OAAsC,CAAC,QAAhD;AAEA,SAAQ,OAAR;AACD,CAbM","sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { unstable_NormalPriority as NormalPriority, unstable_runWithPriority as runWithPriority } from 'scheduler';\n\nimport { Context, ContextValue } from './types';\n\nconst createProvider = <Value>(Original: React.Provider<ContextValue<Value>>) => {\n const Provider: React.FC<React.ProviderProps<Value>> = props => {\n // Holds an actual \"props.value\"\n const valueRef = React.useRef(props.value);\n // Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.\n const versionRef = React.useRef(0);\n\n // A stable object, is used to avoid context updates via mutation of its values.\n const contextValue = React.useRef<ContextValue<Value>>();\n\n if (!contextValue.current) {\n contextValue.current = {\n value: valueRef,\n version: versionRef,\n listeners: [],\n };\n }\n\n useIsomorphicLayoutEffect(() => {\n valueRef.current = props.value;\n versionRef.current += 1;\n\n runWithPriority(NormalPriority, () => {\n (contextValue.current as ContextValue<Value>).listeners.forEach(listener => {\n listener([versionRef.current, props.value]);\n });\n });\n }, [props.value]);\n\n return React.createElement(Original, { value: contextValue.current }, props.children);\n };\n\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== 'production') {\n Provider.displayName = 'ContextSelector.Provider';\n }\n\n return (Provider as unknown) as React.Provider<ContextValue<Value>>;\n};\n\nexport const createContext = <Value>(defaultValue: Value): Context<Value> => {\n const context = React.createContext<ContextValue<Value>>({\n value: { current: defaultValue },\n version: { current: -1 },\n listeners: [],\n });\n\n context.Provider = createProvider<Value>(context.Provider);\n\n // We don't support Consumer API\n delete ((context as unknown) as Context<Value>).Consumer;\n\n return (context as unknown) as Context<Value>;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,SAAS,CAAC","sourcesContent":["export { createContext } from './createContext';\nexport { useContextSelector } from './useContextSelector';\nexport { useHasParentContext } from './useHasParentContext';\nexport * from './types';\n"]}
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type Context<Value> = React.Context<Value> & {\n Provider: React.FC<React.ProviderProps<Value>>;\n Consumer: never;\n};\n\nexport type ContextSelector<Value, SelectedValue> = (value: Value) => SelectedValue;\n\nexport type ContextVersion = number;\n\nexport type ContextValue<Value> = {\n /** Holds a set of subscribers from components. */\n listeners: ((payload: readonly [ContextVersion, Value]) => void)[];\n\n /** Holds an actual value of React's context that will be propagated down for computations. */\n value: React.MutableRefObject<Value>;\n\n /** A version field is used to sync a context value and consumers. */\n version: React.MutableRefObject<ContextVersion>;\n};\n\nexport type ContextValues<Value> = ContextValue<Value> & {\n /** List of listners to publish changes */\n listeners: ((payload: readonly [ContextVersion, Record<string, Value>]) => void)[];\n};\n"]}
|
@@ -5,63 +5,80 @@ import * as React from 'react';
|
|
5
5
|
* It will only accept context created by `createContext`.
|
6
6
|
* It will trigger re-render if only the selected value is referencially changed.
|
7
7
|
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return prevState; // do not update
|
26
|
-
}
|
27
|
-
var nextSelected = selector(payload[1]);
|
28
|
-
if (objectIs(prevState[1], nextSelected)) {
|
29
|
-
return prevState; // do not update
|
30
|
-
}
|
31
|
-
return [payload[1], nextSelected];
|
32
|
-
}
|
33
|
-
catch (e) {
|
34
|
-
// ignored (stale props or some other reason)
|
35
|
-
}
|
36
|
-
// explicitly spread to enforce typing
|
37
|
-
return [prevState[0], prevState[1]]; // schedule update
|
38
|
-
}, [value, selected]), state = _a[0], dispatch = _a[1];
|
39
|
-
if (!objectIs(state[1], selected)) {
|
40
|
-
// schedule re-render
|
41
|
-
// this is safe because it's self contained
|
42
|
-
dispatch(undefined);
|
8
|
+
|
9
|
+
export const useContextSelector = (context, selector) => {
|
10
|
+
const contextValue = React.useContext(context);
|
11
|
+
const {
|
12
|
+
value: {
|
13
|
+
current: value
|
14
|
+
},
|
15
|
+
version: {
|
16
|
+
current: version
|
17
|
+
},
|
18
|
+
listeners
|
19
|
+
} = contextValue;
|
20
|
+
const selected = selector(value);
|
21
|
+
const [state, dispatch] = React.useReducer((prevState, payload) => {
|
22
|
+
if (!payload) {
|
23
|
+
// early bail out when is dispatched during render
|
24
|
+
return [value, selected];
|
43
25
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
26
|
+
|
27
|
+
if (payload[0] <= version) {
|
28
|
+
if (objectIs(prevState[1], selected)) {
|
29
|
+
return prevState; // bail out
|
30
|
+
}
|
31
|
+
|
32
|
+
return [value, selected];
|
33
|
+
}
|
34
|
+
|
35
|
+
try {
|
36
|
+
if (objectIs(prevState[0], payload[1])) {
|
37
|
+
return prevState; // do not update
|
38
|
+
}
|
39
|
+
|
40
|
+
const nextSelected = selector(payload[1]);
|
41
|
+
|
42
|
+
if (objectIs(prevState[1], nextSelected)) {
|
43
|
+
return prevState; // do not update
|
44
|
+
}
|
45
|
+
|
46
|
+
return [payload[1], nextSelected];
|
47
|
+
} catch (e) {// ignored (stale props or some other reason)
|
48
|
+
} // explicitly spread to enforce typing
|
49
|
+
|
50
|
+
|
51
|
+
return [prevState[0], prevState[1]]; // schedule update
|
52
|
+
}, [value, selected]);
|
53
|
+
|
54
|
+
if (!objectIs(state[1], selected)) {
|
55
|
+
// schedule re-render
|
56
|
+
// this is safe because it's self contained
|
57
|
+
dispatch(undefined);
|
58
|
+
}
|
59
|
+
|
60
|
+
useIsomorphicLayoutEffect(() => {
|
61
|
+
listeners.push(dispatch);
|
62
|
+
return () => {
|
63
|
+
const index = listeners.indexOf(dispatch);
|
64
|
+
listeners.splice(index, 1);
|
65
|
+
};
|
66
|
+
}, [listeners]);
|
67
|
+
return state[1];
|
52
68
|
};
|
53
69
|
/**
|
54
70
|
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
55
71
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
56
72
|
*/
|
57
73
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
74
|
+
|
58
75
|
function is(x, y) {
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
76
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
77
|
+
;
|
78
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
79
|
+
|
80
|
+
|
81
|
+
const objectIs = // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
65
82
|
// @ts-ignore fallback to native if it exists (not in IE11)
|
66
83
|
typeof Object.is === 'function' ? Object.is : is;
|
67
84
|
//# sourceMappingURL=useContextSelector.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useContextSelector.ts"],"names":[],"mappings":"AAAA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAaA;;;;AAIG;;AACH,OAAO,MAAM,kBAAkB,GAAG,CAChC,OADgC,EAEhC,QAFgC,KAGf;AACjB,QAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;AAEA,QAAM;AACJ,IAAA,KAAK,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KADH;AAEJ,IAAA,OAAO,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KAFL;AAGJ,IAAA;AAHI,MAIF,YAJJ;AAKA,QAAM,QAAQ,GAAG,QAAQ,CAAC,KAAD,CAAzB;AAEA,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,UAAN,CACxB,CACE,SADF,EAEE,OAFF,KAKqC;AACnC,QAAI,CAAC,OAAL,EAAc;AACZ;AACA,aAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;AACD;;AAED,QAAI,OAAO,CAAC,CAAD,CAAP,IAAc,OAAlB,EAA2B;AACzB,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,QAAf,CAAZ,EAAsC;AACpC,eAAO,SAAP,CADoC,CAClB;AACnB;;AAED,aAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;AACD;;AAED,QAAI;AACF,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,OAAO,CAAC,CAAD,CAAtB,CAAZ,EAAwC;AACtC,eAAO,SAAP,CADsC,CACpB;AACnB;;AAED,YAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAD,CAAR,CAA7B;;AAEA,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,YAAf,CAAZ,EAA0C;AACxC,eAAO,SAAP,CADwC,CACtB;AACnB;;AAED,aAAO,CAAC,OAAO,CAAC,CAAD,CAAR,EAAa,YAAb,CAAP;AACD,KAZD,CAYE,OAAO,CAAP,EAAU,CACV;AACD,KA5BkC,CA8BnC;;;AACA,WAAO,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,SAAS,CAAC,CAAD,CAAxB,CAAP,CA/BmC,CA+BW;AAC/C,GAtCuB,EAuCxB,CAAC,KAAD,EAAQ,QAAR,CAvCwB,CAA1B;;AA0CA,MAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAD,CAAN,EAAW,QAAX,CAAb,EAAmC;AACjC;AACA;AACA,IAAA,QAAQ,CAAC,SAAD,CAAR;AACD;;AAED,EAAA,yBAAyB,CAAC,MAAK;AAC7B,IAAA,SAAS,CAAC,IAAV,CAAe,QAAf;AAEA,WAAO,MAAK;AACV,YAAM,KAAK,GAAG,SAAS,CAAC,OAAV,CAAkB,QAAlB,CAAd;AACA,MAAA,SAAS,CAAC,MAAV,CAAiB,KAAjB,EAAwB,CAAxB;AACD,KAHD;AAID,GAPwB,EAOtB,CAAC,SAAD,CAPsB,CAAzB;AASA,SAAO,KAAK,CAAC,CAAD,CAAZ;AACD,CAvEM;AAyEP;;;AAGG;AACH;;AACA,SAAS,EAAT,CAAY,CAAZ,EAAoB,CAApB,EAA0B;AACxB,SACG,CAAC,KAAK,CAAN,KAAY,CAAC,KAAK,CAAN,IAAW,IAAI,CAAJ,KAAU,IAAI,CAArC,CAAD,IAA8C,CAAC,KAAK,CAAN,IAAW,CAAC,KAAK,CADjE,CACoE;AADpE;AAGD,C,CAED;;;AACA,MAAM,QAAQ,GACZ;AACA;AACA,OAAO,MAAM,CAAC,EAAd,KAAqB,UAArB,GAAkC,MAAM,CAAC,EAAzC,GAA8C,EAHhD","sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { Context, ContextSelector, ContextValue, ContextVersion } from './types';\n\n/**\n * Narrowing React.Reducer type to be more easily usable below.\n * No need to export this as it's for internal reducer usage.\n */\ntype ContextReducer<Value, SelectedValue> = React.Reducer<\n readonly [Value, SelectedValue],\n undefined | readonly [ContextVersion, Value]\n>;\n\n/**\n * This hook returns context selected value by selector.\n * It will only accept context created by `createContext`.\n * It will trigger re-render if only the selected value is referencially changed.\n */\nexport const useContextSelector = <Value, SelectedValue>(\n context: Context<Value>,\n selector: ContextSelector<Value, SelectedValue>,\n): SelectedValue => {\n const contextValue = React.useContext((context as unknown) as Context<ContextValue<Value>>);\n\n const {\n value: { current: value },\n version: { current: version },\n listeners,\n } = contextValue;\n const selected = selector(value);\n\n const [state, dispatch] = React.useReducer<ContextReducer<Value, SelectedValue>>(\n (\n prevState: readonly [Value /* contextValue */, SelectedValue /* selector(value) */],\n payload:\n | undefined // undefined from render below\n | readonly [ContextVersion, Value], // from provider effect\n ): readonly [Value, SelectedValue] => {\n if (!payload) {\n // early bail out when is dispatched during render\n return [value, selected] as const;\n }\n\n if (payload[0] <= version) {\n if (objectIs(prevState[1], selected)) {\n return prevState; // bail out\n }\n\n return [value, selected] as const;\n }\n\n try {\n if (objectIs(prevState[0], payload[1])) {\n return prevState; // do not update\n }\n\n const nextSelected = selector(payload[1]);\n\n if (objectIs(prevState[1], nextSelected)) {\n return prevState; // do not update\n }\n\n return [payload[1], nextSelected] as const;\n } catch (e) {\n // ignored (stale props or some other reason)\n }\n\n // explicitly spread to enforce typing\n return [prevState[0], prevState[1]] as const; // schedule update\n },\n [value, selected] as const,\n );\n\n if (!objectIs(state[1], selected)) {\n // schedule re-render\n // this is safe because it's self contained\n dispatch(undefined);\n }\n\n useIsomorphicLayoutEffect(() => {\n listeners.push(dispatch);\n\n return () => {\n const index = listeners.indexOf(dispatch);\n listeners.splice(index, 1);\n };\n }, [listeners]);\n\n return state[1] as SelectedValue;\n};\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction is(x: any, y: any) {\n return (\n (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst objectIs: (x: any, y: any) => boolean =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore fallback to native if it exists (not in IE11)\n typeof Object.is === 'function' ? Object.is : is;\n"],"sourceRoot":"../src/"}
|
@@ -6,11 +6,14 @@ import * as React from 'react';
|
|
6
6
|
* @param context - context created by react-context-selector
|
7
7
|
* @returns whether the hook is wrapped by a parent context
|
8
8
|
*/
|
9
|
+
|
9
10
|
export function useHasParentContext(context) {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
const contextValue = React.useContext(context);
|
12
|
+
|
13
|
+
if (contextValue.version) {
|
14
|
+
return contextValue.version.current !== -1;
|
15
|
+
}
|
16
|
+
|
17
|
+
return false;
|
15
18
|
}
|
16
19
|
//# sourceMappingURL=useHasParentContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA;;;;;;AAMG;;AACH,OAAM,SAAU,mBAAV,CAAqC,OAArC,EAA4D;AAChE,QAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;;AAEA,MAAI,YAAY,CAAC,OAAjB,EAA0B;AACxB,WAAO,YAAY,CAAC,OAAb,CAAqB,OAArB,KAAiC,CAAC,CAAzC;AACD;;AAED,SAAO,KAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { Context, ContextValue } from './types';\n\n/**\n * Utility hook for contexts created by react-context-selector to determine if a parent context exists\n * WARNING: This hook will not work for native React contexts\n *\n * @param context - context created by react-context-selector\n * @returns whether the hook is wrapped by a parent context\n */\nexport function useHasParentContext<Value>(context: Context<Value>) {\n const contextValue = React.useContext((context as unknown) as Context<ContextValue<Value>>);\n\n if (contextValue.version) {\n return contextValue.version.current !== -1;\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
|
@@ -1,51 +1,71 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.createContext = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
contextValue.current.listeners.forEach(function (listener) {
|
27
|
-
listener([versionRef.current, props.value]);
|
28
|
-
});
|
29
|
-
});
|
30
|
-
}, [props.value]);
|
31
|
-
return React.createElement(Original, { value: contextValue.current }, props.children);
|
32
|
-
};
|
33
|
-
/* istanbul ignore else */
|
34
|
-
if (process.env.NODE_ENV !== 'production') {
|
35
|
-
Provider.displayName = 'ContextSelector.Provider';
|
7
|
+
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
9
|
+
|
10
|
+
const React = /*#__PURE__*/require("react");
|
11
|
+
|
12
|
+
const scheduler_1 = /*#__PURE__*/require("scheduler");
|
13
|
+
|
14
|
+
const createProvider = Original => {
|
15
|
+
const Provider = props => {
|
16
|
+
// Holds an actual "props.value"
|
17
|
+
const valueRef = React.useRef(props.value); // Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.
|
18
|
+
|
19
|
+
const versionRef = React.useRef(0); // A stable object, is used to avoid context updates via mutation of its values.
|
20
|
+
|
21
|
+
const contextValue = React.useRef();
|
22
|
+
|
23
|
+
if (!contextValue.current) {
|
24
|
+
contextValue.current = {
|
25
|
+
value: valueRef,
|
26
|
+
version: versionRef,
|
27
|
+
listeners: []
|
28
|
+
};
|
36
29
|
}
|
37
|
-
|
30
|
+
|
31
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
32
|
+
valueRef.current = props.value;
|
33
|
+
versionRef.current += 1;
|
34
|
+
scheduler_1.unstable_runWithPriority(scheduler_1.unstable_NormalPriority, () => {
|
35
|
+
contextValue.current.listeners.forEach(listener => {
|
36
|
+
listener([versionRef.current, props.value]);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
}, [props.value]);
|
40
|
+
return React.createElement(Original, {
|
41
|
+
value: contextValue.current
|
42
|
+
}, props.children);
|
43
|
+
};
|
44
|
+
/* istanbul ignore else */
|
45
|
+
|
46
|
+
|
47
|
+
if (process.env.NODE_ENV !== 'production') {
|
48
|
+
Provider.displayName = 'ContextSelector.Provider';
|
49
|
+
}
|
50
|
+
|
51
|
+
return Provider;
|
38
52
|
};
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
53
|
+
|
54
|
+
const createContext = defaultValue => {
|
55
|
+
const context = React.createContext({
|
56
|
+
value: {
|
57
|
+
current: defaultValue
|
58
|
+
},
|
59
|
+
version: {
|
60
|
+
current: -1
|
61
|
+
},
|
62
|
+
listeners: []
|
63
|
+
});
|
64
|
+
context.Provider = createProvider(context.Provider); // We don't support Consumer API
|
65
|
+
|
66
|
+
delete context.Consumer;
|
67
|
+
return context;
|
49
68
|
};
|
69
|
+
|
50
70
|
exports.createContext = createContext;
|
51
71
|
//# sourceMappingURL=createContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["createContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,WAAA,CAAA;;AAIA,MAAM,cAAc,GAAW,QAAR,IAAyD;AAC9E,QAAM,QAAQ,GAAyC,KAAK,IAAG;AAC7D;AACA,UAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAK,CAAC,KAAnB,CAAjB,CAF6D,CAG7D;;AACA,UAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAa,CAAb,CAAnB,CAJ6D,CAM7D;;AACA,UAAM,YAAY,GAAG,KAAK,CAAC,MAAN,EAArB;;AAEA,QAAI,CAAC,YAAY,CAAC,OAAlB,EAA2B;AACzB,MAAA,YAAY,CAAC,OAAb,GAAuB;AACrB,QAAA,KAAK,EAAE,QADc;AAErB,QAAA,OAAO,EAAE,UAFY;AAGrB,QAAA,SAAS,EAAE;AAHU,OAAvB;AAKD;;AAED,IAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,MAAA,QAAQ,CAAC,OAAT,GAAmB,KAAK,CAAC,KAAzB;AACA,MAAA,UAAU,CAAC,OAAX,IAAsB,CAAtB;AAEA,MAAA,WAAA,CAAA,wBAAA,CAAgB,WAAA,CAAA,uBAAhB,EAAgC,MAAK;AAClC,QAAA,YAAY,CAAC,OAAb,CAA6C,SAA7C,CAAuD,OAAvD,CAA+D,QAAQ,IAAG;AACzE,UAAA,QAAQ,CAAC,CAAC,UAAU,CAAC,OAAZ,EAAqB,KAAK,CAAC,KAA3B,CAAD,CAAR;AACD,SAFA;AAGF,OAJD;AAKD,KATD,EASG,CAAC,KAAK,CAAC,KAAP,CATH;AAWA,WAAO,KAAK,CAAC,aAAN,CAAoB,QAApB,EAA8B;AAAE,MAAA,KAAK,EAAE,YAAY,CAAC;AAAtB,KAA9B,EAA+D,KAAK,CAAC,QAArE,CAAP;AACD,GA7BD;AA+BA;;;AACA,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,IAAA,QAAQ,CAAC,WAAT,GAAuB,0BAAvB;AACD;;AAED,SAAQ,QAAR;AACD,CAtCD;;AAwCO,MAAM,aAAa,GAAW,YAAR,IAA+C;AAC1E,QAAM,OAAO,GAAG,KAAK,CAAC,aAAN,CAAyC;AACvD,IAAA,KAAK,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KADgD;AAEvD,IAAA,OAAO,EAAE;AAAE,MAAA,OAAO,EAAE,CAAC;AAAZ,KAF8C;AAGvD,IAAA,SAAS,EAAE;AAH4C,GAAzC,CAAhB;AAMA,EAAA,OAAO,CAAC,QAAR,GAAmB,cAAc,CAAQ,OAAO,CAAC,QAAhB,CAAjC,CAP0E,CAS1E;;AACA,SAAS,OAAsC,CAAC,QAAhD;AAEA,SAAQ,OAAR;AACD,CAbM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { unstable_NormalPriority as NormalPriority, unstable_runWithPriority as runWithPriority } from 'scheduler';\n\nimport { Context, ContextValue } from './types';\n\nconst createProvider = <Value>(Original: React.Provider<ContextValue<Value>>) => {\n const Provider: React.FC<React.ProviderProps<Value>> = props => {\n // Holds an actual \"props.value\"\n const valueRef = React.useRef(props.value);\n // Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.\n const versionRef = React.useRef(0);\n\n // A stable object, is used to avoid context updates via mutation of its values.\n const contextValue = React.useRef<ContextValue<Value>>();\n\n if (!contextValue.current) {\n contextValue.current = {\n value: valueRef,\n version: versionRef,\n listeners: [],\n };\n }\n\n useIsomorphicLayoutEffect(() => {\n valueRef.current = props.value;\n versionRef.current += 1;\n\n runWithPriority(NormalPriority, () => {\n (contextValue.current as ContextValue<Value>).listeners.forEach(listener => {\n listener([versionRef.current, props.value]);\n });\n });\n }, [props.value]);\n\n return React.createElement(Original, { value: contextValue.current }, props.children);\n };\n\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== 'production') {\n Provider.displayName = 'ContextSelector.Provider';\n }\n\n return (Provider as unknown) as React.Provider<ContextValue<Value>>;\n};\n\nexport const createContext = <Value>(defaultValue: Value): Context<Value> => {\n const context = React.createContext<ContextValue<Value>>({\n value: { current: defaultValue },\n version: { current: -1 },\n listeners: [],\n });\n\n context.Provider = createProvider<Value>(context.Provider);\n\n // We don't support Consumer API\n delete ((context as unknown) as Context<Value>).Consumer;\n\n return (context as unknown) as Context<Value>;\n};\n"],"sourceRoot":"../src/"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1,12 +1,38 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.useHasParentContext = exports.useContextSelector = exports.createContext = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
var
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
|
8
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
9
|
+
|
10
|
+
var createContext_1 = /*#__PURE__*/require("./createContext");
|
11
|
+
|
12
|
+
Object.defineProperty(exports, "createContext", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return createContext_1.createContext;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
var useContextSelector_1 = /*#__PURE__*/require("./useContextSelector");
|
20
|
+
|
21
|
+
Object.defineProperty(exports, "useContextSelector", {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return useContextSelector_1.useContextSelector;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
var useHasParentContext_1 = /*#__PURE__*/require("./useHasParentContext");
|
29
|
+
|
30
|
+
Object.defineProperty(exports, "useHasParentContext", {
|
31
|
+
enumerable: true,
|
32
|
+
get: function () {
|
33
|
+
return useHasParentContext_1.useHasParentContext;
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
11
37
|
tslib_1.__exportStar(require("./types"), exports);
|
12
38
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,eAAA,CAAA,aAAA;AAAa;AAAb,CAAA;;AACT,IAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,oBAAA,CAAA,kBAAA;AAAkB;AAAlB,CAAA;;AACT,IAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,qBAAA,EAAA;AAAA,EAAA,UAAA,EAAA,IAAA;AAAA,EAAA,GAAA,EAAA,YAAA;AAAA,WAAA,qBAAA,CAAA,mBAAA;AAAmB;AAAnB,CAAA;;AACT,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA","sourcesContent":["export { createContext } from './createContext';\nexport { useContextSelector } from './useContextSelector';\nexport { useHasParentContext } from './useHasParentContext';\nexport * from './types';\n"],"sourceRoot":"../src/"}
|
package/lib-commonjs/types.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
|
@@ -1,71 +1,95 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.useContextSelector = void 0;
|
4
|
-
|
5
|
-
|
7
|
+
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
9
|
+
|
10
|
+
const React = /*#__PURE__*/require("react");
|
6
11
|
/**
|
7
12
|
* This hook returns context selected value by selector.
|
8
13
|
* It will only accept context created by `createContext`.
|
9
14
|
* It will trigger re-render if only the selected value is referencially changed.
|
10
15
|
*/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
30
|
-
var nextSelected = selector(payload[1]);
|
31
|
-
if (objectIs(prevState[1], nextSelected)) {
|
32
|
-
return prevState; // do not update
|
33
|
-
}
|
34
|
-
return [payload[1], nextSelected];
|
35
|
-
}
|
36
|
-
catch (e) {
|
37
|
-
// ignored (stale props or some other reason)
|
38
|
-
}
|
39
|
-
// explicitly spread to enforce typing
|
40
|
-
return [prevState[0], prevState[1]]; // schedule update
|
41
|
-
}, [value, selected]), state = _a[0], dispatch = _a[1];
|
42
|
-
if (!objectIs(state[1], selected)) {
|
43
|
-
// schedule re-render
|
44
|
-
// this is safe because it's self contained
|
45
|
-
dispatch(undefined);
|
16
|
+
|
17
|
+
|
18
|
+
const useContextSelector = (context, selector) => {
|
19
|
+
const contextValue = React.useContext(context);
|
20
|
+
const {
|
21
|
+
value: {
|
22
|
+
current: value
|
23
|
+
},
|
24
|
+
version: {
|
25
|
+
current: version
|
26
|
+
},
|
27
|
+
listeners
|
28
|
+
} = contextValue;
|
29
|
+
const selected = selector(value);
|
30
|
+
const [state, dispatch] = React.useReducer((prevState, payload) => {
|
31
|
+
if (!payload) {
|
32
|
+
// early bail out when is dispatched during render
|
33
|
+
return [value, selected];
|
46
34
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
|
36
|
+
if (payload[0] <= version) {
|
37
|
+
if (objectIs(prevState[1], selected)) {
|
38
|
+
return prevState; // bail out
|
39
|
+
}
|
40
|
+
|
41
|
+
return [value, selected];
|
42
|
+
}
|
43
|
+
|
44
|
+
try {
|
45
|
+
if (objectIs(prevState[0], payload[1])) {
|
46
|
+
return prevState; // do not update
|
47
|
+
}
|
48
|
+
|
49
|
+
const nextSelected = selector(payload[1]);
|
50
|
+
|
51
|
+
if (objectIs(prevState[1], nextSelected)) {
|
52
|
+
return prevState; // do not update
|
53
|
+
}
|
54
|
+
|
55
|
+
return [payload[1], nextSelected];
|
56
|
+
} catch (e) {// ignored (stale props or some other reason)
|
57
|
+
} // explicitly spread to enforce typing
|
58
|
+
|
59
|
+
|
60
|
+
return [prevState[0], prevState[1]]; // schedule update
|
61
|
+
}, [value, selected]);
|
62
|
+
|
63
|
+
if (!objectIs(state[1], selected)) {
|
64
|
+
// schedule re-render
|
65
|
+
// this is safe because it's self contained
|
66
|
+
dispatch(undefined);
|
67
|
+
}
|
68
|
+
|
69
|
+
react_utilities_1.useIsomorphicLayoutEffect(() => {
|
70
|
+
listeners.push(dispatch);
|
71
|
+
return () => {
|
72
|
+
const index = listeners.indexOf(dispatch);
|
73
|
+
listeners.splice(index, 1);
|
74
|
+
};
|
75
|
+
}, [listeners]);
|
76
|
+
return state[1];
|
55
77
|
};
|
78
|
+
|
56
79
|
exports.useContextSelector = useContextSelector;
|
57
80
|
/**
|
58
81
|
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
59
82
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
60
83
|
*/
|
61
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
85
|
+
|
62
86
|
function is(x, y) {
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
87
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
88
|
+
;
|
89
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
90
|
+
|
91
|
+
|
92
|
+
const objectIs = // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
69
93
|
// @ts-ignore fallback to native if it exists (not in IE11)
|
70
94
|
typeof Object.is === 'function' ? Object.is : is;
|
71
95
|
//# sourceMappingURL=useContextSelector.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useContextSelector.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAaA;;;;AAIG;;;AACI,MAAM,kBAAkB,GAAG,CAChC,OADgC,EAEhC,QAFgC,KAGf;AACjB,QAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;AAEA,QAAM;AACJ,IAAA,KAAK,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KADH;AAEJ,IAAA,OAAO,EAAE;AAAE,MAAA,OAAO,EAAE;AAAX,KAFL;AAGJ,IAAA;AAHI,MAIF,YAJJ;AAKA,QAAM,QAAQ,GAAG,QAAQ,CAAC,KAAD,CAAzB;AAEA,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,UAAN,CACxB,CACE,SADF,EAEE,OAFF,KAKqC;AACnC,QAAI,CAAC,OAAL,EAAc;AACZ;AACA,aAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;AACD;;AAED,QAAI,OAAO,CAAC,CAAD,CAAP,IAAc,OAAlB,EAA2B;AACzB,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,QAAf,CAAZ,EAAsC;AACpC,eAAO,SAAP,CADoC,CAClB;AACnB;;AAED,aAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;AACD;;AAED,QAAI;AACF,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,OAAO,CAAC,CAAD,CAAtB,CAAZ,EAAwC;AACtC,eAAO,SAAP,CADsC,CACpB;AACnB;;AAED,YAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAD,CAAR,CAA7B;;AAEA,UAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,YAAf,CAAZ,EAA0C;AACxC,eAAO,SAAP,CADwC,CACtB;AACnB;;AAED,aAAO,CAAC,OAAO,CAAC,CAAD,CAAR,EAAa,YAAb,CAAP;AACD,KAZD,CAYE,OAAO,CAAP,EAAU,CACV;AACD,KA5BkC,CA8BnC;;;AACA,WAAO,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,SAAS,CAAC,CAAD,CAAxB,CAAP,CA/BmC,CA+BW;AAC/C,GAtCuB,EAuCxB,CAAC,KAAD,EAAQ,QAAR,CAvCwB,CAA1B;;AA0CA,MAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAD,CAAN,EAAW,QAAX,CAAb,EAAmC;AACjC;AACA;AACA,IAAA,QAAQ,CAAC,SAAD,CAAR;AACD;;AAED,EAAA,iBAAA,CAAA,yBAAA,CAA0B,MAAK;AAC7B,IAAA,SAAS,CAAC,IAAV,CAAe,QAAf;AAEA,WAAO,MAAK;AACV,YAAM,KAAK,GAAG,SAAS,CAAC,OAAV,CAAkB,QAAlB,CAAd;AACA,MAAA,SAAS,CAAC,MAAV,CAAiB,KAAjB,EAAwB,CAAxB;AACD,KAHD;AAID,GAPD,EAOG,CAAC,SAAD,CAPH;AASA,SAAO,KAAK,CAAC,CAAD,CAAZ;AACD,CAvEM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB;AAyEb;;;AAGG;AACH;;AACA,SAAS,EAAT,CAAY,CAAZ,EAAoB,CAApB,EAA0B;AACxB,SACG,CAAC,KAAK,CAAN,KAAY,CAAC,KAAK,CAAN,IAAW,IAAI,CAAJ,KAAU,IAAI,CAArC,CAAD,IAA8C,CAAC,KAAK,CAAN,IAAW,CAAC,KAAK,CADjE,CACoE;AADpE;AAGD,C,CAED;;;AACA,MAAM,QAAQ,GACZ;AACA;AACA,OAAO,MAAM,CAAC,EAAd,KAAqB,UAArB,GAAkC,MAAM,CAAC,EAAzC,GAA8C,EAHhD","sourcesContent":["import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { Context, ContextSelector, ContextValue, ContextVersion } from './types';\n\n/**\n * Narrowing React.Reducer type to be more easily usable below.\n * No need to export this as it's for internal reducer usage.\n */\ntype ContextReducer<Value, SelectedValue> = React.Reducer<\n readonly [Value, SelectedValue],\n undefined | readonly [ContextVersion, Value]\n>;\n\n/**\n * This hook returns context selected value by selector.\n * It will only accept context created by `createContext`.\n * It will trigger re-render if only the selected value is referencially changed.\n */\nexport const useContextSelector = <Value, SelectedValue>(\n context: Context<Value>,\n selector: ContextSelector<Value, SelectedValue>,\n): SelectedValue => {\n const contextValue = React.useContext((context as unknown) as Context<ContextValue<Value>>);\n\n const {\n value: { current: value },\n version: { current: version },\n listeners,\n } = contextValue;\n const selected = selector(value);\n\n const [state, dispatch] = React.useReducer<ContextReducer<Value, SelectedValue>>(\n (\n prevState: readonly [Value /* contextValue */, SelectedValue /* selector(value) */],\n payload:\n | undefined // undefined from render below\n | readonly [ContextVersion, Value], // from provider effect\n ): readonly [Value, SelectedValue] => {\n if (!payload) {\n // early bail out when is dispatched during render\n return [value, selected] as const;\n }\n\n if (payload[0] <= version) {\n if (objectIs(prevState[1], selected)) {\n return prevState; // bail out\n }\n\n return [value, selected] as const;\n }\n\n try {\n if (objectIs(prevState[0], payload[1])) {\n return prevState; // do not update\n }\n\n const nextSelected = selector(payload[1]);\n\n if (objectIs(prevState[1], nextSelected)) {\n return prevState; // do not update\n }\n\n return [payload[1], nextSelected] as const;\n } catch (e) {\n // ignored (stale props or some other reason)\n }\n\n // explicitly spread to enforce typing\n return [prevState[0], prevState[1]] as const; // schedule update\n },\n [value, selected] as const,\n );\n\n if (!objectIs(state[1], selected)) {\n // schedule re-render\n // this is safe because it's self contained\n dispatch(undefined);\n }\n\n useIsomorphicLayoutEffect(() => {\n listeners.push(dispatch);\n\n return () => {\n const index = listeners.indexOf(dispatch);\n listeners.splice(index, 1);\n };\n }, [listeners]);\n\n return state[1] as SelectedValue;\n};\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction is(x: any, y: any) {\n return (\n (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst objectIs: (x: any, y: any) => boolean =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore fallback to native if it exists (not in IE11)\n typeof Object.is === 'function' ? Object.is : is;\n"],"sourceRoot":"../src/"}
|
@@ -1,7 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
3
6
|
exports.useHasParentContext = void 0;
|
4
|
-
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
5
9
|
/**
|
6
10
|
* Utility hook for contexts created by react-context-selector to determine if a parent context exists
|
7
11
|
* WARNING: This hook will not work for native React contexts
|
@@ -9,12 +13,17 @@ var React = require("react");
|
|
9
13
|
* @param context - context created by react-context-selector
|
10
14
|
* @returns whether the hook is wrapped by a parent context
|
11
15
|
*/
|
16
|
+
|
17
|
+
|
12
18
|
function useHasParentContext(context) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
const contextValue = React.useContext(context);
|
20
|
+
|
21
|
+
if (contextValue.version) {
|
22
|
+
return contextValue.version.current !== -1;
|
23
|
+
}
|
24
|
+
|
25
|
+
return false;
|
18
26
|
}
|
27
|
+
|
19
28
|
exports.useHasParentContext = useHasParentContext;
|
20
29
|
//# sourceMappingURL=useHasParentContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA;;;;;;AAMG;;;AACH,SAAgB,mBAAhB,CAA2C,OAA3C,EAAkE;AAChE,QAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;;AAEA,MAAI,YAAY,CAAC,OAAjB,EAA0B;AACxB,WAAO,YAAY,CAAC,OAAb,CAAqB,OAArB,KAAiC,CAAC,CAAzC;AACD;;AAED,SAAO,KAAP;AACD;;AARD,OAAA,CAAA,mBAAA,GAAA,mBAAA","sourcesContent":["import * as React from 'react';\nimport { Context, ContextValue } from './types';\n\n/**\n * Utility hook for contexts created by react-context-selector to determine if a parent context exists\n * WARNING: This hook will not work for native React contexts\n *\n * @param context - context created by react-context-selector\n * @returns whether the hook is wrapped by a parent context\n */\nexport function useHasParentContext<Value>(context: Context<Value>) {\n const contextValue = React.useContext((context as unknown) as Context<ContextValue<Value>>);\n\n if (contextValue.version) {\n return contextValue.version.current !== -1;\n }\n\n return false;\n}\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-context-selector",
|
3
|
-
"version": "9.0.0-
|
3
|
+
"version": "9.0.0-rc.3",
|
4
4
|
"description": "React useContextSelector hook in userland",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -17,9 +17,10 @@
|
|
17
17
|
"code-style": "just-scripts code-style",
|
18
18
|
"just": "just-scripts",
|
19
19
|
"lint": "just-scripts lint",
|
20
|
-
"test": "jest",
|
20
|
+
"test": "jest --passWithNoTests",
|
21
21
|
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
22
|
-
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-context-selector/src && yarn docs"
|
22
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-context-selector/src && yarn docs",
|
23
|
+
"type-check": "tsc -b tsconfig.json"
|
23
24
|
},
|
24
25
|
"devDependencies": {
|
25
26
|
"@fluentui/eslint-plugin": "*",
|
@@ -34,18 +35,17 @@
|
|
34
35
|
"react-test-renderer": "^16.3.0"
|
35
36
|
},
|
36
37
|
"dependencies": {
|
37
|
-
"@fluentui/react-utilities": "9.0.0-
|
38
|
+
"@fluentui/react-utilities": "9.0.0-rc.3",
|
38
39
|
"scheduler": "^0.20.1",
|
39
40
|
"tslib": "^2.1.0"
|
40
41
|
},
|
41
42
|
"peerDependencies": {
|
42
|
-
"@types/react": ">=16.8.0 <
|
43
|
-
"@types/react-dom": ">=16.8.0 <
|
44
|
-
"react": ">=16.8.0 <
|
45
|
-
"react-dom": ">=16.8.0 <
|
43
|
+
"@types/react": ">=16.8.0 <18.0.0",
|
44
|
+
"@types/react-dom": ">=16.8.0 <18.0.0",
|
45
|
+
"react": ">=16.8.0 <18.0.0",
|
46
|
+
"react-dom": ">=16.8.0 <18.0.0"
|
46
47
|
},
|
47
48
|
"beachball": {
|
48
|
-
"tag": "beta",
|
49
49
|
"disallowedChangeTypes": [
|
50
50
|
"major",
|
51
51
|
"minor",
|