pb-sxp-ui 1.0.62 → 1.0.64

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 ChatLabs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ChatLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,111 +1,111 @@
1
- <!--
2
- * @Author : haocanweng@chatlabs.cn
3
- * @Date : 2023-08-23 18:25:31
4
- * @LastEditors: binruan@chatlabs.com
5
- * @LastEditTime: 2024-03-20 16:26:29
6
- * @FilePath: \pb-sxp-ui\README.md
7
- -->
8
- <h1 align="center">Page Builder SXP UI</h1>
9
-
10
- <div align="center">
11
- React enterprise-class UI components
12
- </div>
13
-
14
- ## 📦 安装
15
-
16
- ```bash
17
- npm install pb-sxp-ui
18
- # or
19
- yarn add pb-sxp-ui
20
- ```
21
-
22
- ## 🔨 使用
23
- 以 Next.js 框架为例子:
24
-
25
- ```jsx
26
- import { GetServerSideProps } from 'next';
27
- import React, { FC } from 'react'
28
- import Pagebuilder, { PageView } from 'pb-sxp-ui';
29
-
30
- // 初始化 PageBuilder 配置
31
- Pagebuilder.init({
32
- tenantId: 'xxxxxxxxxx',
33
- appId: 'xxxxxxxxx',
34
- env: 'live' // 可选参数,默认是 live 环境
35
- });
36
-
37
-
38
- interface IProps {
39
- path: string;
40
- data: any
41
- }
42
-
43
- const ContentPage: FC<IProps> = ({ data ,path}) => {
44
- return (
45
- <PageView data={data?.data} isSsr path={path}/>
46
- )
47
- }
48
-
49
- export const getServerSideProps: GetServerSideProps<IProps> = async (
50
- context
51
- ) => {
52
- // 接收传来的路径
53
- const path = context.query.path as string;
54
- // 获取页面数据
55
- const result = await Pagebuilder.getDetail(path)
56
- return {
57
- props: {
58
- path,
59
- data: result.data
60
- },
61
- };
62
- };
63
-
64
- export default ContentPage;
65
-
66
- ```
67
-
68
- ## ⌨️ 本地调试
69
-
70
- ### 运行开发环境
71
-
72
- ```bash
73
- $ npm install
74
- $ npm run start
75
- ```
76
-
77
- ### 生成本地开发全局链接
78
-
79
- ```bash
80
- npm link
81
- # or
82
- yarn link
83
- ```
84
-
85
- ### 在使用该包的项目中安装调试
86
-
87
- ```bash
88
- npm link pb-sxp-ui
89
- # or
90
- yarn link pb-sxp-ui
91
- ```
92
-
93
- ## 👾 发布
94
-
95
- ### 打包线上安装包
96
-
97
- ```bash
98
- npm run package
99
- # or
100
- yarn package
101
- ```
102
-
103
- ### 发布 npm
104
-
105
- ```bash
106
- $ npm version patch|minor|major
107
- $ npm publish
108
-
109
- # 自动化发布包
110
- $ npm run pub patch|minor|major|xx.xx.xx
111
- ```
1
+ <!--
2
+ * @Author : haocanweng@chatlabs.cn
3
+ * @Date : 2023-08-23 18:25:31
4
+ * @LastEditors: binruan@chatlabs.com
5
+ * @LastEditTime: 2024-03-20 16:26:29
6
+ * @FilePath: \pb-sxp-ui\README.md
7
+ -->
8
+ <h1 align="center">Page Builder SXP UI</h1>
9
+
10
+ <div align="center">
11
+ React enterprise-class UI components
12
+ </div>
13
+
14
+ ## 📦 安装
15
+
16
+ ```bash
17
+ npm install pb-sxp-ui
18
+ # or
19
+ yarn add pb-sxp-ui
20
+ ```
21
+
22
+ ## 🔨 使用
23
+ 以 Next.js 框架为例子:
24
+
25
+ ```jsx
26
+ import { GetServerSideProps } from 'next';
27
+ import React, { FC } from 'react'
28
+ import Pagebuilder, { PageView } from 'pb-sxp-ui';
29
+
30
+ // 初始化 PageBuilder 配置
31
+ Pagebuilder.init({
32
+ tenantId: 'xxxxxxxxxx',
33
+ appId: 'xxxxxxxxx',
34
+ env: 'live' // 可选参数,默认是 live 环境
35
+ });
36
+
37
+
38
+ interface IProps {
39
+ path: string;
40
+ data: any
41
+ }
42
+
43
+ const ContentPage: FC<IProps> = ({ data ,path}) => {
44
+ return (
45
+ <PageView data={data?.data} isSsr path={path}/>
46
+ )
47
+ }
48
+
49
+ export const getServerSideProps: GetServerSideProps<IProps> = async (
50
+ context
51
+ ) => {
52
+ // 接收传来的路径
53
+ const path = context.query.path as string;
54
+ // 获取页面数据
55
+ const result = await Pagebuilder.getDetail(path)
56
+ return {
57
+ props: {
58
+ path,
59
+ data: result.data
60
+ },
61
+ };
62
+ };
63
+
64
+ export default ContentPage;
65
+
66
+ ```
67
+
68
+ ## ⌨️ 本地调试
69
+
70
+ ### 运行开发环境
71
+
72
+ ```bash
73
+ $ npm install
74
+ $ npm run start
75
+ ```
76
+
77
+ ### 生成本地开发全局链接
78
+
79
+ ```bash
80
+ npm link
81
+ # or
82
+ yarn link
83
+ ```
84
+
85
+ ### 在使用该包的项目中安装调试
86
+
87
+ ```bash
88
+ npm link pb-sxp-ui
89
+ # or
90
+ yarn link pb-sxp-ui
91
+ ```
92
+
93
+ ## 👾 发布
94
+
95
+ ### 打包线上安装包
96
+
97
+ ```bash
98
+ npm run package
99
+ # or
100
+ yarn package
101
+ ```
102
+
103
+ ### 发布 npm
104
+
105
+ ```bash
106
+ $ npm version patch|minor|major
107
+ $ npm publish
108
+
109
+ # 自动化发布包
110
+ $ npm run pub patch|minor|major|xx.xx.xx
111
+ ```
package/dist/index.cjs CHANGED
@@ -11,7 +11,6 @@ var EventEmitter = require('eventemitter3');
11
11
  var css = require('@emotion/css');
