pb-sxp-ui 1.20.27 → 1.20.28
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 +174 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +174 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +174 -1
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/index.d.ts +6 -0
- package/es/core/index.js +10 -0
- package/lib/core/index.d.ts +6 -0
- package/lib/core/index.js +10 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -187,6 +187,14 @@ function uuid(len, radix) {
|
|
|
187
187
|
}
|
|
188
188
|
return uuid.join('');
|
|
189
189
|
}
|
|
190
|
+
const getIndexByblockType = (type, index) => {
|
|
191
|
+
if (type === 'CommodityCarouselBlock' || type === 'CopyBlock') {
|
|
192
|
+
return 'initial';
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return index;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
190
198
|
const generateRandomString = (length) => {
|
|
191
199
|
let result = '';
|
|
192
200
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
@@ -246,6 +254,70 @@ const setFontForText = (textContent, style) => {
|
|
|
246
254
|
}
|
|
247
255
|
return content;
|
|
248
256
|
};
|
|
257
|
+
function getBrowserInfo() {
|
|
258
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
259
|
+
const userAgent = self.navigator.userAgent;
|
|
260
|
+
if (!userAgent)
|
|
261
|
+
return null;
|
|
262
|
+
if (/edge\/([\d\.]+)/i.exec(userAgent))
|
|
263
|
+
return `Edge ${(_a = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _a === void 0 ? void 0 : _a[1]}`;
|
|
264
|
+
if (/edg\/([\d\.]+)/i.exec(userAgent))
|
|
265
|
+
return `Edge(Chromium) ${(_b = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _b === void 0 ? void 0 : _b[1]}`;
|
|
266
|
+
if (/msie/i.test(userAgent))
|
|
267
|
+
return `Internet Explorer ${(_c = /msie ([\d\.]+)/i.exec(userAgent)) === null || _c === void 0 ? void 0 : _c[1]}`;
|
|
268
|
+
if (/Trident/i.test(userAgent))
|
|
269
|
+
return `Internet Explorer ${(_d = /rv:([\d\.]+)/i.exec(userAgent)) === null || _d === void 0 ? void 0 : _d[1]}`;
|
|
270
|
+
if (/chrome/i.test(userAgent))
|
|
271
|
+
return `Chrome ${(_e = /chrome\/([\d\.]+)/i.exec(userAgent)) === null || _e === void 0 ? void 0 : _e[1]}`;
|
|
272
|
+
if (/firefox/i.test(userAgent))
|
|
273
|
+
return `Firefox ${(_f = /firefox\/([\d\.]+)/i.exec(userAgent)) === null || _f === void 0 ? void 0 : _f[1]}`;
|
|
274
|
+
if (/safari/i.test(userAgent))
|
|
275
|
+
return `Safari ${(_g = /version\/([\d\.]+)/i.exec(userAgent)) === null || _g === void 0 ? void 0 : _g[1]}`;
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
function getSystem() {
|
|
279
|
+
var _a, _b, _c;
|
|
280
|
+
const userAgent = self.navigator.userAgent;
|
|
281
|
+
if (!userAgent)
|
|
282
|
+
return null;
|
|
283
|
+
if (/iphone/i.test(userAgent))
|
|
284
|
+
return `IOS ${(_a = userAgent.match(/OS\s(.*?)\slike/)) === null || _a === void 0 ? void 0 : _a[1]}`;
|
|
285
|
+
if (/android/i.test(userAgent))
|
|
286
|
+
return `Android ${(_b = userAgent.match(/Android\s(.*?)\;/)) === null || _b === void 0 ? void 0 : _b[1]}`;
|
|
287
|
+
if (/windows/i.test(userAgent))
|
|
288
|
+
return `Windows ${(_c = userAgent.match(/Windows\s(.*?)\;/)) === null || _c === void 0 ? void 0 : _c[1]}`;
|
|
289
|
+
if (/mac/i.test(userAgent))
|
|
290
|
+
return 'Mac OS';
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
function getDevice$1() {
|
|
294
|
+
const userAgent = self.navigator.userAgent;
|
|
295
|
+
if (!userAgent)
|
|
296
|
+
return null;
|
|
297
|
+
if (/iphone/i.test(userAgent))
|
|
298
|
+
return 'iPhone';
|
|
299
|
+
if (/android/i.test(userAgent)) {
|
|
300
|
+
// var index1 = userAgent.indexOf(';');
|
|
301
|
+
// var index2 = userAgent.indexOf(';', index1 + 1);
|
|
302
|
+
// var index3 = userAgent.indexOf(';', index2 + 1);
|
|
303
|
+
// var index4 = userAgent.indexOf(';', index3 + 1);
|
|
304
|
+
// if (index2 !== -1 && index3 !== -1) {
|
|
305
|
+
// var value1 = userAgent.substring(index3 + 1, index4);
|
|
306
|
+
// return `${value1}`;
|
|
307
|
+
// }
|
|
308
|
+
const index1 = userAgent.indexOf('(');
|
|
309
|
+
const index2 = userAgent.indexOf(')');
|
|
310
|
+
if (index1 !== -1 && index2 !== -1) {
|
|
311
|
+
const value = userAgent.substring(index1 + 1, index2);
|
|
312
|
+
return `${value}`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (/windows/i.test(userAgent))
|
|
316
|
+
return 'Windows';
|
|
317
|
+
if (/mac/i.test(userAgent))
|
|
318
|
+
return 'Mac';
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
249
321
|
function getCookie(val) {
|
|
250
322
|
// const expirationDate = new Date();
|
|
251
323
|
// expirationDate.setDate(expirationDate.getDate() + 100);
|
|
@@ -307,6 +379,33 @@ function deleteCookie(name, path = '/', domain = '') {
|
|
|
307
379
|
document.cookie = `${name}=; ${expiration}${pathPart}${domainPart}`;
|
|
308
380
|
console.log(`已尝试删除Cookie: ${name}`);
|
|
309
381
|
}
|
|
382
|
+
function setCookie(name, value, days = 0, path = '/', domain = '', secure = false, sameSite = 'Lax') {
|
|
383
|
+
let cookieString = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
384
|
+
// 设置过期时间
|
|
385
|
+
if (days) {
|
|
386
|
+
const date = new Date();
|
|
387
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
388
|
+
cookieString += `; expires=${date.toUTCString()}`;
|
|
389
|
+
}
|
|
390
|
+
// 设置路径
|
|
391
|
+
if (path) {
|
|
392
|
+
cookieString += `; path=${path}`;
|
|
393
|
+
}
|
|
394
|
+
// 设置域名
|
|
395
|
+
if (domain) {
|
|
396
|
+
cookieString += `; domain=${domain}`;
|
|
397
|
+
}
|
|
398
|
+
// 设置Secure标志
|
|
399
|
+
if (secure) {
|
|
400
|
+
cookieString += '; secure';
|
|
401
|
+
}
|
|
402
|
+
// 设置SameSite属性
|
|
403
|
+
if (sameSite) {
|
|
404
|
+
cookieString += `; samesite=${sameSite}`;
|
|
405
|
+
}
|
|
406
|
+
// 设置Cookie
|
|
407
|
+
document.cookie = cookieString;
|
|
408
|
+
}
|
|
310
409
|
function getUrlParamByKey(key) {
|
|
311
410
|
var _a, _b;
|
|
312
411
|
const queryString = location.search.slice(1);
|
|
@@ -322,6 +421,24 @@ function getUrlParamByKey(key) {
|
|
|
322
421
|
return (_b = params[key]) !== null && _b !== void 0 ? _b : '';
|
|
323
422
|
}
|
|
324
423
|
|
|
424
|
+
var tool = /*#__PURE__*/Object.freeze({
|
|
425
|
+
__proto__: null,
|
|
426
|
+
deleteCookie: deleteCookie,
|
|
427
|
+
generateRandomString: generateRandomString,
|
|
428
|
+
getBrowserInfo: getBrowserInfo,
|
|
429
|
+
getCookie: getCookie,
|
|
430
|
+
getDevice: getDevice$1,
|
|
431
|
+
getIndexByblockType: getIndexByblockType,
|
|
432
|
+
getScreenReader: getScreenReader,
|
|
433
|
+
getSystem: getSystem,
|
|
434
|
+
getUid: getUid,
|
|
435
|
+
getUrlParamByKey: getUrlParamByKey,
|
|
436
|
+
setCookie: setCookie,
|
|
437
|
+
setFontForText: setFontForText,
|
|
438
|
+
splitUrlParams: splitUrlParams,
|
|
439
|
+
uuid: uuid
|
|
440
|
+
});
|
|
441
|
+
|
|
325
442
|
function unzip(b64Data) {
|
|
326
443
|
const strData = atob(b64Data);
|
|
327
444
|
const charData = strData.split('').map(function (x) {
|
|
@@ -506,6 +623,18 @@ const refreshFeSessionId = () => {
|
|
|
506
623
|
const getFeSessionId = () => {
|
|
507
624
|
return window.localStorage.getItem(feRealSessionIdKey);
|
|
508
625
|
};
|
|
626
|
+
// 删除sessionID
|
|
627
|
+
const removeFeSessionId = () => {
|
|
628
|
+
window.localStorage.removeItem(feRealSessionIdKey);
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
var sessionStore = /*#__PURE__*/Object.freeze({
|
|
632
|
+
__proto__: null,
|
|
633
|
+
getFeSessionId: getFeSessionId,
|
|
634
|
+
refreshFeSessionId: refreshFeSessionId,
|
|
635
|
+
removeFeSessionId: removeFeSessionId,
|
|
636
|
+
storeAndLoadFeSessionId: storeAndLoadFeSessionId
|
|
637
|
+
});
|
|
509
638
|
|
|
510
639
|
/*
|
|
511
640
|
* @Author: binruan@chatlabs.com
|
|
@@ -529,6 +658,9 @@ const storeAndLoadFeUserId = () => {
|
|
|
529
658
|
}
|
|
530
659
|
return fakeUserId;
|
|
531
660
|
};
|
|
661
|
+
const removeFeUserId = () => {
|
|
662
|
+
window.localStorage.removeItem(FAKE_USER_KEY);
|
|
663
|
+
};
|
|
532
664
|
const getFeUserState = () => {
|
|
533
665
|
const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
|
|
534
666
|
if (lodash.isEmpty(fakeUserState)) {
|
|
@@ -558,6 +690,24 @@ const setUserConsentResult = () => {
|
|
|
558
690
|
window.localStorage.setItem(USER_CONSENT_RESULT_KEY, 'true');
|
|
559
691
|
};
|
|
560
692
|
|
|
693
|
+
var localStore = /*#__PURE__*/Object.freeze({
|
|
694
|
+
__proto__: null,
|
|
695
|
+
AGREE_POLICY: AGREE_POLICY,
|
|
696
|
+
CCONTSENT_STATE: CCONTSENT_STATE,
|
|
697
|
+
FAKE_USER_KEY: FAKE_USER_KEY,
|
|
698
|
+
FAKE_USER_STATE: FAKE_USER_STATE,
|
|
699
|
+
SLIDE_SKIP_STATE: SLIDE_SKIP_STATE,
|
|
700
|
+
USER_CONSENT_RESULT_KEY: USER_CONSENT_RESULT_KEY,
|
|
701
|
+
getContsentState: getContsentState,
|
|
702
|
+
getFeUserState: getFeUserState,
|
|
703
|
+
getSlideSkipState: getSlideSkipState,
|
|
704
|
+
getUserConsentResult: getUserConsentResult,
|
|
705
|
+
removeFeUserId: removeFeUserId,
|
|
706
|
+
setSlideSkipState: setSlideSkipState,
|
|
707
|
+
setUserConsentResult: setUserConsentResult,
|
|
708
|
+
storeAndLoadFeUserId: storeAndLoadFeUserId
|
|
709
|
+
});
|
|
710
|
+
|
|
561
711
|
/*
|
|
562
712
|
* @Author: binruan@chatlabs.com
|
|
563
713
|
* @Date: 2024-03-20 10:27:31
|
|
@@ -1766,6 +1916,23 @@ var DATA_TYPE;
|
|
|
1766
1916
|
DATA_TYPE["ARRAY_NUMBER"] = "array-number";
|
|
1767
1917
|
})(DATA_TYPE || (DATA_TYPE = {}));
|
|
1768
1918
|
|
|
1919
|
+
/*
|
|
1920
|
+
* @Author: binruan@chatlabs.com
|
|
1921
|
+
* @Date: 2024-03-20 10:27:31
|
|
1922
|
+
* @LastEditors: binruan@chatlabs.com
|
|
1923
|
+
* @LastEditTime: 2024-03-20 13:56:49
|
|
1924
|
+
* @FilePath: \pb-sxp-ui\src\core\hooks\index.ts
|
|
1925
|
+
*
|
|
1926
|
+
*/
|
|
1927
|
+
|
|
1928
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
1929
|
+
__proto__: null,
|
|
1930
|
+
get DATA_TYPE () { return DATA_TYPE; },
|
|
1931
|
+
useDataSource: useDataSource,
|
|
1932
|
+
useEditor: useEditor,
|
|
1933
|
+
useSxpDataSource: useSxpDataSource
|
|
1934
|
+
});
|
|
1935
|
+
|
|
1769
1936
|
const DataSourceContext = React.createContext({ $store: {}, options: [], configs: [] });
|
|
1770
1937
|
const DataSourceProvider = ({ children, isSsr, enable }) => {
|
|
1771
1938
|
const [options, setOptions] = React.useState([]);
|
|
@@ -19796,7 +19963,13 @@ const StructurePage = (_a) => {
|
|
|
19796
19963
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
19797
19964
|
__proto__: null,
|
|
19798
19965
|
EditorCore: EditorCore,
|
|
19799
|
-
|
|
19966
|
+
Pagebuilder: Pagebuilder,
|
|
19967
|
+
StructurePage: StructurePage,
|
|
19968
|
+
createMaterial: createMaterial,
|
|
19969
|
+
hooks: index$4,
|
|
19970
|
+
localStore: localStore,
|
|
19971
|
+
sessionStore: sessionStore,
|
|
19972
|
+
tool: tool
|
|
19800
19973
|
});
|
|
19801
19974
|
|
|
19802
19975
|
/*
|