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.js CHANGED
@@ -165,6 +165,14 @@ function uuid(len, radix) {
165
165
  }
166
166
  return uuid.join('');
167
167
  }
168
+ const getIndexByblockType = (type, index) => {
169
+ if (type === 'CommodityCarouselBlock' || type === 'CopyBlock') {
170
+ return 'initial';
171
+ }
172
+ else {
173
+ return index;
174
+ }
175
+ };
168
176
  const generateRandomString = (length) => {
169
177
  let result = '';
170
178
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -224,6 +232,70 @@ const setFontForText = (textContent, style) => {
224
232
  }
225
233
  return content;
226
234
  };
235
+ function getBrowserInfo() {
236
+ var _a, _b, _c, _d, _e, _f, _g;
237
+ const userAgent = self.navigator.userAgent;
238
+ if (!userAgent)
239
+ return null;
240
+ if (/edge\/([\d\.]+)/i.exec(userAgent))
241
+ return `Edge ${(_a = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _a === void 0 ? void 0 : _a[1]}`;
242
+ if (/edg\/([\d\.]+)/i.exec(userAgent))
243
+ return `Edge(Chromium) ${(_b = /edge\/([\d\.]+)/i.exec(userAgent)) === null || _b === void 0 ? void 0 : _b[1]}`;
244
+ if (/msie/i.test(userAgent))
245
+ return `Internet Explorer ${(_c = /msie ([\d\.]+)/i.exec(userAgent)) === null || _c === void 0 ? void 0 : _c[1]}`;
246
+ if (/Trident/i.test(userAgent))
247
+ return `Internet Explorer ${(_d = /rv:([\d\.]+)/i.exec(userAgent)) === null || _d === void 0 ? void 0 : _d[1]}`;
248
+ if (/chrome/i.test(userAgent))
249
+ return `Chrome ${(_e = /chrome\/([\d\.]+)/i.exec(userAgent)) === null || _e === void 0 ? void 0 : _e[1]}`;
250
+ if (/firefox/i.test(userAgent))
251
+ return `Firefox ${(_f = /firefox\/([\d\.]+)/i.exec(userAgent)) === null || _f === void 0 ? void 0 : _f[1]}`;
252
+ if (/safari/i.test(userAgent))
253
+ return `Safari ${(_g = /version\/([\d\.]+)/i.exec(userAgent)) === null || _g === void 0 ? void 0 : _g[1]}`;
254
+ return null;
255
+ }
256
+ function getSystem() {
257
+ var _a, _b, _c;
258
+ const userAgent = self.navigator.userAgent;
259
+ if (!userAgent)
260
+ return null;
261
+ if (/iphone/i.test(userAgent))
262
+ return `IOS ${(_a = userAgent.match(/OS\s(.*?)\slike/)) === null || _a === void 0 ? void 0 : _a[1]}`;
263
+ if (/android/i.test(userAgent))
264
+ return `Android ${(_b = userAgent.match(/Android\s(.*?)\;/)) === null || _b === void 0 ? void 0 : _b[1]}`;
265
+ if (/windows/i.test(userAgent))
266
+ return `Windows ${(_c = userAgent.match(/Windows\s(.*?)\;/)) === null || _c === void 0 ? void 0 : _c[1]}`;
267
+ if (/mac/i.test(userAgent))
268
+ return 'Mac OS';
269
+ return null;
270
+ }
271
+ function getDevice$1() {
272
+ const userAgent = self.navigator.userAgent;
273
+ if (!userAgent)
274
+ return null;
275
+ if (/iphone/i.test(userAgent))
276
+ return 'iPhone';
277
+ if (/android/i.test(userAgent)) {
278
+ // var index1 = userAgent.indexOf(';');
279
+ // var index2 = userAgent.indexOf(';', index1 + 1);
280
+ // var index3 = userAgent.indexOf(';', index2 + 1);
281
+ // var index4 = userAgent.indexOf(';', index3 + 1);
282
+ // if (index2 !== -1 && index3 !== -1) {
283
+ // var value1 = userAgent.substring(index3 + 1, index4);
284
+ // return `${value1}`;
285
+ // }
286
+ const index1 = userAgent.indexOf('(');
287
+ const index2 = userAgent.indexOf(')');
288
+ if (index1 !== -1 && index2 !== -1) {
289
+ const value = userAgent.substring(index1 + 1, index2);
290
+ return `${value}`;
291
+ }
292
+ }
293
+ if (/windows/i.test(userAgent))
294
+ return 'Windows';
295
+ if (/mac/i.test(userAgent))
296
+ return 'Mac';
297
+ return null;
298
+ }
227
299
  function getCookie(val) {
228
300
  // const expirationDate = new Date();
229
301
  // expirationDate.setDate(expirationDate.getDate() + 100);
@@ -285,6 +357,33 @@ function deleteCookie(name, path = '/', domain = '') {
285
357
  document.cookie = `${name}=; ${expiration}${pathPart}${domainPart}`;
286
358
  console.log(`已尝试删除Cookie: ${name}`);
287
359
  }
360
+ function setCookie(name, value, days = 0, path = '/', domain = '', secure = false, sameSite = 'Lax') {
361
+ let cookieString = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
362
+ // 设置过期时间
363
+ if (days) {
364
+ const date = new Date();
365
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
366
+ cookieString += `; expires=${date.toUTCString()}`;
367
+ }
368
+ // 设置路径
369
+ if (path) {
370
+ cookieString += `; path=${path}`;
371
+ }
372
+ // 设置域名
373
+ if (domain) {
374
+ cookieString += `; domain=${domain}`;
375
+ }
376
+ // 设置Secure标志
377
+ if (secure) {
378
+ cookieString += '; secure';
379
+ }
380
+ // 设置SameSite属性
381
+ if (sameSite) {
382
+ cookieString += `; samesite=${sameSite}`;
383
+ }
384
+ // 设置Cookie
385
+ document.cookie = cookieString;
386
+ }
288
387
  function getUrlParamByKey(key) {
289
388
  var _a, _b;
290
389
  const queryString = location.search.slice(1);
@@ -300,6 +399,24 @@ function getUrlParamByKey(key) {
300
399
  return (_b = params[key]) !== null && _b !== void 0 ? _b : '';
301
400
  }
302
401
 
402
+ var tool = /*#__PURE__*/Object.freeze({
403
+ __proto__: null,
404
+ deleteCookie: deleteCookie,
405
+ generateRandomString: generateRandomString,
406
+ getBrowserInfo: getBrowserInfo,
407
+ getCookie: getCookie,
408
+ getDevice: getDevice$1,
409
+ getIndexByblockType: getIndexByblockType,
410
+ getScreenReader: getScreenReader,
411
+ getSystem: getSystem,
412
+ getUid: getUid,
413
+ getUrlParamByKey: getUrlParamByKey,
414
+ setCookie: setCookie,
415
+ setFontForText: setFontForText,
416
+ splitUrlParams: splitUrlParams,
417
+ uuid: uuid
418
+ });
419
+
303
420
  function unzip(b64Data) {
304
421
  const strData = atob(b64Data);
305
422
  const charData = strData.split('').map(function (x) {
@@ -484,6 +601,18 @@ const refreshFeSessionId = () => {
484
601
  const getFeSessionId = () => {
485
602
  return window.localStorage.getItem(feRealSessionIdKey);
486
603
  };
604
+ // 删除sessionID
605
+ const removeFeSessionId = () => {
606
+ window.localStorage.removeItem(feRealSessionIdKey);
607
+ };
608
+
609
+ var sessionStore = /*#__PURE__*/Object.freeze({
610
+ __proto__: null,
611
+ getFeSessionId: getFeSessionId,
612
+ refreshFeSessionId: refreshFeSessionId,
613
+ removeFeSessionId: removeFeSessionId,
614
+ storeAndLoadFeSessionId: storeAndLoadFeSessionId
615
+ });
487
616
 
488
617
  /*
489
618
  * @Author: binruan@chatlabs.com
@@ -507,6 +636,9 @@ const storeAndLoadFeUserId = () => {
507
636
  }
508
637
  return fakeUserId;
509
638
  };
639
+ const removeFeUserId = () => {
640
+ window.localStorage.removeItem(FAKE_USER_KEY);
641
+ };
510
642
  const getFeUserState = () => {
511
643
  const fakeUserState = window.localStorage.getItem(FAKE_USER_STATE);
512
644
  if (isEmpty(fakeUserState)) {
@@ -536,6 +668,24 @@ const setUserConsentResult = () => {
536
668
  window.localStorage.setItem(USER_CONSENT_RESULT_KEY, 'true');
537
669
  };
538
670
 
671
+ var localStore = /*#__PURE__*/Object.freeze({
672
+ __proto__: null,
673
+ AGREE_POLICY: AGREE_POLICY,
674
+ CCONTSENT_STATE: CCONTSENT_STATE,
675
+ FAKE_USER_KEY: FAKE_USER_KEY,
676
+ FAKE_USER_STATE: FAKE_USER_STATE,
677
+ SLIDE_SKIP_STATE: SLIDE_SKIP_STATE,
678
+ USER_CONSENT_RESULT_KEY: USER_CONSENT_RESULT_KEY,
679
+ getContsentState: getContsentState,
680
+ getFeUserState: getFeUserState,
681
+ getSlideSkipState: getSlideSkipState,
682
+ getUserConsentResult: getUserConsentResult,
683
+ removeFeUserId: removeFeUserId,
684
+ setSlideSkipState: setSlideSkipState,
685
+ setUserConsentResult: setUserConsentResult,
686
+ storeAndLoadFeUserId: storeAndLoadFeUserId
687
+ });
688
+
539
689
  /*
540
690
  * @Author: binruan@chatlabs.com
541
691
  * @Date: 2024-03-20 10:27:31
@@ -1744,6 +1894,23 @@ var DATA_TYPE;
1744
1894
  DATA_TYPE["ARRAY_NUMBER"] = "array-number";
1745
1895
  })(DATA_TYPE || (DATA_TYPE = {}));
1746
1896
 
1897
+ /*
1898
+ * @Author: binruan@chatlabs.com
1899
+ * @Date: 2024-03-20 10:27:31
1900
+ * @LastEditors: binruan@chatlabs.com
1901
+ * @LastEditTime: 2024-03-20 13:56:49
1902
+ * @FilePath: \pb-sxp-ui\src\core\hooks\index.ts
1903
+ *
1904
+ */
1905
+
1906
+ var index$4 = /*#__PURE__*/Object.freeze({
1907
+ __proto__: null,
1908
+ get DATA_TYPE () { return DATA_TYPE; },
1909
+ useDataSource: useDataSource,
1910
+ useEditor: useEditor,
1911
+ useSxpDataSource: useSxpDataSource
1912
+ });
1913
+
1747
1914
  const DataSourceContext = createContext({ $store: {}, options: [], configs: [] });
1748
1915
  const DataSourceProvider = ({ children, isSsr, enable }) => {
1749
1916
  const [options, setOptions] = useState([]);
@@ -19774,7 +19941,13 @@ const StructurePage = (_a) => {
19774
19941
  var index$3 = /*#__PURE__*/Object.freeze({
19775
19942
  __proto__: null,
19776
19943
  EditorCore: EditorCore,
19777
- StructurePage: StructurePage
19944
+ Pagebuilder: Pagebuilder,
19945
+ StructurePage: StructurePage,
19946
+ createMaterial: createMaterial,
19947
+ hooks: index$4,
19948
+ localStore: localStore,
19949
+ sessionStore: sessionStore,
19950
+ tool: tool
19778
19951
  });
19779
19952
 
19780
19953
  /*