@telefonica/mistica 11.10.2 → 11.11.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.
@@ -59,12 +59,10 @@ import { createUseStyles } from "./jss";
59
59
  import { useIsInverseVariant } from "./theme-variant-context";
60
60
  import Box from "./box";
61
61
  import Touchable from "./touchable";
62
- import IconCloseRegular from "./generated/mistica-icons/icon-close-regular";
63
- import { applyAlpha } from "./utils/color";
64
62
  import { useTheme } from "./hooks";
65
63
  import { Text4, Text2 } from "./text";
66
- import IconButton from "./icon-button";
67
64
  import { Boxed } from "./boxed";
65
+ import MaybeDismissable, { useIsDismissable } from "./maybe-dismissable";
68
66
  var useStyles = createUseStyles(function(theme) {
69
67
  var _obj;
70
68
  return {
@@ -85,35 +83,6 @@ var useStyles = createUseStyles(function(theme) {
85
83
  minWidth: 100,
86
84
  height: "inherit"
87
85
  },
88
- dismissableContainer: {
89
- position: "relative",
90
- display: "flex",
91
- flexShrink: 0,
92
- width: function(param) {
93
- var width = param.width;
94
- return width || "100%";
95
- }
96
- },
97
- dismissableButton: {
98
- position: "absolute",
99
- top: 0,
100
- right: 0,
101
- width: 48,
102
- height: 48,
103
- display: "flex",
104
- alignItems: "center",
105
- justifyContent: "center"
106
- },
107
- dismissableCircleContainer: {
108
- display: "flex",
109
- alignItems: "center",
110
- justifyContent: "center",
111
- width: 24,
112
- height: 24,
113
- margin: "0 0 8px 8px",
114
- borderRadius: "50%",
115
- backgroundColor: applyAlpha(theme.colors.background, 0.7)
116
- },
117
86
  textContainer: (_obj = {
118
87
  paddingLeft: 16,
119
88
  paddingTop: 24,
@@ -139,37 +108,6 @@ var useStyles = createUseStyles(function(theme) {
139
108
  }
140
109
  };
141
110
  });
142
- var Dismissable = function(param) {
143
- var children = param.children, width = param.width, _onClose = param.onClose, onClose = _onClose === void 0 ? function() {} : _onClose;
144
- var isInverse = useIsInverseVariant();
145
- var classes = useStyles({
146
- isInverse: isInverse,
147
- width: width
148
- });
149
- var ref = useTheme(), colors = ref.colors, texts = ref.texts;
150
- return /*#__PURE__*/ _jsxs("section", {
151
- className: classes.dismissableContainer,
152
- children: [
153
- children,
154
- /*#__PURE__*/ _jsx(IconButton, {
155
- className: classes.dismissableButton,
156
- onPress: onClose,
157
- "aria-label": texts.closeButtonLabel,
158
- style: {
159
- display: "flex",
160
- width: 48,
161
- height: 48
162
- },
163
- children: /*#__PURE__*/ _jsx("div", {
164
- className: classes.dismissableCircleContainer,
165
- children: /*#__PURE__*/ _jsx(IconCloseRegular, {
166
- color: colors.neutralHigh
167
- })
168
- })
169
- })
170
- ]
171
- });
172
- };
173
111
  var Content = function(props) {
174
112
  var title = props.title, description = props.description, imageUrl = props.imageUrl, imageFit = props.imageFit;
175
113
  var isInverseOutside = useIsInverseVariant();
@@ -181,18 +119,24 @@ var Content = function(props) {
181
119
  width: props.width
182
120
  });
183
121
  var theme = useTheme();
122
+ var isDismissable = useIsDismissable();
184
123
  var content = /*#__PURE__*/ _jsxs(Boxed, {
185
124
  isInverse: isInverse,
186
125
  className: classes.container,
126
+ dataAttributes: props.dataAttributes,
187
127
  children: [
188
128
  /*#__PURE__*/ _jsxs("div", {
189
129
  // don't create another region when the Content is inside a Dismissable wrapper
190
- role: props["aria-label"] ? "region" : undefined,
130
+ role: !isDismissable ? "region" : undefined,
191
131
  className: classes.textContainer,
192
- "aria-label": props["aria-label"],
132
+ // aria-label is already in Dismisable wrapper
133
+ "aria-label": !isDismissable ? props["aria-label"] : undefined,
193
134
  children: [
194
135
  /*#__PURE__*/ _jsx(Text4, {
136
+ as: "h1",
195
137
  regular: true,
138
+ wordBreak: true,
139
+ truncate: props.titleLinesMax,
196
140
  children: title
197
141
  }),
198
142
  /*#__PURE__*/ _jsx(Box, {
@@ -200,6 +144,9 @@ var Content = function(props) {
200
144
  children: /*#__PURE__*/ _jsx(Text2, {
201
145
  regular: true,
202
146
  color: theme.colors.textSecondary,
147
+ wordBreak: true,
148
+ truncate: props.descriptionLinesMax,
149
+ as: "p",
203
150
  children: description
204
151
  })
205
152
  }),
@@ -262,13 +209,13 @@ var HighlightedCard = function(_param) {
262
209
  "aria-label"
263
210
  ]);
264
211
  var label = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : props.title;
265
- return props.onClose ? /*#__PURE__*/ _jsx(Dismissable, {
212
+ return /*#__PURE__*/ _jsx(MaybeDismissable, {
266
213
  onClose: props.onClose,
267
214
  "aria-label": label,
268
215
  width: props.width,
269
- children: /*#__PURE__*/ _jsx(Content, _objectSpread({}, props))
270
- }) : /*#__PURE__*/ _jsx(Content, _objectSpread({}, props, {
271
- "aria-label": label
272
- }));
216
+ children: /*#__PURE__*/ _jsx(Content, _objectSpread({}, props, {
217
+ "aria-label": label
218
+ }))
219
+ });
273
220
  };
274
221
  export default HighlightedCard;
package/dist-es/index.js CHANGED
@@ -48,7 +48,7 @@ export { default as Inline } from "./inline";
48
48
  export { default as HighlightedCard } from "./highlighted-card";
49
49
  export { default as Stepper } from "./stepper";
50
50
  export { default as ProgressBar } from "./progress-bar";
51
- export { MediaCard, DataCard } from "./card";
51
+ export { MediaCard, DataCard, SnapCard } from "./card";
52
52
  export { default as Divider } from "./divider";
53
53
  export { default as Menu } from "./menu";
54
54
  export { default as EmptyState } from "./empty-state";
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { createUseStyles } from "./jss";
4
+ import IconCloseRegular from "./generated/mistica-icons/icon-close-regular";
5
+ import { useTheme } from "./hooks";
6
+ import IconButton from "./icon-button";
7
+ import { useIsInverseVariant } from "./theme-variant-context";
8
+ import { applyAlpha } from "./utils/color";
9
+ var DismissableContext = /*#__PURE__*/ React.createContext(false);
10
+ export var useIsDismissable = function() {
11
+ return React.useContext(DismissableContext);
12
+ };
13
+ var useStyles = createUseStyles(function(theme) {
14
+ return {
15
+ dismissableContainer: {
16
+ position: "relative",
17
+ display: "flex",
18
+ flexShrink: 0,
19
+ width: function(param) {
20
+ var width = param.width;
21
+ return width || "100%";
22
+ }
23
+ },
24
+ dismissableButton: {
25
+ position: "absolute",
26
+ top: 0,
27
+ right: 0,
28
+ width: 48,
29
+ height: 48,
30
+ display: "flex",
31
+ alignItems: "center",
32
+ justifyContent: "center"
33
+ },
34
+ dismissableCircleContainer: {
35
+ display: "flex",
36
+ alignItems: "center",
37
+ justifyContent: "center",
38
+ width: 24,
39
+ height: 24,
40
+ margin: "0 0 8px 8px",
41
+ borderRadius: "50%",
42
+ backgroundColor: applyAlpha(theme.colors.background, 0.7)
43
+ }
44
+ };
45
+ });
46
+ var MaybeDismissable = function(param) {
47
+ var children = param.children, width = param.width, onClose = param.onClose, ariaLabel = param["aria-label"];
48
+ var isInverse = useIsInverseVariant();
49
+ var classes = useStyles({
50
+ isInverse: isInverse,
51
+ width: width
52
+ });
53
+ var ref = useTheme(), colors = ref.colors, texts = ref.texts;
54
+ if (!onClose) {
55
+ return /*#__PURE__*/ _jsx(_Fragment, {
56
+ children: children
57
+ });
58
+ }
59
+ return /*#__PURE__*/ _jsxs("section", {
60
+ className: classes.dismissableContainer,
61
+ "aria-label": ariaLabel,
62
+ children: [
63
+ /*#__PURE__*/ _jsx(DismissableContext.Provider, {
64
+ value: true,
65
+ children: children
66
+ }),
67
+ /*#__PURE__*/ _jsx(IconButton, {
68
+ className: classes.dismissableButton,
69
+ onPress: onClose,
70
+ "aria-label": texts.closeButtonLabel,
71
+ style: {
72
+ display: "flex",
73
+ width: 48,
74
+ height: 48
75
+ },
76
+ children: /*#__PURE__*/ _jsx("div", {
77
+ className: classes.dismissableCircleContainer,
78
+ children: /*#__PURE__*/ _jsx(IconCloseRegular, {
79
+ color: colors.neutralHigh
80
+ })
81
+ })
82
+ })
83
+ ]
84
+ });
85
+ };
86
+ export default MaybeDismissable;
@@ -1,2 +1,2 @@
1
1
  // DO NOT EDIT THIS FILE. It's autogenerated by set-version.js
2
- export var PACKAGE_VERSION = "11.10.2";
2
+ export var PACKAGE_VERSION = "11.11.0";
package/dist-es/text.js CHANGED
@@ -116,7 +116,7 @@ var useStyles = createUseStyles(function(theme) {
116
116
  return truncate === 1 || truncate === true ? "break-all" : "normal";
117
117
  }
118
118
  },
119
- display: "box",
119
+ display: "-webkit-box",
120
120
  boxOrient: "vertical",
121
121
  overflow: "hidden"
122
122
  }
@@ -82,6 +82,14 @@ export var isIos = function(platformOverrides) {
82
82
  }
83
83
  return false;
84
84
  };
85
+ /**
86
+ * Returns true if the browser is a safari browser:
87
+ * webview, mobile, desktop or a browser like Chrome for iOS which is just a safari with a skin
88
+ *
89
+ * Note that this function checks the navigator vendor. It doesn't use platformOverrides or userAgent.
90
+ */ export var isSafari = function() {
91
+ return navigator.vendor.includes("Apple");
92
+ };
85
93
  export var isFirefox = function(platformOverrides) {
86
94
  return !!getUserAgent(platformOverrides).match(/Firefox\/([0-9]+)\./);
87
95
  };
package/dist-es/video.js CHANGED
@@ -60,6 +60,7 @@ import { createUseStyles } from "./jss";
60
60
  import { useSupportsAspectRatio } from "./utils/aspect-ratio-support";
61
61
  import { combineRefs } from "./utils/common";
62
62
  import { getPrefixedDataAttributes } from "./utils/dom";
63
+ import { isSafari } from "./utils/platform";
63
64
  export var RATIO = {
64
65
  "1:1": 1,
65
66
  "16:9": 16 / 9,
@@ -69,6 +70,7 @@ export var RATIO = {
69
70
  var useStyles = createUseStyles(function() {
70
71
  return {
71
72
  video: {
73
+ background: "transparent",
72
74
  display: "block",
73
75
  objectFit: "cover",
74
76
  maxWidth: "100%",
@@ -170,7 +172,11 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
170
172
  } else {
171
173
  width = props.width || "100%";
172
174
  }
173
- var needsWrapper = withCssAspectRatio && !supportsAspectRatio;
175
+ /**
176
+ * In safari, when using a video with poster, the transition from pause to play does a flicker,
177
+ * To avoid this, in Safari browsers, instead of using the poster attribute, we use a
178
+ * wrapper with the poster as background image
179
+ */ var needsWrapper = isSafari() || withCssAspectRatio && !supportsAspectRatio;
174
180
  var video1 = /*#__PURE__*/ _jsx("video", _objectSpread({
175
181
  ref: combineRefs(ref, videoRef),
176
182
  playsInline: true,
@@ -179,14 +185,14 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
179
185
  autoPlay: autoPlay,
180
186
  muted: muted,
181
187
  loop: loop
182
- }, !needsWrapper ? {
188
+ }, needsWrapper ? {} : {
183
189
  width: width,
184
190
  height: height
185
- } : {}, {
191
+ }, {
186
192
  className: classes.video,
187
193
  preload: preload,
188
194
  // This transparent pixel fallback avoids showing the ugly "play" image in android webviews
189
- poster: poster || TRANSPARENT_PIXEL
195
+ poster: needsWrapper ? TRANSPARENT_PIXEL : poster || TRANSPARENT_PIXEL
190
196
  }, getPrefixedDataAttributes(dataAttributes), {
191
197
  children: sources.map(function(param, index) {
192
198
  var src = param.src, type = param.type;
@@ -200,7 +206,10 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
200
206
  return /*#__PURE__*/ _jsx("div", {
201
207
  style: {
202
208
  width: width,
203
- height: height
209
+ height: height,
210
+ backgroundImage: poster ? 'url("'.concat(poster, '")') : undefined,
211
+ backgroundSize: "cover",
212
+ backgroundPosition: "50% 50%"
204
213
  },
205
214
  className: classes.wrapper,
206
215
  children: video1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telefonica/mistica",
3
- "version": "11.10.2",
3
+ "version": "11.11.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",