pb-sxp-ui 1.0.22 → 1.0.23
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/index.cjs +4 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +4 -18
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/PictureGroup/Picture.js +2 -17
- package/es/core/components/SxpPageRender/index.js +1 -1
- package/lib/core/components/SxpPageRender/PictureGroup/Picture.js +1 -16
- package/lib/core/components/SxpPageRender/index.js +1 -1
- package/package.json +1 -1
@@ -1,31 +1,16 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { useState } from 'react';
|
2
2
|
import FormatImage from '../FormatImage';
|
3
|
-
import { useSxpDataSource } from '../../../../core/hooks';
|
4
3
|
const Picture = (props) => {
|
5
4
|
const { src, height, width } = props;
|
6
5
|
const [blur, setBlur] = useState(false);
|
7
|
-
const { sxpParameter } = useSxpDataSource();
|
8
6
|
const onLoad = (img) => {
|
9
|
-
const aspectRatio = img.
|
7
|
+
const aspectRatio = img.naturalHeight / img.naturalWidth;
|
10
8
|
const targetAspectRatio = 16 / 9;
|
11
9
|
const tolerance = 0.05;
|
12
10
|
if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
|
13
11
|
setBlur(true);
|
14
12
|
}
|
15
13
|
};
|
16
|
-
const getImg = useCallback((src, style) => {
|
17
|
-
if (src === '' || !src)
|
18
|
-
return;
|
19
|
-
return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (React.createElement("picture", null,
|
20
|
-
React.createElement("source", { type: 'image/avif', srcSet: src }),
|
21
|
-
React.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
|
22
|
-
React.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
|
23
|
-
React.createElement("img", { src: src, style: style, onLoad: (e) => {
|
24
|
-
onLoad(e.target);
|
25
|
-
} }))) : (React.createElement("img", { src: src, style: style, onLoad: (e) => {
|
26
|
-
onLoad(e.target);
|
27
|
-
} }));
|
28
|
-
}, []);
|
29
14
|
return (React.createElement("div", { style: {
|
30
15
|
overflow: 'hidden',
|
31
16
|
height,
|
@@ -194,7 +194,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
194
194
|
React.createElement(RenderCard, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
195
195
|
React.createElement("div", null,
|
196
196
|
React.createElement(ExpandableText, { className: 'clc-sxp-bottom-text', isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_c = (_b = rec.video) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : '', style: Object.assign({}, descStyle), onChange: onExpandableChange }),
|
197
|
-
React.createElement(Hashtag, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.
|
197
|
+
React.createElement(Hashtag, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
|
198
198
|
}
|
199
199
|
return null;
|
200
200
|
}, [
|
@@ -3,32 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
5
5
|
const FormatImage_1 = tslib_1.__importDefault(require("../FormatImage"));
|
6
|
-
const hooks_1 = require("../../../../core/hooks");
|
7
6
|
const Picture = (props) => {
|
8
7
|
const { src, height, width } = props;
|
9
8
|
const [blur, setBlur] = (0, react_1.useState)(false);
|
10
|
-
const { sxpParameter } = (0, hooks_1.useSxpDataSource)();
|
11
9
|
const onLoad = (img) => {
|
12
|
-
const aspectRatio = img.
|
10
|
+
const aspectRatio = img.naturalHeight / img.naturalWidth;
|
13
11
|
const targetAspectRatio = 16 / 9;
|
14
12
|
const tolerance = 0.05;
|
15
13
|
if (Math.abs(aspectRatio - targetAspectRatio) > tolerance) {
|
16
14
|
setBlur(true);
|
17
15
|
}
|
18
16
|
};
|
19
|
-
const getImg = (0, react_1.useCallback)((src, style) => {
|
20
|
-
if (src === '' || !src)
|
21
|
-
return;
|
22
|
-
return (src === null || src === void 0 ? void 0 : src.includes('.avif')) ? (react_1.default.createElement("picture", null,
|
23
|
-
react_1.default.createElement("source", { type: 'image/avif', srcSet: src }),
|
24
|
-
react_1.default.createElement("source", { type: 'image/webp', srcSet: `${src}?imageMogr2/format/webp` }),
|
25
|
-
react_1.default.createElement("source", { type: 'image/jpeg', srcSet: `${src}?imageMogr2/format/jpg` }),
|
26
|
-
react_1.default.createElement("img", { src: src, style: style, onLoad: (e) => {
|
27
|
-
onLoad(e.target);
|
28
|
-
} }))) : (react_1.default.createElement("img", { src: src, style: style, onLoad: (e) => {
|
29
|
-
onLoad(e.target);
|
30
|
-
} }));
|
31
|
-
}, []);
|
32
17
|
return (react_1.default.createElement("div", { style: {
|
33
18
|
overflow: 'hidden',
|
34
19
|
height,
|
@@ -197,7 +197,7 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
|
|
197
197
|
react_1.default.createElement(RenderCard_1.default, { rec: rec, index: index, tempMap: tempMap, resolver: resolver })),
|
198
198
|
react_1.default.createElement("div", null,
|
199
199
|
react_1.default.createElement(ExpandableText_1.default, { className: 'clc-sxp-bottom-text', isPost: true, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (_c = (_b = rec.video) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : '', style: Object.assign({}, descStyle), onChange: onExpandableChange }),
|
200
|
-
react_1.default.createElement(Hashtag_1.default, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.
|
200
|
+
react_1.default.createElement(Hashtag_1.default, { index: activeIndex, tags: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.hashTags) !== null && _e !== void 0 ? _e : [], itemId: (_f = rec === null || rec === void 0 ? void 0 : rec.video) === null || _f === void 0 ? void 0 : _f.itemId, itemType: ((_g = rec.video) === null || _g === void 0 ? void 0 : _g.itemId) ? 'VIDEO' : null, rec: rec, hashTagStyle: hashTagStyle })))));
|
201
201
|
}
|
202
202
|
return null;
|
203
203
|
}, [
|