@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.
Files changed (45) hide show
  1. package/dist/button.js +35 -43
  2. package/dist/card.d.ts +43 -1
  3. package/dist/card.js +212 -10
  4. package/dist/card.js.flow +44 -0
  5. package/dist/carousel.js +4 -6
  6. package/dist/highlighted-card.d.ts +4 -2
  7. package/dist/highlighted-card.js +19 -72
  8. package/dist/highlighted-card.js.flow +8 -2
  9. package/dist/image.js +9 -4
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +6 -0
  12. package/dist/index.js.flow +1 -1
  13. package/dist/maybe-dismissable.d.ts +10 -0
  14. package/dist/maybe-dismissable.js +119 -0
  15. package/dist/maybe-dismissable.js.flow +12 -0
  16. package/dist/package-version.js +1 -1
  17. package/dist/skins/types.d.ts +15 -0
  18. package/dist/skins/types.js.flow +23 -0
  19. package/dist/text.d.ts +1 -1
  20. package/dist/text.js +14 -7
  21. package/dist/text.js.flow +1 -1
  22. package/dist/theme-context-provider.js +31 -2
  23. package/dist/theme.d.ts +4 -11
  24. package/dist/theme.js.flow +4 -11
  25. package/dist/utils/media-queries.d.ts +9 -7
  26. package/dist/utils/media-queries.js +5 -1
  27. package/dist/utils/media-queries.js.flow +9 -7
  28. package/dist/utils/platform.d.ts +8 -1
  29. package/dist/utils/platform.js +5 -1
  30. package/dist/utils/platform.js.flow +8 -1
  31. package/dist/video.js +22 -8
  32. package/dist-es/button.js +35 -43
  33. package/dist-es/card.js +211 -9
  34. package/dist-es/carousel.js +5 -6
  35. package/dist-es/highlighted-card.js +17 -70
  36. package/dist-es/image.js +10 -4
  37. package/dist-es/index.js +1 -1
  38. package/dist-es/maybe-dismissable.js +86 -0
  39. package/dist-es/package-version.js +1 -1
  40. package/dist-es/text.js +14 -7
  41. package/dist-es/theme-context-provider.js +31 -2
  42. package/dist-es/utils/media-queries.js +5 -1
  43. package/dist-es/utils/platform.js +8 -0
  44. package/dist-es/video.js +23 -8
  45. package/package.json +1 -1
package/dist/theme.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import type { RegionCode } from './utils/region-code';
3
3
  import type { Locale } from './utils/locale';
4
- import type { Skin, Colors, SkinName } from './skins/types';
4
+ import type { Skin, Colors, SkinName, TextPresetsConfig } from './skins/types';
5
5
  import type { TrackingEvent } from './utils/types';
6
+ import type { MediaQueries } from './utils/media-queries';
6
7
  export declare type ThemeTexts = typeof TEXTS_ES;
