@telefonica/mistica 10.25.0 → 10.28.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 (66) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/button.d.ts +2 -0
  3. package/dist/button.js +20 -5
  4. package/dist/button.js.flow +2 -0
  5. package/dist/callout.js +37 -26
  6. package/dist/carousel.js +16 -4
  7. package/dist/hooks.d.ts +7 -0
  8. package/dist/hooks.js +30 -1
  9. package/dist/hooks.js.flow +11 -0
  10. package/dist/image.d.ts +3 -0
  11. package/dist/image.js +35 -4
  12. package/dist/image.js.flow +3 -0
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +13 -0
  15. package/dist/index.js.flow +2 -0
  16. package/dist/package-version.js +1 -1
  17. package/dist/popover.js +5 -4
  18. package/dist/skins/blau.js +0 -2
  19. package/dist/skins/o2-classic.js +0 -4
  20. package/dist/skins/o2.js +0 -4
  21. package/dist/skins/telefonica.js +1 -5
  22. package/dist/skins/vivo.js +0 -4
  23. package/dist/tag.d.ts +2 -1
  24. package/dist/tag.js +33 -3
  25. package/dist/tag.js.flow +2 -1
  26. package/dist/text-link.d.ts +1 -0
  27. package/dist/text-link.js +8 -0
  28. package/dist/text-link.js.flow +1 -0
  29. package/dist/text.d.ts +2 -0
  30. package/dist/text.js +4 -3
  31. package/dist/text.js.flow +2 -0
  32. package/dist/theme-context-provider.js +8 -5
  33. package/dist/utils/analytics.d.ts +6 -0
  34. package/dist/utils/analytics.js +13 -0
  35. package/dist/utils/analytics.js.flow +8 -0
  36. package/dist/utils/common.d.ts +1 -0
  37. package/dist/utils/common.js +11 -1
  38. package/dist/utils/common.js.flow +1 -0
  39. package/dist/utils/document-visibility.d.ts +8 -0
  40. package/dist/utils/document-visibility.js +121 -0
  41. package/dist/utils/document-visibility.js.flow +10 -0
  42. package/dist/video.d.ts +2 -0
  43. package/dist/video.js +37 -5
  44. package/dist/video.js.flow +2 -0
  45. package/dist-es/button.js +20 -5
  46. package/dist-es/callout.js +38 -27
  47. package/dist-es/carousel.js +17 -5
  48. package/dist-es/hooks.js +28 -0
  49. package/dist-es/image.js +34 -4
  50. package/dist-es/index.js +2 -1
  51. package/dist-es/package-version.js +1 -1
  52. package/dist-es/popover.js +5 -4
  53. package/dist-es/skins/blau.js +0 -2
  54. package/dist-es/skins/o2-classic.js +0 -4
  55. package/dist-es/skins/o2.js +0 -4
  56. package/dist-es/skins/telefonica.js +1 -5
  57. package/dist-es/skins/vivo.js +0 -4
  58. package/dist-es/tag.js +32 -3
  59. package/dist-es/text-link.js +8 -0
  60. package/dist-es/text.js +4 -3
  61. package/dist-es/theme-context-provider.js +8 -5
  62. package/dist-es/utils/analytics.js +6 -0
  63. package/dist-es/utils/common.js +9 -0
  64. package/dist-es/utils/document-visibility.js +93 -0
  65. package/dist-es/video.js +36 -5
  66. package/package.json +3 -1
