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/pb-ui.js CHANGED
@@ -180,6 +180,14 @@
180
180
  }
181
181
  return uuid.join('');
182
182
  }
183
+ const getIndexByblockType = (type, index) => {
184
+ if (type === 'CommodityCarouselBlock' || type === 'CopyBlock') {
185
+ return 'initial';
186
+ }
187
+ else {
188
+ return index;
189
+ }
190
+ };
183
191
  const generateRandomString = (length) => {
184
192
  let result = '';
185
193
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -239,6 +247,70 @@
239
247
  }
240
248
  return content;
241
249
  };
250
+ function getBrowserInfo() {
251
+ var _a, _b, _c, _d, _e, _f, _g;
252
+ const userAgent = self.navigator.userAgent;
253
+ if (!userAgent)
254
+ return null;
255
+ if (/edge\/([\d\.]+)/i.exec(userAgent))
256
+ return `Edge ${(_a = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _a === void 0 ? void 0 : _a[1]}`;
257
+ if (/edg\/([\d\.]+)/i.exec(userAgent))
258
+ return `Edge(Chromium) ${(_b = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _b === void 0 ? void 0 : _b[1]}`;
259
+ if (/msie/i.test(userAgent))
260
+ return `Internet Explorer ${(_c = /msie ([\d\.]+)/i.exec(userAgent)) === null || _c === void 0 ? void 0 : _c[1]}`;
261
+ if (/Trident/i.test(userAgent))
262
+ return `Internet Explorer ${(_d = /rv:([\d\.]+)/i.exec(userAgent)) === null || _d === void 0 ? void 0 : _d[1]}`;
263
+ if (/chrome/i.test(userAgent))
264
+ return `Chrome ${(_e = /chrome\/([\d\.]+)/i.exec(userAgent)) === null || _e === void 0 ? void 0 : _e[1]}`;
265
+ if (/firefox/i.test(userAgent))
266
+ return `Firefox ${(_f = /firefox\/([\d\.]+)/i.exec(userAgent)) === null || _f === void 0 ? void 0 : _f[1]}`;
267
+ if (/safari/i.test(userAgent))
268
+ return `Safari ${(_g = /version\/([\d\.]+)/i.exec(userAgent)) === null || _g === void 0 ? void 0 : _g[1]}`;
269
+ return null;
270
+ }
271
+ function getSystem() {
272
+ var _a, _b, _c;
273
+ const userAgent = self.navigator.userAgent;
274
+ if (!userAgent)
275
+ return null;
276
+ if (/iphone/i.test(userAgent))
277
+ return `IOS ${(_a = userAgent.match(/OS\s(.*?)\slike/)) === null || _a === void 0 ? void 0 : _a[1]}`;
278
+ if (/android/i.test(userAgent))
279
+ return `Android ${(_b = userAgent.match(/Android\s(.*?)\;/)) === null || _b === void 0 ? void 0 : _b[1]}`;
280
+ if (/windows/i.test(userAgent))
281
+ return `Windows ${(_c = userAgent.match(/Windows\s(.*?)\;/)) === null || _c === void 0 ? void 0 : _c[1]}`;
282
+ if (/mac/i.test(userAgent))
283
+ return 'Mac OS';
284
+ return null;
285
+ }
286
+ function getDevice$1() {
287
+ const userAgent = self.navigator.userAgent;
288
+ if (!userAgent)
289
+ return null;
290
+ if (/iphone/i.test(userAgent))
291
+ return 'iPhone';
292
+ if (/android/i.test(userAgent)) {
293
+ // var index1 = userAgent.indexOf(';');
294
+ // var index2 = userAgent.indexOf(';', index1 + 1);
295
+ // var index3 = userAgent.indexOf(';', index2 + 1);
296
+ // var index4 = userAgent.indexOf(';', index3 + 1);
297
+ // if (index2 !== -1 && index3 !== -1) {
298
+ // var value1 = userAgent.substring(index3 + 1, index4);
299
+ // return `${value1}`;
300
+ // }
301
+ const index1 = userAgent.indexOf('(');
302
+ const index2 = userAgent.indexOf(')');
303
+ if (index1 !== -1 && index2 !== -1) {
304
+ const value = userAgent.substring(index1 + 1, index2);
305
+ return `${value}`;
306
+ }
307
+ }
308
+ if (/windows/i.test(userAgent))
309
+ return 'Windows';
310
+ if (/mac/i.test(userAgent))
311
+ return 'Mac';
312
+ return null;
313
+ }
242
314
  function getCookie(val) {
243
315
  // const expirationDate = new Date();
244
316
  // expirationDate.setDate(expirationDate.getDate() + 100);
@@ -300,6 +372,33 @@
300
372
  document.cookie = `${name}=; ${expiration}${pathPart}${domainPart}`;
301
373
  console.log(`已尝试删除Cookie: ${name}`);
302
374
  }
375
+ function setCookie(name, value, days = 0, path = '/', domain = '', secure = false, sameSite = 'Lax') {
376
+ let cookieString = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
377
+ // 设置过期时间
378
+ if (days) {
379
+ const date = new Date();
380
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
381
+ cookieString += `; expires=${date.toUTCString()}`;
382
+ }
383
+ // 设置路径
384
+ if (path) {
385
+ cookieString += `; path=${path}`;
386
+ }
387
+ // 设置域名
388
+ if (domain) {
389
+ cookieString += `; domain=${domain}`;
390
+ }
391
+ // 设置Secure标志
392
+ if (secure) {
393
+ cookieString += '; secure';
394
+ }
395
+ // 设置SameSite属性
396
+ if (sameSite) {
397
+ cookieString += `; samesite=${sameSite}`;
398
+ }
399
+ // 设置Cookie
400
+ document.cookie = cookieString;
401
+ }
303
402
  function getUrlParamByKey(key) {
304
403
  var _a, _b;
305
404
  const queryString = location.search.slice(1);
@@ -315,6 +414,24 @@
315
414
  return (_b = params[key]) !== null && _b !== void 0 ? _b : '';
316
415
  }