7
8
  declare const TEXTS_ES: {
8
9
  expirationDatePlaceholder: string;
@@ -124,17 +125,9 @@ export declare type Theme = {
124
125
  dimensions: {
125
126
  headerMobileHeight: number;
126
127
  };
127
- mq: {
128
- mobile: string;
129
- tablet: string;
130
- desktop: string;
131
- largeDesktop: string;
132
- tabletOrBigger: string;
133
- tabletOrSmaller: string;
134
- desktopOrBigger: string;
135
- supportsHover: string;
136
- };
128
+ mq: MediaQueries;
137
129
  colors: Colors;
130
+ textPresets: TextPresetsConfig;
138
131
  Link: LinkComponent;
139
132
  isDarkMode: boolean;
140
133
  isIos: boolean;
@@ -3,8 +3,9 @@
3
3
  import * as React from "react";
4
4
  import type { RegionCode } from "./utils/region-code";
5
5
  import type { Locale } from "./utils/locale";
6
- import type { Skin, Colors, SkinName } from "./skins/types";
6
+ import type { Skin, Colors, SkinName, TextPresetsConfig } from "./skins/types";
7
7
  import type { TrackingEvent } from "./utils/types";
8
+ import type { MediaQueries } from "./utils/media-queries";
8
9
  export type ThemeTexts = typeof TEXTS_ES;
9
10
  declare var TEXTS_ES: {
10
11
  expirationDatePlaceholder: string,
@@ -128,17 +129,9 @@ export type Theme = {
128
129
  dimensions: {
129
130
  headerMobileHeight: number,
130
131
  },
131
- mq: {
132
- mobile: string,
133
- tablet: string,
134
- desktop: string,
135
- largeDesktop: string,
136
- tabletOrBigger: string,
137
- tabletOrSmaller: string,
138
- desktopOrBigger: string,
139
- supportsHover: string,
140
- },
132
+ mq: MediaQueries,
141
133
  colors: Colors,
134
+ textPresets: TextPresetsConfig,
142
135
  Link: LinkComponent,
143
136
  isDarkMode: boolean,
144
137
  isIos: boolean,
@@ -1,9 +1,4 @@
1
- export declare const createMediaQueries: ({ desktopOrTabletMinHeight, tabletMinWidth, desktopMinWidth, largeDesktopMinWidth, }: {
2
- tabletMinWidth: number;
3
- desktopMinWidth: number;
4
- largeDesktopMinWidth: number;
5
- desktopOrTabletMinHeight: number;
6
- }) => {
1
+ export declare type MediaQueries = Readonly<{
7
2
  mobile: string;
8
3
  tablet: string;
9
4
  desktop: string;
@@ -12,4 +7,11 @@ export declare const createMediaQueries: ({ desktopOrTabletMinHeight, tabletMinW
12
7
  tabletOrSmaller: string;
13
8
  desktopOrBigger: string;
14
9
  supportsHover: string;
15
- };
10
+ touchableOnly: string;
11
+ }>;
12
+ export declare const createMediaQueries: ({ desktopOrTabletMinHeight, tabletMinWidth, desktopMinWidth, largeDesktopMinWidth, }: {
13
+ tabletMinWidth: number;
14
+ desktopMinWidth: number;
15
+ largeDesktopMinWidth: number;
16
+ desktopOrTabletMinHeight: number;
17
+ }) => MediaQueries;
@@ -17,7 +17,11 @@ var createMediaQueries = function createMediaQueries(param) {
17
17
  // Also enabled for (pointer: none) for acceptance tests, where (pointer: fine) doesn't match.
18
18
  // WARNING: you may be tempted to use @media (hover: hover) instead, but that doesn't work as expected in some android browsers.
19
19
  // See: https://hover-pointer-media-query.glitch.me/ and https://github.com/mui-org/material-ui/issues/15736
20
- supportsHover: "@media (pointer: fine), (pointer: none)"
20
+ supportsHover: "@media (pointer: fine), (pointer: none)",
21
+ /**
22
+ * Scopes the styles to touchable devices.
23
+ * See: https://stackoverflow.com/questions/12469875/how-to-code-css-media-queries-targeting-all-mobile-devices-and-tablets/42835826#42835826
24
+ */ touchableOnly: "@media (pointer: coarse), @media (hover: none)"
21
25
  };
22
26
  };
23
27
  exports.createMediaQueries = createMediaQueries;
@@ -1,11 +1,6 @@
1
1
  // @flow
2
2
 
3
- declare export var createMediaQueries: (x: {
4
- tabletMinWidth: number,
5
- desktopMinWidth: number,
6
- largeDesktopMinWidth: number,
7
- desktopOrTabletMinHeight: number,
8
- }) => {
3
+ export type MediaQueries = $ReadOnly<{
9
4
  mobile: string,
10
5
  tablet: string,
11
6
  desktop: string,
@@ -14,4 +9,11 @@ declare export var createMediaQueries: (x: {
14
9
  tabletOrSmaller: string,
15
10
  desktopOrBigger: string,
16
11
  supportsHover: string,
17
- };
12
+ touchableOnly: string,
13
+ }>;
14
+ declare export var createMediaQueries: (x: {
15
+ tabletMinWidth: number,
16
+ desktopMinWidth: number,
17
+ largeDesktopMinWidth: number,
18
+ desktopOrTabletMinHeight: number,
19
+ }) => MediaQueries;
@@ -3,8 +3,15 @@ export declare const isInsideNovumNativeApp: (platformOverrides?: Theme['platfor
3
3
  export declare const isRunningAcceptanceTest: (platformOverrides?: Theme['platformOverrides']) => boolean;
4
4
  export declare const isAndroid: (platformOverrides: Theme['platformOverrides']) => boolean;
5
5
  export declare const isIos: (platformOverrides: Theme['platformOverrides']) => boolean;
6
+ /**
7
+ * Returns true if the browser is a safari browser:
8
+ * webview, mobile, desktop or a browser like Chrome for iOS which is just a safari with a skin
9
+ *
10
+ * Note that this function checks the navigator vendor. It doesn't use platformOverrides or userAgent.
11
+ */
12
+ export declare const isSafari: () => boolean;
6
13
  export declare const isFirefox: (platformOverrides?: {
7
- platform?: "ios" | "android" | "desktop" | undefined;
14
+ platform?: "desktop" | "ios" | "android" | undefined;
8
15
  insideNovumNativeApp?: boolean | undefined;
9
16
  userAgent?: string | undefined;
10
17
  } | undefined) => boolean;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.getPlatform = exports.getIosVersion = exports.isOldChrome = exports.isChrome = exports.isFirefox = exports.isIos = exports.isAndroid = exports.isRunningAcceptanceTest = exports.isInsideNovumNativeApp = void 0;
5
+ exports.getPlatform = exports.getIosVersion = exports.isOldChrome = exports.isChrome = exports.isFirefox = exports.isSafari = exports.isIos = exports.isAndroid = exports.isRunningAcceptanceTest = exports.isInsideNovumNativeApp = void 0;
6
6
  var _webviewBridge = require("@tef-novum/webview-bridge");
7
7
  function _arrayLikeToArray(arr, len) {
8
8
  if (len == null || len > arr.length) len = arr.length;
@@ -91,6 +91,10 @@ var isIos = function isIos(platformOverrides) {
91
91
  return false;
92
92
  };
93
93
  exports.isIos = isIos;
94
+ var isSafari = function isSafari() {
95
+ return navigator.vendor.includes("Apple");
96
+ };
97
+ exports.isSafari = isSafari;
94
98
  var isFirefox = function isFirefox(platformOverrides) {
95
99
  return !!getUserAgent(platformOverrides).match(/Firefox\/([0-9]+)\./);
96
100
  };
@@ -13,9 +13,16 @@ declare export var isAndroid: (
13
13
  declare export var isIos: (
14
14
  platformOverrides: $PropertyType<Theme, "platformOverrides">
15
15
  ) => boolean;
16
+ /**
17
+ * Returns true if the browser is a safari browser:
18
+ * webview, mobile, desktop or a browser like Chrome for iOS which is just a safari with a skin
19
+ *
20
+ * Note that this function checks the navigator vendor. It doesn't use platformOverrides or userAgent.
21
+ */
22
+ declare export var isSafari: () => boolean;
16
23
  declare export var isFirefox: (
17
24
  platformOverrides?: {
18
- platform?: "ios" | "android" | "desktop" | void,
25
+ platform?: "desktop" | "ios" | "android" | void,
19
26
  insideNovumNativeApp?: boolean | void,
20
27
  userAgent?: string | void,
21
28
  } | void
package/dist/video.js CHANGED
@@ -10,6 +10,7 @@ var _jss = require("./jss");
10
10
  var _aspectRatioSupport = require("./utils/aspect-ratio-support");
11
11
  var _common = require("./utils/common");
12
12
  var _dom = require("./utils/dom");
13
+ var _platform = require("./utils/platform");
13
14
  function _interopRequireWildcard(obj) {
14
15
  if (obj && obj.__esModule) {
15
16
  return obj;
@@ -97,6 +98,7 @@ exports.RATIO = RATIO;
97
98
  var useStyles = (0, _jss).createUseStyles(function() {
98
99
  return {
99
100
  video: {
101
+ background: "transparent",
100
102
  display: "block",
101
103
  objectFit: "cover",
102
104
  maxWidth: "100%",
@@ -113,7 +115,10 @@ var useStyles = (0, _jss).createUseStyles(function() {
113
115
  },
114
116
  "$wrapper &": {
115
117
  borderRadius: 0,
116
- position: "absolute",
118
+ position: function position(param) {
119
+ var aspectRatio = param.aspectRatio;
120
+ return aspectRatio ? "absolute" : "static";
121
+ },
117
122
  width: "100%",
118
123
  height: "100%",
119
124
  top: 0,
@@ -132,7 +137,7 @@ var useStyles = (0, _jss).createUseStyles(function() {
132
137
  paddingTop: function paddingTop(param) {
133
138
  var aspectRatio = param.aspectRatio, width = param.width;
134
139
  if (!aspectRatio) {
135
- return "initial";
140
+ return 0;
136
141
  }
137
142
  if (width && typeof width === "string" && width.endsWith("%")) {
138
143
  return "".concat(Number(width.replace("%", "")) / aspectRatio, "%");
@@ -144,7 +149,7 @@ var useStyles = (0, _jss).createUseStyles(function() {
144
149
  });
145
150
  /** Transparent 1x1px PNG */ var TRANSPARENT_PIXEL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC";
146
151
  var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
147
- var src1 = _param.src, poster = _param.poster, _autoPlay = _param.autoPlay, autoPlay = _autoPlay === void 0 ? true : _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, [
152
+ var src1 = _param.src, poster = _param.poster, _autoPlay = _param.autoPlay, autoPlay = _autoPlay === void 0 ? !(0, _platform).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, [
148
153
  "src",
149
154
  "poster",
150
155
  "autoPlay",
@@ -198,7 +203,11 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
198
203
  } else {
199
204
  width = props.width || "100%";
200
205
  }
201
- var needsWrapper = withCssAspectRatio && !supportsAspectRatio;
206
+ /**
207
+ * In safari, when using a video with poster, the transition from pause to play does a flicker,
208
+ * To avoid this, in Safari browsers, instead of using the poster attribute, we use a
209
+ * wrapper with the poster as background image
210
+ */ var needsWrapper = (0, _platform).isSafari() || withCssAspectRatio && !supportsAspectRatio;
202
211
  var video1 = /*#__PURE__*/ (0, _jsxRuntime).jsx("video", _objectSpread({
203
212
  ref: (0, _common).combineRefs(ref, videoRef),
204
213
  playsInline: true,
@@ -207,14 +216,16 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
207
216
  autoPlay: autoPlay,
208
217
  muted: muted,
209
218
  loop: loop
210
- }, !needsWrapper ? {
219
+ }, needsWrapper ? {
220
+ width: "100%"
221
+ } : {
211
222
  width: width,
212
223
  height: height
213
- } : {}, {
224
+ }, {
214
225
  className: classes.video,
215
226
  preload: preload,
216
227
  // This transparent pixel fallback avoids showing the ugly "play" image in android webviews
217
- poster: poster || TRANSPARENT_PIXEL
228
+ poster: needsWrapper ? TRANSPARENT_PIXEL : poster || TRANSPARENT_PIXEL
218
229
  }, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
219
230
  children: sources.map(function(param, index) {
220
231
  var src = param.src, type = param.type;
@@ -228,7 +239,10 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
228
239
  return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
229
240
  style: {
230
241
  width: width,
231
- height: height
242
+ height: height,
243
+ backgroundImage: poster ? 'url("'.concat(poster, '")') : undefined,
244
+ backgroundSize: "cover",
245
+ backgroundPosition: "50% 50%"
232
246
  },
233
247
  className: classes.wrapper,
234
248
  children: video1
package/dist-es/button.js CHANGED
@@ -179,13 +179,12 @@ var usePrimaryButtonStyles = createUseStyles(function(theme) {
179
179
  // - Make sure that in FF hover still has it's proper styles
180
180
  // - Media query with "coarse" (mobile), avoids that in devices that have coarse implemented, focus style doesn't get stuck
181
181
  // Must be always declared for Firefox
182
- "&:hover:not([disabled])": {
183
- backgroundColor: theme.colors.buttonPrimaryBackgroundHover,
184
- "@media (pointer: coarse)": {
185
- // Revert hover background in touch devices
186
- backgroundColor: theme.colors.buttonPrimaryBackground
187
- }
188
- }
182
+ "&:hover:not([disabled])": _defineProperty({
183
+ backgroundColor: theme.colors.buttonPrimaryBackgroundHover
184
+ }, theme.mq.touchableOnly, {
185
+ // Revert hover background in touch devices
186
+ backgroundColor: theme.colors.buttonPrimaryBackground
187
+ })
189
188
  },
190
189
  inverse: {
191
190
  color: theme.colors.textButtonPrimaryInverse,
@@ -195,14 +194,13 @@ var usePrimaryButtonStyles = createUseStyles(function(theme) {
195
194
  color: theme.colors.textButtonPrimaryInverseSelected
196
195
  },
197
196
  "&[disabled]:not($isLoading)": disabledStyle,
198
- "&:hover:not([disabled])": {
197
+ "&:hover:not([disabled])": _defineProperty({
199
198
  color: theme.colors.textButtonPrimaryInverseSelected,
200
- backgroundColor: theme.colors.buttonPrimaryBackgroundSelectedInverse,
201
- "@media (pointer: coarse)": {
202
- color: theme.colors.textButtonPrimaryInverse,
203
- backgroundColor: theme.colors.buttonPrimaryBackgroundInverse
204
- }
205
- }
199
+ backgroundColor: theme.colors.buttonPrimaryBackgroundSelectedInverse
200
+ }, theme.mq.touchableOnly, {
201
+ color: theme.colors.textButtonPrimaryInverse,
202
+ backgroundColor: theme.colors.buttonPrimaryBackgroundInverse
203
+ })
206
204
  }
207
205
  });
208
206
  });
@@ -224,9 +222,7 @@ var useSecondaryButtonStyles = createUseStyles(function(theme) {
224
222
  light: _objectSpread({}, buttonSecondaryLightStyle(theme), {
225
223
  "&:enabled:active": _objectSpread({}, buttonSecondaryHoverLightStyle(theme)),
226
224
  "&[disabled]:not($isLoading)": disabledStyle,
227
- "&:hover:not([disabled])": _objectSpread({}, buttonSecondaryHoverLightStyle(theme), {
228
- "@media (pointer: coarse)": _objectSpread({}, buttonSecondaryLightStyle(theme))
229
- })
225
+ "&:hover:not([disabled])": _objectSpread({}, buttonSecondaryHoverLightStyle(theme), _defineProperty({}, theme.mq.touchableOnly, _objectSpread({}, buttonSecondaryLightStyle(theme))))
230
226
  }),
231
227
  inverse: {
232
228
  borderColor: theme.colors.buttonSecondaryBorderInverse,
@@ -236,14 +232,13 @@ var useSecondaryButtonStyles = createUseStyles(function(theme) {
236
232
  color: theme.colors.textButtonSecondaryInverseSelected
237
233
  },
238
234
  "&[disabled]:not($isLoading)": disabledStyle,
239
- "&:hover:not([disabled])": {
235
+ "&:hover:not([disabled])": _defineProperty({
240
236
  borderColor: theme.colors.buttonSecondaryBorderSelectedInverse,
241
- color: theme.colors.textButtonSecondaryInverseSelected,
242
- "@media (pointer: coarse)": {
243
- borderColor: theme.colors.buttonSecondaryBorderInverse,
244
- color: theme.colors.textButtonSecondaryInverse
245
- }
246
- }
237
+ color: theme.colors.textButtonSecondaryInverseSelected
238
+ }, theme.mq.touchableOnly, {
239
+ borderColor: theme.colors.buttonSecondaryBorderInverse,
240
+ color: theme.colors.textButtonSecondaryInverse
241
+ })
247
242
  }
248
243
  });
249
244
  });
@@ -257,13 +252,12 @@ var dangerButtonStyles = function(theme) {
257
252
  "&[disabled]:not($isLoading)": {
258
253
  opacity: 0.5
259
254
  },
260
- "&:hover:not([disabled])": {
261
- backgroundColor: theme.colors.buttonDangerBackgroundHover,
262
- "@media (pointer: coarse)": {
263
- // Revert hover background in touch devices
264
- backgroundColor: theme.colors.buttonDangerBackground
265
- }
266
- }
255
+ "&:hover:not([disabled])": _defineProperty({
256
+ backgroundColor: theme.colors.buttonDangerBackgroundHover
257
+ }, theme.mq.touchableOnly, {
258
+ // Revert hover background in touch devices
259
+ backgroundColor: theme.colors.buttonDangerBackground
260
+ })
267
261
  };
268
262
  };
269
263
  var useDangerButtonStyles = createUseStyles(function(theme) {
@@ -447,12 +441,11 @@ var useButtonLinkStyles = createUseStyles(function(theme) {
447
441
  "&:enabled:active": {
448
442
  backgroundColor: theme.colors.buttonLinkBackgroundSelected
449
443
  },
450
- "&:hover:not([disabled])": {
451
- backgroundColor: theme.colors.buttonLinkBackgroundSelected,
452
- "@media (pointer: coarse)": {
453
- backgroundColor: "initial"
454
- }
455
- },
444
+ "&:hover:not([disabled])": _defineProperty({
445
+ backgroundColor: theme.colors.buttonLinkBackgroundSelected
446
+ }, theme.mq.touchableOnly, {
447
+ backgroundColor: "initial"
448
+ }),
456
449
  "&[disabled]": disabledStyle
457
450
  },
458
451
  inverse: {
@@ -460,12 +453,11 @@ var useButtonLinkStyles = createUseStyles(function(theme) {
460
453
  "&:enabled:active": {
461
454
  backgroundColor: theme.colors.buttonLinkBackgroundSelectedInverse
462
455
  },
463
- "&:hover:not([disabled])": {
464
- backgroundColor: theme.colors.buttonLinkBackgroundSelectedInverse,
465
- "@media (pointer: coarse)": {
466
- backgroundColor: "initial"
467
- }
468
- }
456
+ "&:hover:not([disabled])": _defineProperty({
457
+ backgroundColor: theme.colors.buttonLinkBackgroundSelectedInverse
458
+ }, theme.mq.touchableOnly, {
459
+ backgroundColor: "initial"
460
+ })
469
461
  },
470
462
  aligned: {
471
463
  marginLeft: -padding