@@ -96,8 +96,6 @@ var getTelefonicaSkin = function getTelefonicaSkin() {
96
96
  controlError: palette.coral,
97
97
  loadingBar: palette.telefonicaBlue30,
98
98
  loadingBarBackground: palette.telefonicaBlue70,
99
- loadingBarBackgroundInverse: palette.telefonicaBlue70,
100
- loadingBarInverse: palette.telefonicaBlue30,
101
99
  toggleAndroidInactive: palette.grey2,
102
100
  toggleAndroidBackgroundActive: palette.grey2,
103
101
  iosControlKnob: palette.white,
@@ -106,7 +104,7 @@ var getTelefonicaSkin = function getTelefonicaSkin() {
106
104
  dividerInverse: (0, _color).applyAlpha(palette.white, 0.2),
107
105
  navigationBarDivider: palette.telefonicaBlue,
108
106
  // FEEDBACKS
109
- badge: palette.coral80,
107
+ badge: palette.coral70,
110
108
  feedbackErrorBackground: palette.coral,
111
109
  feedbackInfoBackground: palette.grey9,
112
110
  // GLOBAL
@@ -186,8 +184,6 @@ var getTelefonicaSkin = function getTelefonicaSkin() {
186
184
  controlActivated: palette.telefonicaBlue,
187
185
  loadingBar: palette.telefonicaBlue,
188
186
  loadingBarBackground: (0, _color).applyAlpha(palette.white, 0.05),
189
- loadingBarBackgroundInverse: palette.telefonicaBlue70,
190
- loadingBarInverse: palette.telefonicaBlue30,
191
187
  toggleAndroidInactive: palette.grey4,
192
188
  toggleAndroidBackgroundActive: palette.grey1,
193
189
  iosControlKnob: palette.grey2,
@@ -95,8 +95,6 @@ var getVivoSkin = function getVivoSkin() {
95
95
  controlError: palette.pepper,
96
96
  loadingBar: palette.pink,
97
97
  loadingBarBackground: palette.pepperLight30,
98
- loadingBarBackgroundInverse: palette.vivoPurpleLight50,
99
- loadingBarInverse: palette.vivoPurple,
100
98
  toggleAndroidInactive: palette.grey2,
101
99
  toggleAndroidBackgroundActive: palette.vivoPurpleLight20,
102
100
  iosControlKnob: palette.white,
@@ -187,8 +185,6 @@ var getVivoSkin = function getVivoSkin() {
187
185
  controlActivated: palette.vivoPurpleLight80,
188
186
  loadingBar: palette.vivoPurpleLight80,
189
187
  loadingBarBackground: palette.darkModeGrey6,
190
- loadingBarBackgroundInverse: palette.grey1,
191
- loadingBarInverse: palette.vivoPurpleLight80,
192
188
  toggleAndroidInactive: palette.grey4,
193
189
  toggleAndroidBackgroundActive: palette.vivoPurpleLight50,
194
190
  iosControlKnob: palette.grey2,
package/dist/tag.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import * as React from 'react';
2
- import type { IconProps } from './utils/types';
2
+ import type { DataAttributes, IconProps } from './utils/types';
3
3
  export declare type TagType = 'promo' | 'active' | 'inactive' | 'success' | 'warning' | 'error';
4
4
  export declare type TagProps = {
5
5
  type?: 'promo' | 'active' | 'inactive' | 'success' | 'warning' | 'error';
6
6
  children: string;
7
7
  Icon?: React.FC<IconProps>;
8
+ dataAttributes?: DataAttributes;
8
9
  /** @deprecated use type prop */
9
10
  color?: string;
10
11
  };
package/dist/tag.js CHANGED
@@ -11,6 +11,7 @@ var _jss = require("./jss");
11
11
  var _text = require("./text");
12
12
  var _themeVariantContext = require("./theme-variant-context");
13
13
  var _css = require("./utils/css");
14
+ var _dom = require("./utils/dom");
14
15
  function _interopRequireDefault(obj) {
15
16
  return obj && obj.__esModule ? obj : {
16
17
  default: obj
@@ -45,6 +46,19 @@ function _arrayLikeToArray(arr, len) {
45
46
  function _arrayWithHoles(arr) {
46
47
  if (Array.isArray(arr)) return arr;
47
48
  }
49
+ function _defineProperty(obj, key, value) {
50
+ if (key in obj) {
51
+ Object.defineProperty(obj, key, {
52
+ value: value,
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true
56
+ });
57
+ } else {
58
+ obj[key] = value;
59
+ }
60
+ return obj;
61
+ }
48
62
  function _iterableToArrayLimit(arr, i) {
49
63
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
50
64
  if (_i == null) return;
@@ -72,6 +86,22 @@ function _iterableToArrayLimit(arr, i) {
72
86
  function _nonIterableRest() {
73
87
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
74
88
  }
89
+ function _objectSpread(target) {
90
+ var _arguments = arguments, _loop = function(i) {
91
+ var source = _arguments[i] != null ? _arguments[i] : {};
92
+ var ownKeys = Object.keys(source);
93
+ if (typeof Object.getOwnPropertySymbols === "function") {
94
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
95
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
96
+ }));
97
+ }
98
+ ownKeys.forEach(function(key) {
99
+ _defineProperty(target, key, source[key]);
100
+ });
101
+ };
102
+ for(var i = 1; i < arguments.length; i++)_loop(i);
103
+ return target;
104
+ }
75
105
  function _slicedToArray(arr, i) {
76
106
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
77
107
  }
@@ -105,7 +135,7 @@ var useStyles = (0, _jss).createUseStyles(function() {
105
135
  };
106
136
  });
107
137
  var Tag = function Tag(param) {
108
- var Icon = param.Icon, children = param.children, _type = param.type, type = _type === void 0 ? 'promo' : _type, color = param.color;
138
+ var Icon = param.Icon, children = param.children, dataAttributes = param.dataAttributes, _type = param.type, type = _type === void 0 ? 'promo' : _type, color = param.color;
109
139
  var classes = useStyles({
110
140
  hasIcon: !!Icon
111
141
  });
@@ -168,7 +198,7 @@ var Tag = function Tag(param) {
168
198
  };
169
199
  var _type1 = _slicedToArray(tagTypeToColors[type], 2), textColor1 = _type1[0], backgroundColor = _type1[1];
170
200
  var shouldUseInverseBackground = isInverse && !isDarkMode;
171
- return(/*#__PURE__*/ (0, _jsxRuntime).jsxs("span", {
201
+ return(/*#__PURE__*/ (0, _jsxRuntime).jsxs("span", _objectSpread({}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
172
202
  className: classes.tag,
173
203
  style: {
174
204
  background: shouldUseInverseBackground ? colors.inverse : backgroundColor
@@ -193,7 +223,7 @@ var Tag = function Tag(param) {
193
223
  })
194
224
  })
195
225
  ]
196
- }));
226
+ })));
197
227
  };
198
228
  var _default = Tag;
199
229
  exports.default = _default;
package/dist/tag.js.flow CHANGED
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import * as React from "react";
4
- import type { IconProps } from "./utils/types";
4
+ import type { DataAttributes, IconProps } from "./utils/types";
5
5
  export type TagType =
6
6
  | "promo"
7
7
  | "active"
@@ -13,6 +13,7 @@ export type TagProps = {
13
13
  type?: "promo" | "active" | "inactive" | "success" | "warning" | "error",
14
14
  children: string,
15
15
  Icon?: React.ComponentType<IconProps>,
16
+ dataAttributes?: DataAttributes,
16
17
 
17
18
  /**
18
19
  * @deprecated use type prop
@@ -10,6 +10,7 @@ interface CommonProps {
10
10
  small?: boolean;
11
11
  disabled?: boolean;
12
12
  trackingEvent?: TrackingEvent | ReadonlyArray<TrackingEvent>;
13
+ trackEvent?: boolean;
13
14
  /** "data-" prefix is automatically added. For example, use "testid" instead of "data-testid" */
14
15
  dataAttributes?: DataAttributes;
15
16
  }
package/dist/text-link.js CHANGED
@@ -10,6 +10,8 @@ var _touchable = _interopRequireDefault(require("./touchable"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _themeVariantContext = require("./theme-variant-context");
12
12
  var _formContext = require("./form-context");
13
+ var _common = require("./utils/common");
14
+ var _analytics = require("./utils/analytics");
13
15
  function _interopRequireDefault(obj) {
14
16
  return obj && obj.__esModule ? obj : {
15
17
  default: obj
@@ -126,8 +128,14 @@ var TextLink = function TextLink(_param) {
126
128
  var classes = useStyles();
127
129
  var isInverse = (0, _themeVariantContext).useIsInverseVariant();
128
130
  var formStatus = (0, _formContext).useForm().formStatus;
131
+ var _trackingEvent;
129
132
  var _obj;
130
133
  return(/*#__PURE__*/ (0, _jsxRuntime).jsx(_touchable.default, _objectSpread({}, props, {
134
+ trackingEvent: (_trackingEvent = props.trackingEvent) !== null && _trackingEvent !== void 0 ? _trackingEvent : props.trackEvent ? {
135
+ category: _analytics.eventCategories.userInteraction,
136
+ action: _analytics.eventActions.linkTapped,
137
+ label: (0, _common).getTextFromChildren(children)
138
+ } : undefined,
131
139
  disabled: disabled || formStatus === 'sending',
132
140
  className: (0, _classnames).default(classes.textLink, className, (_obj = {}, _defineProperty(_obj, classes.small, small), _defineProperty(_obj, classes.inverse, isInverse), _obj)),
133
141
  children: children
@@ -12,6 +12,7 @@ declare type CommonProps = {
12
12
  small?: boolean,
13
13
  disabled?: boolean,
14
14
  trackingEvent?: TrackingEvent | $ReadOnlyArray<TrackingEvent>,
15
+ trackEvent?: boolean,
15
16
 
16
17
  /**
17
18
  * "data-" prefix is automatically added. For example, use "testid" instead of "data-testid"
package/dist/text.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import type { DataAttributes } from './utils/types';
2
3
  declare type FontWeight = 'light' | 'regular' | 'medium';
3
4
  export interface TextPresetProps {
4
5
  color?: string;
@@ -15,6 +16,7 @@ export interface TextPresetProps {
15
16
  as?: React.ComponentType<any> | string;
16
17
  role?: string;
17
18
  'aria-level'?: number;
19
+ dataAttributes?: DataAttributes;
18
20
  }
19
21
  interface TextProps extends TextPresetProps {
20
22
  weight?: FontWeight | boolean;
package/dist/text.js CHANGED
@@ -9,6 +9,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
9
9
  var _jss = require("./jss");
10
10
  var _themeVariantContext = require("./theme-variant-context");
11
11
  var _css = require("./utils/css");
12
+ var _dom = require("./utils/dom");
12
13
  function _interopRequireDefault(obj) {
13
14
  return obj && obj.__esModule ? obj : {
14
15
  default: obj
@@ -148,7 +149,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
148
149
  };
149
150
  });
150
151
  var Text = function Text(param) {
151
- var weight = param.weight, color = param.color, textDecoration = param.textDecoration, _decoration = param.decoration, decoration = _decoration === void 0 ? textDecoration : _decoration, truncate = param.truncate, uppercase = param.uppercase, transform = param.transform, wordBreak = param.wordBreak, _as = param.as, as = _as === void 0 ? 'span' : _as, children = param.children, size = param.size, _mobileSize = param.mobileSize, mobileSize = _mobileSize === void 0 ? size : _mobileSize, _desktopSize = param.desktopSize, desktopSize = _desktopSize === void 0 ? size : _desktopSize, lineHeight = param.lineHeight, _mobileLineHeight = param.mobileLineHeight, mobileLineHeight = _mobileLineHeight === void 0 ? lineHeight : _mobileLineHeight, _desktopLineHeight = param.desktopLineHeight, desktopLineHeight = _desktopLineHeight === void 0 ? lineHeight : _desktopLineHeight, letterSpacing = param.letterSpacing, id = param.id, role = param.role, ariaLevel = param['aria-level'];
152
+ var weight = param.weight, color = param.color, textDecoration = param.textDecoration, _decoration = param.decoration, decoration = _decoration === void 0 ? textDecoration : _decoration, truncate = param.truncate, uppercase = param.uppercase, transform = param.transform, wordBreak = param.wordBreak, _as = param.as, as = _as === void 0 ? 'span' : _as, children = param.children, size = param.size, _mobileSize = param.mobileSize, mobileSize = _mobileSize === void 0 ? size : _mobileSize, _desktopSize = param.desktopSize, desktopSize = _desktopSize === void 0 ? size : _desktopSize, lineHeight = param.lineHeight, _mobileLineHeight = param.mobileLineHeight, mobileLineHeight = _mobileLineHeight === void 0 ? lineHeight : _mobileLineHeight, _desktopLineHeight = param.desktopLineHeight, desktopLineHeight = _desktopLineHeight === void 0 ? lineHeight : _desktopLineHeight, letterSpacing = param.letterSpacing, id = param.id, role = param.role, ariaLevel = param['aria-level'], dataAttributes = param.dataAttributes;
152
153
  var isInverse = (0, _themeVariantContext).useIsInverseVariant();
153
154
  var classes = useStyles({
154
155
  isInverse: isInverse,
@@ -169,12 +170,12 @@ var Text = function Text(param) {
169
170
  return null;
170
171
  }
171
172
  var className = (0, _classnames).default(classes.text, _defineProperty({}, classes.truncate, !!truncate));
172
- return(/*#__PURE__*/ React.createElement(as, {
173
+ return(/*#__PURE__*/ React.createElement(as, _objectSpread({
173
174
  className: className,
174
175
  id: id,
175
176
  role: role,
176
177
  'aria-level': ariaLevel
177
- }, children));
178
+ }, (0, _dom).getPrefixedDataAttributes(dataAttributes)), children));
178
179
  };
179
180
  exports.Text = Text;
180
181
  var getRegularOrMediumWeight = function getRegularOrMediumWeight(props) {
package/dist/text.js.flow CHANGED
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import * as React from "react";
4
+ import type { DataAttributes } from "./utils/types";
4
5
  declare type FontWeight = "light" | "regular" | "medium";
5
6
  export type TextPresetProps = {
6
7
  color?: string,
@@ -23,6 +24,7 @@ export type TextPresetProps = {
23
24
  as?: React.ComponentType<any> | string,
24
25
  role?: string,
25
26
  "aria-level"?: number,
27
+ dataAttributes?: DataAttributes,
26
28
  };
27
29
  declare type TextProps = {
28
30
  ...$Exact<TextPresetProps>,
@@ -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
  })
@@ -0,0 +1,6 @@
1
+ export declare const eventCategories: {
2
+ readonly userInteraction: "user_interaction";
3
+ };
4
+ export declare const eventActions: {
5
+ readonly linkTapped: "link_tapped";
6
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.eventActions = exports.eventCategories = void 0;
6
+ var eventCategories = {
7
+ userInteraction: 'user_interaction'
8
+ };
9
+ exports.eventCategories = eventCategories;
10
+ var eventActions = {
11
+ linkTapped: 'link_tapped'
12
+ };
13
+ exports.eventActions = eventActions;
@@ -0,0 +1,8 @@
1
+ // @flow
2
+
3
+ declare export var eventCategories: {
4
+ +userInteraction: "user_interaction",
5
+ };
6
+ declare export var eventActions: {
7
+ +linkTapped: "link_tapped",
8
+ };
@@ -1,2 +1,3 @@
1
1
  import * as React from 'react';
2
2
  export declare const combineRefs: <T>(...refs: (React.Ref<T> | undefined)[]) => (refValue: T | null) => void;
3
+ export declare const getTextFromChildren: (children: React.ReactNode) => string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.combineRefs = void 0;
5
+ exports.getTextFromChildren = exports.combineRefs = void 0;
6
6
  var React = _interopRequireWildcard(require("react"));
7
7
  function _interopRequireWildcard(obj) {
8
8
  if (obj && obj.__esModule) {
@@ -43,3 +43,13 @@ var combineRefs = function combineRefs() {
43
43
  };
44
44
  };
45
45
  exports.combineRefs = combineRefs;
46
+ var getTextFromChildren = function getTextFromChildren(children) {
47
+ var text = '';
48
+ React.Children.forEach(children, function(child) {
49
+ if (typeof child === 'string') {
50
+ text += child;
51
+ }
52
+ });
53
+ return text;
54
+ };
55
+ exports.getTextFromChildren = getTextFromChildren;
@@ -4,3 +4,4 @@ import * as React from "react";
4
4
  declare export var combineRefs: <T>(
5
5
  ...refs: Array<React.Ref<T> | void>
6
6
  ) => (refValue: T | null) => void;
7
+ declare export var getTextFromChildren: (children: React.Node) => string;
@@ -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/video.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import type { DataAttributes } from './utils/types';
2
3
  export declare type AspectRatio = '1:1' | '16:9' | '12:5' | '4:3';
3
4
  export declare const RATIO: {
4
5
  '1:1': number;
@@ -28,6 +29,7 @@ export declare type VideoProps = {
28
29
  children?: void;
29
30
  /** defaults to none */
30
31
  preload?: 'none' | 'metadata' | 'auto';
32
+ dataAttributes?: DataAttributes;
31
33
  };
32
34
  declare const Video: React.ForwardRefExoticComponent<VideoProps & React.RefAttributes<HTMLVideoElement>>;
33
35
  export default Video;
package/dist/video.js CHANGED
@@ -8,6 +8,7 @@ var React = _interopRequireWildcard(require("react"));
8
8
  var _image = require("./image");
9
9
  var _jss = require("./jss");
10
10
  var _common = require("./utils/common");
11
+ var _dom = require("./utils/dom");
11
12
  function _interopRequireWildcard(obj) {
12
13
  if (obj && obj.__esModule) {
13
14
  return obj;
@@ -29,6 +30,35 @@ function _interopRequireWildcard(obj) {
29
30
  return newObj;
30
31
  }
31
32
  }
33
+ function _defineProperty(obj, key, value) {
34
+ if (key in obj) {
35
+ Object.defineProperty(obj, key, {
36
+ value: value,
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true
40
+ });
41
+ } else {
42
+ obj[key] = value;
43
+ }
44
+ return obj;
45
+ }
46
+ function _objectSpread(target) {
47
+ var _arguments = arguments, _loop = function(i) {
48
+ var source = _arguments[i] != null ? _arguments[i] : {};
49
+ var ownKeys = Object.keys(source);
50
+ if (typeof Object.getOwnPropertySymbols === "function") {
51
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
52
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
53
+ }));
54
+ }
55
+ ownKeys.forEach(function(key) {
56
+ _defineProperty(target, key, source[key]);
57
+ });
58
+ };
59
+ for(var i = 1; i < arguments.length; i++)_loop(i);
60
+ return target;
61
+ }
32
62
  function _objectWithoutProperties(source, excluded) {
33
63
  if (source == null) return {};
34
64
  var target = _objectWithoutPropertiesLoose(source, excluded);
@@ -83,14 +113,15 @@ var useStyles = (0, _jss).createUseStyles(function() {
83
113
  });
84
114
  /** Transparent 1x1px PNG */ var TRANSPARENT_PIXEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC';
85
115
  var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
86
- 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, props = _objectWithoutProperties(_param, [
116
+ 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, [
87
117
  "src",
88
118
  "poster",
89
119
  "autoPlay",
90
120
  "muted",
91
121
  "loop",
92
122
  "preload",
93
- "aspectRatio"
123
+ "aspectRatio",
124
+ "dataAttributes"
94
125
  ]);
95
126
  var noBorderRadius = (0, _image).useDisableBorderRadius();
96
127
  var classes = useStyles({
@@ -130,7 +161,7 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
130
161
  } else {
131
162
  width = '100%';
132
163
  }
133
- return(/*#__PURE__*/ (0, _jsxRuntime).jsx("video", {
164
+ return(/*#__PURE__*/ (0, _jsxRuntime).jsx("video", _objectSpread({
134
165
  ref: (0, _common).combineRefs(ref, videoRef),
135
166
  playsInline: true,
136
167
  disablePictureInPicture: true,
@@ -143,7 +174,8 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
143
174
  className: classes.video,
144
175
  preload: preload,
145
176
  // This transparent pixel fallback avoids showing the ugly "play" image in android webviews
146
- poster: poster || TRANSPARENT_PIXEL,
177
+ poster: poster || TRANSPARENT_PIXEL
178
+ }, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
147
179
  children: sources.map(function(param, index) {
148
180
  var src = param.src, type = param.type;
149
181
  /*#__PURE__*/ return (0, _jsxRuntime).jsx("source", {
@@ -151,7 +183,7 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
151
183
  type: type
152
184
  }, index);
153
185
  })
154
- }));
186
+ })));
155
187
  });
156
188
  var _default = Video;
157
189
  exports.default = _default;
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import * as React from "react";
4
+ import type { DataAttributes } from "./utils/types";
4
5
  export type AspectRatio = "1:1" | "16:9" | "12:5" | "4:3";
5
6
  declare export var RATIO: {
6
7
  "1:1": number,
@@ -43,6 +44,7 @@ export type VideoProps = {
43
44
  * defaults to none
44
45
  */
45
46
  preload?: "none" | "metadata" | "auto",
47
+ dataAttributes?: DataAttributes,
46
48
  };
47
49
  declare var Video: React.ComponentType<{
48
50
  ...VideoProps,