12
12
  var proComponents = require('@ant-design/pro-components');
13
13
  var ReactDOM = require('react-dom');
14
- var Hls = require('hls.js');
15
14
 
16
15
  function _interopNamespaceDefault(e) {
17
16
  var n = Object.create(null);
@@ -600,12 +599,16 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
600
599
  }), [bffFetch]);
601
600
  // 获取 Tag
602
601
  const bffGetTagList = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
603
- var _h, _j;
602
+ var _h, _j, _k, _l, _m;
604
603
  if (!utmVal)
605
604
  return;
606
605
  try {
607
- const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: utmVal } }));
608
- setTagList((_j = (_h = result === null || result === void 0 ? void 0 : result.data) === null || _h === void 0 ? void 0 : _h.tags) !== null && _j !== void 0 ? _j : []);
606
+ const val = (_k = (_j = (_h = utmVal === null || utmVal === void 0 ? void 0 : utmVal.split('&')) === null || _h === void 0 ? void 0 : _h.filter((val) => {
607
+ const key = val.split('=')[0];
608
+ return UTM_KEYS.includes(key);
609
+ })) === null || _j === void 0 ? void 0 : _j.join('&')) !== null && _k !== void 0 ? _k : '';
610
+ const result = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('/tag/list', { method: 'GET', query: { channel: decodeURIComponent(val) } }));
611
+ setTagList((_m = (_l = result === null || result === void 0 ? void 0 : result.data) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []);
609
612
  }
