@telefonica/mistica 10.24.0 → 10.24.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.md +7 -0
- package/dist/package-version.js +1 -1
- package/dist/theme-context-provider.d.ts +10 -0
- package/dist/theme-context-provider.js +14 -7
- package/dist/theme-context-provider.js.flow +11 -0
- package/dist-es/package-version.js +1 -1
- package/dist-es/theme-context-provider.js +14 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [10.24.1](https://github.com/Telefonica/mistica-web/compare/v10.24.0...v10.24.1) (2022-02-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ThemeContextProvider:** Support SSR + Strict Mode ([#419](https://github.com/Telefonica/mistica-web/issues/419)) ([05b701d](https://github.com/Telefonica/mistica-web/commit/05b701d868d3b49a280c32365244771bd9c94416))
|
|
7
|
+
|
|
1
8
|
# [10.24.0](https://github.com/Telefonica/mistica-web/compare/v10.23.0...v10.24.0) (2022-02-15)
|
|
2
9
|
|
|
3
10
|
|
package/dist/package-version.js
CHANGED
|
@@ -3,6 +3,16 @@ import type { ThemeConfig } from './theme';
|
|
|
3
3
|
export declare const useIsOsDarkModeEnabled: () => boolean;
|
|
4
4
|
declare type Props = {
|
|
5
5
|
theme: ThemeConfig;
|
|
6
|
+
/**
|
|
7
|
+
* You should use this prop if you use Strict Mode and Server Side Rendering together.
|
|
8
|
+
* This identifier will be used to generate unique class names for each instance of ThemeContextProvider.
|
|
9
|
+
* If no identifier is provided, this will fallback to an auto-incremented id, which will cause
|
|
10
|
+
* problems in SSR + Strict Mode because the class names from client and server won't match.
|
|
11
|
+
* More info: https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects
|
|
12
|
+
*
|
|
13
|
+
* Once we migrate to React18, we could remove this prop and use the useId hook instead.
|
|
14
|
+
*/
|
|
15
|
+
providerId?: string;
|
|
6
16
|
children?: React.ReactNode;
|
|
7
17
|
};
|
|
8
18
|
declare const ThemeContextProvider: React.FC<Props>;
|
|
@@ -145,7 +145,7 @@ exports.useIsOsDarkModeEnabled = useIsOsDarkModeEnabled;
|
|
|
145
145
|
// This counter will increment with every new instance of ThemeContextProvider in the app. In a typical app we don't need more than
|
|
146
146
|
// one instance of ThemeContextProvider. But some apps may depend on libs that use Mistica too, so there may be more than one instance
|
|
147
147
|
// in those cases. We use this counter to avoid class name collisions in those cases.
|
|
148
|
-
var
|
|
148
|
+
var nextJssInstanceId = 0;
|
|
149
149
|
var generateId = function() {
|
|
150
150
|
if (process.env.NODE_ENV === 'test') {
|
|
151
151
|
// in tests classnames are just the classame, whithout ids
|
|
@@ -166,12 +166,19 @@ var useDefaultHrefDecorator = function useDefaultHrefDecorator() {
|
|
|
166
166
|
};
|
|
167
167
|
};
|
|
168
168
|
var ThemeContextProvider = function ThemeContextProvider(param) {
|
|
169
|
-
var theme = param.theme, children = param.children;
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
var theme = param.theme, children = param.children, providerId = param.providerId;
|
|
170
|
+
var ref = _slicedToArray(React.useState(function() {
|
|
171
|
+
if (providerId) {
|
|
172
|
+
return providerId;
|
|
173
|
+
} else {
|
|
174
|
+
return (0, _environment).isServerSide() ? 0 : nextJssInstanceId++;
|
|
175
|
+
}
|
|
176
|
+
}), 1), instanceId = ref[0];
|
|
177
|
+
var classNamePrefix = React.useMemo(function() {
|
|
178
|
+
return process.env.NODE_ENV === 'test' ? '' : "mistica-".concat(_packageVersion.PACKAGE_VERSION.replace(/\./g, '-'), "_").concat(instanceId, "_");
|
|
179
|
+
}, [
|
|
180
|
+
instanceId
|
|
181
|
+
]);
|
|
175
182
|
var nextAriaId = React.useRef(1);
|
|
176
183
|
var getAriaId = React.useCallback(function() {
|
|
177
184
|
return "aria-id-hook-".concat(nextAriaId.current++);
|
|
@@ -5,6 +5,17 @@ import type { ThemeConfig } from "./theme";
|
|
|
5
5
|
declare export var useIsOsDarkModeEnabled: () => boolean;
|
|
6
6
|
declare type Props = {
|
|
7
7
|
theme: ThemeConfig,
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* You should use this prop if you use Strict Mode and Server Side Rendering together.
|
|
11
|
+
* This identifier will be used to generate unique class names for each instance of ThemeContextProvider.
|
|
12
|
+
* If no identifier is provided, this will fallback to an auto-incremented id, which will cause
|
|
13
|
+
* problems in SSR + Strict Mode because the class names from client and server won't match.
|
|
14
|
+
* More info: https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects
|
|
15
|
+
*
|
|
16
|
+
* Once we migrate to React18, we could remove this prop and use the useId hook instead.
|
|
17
|
+
*/
|
|
18
|
+
providerId?: string,
|
|
8
19
|
children?: React.Node,
|
|
9
20
|
};
|
|
10
21
|
declare var ThemeContextProvider: React.ComponentType<Props>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// DO NOT EDIT THIS FILE. It's autogenerated by set-version.js
|
|
2
|
-
export var PACKAGE_VERSION = '10.24.
|
|
2
|
+
export var PACKAGE_VERSION = '10.24.1';
|
|
@@ -112,7 +112,7 @@ export var useIsOsDarkModeEnabled = function() {
|
|
|
112
112
|
// This counter will increment with every new instance of ThemeContextProvider in the app. In a typical app we don't need more than
|
|
113
113
|
// one instance of ThemeContextProvider. But some apps may depend on libs that use Mistica too, so there may be more than one instance
|
|
114
114
|
// in those cases. We use this counter to avoid class name collisions in those cases.
|
|
115
|
-
var
|
|
115
|
+
var nextJssInstanceId = 0;
|
|
116
116
|
var generateId = function() {
|
|
117
117
|
if (process.env.NODE_ENV === 'test') {
|
|
118
118
|
// in tests classnames are just the classame, whithout ids
|
|
@@ -133,13 +133,19 @@ var useDefaultHrefDecorator = function() {
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
var ThemeContextProvider = function(param) {
|
|
136
|
-
var theme = param.theme, children = param.children;
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
var theme = param.theme, children = param.children, providerId = param.providerId;
|
|
137
|
+
var ref = _slicedToArray(React.useState(function() {
|
|
138
|
+
if (providerId) {
|
|
139
|
+
return providerId;
|
|
140
|
+
} else {
|
|
141
|
+
return isServerSide() ? 0 : nextJssInstanceId++;
|
|
142
|
+
}
|
|
143
|
+
}), 1), instanceId = ref[0];
|
|
144
|
+
var classNamePrefix = React.useMemo(function() {
|
|
145
|
+
return process.env.NODE_ENV === 'test' ? '' : "mistica-".concat(PACKAGE_VERSION.replace(/\./g, '-'), "_").concat(instanceId, "_");
|
|
146
|
+
}, [
|
|
147
|
+
instanceId
|
|
148
|
+
]);
|
|
143
149
|
var nextAriaId = React.useRef(1);
|
|
144
150
|
var getAriaId = React.useCallback(function() {
|
|
145
151
|
return "aria-id-hook-".concat(nextAriaId.current++);
|