@telefonica/mistica 10.17.0 → 10.18.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 +7 -0
- package/dist/card.d.ts +10 -1
- package/dist/card.js +4 -1
- package/dist/card.js.flow +16 -1
- package/dist/image.d.ts +25 -4
- package/dist/image.js +64 -7
- package/dist/image.js.flow +30 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.flow +1 -0
- package/dist/package-version.js +1 -1
- package/dist/video.d.ts +32 -0
- package/dist/video.js +161 -0
- package/dist/video.js.flow +50 -0
- package/dist-es/card.js +4 -1
- package/dist-es/image.js +38 -6
- package/dist-es/index.js +1 -0
- package/dist-es/package-version.js +1 -1
- package/dist-es/video.js +123 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [10.18.0](https://github.com/Telefonica/mistica-web/compare/v10.17.0...v10.18.0) (2022-01-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **Video:** Video component and Video support in Media Cards ([#391](https://github.com/Telefonica/mistica-web/issues/391)) ([a830a9b](https://github.com/Telefonica/mistica-web/commit/a830a9b2f364d9f17245aba02cfbbfee678a064b))
|
|
7
|
+
|
|
1
8
|
# [10.17.0](https://github.com/Telefonica/mistica-web/compare/v10.16.0...v10.17.0) (2022-01-18)
|
|
2
9
|
|
|
3
10
|
|
package/dist/card.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Tag from './tag';
|
|
3
3
|
import { ButtonLink, ButtonPrimary } from './button';
|
|
4
|
+
import Video from './video';
|
|
5
|
+
import Image from './image';
|
|
4
6
|
import type { ButtonProps, ButtonLinkProps } from './button';
|
|
5
7
|
import type { DataAttributes } from './utils/types';
|
|
6
8
|
import type { TagProps } from './tag';
|
|
9
|
+
import type { VideoProps } from './video';
|
|
10
|
+
import type { ImageProps } from './image';
|
|
11
|
+
/** @deprecated */
|
|
7
12
|
declare type CardMedia = {
|
|
8
13
|
src: string;
|
|
9
14
|
aspectRatio: number;
|
|
@@ -18,7 +23,11 @@ declare type CardMedia = {
|
|
|
18
23
|
height?: undefined;
|
|
19
24
|
};
|
|
20
25
|
declare type MediaCardProps = {
|
|
21
|
-
media: CardMedia
|
|
26
|
+
media: CardMedia | (React.ReactElement<ImageProps, typeof Image> & {
|
|
27
|
+
src?: undefined;
|
|
28
|
+
}) | (React.ReactElement<VideoProps, typeof Video> & {
|
|
29
|
+
src?: undefined;
|
|
30
|
+
});
|
|
22
31
|
headline?: string | React.ReactElement<TagProps, typeof Tag>;
|
|
23
32
|
pretitle?: string;
|
|
24
33
|
title?: string;
|
package/dist/card.js
CHANGED
|
@@ -13,6 +13,7 @@ var _text = require("./text");
|
|
|
13
13
|
var _jss = require("./jss");
|
|
14
14
|
var _boxed = require("./boxed");
|
|
15
15
|
var _buttonGroup = _interopRequireDefault(require("./button-group"));
|
|
16
|
+
var _image = require("./image");
|
|
16
17
|
function _interopRequireDefault(obj) {
|
|
17
18
|
return obj && obj.__esModule ? obj : {
|
|
18
19
|
default: obj
|
|
@@ -174,8 +175,10 @@ var MediaCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
174
175
|
className: classes.mediaCard,
|
|
175
176
|
"aria-label": ariaLabel,
|
|
176
177
|
children: [
|
|
177
|
-
/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
178
|
+
typeof media.src === 'string' ? /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
178
179
|
className: classes.media
|
|
180
|
+
}) : /*#__PURE__*/ (0, _jsxRuntime).jsx(_image.DisableBorderRadiusProvider, {
|
|
181
|
+
children: media
|
|
179
182
|
}),
|
|
180
183
|
/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
181
184
|
className: classes.content,
|
package/dist/card.js.flow
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import Tag from "./tag";
|
|
5
5
|
import { ButtonLink, ButtonPrimary } from "./button";
|
|
6
|
+
import Video from "./video";
|
|
7
|
+
import Image from "./image";
|
|
6
8
|
import type { DataAttributes } from "./utils/types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
7
13
|
declare type CardMedia =
|
|
8
14
|
| {
|
|
9
15
|
src: string,
|
|
@@ -15,7 +21,16 @@ declare type CardMedia =
|
|
|
15
21
|
}
|
|
16
22
|
| { src: string };
|
|
17
23
|
declare type MediaCardProps = {
|
|
18
|
-
media:
|
|
24
|
+
media:
|
|
25
|
+
| CardMedia
|
|
26
|
+
| {
|
|
27
|
+
...React.Element<typeof Image>,
|
|
28
|
+
...{},
|
|
29
|
+
}
|
|
30
|
+
| {
|
|
31
|
+
...React.Element<typeof Video>,
|
|
32
|
+
...{},
|
|
33
|
+
},
|
|
19
34
|
headline?: string | React.Element<typeof Tag>,
|
|
20
35
|
pretitle?: string,
|
|
21
36
|
title?: string,
|
package/dist/image.d.ts
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare
|
|
3
|
-
declare
|
|
2
|
+
export declare const useDisableBorderRadius: () => boolean;
|
|
3
|
+
export declare const DisableBorderRadiusProvider: React.FC;
|
|
4
|
+
export declare type AspectRatio = '1:1' | '16:9' | '7:10';
|
|
5
|
+
export declare const RATIO: {
|
|
6
|
+
'1:1': number;
|
|
7
|
+
'16:9': number;
|
|
8
|
+
'7:10': number;
|
|
9
|
+
};
|
|
10
|
+
export declare type ImageProps = {
|
|
11
|
+
src: string;
|
|
12
|
+
url?: undefined;
|
|
13
|
+
/** defaults to 100% when no width and no height are given */
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
/** defaults to 1:1, if both width and height are given, aspectRatio is ignored */
|
|
17
|
+
aspectRatio?: AspectRatio;
|
|
18
|
+
/** defaults to empty string */
|
|
19
|
+
alt?: string;
|
|
20
|
+
children?: void;
|
|
21
|
+
};
|
|
22
|
+
/** @deprecated */
|
|
23
|
+
declare type DeprecatedImageProps = {
|
|
4
24
|
url: string;
|
|
25
|
+
src?: undefined;
|
|
5
26
|
width?: number;
|
|
6
27
|
height?: number;
|
|
7
|
-
/** defaults to 1:1 */
|
|
28
|
+
/** defaults to 1:1, if both width and height are given, aspectRatio is ignored */
|
|
8
29
|
aspectRatio?: AspectRatio;
|
|
9
30
|
/** defaults to empty string */
|
|
10
31
|
alt?: string;
|
|
11
32
|
children?: void;
|
|
12
33
|
};
|
|
13
|
-
declare const Image: React.FC<
|
|
34
|
+
declare const Image: React.FC<ImageProps | DeprecatedImageProps>;
|
|
14
35
|
export default Image;
|
package/dist/image.js
CHANGED
|
@@ -2,9 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.default = void 0;
|
|
5
|
+
exports.default = exports.useDisableBorderRadius = exports.RATIO = exports.DisableBorderRadiusProvider = void 0;
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
7
8
|
var _jss = require("./jss");
|
|
9
|
+
function _interopRequireWildcard(obj) {
|
|
10
|
+
if (obj && obj.__esModule) {
|
|
11
|
+
return obj;
|
|
12
|
+
} else {
|
|
13
|
+
var newObj = {
|
|
14
|
+
};
|
|
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
|
+
};
|
|
20
|
+
if (desc.get || desc.set) {
|
|
21
|
+
Object.defineProperty(newObj, key, desc);
|
|
22
|
+
} else {
|
|
23
|
+
newObj[key] = obj[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
newObj.default = obj;
|
|
29
|
+
return newObj;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
8
32
|
function _objectWithoutProperties(source, excluded) {
|
|
9
33
|
if (source == null) return {
|
|
10
34
|
};
|
|
@@ -35,14 +59,37 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
35
59
|
}
|
|
36
60
|
return target;
|
|
37
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* This context is used internally to disable the border radius. This is useful for example
|
|
64
|
+
* when using the Image component inside a Card
|
|
65
|
+
*/ var DisableBorderRadiusContext = /*#__PURE__*/ React.createContext(false);
|
|
66
|
+
var useDisableBorderRadius = function useDisableBorderRadius() {
|
|
67
|
+
return React.useContext(DisableBorderRadiusContext);
|
|
68
|
+
};
|
|
69
|
+
exports.useDisableBorderRadius = useDisableBorderRadius;
|
|
70
|
+
var DisableBorderRadiusProvider = function DisableBorderRadiusProvider(param) {
|
|
71
|
+
var children = param.children;
|
|
72
|
+
/*#__PURE__*/ return (0, _jsxRuntime).jsx(DisableBorderRadiusContext.Provider, {
|
|
73
|
+
value: true,
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
exports.DisableBorderRadiusProvider = DisableBorderRadiusProvider;
|
|
38
78
|
var useStyles = (0, _jss).createUseStyles(function() {
|
|
39
79
|
return {
|
|
40
80
|
image: {
|
|
41
|
-
borderRadius:
|
|
81
|
+
borderRadius: function borderRadius(param) {
|
|
82
|
+
var noBorderRadius = param.noBorderRadius;
|
|
83
|
+
return noBorderRadius ? 0 : 4;
|
|
84
|
+
},
|
|
42
85
|
display: 'block',
|
|
43
86
|
objectFit: 'cover',
|
|
44
87
|
maxWidth: '100%',
|
|
45
|
-
maxHeight: '100%'
|
|
88
|
+
maxHeight: '100%',
|
|
89
|
+
aspectRatio: function aspectRatio(param) {
|
|
90
|
+
var aspectRatio1 = param.aspectRatio;
|
|
91
|
+
return aspectRatio1 !== null && aspectRatio1 !== void 0 ? aspectRatio1 : 'unset';
|
|
92
|
+
}
|
|
46
93
|
}
|
|
47
94
|
};
|
|
48
95
|
});
|
|
@@ -51,19 +98,29 @@ var RATIO = {
|
|
|
51
98
|
'16:9': 16 / 9,
|
|
52
99
|
'7:10': 7 / 10
|
|
53
100
|
};
|
|
101
|
+
exports.RATIO = RATIO;
|
|
54
102
|
var Image = function Image(_param) {
|
|
55
|
-
var
|
|
56
|
-
"url",
|
|
103
|
+
var _aspectRatio = _param.aspectRatio, aspectRatio = _aspectRatio === void 0 ? '1:1' : _aspectRatio, _alt = _param.alt, alt = _alt === void 0 ? '' : _alt, props = _objectWithoutProperties(_param, [
|
|
57
104
|
"aspectRatio",
|
|
58
105
|
"alt"
|
|
59
106
|
]);
|
|
60
|
-
var
|
|
107
|
+
var noBorderRadius = useDisableBorderRadius();
|
|
108
|
+
var classes = useStyles({
|
|
109
|
+
noBorderRadius: noBorderRadius,
|
|
110
|
+
aspectRatio: !props.width && !props.height ? RATIO[aspectRatio] : undefined
|
|
111
|
+
});
|
|
112
|
+
var url = props.src || props.url;
|
|
61
113
|
var width = props.width;
|
|
62
114
|
var height = props.height;
|
|
63
|
-
if (props.width !== undefined) {
|
|
115
|
+
if (props.width !== undefined && props.height !== undefined) {
|
|
116
|
+
width = props.width;
|
|
117
|
+
height = props.height;
|
|
118
|
+
} else if (props.width !== undefined) {
|
|
64
119
|
height = props.width / RATIO[aspectRatio];
|
|
65
120
|
} else if (props.height !== undefined) {
|
|
66
121
|
width = props.height * RATIO[aspectRatio];
|
|
122
|
+
} else {
|
|
123
|
+
width = '100%';
|
|
67
124
|
}
|
|
68
125
|
return(/*#__PURE__*/ (0, _jsxRuntime).jsx("img", {
|
|
69
126
|
src: url,
|
package/dist/image.js.flow
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
declare
|
|
5
|
-
declare
|
|
4
|
+
declare export var useDisableBorderRadius: () => boolean;
|
|
5
|
+
declare export var DisableBorderRadiusProvider: React.ComponentType<{}>;
|
|
6
|
+
export type AspectRatio = "1:1" | "16:9" | "7:10";
|
|
7
|
+
declare export var RATIO: {
|
|
8
|
+
"1:1": number,
|
|
9
|
+
"16:9": number,
|
|
10
|
+
"7:10": number,
|
|
11
|
+
};
|
|
12
|
+
export type ImageProps = {
|
|
13
|
+
src: string,
|
|
14
|
+
/**
|
|
15
|
+
* defaults to 100% when no width and no height are given
|
|
16
|
+
*/
|
|
17
|
+
width?: number,
|
|
18
|
+
height?: number,
|
|
19
|
+
/**
|
|
20
|
+
* defaults to 1:1, if both width and height are given, aspectRatio is ignored
|
|
21
|
+
*/
|
|
22
|
+
aspectRatio?: AspectRatio,
|
|
23
|
+
/**
|
|
24
|
+
* defaults to empty string
|
|
25
|
+
*/
|
|
26
|
+
alt?: string,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
31
|
+
declare type DeprecatedImageProps = {
|
|
6
32
|
url: string,
|
|
7
33
|
width?: number,
|
|
8
34
|
height?: number,
|
|
9
35
|
/**
|
|
10
|
-
* defaults to 1:1
|
|
36
|
+
* defaults to 1:1, if both width and height are given, aspectRatio is ignored
|
|
11
37
|
*/
|
|
12
38
|
aspectRatio?: AspectRatio,
|
|
13
39
|
/**
|
|
@@ -15,5 +41,5 @@ declare type Props = {
|
|
|
15
41
|
*/
|
|
16
42
|
alt?: string,
|
|
17
43
|
};
|
|
18
|
-
declare var Image: React.ComponentType<
|
|
44
|
+
declare var Image: React.ComponentType<ImageProps | DeprecatedImageProps>;
|
|
19
45
|
declare export default typeof Image;
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export { default as Callout } from './callout';
|
|
|
55
55
|
export { useModalState } from './modal-context-provider';
|
|
56
56
|
export { NavigationBar, MainNavigationBar, FunnelNavigationBar, NavigationBarActionGroup, NavigationBarAction, NavigationBarLogo, } from './navigation-bar';
|
|
57
57
|
export { default as Image } from './image';
|
|
58
|
+
export { default as Video } from './video';
|
|
58
59
|
export { default as Form } from './form';
|
|
59
60
|
export { default as Select } from './select';
|
|
60
61
|
export { default as TextField } from './text-field';
|
package/dist/index.js
CHANGED
|
@@ -566,6 +566,12 @@ Object.defineProperty(exports, "Image", {
|
|
|
566
566
|
return _image.default;
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
|
+
Object.defineProperty(exports, "Video", {
|
|
570
|
+
enumerable: true,
|
|
571
|
+
get: function() {
|
|
572
|
+
return _video.default;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
569
575
|
Object.defineProperty(exports, "Form", {
|
|
570
576
|
enumerable: true,
|
|
571
577
|
get: function() {
|
|
@@ -8298,6 +8304,7 @@ var _callout = _interopRequireDefault(require("./callout"));
|
|
|
8298
8304
|
var _modalContextProvider = require("./modal-context-provider");
|
|
8299
8305
|
var _navigationBar = require("./navigation-bar");
|
|
8300
8306
|
var _image = _interopRequireDefault(require("./image"));
|
|
8307
|
+
var _video = _interopRequireDefault(require("./video"));
|
|
8301
8308
|
var _form = _interopRequireDefault(require("./form"));
|
|
8302
8309
|
var _select = _interopRequireDefault(require("./select"));
|
|
8303
8310
|
var _textField = _interopRequireDefault(require("./text-field"));
|
package/dist/index.js.flow
CHANGED
|
@@ -98,6 +98,7 @@ declare export {
|
|
|
98
98
|
NavigationBarLogo,
|
|
99
99
|
} from "./navigation-bar";
|
|
100
100
|
declare export { default as Image } from "./image";
|
|
101
|
+
declare export { default as Video } from "./video";
|
|
101
102
|
declare export { default as Form } from "./form";
|
|
102
103
|
declare export { default as Select } from "./select";
|
|
103
104
|
declare export { default as TextField } from "./text-field";
|
package/dist/package-version.js
CHANGED
package/dist/video.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare type AspectRatio = '1:1' | '16:9' | '12:5';
|
|
3
|
+
export declare const RATIO: {
|
|
4
|
+
'1:1': number;
|
|
5
|
+
'16:9': number;
|
|
6
|
+
'12:5': number;
|
|
7
|
+
};
|
|
8
|
+
declare type VideoSource = {
|
|
9
|
+
src: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type VideoProps = {
|
|
13
|
+
/** defaults to 100% when no width and no height are given */
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
/** defaults to 1:1, if both width and height are given, aspectRatio is ignored */
|
|
17
|
+
aspectRatio?: AspectRatio;
|
|
18
|
+
/** accepts multiple sources */
|
|
19
|
+
src: string | Array<string> | VideoSource | Array<VideoSource>;
|
|
20
|
+
/** defaults to true */
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
/** defaults to true */
|
|
23
|
+
muted?: boolean;
|
|
24
|
+
/** defaults to true */
|
|
25
|
+
autoPlay?: boolean;
|
|
26
|
+
poster?: string;
|
|
27
|
+
children?: void;
|
|
28
|
+
/** defaults to none */
|
|
29
|
+
preload?: 'none' | 'metadata' | 'auto';
|
|
30
|
+
};
|
|
31
|
+
declare const Video: React.ForwardRefExoticComponent<VideoProps & React.RefAttributes<HTMLVideoElement>>;
|
|
32
|
+
export default Video;
|
package/dist/video.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = exports.RATIO = void 0;
|
|
6
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _image = require("./image");
|
|
9
|
+
var _jss = require("./jss");
|
|
10
|
+
var _common = require("./utils/common");
|
|
11
|
+
function _interopRequireWildcard(obj) {
|
|
12
|
+
if (obj && obj.__esModule) {
|
|
13
|
+
return obj;
|
|
14
|
+
} else {
|
|
15
|
+
var newObj = {
|
|
16
|
+
};
|
|
17
|
+
if (obj != null) {
|
|
18
|
+
for(var key in obj){
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
20
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
21
|
+
};
|
|
22
|
+
if (desc.get || desc.set) {
|
|
23
|
+
Object.defineProperty(newObj, key, desc);
|
|
24
|
+
} else {
|
|
25
|
+
newObj[key] = obj[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
newObj.default = obj;
|
|
31
|
+
return newObj;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function _objectWithoutProperties(source, excluded) {
|
|
35
|
+
if (source == null) return {
|
|
36
|
+
};
|
|
37
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
38
|
+
var key, i;
|
|
39
|
+
if (Object.getOwnPropertySymbols) {
|
|
40
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
41
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
42
|
+
key = sourceSymbolKeys[i];
|
|
43
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
44
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
45
|
+
target[key] = source[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return target;
|
|
49
|
+
}
|
|
50
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
51
|
+
if (source == null) return {
|
|
52
|
+
};
|
|
53
|
+
var target = {
|
|
54
|
+
};
|
|
55
|
+
var sourceKeys = Object.keys(source);
|
|
56
|
+
var key, i;
|
|
57
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
58
|
+
key = sourceKeys[i];
|
|
59
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
60
|
+
target[key] = source[key];
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
var RATIO = {
|
|
65
|
+
'1:1': 1,
|
|
66
|
+
'16:9': 16 / 9,
|
|
67
|
+
'12:5': 12 / 5
|
|
68
|
+
};
|
|
69
|
+
exports.RATIO = RATIO;
|
|
70
|
+
var useStyles = (0, _jss).createUseStyles(function() {
|
|
71
|
+
return {
|
|
72
|
+
video: {
|
|
73
|
+
borderRadius: function borderRadius(param) {
|
|
74
|
+
var noBorderRadius = param.noBorderRadius;
|
|
75
|
+
return noBorderRadius ? 0 : 4;
|
|
76
|
+
},
|
|
77
|
+
display: 'block',
|
|
78
|
+
maxWidth: '100%',
|
|
79
|
+
maxHeight: '100%',
|
|
80
|
+
objectFit: 'cover',
|
|
81
|
+
aspectRatio: function aspectRatio(param) {
|
|
82
|
+
var aspectRatio1 = param.aspectRatio;
|
|
83
|
+
return aspectRatio1 !== null && aspectRatio1 !== void 0 ? aspectRatio1 : 'unset';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
/** Transparent 1x1px PNG */ var TRANSPARENT_PIXEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC';
|
|
89
|
+
var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
90
|
+
var src = _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, [
|
|
91
|
+
"src",
|
|
92
|
+
"poster",
|
|
93
|
+
"autoPlay",
|
|
94
|
+
"muted",
|
|
95
|
+
"loop",
|
|
96
|
+
"preload",
|
|
97
|
+
"aspectRatio"
|
|
98
|
+
]);
|
|
99
|
+
var noBorderRadius = (0, _image).useDisableBorderRadius();
|
|
100
|
+
var classes = useStyles({
|
|
101
|
+
noBorderRadius: noBorderRadius,
|
|
102
|
+
aspectRatio: !props.width && !props.height ? RATIO[aspectRatio] : undefined
|
|
103
|
+
});
|
|
104
|
+
var videoRef = React.useRef(null);
|
|
105
|
+
React.useEffect(function() {
|
|
106
|
+
var video = videoRef.current;
|
|
107
|
+
if (video && autoPlay && video.paused) {
|
|
108
|
+
video.play();
|
|
109
|
+
}
|
|
110
|
+
}, [
|
|
111
|
+
autoPlay
|
|
112
|
+
]);
|
|
113
|
+
// normalize sources
|
|
114
|
+
var sources = (Array.isArray(src) ? src : [
|
|
115
|
+
src
|
|
116
|
+
]).map(function(source) {
|
|
117
|
+
if (typeof source === 'string') {
|
|
118
|
+
return {
|
|
119
|
+
src: source
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
122
|
+
return source;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
var width = props.width;
|
|
126
|
+
var height = props.height;
|
|
127
|
+
if (props.width !== undefined && props.height !== undefined) {
|
|
128
|
+
width = props.width;
|
|
129
|
+
height = props.height;
|
|
130
|
+
} else if (props.width !== undefined) {
|
|
131
|
+
height = props.width / RATIO[aspectRatio];
|
|
132
|
+
} else if (props.height !== undefined) {
|
|
133
|
+
width = props.height * RATIO[aspectRatio];
|
|
134
|
+
} else {
|
|
135
|
+
width = '100%';
|
|
136
|
+
}
|
|
137
|
+
return(/*#__PURE__*/ (0, _jsxRuntime).jsx("video", {
|
|
138
|
+
ref: (0, _common).combineRefs(ref, videoRef),
|
|
139
|
+
playsInline: true,
|
|
140
|
+
disablePictureInPicture: true,
|
|
141
|
+
disableRemotePlayback: true,
|
|
142
|
+
autoPlay: autoPlay,
|
|
143
|
+
muted: muted,
|
|
144
|
+
loop: loop,
|
|
145
|
+
width: width,
|
|
146
|
+
height: height,
|
|
147
|
+
className: classes.video,
|
|
148
|
+
preload: preload,
|
|
149
|
+
// This transparent pixel fallback avoids showing the ugly "play" image in android webviews
|
|
150
|
+
poster: poster || TRANSPARENT_PIXEL,
|
|
151
|
+
children: sources.map(function(param, index) {
|
|
152
|
+
var src = param.src, type = param.type;
|
|
153
|
+
/*#__PURE__*/ return (0, _jsxRuntime).jsx("source", {
|
|
154
|
+
src: src,
|
|
155
|
+
type: type
|
|
156
|
+
}, index);
|
|
157
|
+
})
|
|
158
|
+
}));
|
|
159
|
+
});
|
|
160
|
+
var _default = Video;
|
|
161
|
+
exports.default = _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export type AspectRatio = "1:1" | "16:9" | "12:5";
|
|
5
|
+
declare export var RATIO: {
|
|
6
|
+
"1:1": number,
|
|
7
|
+
"16:9": number,
|
|
8
|
+
"12:5": number,
|
|
9
|
+
};
|
|
10
|
+
declare type VideoSource = {
|
|
11
|
+
src: string,
|
|
12
|
+
type?: string,
|
|
13
|
+
};
|
|
14
|
+
export type VideoProps = {
|
|
15
|
+
/**
|
|
16
|
+
* defaults to 100% when no width and no height are given
|
|
17
|
+
*/
|
|
18
|
+
width?: number,
|
|
19
|
+
height?: number,
|
|
20
|
+
/**
|
|
21
|
+
* defaults to 1:1, if both width and height are given, aspectRatio is ignored
|
|
22
|
+
*/
|
|
23
|
+
aspectRatio?: AspectRatio,
|
|
24
|
+
/**
|
|
25
|
+
* accepts multiple sources
|
|
26
|
+
*/
|
|
27
|
+
src: string | Array<string> | VideoSource | Array<VideoSource>,
|
|
28
|
+
/**
|
|
29
|
+
* defaults to true
|
|
30
|
+
*/
|
|
31
|
+
loop?: boolean,
|
|
32
|
+
/**
|
|
33
|
+
* defaults to true
|
|
34
|
+
*/
|
|
35
|
+
muted?: boolean,
|
|
36
|
+
/**
|
|
37
|
+
* defaults to true
|
|
38
|
+
*/
|
|
39
|
+
autoPlay?: boolean,
|
|
40
|
+
poster?: string,
|
|
41
|
+
/**
|
|
42
|
+
* defaults to none
|
|
43
|
+
*/
|
|
44
|
+
preload?: "none" | "metadata" | "auto",
|
|
45
|
+
};
|
|
46
|
+
declare var Video: React.ComponentType<{
|
|
47
|
+
...VideoProps,
|
|
48
|
+
ref?: React.Ref<HTMLVideoElement>,
|
|
49
|
+
}>;
|
|
50
|
+
declare export default typeof Video;
|
package/dist-es/card.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Text1, Text2, Text4 } from './text';
|
|
|
8
8
|
import { createUseStyles } from './jss';
|
|
9
9
|
import { Boxed } from './boxed';
|
|
10
10
|
import ButtonGroup from './button-group';
|
|
11
|
+
import { DisableBorderRadiusProvider } from './image';
|
|
11
12
|
var useCardContentStyles = createUseStyles(function() {
|
|
12
13
|
return {
|
|
13
14
|
actions: {
|
|
@@ -141,8 +142,10 @@ export var MediaCard = /*#__PURE__*/ React.forwardRef(function(param, ref) {
|
|
|
141
142
|
className: classes.mediaCard,
|
|
142
143
|
"aria-label": ariaLabel,
|
|
143
144
|
children: [
|
|
144
|
-
/*#__PURE__*/ _jsx("div", {
|
|
145
|
+
typeof media.src === 'string' ? /*#__PURE__*/ _jsx("div", {
|
|
145
146
|
className: classes.media
|
|
147
|
+
}) : /*#__PURE__*/ _jsx(DisableBorderRadiusProvider, {
|
|
148
|
+
children: media
|
|
146
149
|
}),
|
|
147
150
|
/*#__PURE__*/ _jsx("div", {
|
|
148
151
|
className: classes.content,
|
package/dist-es/image.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { createUseStyles } from './jss';
|
|
3
4
|
function _objectWithoutProperties(source, excluded) {
|
|
4
5
|
if (source == null) return {
|
|
@@ -30,31 +31,62 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
30
31
|
}
|
|
31
32
|
return target;
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* This context is used internally to disable the border radius. This is useful for example
|
|
36
|
+
* when using the Image component inside a Card
|
|
37
|
+
*/ var DisableBorderRadiusContext = /*#__PURE__*/ React.createContext(false);
|
|
38
|
+
export var useDisableBorderRadius = function() {
|
|
39
|
+
return React.useContext(DisableBorderRadiusContext);
|
|
40
|
+
};
|
|
41
|
+
export var DisableBorderRadiusProvider = function(param) {
|
|
42
|
+
var children = param.children;
|
|
43
|
+
/*#__PURE__*/ return _jsx(DisableBorderRadiusContext.Provider, {
|
|
44
|
+
value: true,
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
};
|
|
33
48
|
var useStyles = createUseStyles(function() {
|
|
34
49
|
return {
|
|
35
50
|
image: {
|
|
36
|
-
borderRadius:
|
|
51
|
+
borderRadius: function(param) {
|
|
52
|
+
var noBorderRadius = param.noBorderRadius;
|
|
53
|
+
return noBorderRadius ? 0 : 4;
|
|
54
|
+
},
|
|
37
55
|
display: 'block',
|
|
38
56
|
objectFit: 'cover',
|
|
39
57
|
maxWidth: '100%',
|
|
40
|
-
maxHeight: '100%'
|
|
58
|
+
maxHeight: '100%',
|
|
59
|
+
aspectRatio: function(param) {
|
|
60
|
+
var aspectRatio = param.aspectRatio;
|
|
61
|
+
return aspectRatio !== null && aspectRatio !== void 0 ? aspectRatio : 'unset';
|
|
62
|
+
}
|
|
41
63
|
}
|
|
42
64
|
};
|
|
43
65
|
});
|
|
44
|
-
var RATIO = {
|
|
66
|
+
export var RATIO = {
|
|
45
67
|
'1:1': 1,
|
|
46
68
|
'16:9': 16 / 9,
|
|
47
69
|
'7:10': 7 / 10
|
|
48
70
|
};
|
|
49
71
|
var Image = function(_param) {
|
|
50
|
-
var
|
|
51
|
-
var
|
|
72
|
+
var _aspectRatio = _param.aspectRatio, aspectRatio = _aspectRatio === void 0 ? '1:1' : _aspectRatio, _alt = _param.alt, alt = _alt === void 0 ? '' : _alt, props = _objectWithoutProperties(_param, ["aspectRatio", "alt"]);
|
|
73
|
+
var noBorderRadius = useDisableBorderRadius();
|
|
74
|
+
var classes = useStyles({
|
|
75
|
+
noBorderRadius: noBorderRadius,
|
|
76
|
+
aspectRatio: !props.width && !props.height ? RATIO[aspectRatio] : undefined
|
|
77
|
+
});
|
|
78
|
+
var url = props.src || props.url;
|
|
52
79
|
var width = props.width;
|
|
53
80
|
var height = props.height;
|
|
54
|
-
if (props.width !== undefined) {
|
|
81
|
+
if (props.width !== undefined && props.height !== undefined) {
|
|
82
|
+
width = props.width;
|
|
83
|
+
height = props.height;
|
|
84
|
+
} else if (props.width !== undefined) {
|
|
55
85
|
height = props.width / RATIO[aspectRatio];
|
|
56
86
|
} else if (props.height !== undefined) {
|
|
57
87
|
width = props.height * RATIO[aspectRatio];
|
|
88
|
+
} else {
|
|
89
|
+
width = '100%';
|
|
58
90
|
}
|
|
59
91
|
return(/*#__PURE__*/ _jsx("img", {
|
|
60
92
|
src: url,
|
package/dist-es/index.js
CHANGED
|
@@ -56,6 +56,7 @@ export { default as Callout } from './callout';
|
|
|
56
56
|
export { useModalState } from './modal-context-provider';
|
|
57
57
|
export { NavigationBar, MainNavigationBar, FunnelNavigationBar, NavigationBarActionGroup, NavigationBarAction, NavigationBarLogo } from './navigation-bar';
|
|
58
58
|
export { default as Image } from './image';
|
|
59
|
+
export { default as Video } from './video';
|
|
59
60
|
// Forms
|
|
60
61
|
export { default as Form } from './form';
|
|
61
62
|
export { default as Select } from './select';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// DO NOT EDIT THIS FILE. It's autogenerated by set-version.js
|
|
2
|
-
export var PACKAGE_VERSION = '10.
|
|
2
|
+
export var PACKAGE_VERSION = '10.18.0';
|
package/dist-es/video.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useDisableBorderRadius } from './image';
|
|
4
|
+
import { createUseStyles } from './jss';
|
|
5
|
+
import { combineRefs } from './utils/common';
|
|
6
|
+
function _objectWithoutProperties(source, excluded) {
|
|
7
|
+
if (source == null) return {
|
|
8
|
+
};
|
|
9
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
10
|
+
var key, i;
|
|
11
|
+
if (Object.getOwnPropertySymbols) {
|
|
12
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
13
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
14
|
+
key = sourceSymbolKeys[i];
|
|
15
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
16
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
17
|
+
target[key] = source[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
}
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
23
|
+
if (source == null) return {
|
|
24
|
+
};
|
|
25
|
+
var target = {
|
|
26
|
+
};
|
|
27
|
+
var sourceKeys = Object.keys(source);
|
|
28
|
+
var key, i;
|
|
29
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
30
|
+
key = sourceKeys[i];
|
|
31
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
32
|
+
target[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
export var RATIO = {
|
|
37
|
+
'1:1': 1,
|
|
38
|
+
'16:9': 16 / 9,
|
|
39
|
+
'12:5': 12 / 5
|
|
40
|
+
};
|
|
41
|
+
var useStyles = createUseStyles(function() {
|
|
42
|
+
return {
|
|
43
|
+
video: {
|
|
44
|
+
borderRadius: function(param) {
|
|
45
|
+
var noBorderRadius = param.noBorderRadius;
|
|
46
|
+
return noBorderRadius ? 0 : 4;
|
|
47
|
+
},
|
|
48
|
+
display: 'block',
|
|
49
|
+
maxWidth: '100%',
|
|
50
|
+
maxHeight: '100%',
|
|
51
|
+
objectFit: 'cover',
|
|
52
|
+
aspectRatio: function(param) {
|
|
53
|
+
var aspectRatio = param.aspectRatio;
|
|
54
|
+
return aspectRatio !== null && aspectRatio !== void 0 ? aspectRatio : 'unset';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
/** Transparent 1x1px PNG */ var TRANSPARENT_PIXEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC';
|
|
60
|
+
var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
61
|
+
var src = _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, ["src", "poster", "autoPlay", "muted", "loop", "preload", "aspectRatio"]);
|
|
62
|
+
var noBorderRadius = useDisableBorderRadius();
|
|
63
|
+
var classes = useStyles({
|
|
64
|
+
noBorderRadius: noBorderRadius,
|
|
65
|
+
aspectRatio: !props.width && !props.height ? RATIO[aspectRatio] : undefined
|
|
66
|
+
});
|
|
67
|
+
var videoRef = React.useRef(null);
|
|
68
|
+
React.useEffect(function() {
|
|
69
|
+
var video = videoRef.current;
|
|
70
|
+
if (video && autoPlay && video.paused) {
|
|
71
|
+
video.play();
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
autoPlay
|
|
75
|
+
]);
|
|
76
|
+
// normalize sources
|
|
77
|
+
var sources = (Array.isArray(src) ? src : [
|
|
78
|
+
src
|
|
79
|
+
]).map(function(source) {
|
|
80
|
+
if (typeof source === 'string') {
|
|
81
|
+
return {
|
|
82
|
+
src: source
|
|
83
|
+
};
|
|
84
|
+
} else {
|
|
85
|
+
return source;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
var width = props.width;
|
|
89
|
+
var height = props.height;
|
|
90
|
+
if (props.width !== undefined && props.height !== undefined) {
|
|
91
|
+
width = props.width;
|
|
92
|
+
height = props.height;
|
|
93
|
+
} else if (props.width !== undefined) {
|
|
94
|
+
height = props.width / RATIO[aspectRatio];
|
|
95
|
+
} else if (props.height !== undefined) {
|
|
96
|
+
width = props.height * RATIO[aspectRatio];
|
|
97
|
+
} else {
|
|
98
|
+
width = '100%';
|
|
99
|
+
}
|
|
100
|
+
return(/*#__PURE__*/ _jsx("video", {
|
|
101
|
+
ref: combineRefs(ref, videoRef),
|
|
102
|
+
playsInline: true,
|
|
103
|
+
disablePictureInPicture: true,
|
|
104
|
+
disableRemotePlayback: true,
|
|
105
|
+
autoPlay: autoPlay,
|
|
106
|
+
muted: muted,
|
|
107
|
+
loop: loop,
|
|
108
|
+
width: width,
|
|
109
|
+
height: height,
|
|
110
|
+
className: classes.video,
|
|
111
|
+
preload: preload,
|
|
112
|
+
// This transparent pixel fallback avoids showing the ugly "play" image in android webviews
|
|
113
|
+
poster: poster || TRANSPARENT_PIXEL,
|
|
114
|
+
children: sources.map(function(param, index) {
|
|
115
|
+
var src = param.src, type = param.type;
|
|
116
|
+
/*#__PURE__*/ return _jsx("source", {
|
|
117
|
+
src: src,
|
|
118
|
+
type: type
|
|
119
|
+
}, index);
|
|
120
|
+
})
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
export default Video;
|