@telefonica/mistica 11.10.2 → 11.12.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/dist/button.js +35 -43
- package/dist/card.d.ts +43 -1
- package/dist/card.js +212 -10
- package/dist/card.js.flow +44 -0
- package/dist/carousel.js +4 -6
- package/dist/highlighted-card.d.ts +4 -2
- package/dist/highlighted-card.js +19 -72
- package/dist/highlighted-card.js.flow +8 -2
- package/dist/image.js +9 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.flow +1 -1
- package/dist/maybe-dismissable.d.ts +10 -0
- package/dist/maybe-dismissable.js +119 -0
- package/dist/maybe-dismissable.js.flow +12 -0
- package/dist/package-version.js +1 -1
- package/dist/skins/types.d.ts +15 -0
- package/dist/skins/types.js.flow +23 -0
- package/dist/text.d.ts +1 -1
- package/dist/text.js +14 -7
- package/dist/text.js.flow +1 -1
- package/dist/theme-context-provider.js +31 -2
- package/dist/theme.d.ts +4 -11
- package/dist/theme.js.flow +4 -11
- package/dist/utils/media-queries.d.ts +9 -7
- package/dist/utils/media-queries.js +5 -1
- package/dist/utils/media-queries.js.flow +9 -7
- package/dist/utils/platform.d.ts +8 -1
- package/dist/utils/platform.js +5 -1
- package/dist/utils/platform.js.flow +8 -1
- package/dist/video.js +22 -8
- package/dist-es/button.js +35 -43
- package/dist-es/card.js +211 -9
- package/dist-es/carousel.js +5 -6
- package/dist-es/highlighted-card.js +17 -70
- package/dist-es/image.js +10 -4
- package/dist-es/index.js +1 -1
- package/dist-es/maybe-dismissable.js +86 -0
- package/dist-es/package-version.js +1 -1
- package/dist-es/text.js +14 -7
- package/dist-es/theme-context-provider.js +31 -2
- package/dist-es/utils/media-queries.js +5 -1
- package/dist-es/utils/platform.js +8 -0
- package/dist-es/video.js +23 -8
- package/package.json +1 -1
package/dist-es/text.js
CHANGED
|
@@ -33,6 +33,7 @@ import { createUseStyles } from "./jss";
|
|
|
33
33
|
import { useIsInverseVariant } from "./theme-variant-context";
|
|
34
34
|
import { pxToRem } from "./utils/css";
|
|
35
35
|
import { getPrefixedDataAttributes } from "./utils/dom";
|
|
36
|
+
import { useTheme } from "./hooks";
|
|
36
37
|
var useStyles = createUseStyles(function(theme) {
|
|
37
38
|
var mapToWeight = {
|
|
38
39
|
light: 300,
|
|
@@ -116,7 +117,7 @@ var useStyles = createUseStyles(function(theme) {
|
|
|
116
117
|
return truncate === 1 || truncate === true ? "break-all" : "normal";
|
|
117
118
|
}
|
|
118
119
|
},
|
|
119
|
-
display: "box",
|
|
120
|
+
display: "-webkit-box",
|
|
120
121
|
boxOrient: "vertical",
|
|
121
122
|
overflow: "hidden"
|
|
122
123
|
}
|
|
@@ -157,67 +158,73 @@ var getWeight = function(props) {
|
|
|
157
158
|
return props.light && "light" || props.regular && "regular" || props.medium && "medium";
|
|
158
159
|
};
|
|
159
160
|
export var Text10 = function(props) {
|
|
161
|
+
var textPresets = useTheme().textPresets;
|
|
160
162
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
161
163
|
mobileSize: 32,
|
|
162
164
|
mobileLineHeight: "40px",
|
|
163
165
|
desktopSize: 64,
|
|
164
166
|
desktopLineHeight: "72px",
|
|
165
|
-
weight:
|
|
167
|
+
weight: textPresets.text10.weight
|
|
166
168
|
}, props, {
|
|
167
169
|
children: props.children
|
|
168
170
|
}));
|
|
169
171
|
};
|
|
170
172
|
export var Text9 = function(props) {
|
|
173
|
+
var textPresets = useTheme().textPresets;
|
|
171
174
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
172
175
|
mobileSize: 32,
|
|
173
176
|
mobileLineHeight: "40px",
|
|
174
177
|
desktopSize: 56,
|
|
175
178
|
desktopLineHeight: "64px",
|
|
176
|
-
weight:
|
|
179
|
+
weight: textPresets.text9.weight
|
|
177
180
|
}, props, {
|
|
178
181
|
children: props.children
|
|
179
182
|
}));
|
|
180
183
|
};
|
|
181
184
|
export var Text8 = function(props) {
|
|
185
|
+
var textPresets = useTheme().textPresets;
|
|
182
186
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
183
187
|
mobileSize: 32,
|
|
184
188
|
mobileLineHeight: "40px",
|
|
185
189
|
desktopSize: 40,
|
|
186
190
|
desktopLineHeight: "48px",
|
|
187
|
-
weight:
|
|
191
|
+
weight: textPresets.text8.weight
|
|
188
192
|
}, props, {
|
|
189
193
|
children: props.children
|
|
190
194
|
}));
|
|
191
195
|
};
|
|
192
196
|
export var Text7 = function(props) {
|
|
197
|
+
var textPresets = useTheme().textPresets;
|
|
193
198
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
194
199
|
mobileSize: 28,
|
|
195
200
|
mobileLineHeight: "32px",
|
|
196
201
|
desktopSize: 40,
|
|
197
202
|
desktopLineHeight: "48px",
|
|
198
|
-
weight:
|
|
203
|
+
weight: textPresets.text7.weight
|
|
199
204
|
}, props, {
|
|
200
205
|
children: props.children
|
|
201
206
|
}));
|
|
202
207
|
};
|
|
203
208
|
export var Text6 = function(props) {
|
|
209
|
+
var textPresets = useTheme().textPresets;
|
|
204
210
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
205
211
|
mobileSize: 24,
|
|
206
212
|
mobileLineHeight: "32px",
|
|
207
213
|
desktopSize: 32,
|
|
208
214
|
desktopLineHeight: "40px",
|
|
209
|
-
weight:
|
|
215
|
+
weight: textPresets.text6.weight
|
|
210
216
|
}, props, {
|
|
211
217
|
children: props.children
|
|
212
218
|
}));
|
|
213
219
|
};
|
|
214
220
|
export var Text5 = function(props) {
|
|
221
|
+
var textPresets = useTheme().textPresets;
|
|
215
222
|
return /*#__PURE__*/ _jsx(Text, _objectSpread({
|
|
216
223
|
mobileSize: 22,
|
|
217
224
|
mobileLineHeight: "24px",
|
|
218
225
|
desktopSize: 28,
|
|
219
226
|
desktopLineHeight: "32px",
|
|
220
|
-
weight:
|
|
227
|
+
weight: textPresets.text5.weight
|
|
221
228
|
}, props, {
|
|
222
229
|
children: props.children
|
|
223
230
|
}));
|
|
@@ -134,15 +134,35 @@ var useDefaultHrefDecorator = function() {
|
|
|
134
134
|
return href;
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
+
var defaultTextPresetsConfig = {
|
|
138
|
+
text5: {
|
|
139
|
+
weight: "light"
|
|
140
|
+
},
|
|
141
|
+
text6: {
|
|
142
|
+
weight: "light"
|
|
143
|
+
},
|
|
144
|
+
text7: {
|
|
145
|
+
weight: "light"
|
|
146
|
+
},
|
|
147
|
+
text8: {
|
|
148
|
+
weight: "light"
|
|
149
|
+
},
|
|
150
|
+
text9: {
|
|
151
|
+
weight: "light"
|
|
152
|
+
},
|
|
153
|
+
text10: {
|
|
154
|
+
weight: "light"
|
|
155
|
+
}
|
|
156
|
+
};
|
|
137
157
|
var ThemeContextProvider = function(param) {
|
|
138
158
|
var theme = param.theme, children = param.children, providerId = param.providerId;
|
|
139
|
-
var
|
|
159
|
+
var ref6 = _slicedToArray(React.useState(function() {
|
|
140
160
|
if (providerId) {
|
|
141
161
|
return providerId;
|
|
142
162
|
} else {
|
|
143
163
|
return isServerSide() ? 0 : nextJssInstanceId++;
|
|
144
164
|
}
|
|
145
|
-
}), 1), instanceId =
|
|
165
|
+
}), 1), instanceId = ref6[0];
|
|
146
166
|
var classNamePrefix = React.useMemo(function() {
|
|
147
167
|
return process.env.NODE_ENV === "test" ? "" : "mistica-".concat(PACKAGE_VERSION.replace(/\./g, "-"), "_").concat(instanceId, "_");
|
|
148
168
|
}, [
|
|
@@ -154,6 +174,7 @@ var ThemeContextProvider = function(param) {
|
|
|
154
174
|
}, []);
|
|
155
175
|
var isOsDarkModeEnabled = useIsOsDarkModeEnabled();
|
|
156
176
|
var contextTheme = React.useMemo(function() {
|
|
177
|
+
var ref, ref1, ref2, ref3, ref4, ref5;
|
|
157
178
|
var _colorScheme;
|
|
158
179
|
// TODO: In next major version we could change this to "auto" by default
|
|
159
180
|
var colorScheme = (_colorScheme = theme.colorScheme) !== null && _colorScheme !== void 0 ? _colorScheme : "light";
|
|
@@ -180,6 +201,14 @@ var ThemeContextProvider = function(param) {
|
|
|
180
201
|
dimensions: _objectSpread({}, dimensions, theme.dimensions),
|
|
181
202
|
mq: createMediaQueries((_mediaQueries = theme.mediaQueries) !== null && _mediaQueries !== void 0 ? _mediaQueries : mediaQueriesConfig),
|
|
182
203
|
colors: colors,
|
|
204
|
+
textPresets: {
|
|
205
|
+
text5: _objectSpread({}, defaultTextPresetsConfig.text5, (ref = theme.skin.textPresets) === null || ref === void 0 ? void 0 : ref.text5),
|
|
206
|
+
text6: _objectSpread({}, defaultTextPresetsConfig.text6, (ref1 = theme.skin.textPresets) === null || ref1 === void 0 ? void 0 : ref1.text6),
|
|
207
|
+
text7: _objectSpread({}, defaultTextPresetsConfig.text7, (ref2 = theme.skin.textPresets) === null || ref2 === void 0 ? void 0 : ref2.text7),
|
|
208
|
+
text8: _objectSpread({}, defaultTextPresetsConfig.text8, (ref3 = theme.skin.textPresets) === null || ref3 === void 0 ? void 0 : ref3.text8),
|
|
209
|
+
text9: _objectSpread({}, defaultTextPresetsConfig.text9, (ref4 = theme.skin.textPresets) === null || ref4 === void 0 ? void 0 : ref4.text9),
|
|
210
|
+
text10: _objectSpread({}, defaultTextPresetsConfig.text10, (ref5 = theme.skin.textPresets) === null || ref5 === void 0 ? void 0 : ref5.text10)
|
|
211
|
+
},
|
|
183
212
|
Link: (_Link = theme.Link) !== null && _Link !== void 0 ? _Link : AnchorLink,
|
|
184
213
|
isDarkMode: isDarkModeEnabled,
|
|
185
214
|
isIos: getPlatform(platformOverrides) === "ios",
|
|
@@ -12,6 +12,10 @@ export var createMediaQueries = function(param) {
|
|
|
12
12
|
// Also enabled for (pointer: none) for acceptance tests, where (pointer: fine) doesn't match.
|
|
13
13
|
// WARNING: you may be tempted to use @media (hover: hover) instead, but that doesn't work as expected in some android browsers.
|
|
14
14
|
// See: https://hover-pointer-media-query.glitch.me/ and https://github.com/mui-org/material-ui/issues/15736
|
|
15
|
-
supportsHover: "@media (pointer: fine), (pointer: none)"
|
|
15
|
+
supportsHover: "@media (pointer: fine), (pointer: none)",
|
|
16
|
+
/**
|
|
17
|
+
* Scopes the styles to touchable devices.
|
|
18
|
+
* See: https://stackoverflow.com/questions/12469875/how-to-code-css-media-queries-targeting-all-mobile-devices-and-tablets/42835826#42835826
|
|
19
|
+
*/ touchableOnly: "@media (pointer: coarse), @media (hover: none)"
|
|
16
20
|
};
|
|
17
21
|
};
|
|
@@ -82,6 +82,14 @@ export var isIos = function(platformOverrides) {
|
|
|
82
82
|
}
|
|
83
83
|
return false;
|
|
84
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Returns true if the browser is a safari browser:
|
|
87
|
+
* webview, mobile, desktop or a browser like Chrome for iOS which is just a safari with a skin
|
|
88
|
+
*
|
|
89
|
+
* Note that this function checks the navigator vendor. It doesn't use platformOverrides or userAgent.
|
|
90
|
+
*/ export var isSafari = function() {
|
|
91
|
+
return navigator.vendor.includes("Apple");
|
|
92
|
+
};
|
|
85
93
|
export var isFirefox = function(platformOverrides) {
|
|
86
94
|
return !!getUserAgent(platformOverrides).match(/Firefox\/([0-9]+)\./);
|
|
87
95
|
};
|
package/dist-es/video.js
CHANGED
|
@@ -60,6 +60,7 @@ import { createUseStyles } from "./jss";
|
|
|
60
60
|
import { useSupportsAspectRatio } from "./utils/aspect-ratio-support";
|
|
61
61
|
import { combineRefs } from "./utils/common";
|
|
62
62
|
import { getPrefixedDataAttributes } from "./utils/dom";
|
|
63
|
+
import { isRunningAcceptanceTest, isSafari } from "./utils/platform";
|
|
63
64
|
export var RATIO = {
|
|
64
65
|
"1:1": 1,
|
|
65
66
|
"16:9": 16 / 9,
|
|
@@ -69,6 +70,7 @@ export var RATIO = {
|
|
|
69
70
|
var useStyles = createUseStyles(function() {
|
|
70
71
|
return {
|
|
71
72
|
video: {
|
|
73
|
+
background: "transparent",
|
|
72
74
|
display: "block",
|
|
73
75
|
objectFit: "cover",
|
|
74
76
|
maxWidth: "100%",
|
|
@@ -85,7 +87,11 @@ var useStyles = createUseStyles(function() {
|
|
|
85
87
|
},
|
|
86
88
|
"$wrapper &": {
|
|
87
89
|
borderRadius: 0,
|
|
88
|
-
position:
|
|
90
|
+
position: function(param) {
|
|
91
|
+
var aspectRatio = param.aspectRatio;
|
|
92
|
+
return(// when aspectRatio is 0, we want the video to use the original aspect ratio
|
|
93
|
+
aspectRatio ? "absolute" : "static");
|
|
94
|
+
},
|
|
89
95
|
width: "100%",
|
|
90
96
|
height: "100%",
|
|
91
97
|
top: 0,
|
|
@@ -104,7 +110,7 @@ var useStyles = createUseStyles(function() {
|
|
|
104
110
|
paddingTop: function(param) {
|
|
105
111
|
var aspectRatio = param.aspectRatio, width = param.width;
|
|
106
112
|
if (!aspectRatio) {
|
|
107
|
-
return
|
|
113
|
+
return 0;
|
|
108
114
|
}
|
|
109
115
|
if (width && typeof width === "string" && width.endsWith("%")) {
|
|
110
116
|
return "".concat(Number(width.replace("%", "")) / aspectRatio, "%");
|
|
@@ -116,7 +122,7 @@ var useStyles = createUseStyles(function() {
|
|
|
116
122
|
});
|
|
117
123
|
/** Transparent 1x1px PNG */ var TRANSPARENT_PIXEL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC";
|
|
118
124
|
var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
119
|
-
var src1 = _param.src, poster = _param.poster, _autoPlay = _param.autoPlay, autoPlay = _autoPlay === void 0 ?
|
|
125
|
+
var src1 = _param.src, poster = _param.poster, _autoPlay = _param.autoPlay, autoPlay = _autoPlay === void 0 ? !isRunningAcceptanceTest() : _autoPlay, _muted = _param.muted, muted = _muted === void 0 ? true : _muted, _loop = _param.loop, loop = _loop === void 0 ? true : _loop, _preload = _param.preload, preload = _preload === void 0 ? "none" : _preload, _aspectRatio = _param.aspectRatio, aspectRatio = _aspectRatio === void 0 ? "1:1" : _aspectRatio, dataAttributes = _param.dataAttributes, props = _objectWithoutProperties(_param, [
|
|
120
126
|
"src",
|
|
121
127
|
"poster",
|
|
122
128
|
"autoPlay",
|
|
@@ -170,7 +176,11 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
170
176
|
} else {
|
|
171
177
|
width = props.width || "100%";
|
|
172
178
|
}
|
|
173
|
-
|
|
179
|
+
/**
|
|
180
|
+
* In safari, when using a video with poster, the transition from pause to play does a flicker,
|
|
181
|
+
* To avoid this, in Safari browsers, instead of using the poster attribute, we use a
|
|
182
|
+
* wrapper with the poster as background image
|
|
183
|
+
*/ var needsWrapper = isSafari() || withCssAspectRatio && !supportsAspectRatio;
|
|
174
184
|
var video1 = /*#__PURE__*/ _jsx("video", _objectSpread({
|
|
175
185
|
ref: combineRefs(ref, videoRef),
|
|
176
186
|
playsInline: true,
|
|
@@ -179,14 +189,16 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
179
189
|
autoPlay: autoPlay,
|
|
180
190
|
muted: muted,
|
|
181
191
|
loop: loop
|
|
182
|
-
},
|
|
192
|
+
}, needsWrapper ? {
|
|
193
|
+
width: "100%"
|
|
194
|
+
} : {
|
|
183
195
|
width: width,
|
|
184
196
|
height: height
|
|
185
|
-
}
|
|
197
|
+
}, {
|
|
186
198
|
className: classes.video,
|
|
187
199
|
preload: preload,
|
|
188
200
|
// This transparent pixel fallback avoids showing the ugly "play" image in android webviews
|
|
189
|
-
poster: poster || TRANSPARENT_PIXEL
|
|
201
|
+
poster: needsWrapper ? TRANSPARENT_PIXEL : poster || TRANSPARENT_PIXEL
|
|
190
202
|
}, getPrefixedDataAttributes(dataAttributes), {
|
|
191
203
|
children: sources.map(function(param, index) {
|
|
192
204
|
var src = param.src, type = param.type;
|
|
@@ -200,7 +212,10 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
200
212
|
return /*#__PURE__*/ _jsx("div", {
|
|
201
213
|
style: {
|
|
202
214
|
width: width,
|
|
203
|
-
height: height
|
|
215
|
+
height: height,
|
|
216
|
+
backgroundImage: poster ? 'url("'.concat(poster, '")') : undefined,
|
|
217
|
+
backgroundSize: "cover",
|
|
218
|
+
backgroundPosition: "50% 50%"
|
|
204
219
|
},
|
|
205
220
|
className: classes.wrapper,
|
|
206
221
|
children: video1
|