@wibetter/json-utils 5.0.16 → 5.0.21

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.esm.js CHANGED
@@ -528,6 +528,58 @@ var initCheckboxSchema = {
528
528
  description: '',
529
529
  };
530
530
 
531
+ /* Cascader 级联选择
532
+ * 【字段属性说明】
533
+ * title:字段项的label值
534
+ * type:用于标识字段项的展示类型(input、date、data-time、url、textarea 等)
535
+ * options:用于设置选择项
536
+ * isRequired:是否是必填项
537
+ * description:字段说明&描述
538
+ * readOnly:字段项可设置是否可编辑
539
+ * */
540
+ var initCascaderSchema = {
541
+ type: 'cascader',
542
+ title: '级联选择',
543
+ options: [
544
+ {
545
+ value: 'zhejiang',
546
+ label: 'Zhejiang',
547
+ children: [
548
+ {
549
+ value: 'hangzhou',
550
+ label: 'Hangzhou',
551
+ children: [
552
+ {
553
+ value: 'xihu',
554
+ label: 'West Lake',
555
+ },
556
+ ],
557
+ },
558
+ ],
559
+ },
560
+ {
561
+ value: 'jiangsu',
562
+ label: 'Jiangsu',
563
+ children: [
564
+ {
565
+ value: 'nanjing',
566
+ label: 'Nanjing',
567
+ children: [
568
+ {
569
+ value: 'zhonghuamen',
570
+ label: 'Zhong Hua Men',
571
+ },
572
+ ],
573
+ },
574
+ ],
575
+ },
576
+ ],
577
+ default: 'a',
578
+ description: '',
579
+ showSearch: true,
580
+ allowClear: true,
581
+ };
582
+
531
583
  /* DateTime类型字段
532
584
  * 【字段属性说明】
533
585
  * title:字段项的label值
@@ -1361,8 +1413,8 @@ var initSohuSourceData = {
1361
1413
  title: '数据源类型',
1362
1414
  options: [
1363
1415
  {
1364
- label: 'channle',
1365
- value: 'channle',
1416
+ label: 'channel',
1417
+ value: 'channel',
1366
1418
  },
1367
1419
  {
1368
1420
  label: 'topic',
@@ -2310,6 +2362,7 @@ var TypeDataList = {
2310
2362
  'box-style': initBoxStyleData,
2311
2363
  radio: initRadioData,
2312
2364
  select: initSelectData,
2365
+ cascader: initCascaderSchema,
2313
2366
  checkboxes: initCheckboxSchema,
2314
2367
  'dynamic-data': initDynamicData,
2315
2368
  datasource: initDataSourceData,
@@ -7627,6 +7680,14 @@ function getDefaultOptionVal(jsonSchema, multiple) {
7627
7680
  * jsonData: json数据对象,会优先使用此jsonData对应的数值
7628
7681
  * */
7629
7682
 
7683
+ // 用于区分 对象 和 数组 类型
7684
+ function isEqualByType(value1, value2) {
7685
+ return (
7686
+ isObject$1(value1) + '-' + isArray(value1) ===
7687
+ isObject$1(value2) + '-' + isArray(value2)
7688
+ );
7689
+ }
7690
+
7630
7691
  /**
7631
7692
  * 基础类型的schema转jsonData
7632
7693
  * 根据jsonSchema和旧版的jsonData生成一份对应的jsonData
@@ -7638,7 +7699,8 @@ function baseSchema2JsonData(jsonSchema, jsonData) {
7638
7699
  if (
7639
7700
  hasProperties(oldValue) &&
7640
7701
  hasProperties(jsonSchema.default) &&
7641
- typeof oldValue !== typeof jsonSchema.default
7702
+ (typeof oldValue !== typeof jsonSchema.default ||
7703
+ !isEqualByType(oldValue, jsonSchema.default))
7642
7704
  ) {
7643
7705
  // 表示当前数据类型发生变化,则丢弃旧版数据
7644
7706
  oldValue = undefined;
@@ -489,6 +489,38 @@ var y,
489
489
  default: 'a',
490
490
  description: '',
491
491
  },
492
+ cascader: {
493
+ type: 'cascader',
494
+ title: '级联选择',
495
+ options: [
496
+ {
497
+ value: 'zhejiang',
498
+ label: 'Zhejiang',
499
+ children: [
500
+ {
501
+ value: 'hangzhou',
502
+ label: 'Hangzhou',
503
+ children: [{ value: 'xihu', label: 'West Lake' }],
504
+ },
505
+ ],
506
+ },
507
+ {
508
+ value: 'jiangsu',
509
+ label: 'Jiangsu',
510
+ children: [
511
+ {
512
+ value: 'nanjing',
513
+ label: 'Nanjing',
514
+ children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }],
515
+ },
516
+ ],
517
+ },
518
+ ],
519
+ default: 'a',
520
+ description: '',
521
+ showSearch: !0,
522
+ allowClear: !0,
523
+ },
492
524
  checkboxes: {
493
525
  type: 'checkboxes',
494
526
  title: '多选',
@@ -682,7 +714,7 @@ var y,
682
714
  type: 'select',
683
715
  title: '数据源类型',
684
716
  options: [
685
- { label: 'channle', value: 'channle' },
717
+ { label: 'channel', value: 'channel' },
686
718
  { label: 'topic', value: 'topic' },
687
719
  { label: 'block', value: 'block' },
688
720
  ],
@@ -1220,10 +1252,10 @@ var y,
1220
1252
  function _(e) {
1221
1253
  return /^http[s]?:\/\/.*/.test(e);
1222
1254
  }
