@fluentui/react-context-selector 9.0.0-rc.9 → 9.0.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/CHANGELOG.json +66 -1
- package/CHANGELOG.md +26 -2
- package/dist/index.d.ts +20 -0
- package/lib/createContext.js +4 -0
- 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 +1 -0
- package/lib/useContextSelector.js.map +1 -1
- package/lib/useHasParentContext.js +1 -0
- package/lib/useHasParentContext.js.map +1 -1
- package/lib-commonjs/createContext.js +4 -0
- package/lib-commonjs/createContext.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/useContextSelector.js +1 -0
- package/lib-commonjs/useContextSelector.js.map +1 -1
- package/lib-commonjs/useHasParentContext.js +1 -0
- package/lib-commonjs/useHasParentContext.js.map +1 -1
- package/package.json +3 -5
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,72 @@
|
|
2
2
|
"name": "@fluentui/react-context-selector",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 28 Jun 2022 15:08:45 GMT",
|
6
|
+
"tag": "@fluentui/react-context-selector_v9.0.0",
|
7
|
+
"version": "9.0.0",
|
8
|
+
"comments": {
|
9
|
+
"prerelease": [
|
10
|
+
{
|
11
|
+
"author": "lingfangao@hotmail.com",
|
12
|
+
"package": "@fluentui/react-context-selector",
|
13
|
+
"commit": "2da4428ae7d6e464c538b7ed10e425ce0e531144",
|
14
|
+
"comment": "chore: Mark teams-prg owned APIs with @internal"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "lingfangao@hotmail.com",
|
18
|
+
"package": "@fluentui/react-context-selector",
|
19
|
+
"commit": "e0aabd850b15adf9c151ebd4e332f7c50ad6cfdf",
|
20
|
+
"comment": "Update 9.0.0-rc dependencies to use caret range"
|
21
|
+
}
|
22
|
+
],
|
23
|
+
"patch": [
|
24
|
+
{
|
25
|
+
"author": "lingfangao@hotmail.com",
|
26
|
+
"package": "@fluentui/react-context-selector",
|
27
|
+
"commit": "c7b1348bdad7aa883c29bfbc96ef2a32e6ebc7dd",
|
28
|
+
"comment": "feat: Initial 9.0.0 release"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"author": "beachball",
|
32
|
+
"package": "@fluentui/react-context-selector",
|
33
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0",
|
34
|
+
"commit": "ba6c5d651559b91c815429c9a9357c4d5a390f3e"
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"date": "Tue, 31 May 2022 21:28:50 GMT",
|
41
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-rc.10",
|
42
|
+
"version": "9.0.0-rc.10",
|
43
|
+
"comments": {
|
44
|
+
"prerelease": [
|
45
|
+
{
|
46
|
+
"author": "beachball",
|
47
|
+
"package": "@fluentui/react-context-selector",
|
48
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-rc.10",
|
49
|
+
"commit": "335ebfcfd47005003901b5e319782bfe9ccd89fd"
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"date": "Thu, 26 May 2022 21:01:25 GMT",
|
56
|
+
"tag": "@fluentui/react-context-selector_v9.0.0-rc.9",
|
57
|
+
"version": "9.0.0-rc.9",
|
58
|
+
"comments": {
|
59
|
+
"none": [
|
60
|
+
{
|
61
|
+
"author": "lingfangao@hotmail.com",
|
62
|
+
"package": "@fluentui/react-context-selector",
|
63
|
+
"commit": "fff6a012b8a3b165b364ef2c412b9edee0bc05a9",
|
64
|
+
"comment": "Add eslint ignore for context export"
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"date": "Mon, 23 May 2022 12:14:24 GMT",
|
6
71
|
"tag": "@fluentui/react-context-selector_v9.0.0-rc.9",
|
7
72
|
"version": "9.0.0-rc.9",
|
8
73
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
# Change Log - @fluentui/react-context-selector
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 28 Jun 2022 15:08:45 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0)
|
8
|
+
|
9
|
+
Tue, 28 Jun 2022 15:08:45 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-rc.10..@fluentui/react-context-selector_v9.0.0)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- feat: Initial 9.0.0 release ([PR #23733](https://github.com/microsoft/fluentui/pull/23733) by lingfangao@hotmail.com)
|
15
|
+
- Bump @fluentui/react-utilities to v9.0.0 ([commit](https://github.com/microsoft/fluentui/commit/ba6c5d651559b91c815429c9a9357c4d5a390f3e) by beachball)
|
16
|
+
|
17
|
+
### Changes
|
18
|
+
|
19
|
+
- chore: Mark teams-prg owned APIs with @internal ([PR #23689](https://github.com/microsoft/fluentui/pull/23689) by lingfangao@hotmail.com)
|
20
|
+
- Update 9.0.0-rc dependencies to use caret range ([PR #23732](https://github.com/microsoft/fluentui/pull/23732) by lingfangao@hotmail.com)
|
21
|
+
|
22
|
+
## [9.0.0-rc.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-rc.10)
|
23
|
+
|
24
|
+
Tue, 31 May 2022 21:28:50 GMT
|
25
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-rc.9..@fluentui/react-context-selector_v9.0.0-rc.10)
|
26
|
+
|
27
|
+
### Changes
|
28
|
+
|
29
|
+
- Bump @fluentui/react-utilities to v9.0.0-rc.10 ([PR #23325](https://github.com/microsoft/fluentui/pull/23325) by beachball)
|
30
|
+
|
7
31
|
## [9.0.0-rc.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-rc.9)
|
8
32
|
|
9
|
-
Mon, 23 May 2022 12:
|
33
|
+
Mon, 23 May 2022 12:14:24 GMT
|
10
34
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-rc.8..@fluentui/react-context-selector_v9.0.0-rc.9)
|
11
35
|
|
12
36
|
### Changes
|
package/dist/index.d.ts
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
import * as React_2 from 'react';
|
2
2
|
|
3
|
+
/**
|
4
|
+
* @internal
|
5
|
+
*/
|
3
6
|
export declare type Context<Value> = React_2.Context<Value> & {
|
4
7
|
Provider: React_2.FC<React_2.ProviderProps<Value>>;
|
5
8
|
Consumer: never;
|
6
9
|
};
|
7
10
|
|
11
|
+
/**
|
12
|
+
* @internal
|
13
|
+
*/
|
8
14
|
export declare type ContextSelector<Value, SelectedValue> = (value: Value) => SelectedValue;
|
9
15
|
|
16
|
+
/**
|
17
|
+
* @internal
|
18
|
+
*/
|
10
19
|
export declare type ContextValue<Value> = {
|
11
20
|
/** Holds a set of subscribers from components. */
|
12
21
|
listeners: ((payload: readonly [ContextVersion, Value]) => void)[];
|
@@ -16,16 +25,26 @@ export declare type ContextValue<Value> = {
|
|
16
25
|
version: React_2.MutableRefObject<ContextVersion>;
|
17
26
|
};
|
18
27
|
|
28
|
+
/**
|
29
|
+
* @internal
|
30
|
+
*/
|
19
31
|
export declare type ContextValues<Value> = ContextValue<Value> & {
|
20
32
|
/** List of listners to publish changes */
|
21
33
|
listeners: ((payload: readonly [ContextVersion, Record<string, Value>]) => void)[];
|
22
34
|
};
|
23
35
|
|
36
|
+
/**
|
37
|
+
* @internal
|
38
|
+
*/
|
24
39
|
export declare type ContextVersion = number;
|
25
40
|
|
41
|
+
/**
|
42
|
+
* @internal
|
43
|
+
*/
|
26
44
|
export declare const createContext: <Value>(defaultValue: Value) => Context<Value>;
|
27
45
|
|
28
46
|
/**
|
47
|
+
* @internal
|
29
48
|
* This hook returns context selected value by selector.
|
30
49
|
* It will only accept context created by `createContext`.
|
31
50
|
* It will trigger re-render if only the selected value is referencially changed.
|
@@ -33,6 +52,7 @@ export declare const createContext: <Value>(defaultValue: Value) => Context<Valu
|
|
33
52
|
export declare const useContextSelector: <Value, SelectedValue>(context: Context<Value>, selector: ContextSelector<Value, SelectedValue>) => SelectedValue;
|
34
53
|
|
35
54
|
/**
|
55
|
+
* @internal
|
36
56
|
* Utility hook for contexts created by react-context-selector to determine if a parent context exists
|
37
57
|
* WARNING: This hook will not work for native React contexts
|
38
58
|
*
|
package/lib/createContext.js
CHANGED
package/lib/createContext.js.map
CHANGED
@@ -1 +1 @@
|
|
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;
|
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;EAC9E,MAAM,QAAQ,GAAyC,KAAK,IAAG;IAC7D;IACA,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAK,CAAC,KAAnB,CAAjB,CAF6D,CAG7D;;IACA,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAAa,CAAb,CAAnB,CAJ6D,CAM7D;;IACA,MAAM,YAAY,GAAG,KAAK,CAAC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hD;EAEA,OAAQ,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\n/**\n * @internal\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":"../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","sourcesContent":["export { createContext } from './createContext';\nexport { useContextSelector } from './useContextSelector';\nexport { useHasParentContext } from './useHasParentContext';\nexport type { Context, ContextSelector, ContextValue, ContextValues, ContextVersion } from './types';\n"]}
|
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","sourcesContent":["export { createContext } from './createContext';\nexport { useContextSelector } from './useContextSelector';\nexport { useHasParentContext } from './useHasParentContext';\n// eslint-disable-next-line @fluentui/ban-context-export\nexport type { Context, ContextSelector, ContextValue, ContextValues, ContextVersion } from './types';\n"]}
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
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"]}
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport type Context<Value> = React.Context<Value> & {\n Provider: React.FC<React.ProviderProps<Value>>;\n Consumer: never;\n};\n\n/**\n * @internal\n */\nexport type ContextSelector<Value, SelectedValue> = (value: Value) => SelectedValue;\n\n/**\n * @internal\n */\nexport type ContextVersion = number;\n\n/**\n * @internal\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\n/**\n * @internal\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"]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
|
2
2
|
import * as React from 'react';
|
3
3
|
/**
|
4
|
+
* @internal
|
4
5
|
* This hook returns context selected value by selector.
|
5
6
|
* It will only accept context created by `createContext`.
|
6
7
|
* It will trigger re-render if only the selected value is referencially changed.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useContextSelector.ts"],"names":[],"mappings":"AAAA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAaA
|
1
|
+
{"version":3,"sources":["useContextSelector.ts"],"names":[],"mappings":"AAAA,SAAS,yBAAT,QAA0C,2BAA1C;AACA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAaA;;;;;AAKG;;AACH,OAAO,MAAM,kBAAkB,GAAG,CAChC,OADgC,EAEhC,QAFgC,KAGf;EACjB,MAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;EAEA,MAAM;IACJ,KAAK,EAAE;MAAE,OAAO,EAAE;IA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;IACA,QAAQ,CAAC,SAAD,CAAR;EACD;;EAED,yBAAyB,CAAC,MAAK;IAC7B,SAAS,CAAC,IAAV,CAAe,QAAf;IAEA,OAAO,MAAK;MACV,MAAM,KAAK,GAAG,SAAS,CAAC,OAAV,CAAkB,QAAlB,CAAd;MACA,SAAS,CAAC,MAAV,CAAiB,KAAjB,EAAwB,CAAxB;IACD,CAHD;EAID,CAPwB,EAOtB,CAAC,SAAD,CAPsB,CAAzB;EASA,OAAO,KAAK,CAAC,CAAD,CAAZ;AACD,CAvEM;AAyEP;;;AAGG;AACH;;AACA,SAAS,EAAT,CAAY,CAAZ,EAAoB,CAApB,EAA0B;EACxB,OACG,CAAC,KAAK,CAAN,KAAY,CAAC,KAAK,CAAN,IAAW,IAAI,CAAJ,KAAU,IAAI,CAArC,CAAD,IAA8C,CAAC,KAAK,CAAN,IAAW,CAAC,KAAK,CADjE,CACoE;EADpE;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 * @internal\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 +1 @@
|
|
1
|
-
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA
|
1
|
+
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA;;;;;;;AAOG;;AACH,OAAM,SAAU,mBAAV,CAAqC,OAArC,EAA4D;EAChE,MAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;;EAEA,IAAI,YAAY,CAAC,OAAjB,EAA0B;IACxB,OAAO,YAAY,CAAC,OAAb,CAAqB,OAArB,KAAiC,CAAC,CAAzC;EACD;;EAED,OAAO,KAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { Context, ContextValue } from './types';\n\n/**\n * @internal\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 +1 @@
|
|
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;
|
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;EAC9E,MAAM,QAAQ,GAAyC,KAAK,IA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AE;IAAX,CADgD;IAEvD,OAAO,EAAE;MAAE,OAAO,EAAE,CAAC;IAAZ,CAF8C;IAGvD,SAAS,EAAE;EAH4C,CAAzC,CAAhB;EAMA,OAAO,CAAC,QAAR,GAAmB,cAAc,CAAQ,OAAO,CAAC,QAAhB,CAAjC,CAP0E,CAS1E;;EACA,OAAS,OAAsC,CAAC,QAAhD;EAEA,OAAQ,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\n/**\n * @internal\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/"}
|
@@ -1 +1 @@
|
|
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;
|
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;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,eAAA,CAAA,aAAA;EAAa;AAAb,CAAA;;AACT,IAAA,oBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,oBAAA,CAAA,kBAAA;EAAkB;AAAlB,CAAA;;AACT,IAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,qBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,qBAAA,CAAA,mBAAA;EAAmB;AAAnB,CAAA","sourcesContent":["export { createContext } from './createContext';\nexport { useContextSelector } from './useContextSelector';\nexport { useHasParentContext } from './useHasParentContext';\n// eslint-disable-next-line @fluentui/ban-context-export\nexport type { Context, ContextSelector, ContextValue, ContextValues, ContextVersion } from './types';\n"],"sourceRoot":"../src/"}
|
@@ -9,6 +9,7 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
9
|
|
10
10
|
const React = /*#__PURE__*/require("react");
|
11
11
|
/**
|
12
|
+
* @internal
|
12
13
|
* This hook returns context selected value by selector.
|
13
14
|
* It will only accept context created by `createContext`.
|
14
15
|
* It will trigger re-render if only the selected value is referencially changed.
|
@@ -1 +1 @@
|
|
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
|
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;;;;;AAKG;;;AACI,MAAM,kBAAkB,GAAG,CAChC,OADgC,EAEhC,QAFgC,KAGf;EACjB,MAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;EAEA,MAAM;IACJ,KAAK,EAAE;MAAE,OAAO,EAAE;IAAX,CADH;IAEJ,OAAO,EAAE;MAAE,OAAO,EAAE;IAAX,CAFL;IAGJ;EAHI,IAIF,YAJJ;EAKA,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAD,CAAzB;EAEA,MAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,UAAN,CACxB,CACE,SADF,EAEE,OAFF,KAKqC;IACnC,IAAI,CAAC,OAAL,EAAc;MACZ;MACA,OAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;IACD;;IAED,IAAI,OAAO,CAAC,CAAD,CAAP,IAAc,OAAlB,EAA2B;MACzB,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAD,CAAV,EAAe,QAAf,CAAZ,EAAsC;QACpC,OAAO,SAAP,CADoC,CAClB;MACnB;;MAED,OAAO,CAAC,KAAD,EAAQ,QAAR,CAAP;IACD;;IAED,IAAI;MACF,IAAI,QAAQ,CAAC,SAAS,CAAC,CAA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,KAAK,CADjE,CACoE;EADpE;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 * @internal\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/"}
|
@@ -7,6 +7,7 @@ exports.useHasParentContext = void 0;
|
|
7
7
|
|
8
8
|
const React = /*#__PURE__*/require("react");
|
9
9
|
/**
|
10
|
+
* @internal
|
10
11
|
* Utility hook for contexts created by react-context-selector to determine if a parent context exists
|
11
12
|
* WARNING: This hook will not work for native React contexts
|
12
13
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA
|
1
|
+
{"version":3,"sources":["useHasParentContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAGA;;;;;;;AAOG;;;AACH,SAAgB,mBAAhB,CAA2C,OAA3C,EAAkE;EAChE,MAAM,YAAY,GAAG,KAAK,CAAC,UAAN,CAAkB,OAAlB,CAArB;;EAEA,IAAI,YAAY,CAAC,OAAjB,EAA0B;IACxB,OAAO,YAAY,CAAC,OAAb,CAAqB,OAArB,KAAiC,CAAC,CAAzC;EACD;;EAED,OAAO,KAAP;AACD;;AARD,OAAA,CAAA,mBAAA,GAAA,mBAAA","sourcesContent":["import * as React from 'react';\nimport { Context, ContextValue } from './types';\n\n/**\n * @internal\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",
|
4
4
|
"description": "React useContextSelector hook in userland",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"@fluentui/scripts": "^1.0.0"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@fluentui/react-utilities": "9.0.0
|
30
|
+
"@fluentui/react-utilities": "^9.0.0",
|
31
31
|
"tslib": "^2.1.0"
|
32
32
|
},
|
33
33
|
"peerDependencies": {
|
@@ -39,9 +39,7 @@
|
|
39
39
|
},
|
40
40
|
"beachball": {
|
41
41
|
"disallowedChangeTypes": [
|
42
|
-
"major"
|
43
|
-
"minor",
|
44
|
-
"patch"
|
42
|
+
"major"
|
45
43
|
]
|
46
44
|
},
|
47
45
|
"exports": {
|