610
613
  catch (e) {
611
614
  console.log('e', e);
@@ -8388,7 +8391,7 @@ var ExpandableText$1 = React.memo(ExpandableText);
8388
8391
  * @Author: binruan@chatlabs.com
8389
8392
  * @Date: 2024-03-20 10:27:31
8390
8393
  * @LastEditors: binruan@chatlabs.com
8391
- * @LastEditTime: 2024-04-19 14:12:55
8394
+ * @LastEditTime: 2024-05-17 16:53:11
8392
8395
  * @FilePath: \pb-sxp-ui\src\core\components\SxpPageRender\FormatImage.tsx
8393
8396
  *
8394
8397
  */
@@ -8400,10 +8403,32 @@ const FormatImage = React.forwardRef((props, ref) => {
8400
8403
  setImgSrc(v);
8401
8404
  }
8402
8405
  }));
8406
+ // useEffect(() => {
8407
+ // setImgSrc(src);
8408
+ // }, [src]);
8409
+ const imgRef = React.useRef(null);
8403
8410
  React.useEffect(() => {
8404
- setImgSrc(src);
8411
+ let observer = null;
8412
+ const { current } = imgRef;
8413
+ if (current) {
8414
+ observer = new IntersectionObserver((entries) => {
8415
+ entries.forEach((entry) => {
8416
+ if (entry.isIntersecting) {
8417
+ setImgSrc(src);
8418
+ observer.unobserve(current);
8419
+ }
8420
+ });
8421
+ }, { threshold: 0.1 } // 触发阈值,可根据需要调整
8422
+ );
8423
+ observer.observe(current);
8424
+ }
8425
+ return () => {
8426
+ if (observer && current) {
8427
+ observer.unobserve(current);
8428
+ }
8429
+ };
8405
8430
  }, [src]);