317
416
 
417
+ var tool = /*#__PURE__*/Object.freeze({
418
+ __proto__: null,
419
+ deleteCookie: deleteCookie,
420
+ generateRandomString: generateRandomString,
421
+ getBrowserInfo: getBrowserInfo,
422
+ getCookie: getCookie,
423
+ getDevice: getDevice$1,
424
+ getIndexByblockType: getIndexByblockType,
425
+ getScreenReader: getScreenReader,
426
+ getSystem: getSystem,
427
+ getUid: getUid,
428
+ getUrlParamByKey: getUrlParamByKey,
429
+ setCookie: setCookie,
430
+ setFontForText: setFontForText,
431
+ splitUrlParams: splitUrlParams,
432
+ uuid: uuid
433
+ });
434
+
318
435
  function unzip(b64Data) {
319
436
  const strData = atob(b64Data);
320
437
  const charData = strData.split('').map(function (x) {
@@ -499,6 +616,18 @@
499
616
  const getFeSessionId = () => {
500
617
  return window.localStorage.getItem(feRealSessionIdKey);
501
618
  };
619
+ // 删除sessionID
620
+ const removeFeSessionId = () => {
621
+ window.localStorage.removeItem(feRealSessionIdKey);
622
+ };
623
+
624
+ var sessionStore = /*#__PURE__*/Object.freeze({
625
+ __proto__: null,
626
+ getFeSessionId: getFeSessionId,
627
+ refreshFeSessionId: refreshFeSessionId,
628
+ removeFeSessionId: removeFeSessionId,
629
+ storeAndLoadFeSessionId: storeAndLoadFeSessionId
630
+ });
502
631
 
503
632
  /*
504
633
  * @Author: binruan@chatlabs.com
@@ -522,6 +651,9 @@
522
651
  }
523
652
  return fakeUserId;
524
653
  };
654
+ const removeFeUserId = () => {
655
+ window.localStorage.removeItem(FAKE_USER_KEY);
656
+ };
525
657
  const getFeUserState = () => {
526
658
  const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
527
659
  if (lodash.isEmpty(fakeUserState)) {
@@ -551,6 +683,24 @@
551
683
  window.localStorage.setItem(USER_CONSENT_RESULT_KEY, 'true');
552
684
  };
553
685
 
686
+ var localStore = /*#__PURE__*/Object.freeze({
687
+ __proto__: null,
688
+ AGREE_POLICY: AGREE_POLICY,
689
+ CCONTSENT_STATE: CCONTSENT_STATE,
690
+ FAKE_USER_KEY: FAKE_USER_KEY,
691
+ FAKE_USER_STATE: FAKE_USER_STATE,
692
+ SLIDE_SKIP_STATE: SLIDE_SKIP_STATE,
693
+ USER_CONSENT_RESULT_KEY: USER_CONSENT_RESULT_KEY,
694
+ getContsentState: getContsentState,
695
+ getFeUserState: getFeUserState,
696
+ getSlideSkipState: getSlideSkipState,
697
+ getUserConsentResult: getUserConsentResult,
698
+ removeFeUserId: removeFeUserId,
699
+ setSlideSkipState: setSlideSkipState,
700
+ setUserConsentResult: setUserConsentResult,
701
+ storeAndLoadFeUserId: storeAndLoadFeUserId
702
+ });
703
+
554
704
  /*
555
705
  * @Author: binruan@chatlabs.com
556
706
  * @Date: 2024-03-20 10:27:31
@@ -1759,6 +1909,23 @@
1759
1909
  DATA_TYPE["ARRAY_NUMBER"] = "array-number";
1760
1910
  })(DATA_TYPE || (DATA_TYPE = {}));
1761
1911
 
1912
+ /*
1913
+ * @Author: binruan@chatlabs.com
1914
+ * @Date: 2024-03-20 10:27:31
1915
+ * @LastEditors: binruan@chatlabs.com
1916
+ * @LastEditTime: 2024-03-20 13:56:49
1917
+ * @FilePath: \pb-sxp-ui\src\core\hooks\index.ts
1918
+ *
1919
+ */
1920
+
1921
+ var index$4 = /*#__PURE__*/Object.freeze({
1922
+ __proto__: null,
1923
+ get DATA_TYPE () { return DATA_TYPE; },
1924
+ useDataSource: useDataSource,
1925
+ useEditor: useEditor,
1926
+ useSxpDataSource: useSxpDataSource
1927
+ });
1928
+
1762
1929
  const DataSourceContext = React.createContext({ $store: {}, options: [], configs: [] });
1763
1930
  const DataSourceProvider = ({ children, isSsr, enable }) => {
1764
1931
  const [options, setOptions] = React.useState([]);
@@ -19789,7 +19956,13 @@ Made in Italy` })));
19789
19956
  var index$3 = /*#__PURE__*/Object.freeze({
19790
19957
  __proto__: null,
19791
19958
  EditorCore: EditorCore,
19792
- StructurePage: StructurePage
19959
+ Pagebuilder: Pagebuilder,
19960
+ StructurePage: StructurePage,
19961
+ createMaterial: createMaterial,
19962
+ hooks: index$4,
19963
+ localStore: localStore,
19964
+ sessionStore: sessionStore,
19965
+ tool: tool
19793
19966
  });
19794
19967
 
19795
19968
  /*