@telefonica/mistica 12.6.0 → 12.8.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/carousel.d.ts +2 -0
- package/dist/carousel.js +23 -6
- package/dist/carousel.js.flow +2 -0
- package/dist/fixed-footer-layout.js +31 -9
- package/dist/generated/mistica-icons/icon-buy-data-light.js +5 -11
- package/dist/generated/mistica-icons/icon-buy-data-regular.js +1 -1
- package/dist/generated/mistica-icons/icon-eco-light.js +1 -1
- package/dist/generated/mistica-icons/icon-justice-regular.js +1 -1
- package/dist/generated/mistica-icons/icon-tokens-filled.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-tokens-filled.js +109 -0
- package/dist/generated/mistica-icons/icon-tokens-filled.js.flow +6 -0
- package/dist/generated/mistica-icons/icon-tokens-light.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-tokens-light.js +109 -0
- package/dist/generated/mistica-icons/icon-tokens-light.js.flow +6 -0
- package/dist/generated/mistica-icons/icon-tokens-regular.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-tokens-regular.js +109 -0
- package/dist/generated/mistica-icons/icon-tokens-regular.js.flow +6 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.js +16 -3
- package/dist/hooks.js.flow +3 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +118 -80
- package/dist/image.js.flow +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +21 -0
- package/dist/index.js.flow +3 -0
- package/dist/list.d.ts +1 -0
- package/dist/list.js +4 -2
- package/dist/list.js.flow +1 -0
- package/dist/package-version.js +1 -1
- package/dist/skeletons.d.ts +5 -2
- package/dist/skeletons.js +50 -87
- package/dist/skeletons.js.flow +4 -4
- package/dist/skins/o2.js +1 -1
- package/dist/text-field-base.d.ts +0 -1
- package/dist/text-field-base.js +2 -0
- package/dist/text-field-base.js.flow +0 -1
- package/dist/text-field-components.d.ts +1 -0
- package/dist/text-field-components.js +7 -3
- package/dist/text-field-components.js.flow +1 -0
- package/dist/utils/aspect-ratio-support.d.ts +10 -0
- package/dist/utils/aspect-ratio-support.js +115 -1
- package/dist/utils/aspect-ratio-support.js.flow +14 -0
- package/dist/video.js +20 -79
- package/dist-es/carousel.js +23 -6
- package/dist-es/fixed-footer-layout.js +32 -10
- package/dist-es/generated/mistica-icons/icon-buy-data-light.js +6 -12
- package/dist-es/generated/mistica-icons/icon-buy-data-regular.js +1 -1
- package/dist-es/generated/mistica-icons/icon-eco-light.js +1 -1
- package/dist-es/generated/mistica-icons/icon-justice-regular.js +1 -1
- package/dist-es/generated/mistica-icons/icon-tokens-filled.js +85 -0
- package/dist-es/generated/mistica-icons/icon-tokens-light.js +85 -0
- package/dist-es/generated/mistica-icons/icon-tokens-regular.js +85 -0
- package/dist-es/hooks.js +14 -2
- package/dist-es/image.js +115 -83
- package/dist-es/index.js +3 -0
- package/dist-es/list.js +4 -2
- package/dist-es/package-version.js +1 -1
- package/dist-es/skeletons.js +50 -87
- package/dist-es/skins/o2.js +1 -1
- package/dist-es/text-field-base.js +2 -0
- package/dist-es/text-field-components.js +7 -3
- package/dist-es/utils/aspect-ratio-support.js +112 -0
- package/dist-es/video.js +21 -81
- package/package.json +1 -1
package/dist/skeletons.js
CHANGED
|
@@ -8,7 +8,6 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _skeletonBase = _interopRequireDefault(require("./skeleton-base"));
|
|
9
9
|
var _jss = require("./jss");
|
|
10
10
|
var _stack = _interopRequireDefault(require("./stack"));
|
|
11
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
11
|
var _dom = require("./utils/dom");
|
|
13
12
|
function _interopRequireDefault(obj) {
|
|
14
13
|
return obj && obj.__esModule ? obj : {
|
|
@@ -69,6 +68,8 @@ var transition = "1.5s linear";
|
|
|
69
68
|
var useAnimation = (0, _jss).createUseStyles(function() {
|
|
70
69
|
return {
|
|
71
70
|
animation: {
|
|
71
|
+
width: "100%",
|
|
72
|
+
height: "100%",
|
|
72
73
|
animation: "$pulse ".concat(transition, " infinite")
|
|
73
74
|
},
|
|
74
75
|
"@keyframes pulse": {
|
|
@@ -84,75 +85,52 @@ var useAnimation = (0, _jss).createUseStyles(function() {
|
|
|
84
85
|
}
|
|
85
86
|
};
|
|
86
87
|
});
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
wrap: {
|
|
90
|
-
borderRadius: 8,
|
|
91
|
-
height: function height(param) {
|
|
92
|
-
var _height = param.height, height1 = _height === void 0 ? 8 : _height;
|
|
93
|
-
return height1;
|
|
94
|
-
},
|
|
95
|
-
width: function width(param) {
|
|
96
|
-
var _width = param.width, width1 = _width === void 0 ? "100%" : _width;
|
|
97
|
-
return width1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
var SkeletonLine = function SkeletonLine(param) {
|
|
103
|
-
var _width = param.width, width = _width === void 0 ? "100%" : _width, ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
88
|
+
var SkeletonAnimation = function SkeletonAnimation(param) {
|
|
89
|
+
var children = param.children, ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
104
90
|
var animationClasses = useAnimation();
|
|
105
|
-
var styleClass = useSkeletonStyles({
|
|
106
|
-
width: width
|
|
107
|
-
});
|
|
108
91
|
return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", _objectSpread({
|
|
109
|
-
className:
|
|
92
|
+
className: animationClasses.animation,
|
|
110
93
|
role: "status",
|
|
94
|
+
"aria-busy": true,
|
|
111
95
|
"aria-hidden": ariaLabel === undefined,
|
|
112
|
-
"aria-busy": ariaLabel !== undefined,
|
|
113
96
|
"aria-label": ariaLabel
|
|
114
97
|
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
115
|
-
children:
|
|
98
|
+
children: children
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
var SkeletonLine = function SkeletonLine(param) {
|
|
102
|
+
var _width = param.width, width = _width === void 0 ? "100%" : _width, ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
103
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(SkeletonAnimation, _objectSpread({
|
|
104
|
+
ariaLabel: ariaLabel
|
|
105
|
+
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
106
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
107
|
+
width: width
|
|
108
|
+
})
|
|
116
109
|
}));
|
|
117
110
|
};
|
|
118
111
|
exports.SkeletonLine = SkeletonLine;
|
|
119
112
|
var SkeletonText = function SkeletonText(param) {
|
|
120
113
|
var ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
height: "fit-content"
|
|
124
|
-
});
|
|
125
|
-
return /*#__PURE__*/ (0, _jsxRuntime).jsxs(_stack.default, _objectSpread({
|
|
126
|
-
className: "".concat(animationClasses.animation, " ").concat(styleClass.wrap),
|
|
127
|
-
space: 16,
|
|
128
|
-
role: "status",
|
|
129
|
-
"aria-hidden": ariaLabel === undefined,
|
|
130
|
-
"aria-busy": ariaLabel !== undefined,
|
|
131
|
-
"aria-label": ariaLabel
|
|
114
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(SkeletonAnimation, _objectSpread({
|
|
115
|
+
ariaLabel: ariaLabel
|
|
132
116
|
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
133
|
-
children:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
117
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(_stack.default, {
|
|
118
|
+
space: 16,
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {}),
|
|
121
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {}),
|
|
122
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
123
|
+
width: "75%"
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})
|
|
140
127
|
}));
|
|
141
128
|
};
|
|
142
129
|
exports.SkeletonText = SkeletonText;
|
|
143
130
|
var SkeletonCircle = function SkeletonCircle(param) {
|
|
144
131
|
var ariaLabel = param.ariaLabel, _size = param.size, size = _size === void 0 ? 40 : _size, dataAttributes = param.dataAttributes;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
width: size,
|
|
148
|
-
height: size
|
|
149
|
-
});
|
|
150
|
-
return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", _objectSpread({
|
|
151
|
-
className: (0, _classnames).default(animationClasses.animation, styleClass.wrap),
|
|
152
|
-
role: "status",
|
|
153
|
-
"aria-hidden": ariaLabel === undefined,
|
|
154
|
-
"aria-busy": ariaLabel !== undefined,
|
|
155
|
-
"aria-label": ariaLabel
|
|
132
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(SkeletonAnimation, _objectSpread({
|
|
133
|
+
ariaLabel: ariaLabel
|
|
156
134
|
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
157
135
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
158
136
|
height: size,
|
|
@@ -181,47 +159,32 @@ var useSkeletonRowStyles = (0, _jss).createUseStyles(function() {
|
|
|
181
159
|
});
|
|
182
160
|
var SkeletonRow = function SkeletonRow(param) {
|
|
183
161
|
var _width = param.width, width = _width === void 0 ? "100%" : _width, ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
184
|
-
var animationClasses = useAnimation();
|
|
185
|
-
var styleClass = useSkeletonStyles({
|
|
186
|
-
width: width,
|
|
187
|
-
height: "100%"
|
|
188
|
-
});
|
|
189
162
|
var rowClass = useSkeletonRowStyles();
|
|
190
|
-
return /*#__PURE__*/ (0, _jsxRuntime).
|
|
191
|
-
|
|
192
|
-
role: "status",
|
|
193
|
-
"aria-hidden": ariaLabel === undefined,
|
|
194
|
-
"aria-busy": ariaLabel !== undefined,
|
|
195
|
-
"aria-label": ariaLabel
|
|
163
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(SkeletonAnimation, _objectSpread({
|
|
164
|
+
ariaLabel: ariaLabel
|
|
196
165
|
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
197
|
-
children:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
166
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
167
|
+
className: rowClass.row,
|
|
168
|
+
children: [
|
|
169
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
170
|
+
height: 40,
|
|
171
|
+
width: 40,
|
|
172
|
+
radius: "50%",
|
|
173
|
+
className: rowClass.circle
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
176
|
+
width: width,
|
|
177
|
+
className: rowClass.line
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
})
|
|
209
181
|
}));
|
|
210
182
|
};
|
|
211
183
|
exports.SkeletonRow = SkeletonRow;
|
|
212
184
|
var SkeletonRectangle = function SkeletonRectangle(param) {
|
|
213
185
|
var _width = param.width, width = _width === void 0 ? "100%" : _width, _height = param.height, height = _height === void 0 ? "100%" : _height, ariaLabel = param.ariaLabel, dataAttributes = param.dataAttributes;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
width: width,
|
|
217
|
-
height: "100%"
|
|
218
|
-
});
|
|
219
|
-
return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", _objectSpread({
|
|
220
|
-
className: (0, _classnames).default(animationClasses.animation, styleClass.wrap),
|
|
221
|
-
role: "status",
|
|
222
|
-
"aria-hidden": true,
|
|
223
|
-
"aria-busy": true,
|
|
224
|
-
"aria-label": ariaLabel
|
|
186
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(SkeletonAnimation, _objectSpread({
|
|
187
|
+
ariaLabel: ariaLabel
|
|
225
188
|
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
226
189
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_skeletonBase.default, {
|
|
227
190
|
height: height,
|
package/dist/skeletons.js.flow
CHANGED
|
@@ -20,10 +20,10 @@ declare export var SkeletonCircle: (x: SkeletonCircleProps) => React.Node;
|
|
|
20
20
|
declare type SkeletonRowProps = SkeletonLineProps;
|
|
21
21
|
declare export var SkeletonRow: (x: SkeletonRowProps) => React.Node;
|
|
22
22
|
declare type SkeletonRectangleProps = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
ariaLabel?: string,
|
|
24
|
+
dataAttributes?: DataAttributes,
|
|
25
|
+
width?: number | string,
|
|
26
|
+
height?: number | string,
|
|
27
27
|
};
|
|
28
28
|
declare export var SkeletonRectangle: (x: SkeletonRectangleProps) => React.Node;
|
|
29
29
|
declare export {};
|
package/dist/skins/o2.js
CHANGED
|
@@ -73,7 +73,7 @@ var getO2Skin = function getO2Skin() {
|
|
|
73
73
|
buttonDangerBackground: palette.pepper,
|
|
74
74
|
buttonDangerBackgroundSelected: palette.pepper60,
|
|
75
75
|
buttonDangerBackgroundHover: palette.pepper60,
|
|
76
|
-
buttonLinkBackgroundSelected: palette.
|
|
76
|
+
buttonLinkBackgroundSelected: palette.o2BluePrimary10,
|
|
77
77
|
buttonLinkBackgroundSelectedInverse: (0, _color).applyAlpha(palette.white, 0.2),
|
|
78
78
|
buttonPrimaryBackground: palette.o2BluePrimary,
|
|
79
79
|
buttonPrimaryBackgroundInverse: palette.white,
|
package/dist/text-field-base.js
CHANGED
|
@@ -205,6 +205,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
205
205
|
},
|
|
206
206
|
textArea: _objectSpread((_obj = {
|
|
207
207
|
resize: "none",
|
|
208
|
+
padding: 0,
|
|
208
209
|
marginTop: function marginTop(param) {
|
|
209
210
|
var hasLabel = param.hasLabel;
|
|
210
211
|
return hasLabel ? 28 : 16;
|
|
@@ -441,6 +442,7 @@ var TextFieldBase = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
441
442
|
multiline: multiline,
|
|
442
443
|
fullWidth: fullWidth,
|
|
443
444
|
fieldRef: fieldRef,
|
|
445
|
+
readOnly: rest.readOnly,
|
|
444
446
|
children: [
|
|
445
447
|
startIcon && /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
446
448
|
className: classes.startIcon,
|
|
@@ -297,15 +297,19 @@ var useFieldContainerStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
297
297
|
var multiline = param.multiline;
|
|
298
298
|
return multiline ? 152 : 56;
|
|
299
299
|
}
|
|
300
|
-
}), _defineProperty(_obj1, "display", "flex"), _defineProperty(_obj1, "position", "relative"), _defineProperty(_obj1, "backgroundColor",
|
|
300
|
+
}), _defineProperty(_obj1, "display", "flex"), _defineProperty(_obj1, "position", "relative"), _defineProperty(_obj1, "backgroundColor", function(param) {
|
|
301
|
+
var readOnly = param.readOnly;
|
|
302
|
+
return readOnly ? theme.colors.neutralLow : theme.colors.backgroundContainer;
|
|
303
|
+
}), _obj1)
|
|
301
304
|
};
|
|
302
305
|
});
|
|
303
306
|
var FieldContainer = function FieldContainer(param) {
|
|
304
|
-
var multiline = param.multiline, disabled = param.disabled, children = param.children, helperText = param.helperText, className = param.className, fieldRef = param.fieldRef, fullWidth = param.fullWidth;
|
|
307
|
+
var multiline = param.multiline, disabled = param.disabled, children = param.children, helperText = param.helperText, className = param.className, fieldRef = param.fieldRef, fullWidth = param.fullWidth, readOnly = param.readOnly;
|
|
305
308
|
var classes = useFieldContainerStyles({
|
|
306
309
|
multiline: multiline,
|
|
307
310
|
fullWidth: fullWidth,
|
|
308
|
-
disabled: disabled
|
|
311
|
+
disabled: disabled,
|
|
312
|
+
readOnly: readOnly
|
|
309
313
|
});
|
|
310
314
|
return /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
311
315
|
className: classes.fieldContainer,
|
|
@@ -4,4 +4,14 @@ declare type Props = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const AspectRatioSupportProvider: React.FC<Props>;
|
|
6
6
|
export declare const useSupportsAspectRatio: () => boolean;
|
|
7
|
+
declare type AspectRatioElementProps = {
|
|
8
|
+
width?: number | string;
|
|
9
|
+
height?: number | string;
|
|
10
|
+
aspectRatio: number;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
as?: React.ComponentType<any> | string;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const AspectRatioElement: (props: AspectRatioElementProps) => JSX.Element;
|
|
7
17
|
export {};
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.useSupportsAspectRatio = exports.AspectRatioSupportProvider = void 0;
|
|
5
|
+
exports.AspectRatioElement = exports.useSupportsAspectRatio = exports.AspectRatioSupportProvider = void 0;
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _hooks = require("../hooks");
|
|
9
|
+
var _jss = require("../jss");
|
|
9
10
|
function _interopRequireWildcard(obj) {
|
|
10
11
|
if (obj && obj.__esModule) {
|
|
11
12
|
return obj;
|
|
@@ -35,6 +36,19 @@ function _arrayLikeToArray(arr, len) {
|
|
|
35
36
|
function _arrayWithHoles(arr) {
|
|
36
37
|
if (Array.isArray(arr)) return arr;
|
|
37
38
|
}
|
|
39
|
+
function _defineProperty(obj, key, value) {
|
|
40
|
+
if (key in obj) {
|
|
41
|
+
Object.defineProperty(obj, key, {
|
|
42
|
+
value: value,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
obj[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
38
52
|
function _iterableToArrayLimit(arr, i) {
|
|
39
53
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
54
|
if (_i == null) return;
|
|
@@ -62,6 +76,22 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
62
76
|
function _nonIterableRest() {
|
|
63
77
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
78
|
}
|
|
79
|
+
function _objectSpread(target) {
|
|
80
|
+
var _arguments = arguments, _loop = function(i) {
|
|
81
|
+
var source = _arguments[i] != null ? _arguments[i] : {};
|
|
82
|
+
var ownKeys = Object.keys(source);
|
|
83
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
84
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
85
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
ownKeys.forEach(function(key) {
|
|
89
|
+
_defineProperty(target, key, source[key]);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
for(var i = 1; i < arguments.length; i++)_loop(i);
|
|
93
|
+
return target;
|
|
94
|
+
}
|
|
65
95
|
function _slicedToArray(arr, i) {
|
|
66
96
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
67
97
|
}
|
|
@@ -98,3 +128,87 @@ var useSupportsAspectRatio = function useSupportsAspectRatio() {
|
|
|
98
128
|
return React.useContext(AspectRatioSupport);
|
|
99
129
|
};
|
|
100
130
|
exports.useSupportsAspectRatio = useSupportsAspectRatio;
|
|
131
|
+
var useAspectRatioStyles = (0, _jss).createUseStyles(function() {
|
|
132
|
+
return {
|
|
133
|
+
container: {
|
|
134
|
+
"@supports (aspect-ratio: 1 / 1)": {
|
|
135
|
+
aspectRatio: function aspectRatio(param) {
|
|
136
|
+
var aspectRatio1 = param.aspectRatio;
|
|
137
|
+
return aspectRatio1 !== null && aspectRatio1 !== void 0 ? aspectRatio1 : "unset";
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"$wrapper &": {
|
|
141
|
+
position: function position(param) {
|
|
142
|
+
var aspectRatio = param.aspectRatio;
|
|
143
|
+
return aspectRatio ? "absolute" : "static";
|
|
144
|
+
},
|
|
145
|
+
width: "100%",
|
|
146
|
+
height: "100%",
|
|
147
|
+
top: 0,
|
|
148
|
+
left: 0
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
wrapper: {
|
|
152
|
+
overflow: "hidden",
|
|
153
|
+
maxWidth: "100%",
|
|
154
|
+
maxHeight: "100%",
|
|
155
|
+
position: "relative",
|
|
156
|
+
paddingTop: function paddingTop(param) {
|
|
157
|
+
var aspectRatio = param.aspectRatio, width = param.width;
|
|
158
|
+
if (!aspectRatio) {
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
if (width && typeof width === "string" && width.endsWith("%")) {
|
|
162
|
+
return "".concat(Number(width.replace("%", "")) / aspectRatio, "%");
|
|
163
|
+
}
|
|
164
|
+
return "".concat(100 / aspectRatio, "%");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
var AspectRatioElement = function AspectRatioElement(props) {
|
|
170
|
+
var supportsAspectRatio = useSupportsAspectRatio();
|
|
171
|
+
// if width or height are numeric, we can calculate the other with the ratio without css.
|
|
172
|
+
// if aspect ratio is 0, we use the original image proportions
|
|
173
|
+
var withCssAspectRatio = typeof props.width !== "number" && typeof props.height !== "number" && props.aspectRatio !== 0;
|
|
174
|
+
var classes = useAspectRatioStyles({
|
|
175
|
+
aspectRatio: withCssAspectRatio ? props.aspectRatio : undefined,
|
|
176
|
+
width: props.width
|
|
177
|
+
});
|
|
178
|
+
var width = props.width;
|
|
179
|
+
var height = props.height;
|
|
180
|
+
if (props.width !== undefined && props.height !== undefined) {
|
|
181
|
+
width = props.width;
|
|
182
|
+
height = props.height;
|
|
183
|
+
} else if (typeof props.width === "number") {
|
|
184
|
+
height = props.aspectRatio !== 0 ? props.width / props.aspectRatio : undefined;
|
|
185
|
+
} else if (typeof props.height === "number") {
|
|
186
|
+
width = props.aspectRatio !== 0 ? props.height * props.aspectRatio : undefined;
|
|
187
|
+
} else {
|
|
188
|
+
width = props.width || "100%";
|
|
189
|
+
}
|
|
190
|
+
var needsWrapper = withCssAspectRatio && !supportsAspectRatio;
|
|
191
|
+
var _as;
|
|
192
|
+
var container = /*#__PURE__*/ React.createElement((_as = props.as) !== null && _as !== void 0 ? _as : "div", {
|
|
193
|
+
className: props.className ? "".concat(props.className, " ").concat(classes.container) : classes.container,
|
|
194
|
+
style: _objectSpread({}, needsWrapper ? _objectSpread({}, props.style, {
|
|
195
|
+
width: "100%"
|
|
196
|
+
}) : _objectSpread({}, props.style, {
|
|
197
|
+
width: width,
|
|
198
|
+
height: height
|
|
199
|
+
}))
|
|
200
|
+
}, props.children);
|
|
201
|
+
if (needsWrapper) {
|
|
202
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
203
|
+
style: {
|
|
204
|
+
width: width,
|
|
205
|
+
height: height
|
|
206
|
+
},
|
|
207
|
+
className: classes.wrapper,
|
|
208
|
+
children: container
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
return container;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
exports.AspectRatioElement = AspectRatioElement;
|
|
@@ -6,4 +6,18 @@ declare type Props = {
|
|
|
6
6
|
};
|
|
7
7
|
declare export var AspectRatioSupportProvider: React.ComponentType<Props>;
|
|
8
8
|
declare export var useSupportsAspectRatio: () => boolean;
|
|
9
|
+
declare type AspectRatioElementProps = {
|
|
10
|
+
width?: number | string,
|
|
11
|
+
height?: number | string,
|
|
12
|
+
aspectRatio: number,
|
|
13
|
+
children: React.Node,
|
|
14
|
+
as?: React.ComponentType<any> | string,
|
|
15
|
+
style?: CssStyle,
|
|
16
|
+
className?: string,
|
|
17
|
+
};
|
|
18
|
+
declare export var AspectRatioElement: (
|
|
19
|
+
props: AspectRatioElementProps
|
|
20
|
+
) => React.Node;
|
|
9
21
|
declare export {};
|
|
22
|
+
|
|
23
|
+
import { type CssStyle } from "../__css_types__.js.flow";
|
package/dist/video.js
CHANGED
|
@@ -98,44 +98,13 @@ exports.RATIO = RATIO;
|
|
|
98
98
|
var useStyles = (0, _jss).createUseStyles(function() {
|
|
99
99
|
return {
|
|
100
100
|
video: {
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: "100%",
|
|
101
103
|
background: "transparent",
|
|
102
104
|
display: "block",
|
|
103
105
|
objectFit: "cover",
|
|
104
106
|
maxWidth: "100%",
|
|
105
|
-
maxHeight: "100%"
|
|
106
|
-
"@supports (aspect-ratio: 1 / 1)": {
|
|
107
|
-
aspectRatio: function aspectRatio(param) {
|
|
108
|
-
var aspectRatio1 = param.aspectRatio;
|
|
109
|
-
return aspectRatio1 !== null && aspectRatio1 !== void 0 ? aspectRatio1 : "unset";
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
"$wrapper &": {
|
|
113
|
-
borderRadius: 0,
|
|
114
|
-
position: function position(param) {
|
|
115
|
-
var aspectRatio = param.aspectRatio;
|
|
116
|
-
return aspectRatio ? "absolute" : "static";
|
|
117
|
-
},
|
|
118
|
-
width: "100%",
|
|
119
|
-
height: "100%",
|
|
120
|
-
top: 0,
|
|
121
|
-
left: 0
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
wrapper: {
|
|
125
|
-
overflow: "hidden",
|
|
126
|
-
maxWidth: "100%",
|
|
127
|
-
maxHeight: "100%",
|
|
128
|
-
position: "relative",
|
|
129
|
-
paddingTop: function paddingTop(param) {
|
|
130
|
-
var aspectRatio = param.aspectRatio, width = param.width;
|
|
131
|
-
if (!aspectRatio) {
|
|
132
|
-
return 0;
|
|
133
|
-
}
|
|
134
|
-
if (width && typeof width === "string" && width.endsWith("%")) {
|
|
135
|
-
return "".concat(Number(width.replace("%", "")) / aspectRatio, "%");
|
|
136
|
-
}
|
|
137
|
-
return "".concat(100 / aspectRatio, "%");
|
|
138
|
-
}
|
|
107
|
+
maxHeight: "100%"
|
|
139
108
|
}
|
|
140
109
|
};
|
|
141
110
|
});
|
|
@@ -151,16 +120,9 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
151
120
|
"aspectRatio",
|
|
152
121
|
"dataAttributes"
|
|
153
122
|
]);
|
|
154
|
-
var supportsAspectRatio = (0, _aspectRatioSupport).useSupportsAspectRatio();
|
|
155
123
|
var noBorderRadius = (0, _image).useDisableBorderRadius();
|
|
156
124
|
var ratio = typeof aspectRatio === "number" ? aspectRatio : RATIO[aspectRatio];
|
|
157
|
-
|
|
158
|
-
// if aspect ratio is 0, we use the original video proportions
|
|
159
|
-
var withCssAspectRatio = typeof props.width !== "number" && typeof props.height !== "number" && ratio !== 0;
|
|
160
|
-
var classes = useStyles({
|
|
161
|
-
aspectRatio: withCssAspectRatio ? ratio : undefined,
|
|
162
|
-
width: props.width
|
|
163
|
-
});
|
|
125
|
+
var classes = useStyles();
|
|
164
126
|
var videoRef = React.useRef(null);
|
|
165
127
|
React.useEffect(function() {
|
|
166
128
|
var video = videoRef.current;
|
|
@@ -182,23 +144,6 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
182
144
|
return source;
|
|
183
145
|
}
|
|
184
146
|
});
|
|
185
|
-
var width = props.width;
|
|
186
|
-
var height = props.height;
|
|
187
|
-
if (props.width !== undefined && props.height !== undefined) {
|
|
188
|
-
width = props.width;
|
|
189
|
-
height = props.height;
|
|
190
|
-
} else if (typeof props.width === "number") {
|
|
191
|
-
height = ratio ? props.width / ratio : undefined;
|
|
192
|
-
} else if (typeof props.height === "number") {
|
|
193
|
-
width = ratio ? props.height * ratio : undefined;
|
|
194
|
-
} else {
|
|
195
|
-
width = props.width || "100%";
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* In safari, when using a video with poster, the transition from pause to play does a flicker,
|
|
199
|
-
* To avoid this, in Safari browsers, instead of using the poster attribute, we use a
|
|
200
|
-
* wrapper with the poster as background image
|
|
201
|
-
*/ var needsWrapper = (0, _platform).isSafari() || withCssAspectRatio && !supportsAspectRatio;
|
|
202
147
|
var video1 = /*#__PURE__*/ (0, _jsxRuntime).jsx("video", _objectSpread({
|
|
203
148
|
ref: (0, _common).combineRefs(ref, videoRef),
|
|
204
149
|
playsInline: true,
|
|
@@ -206,13 +151,7 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
206
151
|
disableRemotePlayback: true,
|
|
207
152
|
autoPlay: autoPlay,
|
|
208
153
|
muted: muted,
|
|
209
|
-
loop: loop
|
|
210
|
-
}, needsWrapper ? {
|
|
211
|
-
width: "100%"
|
|
212
|
-
} : {
|
|
213
|
-
width: width,
|
|
214
|
-
height: height
|
|
215
|
-
}, {
|
|
154
|
+
loop: loop,
|
|
216
155
|
className: classes.video,
|
|
217
156
|
preload: preload,
|
|
218
157
|
// This transparent pixel fallback avoids showing the ugly "play" image in android webviews
|
|
@@ -230,23 +169,25 @@ var Video = /*#__PURE__*/ React.forwardRef(function(_param, ref) {
|
|
|
230
169
|
}, index);
|
|
231
170
|
})
|
|
232
171
|
}));
|
|
233
|
-
|
|
234
|
-
|
|
172
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_aspectRatioSupport.AspectRatioElement, {
|
|
173
|
+
aspectRatio: ratio,
|
|
174
|
+
width: props.width,
|
|
175
|
+
height: props.height,
|
|
176
|
+
children: (0, _platform).isSafari() ? /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
235
177
|
style: {
|
|
236
|
-
width:
|
|
237
|
-
height:
|
|
238
|
-
|
|
239
|
-
|
|
178
|
+
width: "100%",
|
|
179
|
+
height: "100%",
|
|
180
|
+
/**
|
|
181
|
+
* In safari, when using a video with poster, the transition from pause to play does a flicker,
|
|
182
|
+
* To avoid this, in Safari browsers, instead of using the poster attribute, we use a
|
|
183
|
+
* wrapper with the poster as background image
|
|
184
|
+
*/ backgroundImage: poster ? 'url("'.concat(poster, '")') : undefined,
|
|
240
185
|
backgroundSize: "cover",
|
|
241
|
-
backgroundPosition: "50% 50%"
|
|
242
|
-
borderRadius: noBorderRadius ? 0 : 8
|
|
186
|
+
backgroundPosition: "50% 50%"
|
|
243
187
|
},
|
|
244
|
-
className: classes.wrapper,
|
|
245
188
|
children: video1
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
return video1;
|
|
249
|
-
}
|
|
189
|
+
}) : video1
|
|
190
|
+
});
|
|
250
191
|
});
|
|
251
192
|
var _default = Video;
|
|
252
193
|
exports.default = _default;
|