1223
- function x(e) {
1255
+ function j(e) {
1224
1256
  return 'String' === Object.prototype.toString.call(e).slice(8, -1);
1225
1257
  }
1226
- function j(e) {
1258
+ function x(e) {
1227
1259
  return (
1228
1260
  'number' == typeof e ||
1229
1261
  '[object Number]' === Object.prototype.toString.call(e)
@@ -1253,7 +1285,7 @@ function V(e) {
1253
1285
  function T(e) {
1254
1286
  if (!V(e)) return !1;
1255
1287
  for (var t = 0, r = e.length; t < r; t++) {
1256
- if (!x(e[t])) return !1;
1288
+ if (!j(e[t])) return !1;
1257
1289
  }
1258
1290
  return !0;
1259
1291
  }
@@ -1322,7 +1354,7 @@ function M(e) {
1322
1354
  : (function (e) {
1323
1355
  var t = '';
1324
1356
  if (S(e)) t = a(E.boolean);
1325
- else if (j(e)) t = a(E.number);
1357
+ else if (x(e)) t = a(E.number);
1326
1358
  else if (_(e)) t = a(E.url);
1327
1359
  else if (D(e)) t = a(E.date);
1328
1360
  else if (C(e)) t = a(E['date-time']);
@@ -1330,7 +1362,7 @@ function M(e) {
1330
1362
  else if (P(e)) t = a(E.color);
1331
1363
  else
1332
1364
  try {
1333
- t = j(JSON.parse(e)) ? a(E.input) : a(E.json);
1365
+ t = x(JSON.parse(e)) ? a(E.input) : a(E.json);
1334
1366
  } catch (r) {
1335
1367
  t = e && e.length > 30 ? a(E.textarea) : a(E.input);
1336
1368
  }
@@ -1804,7 +1836,7 @@ function we(e, t, r) {
1804
1836
  function _e(e) {
1805
1837
  return e;
1806
1838
  }
1807
- function xe(e) {
1839
+ function je(e) {
1808
1840
  J(e);
1809
1841
  var t = Ee(!0, function (t, r, n, o, i) {
1810
1842
  'production' !== process.env.NODE_ENV &&
@@ -1831,13 +1863,13 @@ function xe(e) {
1831
1863
  : t;
1832
1864
  return (r.enhancer = e), r;
1833
1865
  }
1834
- var je = { deep: !0, name: void 0, defaultDecorator: void 0, proxy: !0 };
1866
+ var xe = { deep: !0, name: void 0, defaultDecorator: void 0, proxy: !0 };
1835
1867
  function Se(e) {
1836
1868
  /^(deep|name|equals|defaultDecorator|proxy)$/.test(e) ||
1837
1869
  z('invalid option for (extend)observable: ' + e);
1838
1870
  }
1839
1871
  function De(e) {
1840
- if (null == e) return je;
1872
+ if (null == e) return xe;
1841
1873
  if ('string' == typeof e) return { name: e, deep: !0, proxy: !0 };
1842
1874
  if ('production' !== process.env.NODE_ENV) {
1843
1875
  if ('object' != typeof e) return z('expected options object');
@@ -1845,9 +1877,9 @@ function De(e) {
1845
1877
  }
1846
1878
  return e;
1847
1879
  }
1848
- Object.freeze(je);
1849
- var Ce = xe(we),
1850
- Ae = xe(function (e, t, r) {
1880
+ Object.freeze(xe);
1881
+ var Ce = je(we),
1882
+ Ae = je(function (e, t, r) {
1851
1883
  return null == e || br(e) || nr(e) || sr(e) || cr(e)
1852
1884
  ? e
1853
1885
  : Array.isArray(e)
@@ -1863,8 +1895,8 @@ var Ce = xe(we),
1863
1895
  'The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets',
1864
1896
  );
1865
1897
  }),
1866
- Ve = xe(_e),
1867
- Te = xe(function (e, t, r) {
1898
+ Ve = je(_e),
1899
+ Te = je(function (e, t, r) {
1868
1900
  if ('production' !== process.env.NODE_ENV && qt(e))
1869
1901
  throw 'observable.struct should not be used with observable values';
1870
1902
  return wr(e, t) ? t : e;
@@ -2827,9 +2859,9 @@ var Et = (function () {
2827
2859
  return e();
2828
2860
  };
2829
2861
  function _t() {
2830
- dt.inBatch > 0 || dt.isRunningReactions || wt(xt);
2862
+ dt.inBatch > 0 || dt.isRunningReactions || wt(jt);
2831
2863
  }
2832
- function xt() {
2864
+ function jt() {
2833
2865
  dt.isRunningReactions = !0;
2834
2866
  for (var e = dt.pendingReactions, t = 0; e.length > 0; ) {
2835
2867
  ++t === Nt &&
@@ -2845,7 +2877,7 @@ function xt() {
2845
2877
  }
2846
2878
  dt.isRunningReactions = !1;
2847
2879
  }
2848
- var jt = Q('Reaction', Et);
2880
+ var xt = Q('Reaction', Et);
2849
2881
  function St() {
2850
2882
  return 'production' !== process.env.NODE_ENV && !!dt.spyListeners.length;
2851
2883
  }
@@ -3020,7 +3052,7 @@ function qt(e) {
3020
3052
  'isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.',
3021
3053
  )
3022
3054
  : !!br(e) && e[ae].values.has(t)
3023
- : br(e) || !!e[ae] || le(e) || jt(e) || st(e))
3055
+ : br(e) || !!e[ae] || le(e) || xt(e) || st(e))
3024
3056
  );
3025
3057
  })(e)
3026
3058
  );
@@ -4453,8 +4485,8 @@ function mr(e, t) {
4453
4485
  'production' !== process.env.NODE_ENV &&
4454
4486
  'please specify a property',
4455
4487
  );
4456
- if (le(e) || st(e) || jt(e)) return e;
4457
- } else if ('function' == typeof e && jt(e[ae])) return e[ae];
4488
+ if (le(e) || st(e) || xt(e)) return e;
4489
+ } else if ('function' == typeof e && xt(e[ae])) return e[ae];
4458
4490
  return z(
4459
4491
  'production' !== process.env.NODE_ENV && 'Cannot obtain atom from ' + e,
4460
4492
  );
@@ -4464,7 +4496,7 @@ function gr(e, t) {
4464
4496
  e || z('Expecting some object'),
4465
4497
  void 0 !== t
4466
4498
  ? gr(mr(e, t))
4467
- : le(e) || st(e) || jt(e) || sr(e) || cr(e)
4499
+ : le(e) || st(e) || xt(e) || sr(e) || cr(e)
4468
4500
  ? e
4469
4501
  : (Oe(e),
4470
4502
  e[ae]
@@ -4510,7 +4542,7 @@ function _r(e, t, r, n, o) {
4510
4542
  case '[object Set]':
4511
4543
  r >= 0 && r++;
4512
4544
  }
4513
- (e = xr(e)), (t = xr(t));
4545
+ (e = jr(e)), (t = jr(t));
4514
4546
  var s = '[object Array]' === a;
4515
4547
  if (!s) {
4516
4548
  if ('object' != typeof e || 'object' != typeof t) return !1;
@@ -4540,18 +4572,18 @@ function _r(e, t, r, n, o) {
4540
4572
  d = void 0;
4541
4573
  if (((c = p.length), Object.keys(t).length !== c)) return !1;
4542
4574
  for (; c--; )
4543
- if (!jr(t, (d = p[c])) || !_r(e[d], t[d], r - 1, n, o)) return !1;
4575
+ if (!xr(t, (d = p[c])) || !_r(e[d], t[d], r - 1, n, o)) return !1;
4544
4576
  }
4545
4577
  return n.pop(), o.pop(), !0;
4546
4578
  }
4547
- function xr(e) {
4579
+ function jr(e) {
4548
4580
  return nr(e)
4549
4581
  ? e.slice()
4550
4582
  : ee(e) || sr(e) || te(e) || cr(e)
4551
4583
  ? Array.from(e.entries())
4552
4584
  : e;
4553
4585
  }
4554
- function jr(e, t) {
4586
+ function xr(e, t) {
4555
4587
  return Object.prototype.hasOwnProperty.call(e, t);
4556
4588
  }
4557
4589
  function Sr(e) {
@@ -4739,49 +4771,55 @@ function Kr(e, t) {
4739
4771
  );
4740
4772
  }
4741
4773
  function zr(e, t) {
4742
- var r = '',
4743
- n = t;
4744
- l(n) && l(e.default) && typeof n != typeof e.default && (n = void 0);
4745
- var o = l(n) ? n : e.default;
4774
+ var r,
4775
+ n,
4776
+ o = '',
4777
+ i = t;
4778
+ l(i) &&
4779
+ l(e.default) &&
4780
+ (typeof i != typeof e.default ||
4781
+ ((r = i), (n = e.default), k(r) + '-' + V(r) != k(n) + '-' + V(n))) &&
4782
+ (i = void 0);
4783
+ var a = l(i) ? i : e.default;
4746
4784
  switch (e.type) {
4747
4785
  case 'select':
4748
4786
  case 'radio':
4749
- r = o || Kr(e);
4787
+ o = a || Kr(e);
4750
4788
  break;
4751
4789
  case 'checkboxes':
4752
- r = o || Kr(e, !0);
4790
+ o = a || Kr(e, !0);
4753
4791
  break;
4754
4792
  case 'color':
4755
- ('#fff' !== o && '#FFF' !== o) || (o = '#ffffff'),
4756
- (r = l(o) ? o : '#ffffff');
4793
+ ('#fff' !== a && '#FFF' !== a) || (a = '#ffffff'),
4794
+ (o = l(a) ? a : '#ffffff');
4757
4795
  break;
4758
4796
  case 'boolean':
4759
- r = !!l(o) && o;
4797
+ o = !!l(a) && a;
4760
4798
  break;
4761
4799
  case 'number':
4762
- r = l(o) ? o : void 0;
4800
+ o = l(a) ? a : void 0;
4763
4801
  break;
4764
4802
  case 'json':
4765
- var i = '';
4766
- if (k(o) || V(o)) i = o;
4767
- else if (I(o) || '' === o) i = {};
4803
+ var s = '';
4804
+ if (k(a) || V(a)) s = a;
4805
+ else if (I(a) || '' === a) s = {};
4768
4806
  else
4769
4807
  try {
4770
- i = JSON.parse(o);
4808
+ s = JSON.parse(a);
4771
4809
  } catch (e) {
4772
- i = {};
4810
+ s = {};
4773
4811
  }
4774
- r = i;
4812
+ o = s;
4775
4813
  break;
4776
4814
  default:
4777
- r =
4815
+ o =
4778
4816
  'input' === e.type && '0' === e.default
4779
- ? o || e.default
4780
- : l(o)
4781
- ? o
4817
+ ? a || e.default
4818
+ : l(a)
4819
+ ? a
4782
4820
  : void 0;
4783
4821
  }
4784
- return r;
4822
+ return o;
4785
4823
  }
4786
4824
  function Jr(e, t) {
4787
4825
  var r = {},
@@ -5028,12 +5066,12 @@ export {
5028
5066
  s as isEqual,
5029
5067
  I as isFunction,
5030
5068
  Rr as isNewSchemaData,
5031
- j as isNumber,
5069
+ x as isNumber,
5032
5070
  k as isObject,
5033
5071
  R as isQuantity,
5034
5072
  Mr as isSameParent,
5035
5073
  T as isSelect,
5036
- x as isString,
5074
+ j as isString,
5037
5075
  Ir as isStructuredSchema,
5038
5076
  A as isTimeStr,
5039
5077
  _ as isURL,
package/dist/index.js CHANGED
@@ -66,10 +66,10 @@
66
66
  return Q;
67
67
  },
68
68
  getDefaultOptionVal: function () {
69
- return ie;
69
+ return le;
70
70
  },
71
71
  getExpectType: function () {
72
- return U;
72
+ return z;
73
73
  },
74
74
  getJsonDataByKeyRoute: function () {
75
75
  return d;
@@ -102,7 +102,7 @@
102
102
  return b;
103
103
  },
104
104
  isArray: function () {
105
- return k;
105
+ return q;
106
106
  },
107
107
  isBoolean: function () {
108
108
  return w;
@@ -111,7 +111,7 @@
111
111
  return M;
112
112
  },
113
113
  isContainerSchema: function () {
114
- return Z;
114
+ return Y;
115
115
  },
116
116
  isDateStr: function () {
117
117
  return R;
@@ -120,7 +120,7 @@
120
120
  return E;
121
121
  },
122
122
  isEmptySchema: function () {
123
- return Y;
123
+ return W;
124
124
  },
125
125
  isEqual: function () {
126
126
  return u;
@@ -129,7 +129,7 @@
129
129
  return _;
130
130
  },
131
131
  isNewSchemaData: function () {
132
- return W;
132
+ return X;
133
133
  },
134
134
  isNumber: function () {
135
135
  return N;
@@ -150,10 +150,10 @@
150
150
  return D;
151
151
  },
152
152
  isStructuredSchema: function () {
153
- return z;
153
+ return Z;
154
154
  },
155
155
  isTimeStr: function () {
156
- return q;
156
+ return k;
157
157
  },
158
158
  isURL: function () {
159
159
  return T;
@@ -168,7 +168,7 @@
168
168
  return v;
169
169
  },
170
170
  metaElemAnalyzer: function () {
171
- return B;
171
+ return $;
172
172
  },
173
173
  moveBackward: function () {
174
174
  return ae;
@@ -183,10 +183,10 @@
183
183
  return V;
184
184
  },
185
185
  oldSchemaToNewSchemaV1: function () {
186
- return L;
186
+ return B;
187
187
  },
188
188
  registerExpectType: function () {
189
- return X;
189
+ return U;
190
190
  },
191
191
  schema2conditionValue: function () {
192
192
  return ye;
@@ -201,7 +201,7 @@
201
201
  return c;
202
202
  },
203
203
  urlParse: function () {
204
- return l;
204
+ return i;
205
205
  },
206
206
  urlStringify: function () {
207
207
  return n;
@@ -209,16 +209,16 @@
209
209
  });
210
210
  var r = require('lodash'),
211
211
  a = require('qs'),
212
- i = e.n(a);
213
- function l() {
212
+ l = e.n(a);
213
+ function i() {
214
214
  var e = {};
215
215
  return (
216
- location.search && (e = i().parse(location.search.substring(1))), e
216
+ location.search && (e = l().parse(location.search.substring(1))), e
217
217
  );
218
218
  }
219
219
  function n(e) {
220
220
  var t = '';
221
- return url && (t = i().stringify(e)), t;
221
+ return url && (t = l().stringify(e)), t;
222
222
  }
223
223
  function o(e) {
224
224
  return (0, r.cloneDeep)(e);
@@ -237,19 +237,19 @@
237
237
  var r = t || {};
238
238
  if (!e) return !1;
239
239
  var a = new Function('data', 'with(data) { return (' + e + ');}'),
240
- i = '';
240
+ l = '';
241
241
  try {
242
- i = a(r);
242
+ l = a(r);
243
243
  } catch (t) {
244
- return console.warn('表达式运算出错: ' + e + ',报错信息:', t), i;
244
+ return console.warn('表达式运算出错: ' + e + ',报错信息:', t), l;
245
245
  }
246
- return i;
246
+ return l;
247
247
  }
248
248
  function d(e, t, r) {
249
249
  var a = t;
250
250
  if ((r && (a = o(t)), e))
251
- for (var i = e.split('-'), l = 0, n = i.length; l < n; l++) {
252
- var u = i[l];
251
+ for (var l = e.split('-'), i = 0, n = l.length; i < n; i++) {
252
+ var u = l[i];
253
253
  u && (a = a && a[u]);
254
254
  }
255
255
  return a;
@@ -257,8 +257,8 @@
257
257
  function y(e, t, r) {
258
258
  var a = t;
259
259
  if ((r && (a = o(t)), e))
260
- for (var i = e.split('-'), l = 0, n = i.length; l < n; l++) {
261
- var u = i[l];
260
+ for (var l = e.split('-'), i = 0, n = l.length; i < n; i++) {
261
+ var u = l[i];
262
262
  if (
263
263
  '0' !== u ||
264
264
  ('array' !== a.type &&
@@ -281,19 +281,19 @@
281
281
  function f(e, t, r) {
282
282
  var a = t;
283
283
  if ((r && (a = o(t)), e && a))
284
- for (var i = e.split('-'), l = 0, n = i.length; l < n; l++) {
285
- var u = i[l];
284
+ for (var l = e.split('-'), i = 0, n = l.length; i < n; i++) {
285
+ var u = l[i];
286
286
  u && a.properties && (a = a.properties[u]);
287
287
  }
288
288
  return a;
289
289
  }
290
290
  function b(e, t) {
291
291
  for (
292
- var r = t, a = '', i = e.split('-'), l = 0, n = i.length;
293
- l < n;
294
- l++
292
+ var r = t, a = '', l = e.split('-'), i = 0, n = l.length;
293
+ i < n;
294
+ i++
295
295
  ) {
296
- var o = i[l];
296
+ var o = l[i];
297
297
  if ('0' === o && r.items)
298
298
  (r = r.items), (a = a ? a + '-items' : 'items');
299
299
  else if ('0' === o && r.options)
@@ -311,11 +311,11 @@
311
311
  }
312
312
  function v(e, t) {
313
313
  for (
314
- var r = t, a = '', i = e.split('-'), l = 0, n = i.length;
315
- l < n;
316
- l++
314
+ var r = t, a = '', l = e.split('-'), i = 0, n = l.length;
315
+ i < n;
316
+ i++
317
317
  ) {
318
- var o = i[l];
318
+ var o = l[i];
319
319
  if (o) {
320
320
  var u = -1;
321
321
  r.propertyOrder
@@ -332,7 +332,7 @@
332
332
  return a;
333
333
  }
334
334
  var m,
335
- g = {
335
+ h = {
336
336
  type: 'event',
337
337
  title: '事件',
338
338
  isContainer: !1,
@@ -362,7 +362,7 @@
362
362
  },
363
363
  propertyOrder: ['type', 'trigger', 'eventData'],
364
364
  },
365
- h = {
365
+ g = {
366
366
  type: 'datasource',
367
367
  title: '数据源',
368
368
  isContainer: !1,
@@ -394,7 +394,7 @@
394
394
  },
395
395
  propertyOrder: ['type', 'data', 'filter'],
396
396
  },
397
- O =
397
+ j =
398
398
  (((m = { type: 'object' }).type = 'datasource'),
399
399
  (m.title = '数据源'),
400
400
  (m.isContainer = !1),
@@ -426,7 +426,7 @@
426
426
  }),
427
427
  (m.propertyOrder = ['type', 'data', 'filter']),
428
428
  m),
429
- j = {
429
+ O = {
430
430
  type: 'local',
431
431
  config: { dataName: '', body: {}, filter: 'return data;' },
432
432
  data: '{}',
@@ -719,6 +719,38 @@
719
719
  default: 'a',
720
720
  description: '',
721
721
  },
722
+ cascader: {
723
+ type: 'cascader',
724
+ title: '级联选择',
725
+ options: [
726
+ {
727
+ value: 'zhejiang',
728
+ label: 'Zhejiang',
729
+ children: [
730
+ {
731
+ value: 'hangzhou',
732
+ label: 'Hangzhou',
733
+ children: [{ value: 'xihu', label: 'West Lake' }],
734
+ },
735
+ ],
736
+ },
737
+ {
738
+ value: 'jiangsu',
739
+ label: 'Jiangsu',
740
+ children: [
741
+ {
742
+ value: 'nanjing',
743
+ label: 'Nanjing',
744
+ children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }],
745
+ },
746
+ ],
747
+ },
748
+ ],
749
+ default: 'a',
750
+ description: '',
751
+ showSearch: !0,
752
+ allowClear: !0,
753
+ },
722
754
  checkboxes: {
723
755
  type: 'checkboxes',
724
756
  title: '多选',
@@ -792,8 +824,8 @@
792
824
  },
793
825
  propertyOrder: ['type', 'config', 'data', 'localFilter'],
794
826
  },
795
- datasource: h,
796
- event: g,
827
+ datasource: g,
828
+ event: h,
797
829
  'dynamic-config': {
798
830
  type: 'dynamic-config',
799
831
  title: '动态配置',
@@ -917,7 +949,7 @@
917
949
  type: 'select',
918
950
  title: '数据源类型',
919
951
  options: [
920
- { label: 'channle', value: 'channle' },
952
+ { label: 'channel', value: 'channel' },
921
953
  { label: 'topic', value: 'topic' },
922
954
  { label: 'block', value: 'block' },
923
955
  ],
@@ -1458,9 +1490,9 @@
1458
1490
  },
1459
1491
  propertyOrder: ['type', 'register', 'actionFunc'],
1460
1492
  },
1461
- emit: g,
1493
+ emit: h,
1462
1494
  },
1463
- S = { local: h, remote: O };
1495
+ S = { local: g, remote: j };
1464
1496
  function T(e) {
1465
1497
  return /^http[s]?:\/\/.*/.test(e);
1466
1498
  }
@@ -1485,10 +1517,10 @@
1485
1517
  /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(e)
1486
1518
  );
1487
1519
  }
1488
- function q(e) {
1520
+ function k(e) {
1489
1521
  return /^\d{2}:\d{2}:\d{2}$/.test(e) || /^\d{2}:\d{2}$/.test(e);
1490
1522
  }
1491
- function k(e) {
1523
+ function q(e) {
1492
1524
  var t = !1;
1493
1525
  return (
1494
1526
  'Array' === Object.prototype.toString.call(e).slice(8, -1) && (t = !0),
@@ -1496,7 +1528,7 @@
1496
1528
  );
1497
1529
  }
1498
1530
  function F(e) {
1499
- if (!k(e)) return !1;
1531
+ if (!q(e)) return !1;
1500
1532
  for (var t = 0, r = e.length; t < r; t++) if (!D(e[t])) return !1;
1501
1533
  return !0;
1502
1534
  }
@@ -1532,7 +1564,7 @@
1532
1564
  if (P(e)) {
1533
1565
  var r = Object.keys(e);
1534
1566
  e.data && e.filter && 2 === r.length
1535
- ? (t = k(e.data) || P(e.data) ? o(S.local) : o(S.remote))
1567
+ ? (t = q(e.data) || P(e.data) ? o(S.local) : o(S.remote))
1536
1568
  : e.trigger && e.eventData && 2 === r.length
1537
1569
  ? (t = o(x.emit))
1538
1570
  : e.register && e.actionFunc && 2 === r.length
@@ -1547,17 +1579,17 @@
1547
1579
  }
1548
1580
  return t;
1549
1581
  })(e)
1550
- : e && k(e)
1582
+ : e && q(e)
1551
1583
  ? (function (e) {
1552
1584
  var t;
1553
- if (e && k(e))
1585
+ if (e && q(e))
1554
1586
  if (F(e)) {
1555
1587
  (t = o(C.select)).items.enum = e;
1556
1588
  var r = t.items.enumextra.length,
1557
1589
  a = e.length;
1558
1590
  if (a > r)
1559
- for (var i = r, l = a; i < l; i++)
1560
- t.items.enumextra.push('选项' + e(i));
1591
+ for (var l = r, i = a; l < i; l++)
1592
+ t.items.enumextra.push('选项' + e(l));
1561
1593
  } else {
1562
1594
  t = o(C['empty-array']);
1563
1595
  var n = A(e[0]);
@@ -1572,7 +1604,7 @@
1572
1604
  else if (T(e)) t = o(C.url);
1573
1605
  else if (R(e)) t = o(C.date);
1574
1606
  else if (E(e)) t = o(C['date-time']);
1575
- else if (q(e)) t = o(C.time);
1607
+ else if (k(e)) t = o(C.time);
1576
1608
  else if (M(e)) t = o(C.color);
1577
1609
  else
1578
1610
  try {
@@ -1585,7 +1617,7 @@
1585
1617
  t
1586
1618
  );
1587
1619
  }
1588
- function $(e, t) {
1620
+ function L(e, t) {
1589
1621
  var r = t || {};
1590
1622
  return (
1591
1623
  P(e) &&
@@ -1594,30 +1626,30 @@
1594
1626
  (e.propertyOrder ? e.propertyOrder : Object.keys(e.properties)).map(
1595
1627
  function (t) {
1596
1628
  var a = e.properties[t];
1597
- r = B(a, r);
1629
+ r = $(a, r);
1598
1630
  },
1599
1631
  ),
1600
1632
  r
1601
1633
  );
1602
1634
  }
1603
- function B(e, t) {
1635
+ function $(e, t) {
1604
1636
  var r = !t,
1605
1637
  a = t || {};
1606
1638
  if (e && '{}' !== JSON.stringify(e)) {
1607
- var i = e.type;
1608
- 'object' === i || 'func' === i || 'style' === i || 'data' === i
1639
+ var l = e.type;
1640
+ 'object' === l || 'func' === l || 'style' === l || 'data' === l
1609
1641
  ? (!r && a.object ? (a.object += 1) : r || (a.object = 1),
1610
- (a = $(e, a)))
1611
- : 'array' === i
1642
+ (a = L(e, a)))
1643
+ : 'array' === l
1612
1644
  ? (!r && a.array ? (a.array += 1) : r || (a.array = 1),
1613
- (a = $((e = e.items), a)))
1614
- : !r && a[i]
1615
- ? (a[i] += 1)
1616
- : r || (a[i] = 1);
1645
+ (a = L((e = e.items), a)))
1646
+ : !r && a[l]
1647
+ ? (a[l] += 1)
1648
+ : r || (a[l] = 1);
1617
1649
  }
1618
1650
  return a;
1619
1651
  }
1620
- function L(e) {
1652
+ function B(e) {
1621
1653
  var t = o(e);
1622
1654
  if (
1623
1655
  (!t.title && t.description && (t.title = t.description),
@@ -1645,16 +1677,16 @@
1645
1677
  var r = t.properties,
1646
1678
  a = o(C.quantity);
1647
1679
  if (r.quantity && P(r.quantity) && r.quantity.default) {
1648
- var i = r.quantity.default;
1649
- a.properties.quantity.default = 'percent' === i ? '%' : i;
1680
+ var l = r.quantity.default;
1681
+ a.properties.quantity.default = 'percent' === l ? '%' : l;
1650
1682
  }
1651
1683
  t = a;
1652
1684
  }
1653
1685
  if ('datasource' === t.type) {
1654
- var l = t.properties,
1655
- n = l.type && l.type.default,
1656
- u = l.data && l.data.default,
1657
- c = l.filter && l.filter.default;
1686
+ var i = t.properties,
1687
+ n = i.type && i.type.default,
1688
+ u = i.data && i.data.default,
1689
+ c = i.filter && i.filter.default;
1658
1690
  'local' === n
1659
1691
  ? ((t = o(S.local)).properties.data.default = u ? o(u) : '{}')
1660
1692
  : ((t = o(S.remote)).properties.data.default = u
@@ -1755,15 +1787,15 @@
1755
1787
  (J['sohu-source'] = 'object'),
1756
1788
  (J['sohu-event'] = 'object'),
1757
1789
  J);
1758
- function U(e) {
1790
+ function z(e) {
1759
1791
  return K[e] || e;
1760
1792
  }
1761
- function X(e, t) {
1793
+ function U(e, t) {
1762
1794
  K[e]
1763
1795
  ? console.warn('当前已经存在' + e + '(' + K[e] + '),暂时不支持覆盖。')
1764
1796
  : (K[e] = t);
1765
1797
  }
1766
- function Y(e) {
1798
+ function W(e) {
1767
1799
  var t = !0;
1768
1800
  if (!e) return t;
1769
1801
  var r = e.type;
@@ -1783,19 +1815,19 @@
1783
1815
  t
1784
1816
  );
1785
1817
  }
1786
- function W(e) {
1818
+ function X(e) {
1787
1819
  var t = !1,
1788
1820
  r = e.lastUpdateTime,
1789
1821
  a = new Date('2024-10-05T00:01:00.691Z').getTime();
1790
1822
  return r && new Date(r).getTime() >= a && (t = !0), t;
1791
1823
  }
1792
- function Z(e) {
1824
+ function Y(e) {
1793
1825
  var t = !1,
1794
- r = U(e.type),
1826
+ r = z(e.type),
1795
1827
  a = void 0 === e.isContainer || e.isContainer;
1796
1828
  return 'object' === r && a && (t = !0), t;
1797
1829
  }
1798
- function z(e) {
1830
+ function Z(e) {
1799
1831
  var t = !0;
1800
1832
  return (
1801
1833
  'object' === e.type && e.propertyOrder && e.properties
@@ -1817,14 +1849,14 @@
1817
1849
  for (
1818
1850
  var r = e.split('-'),
1819
1851
  a = t.split('-'),
1820
- i = 'before',
1821
- l = 0,
1852
+ l = 'before',
1853
+ i = 0,
1822
1854
  n = (r.length > a.length ? a : r).length;
1823
- l < n;
1824
- l += 1
1855
+ i < n;
1856
+ i += 1
1825
1857
  )
1826
- Number(r[l]) > Number(a[l]) && (i = 'after');
1827
- return i;
1858
+ Number(r[i]) > Number(a[i]) && (l = 'after');
1859
+ return l;
1828
1860
  }
1829
1861
  function G(e) {
1830
1862
  var t = e.split('-');
@@ -1851,7 +1883,7 @@
1851
1883
  r = t.pop();
1852
1884
  return t.push(Number(r) + 1), t.join('-');
1853
1885
  }
1854
- function ie(e, t) {
1886
+ function le(e, t) {
1855
1887
  var r = '',
1856
1888
  a = !1;
1857
1889
  return (
@@ -1860,72 +1892,78 @@
1860
1892
  r
1861
1893
  );
1862
1894
  }
1863
- function le(e, t) {
1864
- var r = '',
1865
- a = t;
1866
- p(a) && p(e.default) && typeof a != typeof e.default && (a = void 0);
1867
- var i = p(a) ? a : e.default;
1895
+ function ie(e, t) {
1896
+ var r,
1897
+ a,
1898
+ l = '',
1899
+ i = t;
1900
+ p(i) &&
1901
+ p(e.default) &&
1902
+ (typeof i != typeof e.default ||
1903
+ ((r = i), (a = e.default), P(r) + '-' + q(r) != P(a) + '-' + q(a))) &&
1904
+ (i = void 0);
1905
+ var n = p(i) ? i : e.default;
1868
1906
  switch (e.type) {
1869
1907
  case 'select':
1870
1908
  case 'radio':
1871
- r = i || ie(e);
1909
+ l = n || le(e);
1872
1910
  break;
1873
1911
  case 'checkboxes':
1874
- r = i || ie(e, !0);
1912
+ l = n || le(e, !0);
1875
1913
  break;
1876
1914
  case 'color':
1877
- ('#fff' !== i && '#FFF' !== i) || (i = '#ffffff'),
1878
- (r = p(i) ? i : '#ffffff');
1915
+ ('#fff' !== n && '#FFF' !== n) || (n = '#ffffff'),
1916
+ (l = p(n) ? n : '#ffffff');
1879
1917
  break;
1880
1918
  case 'boolean':
1881
- r = !!p(i) && i;
1919
+ l = !!p(n) && n;
1882
1920
  break;
1883
1921
  case 'number':
1884
- r = p(i) ? i : void 0;
1922
+ l = p(n) ? n : void 0;
1885
1923
  break;
1886
1924
  case 'json':
1887
- var l = '';
1888
- if (P(i) || k(i)) l = i;
1889
- else if (_(i) || '' === i) l = {};
1925
+ var o = '';
1926
+ if (P(n) || q(n)) o = n;
1927
+ else if (_(n) || '' === n) o = {};
1890
1928
  else
1891
1929
  try {
1892
- l = JSON.parse(i);
1930
+ o = JSON.parse(n);
1893
1931
  } catch (e) {
1894
- l = {};
1932
+ o = {};
1895
1933
  }
1896
- r = l;
1934
+ l = o;
1897
1935
  break;
1898
1936
  default:
1899
- r =
1937
+ l =
1900
1938
  'input' === e.type && '0' === e.default
1901
- ? i || e.default
1902
- : p(i)
1903
- ? i
1939
+ ? n || e.default
1940
+ : p(n)
1941
+ ? n
1904
1942
  : void 0;
1905
1943
  }
1906
- return r;
1944
+ return l;
1907
1945
  }
1908
1946
  function ne(e, t) {
1909
1947
  var r = {},
1910
1948
  a = e.type;
1911
- if (P(e) && 'object' === U(e.type)) {
1912
- var i = e,
1913
- l = t;
1914
- p(l) &&
1915
- ((p(i.default) && typeof l != typeof e.default) || !P(l)) &&
1916
- (l = void 0);
1917
- var n = p(l) ? l : i.default;
1949
+ if (P(e) && 'object' === z(e.type)) {
1950
+ var l = e,
1951
+ i = t;
1952
+ p(i) &&
1953
+ ((p(l.default) && typeof i != typeof e.default) || !P(i)) &&
1954
+ (i = void 0);
1955
+ var n = p(i) ? i : l.default;
1918
1956
  'dynamic-data' === a
1919
- ? ((r = o(j)),
1957
+ ? ((r = o(O)),
1920
1958
  n &&
1921
1959
  P(n) &&
1922
1960
  '{}' !== JSON.stringify(n) &&
1923
1961
  (r = Object.assign(r, n)))
1924
1962
  : 'datasource' === a
1925
- ? i.properties &&
1926
- i.properties.type &&
1927
- i.properties.type.default &&
1928
- 'local' === i.properties.type.default
1963
+ ? l.properties &&
1964
+ l.properties.type &&
1965
+ l.properties.type.default &&
1966
+ 'local' === l.properties.type.default
1929
1967
  ? ((r = { data: '{}', filter: '() => {}' }),
1930
1968
  n && n.data && (r.data = n.data),
1931
1969
  n && n.filter && (r.filter = n.filter),
@@ -1935,10 +1973,10 @@
1935
1973
  n && n.filter && (r.filter = n.filter),
1936
1974
  '{}' === r.data && (r.data = 'http://xxx'))
1937
1975
  : 'event' === a
1938
- ? i.properties &&
1939
- i.properties.type &&
1940
- i.properties.type.default &&
1941
- 'emit' === i.properties.type.default
1976
+ ? l.properties &&
1977
+ l.properties.type &&
1978
+ l.properties.type.default &&
1979
+ 'emit' === l.properties.type.default
1942
1980
  ? n && 'out' === n.type
1943
1981
  ? (r = {
1944
1982
  trigger: (n && n.filter) || 'eventName',
@@ -1957,24 +1995,24 @@
1957
1995
  n && n.actionFunc && (r.actionFunc = n.actionFunc))
1958
1996
  : !1 === e.isContainer && n && P(n) && '{}' !== JSON.stringify(n)
1959
1997
  ? (r = Object.assign(r, n))
1960
- : void 0 === l && i.default && P(i.default)
1961
- ? (r = i.default)
1998
+ : void 0 === i && l.default && P(l.default)
1999
+ ? (r = l.default)
1962
2000
  : e.properties &&
1963
2001
  (e.propertyOrder
1964
2002
  ? e.propertyOrder
1965
2003
  : Object.keys(e.properties)
1966
2004
  ).map(function (a) {
1967
- var i = e.properties[a],
1968
- l = t && t[a];
1969
- switch (U(i.type)) {
2005
+ var l = e.properties[a],
2006
+ i = t && t[a];
2007
+ switch (z(l.type)) {
1970
2008
  case 'array':
1971
- r[a] = oe(i, l);
2009
+ r[a] = oe(l, i);
1972
2010
  break;
1973
2011
  case 'object':
1974
- r[a] = ne(i, l);
2012
+ r[a] = ne(l, i);
1975
2013
  break;
1976
2014
  default:
1977
- r[a] = le(i, l);
2015
+ r[a] = ie(l, i);
1978
2016
  }
1979
2017
  });
1980
2018
  }
@@ -1982,32 +2020,32 @@
1982
2020
  }
1983
2021
  function oe(e, t) {
1984
2022
  var r = [];
1985
- if (e && 'array' === U(e.type)) {
2023
+ if (e && 'array' === z(e.type)) {
1986
2024
  var a = t;
1987
2025
  p(a) &&
1988
- ((p(e.default) && typeof a != typeof e.default) || !k(a)) &&
2026
+ ((p(e.default) && typeof a != typeof e.default) || !q(a)) &&
1989
2027
  (a = void 0);
1990
- var i = p(a) ? a : e.default;
1991
- if ('array' === U(e.type))
1992
- if (k(i))
1993
- i.map(function (t) {
2028
+ var l = p(a) ? a : e.default;
2029
+ if ('array' === z(e.type))
2030
+ if (q(l))
2031
+ l.map(function (t) {
1994
2032
  r.push(ne(e.items, t));
1995
2033
  });
1996
- else if (i) r = i;
2034
+ else if (l) r = l;
1997
2035
  else {
1998
- var l = ne(e.items, i);
1999
- r.push(l);
2036
+ var i = ne(e.items, l);
2037
+ r.push(i);
2000
2038
  }
2001
- else r = p(i) ? i : [];
2039
+ else r = p(l) ? l : [];
2002
2040
  }
2003
2041
  return r;
2004
2042
  }
2005
2043
  function ue(e, t) {
2006
- return 'object' === U(e.type)
2044
+ return 'object' === z(e.type)
2007
2045
  ? ne(e, t)
2008
- : 'array' === U(e.type)
2046
+ : 'array' === z(e.type)
2009
2047
  ? oe(e, t)
2010
- : le(e, t);
2048
+ : ie(e, t);
2011
2049
  }
2012
2050
  var pe = C;
2013
2051
  function ce(e, t) {
@@ -2036,7 +2074,7 @@
2036
2074
  ce(e[t], r);
2037
2075
  });
2038
2076
  else
2039
- k(e) &&
2077
+ q(e) &&
2040
2078
  e.map(function (e) {
2041
2079
  ce(e, r);
2042
2080
  });
@@ -2056,19 +2094,19 @@
2056
2094
  return (
2057
2095
  P(e)
2058
2096
  ? Object.keys(e).map(function (a) {
2059
- var i = e[a],
2060
- l = t ? t + '-' + a : a;
2061
- P(i) || k(i)
2062
- ? r.push({ title: a, value: l, key: l, children: de(i, l) })
2063
- : r.push({ title: a, value: l, key: l });
2097
+ var l = e[a],
2098
+ i = t ? t + '-' + a : a;
2099
+ P(l) || q(l)
2100
+ ? r.push({ title: a, value: i, key: i, children: de(l, i) })
2101
+ : r.push({ title: a, value: i, key: i });
2064
2102
  })
2065
- : k(e) &&
2103
+ : q(e) &&
2066
2104
  e.map(function (e, a) {
2067
- var i = a.toString(),
2068
- l = t ? t + '-' + a : i;
2069
- P(e) || k(e)
2070
- ? r.push({ title: i, value: l, key: l, children: de(e, l) })
2071
- : r.push({ title: i, value: l, key: l });
2105
+ var l = a.toString(),
2106
+ i = t ? t + '-' + a : l;
2107
+ P(e) || q(e)
2108
+ ? r.push({ title: l, value: i, key: i, children: de(e, i) })
2109
+ : r.push({ title: l, value: i, key: i });
2072
2110
  }),
2073
2111
  r
2074
2112
  );
@@ -2076,16 +2114,16 @@
2076
2114
  function ye(e, t) {
2077
2115
  var r = '';
2078
2116
  return (
2079
- 'object' === U(e.type) &&
2117
+ 'object' === z(e.type) &&
2080
2118
  e.properties &&
2081
2119
  (e.propertyOrder ? e.propertyOrder : Object.keys(e.properties)).map(
2082
2120
  function (a) {
2083
- var i = e.properties[a],
2084
- l = t[a];
2085
- ('array' === U(i.type) && 'object' === U(i.type)) ||
2086
- (l &&
2087
- i.isConditionProp &&
2088
- (r.indexOf('-') > 0 ? (r += '-' + l) : (r = l)));
2121
+ var l = e.properties[a],
2122
+ i = t[a];
2123
+ ('array' === z(l.type) && 'object' === z(l.type)) ||
2124
+ (i &&
2125
+ l.isConditionProp &&
2126
+ (r.indexOf('-') > 0 ? (r += '-' + i) : (r = i)));
2089
2127
  },
2090
2128
  ),
2091
2129
  r
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @wibetter/json-utils v5.0.16
2
+ * @wibetter/json-utils v5.0.21
3
3
  * author: wibetter
4
4
  * build tool: AKFun
5
- * build time: Sun Dec 29 2024 02:45:04 GMT+0800 (中国标准时间)
5
+ * build time: Tue Dec 31 2024 17:31:46 GMT+0800 (中国标准时间)
6
6
  * build tool info: https://github.com/wibetter/akfun
7
7
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wibetter/json-utils",
3
- "version": "5.0.16",
3
+ "version": "5.0.21",
4
4
  "description": "提供JSON相关的各类工具方法,比如schema转json、json转schema、json元数据分析等",
5
5
  "keywords": [
6
6
  "json工具包",