@fluentui/react-provider 9.9.0 → 9.10.1

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 CHANGED
@@ -2,23 +2,160 @@
2
2
  "name": "@fluentui/react-provider",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 20 Sep 2023 14:13:57 GMT",
6
- "tag": "@fluentui/react-provider_v9.9.0",
7
- "version": "9.9.0",
5
+ "date": "Tue, 26 Sep 2023 17:44:15 GMT",
6
+ "tag": "@fluentui/react-provider_v9.10.1",
7
+ "version": "9.10.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "yuanboxue@microsoft.com",
12
+ "package": "@fluentui/react-provider",
13
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d",
14
+ "comment": "chore: trigger manual version bump after broken release"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-provider",
19
+ "comment": "Bump @fluentui/react-shared-contexts to v9.9.1",
20
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-provider",
25
+ "comment": "Bump @fluentui/react-tabster to v9.13.1",
26
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-provider",
31
+ "comment": "Bump @fluentui/react-theme to v9.1.14",
32
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-provider",
37
+ "comment": "Bump @fluentui/react-utilities to v9.13.5",
38
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-provider",
43
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.12",
44
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Tue, 26 Sep 2023 15:31:51 GMT",
51
+ "tag": "@fluentui/react-provider_v9.10.0",
52
+ "version": "9.10.0",
8
53
  "comments": {
54
+ "patch": [
55
+ {
56
+ "author": "martinhochel@microsoft.com",
57
+ "package": "@fluentui/react-provider",
58
+ "commit": "e61473fa10195f6ebf2308205c1e72e91b711831",
59
+ "comment": "fix: bump swc core to mitigate transpilation memory leaks"
60
+ },
61
+ {
62
+ "author": "ololubek@microsoft.com",
63
+ "package": "@fluentui/react-provider",
64
+ "commit": "a31e7394d9f169bc5aa55430a22cdc65425a1b49",
65
+ "comment": "chore: Update react-icons version to pick up IconDirectionContextProvider updated export"
66
+ }
67
+ ],
9
68
  "minor": [
10
69
  {
11
- "author": "marcosvmmoura@gmail.com",
70
+ "author": "yuanboxue@microsoft.com",
12
71
  "package": "@fluentui/react-provider",
13
- "commit": "921694374c78c37ecf18d7bb99000bb0bb67551b",
14
- "comment": "feat: add custom styling hooks for Drawer subcomponents"
72
+ "commit": "45ab251870368226b02c57882e8f7ca0deb86c8f",
73
+ "comment": "feat: add custom style hooks for tag components"
74
+ },
75
+ {
76
+ "author": "beachball",
77
+ "package": "@fluentui/react-provider",
78
+ "comment": "Bump @fluentui/react-shared-contexts to v9.9.0",
79
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
80
+ },
81
+ {
82
+ "author": "beachball",
83
+ "package": "@fluentui/react-provider",
84
+ "comment": "Bump @fluentui/react-tabster to v9.13.0",
85
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
86
+ },
87
+ {
88
+ "author": "beachball",
89
+ "package": "@fluentui/react-provider",
90
+ "comment": "Bump @fluentui/react-theme to v9.1.13",
91
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
92
+ },
93
+ {
94
+ "author": "beachball",
95
+ "package": "@fluentui/react-provider",
96
+ "comment": "Bump @fluentui/react-utilities to v9.13.4",
97
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
98
+ },
99
+ {
100
+ "author": "beachball",
101
+ "package": "@fluentui/react-provider",
102
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.11",
103
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
104
+ }
105
+ ]
106
+ }
107
+ },
108
+ {
109
+ "date": "Wed, 20 Sep 2023 17:47:41 GMT",
110
+ "tag": "@fluentui/react-provider_v9.9.1",
111
+ "version": "9.9.1",
112
+ "comments": {
113
+ "patch": [
114
+ {
115
+ "author": "martinhochel@microsoft.com",
116
+ "package": "@fluentui/react-provider",
117
+ "commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0",
118
+ "comment": "chore: trigger manual version bump after broken release"
119
+ },
120
+ {
121
+ "author": "beachball",
122
+ "package": "@fluentui/react-provider",
123
+ "comment": "Bump @fluentui/react-shared-contexts to v9.8.1",
124
+ "commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
125
+ },
126
+ {
127
+ "author": "beachball",
128
+ "package": "@fluentui/react-provider",
129
+ "comment": "Bump @fluentui/react-tabster to v9.12.11",
130
+ "commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
15
131
  },
132
+ {
133
+ "author": "beachball",
134
+ "package": "@fluentui/react-provider",
135
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.10",
136
+ "commit": "41d0ed0376ad79f1f5f5c4c7487515a1c6be35f0"
137
+ }
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ "date": "Wed, 20 Sep 2023 14:59:51 GMT",
143
+ "tag": "@fluentui/react-provider_v9.9.0",
144
+ "version": "9.9.0",
145
+ "comments": {
146
+ "minor": [
16
147
  {
17
148
  "author": "olfedias@microsoft.com",
18
149
  "package": "@fluentui/react-provider",
19
150
  "commit": "48153fef6aa6ba63abfdfad25fb76dea13395b94",
20
151
  "comment": "feat: add createCSSRuleFromTheme() to create CSS from themes"
21
152
  },
153
+ {
154
+ "author": "marcosvmmoura@gmail.com",
155
+ "package": "@fluentui/react-provider",
156
+ "commit": "921694374c78c37ecf18d7bb99000bb0bb67551b",
157
+ "comment": "feat: add custom styling hooks for Drawer subcomponents"
158
+ },
22
159
  {
23
160
  "author": "beachball",
24
161
  "package": "@fluentui/react-provider",
package/CHANGELOG.md CHANGED
@@ -1,18 +1,63 @@
1
1
  # Change Log - @fluentui/react-provider
2
2
 
3
- This log was last generated on Wed, 20 Sep 2023 14:13:57 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 26 Sep 2023 17:44:15 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.10.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-provider_v9.10.1)
8
+
9
+ Tue, 26 Sep 2023 17:44:15 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-provider_v9.10.0..@fluentui/react-provider_v9.10.1)
11
+
12
+ ### Patches
13
+
14
+ - chore: trigger manual version bump after broken release ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by yuanboxue@microsoft.com)
15
+ - Bump @fluentui/react-shared-contexts to v9.9.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
16
+ - Bump @fluentui/react-tabster to v9.13.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
17
+ - Bump @fluentui/react-theme to v9.1.14 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
18
+ - Bump @fluentui/react-utilities to v9.13.5 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
19
+ - Bump @fluentui/react-jsx-runtime to v9.0.12 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
20
+
21
+ ## [9.10.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-provider_v9.10.0)
22
+
23
+ Tue, 26 Sep 2023 15:31:51 GMT
24
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-provider_v9.9.1..@fluentui/react-provider_v9.10.0)
25
+
26
+ ### Minor changes
27
+
28
+ - feat: add custom style hooks for tag components ([PR #29237](https://github.com/microsoft/fluentui/pull/29237) by yuanboxue@microsoft.com)
29
+ - Bump @fluentui/react-shared-contexts to v9.9.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
30
+ - Bump @fluentui/react-tabster to v9.13.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
31
+ - Bump @fluentui/react-theme to v9.1.13 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
32
+ - Bump @fluentui/react-utilities to v9.13.4 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
33
+ - Bump @fluentui/react-jsx-runtime to v9.0.11 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
34
+
35
+ ### Patches
36
+
37
+ - fix: bump swc core to mitigate transpilation memory leaks ([PR #29253](https://github.com/microsoft/fluentui/pull/29253) by martinhochel@microsoft.com)
38
+ - chore: Update react-icons version to pick up IconDirectionContextProvider updated export ([PR #29151](https://github.com/microsoft/fluentui/pull/29151) by ololubek@microsoft.com)
39
+
40
+ ## [9.9.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-provider_v9.9.1)
41
+
42
+ Wed, 20 Sep 2023 17:47:41 GMT
43
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-provider_v9.9.0..@fluentui/react-provider_v9.9.1)
44
+
45
+ ### Patches
46
+
47
+ - chore: trigger manual version bump after broken release ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by martinhochel@microsoft.com)
48
+ - Bump @fluentui/react-shared-contexts to v9.8.1 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
49
+ - Bump @fluentui/react-tabster to v9.12.11 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
50
+ - Bump @fluentui/react-jsx-runtime to v9.0.10 ([PR #29197](https://github.com/microsoft/fluentui/pull/29197) by beachball)
51
+
7
52
  ## [9.9.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-provider_v9.9.0)
8
53
 
9
- Wed, 20 Sep 2023 14:13:57 GMT
54
+ Wed, 20 Sep 2023 14:59:51 GMT
10
55
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-provider_v9.8.5..@fluentui/react-provider_v9.9.0)
11
56
 
12
57
  ### Minor changes
13
58
 
14
- - feat: add custom styling hooks for Drawer subcomponents ([PR #29041](https://github.com/microsoft/fluentui/pull/29041) by marcosvmmoura@gmail.com)
15
59
  - feat: add createCSSRuleFromTheme() to create CSS from themes ([PR #29052](https://github.com/microsoft/fluentui/pull/29052) by olfedias@microsoft.com)
60
+ - feat: add custom styling hooks for Drawer subcomponents ([PR #29041](https://github.com/microsoft/fluentui/pull/29041) by marcosvmmoura@gmail.com)
16
61
  - Bump @fluentui/react-shared-contexts to v9.8.0 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
17
62
  - Bump @fluentui/react-tabster to v9.12.10 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
18
63
  - Bump @fluentui/react-jsx-runtime to v9.0.9 ([PR #29193](https://github.com/microsoft/fluentui/pull/29193) by beachball)
package/dist/index.d.ts CHANGED
@@ -116,6 +116,11 @@ export declare const FluentProvider: React_2.ForwardRefExoticComponent<Omit<Comp
116
116
  useDrawerHeaderTitleStyles_unstable: (state: unknown) => void;
117
117
  useDrawerBodyStyles_unstable: (state: unknown) => void;
118
118
  useDrawerFooterStyles_unstable: (state: unknown) => void;
119
+ useInteractionTagStyles_unstable: (state: unknown) => void;
120
+ useInteractionTagPrimaryStyles_unstable: (state: unknown) => void;
121
+ useInteractionTagSecondaryStyles_unstable: (state: unknown) => void;
122
+ useTagStyles_unstable: (state: unknown) => void;
123
+ useTagGroupStyles_unstable: (state: unknown) => void;
119
124
  }> | undefined;
120
125
  dir?: "ltr" | "rtl" | undefined;
121
126
  targetDocument?: Document | undefined;
@@ -69,9 +69,8 @@ const insertSheet = (tag, rule)=>{
69
69
  }
70
70
  useHandleSSRStyleElements(targetDocument, styleTagId);
71
71
  useInsertionEffect(()=>{
72
- var _targetDocument;
73
72
  // The style element could already have been created during SSR - no need to recreate it
74
- const ssrStyleElement = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.getElementById(styleTagId);
73
+ const ssrStyleElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.getElementById(styleTagId);
75
74
  if (ssrStyleElement) {
76
75
  styleTag.current = ssrStyleElement;
77
76
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["useFluentProviderThemeStyleTag.ts"],"sourcesContent":["import { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { createCSSRuleFromTheme } from './createCSSRuleFromTheme';\nimport type { FluentProviderState } from './FluentProvider.types';\nimport { fluentProviderClassNames } from './useFluentProviderStyles.styles';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nconst createStyleTag = (target: Document | undefined, elementAttributes: Record<string, string>) => {\n if (!target) {\n return undefined;\n }\n\n const tag = target.createElement('style');\n\n Object.keys(elementAttributes).forEach(attrName => {\n tag.setAttribute(attrName, elementAttributes[attrName]);\n });\n\n target.head.appendChild(tag);\n return tag;\n};\n\nconst insertSheet = (tag: HTMLStyleElement, rule: string) => {\n const sheet = tag.sheet;\n\n if (sheet) {\n if (sheet.cssRules.length > 0) {\n sheet.deleteRule(0);\n }\n sheet.insertRule(rule, 0);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('FluentProvider: No sheet available on styleTag, styles will not be inserted into DOM.');\n }\n};\n\n/**\n * Writes a theme as css variables in a style tag on the provided targetDocument as a rule applied to a CSS class\n * @internal\n * @returns CSS class to apply the rule\n */\nexport const useFluentProviderThemeStyleTag = (\n options: Pick<FluentProviderState, 'theme' | 'targetDocument'> & { rendererAttributes: Record<string, string> },\n) => {\n const { targetDocument, theme, rendererAttributes } = options;\n\n const styleTag = React.useRef<HTMLStyleElement | undefined | null>();\n\n const styleTagId = useId(fluentProviderClassNames.root);\n const styleElementAttributes = rendererAttributes;\n\n const rule = React.useMemo(() => createCSSRuleFromTheme(`.${styleTagId}`, theme), [theme, styleTagId]);\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // Heads up!\n // .useMemo() is used because it is called during render and DOM for _current_ component is not mounted yet. Also,\n // this allows to do checks with strict mode enabled as .useEffect() will be called with incremented IDs because\n // of double render.\n\n if (targetDocument) {\n const providerSelector = `.${fluentProviderClassNames.root}.${styleTagId}`;\n const providerElements = targetDocument.querySelectorAll(providerSelector);\n\n // In SSR, we will have DOM upfront. To avoid false positives the check on nested style tag is performed\n const isSSR = targetDocument.querySelector(`${providerSelector} > style[id=\"${styleTagId}\"]`) !== null;\n const elementsCount = isSSR ? 1 : 0;\n\n if (providerElements.length > elementsCount) {\n // eslint-disable-next-line no-console\n console.error(\n [\n '@fluentui/react-provider: There are conflicting ids in your DOM.',\n 'Please make sure that you configured your application properly.',\n '\\n',\n '\\n',\n 'Configuration guide: https://aka.ms/fluentui-conflicting-ids',\n ].join(' '),\n );\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n useHandleSSRStyleElements(targetDocument, styleTagId);\n useInsertionEffect(() => {\n // The style element could already have been created during SSR - no need to recreate it\n const ssrStyleElement = targetDocument?.getElementById(styleTagId);\n if (ssrStyleElement) {\n styleTag.current = ssrStyleElement as HTMLStyleElement;\n } else {\n styleTag.current = createStyleTag(targetDocument, { ...styleElementAttributes, id: styleTagId });\n if (styleTag.current) {\n insertSheet(styleTag.current, rule);\n }\n }\n\n return () => {\n styleTag.current?.remove();\n };\n }, [styleTagId, targetDocument, rule, styleElementAttributes]);\n\n return { styleTagId, rule };\n};\n\nfunction useHandleSSRStyleElements(targetDocument: Document | undefined | null, styleTagId: string) {\n // Using a state factory so that this logic only runs once per render\n // Each FluentProvider can create its own style element during SSR as a slot\n // Moves all theme style elements to document head during render to avoid hydration errors.\n // Should be strict mode safe since the logic is idempotent.\n React.useState(() => {\n if (!targetDocument) {\n return;\n }\n\n const themeStyleElement = targetDocument.getElementById(styleTagId);\n if (themeStyleElement) {\n targetDocument.head.append(themeStyleElement);\n }\n });\n}\n"],"names":["useId","useIsomorphicLayoutEffect","React","createCSSRuleFromTheme","fluentProviderClassNames","useInsertionEffect","createStyleTag","target","elementAttributes","undefined","tag","createElement","Object","keys","forEach","attrName","setAttribute","head","appendChild","insertSheet","rule","sheet","cssRules","length","deleteRule","insertRule","process","env","NODE_ENV","console","error","useFluentProviderThemeStyleTag","options","targetDocument","theme","rendererAttributes","styleTag","useRef","styleTagId","root","styleElementAttributes","useMemo","providerSelector","providerElements","querySelectorAll","isSSR","querySelector","elementsCount","join","useHandleSSRStyleElements","ssrStyleElement","getElementById","current","id","remove","useState","themeStyleElement","append"],"mappings":"AAAA,SAASA,KAAK,EAAEC,yBAAyB,QAAQ,4BAA4B;AAC7E,YAAYC,WAAW,QAAQ;AAE/B,SAASC,sBAAsB,QAAQ,2BAA2B;AAElE,SAASC,wBAAwB,QAAQ,mCAAmC;AAE5E,4FAA4F;AAC5F,MAAMC,qBAAqB,AAACH,KAAe,CAAC,iBAAiB,SAAS,GAClE,AAACA,KAAe,CAAC,iBAAiB,SAAS,GAC3CD;AAEJ,MAAMK,iBAAiB,CAACC,QAA8BC;IACpD,IAAI,CAACD,QAAQ;QACX,OAAOE;IACT;IAEA,MAAMC,MAAMH,OAAOI,aAAa,CAAC;IAEjCC,OAAOC,IAAI,CAACL,mBAAmBM,OAAO,CAACC,CAAAA;QACrCL,IAAIM,YAAY,CAACD,UAAUP,iBAAiB,CAACO,SAAS;IACxD;IAEAR,OAAOU,IAAI,CAACC,WAAW,CAACR;IACxB,OAAOA;AACT;AAEA,MA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wBACA;wBACA;qBACD,CAACkB,IAAI,CAAC;gBAEX;YACF;QACA,uDAAuD;QACzD,GAAG,EAAE;IACP;IAEAC,0BAA0BhB,gBAAgBK;IAC1CjC,mBAAmB;YAEO4B;QADxB,wFAAwF;QACxF,MAAMiB,mBAAkBjB,kBAAAA,4BAAAA,sCAAAA,gBAAgBkB,cAAc,CAACb;QACvD,IAAIY,iBAAiB;YACnBd,SAASgB,OAAO,GAAGF;QACrB,OAAO;YACLd,SAASgB,OAAO,GAAG9C,eAAe2B,gBAAgB;gBAAE,GAAGO,sBAAsB;gBAAEa,IAAIf;YAAW;YAC9F,IAAIF,SAASgB,OAAO,EAAE;gBACpBjC,YAAYiB,SAASgB,OAAO,EAAEhC;YAChC;QACF;QAEA,OAAO;gBACLgB;aAAAA,oBAAAA,SAASgB,OAAO,cAAhBhB,wCAAAA,kBAAkBkB,MAAM;QAC1B;IACF,GAAG;QAAChB;QAAYL;QAAgBb;QAAMoB;KAAuB;IAE7D,OAAO;QAAEF;QAAYlB;IAAK;AAC5B,EAAE;AAEF,SAAS6B,0BAA0BhB,cAA2C,EAAEK,UAAkB;IAChG,qEAAqE;IACrE,4EAA4E;IAC5E,2FAA2F;IAC3F,4DAA4D;IAC5DpC,MAAMqD,QAAQ,CAAC;QACb,IAAI,CAACtB,gBAAgB;YACnB;QACF;QAEA,MAAMuB,oBAAoBvB,eAAekB,cAAc,CAACb;QACxD,IAAIkB,mBAAmB;YACrBvB,eAAehB,IAAI,CAACwC,MAAM,CAACD;QAC7B;IACF;AACF"}
1
+ {"version":3,"sources":["useFluentProviderThemeStyleTag.ts"],"sourcesContent":["import { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport { createCSSRuleFromTheme } from './createCSSRuleFromTheme';\nimport type { FluentProviderState } from './FluentProvider.types';\nimport { fluentProviderClassNames } from './useFluentProviderStyles.styles';\n\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = (React as never)['useInsertion' + 'Effect']\n ? (React as never)['useInsertion' + 'Effect']\n : useIsomorphicLayoutEffect;\n\nconst createStyleTag = (target: Document | undefined, elementAttributes: Record<string, string>) => {\n if (!target) {\n return undefined;\n }\n\n const tag = target.createElement('style');\n\n Object.keys(elementAttributes).forEach(attrName => {\n tag.setAttribute(attrName, elementAttributes[attrName]);\n });\n\n target.head.appendChild(tag);\n return tag;\n};\n\nconst insertSheet = (tag: HTMLStyleElement, rule: string) => {\n const sheet = tag.sheet;\n\n if (sheet) {\n if (sheet.cssRules.length > 0) {\n sheet.deleteRule(0);\n }\n sheet.insertRule(rule, 0);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('FluentProvider: No sheet available on styleTag, styles will not be inserted into DOM.');\n }\n};\n\n/**\n * Writes a theme as css variables in a style tag on the provided targetDocument as a rule applied to a CSS class\n * @internal\n * @returns CSS class to apply the rule\n */\nexport const useFluentProviderThemeStyleTag = (\n options: Pick<FluentProviderState, 'theme' | 'targetDocument'> & { rendererAttributes: Record<string, string> },\n) => {\n const { targetDocument, theme, rendererAttributes } = options;\n\n const styleTag = React.useRef<HTMLStyleElement | undefined | null>();\n\n const styleTagId = useId(fluentProviderClassNames.root);\n const styleElementAttributes = rendererAttributes;\n\n const rule = React.useMemo(() => createCSSRuleFromTheme(`.${styleTagId}`, theme), [theme, styleTagId]);\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(() => {\n // Heads up!\n // .useMemo() is used because it is called during render and DOM for _current_ component is not mounted yet. Also,\n // this allows to do checks with strict mode enabled as .useEffect() will be called with incremented IDs because\n // of double render.\n\n if (targetDocument) {\n const providerSelector = `.${fluentProviderClassNames.root}.${styleTagId}`;\n const providerElements = targetDocument.querySelectorAll(providerSelector);\n\n // In SSR, we will have DOM upfront. To avoid false positives the check on nested style tag is performed\n const isSSR = targetDocument.querySelector(`${providerSelector} > style[id=\"${styleTagId}\"]`) !== null;\n const elementsCount = isSSR ? 1 : 0;\n\n if (providerElements.length > elementsCount) {\n // eslint-disable-next-line no-console\n console.error(\n [\n '@fluentui/react-provider: There are conflicting ids in your DOM.',\n 'Please make sure that you configured your application properly.',\n '\\n',\n '\\n',\n 'Configuration guide: https://aka.ms/fluentui-conflicting-ids',\n ].join(' '),\n );\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n useHandleSSRStyleElements(targetDocument, styleTagId);\n useInsertionEffect(() => {\n // The style element could already have been created during SSR - no need to recreate it\n const ssrStyleElement = targetDocument?.getElementById(styleTagId);\n if (ssrStyleElement) {\n styleTag.current = ssrStyleElement as HTMLStyleElement;\n } else {\n styleTag.current = createStyleTag(targetDocument, { ...styleElementAttributes, id: styleTagId });\n if (styleTag.current) {\n insertSheet(styleTag.current, rule);\n }\n }\n\n return () => {\n styleTag.current?.remove();\n };\n }, [styleTagId, targetDocument, rule, styleElementAttributes]);\n\n return { styleTagId, rule };\n};\n\nfunction useHandleSSRStyleElements(targetDocument: Document | undefined | null, styleTagId: string) {\n // Using a state factory so that this logic only runs once per render\n // Each FluentProvider can create its own style element during SSR as a slot\n // Moves all theme style elements to document head during render to avoid hydration errors.\n // Should be strict mode safe since the logic is idempotent.\n React.useState(() => {\n if (!targetDocument) {\n return;\n }\n\n const themeStyleElement = targetDocument.getElementById(styleTagId);\n if (themeStyleElement) {\n targetDocument.head.append(themeStyleElement);\n }\n });\n}\n"],"names":["useId","useIsomorphicLayoutEffect","React","createCSSRuleFromTheme","fluentProviderClassNames","useInsertionEffect","createStyleTag","target","elementAttributes","undefined","tag","createElement","Object","keys","forEach","attrName","setAttribute","head","appendChild","insertSheet","rule","sheet","cssRules","length","deleteRule","insertRule","process","env","NODE_ENV","console","error","useFluentProviderThemeStyleTag","options","targetDocument","theme","rendererAttributes","styleTag","useRef","styleTagId","root","styleElementAttributes","useMemo","providerSelector","providerElements","querySelectorAll","isSSR","querySelector","elementsCount","join","useHandleSSRStyleElements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;IAAK;AAC5B,EAAE;AAEF,SAAS6B,0BAA0BhB,cAA2C,EAAEK,UAAkB;IAChG,qEAAqE;IACrE,4EAA4E;IAC5E,2FAA2F;IAC3F,4DAA4D;IAC5DpC,MAAMqD,QAAQ,CAAC;QACb,IAAI,CAACtB,gBAAgB;YACnB;QACF;QAEA,MAAMuB,oBAAoBvB,eAAekB,cAAc,CAACb;QACxD,IAAIkB,mBAAmB;YACrBvB,eAAehB,IAAI,CAACwC,MAAM,CAACD;QAC7B;IACF;AACF"}
@@ -76,9 +76,8 @@ const useFluentProviderThemeStyleTag = (options)=>{
76
76
  }
77
77
  useHandleSSRStyleElements(targetDocument, styleTagId);
78
78
  useInsertionEffect(()=>{
79
- var _targetDocument;
80
79
  // The style element could already have been created during SSR - no need to recreate it
81
- const ssrStyleElement = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.getElementById(styleTagId);
80
+ const ssrStyleElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.getElementById(styleTagId);
82
81
  if (ssrStyleElement) {
83
82
  styleTag.current = ssrStyleElement;
84
83
  } else {
@@ -1 +1 @@
1
- {"version":3,"sources":["useFluentProviderThemeStyleTag.js"],"sourcesContent":["import { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { createCSSRuleFromTheme } from './createCSSRuleFromTheme';\nimport { fluentProviderClassNames } from './useFluentProviderStyles.styles';\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useIsomorphicLayoutEffect;\nconst createStyleTag = (target, elementAttributes)=>{\n if (!target) {\n return undefined;\n }\n const tag = target.createElement('style');\n Object.keys(elementAttributes).forEach((attrName)=>{\n tag.setAttribute(attrName, elementAttributes[attrName]);\n });\n target.head.appendChild(tag);\n return tag;\n};\nconst insertSheet = (tag, rule)=>{\n const sheet = tag.sheet;\n if (sheet) {\n if (sheet.cssRules.length > 0) {\n sheet.deleteRule(0);\n }\n sheet.insertRule(rule, 0);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('FluentProvider: No sheet available on styleTag, styles will not be inserted into DOM.');\n }\n};\n/**\n * Writes a theme as css variables in a style tag on the provided targetDocument as a rule applied to a CSS class\n * @internal\n * @returns CSS class to apply the rule\n */ export const useFluentProviderThemeStyleTag = (options)=>{\n const { targetDocument, theme, rendererAttributes } = options;\n const styleTag = React.useRef();\n const styleTagId = useId(fluentProviderClassNames.root);\n const styleElementAttributes = rendererAttributes;\n const rule = React.useMemo(()=>createCSSRuleFromTheme(`.${styleTagId}`, theme), [\n theme,\n styleTagId\n ]);\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(()=>{\n // Heads up!\n // .useMemo() is used because it is called during render and DOM for _current_ component is not mounted yet. Also,\n // this allows to do checks with strict mode enabled as .useEffect() will be called with incremented IDs because\n // of double render.\n if (targetDocument) {\n const providerSelector = `.${fluentProviderClassNames.root}.${styleTagId}`;\n const providerElements = targetDocument.querySelectorAll(providerSelector);\n // In SSR, we will have DOM upfront. To avoid false positives the check on nested style tag is performed\n const isSSR = targetDocument.querySelector(`${providerSelector} > style[id=\"${styleTagId}\"]`) !== null;\n const elementsCount = isSSR ? 1 : 0;\n if (providerElements.length > elementsCount) {\n // eslint-disable-next-line no-console\n console.error([\n '@fluentui/react-provider: There are conflicting ids in your DOM.',\n 'Please make sure that you configured your application properly.',\n '\\n',\n '\\n',\n 'Configuration guide: https://aka.ms/fluentui-conflicting-ids'\n ].join(' '));\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n useHandleSSRStyleElements(targetDocument, styleTagId);\n useInsertionEffect(()=>{\n var _targetDocument;\n // The style element could already have been created during SSR - no need to recreate it\n const ssrStyleElement = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.getElementById(styleTagId);\n if (ssrStyleElement) {\n styleTag.current = ssrStyleElement;\n } else {\n styleTag.current = createStyleTag(targetDocument, {\n ...styleElementAttributes,\n id: styleTagId\n });\n if (styleTag.current) {\n insertSheet(styleTag.current, rule);\n }\n }\n return ()=>{\n var _styleTag_current;\n (_styleTag_current = styleTag.current) === null || _styleTag_current === void 0 ? void 0 : _styleTag_current.remove();\n };\n }, [\n styleTagId,\n targetDocument,\n rule,\n styleElementAttributes\n ]);\n return {\n styleTagId,\n rule\n };\n};\nfunction useHandleSSRStyleElements(targetDocument, styleTagId) {\n // Using a state factory so that this logic only runs once per render\n // Each FluentProvider can create its own style element during SSR as a slot\n // Moves all theme style elements to document head during render to avoid hydration errors.\n // Should be strict mode safe since the logic is idempotent.\n React.useState(()=>{\n if (!targetDocument) {\n return;\n }\n const themeStyleElement = targetDocument.getElementById(styleTagId);\n if (themeStyleElement) {\n targetDocument.head.append(themeStyleElement);\n }\n });\n}\n"],"names":["useFluentProviderThemeStyleTag","useInsertionEffect","React","useIsomorphicLayoutEffect","createStyleTag","target","elementAttributes","undefined","tag","createElement","Object","keys","forEach","attrName","setAttribute","head","appendChild","insertSheet","rule","sheet","cssRules","length","deleteRule","insertRule","process","env","NODE_ENV","console","error","options","targetDocument","theme","rendererAttributes","styleTag","useRef","styleTagId","useId","fluentProviderClassNames","root","styleElementAttributes","useMemo","createCSSRuleFromTheme","providerSelector","providerElements","querySelectorAll","isSSR","querySelector","elementsCount","join","useHandleSSRStyleElements","_targetDocument","ssrStyleElement","getElementById","current","id","_styleTag_current","remove","useState","themeStyleElement","append"],"mappings":";;;;+BAiCiBA;;;eAAAA;;;;gCAjCgC;iEAC1B;wCACgB;+CACE;AACzC,4FAA4F;AAC5F,MAAMC,qBAAqBC,MAAK,CAAC,iBAAiB,SAAS,GAAGA,MAAK,CAAC,iBAAiB,SAAS,GAAGC,yCAAyB;AAC1H,MAAMC,iBAAiB,CAACC,QAAQC;IAC5B,IAAI,CAACD,QAAQ;QACT,OAAOE;IACX;IACA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,CAACD;QAC/B;IACJ;AACJ"}
1
+ {"version":3,"sources":["useFluentProviderThemeStyleTag.js"],"sourcesContent":["import { useId, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { createCSSRuleFromTheme } from './createCSSRuleFromTheme';\nimport { fluentProviderClassNames } from './useFluentProviderStyles.styles';\n// String concatenation is used to prevent bundlers to complain with older versions of React\nconst useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : useIsomorphicLayoutEffect;\nconst createStyleTag = (target, elementAttributes)=>{\n if (!target) {\n return undefined;\n }\n const tag = target.createElement('style');\n Object.keys(elementAttributes).forEach((attrName)=>{\n tag.setAttribute(attrName, elementAttributes[attrName]);\n });\n target.head.appendChild(tag);\n return tag;\n};\nconst insertSheet = (tag, rule)=>{\n const sheet = tag.sheet;\n if (sheet) {\n if (sheet.cssRules.length > 0) {\n sheet.deleteRule(0);\n }\n sheet.insertRule(rule, 0);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('FluentProvider: No sheet available on styleTag, styles will not be inserted into DOM.');\n }\n};\n/**\n * Writes a theme as css variables in a style tag on the provided targetDocument as a rule applied to a CSS class\n * @internal\n * @returns CSS class to apply the rule\n */ export const useFluentProviderThemeStyleTag = (options)=>{\n const { targetDocument, theme, rendererAttributes } = options;\n const styleTag = React.useRef();\n const styleTagId = useId(fluentProviderClassNames.root);\n const styleElementAttributes = rendererAttributes;\n const rule = React.useMemo(()=>createCSSRuleFromTheme(`.${styleTagId}`, theme), [\n theme,\n styleTagId\n ]);\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useMemo(()=>{\n // Heads up!\n // .useMemo() is used because it is called during render and DOM for _current_ component is not mounted yet. Also,\n // this allows to do checks with strict mode enabled as .useEffect() will be called with incremented IDs because\n // of double render.\n if (targetDocument) {\n const providerSelector = `.${fluentProviderClassNames.root}.${styleTagId}`;\n const providerElements = targetDocument.querySelectorAll(providerSelector);\n // In SSR, we will have DOM upfront. To avoid false positives the check on nested style tag is performed\n const isSSR = targetDocument.querySelector(`${providerSelector} > style[id=\"${styleTagId}\"]`) !== null;\n const elementsCount = isSSR ? 1 : 0;\n if (providerElements.length > elementsCount) {\n // eslint-disable-next-line no-console\n console.error([\n '@fluentui/react-provider: There are conflicting ids in your DOM.',\n 'Please make sure that you configured your application properly.',\n '\\n',\n '\\n',\n 'Configuration guide: https://aka.ms/fluentui-conflicting-ids'\n ].join(' '));\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n useHandleSSRStyleElements(targetDocument, styleTagId);\n useInsertionEffect(()=>{\n // The style element could already have been created during SSR - no need to recreate it\n const ssrStyleElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.getElementById(styleTagId);\n if (ssrStyleElement) {\n styleTag.current = ssrStyleElement;\n } else {\n styleTag.current = createStyleTag(targetDocument, {\n ...styleElementAttributes,\n id: styleTagId\n });\n if (styleTag.current) {\n insertSheet(styleTag.current, rule);\n }\n }\n return ()=>{\n var _styleTag_current;\n (_styleTag_current = styleTag.current) === null || _styleTag_current === void 0 ? void 0 : _styleTag_current.remove();\n };\n }, [\n styleTagId,\n targetDocument,\n rule,\n styleElementAttributes\n ]);\n return {\n styleTagId,\n rule\n };\n};\nfunction useHandleSSRStyleElements(targetDocument, styleTagId) {\n // Using a state factory so that this logic only runs once per render\n // Each FluentProvider can create its own style element during SSR as a slot\n // Moves all theme style elements to document head during render to avoid hydration errors.\n // Should be strict mode safe since the logic is idempotent.\n React.useState(()=>{\n if (!targetDocument) {\n return;\n }\n const themeStyleElement = targetDocument.getElementById(styleTagId);\n if (themeStyleElement) {\n targetDocument.head.append(themeStyleElement);\n }\n });\n}\n"],"names":["useFluentProviderThemeStyleTag","useInsertionEffect","React","useIsomorphicLayoutEffect","createStyleTag","target","elementAttributes","undefined","tag","createElement","Object","keys","forEach","attrName","setAttribute","head","appendChild","insertSheet","rule","sheet","cssRules","length","deleteRule","insertRule","process","env","NODE_ENV","console","error","options","targetDocument","theme","rendererAttributes","styleTag","useRef","styleTagId","useId","fluentProviderClassNames","root","styleElementAttributes","useMemo","createCSSRuleFromTheme","providerSelector","providerElements","querySelectorAll","isSSR","querySelector","elementsCount","join","useHandleSSRStyleElements","ssrStyleElement","getElementById","current","id","_styleTag_current","remove","useState","themeStyleElement","append"],"mappings":";;;;+BAiCiBA;;;eAAAA;;;;gCAjCgC;iEAC1B;wCACgB;+CACE;AACzC,4FAA4F;AAC5F,MAAMC,qBAAqBC,MAAK,CAAC,iBAAiB,SAAS,GAAGA,MAAK,CAAC,iBAAiB,SAAS,GAAGC,yCAAyB;AAC1H,MAAMC,iBAAiB,CAACC,QAAQC;IAC5B,IAAI,CAACD,QAAQ;QACT,OAAOE;IACX;IACA,MAAMC,MAAMH,OAAOI,aAAa,CAAC;IACjCC,OAAOC,IAAI,CAACL,mBAAmBM,OAAO,CAAC,CAACC;QACpCL,IAAIM,YAAY,CAACD,UAAUP,iBAAiB,CAACO,SAAS;IAC1D;IACAR,OAAOU,IAAI,CAACC,WAAW,CAACR;IACxB,OAAOA;AACX;AACA,MAAMS,cAAc,CAACT,KAAKU;IACtB,MAAMC,QAAQX,IAAIW,KAAK;IACvB,IAAIA,OAAO;QACP,IAAIA,MAAMC,QAAQ,CAACC,MAAM,GAAG,GAAG;YAC3BF,MAAMG,UAAU,CAAC;QACrB;QACAH,MAAMI,UAAU,CAACL,MAAM;IAC3B,OAAO,IAAIM,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QAC9C,sCAAsC;QACtCC,QAAQC,KAAK,CAAC;IAClB;AACJ;AAKW,MAAM5B,iCAAiC,CAAC6B;IAC/C,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,kBAAkB,EAAE,GAAGH;IACtD,MAAMI,WAAW/B,OAAMgC,MAAM;IAC7B,MAAMC,aAAaC,IAAAA,qBAAK,EAACC,uDAAwB,CAACC,IA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AIoC;YACHA,CAAAA,oBAAoBrB,SAASmB,OAAO,AAAD,MAAO,QAAQE,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBC,MAAM;QACvH;IACJ,GAAG;QACCpB;QACAL;QACAZ;QACAqB;KACH;IACD,OAAO;QACHJ;QACAjB;IACJ;AACJ;AACA,SAAS+B,0BAA0BnB,cAAc,EAAEK,UAAU;IACzD,qEAAqE;IACrE,4EAA4E;IAC5E,2FAA2F;IAC3F,4DAA4D;IAC5DjC,OAAMsD,QAAQ,CAAC;QACX,IAAI,CAAC1B,gBAAgB;YACjB;QACJ;QACA,MAAM2B,oBAAoB3B,eAAeqB,cAAc,CAAChB;QACxD,IAAIsB,mBAAmB;YACnB3B,eAAef,IAAI,CAAC2C,MAAM,CAACD;QAC/B;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-provider",
3
- "version": "9.9.0",
3
+ "version": "9.10.1",
4
4
  "description": "Fluent UI React provider component",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -33,12 +33,12 @@
33
33
  "@fluentui/scripts-tasks": "*"
34
34
  },
35
35
  "dependencies": {
36
- "@fluentui/react-icons": "^2.0.207",
37
- "@fluentui/react-shared-contexts": "^9.8.0",
38
- "@fluentui/react-tabster": "^9.12.10",
39
- "@fluentui/react-theme": "^9.1.12",
40
- "@fluentui/react-utilities": "^9.13.3",
41
- "@fluentui/react-jsx-runtime": "^9.0.9",
36
+ "@fluentui/react-icons": "^2.0.217",
37
+ "@fluentui/react-shared-contexts": "^9.9.1",
38
+ "@fluentui/react-tabster": "^9.13.1",
39
+ "@fluentui/react-theme": "^9.1.14",
40
+ "@fluentui/react-utilities": "^9.13.5",
41
+ "@fluentui/react-jsx-runtime": "^9.0.12",
42
42
  "@griffel/core": "^1.14.1",
43
43
  "@griffel/react": "^1.5.14",
44
44
  "@swc/helpers": "^0.5.1"