@telefonica/mistica 11.10.0 → 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.
- package/dist/card.d.ts +43 -1
- package/dist/card.js +212 -10
- package/dist/card.js.flow +44 -0
- package/dist/highlighted-card.d.ts +4 -2
- package/dist/highlighted-card.js +19 -72
- package/dist/highlighted-card.js.flow +8 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.flow +1 -1
- package/dist/maybe-dismissable.d.ts +10 -0
- package/dist/maybe-dismissable.js +119 -0
- package/dist/maybe-dismissable.js.flow +12 -0
- package/dist/package-version.js +1 -1
- package/dist/select.js +1 -1
- package/dist/text.js +9 -3
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/platform.js +5 -1
- package/dist/utils/platform.js.flow +7 -0
- package/dist/video.js +14 -5
- package/dist-es/card.js +211 -9
- package/dist-es/highlighted-card.js +17 -70
- package/dist-es/index.js +1 -1
- package/dist-es/maybe-dismissable.js +86 -0
- package/dist-es/package-version.js +1 -1
- package/dist-es/select.js +1 -1
- package/dist-es/text.js +7 -1
- package/dist-es/utils/platform.js +8 -0
- package/dist-es/video.js +14 -5
- package/package.json +3 -3
package/dist/card.d.ts
CHANGED
|
@@ -3,18 +3,23 @@ import Tag from './tag';
|
|
|
3
3
|
import { ButtonLink, ButtonPrimary } from './button';
|
|
4
4
|
import Video from './video';
|
|
5
5
|
import Image from './image';
|
|
6
|
-
import type { DataAttributes, RendersElement, RendersNullableElement } from './utils/types';
|
|
6
|
+
import type { DataAttributes, RendersElement, RendersNullableElement, TrackingEvent } from './utils/types';
|
|
7
7
|
declare type MediaCardProps = {
|
|
8
8
|
media: RendersElement<typeof Image> | RendersElement<typeof Video>;
|
|
9
9
|
headline?: string | RendersNullableElement<typeof Tag>;
|
|
10
10
|
pretitle?: string;
|
|
11
|
+
pretitleLinesMax?: number;
|
|
11
12
|
title?: string;
|
|
13
|
+
titleLinesMax?: number;
|
|
12
14
|
description?: string;
|
|
15
|
+
descriptionLinesMax?: number;
|
|
13
16
|
extra?: React.ReactNode;
|
|
14
17
|
button?: RendersNullableElement<typeof ButtonPrimary>;
|
|
15
18
|
buttonLink?: RendersNullableElement<typeof ButtonLink>;
|
|
16
19
|
children?: void;
|
|
20
|
+
dataAttributes?: DataAttributes;
|
|
17
21
|
'aria-label'?: string;
|
|
22
|
+
onClose?: () => void;
|
|
18
23
|
};
|
|
19
24
|
export declare const MediaCard: React.ForwardRefExoticComponent<MediaCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
25
|
interface DataCardProps {
|
|
@@ -24,8 +29,11 @@ interface DataCardProps {
|
|
|
24
29
|
icon?: React.ReactElement;
|
|
25
30
|
headline?: string | RendersNullableElement<typeof Tag>;
|
|
26
31
|
title?: string;
|
|
32
|
+
titleLinesMax?: number;
|
|
27
33
|
subtitle?: string;
|
|
34
|
+
subtitleLinesMax?: number;
|
|
28
35
|
description?: string;
|
|
36
|
+
descriptionLinesMax?: number;
|
|
29
37
|
extra?: React.ReactNode;
|
|
30
38
|
button?: RendersNullableElement<typeof ButtonPrimary>;
|
|
31
39
|
buttonLink?: RendersNullableElement<typeof ButtonLink>;
|
|
@@ -33,6 +41,40 @@ interface DataCardProps {
|
|
|
33
41
|
/** "data-" prefix is automatically added. For example, use "testid" instead of "data-testid" */
|
|
34
42
|
dataAttributes?: DataAttributes;
|
|
35
43
|
'aria-label'?: string;
|
|
44
|
+
onClose?: () => void;
|
|
36
45
|
}
|
|
37
46
|
export declare const DataCard: React.ForwardRefExoticComponent<DataCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
47
|
+
interface SnapCardBaseProps {
|
|
48
|
+
icon?: React.ReactElement;
|
|
49
|
+
title?: string;
|
|
50
|
+
titleLinesMax?: number;
|
|
51
|
+
subtitle?: string;
|
|
52
|
+
subtitleLinesMax?: number;
|
|
53
|
+
/** "data-" prefix is automatically added. For example, use "testid" instead of "data-testid" */
|
|
54
|
+
dataAttributes?: DataAttributes;
|
|
55
|
+
'aria-label'?: string;
|
|
56
|
+
extra?: React.ReactNode;
|
|
57
|
+
isInverse?: boolean;
|
|
58
|
+
trackingEvent?: TrackingEvent | ReadonlyArray<TrackingEvent>;
|
|
59
|
+
children?: void;
|
|
60
|
+
}
|
|
61
|
+
interface SnapCardToProps extends SnapCardBaseProps {
|
|
62
|
+
to?: string;
|
|
63
|
+
fullPageOnWebView?: boolean;
|
|
64
|
+
href?: undefined;
|
|
65
|
+
onPress?: undefined;
|
|
66
|
+
}
|
|
67
|
+
interface SnapCardHrefProps extends SnapCardBaseProps {
|
|
68
|
+
href?: string;
|
|
69
|
+
newTab?: boolean;
|
|
70
|
+
onPress?: undefined;
|
|
71
|
+
to?: undefined;
|
|
72
|
+
}
|
|
73
|
+
interface SnapCardOnPressProps extends SnapCardBaseProps {
|
|
74
|
+
onPress?: () => void;
|
|
75
|
+
href?: undefined;
|
|
76
|
+
to?: undefined;
|
|
77
|
+
}
|
|
78
|
+
declare type SnapCardProps = SnapCardToProps | SnapCardHrefProps | SnapCardOnPressProps;
|
|
79
|
+
export declare const SnapCard: React.ForwardRefExoticComponent<SnapCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
38
80
|
export {};
|
package/dist/card.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.DataCard = exports.MediaCard = void 0;
|
|
5
|
+
exports.SnapCard = exports.DataCard = exports.MediaCard = void 0;
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _tag = _interopRequireDefault(require("./tag"));
|
|
@@ -14,6 +14,8 @@ var _jss = require("./jss");
|
|
|
14
14
|
var _boxed = require("./boxed");
|
|
15
15
|
var _buttonGroup = _interopRequireDefault(require("./button-group"));
|
|
16
16
|
var _image = require("./image");
|
|
17
|
+
var _maybeDismissable = _interopRequireWildcard(require("./maybe-dismissable"));
|
|
18
|
+
var _touchable = _interopRequireDefault(require("./touchable"));
|
|
17
19
|
function _interopRequireDefault(obj) {
|
|
18
20
|
return obj && obj.__esModule ? obj : {
|
|
19
21
|
default: obj
|
|
@@ -40,6 +42,62 @@ function _interopRequireWildcard(obj) {
|
|
|
40
42
|
return newObj;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
45
|
+
function _defineProperty(obj, key, value) {
|
|
46
|
+
if (key in obj) {
|
|
47
|
+
Object.defineProperty(obj, key, {
|
|
48
|
+
value: value,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
obj[key] = value;
|
|
55
|
+
}
|
|
56
|
+
return obj;
|
|
57
|
+
}
|
|
58
|
+
function _objectSpread(target) {
|
|
59
|
+
var _arguments = arguments, _loop = function(i) {
|
|
60
|
+
var source = _arguments[i] != null ? _arguments[i] : {};
|
|
61
|
+
var ownKeys = Object.keys(source);
|
|
62
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
63
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
ownKeys.forEach(function(key) {
|
|
68
|
+
_defineProperty(target, key, source[key]);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
for(var i = 1; i < arguments.length; i++)_loop(i);
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function _objectWithoutProperties(source, excluded) {
|
|
75
|
+
if (source == null) return {};
|
|
76
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
77
|
+
var key, i;
|
|
78
|
+
if (Object.getOwnPropertySymbols) {
|
|
79
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
80
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
81
|
+
key = sourceSymbolKeys[i];
|
|
82
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
83
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
84
|
+
target[key] = source[key];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
90
|
+
if (source == null) return {};
|
|
91
|
+
var target = {};
|
|
92
|
+
var sourceKeys = Object.keys(source);
|
|
93
|
+
var key, i;
|
|
94
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
95
|
+
key = sourceKeys[i];
|
|
96
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
97
|
+
target[key] = source[key];
|
|
98
|
+
}
|
|
99
|
+
return target;
|
|
100
|
+
}
|
|
43
101
|
var useCardContentStyles = (0, _jss).createUseStyles(function() {
|
|
44
102
|
return {
|
|
45
103
|
actions: {
|
|
@@ -50,7 +108,7 @@ var useCardContentStyles = (0, _jss).createUseStyles(function() {
|
|
|
50
108
|
};
|
|
51
109
|
});
|
|
52
110
|
var CardContent = function CardContent(param) {
|
|
53
|
-
var headline = param.headline, pretitle = param.pretitle, title = param.title, subtitle = param.subtitle, description = param.description, extra = param.extra, button = param.button, buttonLink = param.buttonLink;
|
|
111
|
+
var headline = param.headline, pretitle = param.pretitle, pretitleLinesMax = param.pretitleLinesMax, title = param.title, titleLinesMax = param.titleLinesMax, subtitle = param.subtitle, subtitleLinesMax = param.subtitleLinesMax, description = param.description, descriptionLinesMax = param.descriptionLinesMax, extra = param.extra, button = param.button, buttonLink = param.buttonLink;
|
|
54
112
|
var theme = (0, _hooks).useTheme();
|
|
55
113
|
var classes = useCardContentStyles();
|
|
56
114
|
var renderHeadline = function renderHeadline() {
|
|
@@ -80,16 +138,24 @@ var CardContent = function CardContent(param) {
|
|
|
80
138
|
space: 4,
|
|
81
139
|
children: [
|
|
82
140
|
pretitle && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text1, {
|
|
141
|
+
wordBreak: true,
|
|
142
|
+
truncate: pretitleLinesMax,
|
|
143
|
+
as: "div",
|
|
83
144
|
regular: true,
|
|
84
145
|
transform: "uppercase",
|
|
85
146
|
children: pretitle
|
|
86
147
|
}),
|
|
87
148
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text4, {
|
|
149
|
+
wordBreak: true,
|
|
150
|
+
truncate: titleLinesMax,
|
|
88
151
|
as: "h1",
|
|
89
152
|
regular: true,
|
|
90
153
|
children: title
|
|
91
154
|
}),
|
|
92
155
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
156
|
+
wordBreak: true,
|
|
157
|
+
truncate: subtitleLinesMax,
|
|
158
|
+
as: "div",
|
|
93
159
|
regular: true,
|
|
94
160
|
children: subtitle
|
|
95
161
|
})
|
|
@@ -99,6 +165,8 @@ var CardContent = function CardContent(param) {
|
|
|
99
165
|
})
|
|
100
166
|
}),
|
|
101
167
|
description && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
168
|
+
wordBreak: true,
|
|
169
|
+
truncate: descriptionLinesMax,
|
|
102
170
|
as: "p",
|
|
103
171
|
regular: true,
|
|
104
172
|
color: theme.colors.textSecondary,
|
|
@@ -119,10 +187,27 @@ var CardContent = function CardContent(param) {
|
|
|
119
187
|
]
|
|
120
188
|
});
|
|
121
189
|
};
|
|
190
|
+
var MaybeSection = function MaybeSection(param) {
|
|
191
|
+
var ariaLabel = param["aria-label"], className = param.className, children = param.children;
|
|
192
|
+
var isDismissable = (0, _maybeDismissable).useIsDismissable();
|
|
193
|
+
if (isDismissable) {
|
|
194
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
195
|
+
className: className,
|
|
196
|
+
children: children
|
|
197
|
+
});
|
|
198
|
+
} else {
|
|
199
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx("section", {
|
|
200
|
+
className: className,
|
|
201
|
+
"aria-label": ariaLabel,
|
|
202
|
+
children: children
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
};
|
|
122
206
|
var useMediaCardStyles = (0, _jss).createUseStyles(function() {
|
|
123
207
|
return {
|
|
124
208
|
boxed: {
|
|
125
|
-
height: "100%"
|
|
209
|
+
height: "100%",
|
|
210
|
+
width: "100%"
|
|
126
211
|
},
|
|
127
212
|
mediaCard: {
|
|
128
213
|
display: "flex",
|
|
@@ -139,14 +224,15 @@ var useMediaCardStyles = (0, _jss).createUseStyles(function() {
|
|
|
139
224
|
};
|
|
140
225
|
});
|
|
141
226
|
var MediaCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
142
|
-
var media = param.media, headline = param.headline, pretitle = param.pretitle, title = param.title, description = param.description, extra = param.extra, button = param.button, buttonLink = param.buttonLink, ariaLabel = param["aria-label"];
|
|
227
|
+
var media = param.media, headline = param.headline, pretitle = param.pretitle, pretitleLinesMax = param.pretitleLinesMax, title = param.title, titleLinesMax = param.titleLinesMax, description = param.description, descriptionLinesMax = param.descriptionLinesMax, extra = param.extra, button = param.button, buttonLink = param.buttonLink, dataAttributes = param.dataAttributes, ariaLabel = param["aria-label"], onClose = param.onClose;
|
|
143
228
|
var classes = useMediaCardStyles({
|
|
144
229
|
media: media
|
|
145
230
|
});
|
|
146
|
-
|
|
231
|
+
var content = /*#__PURE__*/ (0, _jsxRuntime).jsx(_boxed.Boxed, {
|
|
147
232
|
className: classes.boxed,
|
|
233
|
+
dataAttributes: dataAttributes,
|
|
148
234
|
ref: ref,
|
|
149
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(
|
|
235
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(MaybeSection, {
|
|
150
236
|
className: classes.mediaCard,
|
|
151
237
|
"aria-label": ariaLabel,
|
|
152
238
|
children: [
|
|
@@ -158,8 +244,11 @@ var MediaCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
158
244
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(CardContent, {
|
|
159
245
|
headline: headline,
|
|
160
246
|
pretitle: pretitle,
|
|
247
|
+
pretitleLinesMax: pretitleLinesMax,
|
|
161
248
|
title: title,
|
|
249
|
+
titleLinesMax: titleLinesMax,
|
|
162
250
|
description: description,
|
|
251
|
+
descriptionLinesMax: descriptionLinesMax,
|
|
163
252
|
extra: extra,
|
|
164
253
|
button: button,
|
|
165
254
|
buttonLink: buttonLink
|
|
@@ -168,12 +257,18 @@ var MediaCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
168
257
|
]
|
|
169
258
|
})
|
|
170
259
|
});
|
|
260
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_maybeDismissable.default, {
|
|
261
|
+
onClose: onClose,
|
|
262
|
+
"aria-label": ariaLabel,
|
|
263
|
+
children: content
|
|
264
|
+
});
|
|
171
265
|
});
|
|
172
266
|
exports.MediaCard = MediaCard;
|
|
173
267
|
var useDataCardStyles = (0, _jss).createUseStyles(function() {
|
|
174
268
|
return {
|
|
175
269
|
boxed: {
|
|
176
|
-
height: "100%"
|
|
270
|
+
height: "100%",
|
|
271
|
+
width: "100%"
|
|
177
272
|
},
|
|
178
273
|
dataCard: {
|
|
179
274
|
display: "flex",
|
|
@@ -184,13 +279,13 @@ var useDataCardStyles = (0, _jss).createUseStyles(function() {
|
|
|
184
279
|
};
|
|
185
280
|
});
|
|
186
281
|
var DataCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
187
|
-
var icon = param.icon, headline = param.headline, title = param.title, subtitle = param.subtitle, description = param.description, extra = param.extra, button = param.button, buttonLink = param.buttonLink, dataAttributes = param.dataAttributes, ariaLabel = param["aria-label"];
|
|
282
|
+
var icon = param.icon, headline = param.headline, title = param.title, titleLinesMax = param.titleLinesMax, subtitle = param.subtitle, subtitleLinesMax = param.subtitleLinesMax, description = param.description, descriptionLinesMax = param.descriptionLinesMax, extra = param.extra, button = param.button, buttonLink = param.buttonLink, dataAttributes = param.dataAttributes, ariaLabel = param["aria-label"], onClose = param.onClose;
|
|
188
283
|
var classes = useDataCardStyles();
|
|
189
|
-
|
|
284
|
+
var content = /*#__PURE__*/ (0, _jsxRuntime).jsx(_boxed.Boxed, {
|
|
190
285
|
className: classes.boxed,
|
|
191
286
|
dataAttributes: dataAttributes,
|
|
192
287
|
ref: ref,
|
|
193
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(
|
|
288
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(MaybeSection, {
|
|
194
289
|
className: classes.dataCard,
|
|
195
290
|
"aria-label": ariaLabel,
|
|
196
291
|
children: [
|
|
@@ -201,8 +296,11 @@ var DataCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
201
296
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(CardContent, {
|
|
202
297
|
headline: headline,
|
|
203
298
|
title: title,
|
|
299
|
+
titleLinesMax: titleLinesMax,
|
|
204
300
|
subtitle: subtitle,
|
|
301
|
+
subtitleLinesMax: subtitleLinesMax,
|
|
205
302
|
description: description,
|
|
303
|
+
descriptionLinesMax: descriptionLinesMax,
|
|
206
304
|
extra: extra,
|
|
207
305
|
button: button,
|
|
208
306
|
buttonLink: buttonLink
|
|
@@ -210,5 +308,109 @@ var DataCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
210
308
|
]
|
|
211
309
|
})
|
|
212
310
|
});
|
|
311
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_maybeDismissable.default, {
|
|
312
|
+
"aria-label": ariaLabel,
|
|
313
|
+
onClose: onClose,
|
|
314
|
+
children: content
|
|
315
|
+
});
|
|
213
316
|
});
|
|
214
317
|
exports.DataCard = DataCard;
|
|
318
|
+
var useSnapCardStyles = (0, _jss).createUseStyles(function(theme) {
|
|
319
|
+
return {
|
|
320
|
+
boxed: {
|
|
321
|
+
height: "100%"
|
|
322
|
+
},
|
|
323
|
+
touchable: _defineProperty({
|
|
324
|
+
display: "flex",
|
|
325
|
+
height: "100%"
|
|
326
|
+
}, theme.mq.supportsHover, {
|
|
327
|
+
"&:hover": {
|
|
328
|
+
backgroundColor: function backgroundColor(param) {
|
|
329
|
+
var isTouchable = param.isTouchable, isInverse = param.isInverse;
|
|
330
|
+
return isTouchable && !isInverse && !theme.isDarkMode ? theme.colors.backgroundAlternative : "transparent";
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}),
|
|
334
|
+
snapCard: _defineProperty({
|
|
335
|
+
height: "100%",
|
|
336
|
+
display: "flex",
|
|
337
|
+
flexDirection: "column",
|
|
338
|
+
justifyContent: "space-between",
|
|
339
|
+
padding: 16,
|
|
340
|
+
minHeight: 80,
|
|
341
|
+
minWidth: 104
|
|
342
|
+
}, theme.mq.desktopOrBigger, {
|
|
343
|
+
padding: 24
|
|
344
|
+
})
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
var SnapCard = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
348
|
+
var icon = _param.icon, title = _param.title, titleLinesMax = _param.titleLinesMax, subtitle = _param.subtitle, subtitleLinesMax = _param.subtitleLinesMax, dataAttributes = _param.dataAttributes, ariaLabel = _param["aria-label"], extra = _param.extra, _isInverse = _param.isInverse, isInverse = _isInverse === void 0 ? false : _isInverse, touchableProps = _objectWithoutProperties(_param, [
|
|
349
|
+
"icon",
|
|
350
|
+
"title",
|
|
351
|
+
"titleLinesMax",
|
|
352
|
+
"subtitle",
|
|
353
|
+
"subtitleLinesMax",
|
|
354
|
+
"dataAttributes",
|
|
355
|
+
"aria-label",
|
|
356
|
+
"extra",
|
|
357
|
+
"isInverse"
|
|
358
|
+
]);
|
|
359
|
+
var isTouchable = Boolean(touchableProps.to || touchableProps.href || touchableProps.onPress);
|
|
360
|
+
var classes = useSnapCardStyles({
|
|
361
|
+
isTouchable: isTouchable,
|
|
362
|
+
isInverse: isInverse,
|
|
363
|
+
hasIcon: !!icon
|
|
364
|
+
});
|
|
365
|
+
var colors = (0, _hooks).useTheme().colors;
|
|
366
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_boxed.Boxed, {
|
|
367
|
+
className: classes.boxed,
|
|
368
|
+
dataAttributes: dataAttributes,
|
|
369
|
+
ref: ref,
|
|
370
|
+
isInverse: isInverse,
|
|
371
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_touchable.default, _objectSpread({
|
|
372
|
+
maybe: true
|
|
373
|
+
}, touchableProps, {
|
|
374
|
+
className: classes.touchable,
|
|
375
|
+
"aria-label": ariaLabel,
|
|
376
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs("section", {
|
|
377
|
+
className: classes.snapCard,
|
|
378
|
+
children: [
|
|
379
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
380
|
+
children: [
|
|
381
|
+
icon && /*#__PURE__*/ (0, _jsxRuntime).jsx(_box.default, {
|
|
382
|
+
paddingBottom: 16,
|
|
383
|
+
children: icon
|
|
384
|
+
}),
|
|
385
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsxs(_stack.default, {
|
|
386
|
+
space: 4,
|
|
387
|
+
children: [
|
|
388
|
+
title && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
389
|
+
wordBreak: true,
|
|
390
|
+
truncate: titleLinesMax,
|
|
391
|
+
as: "h1",
|
|
392
|
+
regular: true,
|
|
393
|
+
children: title
|
|
394
|
+
}),
|
|
395
|
+
subtitle && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
396
|
+
wordBreak: true,
|
|
397
|
+
truncate: subtitleLinesMax,
|
|
398
|
+
regular: true,
|
|
399
|
+
color: colors.textSecondary,
|
|
400
|
+
as: "p",
|
|
401
|
+
children: subtitle
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
})
|
|
405
|
+
]
|
|
406
|
+
}),
|
|
407
|
+
extra && /*#__PURE__*/ (0, _jsxRuntime).jsx(_box.default, {
|
|
408
|
+
paddingTop: 16,
|
|
409
|
+
children: extra
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
})
|
|
413
|
+
}))
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
exports.SnapCard = SnapCard;
|
package/dist/card.js.flow
CHANGED
|
@@ -9,17 +9,23 @@ import type {
|
|
|
9
9
|
DataAttributes,
|
|
10
10
|
RendersElement,
|
|
11
11
|
RendersNullableElement,
|
|
12
|
+
TrackingEvent,
|
|
12
13
|
} from "./utils/types";
|
|
13
14
|
declare type MediaCardProps = {
|
|
14
15
|
media: RendersElement<typeof Image> | RendersElement<typeof Video>,
|
|
15
16
|
headline?: string | RendersNullableElement<typeof Tag>,
|
|
16
17
|
pretitle?: string,
|
|
18
|
+
pretitleLinesMax?: number,
|
|
17
19
|
title?: string,
|
|
20
|
+
titleLinesMax?: number,
|
|
18
21
|
description?: string,
|
|
22
|
+
descriptionLinesMax?: number,
|
|
19
23
|
extra?: React.Node,
|
|
20
24
|
button?: RendersNullableElement<typeof ButtonPrimary>,
|
|
21
25
|
buttonLink?: RendersNullableElement<typeof ButtonLink>,
|
|
26
|
+
dataAttributes?: DataAttributes,
|
|
22
27
|
"aria-label"?: string,
|
|
28
|
+
onClose?: () => void,
|
|
23
29
|
};
|
|
24
30
|
declare export var MediaCard: React.AbstractComponent<MediaCardProps, HTMLDivElement>;
|
|
25
31
|
declare type DataCardProps = {
|
|
@@ -29,8 +35,11 @@ declare type DataCardProps = {
|
|
|
29
35
|
icon?: React.Element<any>,
|
|
30
36
|
headline?: string | RendersNullableElement<typeof Tag>,
|
|
31
37
|
title?: string,
|
|
38
|
+
titleLinesMax?: number,
|
|
32
39
|
subtitle?: string,
|
|
40
|
+
subtitleLinesMax?: number,
|
|
33
41
|
description?: string,
|
|
42
|
+
descriptionLinesMax?: number,
|
|
34
43
|
extra?: React.Node,
|
|
35
44
|
button?: RendersNullableElement<typeof ButtonPrimary>,
|
|
36
45
|
buttonLink?: RendersNullableElement<typeof ButtonLink>,
|
|
@@ -39,6 +48,41 @@ declare type DataCardProps = {
|
|
|
39
48
|
*/
|
|
40
49
|
dataAttributes?: DataAttributes,
|
|
41
50
|
"aria-label"?: string,
|
|
51
|
+
onClose?: () => void,
|
|
42
52
|
};
|
|
43
53
|
declare export var DataCard: React.AbstractComponent<DataCardProps, HTMLDivElement>;
|
|
54
|
+
declare type SnapCardBaseProps = {
|
|
55
|
+
icon?: React.Element<any>,
|
|
56
|
+
title?: string,
|
|
57
|
+
titleLinesMax?: number,
|
|
58
|
+
subtitle?: string,
|
|
59
|
+
subtitleLinesMax?: number,
|
|
60
|
+
/**
|
|
61
|
+
* "data-" prefix is automatically added. For example, use "testid" instead of "data-testid"
|
|
62
|
+
*/
|
|
63
|
+
dataAttributes?: DataAttributes,
|
|
64
|
+
"aria-label"?: string,
|
|
65
|
+
extra?: React.Node,
|
|
66
|
+
isInverse?: boolean,
|
|
67
|
+
trackingEvent?: TrackingEvent | $ReadOnlyArray<TrackingEvent>,
|
|
68
|
+
};
|
|
69
|
+
declare type SnapCardToProps = {
|
|
70
|
+
...$Exact<SnapCardBaseProps>,
|
|
71
|
+
to?: string,
|
|
72
|
+
fullPageOnWebView?: boolean,
|
|
73
|
+
};
|
|
74
|
+
declare type SnapCardHrefProps = {
|
|
75
|
+
...$Exact<SnapCardBaseProps>,
|
|
76
|
+
href?: string,
|
|
77
|
+
newTab?: boolean,
|
|
78
|
+
};
|
|
79
|
+
declare type SnapCardOnPressProps = {
|
|
80
|
+
...$Exact<SnapCardBaseProps>,
|
|
81
|
+
onPress?: () => void,
|
|
82
|
+
};
|
|
83
|
+
declare type SnapCardProps =
|
|
84
|
+
| SnapCardToProps
|
|
85
|
+
| SnapCardHrefProps
|
|
86
|
+
| SnapCardOnPressProps;
|
|
87
|
+
declare export var SnapCard: React.AbstractComponent<SnapCardProps, HTMLDivElement>;
|
|
44
88
|
declare export {};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ButtonLink } from './button';
|
|
3
|
-
import type { RendersNullableElement, TrackingEvent } from './utils/types';
|
|
3
|
+
import type { DataAttributes, RendersNullableElement, TrackingEvent } from './utils/types';
|
|
4
4
|
import type { NullableButtonElement } from './button';
|
|
5
5
|
interface CommonProps {
|
|
6
6
|
title: string;
|
|
7
|
+
titleLinesMax?: number;
|
|
7
8
|
description: string;
|
|
9
|
+
descriptionLinesMax?: number;
|
|
8
10
|
imageUrl?: string;
|
|
9
11
|
imageFit?: 'fit' | 'fill';
|
|
10
|
-
backgroundImageUrl?: string;
|
|
11
12
|
onClose?: () => void;
|
|
12
13
|
trackingEvent?: TrackingEvent | ReadonlyArray<TrackingEvent>;
|
|
13
14
|
isInverse?: boolean;
|
|
14
15
|
children?: void;
|
|
15
16
|
'aria-label'?: string;
|
|
16
17
|
width?: string | number;
|
|
18
|
+
dataAttributes?: DataAttributes;
|
|
17
19
|
}
|
|
18
20
|
interface BasicProps extends CommonProps {
|
|
19
21
|
button?: undefined;
|
package/dist/highlighted-card.js
CHANGED
|
@@ -9,12 +9,10 @@ var _jss = require("./jss");
|
|
|
9
9
|
var _themeVariantContext = require("./theme-variant-context");
|
|
10
10
|
var _box = _interopRequireDefault(require("./box"));
|
|
11
11
|
var _touchable = _interopRequireDefault(require("./touchable"));
|
|
12
|
-
var _iconCloseRegular = _interopRequireDefault(require("./generated/mistica-icons/icon-close-regular"));
|
|
13
|
-
var _color = require("./utils/color");
|
|
14
12
|
var _hooks = require("./hooks");
|
|
15
13
|
var _text = require("./text");
|
|
16
|
-
var _iconButton = _interopRequireDefault(require("./icon-button"));
|
|
17
14
|
var _boxed = require("./boxed");
|
|
15
|
+
var _maybeDismissable = _interopRequireWildcard(require("./maybe-dismissable"));
|
|
18
16
|
function _interopRequireDefault(obj) {
|
|
19
17
|
return obj && obj.__esModule ? obj : {
|
|
20
18
|
default: obj
|
|
@@ -117,35 +115,6 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
117
115
|
minWidth: 100,
|
|
118
116
|
height: "inherit"
|
|
119
117
|
},
|
|
120
|
-
dismissableContainer: {
|
|
121
|
-
position: "relative",
|
|
122
|
-
display: "flex",
|
|
123
|
-
flexShrink: 0,
|
|
124
|
-
width: function width(param) {
|
|
125
|
-
var width2 = param.width;
|
|
126
|
-
return width2 || "100%";
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
dismissableButton: {
|
|
130
|
-
position: "absolute",
|
|
131
|
-
top: 0,
|
|
132
|
-
right: 0,
|
|
133
|
-
width: 48,
|
|
134
|
-
height: 48,
|
|
135
|
-
display: "flex",
|
|
136
|
-
alignItems: "center",
|
|
137
|
-
justifyContent: "center"
|
|
138
|
-
},
|
|
139
|
-
dismissableCircleContainer: {
|
|
140
|
-
display: "flex",
|
|
141
|
-
alignItems: "center",
|
|
142
|
-
justifyContent: "center",
|
|
143
|
-
width: 24,
|
|
144
|
-
height: 24,
|
|
145
|
-
margin: "0 0 8px 8px",
|
|
146
|
-
borderRadius: "50%",
|
|
147
|
-
backgroundColor: (0, _color).applyAlpha(theme.colors.background, 0.7)
|
|
148
|
-
},
|
|
149
118
|
textContainer: (_obj = {
|
|
150
119
|
paddingLeft: 16,
|
|
151
120
|
paddingTop: 24,
|
|
@@ -165,43 +134,12 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
165
134
|
display: "flex",
|
|
166
135
|
flexShrink: 0,
|
|
167
136
|
width: function width(param) {
|
|
168
|
-
var
|
|
169
|
-
return
|
|
137
|
+
var width2 = param.width;
|
|
138
|
+
return width2 || "100%";
|
|
170
139
|
}
|
|
171
140
|
}
|
|
172
141
|
};
|
|
173
142
|
});
|
|
174
|
-
var Dismissable = function Dismissable(param) {
|
|
175
|
-
var children = param.children, width = param.width, _onClose = param.onClose, onClose = _onClose === void 0 ? function onClose() {} : _onClose;
|
|
176
|
-
var isInverse = (0, _themeVariantContext).useIsInverseVariant();
|
|
177
|
-
var classes = useStyles({
|
|
178
|
-
isInverse: isInverse,
|
|
179
|
-
width: width
|
|
180
|
-
});
|
|
181
|
-
var ref = (0, _hooks).useTheme(), colors = ref.colors, texts = ref.texts;
|
|
182
|
-
return /*#__PURE__*/ (0, _jsxRuntime).jsxs("section", {
|
|
183
|
-
className: classes.dismissableContainer,
|
|
184
|
-
children: [
|
|
185
|
-
children,
|
|
186
|
-
/*#__PURE__*/ (0, _jsxRuntime).jsx(_iconButton.default, {
|
|
187
|
-
className: classes.dismissableButton,
|
|
188
|
-
onPress: onClose,
|
|
189
|
-
"aria-label": texts.closeButtonLabel,
|
|
190
|
-
style: {
|
|
191
|
-
display: "flex",
|
|
192
|
-
width: 48,
|
|
193
|
-
height: 48
|
|
194
|
-
},
|
|
195
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
196
|
-
className: classes.dismissableCircleContainer,
|
|
197
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_iconCloseRegular.default, {
|
|
198
|
-
color: colors.neutralHigh
|
|
199
|
-
})
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
143
|
var Content = function Content(props) {
|
|
206
144
|
var title = props.title, description = props.description, imageUrl = props.imageUrl, imageFit = props.imageFit;
|
|
207
145
|
var isInverseOutside = (0, _themeVariantContext).useIsInverseVariant();
|
|
@@ -213,18 +151,24 @@ var Content = function Content(props) {
|
|
|
213
151
|
width: props.width
|
|
214
152
|
});
|
|
215
153
|
var theme = (0, _hooks).useTheme();
|
|
154
|
+
var isDismissable = (0, _maybeDismissable).useIsDismissable();
|
|
216
155
|
var content = /*#__PURE__*/ (0, _jsxRuntime).jsxs(_boxed.Boxed, {
|
|
217
156
|
isInverse: isInverse,
|
|
218
157
|
className: classes.container,
|
|
158
|
+
dataAttributes: props.dataAttributes,
|
|
219
159
|
children: [
|
|
220
160
|
/*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
221
161
|
// don't create another region when the Content is inside a Dismissable wrapper
|
|
222
|
-
role:
|
|
162
|
+
role: !isDismissable ? "region" : undefined,
|
|
223
163
|
className: classes.textContainer,
|
|
224
|
-
|
|
164
|
+
// aria-label is already in Dismisable wrapper
|
|
165
|
+
"aria-label": !isDismissable ? props["aria-label"] : undefined,
|
|
225
166
|
children: [
|
|
226
167
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text4, {
|
|
168
|
+
as: "h1",
|
|
227
169
|
regular: true,
|
|
170
|
+
wordBreak: true,
|
|
171
|
+
truncate: props.titleLinesMax,
|
|
228
172
|
children: title
|
|
229
173
|
}),
|
|
230
174
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(_box.default, {
|
|
@@ -232,6 +176,9 @@ var Content = function Content(props) {
|
|
|
232
176
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
233
177
|
regular: true,
|
|
234
178
|
color: theme.colors.textSecondary,
|
|
179
|
+
wordBreak: true,
|
|
180
|
+
truncate: props.descriptionLinesMax,
|
|
181
|
+
as: "p",
|
|
235
182
|
children: description
|
|
236
183
|
})
|
|
237
184
|
}),
|
|
@@ -294,14 +241,14 @@ var HighlightedCard = function HighlightedCard(_param) {
|
|
|
294
241
|
"aria-label"
|
|
295
242
|
]);
|
|
296
243
|
var label = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : props.title;
|
|
297
|
-
return
|
|
244
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_maybeDismissable.default, {
|
|
298
245
|
onClose: props.onClose,
|
|
299
246
|
"aria-label": label,
|
|
300
247
|
width: props.width,
|
|
301
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(Content, _objectSpread({}, props
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
})
|
|
248
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(Content, _objectSpread({}, props, {
|
|
249
|
+
"aria-label": label
|
|
250
|
+
}))
|
|
251
|
+
});
|
|
305
252
|
};
|
|
306
253
|
var _default = HighlightedCard;
|
|
307
254
|
exports.default = _default;
|