8406
- return (React.createElement(React.Fragment, null, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8431
+ return (React.createElement("div", { ref: imgRef }, (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.includes('.avif')) ? (React.createElement("picture", null,
8407
8432
  React.createElement("source", { type: 'image/avif', srcSet: imgSrc }),
8408
8433
  React.createElement("source", { type: 'image/webp', srcSet: `${imgSrc}?imageMogr2/format/webp` }),
8409
8434
  React.createElement("source", { type: 'image/jpeg', srcSet: `${imgSrc}?imageMogr2/format/jpg` }),
@@ -8472,10 +8497,10 @@ const CommodityDetail$1 = (_a) => {
8472
8497
  React.createElement("div", { className: 'pb-commondity-content-title', style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.title, hidden: !!product && !(product === null || product === void 0 ? void 0 : product.title) }, (_b = product === null || product === void 0 ? void 0 : product.title) !== null && _b !== void 0 ? _b : 'Pendant in Yellow Gold with Diamonds, Medium'),
8473
8498
  React.createElement("div", { className: 'pb-commondity-content-price', style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.price, hidden: !!product && !(product === null || product === void 0 ? void 0 : product.price) }, priceText),
8474
8499
  React.createElement("div", { hidden: !!product && (!(product === null || product === void 0 ? void 0 : product.info) || (product === null || product === void 0 ? void 0 : product.info) === '') },
8475
- React.createElement(ExpandableText$1, { foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, onClick: () => setShowModal(true), isPost: isPost, text: (_c = product === null || product === void 0 ? void 0 : product.info) !== null && _c !== void 0 ? _c : `The design inspiration of Tiffany Lock series comes from the power of connection and inclusiveness, and the
8476
- bold and avant-garde visual design interprets the emotional bond connecting my heart. The Tiffany Lock
8477
- collection is unisex and is inspired by the padlock pattern found in the Tiffany Antique Collection. This
8478
- necklace features a stylish and eye-catching oval clasp chain decorated with a lock pattern. Crafted from
8500
+ React.createElement(ExpandableText$1, { foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, onClick: () => setShowModal(true), isPost: isPost, text: (_c = product === null || product === void 0 ? void 0 : product.info) !== null && _c !== void 0 ? _c : `The design inspiration of Tiffany Lock series comes from the power of connection and inclusiveness, and the
8501
+ bold and avant-garde visual design interprets the emotional bond connecting my heart. The Tiffany Lock
8502
+ collection is unisex and is inspired by the padlock pattern found in the Tiffany Antique Collection. This
8503
+ necklace features a stylish and eye-catching oval clasp chain decorated with a lock pattern. Crafted from
8479
8504
  18-karat gold, this necklace is embellished with hand-set diamonds.`, maxStr: 79, className: 'pb-commondity-content-info', style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.info }))));
8480
8505
  };
8481
8506
  const renderBtn = () => {
@@ -8945,7 +8970,7 @@ const CommodityDetailDiroNew$1 = (_a) => {
8945
8970
  const productInfoText = ({ isPost }) => {
8946
8971
  return (React.createElement("div", { hidden: !!product && (!(product === null || product === void 0 ? void 0 : product.info) || (product === null || product === void 0 ? void 0 : product.info) === '') },
8947
8972
  React.createElement(ExpandableText$1, { isPost: isPost, onClick: () => setShowModal(true), className: 'pb-commondityDiroNew-info', style: commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.info, foldText: tipText === null || tipText === void 0 ? void 0 : tipText.foldText, unfoldText: tipText === null || tipText === void 0 ? void 0 : tipText.unfoldText, text: (product === null || product === void 0 ? void 0 : product.info) ||
8948
- `Unveiled at the Spring-Summer 2023 fashion show, the Dior Toujours bag is distinguished by a casual and practical design. Crafted in black calfskin with Macrocannage topstitching, it showcases a spacious interior compartment with a matching pouch to organize essentials. Its leather strap closure keeps items secure while the D of the CD Lock closure twists to adjust the sides and enhance the bag's silhouette. The leather handles can be adjusted using the small notches in order to be able to carry the large bag by hand or wear it over the shoulder. CD Lock and strap closures D.I.O.R. charms Removable interior pouch Adjustable leather handles Dust bag included
8973
+ `Unveiled at the Spring-Summer 2023 fashion show, the Dior Toujours bag is distinguished by a casual and practical design. Crafted in black calfskin with Macrocannage topstitching, it showcases a spacious interior compartment with a matching pouch to organize essentials. Its leather strap closure keeps items secure while the D of the CD Lock closure twists to adjust the sides and enhance the bag's silhouette. The leather handles can be adjusted using the small notches in order to be able to carry the large bag by hand or wear it over the shoulder. CD Lock and strap closures D.I.O.R. charms Removable interior pouch Adjustable leather handles Dust bag included
8949
8974
  Made in Italy` })));
8950
8975
  };
8951
8976
  return (React.createElement("div", { className: 'pb-commondityDiroNew' },
@@ -12310,6 +12335,7 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12310
12335
  const videoSrc = rec.video.url;
12311
12336
  if (!videoSrc)
12312
12337
  return;
12338
+ videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12313
12339
  setIsPauseVideo(false);
12314
12340
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
12315
12341
  const dom = document.querySelector('#player-container-id');
@@ -12317,7 +12343,6 @@ const VideoWidget$2 = ({ rec, index, height, data, muted, activeIndex, videoPost
12317
12343
  if (!dom && !dom2)
12318
12344
  return;
12319
12345
  videoPlayerWrapperNode === null || videoPlayerWrapperNode === void 0 ? void 0 : videoPlayerWrapperNode.appendChild(dom || dom2);
12320
- videoRef === null || videoRef === void 0 ? void 0 : videoRef.src(videoSrc);
12321
12346
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadedmetadata', handleLoadedmetadata);
12322
12347
  videoRef === null || videoRef === void 0 ? void 0 : videoRef.on('loadeddata', handLoadeddata);
12323
12348
  // videoRef?.on('canplay', handleCanplay);
@@ -13390,8 +13415,8 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
13390
13415
  if (!videoRef.current.src) {
13391
13416
  const videoSrc = rec.video.url;
13392
13417
  if (videoSrc.includes('.m3u8')) {
13393
- if (Hls.isSupported()) {
13394
- const hls = new Hls();
13418
+ if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.Hls.isSupported())) {
13419
+ const hls = new window.Hls();
13395
13420
  hls.loadSource(videoSrc);
13396
13421
  hls.attachMedia(videoRef.current);
13397
13422
  }