@telefonica/mistica 10.27.0 → 10.29.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.md CHANGED
@@ -1,3 +1,34 @@
1
+ # [10.29.0](https://github.com/Telefonica/mistica-web/compare/v10.28.1...v10.29.0) (2022-03-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Touchable:** Added loadOnTop prop ([#440](https://github.com/Telefonica/mistica-web/issues/440)) ([884940f](https://github.com/Telefonica/mistica-web/commit/884940fc1b924fef8f398af1c71313068c0e7ad7))
7
+
8
+ ## [10.28.1](https://github.com/Telefonica/mistica-web/compare/v10.28.0...v10.28.1) (2022-03-09)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **Carousel:** undefined is not an object error in iOS 14 ([#439](https://github.com/Telefonica/mistica-web/issues/439)) ([ef1cf63](https://github.com/Telefonica/mistica-web/commit/ef1cf63a1e7b9009cab28a0bb23b3dd6540defbb))
14
+ * **FixedFooterLayout:** shadow style ([#437](https://github.com/Telefonica/mistica-web/issues/437)) ([d9d9641](https://github.com/Telefonica/mistica-web/commit/d9d9641b101484f8e1d3e5bf9476821cdef517e3))
15
+ * **Popover:** arrow border radius ([#435](https://github.com/Telefonica/mistica-web/issues/435)) ([42eb25e](https://github.com/Telefonica/mistica-web/commit/42eb25ea9e071a38a3b44c1934aef949cfc7c9a5))
16
+ * **Popover:** text styles ([#436](https://github.com/Telefonica/mistica-web/issues/436)) ([4c156cb](https://github.com/Telefonica/mistica-web/commit/4c156cbebae937175a66cf3afb5abfca8051cfd0))
17
+ * **select:** issue with cropped text ([#426](https://github.com/Telefonica/mistica-web/issues/426)) ([2c6e027](https://github.com/Telefonica/mistica-web/commit/2c6e027f643b3458359e6866bc6d9a10afb1e5b4))
18
+ * **Slideshow:** scroll snap stop on android ([#434](https://github.com/Telefonica/mistica-web/issues/434)) ([4ccb6a6](https://github.com/Telefonica/mistica-web/commit/4ccb6a6822a936ae185470bf8bf01bb4224a6626))
19
+
20
+ # [10.28.0](https://github.com/Telefonica/mistica-web/compare/v10.27.0...v10.28.0) (2022-03-01)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **popover:** Fix size in iOS when rendered offscreen ([#431](https://github.com/Telefonica/mistica-web/issues/431)) ([9cb3a29](https://github.com/Telefonica/mistica-web/commit/9cb3a290ea2b6c434c715bb7c18bca9678c5a006))
26
+
27
+
28
+ ### Features
29
+
30
+ * **Carousel:** autoplay only move when carousel is visible ([#430](https://github.com/Telefonica/mistica-web/issues/430)) ([fa74b04](https://github.com/Telefonica/mistica-web/commit/fa74b04e1d6171809ea8a5c1522cb0622b9dfc01))
31
+
1
32
  # [10.27.0](https://github.com/Telefonica/mistica-web/compare/v10.26.0...v10.27.0) (2022-02-25)
2
33
 
3
34
 
package/dist/button.d.ts CHANGED
@@ -36,6 +36,7 @@ export interface OnPressButtonProps extends CommonProps {
36
36
  export interface HrefButtonProps extends CommonProps {
37
37
  href: string;
38
38
  newTab?: boolean;
39
+ loadOnTop?: boolean;
39
40
  submit?: undefined;
40
41
  fake?: undefined;
41
42
  onPress?: undefined;
package/dist/button.js CHANGED
@@ -442,7 +442,8 @@ var Button = function Button(props) {
442
442
  if (props.href || props.href === '') {
443
443
  return(/*#__PURE__*/ (0, _jsxRuntime).jsx(_touchable.default, _objectSpread({}, commonProps, {
444
444
  href: props.href,
445
- newTab: props.newTab
445
+ newTab: props.newTab,
446
+ loadOnTop: props.loadOnTop
446
447
  })));
447
448
  }
448
449
  if (process.env.NODE_ENV !== 'production') {
@@ -41,6 +41,7 @@ export type HrefButtonProps = {
41
41
  ...$Exact<CommonProps>,
42
42
  href: string,
43
43
  newTab?: boolean,
44
+ loadOnTop?: boolean,
44
45
  };
45
46
  export type FakeButtonProps = {
46
47
  ...$Exact<CommonProps>,
package/dist/carousel.js CHANGED
@@ -18,6 +18,8 @@ var _themeVariantContext = require("./theme-variant-context");
18
18
  var _color = require("./utils/color");
19
19
  var _image = require("./image");
20
20
  var _dom = require("./utils/dom");
21
+ var _platform = require("./utils/platform");
22
+ var _documentVisibility = require("./utils/document-visibility");
21
23
  function _interopRequireDefault(obj) {
22
24
  return obj && obj.__esModule ? obj : {
23
25
  default: obj
@@ -131,6 +133,11 @@ function _unsupportedIterableToArray(o, minLen) {
131
133
  if (n === "Map" || n === "Set") return Array.from(n);
132
134
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
133
135
  }
136
+ var useShouldAutoplay = function useShouldAutoplay(autoplay, ref) {
137
+ var isDocumentVisible = (0, _documentVisibility).useDocumentVisibility();
138
+ var isInViewport = (0, _hooks).useIsInViewport(ref, false);
139
+ return isInViewport && isDocumentVisible && !!autoplay;
140
+ };
134
141
  var useBulletsStyles = (0, _jss).createUseStyles(function(theme) {
135
142
  return {
136
143
  bullet: _defineProperty({
@@ -268,6 +275,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
268
275
  }
269
276
  })),
270
277
  item: (_obj2 = {
278
+ scrollSnapStop: (0, _platform).isAndroid(theme.platformOverrides) ? 'always' : 'normal',
271
279
  scrollSnapAlign: 'start',
272
280
  flexShrink: 0,
273
281
  width: function width(param) {
@@ -448,12 +456,24 @@ var BaseCarousel = function BaseCarousel(param) {
448
456
  };
449
457
  var calcItemScrollPositions = function calcItemScrollPositions() {
450
458
  var maxScroll = carouselEl.scrollWidth - carouselEl.clientWidth;
459
+ var getItemScrollMargin = function getItemScrollMargin(itemIndex) {
460
+ if (centered) {
461
+ return 0;
462
+ }
463
+ if (itemIndex === 0) {
464
+ return 0;
465
+ }
466
+ if (isDesktopOrBigger) {
467
+ return -gap;
468
+ }
469
+ return mobilePageOffsetConfig.prev;
470
+ };
451
471
  setItemScrollPositions(Array.from(carouselEl.querySelectorAll('[data-item]')).map(function(itemEl, idx) {
452
472
  if (idx === items.length - 1) {
453
473
  return maxScroll;
454
474
  }
455
475
  var offsetLeft = itemEl.offsetLeft;
456
- var scrollMargin = Number(getComputedStyle(itemEl).scrollMargin.replace('px', ''));
476
+ var scrollMargin = getItemScrollMargin(idx);
457
477
  var scrollPosition = centered && !isDesktopOrBigger ? offsetLeft - itemEl.clientWidth / 2 : offsetLeft;
458
478
  return Math.min(scrollPosition - scrollMargin - carouselEl.offsetLeft, maxScroll);
459
479
  }));
@@ -525,8 +545,9 @@ var BaseCarousel = function BaseCarousel(param) {
525
545
  }, [
526
546
  scrollPositions
527
547
  ]);
548
+ var shouldAutoplay = useShouldAutoplay(!!autoplay, carouselRef);
528
549
  React.useEffect(function() {
529
- if (autoplay) {
550
+ if (shouldAutoplay && autoplay) {
530
551
  var time = typeof autoplay === 'boolean' ? DEFAULT_AUTOPLAY_TIME : autoplay.time;
531
552
  var loop = typeof autoplay === 'object' && autoplay.loop;
532
553
  var interval = setInterval(function() {
@@ -547,7 +568,8 @@ var BaseCarousel = function BaseCarousel(param) {
547
568
  }, [
548
569
  autoplay,
549
570
  goNext,
550
- scrollRight1
571
+ scrollRight1,
572
+ shouldAutoplay
551
573
  ]);
552
574
  var currentPageIndex = calcCurrentPageIndex(scrollLeft1, pagesScrollPositions);
553
575
  React.useEffect(function() {
@@ -672,6 +694,7 @@ var useSlideshowStyles = (0, _jss).createUseStyles(function(theme) {
672
694
  })),
673
695
  item: {
674
696
  width: '100%',
697
+ scrollSnapStop: (0, _platform).isAndroid(theme.platformOverrides) ? 'always' : 'normal',
675
698
  scrollSnapAlign: 'start',
676
699
  flexShrink: 0
677
700
  },
@@ -756,8 +779,9 @@ var Slideshow = function Slideshow(param) {
756
779
  }, [
757
780
  items.length
758
781
  ]);
782
+ var shouldAutoplay = useShouldAutoplay(!!autoplay, carouselRef);
759
783
  React.useEffect(function() {
760
- if (autoplay) {
784
+ if (shouldAutoplay && autoplay) {
761
785
  var time = typeof autoplay === 'boolean' ? DEFAULT_AUTOPLAY_TIME : autoplay.time;
762
786
  var loop = typeof autoplay === 'object' && autoplay.loop;
763
787
  var interval = setInterval(function() {
@@ -778,7 +802,8 @@ var Slideshow = function Slideshow(param) {
778
802
  }, [
779
803
  autoplay,
780
804
  goNext,
781
- scrollRight2
805
+ scrollRight2,
806
+ shouldAutoplay
782
807
  ]);
783
808
  React.useEffect(function() {
784
809
  if (onPageChange) {
@@ -134,7 +134,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
134
134
  zIndex: 1
135
135
  },
136
136
  shadow: {
137
- boxShadow: '0 -1px 2px 0 rgba(0, 0, 0, 0.2)'
137
+ boxShadow: '0 -3px 8px 0 rgba(0, 0, 0, 0.15)'
138
138
  }
139
139
  });
140
140
  });
package/dist/hooks.d.ts CHANGED
@@ -17,3 +17,10 @@ export declare const useWindowSize: () => {
17
17
  export declare const useWindowHeight: () => number;
18
18
  export declare const useWindowWidth: () => number;
19
19
  export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
20
+ declare type IntersectionObserverOptions = {
21
+ root?: Element | Document | null;
22
+ rootMargin?: string;
23
+ threshold?: number | number[];
24
+ };
25
+ export declare const useIsInViewport: (ref: React.RefObject<HTMLElement>, defaultValue: boolean, options?: IntersectionObserverOptions | undefined) => boolean;
26
+ export {};
package/dist/hooks.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.useIsomorphicLayoutEffect = exports.useWindowWidth = exports.useWindowHeight = exports.useWindowSize = exports.useAriaId = exports.useElementDimensions = exports.useScreenSize = exports.useDisableBodyScroll = exports.useTheme = void 0;
5
+ exports.useIsInViewport = exports.useIsomorphicLayoutEffect = exports.useWindowWidth = exports.useWindowHeight = exports.useWindowSize = exports.useAriaId = exports.useElementDimensions = exports.useScreenSize = exports.useDisableBodyScroll = exports.useTheme = void 0;
6
6
  var React = _interopRequireWildcard(require("react"));
7
7
  var _themeContext = _interopRequireDefault(require("./theme-context"));
8
8
  var _screenSizeContext = _interopRequireDefault(require("./screen-size-context"));
@@ -217,3 +217,32 @@ var useWindowWidth = function useWindowWidth() {
217
217
  exports.useWindowWidth = useWindowWidth;
218
218
  var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
219
219
  exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
220
+ var useIsInViewport = function useIsInViewport(ref, defaultValue, options) {
221
+ var ref7 = _slicedToArray(React.useState(defaultValue), 2), isInViewport = ref7[0], setIsInViewport = ref7[1];
222
+ React.useEffect(function() {
223
+ if (!ref.current) {
224
+ return;
225
+ }
226
+ if (typeof window.IntersectionObserver === 'undefined') {
227
+ return function() {};
228
+ }
229
+ var observer = new IntersectionObserver(function(entries) {
230
+ setIsInViewport(entries[0].isIntersecting);
231
+ }, {
232
+ root: options === null || options === void 0 ? void 0 : options.root,
233
+ rootMargin: options === null || options === void 0 ? void 0 : options.rootMargin,
234
+ threshold: options === null || options === void 0 ? void 0 : options.threshold
235
+ });
236
+ observer.observe(ref.current);
237
+ return function() {
238
+ observer.disconnect();
239
+ };
240
+ }, [
241
+ ref,
242
+ options === null || options === void 0 ? void 0 : options.root,
243
+ options === null || options === void 0 ? void 0 : options.rootMargin,
244
+ options === null || options === void 0 ? void 0 : options.threshold
245
+ ]);
246
+ return isInViewport;
247
+ };
248
+ exports.useIsInViewport = useIsInViewport;
@@ -19,3 +19,14 @@ declare export var useWindowSize: () => {
19
19
  declare export var useWindowHeight: () => number;
20
20
  declare export var useWindowWidth: () => number;
21
21
  declare export var useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
22
+ declare type IntersectionObserverOptions = {
23
+ root?: Element | Document | null,
24
+ rootMargin?: string,
25
+ threshold?: number | Array<number>,
26
+ };
27
+ declare export var useIsInViewport: (
28
+ ref: React.Ref<HTMLElement>,
29
+ defaultValue: boolean,
30
+ options?: IntersectionObserverOptions | void
31
+ ) => boolean;
32
+ declare export {};
package/dist/index.d.ts CHANGED
@@ -87,8 +87,9 @@ export { default as IconError } from './icons/icon-error';
87
87
  export { default as IconSuccess } from './icons/icon-success';
88
88
  export { default as IconSuccessVivo } from './icons/icon-success-vivo';
89
89
  export { default as Circle } from './circle';
90
- export { useTheme, useScreenSize, useElementDimensions, useAriaId, useWindowSize, useWindowHeight, useWindowWidth, } from './hooks';
90
+ export { useTheme, useScreenSize, useElementDimensions, useAriaId, useWindowSize, useWindowHeight, useWindowWidth, useIsInViewport, } from './hooks';
91
91
  export type { ThemeConfig, ColorScheme } from './theme';
92
+ export { useDocumentVisibility } from './utils/document-visibility';
92
93
  export { ThemeVariant, useIsInverseVariant } from './theme-variant-context';
93
94
  export type { Skin, SkinName } from './skins/types';
94
95
  export { VIVO_SKIN, O2_CLASSIC_SKIN, O2_SKIN, MOVISTAR_SKIN, TELEFONICA_SKIN, BLAU_SKIN, } from './skins/constants';
package/dist/index.js CHANGED
@@ -818,6 +818,18 @@ Object.defineProperty(exports, "useWindowWidth", {
818
818
  return _hooks.useWindowWidth;
819
819
  }
820
820
  });
821
+ Object.defineProperty(exports, "useIsInViewport", {
822
+ enumerable: true,
823
+ get: function() {
824
+ return _hooks.useIsInViewport;
825
+ }
826
+ });
827
+ Object.defineProperty(exports, "useDocumentVisibility", {
828
+ enumerable: true,
829
+ get: function() {
830
+ return _documentVisibility.useDocumentVisibility;
831
+ }
832
+ });
821
833
  Object.defineProperty(exports, "ThemeVariant", {
822
834
  enumerable: true,
823
835
  get: function() {
@@ -8366,6 +8378,7 @@ var _iconSuccess = _interopRequireDefault(require("./icons/icon-success"));
8366
8378
  var _iconSuccessVivo = _interopRequireDefault(require("./icons/icon-success-vivo"));
8367
8379
  var _circle = _interopRequireDefault(require("./circle"));
8368
8380
  var _hooks = require("./hooks");
8381
+ var _documentVisibility = require("./utils/document-visibility");
8369
8382
  var _themeVariantContext = require("./theme-variant-context");
8370
8383
  var _constants = require("./skins/constants");
8371
8384
  var _utils = require("./skins/utils");
@@ -143,8 +143,10 @@ declare export {
143
143
  useWindowSize,
144
144
  useWindowHeight,
145
145
  useWindowWidth,
146
+ useIsInViewport,
146
147
  } from "./hooks";
147
148
  export type { ThemeConfig, ColorScheme } from "./theme";
149
+ declare export { useDocumentVisibility } from "./utils/document-visibility";
148
150
  declare export {
149
151
  ThemeVariant,
150
152
  useIsInverseVariant,
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.PACKAGE_VERSION = void 0;
6
- var PACKAGE_VERSION = '10.27.0';
6
+ var PACKAGE_VERSION = '10.29.0';
7
7
  exports.PACKAGE_VERSION = PACKAGE_VERSION;
package/dist/popover.js CHANGED
@@ -132,7 +132,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
132
132
  left: '50%',
133
133
  transform: 'translate(-50%, -50%) rotate(45deg)',
134
134
  border: "1px solid ".concat(theme.colors.divider),
135
- borderRadius: 4,
135
+ borderRadius: 2,
136
136
  boxShadow: function boxShadow(param) {
137
137
  var position = param.position;
138
138
  return position === 'bottom' ? 'initial' : "0 0 4px 0 rgba(0, 0, 0, ".concat(shadowAlpha, ")");
@@ -160,7 +160,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
160
160
  title: {
161
161
  marginBottom: 4,
162
162
  color: theme.colors.textPrimary,
163
- fontWeight: 500,
163
+ fontWeight: 400,
164
164
  lineHeight: 1.5,
165
165
  fontSize: 16
166
166
  },
@@ -186,7 +186,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
186
186
  marginRight: 0
187
187
  },
188
188
  text: {
189
- color: theme.colors.textPrimary,
189
+ color: theme.colors.textSecondary,
190
190
  textAlign: 'left',
191
191
  lineHeight: 1.42857142,
192
192
  fontSize: 14
@@ -204,8 +204,9 @@ var getPosition = function getPosition() {
204
204
  var position = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultPositionDesktop, isTabletOrSmaller = arguments.length > 1 ? arguments[1] : void 0;
205
205
  return isTabletOrSmaller && (position === 'left' || position === 'right') ? defaultPositionMobile : position;
206
206
  };
207
- var getWidth = function getWidth(isTabletOrSmaller, width) {
208
- return isTabletOrSmaller ? window.innerWidth - marginLeftRightMobile * 2 : getWidthDesktop(width);
207
+ var getWidth = function getWidth(isTabletOrSmaller, isIos, width) {
208
+ // in iOS, when the webview is rendered offscreen (eg. acccount tab), window.innerWidth value is wrong, it returns strange values like 0 or 80.
209
+ return isTabletOrSmaller ? (isIos ? window.screen.width : window.innerWidth) - marginLeftRightMobile * 2 : getWidthDesktop(width);
209
210
  };
210
211
  var getPositionStyles = function getPositionStyles(position, width, targetPosition, isTabletOrSmaller) {
211
212
  var containerStylesByPos = {
@@ -278,12 +279,12 @@ var getTargetPosition = function getTargetPosition(targetWrapper) {
278
279
  };
279
280
  var Popover = function Popover(param) {
280
281
  var description = param.description, title = param.title, onClose = param.onClose, trackingEvent = param.trackingEvent, position = param.position, width = param.width, target = param.target, asset = param.asset, _isVisible = param.isVisible, isVisible = _isVisible === void 0 ? true : _isVisible;
281
- var ref = (0, _hooks).useTheme(), texts = ref.texts, colors = ref.colors;
282
+ var ref = (0, _hooks).useTheme(), texts = ref.texts, colors = ref.colors, isIos = ref.isIos;
282
283
  var isTabletOrSmaller = (0, _hooks).useScreenSize().isTabletOrSmaller;
283
284
  var ref1 = _slicedToArray(React.useState(null), 2), targetPosition = ref1[0], setTargetPosition = ref1[1];
284
285
  var targetWrapperRef = React.useRef(null);
285
286
  position = getPosition(position, isTabletOrSmaller);
286
- var innerWidth = getWidth(isTabletOrSmaller, width);
287
+ var innerWidth = getWidth(isTabletOrSmaller, isIos, width);
287
288
  var classes = useStyles({
288
289
  position: position
289
290
  });
package/dist/select.js CHANGED
@@ -175,6 +175,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
175
175
  var label = param.label;
176
176
  return label ? 27 : 17;
177
177
  },
178
+ lineHeight: '20px',
178
179
  fontSize: 16,
179
180
  color: theme.colors.textPrimary,
180
181
  opacity: function opacity(param) {
@@ -21,6 +21,7 @@ var _hooks = require("./hooks");
21
21
  var _tabFocus = _interopRequireDefault(require("./tab-focus"));
22
22
  var _portal = require("./portal");
23
23
  var _modalContextProvider = _interopRequireDefault(require("./modal-context-provider"));
24
+ var _documentVisibility = require("./utils/document-visibility");
24
25
  function _interopRequireDefault(obj) {
25
26
  return obj && obj.__esModule ? obj : {
26
27
  default: obj
@@ -229,11 +230,13 @@ var ThemeContextProvider = function ThemeContextProvider(param) {
229
230
  children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_modalContextProvider.default, {
230
231
  children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_themeContext.default.Provider, {
231
232
  value: contextTheme,
232
- children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_ariaIdGetterContext.default.Provider, {
233
- value: getAriaId,
234
- children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_screenSizeContextProvider.default, {
235
- children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_dialog.default, {
236
- children: children
233
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_documentVisibility.DocumentVisibilityProvider, {
234
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_ariaIdGetterContext.default.Provider, {
235
+ value: getAriaId,
236
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_screenSizeContextProvider.default, {
237
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_dialog.default, {
238
+ children: children
239
+ })
237
240
  })
238
241
  })
239
242
  })
@@ -27,6 +27,7 @@ interface CommonProps {
27
27
  export interface PropsHref extends CommonProps {
28
28
  href: string;
29
29
  newTab?: boolean;
30
+ loadOnTop?: boolean;
30
31
  to?: undefined;
31
32
  onPress?: undefined;
32
33
  }
@@ -47,6 +48,7 @@ export interface PropsMaybeHref extends CommonProps {
47
48
  maybe: true;
48
49
  href?: string;
49
50
  newTab?: boolean;
51
+ loadOnTop?: boolean;
50
52
  to?: undefined;
51
53
  onPress?: undefined;
52
54
  }
package/dist/touchable.js CHANGED
@@ -68,9 +68,11 @@ function _objectSpread(target) {
68
68
  return target;
69
69
  }
70
70
  var redirect = function redirect(url) {
71
- var external = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
71
+ var external = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, loadOnTop = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
72
72
  if (external) {
73
73
  window.open(url, '_blank');
74
+ } else if (loadOnTop) {
75
+ window.open(url, '_top');
74
76
  } else {
75
77
  document.location.href = url;
76
78
  }
@@ -141,6 +143,7 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
141
143
  }, (0, _dom).getPrefixedDataAttributes(props.dataAttributes));
142
144
  var type = props.type ? props.type : 'button';
143
145
  var openNewTab = !!props.href && !!props.newTab;
146
+ var loadOnTop = !openNewTab && !!props.href && !!props.loadOnTop;
144
147
  var onPress = function onPress(event) {
145
148
  if (props.onPress) {
146
149
  props.onPress(event);
@@ -188,7 +191,7 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
188
191
  }
189
192
  event.preventDefault();
190
193
  trackOnce(function() {
191
- return redirect(getHref(), openNewTab);
194
+ return redirect(getHref(), openNewTab, loadOnTop);
192
195
  });
193
196
  };
194
197
  var handleKeyDown = function handleKeyDown(event) {
@@ -204,7 +207,11 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
204
207
  onClick: handleHrefClick,
205
208
  onKeyDown: handleKeyDown,
206
209
  href: props.disabled ? undefined : getHref(),
207
- target: openNewTab ? '_blank' : undefined,
210
+ target: function() {
211
+ if (openNewTab) return '_blank';
212
+ if (loadOnTop) return '_top';
213
+ return undefined;
214
+ }(),
208
215
  rel: openNewTab ? 'noopener noreferrer' : undefined,
209
216
  ref: ref,
210
217
  children: [
@@ -36,6 +36,7 @@ export type PropsHref = {
36
36
  ...$Exact<CommonProps>,
37
37
  href: string,
38
38
  newTab?: boolean,
39
+ loadOnTop?: boolean,
39
40
  };
40
41
  export type PropsOnPress = {
41
42
  ...$Exact<CommonProps>,
@@ -53,6 +54,7 @@ export type PropsMaybeHref = {
53
54
  maybe: true,
54
55
  href?: string,
55
56
  newTab?: boolean,
57
+ loadOnTop?: boolean,
56
58
  };
57
59
  export type PropsMaybeTo = {
58
60
  ...$Exact<CommonProps>,
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ declare type Props = {
3
+ hidden?: boolean;
4
+ children: React.ReactNode;
5
+ };
6
+ export declare const DocumentVisibilityProvider: React.FC<Props>;
7
+ export declare const useDocumentVisibility: () => boolean;
8
+ export {};
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.useDocumentVisibility = exports.DocumentVisibilityProvider = void 0;
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _hooks = require("../hooks");
9
+ var _platform = require("./platform");
10
+ function _interopRequireWildcard(obj) {
11
+ if (obj && obj.__esModule) {
12
+ return obj;
13
+ } else {
14
+ var newObj = {};
15
+ if (obj != null) {
16
+ for(var key in obj){
17
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
18
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
19
+ if (desc.get || desc.set) {
20
+ Object.defineProperty(newObj, key, desc);
21
+ } else {
22
+ newObj[key] = obj[key];
23
+ }
24
+ }
25
+ }
26
+ }
27
+ newObj.default = obj;
28
+ return newObj;
29
+ }
30
+ }
31
+ function _arrayLikeToArray(arr, len) {
32
+ if (len == null || len > arr.length) len = arr.length;
33
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34
+ return arr2;
35
+ }
36
+ function _arrayWithHoles(arr) {
37
+ if (Array.isArray(arr)) return arr;
38
+ }
39
+ function _iterableToArrayLimit(arr, i) {
40
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
41
+ if (_i == null) return;
42
+ var _arr = [];
43
+ var _n = true;
44
+ var _d = false;
45
+ var _s, _e;
46
+ try {
47
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
48
+ _arr.push(_s.value);
49
+ if (i && _arr.length === i) break;
50
+ }
51
+ } catch (err) {
52
+ _d = true;
53
+ _e = err;
54
+ } finally{
55
+ try {
56
+ if (!_n && _i["return"] != null) _i["return"]();
57
+ } finally{
58
+ if (_d) throw _e;
59
+ }
60
+ }
61
+ return _arr;
62
+ }
63
+ function _nonIterableRest() {
64
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
65
+ }
66
+ function _slicedToArray(arr, i) {
67
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
68
+ }
69
+ function _unsupportedIterableToArray(o, minLen) {
70
+ if (!o) return;
71
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
72
+ var n = Object.prototype.toString.call(o).slice(8, -1);
73
+ if (n === "Object" && o.constructor) n = o.constructor.name;
74
+ if (n === "Map" || n === "Set") return Array.from(n);
75
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
76
+ }
77
+ var isDocumentVisible = function isDocumentVisible() {
78
+ return typeof document !== 'undefined' && document.visibilityState === 'visible';
79
+ };
80
+ var DocumentVisibilityContext = /*#__PURE__*/ React.createContext(true);
81
+ var DocumentVisibilityProvider = function DocumentVisibilityProvider(param) {
82
+ var hidden = param.hidden, children = param.children;
83
+ var platformOverrides = (0, _hooks).useTheme().platformOverrides;
84
+ var ref = _slicedToArray(React.useState(!hidden), 2), visible = ref[0], setVisible = ref[1];
85
+ React.useEffect(function() {
86
+ var visibilitychangeCallback = function visibilitychangeCallback() {
87
+ setVisible(isDocumentVisible());
88
+ };
89
+ var focusCallback = function focusCallback() {
90
+ setVisible(true);
91
+ };
92
+ var blurCallback = function blurCallback() {
93
+ setVisible(false);
94
+ };
95
+ setVisible(isDocumentVisible());
96
+ document.addEventListener('visibilitychange', visibilitychangeCallback);
97
+ document.addEventListener('focus', focusCallback);
98
+ document.addEventListener('blur', blurCallback);
99
+ return function() {
100
+ document.removeEventListener('visibilitychange', visibilitychangeCallback);
101
+ document.removeEventListener('focus', focusCallback);
102
+ document.removeEventListener('blur', blurCallback);
103
+ };
104
+ }, []);
105
+ // Workaround for this bug: https://jira.tuenti.io/jira/browse/ACCOUNT-10938
106
+ // In Android, after ~10 minutes of inactivity, when a background webview receives focus (back navigation from another webview),
107
+ // visibility change event is not fired, this causes problems like the navigation bar not being updated
108
+ var isVisibleNow = isDocumentVisible();
109
+ if ((0, _platform).isAndroid(platformOverrides) && isVisibleNow !== visible) {
110
+ setVisible(isVisibleNow);
111
+ }
112
+ return(/*#__PURE__*/ (0, _jsxRuntime).jsx(DocumentVisibilityContext.Provider, {
113
+ value: visible,
114
+ children: children
115
+ }));
116
+ };
117
+ exports.DocumentVisibilityProvider = DocumentVisibilityProvider;
118
+ var useDocumentVisibility = function useDocumentVisibility() {
119
+ return React.useContext(DocumentVisibilityContext);
120
+ };
121
+ exports.useDocumentVisibility = useDocumentVisibility;
@@ -0,0 +1,10 @@
1
+ // @flow
2
+
3
+ import * as React from "react";
4
+ declare type Props = {
5
+ hidden?: boolean,
6
+ children: React.Node,
7
+ };
8
+ declare export var DocumentVisibilityProvider: React.ComponentType<Props>;
9
+ declare export var useDocumentVisibility: () => boolean;
10
+ declare export {};
package/dist-es/button.js CHANGED
@@ -409,7 +409,8 @@ var Button = function(props) {
409
409
  if (props.href || props.href === '') {
410
410
  return(/*#__PURE__*/ _jsx(Touchable, _objectSpread({}, commonProps, {
411
411
  href: props.href,
412
- newTab: props.newTab
412
+ newTab: props.newTab,
413
+ loadOnTop: props.loadOnTop
413
414
  })));
414
415
  }
415
416
  if (process.env.NODE_ENV !== 'production') {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import IconChevronLeftRegular from './generated/mistica-icons/icon-chevron-left-regular';
4
4
  import IconChevronRightRegular from './generated/mistica-icons/icon-chevron-right-regular';
5
- import { useScreenSize, useTheme } from './hooks';
5
+ import { useIsInViewport, useScreenSize, useTheme } from './hooks';
6
6
  import Inline from './inline';
7
7
  import { createUseStyles } from './jss';
8
8
  import Stack from './stack';
@@ -13,6 +13,8 @@ import { useIsInverseVariant, ThemeVariant } from './theme-variant-context';
13
13
  import { applyAlpha } from './utils/color';
14
14
  import { DisableBorderRadiusProvider } from './image';
15
15
  import { getPrefixedDataAttributes, listenResize } from './utils/dom';
16
+ import { isAndroid } from './utils/platform';
17
+ import { useDocumentVisibility } from './utils/document-visibility';
16
18
  function _arrayLikeToArray(arr, len) {
17
19
  if (len == null || len > arr.length) len = arr.length;
18
20
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -99,6 +101,11 @@ function _unsupportedIterableToArray(o, minLen) {
99
101
  if (n === "Map" || n === "Set") return Array.from(n);
100
102
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
101
103
  }
104
+ var useShouldAutoplay = function(autoplay, ref) {
105
+ var isDocumentVisible = useDocumentVisibility();
106
+ var isInViewport = useIsInViewport(ref, false);
107
+ return isInViewport && isDocumentVisible && !!autoplay;
108
+ };
102
109
  var useBulletsStyles = createUseStyles(function(theme) {
103
110
  return {
104
111
  bullet: _defineProperty({
@@ -235,6 +242,7 @@ var useStyles = createUseStyles(function(theme) {
235
242
  }
236
243
  })),
237
244
  item: (_obj2 = {
245
+ scrollSnapStop: isAndroid(theme.platformOverrides) ? 'always' : 'normal',
238
246
  scrollSnapAlign: 'start',
239
247
  flexShrink: 0,
240
248
  width: function(param) {
@@ -415,12 +423,24 @@ var BaseCarousel = function(param) {
415
423
  };
416
424
  var calcItemScrollPositions = function() {
417
425
  var maxScroll = carouselEl.scrollWidth - carouselEl.clientWidth;
426
+ var getItemScrollMargin = function(itemIndex) {
427
+ if (centered) {
428
+ return 0;
429
+ }
430
+ if (itemIndex === 0) {
431
+ return 0;
432
+ }
433
+ if (isDesktopOrBigger) {
434
+ return -gap;
435
+ }
436
+ return mobilePageOffsetConfig.prev;
437
+ };
418
438
  setItemScrollPositions(Array.from(carouselEl.querySelectorAll('[data-item]')).map(function(itemEl, idx) {
419
439
  if (idx === items.length - 1) {
420
440
  return maxScroll;
421
441
  }
422
442
  var offsetLeft = itemEl.offsetLeft;
423
- var scrollMargin = Number(getComputedStyle(itemEl).scrollMargin.replace('px', ''));
443
+ var scrollMargin = getItemScrollMargin(idx);
424
444
  var scrollPosition = centered && !isDesktopOrBigger ? offsetLeft - itemEl.clientWidth / 2 : offsetLeft;
425
445
  return Math.min(scrollPosition - scrollMargin - carouselEl.offsetLeft, maxScroll);
426
446
  }));
@@ -492,8 +512,9 @@ var BaseCarousel = function(param) {
492
512
  }, [
493
513
  scrollPositions
494
514
  ]);
515
+ var shouldAutoplay = useShouldAutoplay(!!autoplay, carouselRef);
495
516
  React.useEffect(function() {
496
- if (autoplay) {
517
+ if (shouldAutoplay && autoplay) {
497
518
  var time = typeof autoplay === 'boolean' ? DEFAULT_AUTOPLAY_TIME : autoplay.time;
498
519
  var loop = typeof autoplay === 'object' && autoplay.loop;
499
520
  var interval = setInterval(function() {
@@ -514,7 +535,8 @@ var BaseCarousel = function(param) {
514
535
  }, [
515
536
  autoplay,
516
537
  goNext,
517
- scrollRight1
538
+ scrollRight1,
539
+ shouldAutoplay
518
540
  ]);
519
541
  var currentPageIndex = calcCurrentPageIndex(scrollLeft1, pagesScrollPositions);
520
542
  React.useEffect(function() {
@@ -637,6 +659,7 @@ var useSlideshowStyles = createUseStyles(function(theme) {
637
659
  })),
638
660
  item: {
639
661
  width: '100%',
662
+ scrollSnapStop: isAndroid(theme.platformOverrides) ? 'always' : 'normal',
640
663
  scrollSnapAlign: 'start',
641
664
  flexShrink: 0
642
665
  },
@@ -721,8 +744,9 @@ export var Slideshow = function(param) {
721
744
  }, [
722
745
  items.length
723
746
  ]);
747
+ var shouldAutoplay = useShouldAutoplay(!!autoplay, carouselRef);
724
748
  React.useEffect(function() {
725
- if (autoplay) {
749
+ if (shouldAutoplay && autoplay) {
726
750
  var time = typeof autoplay === 'boolean' ? DEFAULT_AUTOPLAY_TIME : autoplay.time;
727
751
  var loop = typeof autoplay === 'object' && autoplay.loop;
728
752
  var interval = setInterval(function() {
@@ -743,7 +767,8 @@ export var Slideshow = function(param) {
743
767
  }, [
744
768
  autoplay,
745
769
  goNext,
746
- scrollRight2
770
+ scrollRight2,
771
+ shouldAutoplay
747
772
  ]);
748
773
  React.useEffect(function() {
749
774
  if (onPageChange) {
@@ -103,7 +103,7 @@ var useStyles = createUseStyles(function(theme) {
103
103
  zIndex: 1
104
104
  },
105
105
  shadow: {
106
- boxShadow: '0 -1px 2px 0 rgba(0, 0, 0, 0.2)'
106
+ boxShadow: '0 -3px 8px 0 rgba(0, 0, 0, 0.15)'
107
107
  }
108
108
  });
109
109
  });
package/dist-es/hooks.js CHANGED
@@ -180,3 +180,31 @@ export var useWindowWidth = function() {
180
180
  // To get around it, we can conditionally useEffect on the server (no-op) and
181
181
  // useLayoutEffect in the browser
182
182
  export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
183
+ export var useIsInViewport = function(ref, defaultValue, options) {
184
+ var ref7 = _slicedToArray(React.useState(defaultValue), 2), isInViewport = ref7[0], setIsInViewport = ref7[1];
185
+ React.useEffect(function() {
186
+ if (!ref.current) {
187
+ return;
188
+ }
189
+ if (typeof window.IntersectionObserver === 'undefined') {
190
+ return function() {};
191
+ }
192
+ var observer = new IntersectionObserver(function(entries) {
193
+ setIsInViewport(entries[0].isIntersecting);
194
+ }, {
195
+ root: options === null || options === void 0 ? void 0 : options.root,
196
+ rootMargin: options === null || options === void 0 ? void 0 : options.rootMargin,
197
+ threshold: options === null || options === void 0 ? void 0 : options.threshold
198
+ });
199
+ observer.observe(ref.current);
200
+ return function() {
201
+ observer.disconnect();
202
+ };
203
+ }, [
204
+ ref,
205
+ options === null || options === void 0 ? void 0 : options.root,
206
+ options === null || options === void 0 ? void 0 : options.rootMargin,
207
+ options === null || options === void 0 ? void 0 : options.threshold
208
+ ]);
209
+ return isInViewport;
210
+ };
package/dist-es/index.js CHANGED
@@ -91,7 +91,8 @@ export { default as IconError } from './icons/icon-error';
91
91
  export { default as IconSuccess } from './icons/icon-success';
92
92
  export { default as IconSuccessVivo } from './icons/icon-success-vivo';
93
93
  export { default as Circle } from './circle';
94
- export { useTheme, useScreenSize, useElementDimensions, useAriaId, useWindowSize, useWindowHeight, useWindowWidth } from './hooks';
94
+ export { useTheme, useScreenSize, useElementDimensions, useAriaId, useWindowSize, useWindowHeight, useWindowWidth, useIsInViewport } from './hooks';
95
+ export { useDocumentVisibility } from './utils/document-visibility';
95
96
  export { ThemeVariant, useIsInverseVariant } from './theme-variant-context';
96
97
  export { VIVO_SKIN, O2_CLASSIC_SKIN, O2_SKIN, MOVISTAR_SKIN, TELEFONICA_SKIN, BLAU_SKIN } from './skins/constants';
97
98
  export { getSkinByName } from './skins/utils';
@@ -1,2 +1,2 @@
1
1
  // DO NOT EDIT THIS FILE. It's autogenerated by set-version.js
2
- export var PACKAGE_VERSION = '10.27.0';
2
+ export var PACKAGE_VERSION = '10.29.0';
@@ -100,7 +100,7 @@ var useStyles = createUseStyles(function(theme) {
100
100
  left: '50%',
101
101
  transform: 'translate(-50%, -50%) rotate(45deg)',
102
102
  border: "1px solid ".concat(theme.colors.divider),
103
- borderRadius: 4,
103
+ borderRadius: 2,
104
104
  boxShadow: function(param) {
105
105
  var position = param.position;
106
106
  return position === 'bottom' ? 'initial' : "0 0 4px 0 rgba(0, 0, 0, ".concat(shadowAlpha, ")");
@@ -128,7 +128,7 @@ var useStyles = createUseStyles(function(theme) {
128
128
  title: {
129
129
  marginBottom: 4,
130
130
  color: theme.colors.textPrimary,
131
- fontWeight: 500,
131
+ fontWeight: 400,
132
132
  lineHeight: 1.5,
133
133
  fontSize: 16
134
134
  },
@@ -154,7 +154,7 @@ var useStyles = createUseStyles(function(theme) {
154
154
  marginRight: 0
155
155
  },
156
156
  text: {
157
- color: theme.colors.textPrimary,
157
+ color: theme.colors.textSecondary,
158
158
  textAlign: 'left',
159
159
  lineHeight: 1.42857142,
160
160
  fontSize: 14
@@ -172,8 +172,9 @@ var getPosition = function() {
172
172
  var position = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultPositionDesktop, isTabletOrSmaller = arguments.length > 1 ? arguments[1] : void 0;
173
173
  return isTabletOrSmaller && (position === 'left' || position === 'right') ? defaultPositionMobile : position;
174
174
  };
175
- var getWidth = function(isTabletOrSmaller, width) {
176
- return isTabletOrSmaller ? window.innerWidth - marginLeftRightMobile * 2 : getWidthDesktop(width);
175
+ var getWidth = function(isTabletOrSmaller, isIos, width) {
176
+ // in iOS, when the webview is rendered offscreen (eg. acccount tab), window.innerWidth value is wrong, it returns strange values like 0 or 80.
177
+ return isTabletOrSmaller ? (isIos ? window.screen.width : window.innerWidth) - marginLeftRightMobile * 2 : getWidthDesktop(width);
177
178
  };
178
179
  var getPositionStyles = function(position, width, targetPosition, isTabletOrSmaller) {
179
180
  var containerStylesByPos = {
@@ -246,12 +247,12 @@ var getTargetPosition = function(targetWrapper) {
246
247
  };
247
248
  var Popover = function(param) {
248
249
  var description = param.description, title = param.title, onClose = param.onClose, trackingEvent = param.trackingEvent, position = param.position, width = param.width, target = param.target, asset = param.asset, _isVisible = param.isVisible, isVisible = _isVisible === void 0 ? true : _isVisible;
249
- var ref = useTheme(), texts = ref.texts, colors = ref.colors;
250
+ var ref = useTheme(), texts = ref.texts, colors = ref.colors, isIos = ref.isIos;
250
251
  var isTabletOrSmaller = useScreenSize().isTabletOrSmaller;
251
252
  var ref1 = _slicedToArray(React.useState(null), 2), targetPosition = ref1[0], setTargetPosition = ref1[1];
252
253
  var targetWrapperRef = React.useRef(null);
253
254
  position = getPosition(position, isTabletOrSmaller);
254
- var innerWidth = getWidth(isTabletOrSmaller, width);
255
+ var innerWidth = getWidth(isTabletOrSmaller, isIos, width);
255
256
  var classes = useStyles({
256
257
  position: position
257
258
  });
package/dist-es/select.js CHANGED
@@ -143,6 +143,7 @@ var useStyles = createUseStyles(function(theme) {
143
143
  var label = param.label;
144
144
  return label ? 27 : 17;
145
145
  },
146
+ lineHeight: '20px',
146
147
  fontSize: 16,
147
148
  color: theme.colors.textPrimary,
148
149
  opacity: function(param) {
@@ -16,6 +16,7 @@ import { useIsomorphicLayoutEffect } from './hooks';
16
16
  import TabFocus from './tab-focus';
17
17
  import { PortalNodesProvider } from './portal';
18
18
  import ModalContextProvider from './modal-context-provider';
19
+ import { DocumentVisibilityProvider } from './utils/document-visibility';
19
20
  function _arrayLikeToArray(arr, len) {
20
21
  if (len == null || len > arr.length) len = arr.length;
21
22
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -196,11 +197,13 @@ var ThemeContextProvider = function(param) {
196
197
  children: /*#__PURE__*/ _jsx(ModalContextProvider, {
197
198
  children: /*#__PURE__*/ _jsx(ThemeContext.Provider, {
198
199
  value: contextTheme,
199
- children: /*#__PURE__*/ _jsx(AriaIdGetterContext.Provider, {
200
- value: getAriaId,
201
- children: /*#__PURE__*/ _jsx(ScreenSizeContextProvider, {
202
- children: /*#__PURE__*/ _jsx(DialogRoot, {
203
- children: children
200
+ children: /*#__PURE__*/ _jsx(DocumentVisibilityProvider, {
201
+ children: /*#__PURE__*/ _jsx(AriaIdGetterContext.Provider, {
202
+ value: getAriaId,
203
+ children: /*#__PURE__*/ _jsx(ScreenSizeContextProvider, {
204
+ children: /*#__PURE__*/ _jsx(DialogRoot, {
205
+ children: children
206
+ })
204
207
  })
205
208
  })
206
209
  })
@@ -36,9 +36,11 @@ function _objectSpread(target) {
36
36
  return target;
37
37
  }
38
38
  var redirect = function(url) {
39
- var external = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
39
+ var external = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, loadOnTop = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
40
40
  if (external) {
41
41
  window.open(url, '_blank');
42
+ } else if (loadOnTop) {
43
+ window.open(url, '_top');
42
44
  } else {
43
45
  document.location.href = url;
44
46
  }
@@ -109,6 +111,7 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
109
111
  }, getPrefixedDataAttributes(props.dataAttributes));
110
112
  var type = props.type ? props.type : 'button';
111
113
  var openNewTab = !!props.href && !!props.newTab;
114
+ var loadOnTop = !openNewTab && !!props.href && !!props.loadOnTop;
112
115
  var onPress = function(event) {
113
116
  if (props.onPress) {
114
117
  props.onPress(event);
@@ -156,7 +159,7 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
156
159
  }
157
160
  event.preventDefault();
158
161
  trackOnce(function() {
159
- return redirect(getHref(), openNewTab);
162
+ return redirect(getHref(), openNewTab, loadOnTop);
160
163
  });
161
164
  };
162
165
  var handleKeyDown = function(event) {
@@ -172,7 +175,11 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
172
175
  onClick: handleHrefClick,
173
176
  onKeyDown: handleKeyDown,
174
177
  href: props.disabled ? undefined : getHref(),
175
- target: openNewTab ? '_blank' : undefined,
178
+ target: function() {
179
+ if (openNewTab) return '_blank';
180
+ if (loadOnTop) return '_top';
181
+ return undefined;
182
+ }(),
176
183
  rel: openNewTab ? 'noopener noreferrer' : undefined,
177
184
  ref: ref,
178
185
  children: [
@@ -0,0 +1,93 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { useTheme } from '../hooks';
4
+ import { isAndroid } from './platform';
5
+ function _arrayLikeToArray(arr, len) {
6
+ if (len == null || len > arr.length) len = arr.length;
7
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8
+ return arr2;
9
+ }
10
+ function _arrayWithHoles(arr) {
11
+ if (Array.isArray(arr)) return arr;
12
+ }
13
+ function _iterableToArrayLimit(arr, i) {
14
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
15
+ if (_i == null) return;
16
+ var _arr = [];
17
+ var _n = true;
18
+ var _d = false;
19
+ var _s, _e;
20
+ try {
21
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
22
+ _arr.push(_s.value);
23
+ if (i && _arr.length === i) break;
24
+ }
25
+ } catch (err) {
26
+ _d = true;
27
+ _e = err;
28
+ } finally{
29
+ try {
30
+ if (!_n && _i["return"] != null) _i["return"]();
31
+ } finally{
32
+ if (_d) throw _e;
33
+ }
34
+ }
35
+ return _arr;
36
+ }
37
+ function _nonIterableRest() {
38
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39
+ }
40
+ function _slicedToArray(arr, i) {
41
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
42
+ }
43
+ function _unsupportedIterableToArray(o, minLen) {
44
+ if (!o) return;
45
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
46
+ var n = Object.prototype.toString.call(o).slice(8, -1);
47
+ if (n === "Object" && o.constructor) n = o.constructor.name;
48
+ if (n === "Map" || n === "Set") return Array.from(n);
49
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
50
+ }
51
+ var isDocumentVisible = function() {
52
+ return typeof document !== 'undefined' && document.visibilityState === 'visible';
53
+ };
54
+ var DocumentVisibilityContext = /*#__PURE__*/ React.createContext(true);
55
+ export var DocumentVisibilityProvider = function(param) {
56
+ var hidden = param.hidden, children = param.children;
57
+ var platformOverrides = useTheme().platformOverrides;
58
+ var ref = _slicedToArray(React.useState(!hidden), 2), visible = ref[0], setVisible = ref[1];
59
+ React.useEffect(function() {
60
+ var visibilitychangeCallback = function() {
61
+ setVisible(isDocumentVisible());
62
+ };
63
+ var focusCallback = function() {
64
+ setVisible(true);
65
+ };
66
+ var blurCallback = function() {
67
+ setVisible(false);
68
+ };
69
+ setVisible(isDocumentVisible());
70
+ document.addEventListener('visibilitychange', visibilitychangeCallback);
71
+ document.addEventListener('focus', focusCallback);
72
+ document.addEventListener('blur', blurCallback);
73
+ return function() {
74
+ document.removeEventListener('visibilitychange', visibilitychangeCallback);
75
+ document.removeEventListener('focus', focusCallback);
76
+ document.removeEventListener('blur', blurCallback);
77
+ };
78
+ }, []);
79
+ // Workaround for this bug: https://jira.tuenti.io/jira/browse/ACCOUNT-10938
80
+ // In Android, after ~10 minutes of inactivity, when a background webview receives focus (back navigation from another webview),
81
+ // visibility change event is not fired, this causes problems like the navigation bar not being updated
82
+ var isVisibleNow = isDocumentVisible();
83
+ if (isAndroid(platformOverrides) && isVisibleNow !== visible) {
84
+ setVisible(isVisibleNow);
85
+ }
86
+ return(/*#__PURE__*/ _jsx(DocumentVisibilityContext.Provider, {
87
+ value: visible,
88
+ children: children
89
+ }));
90
+ };
91
+ export var useDocumentVisibility = function() {
92
+ return React.useContext(DocumentVisibilityContext);
93
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telefonica/mistica",
3
- "version": "10.27.0",
3
+ "version": "10.29.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,6 +21,7 @@
21
21
  "lint": "eslint --report-unused-disable-directives .",
22
22
  "ts-check": "tsc --project tsconfig.json --noEmit",
23
23
  "build": "yarn clean && node scripts/build.js",
24
+ "compile": "node scripts/compile.js",
24
25
  "clean": "rimraf dist && rimraf dist-es && rimraf dist-ts && rimraf node_modules/.cache",
25
26
  "ci": "yarn lint && yarn prettier-check && yarn ts-check && yarn circular-dependencies && yarn build && yarn storybook-static && yarn test --ci && yarn test-acceptance --ci",
26
27
  "prepublishOnly": "node scripts/prepublish-only.js",
@@ -108,6 +109,7 @@
108
109
  "node-fetch": "^2.6.1",
109
110
  "playroom": "^0.27.9",
110
111
  "prettier": "^2.5.1",
112
+ "pretty-bytes": "^5.6.0",
111
113
  "prop-types": "^15.7.2",
112
114
  "react": "17.0.2",
113
115
  "react-dom": "17.0.2",