@wibetter/json-utils 7.0.1 → 7.0.3

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
@@ -1749,15 +1749,11 @@ function json2schema(jsonData) {
1749
1749
  var valExpectType = {
1750
1750
  array: 'array',
1751
1751
  boolean: 'boolean',
1752
- 'box-style': 'object',
1753
1752
  'padding-margin': 'object',
1754
1753
  codearea: 'string',
1755
1754
  color: 'string',
1756
- datasource: 'object',
1757
1755
  date: 'string',
1758
1756
  'date-time': 'string',
1759
- 'dynamic-data': 'object',
1760
- event: 'object',
1761
1757
  'func-body': 'string',
1762
1758
  htmlarea: 'string',
1763
1759
  image: 'string',
@@ -1766,13 +1762,17 @@ var valExpectType = {
1766
1762
  number: 'number',
1767
1763
  'input-image': 'string',
1768
1764
  object: 'object',
1769
- quantity: 'object',
1765
+ quantity: 'string',
1770
1766
  radio: 'string',
1771
1767
  select: 'string',
1772
1768
  textarea: 'string',
1773
1769
  'text-editor': 'string',
1774
1770
  time: 'string',
1775
1771
  url: 'string',
1772
+ 'box-style': 'object',
1773
+ datasource: 'object',
1774
+ 'dynamic-data': 'object',
1775
+ event: 'object',
1776
1776
  };
1777
1777
  // 根据type获取对应元素的期望类型值
1778
1778
  function getExpectType(type) {
@@ -2309,6 +2309,7 @@ function isEqualByType(value1, value2) {
2309
2309
  * 备注:使用旧版数据,以便进行新旧数据融合
2310
2310
  * */
2311
2311
  function baseSchema2JsonData(jsonSchema, jsonData) {
2312
+ var _jsonSchema$propertie, _jsonSchema$propertie2, _jsonSchema$propertie3;
2312
2313
  var curJsonData = undefined;
2313
2314
  var oldValue = jsonData;
2314
2315
  if (
@@ -2348,6 +2349,30 @@ function baseSchema2JsonData(jsonSchema, jsonData) {
2348
2349
  case 'number':
2349
2350
  curJsonData = hasProperties(curValue) ? curValue : undefined;
2350
2351
  break;
2352
+ case 'quantity':
2353
+ var defaultUnit =
2354
+ ((_jsonSchema$propertie = jsonSchema.properties) === null ||
2355
+ _jsonSchema$propertie === void 0 ||
2356
+ (_jsonSchema$propertie = _jsonSchema$propertie.quantity) === null ||
2357
+ _jsonSchema$propertie === void 0
2358
+ ? void 0
2359
+ : _jsonSchema$propertie.default) || 'px';
2360
+ // 根据 schema 的默认值生成初始字符串
2361
+ var defaultNum =
2362
+ (_jsonSchema$propertie2 =
2363
+ (_jsonSchema$propertie3 = jsonSchema.properties) === null ||
2364
+ _jsonSchema$propertie3 === void 0 ||
2365
+ (_jsonSchema$propertie3 = _jsonSchema$propertie3.unit) === null ||
2366
+ _jsonSchema$propertie3 === void 0
2367
+ ? void 0
2368
+ : _jsonSchema$propertie3.default) !== null &&
2369
+ _jsonSchema$propertie2 !== void 0
2370
+ ? _jsonSchema$propertie2
2371
+ : '';
2372
+ curJsonData = hasProperties(curValue)
2373
+ ? curValue
2374
+ : '' + defaultNum + defaultUnit;
2375
+ break;
2351
2376
  case 'json':
2352
2377
  /* 转成json类型进行特殊处理,需要保证json类型的数值是json对象 */
2353
2378
  var curJsonItemData = ''; // 字符串类型的json数据
@@ -2713,39 +2738,6 @@ function json2treeData(mockData, parentDataRoute) {
2713
2738
  return treeData;
2714
2739
  }
2715
2740
 
2716
- /**
2717
- * 收集当前schema中的所有条件子字段,根据其数值拼接成对应的 conditionValue
2718
- */
2719
- function schema2conditionValue(jsonSchema, jsonData) {
2720
- var conditionValue = '';
2721
- if (getExpectType(jsonSchema.type) === 'object' && jsonSchema.properties) {
2722
- var curPropertyOrder = [];
2723
- if (jsonSchema.propertyOrder) {
2724
- curPropertyOrder = jsonSchema.propertyOrder;
2725
- } else {
2726
- curPropertyOrder = Object.keys(jsonSchema.properties);
2727
- }
2728
- curPropertyOrder.map(function (jsonKey) {
2729
- var curJsonItem = jsonSchema.properties[jsonKey];
2730
- var curConditionValue = jsonData[jsonKey];
2731
- if (
2732
- getExpectType(curJsonItem.type) !== 'array' ||
2733
- getExpectType(curJsonItem.type) !== 'object'
2734
- ) {
2735
- if (curConditionValue && curJsonItem.isConditionProp) {
2736
- // 仅记录条件字段数值
2737
- if (conditionValue.indexOf('-') > 0) {
2738
- conditionValue += '-' + curConditionValue;
2739
- } else {
2740
- conditionValue = curConditionValue;
2741
- }
2742
- }
2743
- }
2744
- });
2745
- }
2746
- return conditionValue;
2747
- }
2748
-
2749
2741
  /**
2750
2742
  * 获取父元素的key路径值
2751
2743
  */
@@ -2844,7 +2836,6 @@ export {
2844
2836
  oldSchemaToNewSchema,
2845
2837
  oldSchemaToNewSchemaV1,
2846
2838
  registerExpectType,
2847
- schema2conditionValue,
2848
2839
  schema2json,
2849
2840
  schemaMetaList,
2850
2841
  truncate,
@@ -687,15 +687,15 @@ function x(e) {
687
687
  t
688
688
  );
689
689
  }
690
- function S() {
690
+ function q() {
691
691
  var e = {};
692
692
  return (location.search && (e = a.parse(location.search.substring(1))), e);
693
693
  }
694
- function T(e) {
694
+ function S(e) {
695
695
  var t = '';
696
696
  return (e && (t = a.stringify(e)), t);
697
697
  }
698
- function q(e) {
698
+ function T(e) {
699
699
  return t(e);
700
700
  }
701
701
  function k(t, r) {
@@ -753,18 +753,18 @@ function N(e, t) {
753
753
  }
754
754
  return i;
755
755
  }
756
- function C(e, t, r) {
756
+ function U(e, t, r) {
757
757
  var a = t;
758
- if ((r && (a = q(t)), e))
758
+ if ((r && (a = T(t)), e))
759
759
  for (var i = e.split('-'), n = 0, o = i.length; n < o; n++) {
760
760
  var p = i[n];
761
761
  p && (a = a && a[p]);
762
762
  }
763
763
  return a;
764
764
  }
765
- function U(e, t, r) {
765
+ function C(e, t, r) {
766
766
  var a = t;
767
- if ((r && (a = q(t)), e))
767
+ if ((r && (a = T(t)), e))
768
768
  for (
769
769
  var i = 'string' == typeof e ? e.split('-') : [e.toString()],
770
770
  n = 0,
@@ -794,7 +794,7 @@ function U(e, t, r) {
794
794
  }
795
795
  function w(e, t, r) {
796
796
  var a = t;
797
- if ((r && (a = q(t)), e && a))
797
+ if ((r && (a = T(t)), e && a))
798
798
  for (var i = e.split('-'), n = 0, o = i.length; n < o; n++) {
799
799
  var p = i[n];
800
800
  p && a.properties && (a = a.properties[p]);
@@ -853,14 +853,14 @@ function A(e) {
853
853
  if (h(e)) {
854
854
  var r = Object.keys(e);
855
855
  e.data && e.filter && 2 === r.length
856
- ? (t = b(e.data) || h(e.data) ? q(s.local) : q(s.remote))
856
+ ? (t = b(e.data) || h(e.data) ? T(s.local) : T(s.remote))
857
857
  : e.trigger && e.eventData && 2 === r.length
858
- ? (t = q(l.emit))
858
+ ? (t = T(l.emit))
859
859
  : e.register && e.actionFunc && 2 === r.length
860
- ? (t = q(l.on))
860
+ ? (t = T(l.on))
861
861
  : e.quantity && j(e.quantity) && 2 === r.length
862
- ? (t = q(p.quantity))
863
- : ((t = q(p['empty-object'])),
862
+ ? (t = T(p.quantity))
863
+ : ((t = T(p['empty-object'])),
864
864
  Object.keys(e).map(function (r) {
865
865
  var a = e[r];
866
866
  t.properties[r] = A(a);
@@ -873,14 +873,14 @@ function A(e) {
873
873
  var t;
874
874
  if (e && b(e))
875
875
  if (g(e)) {
876
- (t = q(p.select)).items.enum = e;
876
+ (t = T(p.select)).items.enum = e;
877
877
  var r = t.items.enumextra.length,
878
878
  a = e.length;
879
879
  if (a > r)
880
880
  for (var i = r, n = a; i < n; i++)
881
881
  t.items.enumextra.push('选项' + e(i));
882
882
  } else {
883
- t = q(p['empty-array']);
883
+ t = T(p['empty-array']);
884
884
  var o = A(e[0]);
885
885
  t.items.properties = o.properties;
886
886
  }
@@ -888,18 +888,18 @@ function A(e) {
888
888
  })(e)
889
889
  : (function (e) {
890
890
  var t = '';
891
- if (y(e)) t = q(p.boolean);
892
- else if (c(e)) t = q(p.number);
893
- else if (u(e)) t = q(p.url);
894
- else if (f(e)) t = q(p.date);
895
- else if (m(e)) t = q(p['date-time']);
896
- else if (v(e)) t = q(p.time);
897
- else if (O(e)) t = q(p.color);
891
+ if (y(e)) t = T(p.boolean);
892
+ else if (c(e)) t = T(p.number);
893
+ else if (u(e)) t = T(p.url);
894
+ else if (f(e)) t = T(p.date);
895
+ else if (m(e)) t = T(p['date-time']);
896
+ else if (v(e)) t = T(p.time);
897
+ else if (O(e)) t = T(p.color);
898
898
  else
899
899
  try {
900
- t = c(JSON.parse(e)) ? q(p.input) : q(p.json);
900
+ t = c(JSON.parse(e)) ? T(p.input) : T(p.json);
901
901
  } catch (r) {
902
- t = e && e.length > 30 ? q(p.textarea) : q(p.input);
902
+ t = e && e.length > 30 ? T(p.textarea) : T(p.input);
903
903
  }
904
904
  return t;
905
905
  })(e)),
@@ -909,15 +909,11 @@ function A(e) {
909
909
  var L = {
910
910
  array: 'array',
911
911
  boolean: 'boolean',
912
- 'box-style': 'object',
913
912
  'padding-margin': 'object',
914
913
  codearea: 'string',
915
914
  color: 'string',
916
- datasource: 'object',
917
915
  date: 'string',
918
916
  'date-time': 'string',
919
- 'dynamic-data': 'object',
920
- event: 'object',
921
917
  'func-body': 'string',
922
918
  htmlarea: 'string',
923
919
  image: 'string',
@@ -926,13 +922,17 @@ var L = {
926
922
  number: 'number',
927
923
  'input-image': 'string',
928
924
  object: 'object',
929
- quantity: 'object',
925
+ quantity: 'string',
930
926
  radio: 'string',
931
927
  select: 'string',
932
928
  textarea: 'string',
933
929
  'text-editor': 'string',
934
930
  time: 'string',
935
931
  url: 'string',
932
+ 'box-style': 'object',
933
+ datasource: 'object',
934
+ 'dynamic-data': 'object',
935
+ event: 'object',
936
936
  };
937
937
  function I(e) {
938
938
  return L[e] || e;
@@ -974,7 +974,7 @@ function B(e, t) {
974
974
  return a;
975
975
  }
976
976
  function K(e) {
977
- var t = q(e);
977
+ var t = T(e);
978
978
  if (
979
979
  (!t.title && t.description && (t.title = t.description),
980
980
  t.type || (t.type = t.format),
@@ -991,15 +991,15 @@ function K(e) {
991
991
  t.enumextra &&
992
992
  ((t.items = {
993
993
  type: 'string',
994
- enum: q(t.enum),
995
- enumextra: q(t.enumextra),
994
+ enum: T(t.enum),
995
+ enumextra: T(t.enumextra),
996
996
  }),
997
997
  delete t.enum,
998
998
  delete t.enumextra)),
999
999
  'quantity' === t.type)
1000
1000
  ) {
1001
1001
  var r = t.properties,
1002
- a = q(p.quantity);
1002
+ a = T(p.quantity);
1003
1003
  if (r.quantity && h(r.quantity) && r.quantity.default) {
1004
1004
  var i = r.quantity.default;
1005
1005
  a.properties.quantity.default = 'percent' === i ? '%' : i;
@@ -1012,25 +1012,25 @@ function K(e) {
1012
1012
  u = n.data && n.data.default,
1013
1013
  d = n.filter && n.filter.default;
1014
1014
  ('local' === o
1015
- ? ((t = q(s.local)).properties.data.default = u ? q(u) : '{}')
1016
- : ((t = q(s.remote)).properties.data.default = u ? q(u) : 'http://xxx'),
1017
- (t.properties.filter.default = d ? q(d) : '() => {}'));
1015
+ ? ((t = T(s.local)).properties.data.default = u ? T(u) : '{}')
1016
+ : ((t = T(s.remote)).properties.data.default = u ? T(u) : 'http://xxx'),
1017
+ (t.properties.filter.default = d ? T(d) : '() => {}'));
1018
1018
  }
1019
1019
  if ('event' === t.type) {
1020
1020
  var c = t.properties,
1021
1021
  y = c.type && c.type.default;
1022
1022
  if ('in' === y || 'on' === y) {
1023
1023
  var f = (c.filter && c.filter.default) || '() => {}';
1024
- ((t = q(l.on)),
1024
+ ((t = T(l.on)),
1025
1025
  c.actionFunc &&
1026
1026
  h(c.actionFunc) &&
1027
- (t.properties.actionFunc.default = c.actionFunc.default || q(f)));
1027
+ (t.properties.actionFunc.default = c.actionFunc.default || T(f)));
1028
1028
  } else {
1029
1029
  var m = (c.filter && c.filter.default) || '{}';
1030
- ((t = q(l.emit)),
1030
+ ((t = T(l.emit)),
1031
1031
  c.eventData &&
1032
1032
  h(c.eventData) &&
1033
- (t.properties.eventData.default = c.eventData.default || q(m)));
1033
+ (t.properties.eventData.default = c.eventData.default || T(m)));
1034
1034
  }
1035
1035
  }
1036
1036
  return (
@@ -1044,7 +1044,7 @@ function K(e) {
1044
1044
  );
1045
1045
  }
1046
1046
  function z(e) {
1047
- var t = q(e);
1047
+ var t = T(e);
1048
1048
  return (
1049
1049
  t.required || delete t.required,
1050
1050
  t.type && t.type && (t.type = t.type),
@@ -1093,19 +1093,19 @@ function H(e) {
1093
1093
  t
1094
1094
  );
1095
1095
  }
1096
- function V(e) {
1096
+ function W(e) {
1097
1097
  var t = !1,
1098
1098
  r = e.lastUpdateTime,
1099
1099
  a = new Date('2024-10-05T00:01:00.691Z').getTime();
1100
1100
  return (r && new Date(r).getTime() >= a && (t = !0), t);
1101
1101
  }
1102
- function W(e) {
1102
+ function Z(e) {
1103
1103
  var t = !1,
1104
1104
  r = I(e.type),
1105
1105
  a = void 0 === e.isContainer || e.isContainer;
1106
1106
  return ('object' === r && a && (t = !0), t);
1107
1107
  }
1108
- function Z(e) {
1108
+ function G(e) {
1109
1109
  var t = !0;
1110
1110
  return (
1111
1111
  'object' === e.type && e.propertyOrder && e.properties
@@ -1117,12 +1117,12 @@ function Z(e) {
1117
1117
  t
1118
1118
  );
1119
1119
  }
1120
- function G(e, t) {
1120
+ function M(e, t) {
1121
1121
  var r = e.split('-'),
1122
1122
  a = t.split('-');
1123
1123
  return (r.pop(), a.pop(), r.join('-') === a.join('-'));
1124
1124
  }
1125
- function M(e, t) {
1125
+ function V(e, t) {
1126
1126
  for (
1127
1127
  var r = e.split('-'),
1128
1128
  a = t.split('-'),
@@ -1173,53 +1173,77 @@ function te(e, t) {
1173
1173
  function re(e, t) {
1174
1174
  var r,
1175
1175
  a,
1176
- i = void 0,
1177
- n = t;
1178
- R(n) &&
1176
+ i,
1177
+ n,
1178
+ o,
1179
+ p = void 0,
1180
+ l = t;
1181
+ R(l) &&
1179
1182
  R(e.default) &&
1180
- (typeof n != typeof e.default ||
1181
- ((r = n), (a = e.default), h(r) + '-' + b(r) != h(a) + '-' + b(a))) &&
1182
- (n = void 0);
1183
- var o = R(n) ? n : e.default;
1183
+ (typeof l != typeof e.default ||
1184
+ ((n = l), (o = e.default), h(n) + '-' + b(n) != h(o) + '-' + b(o))) &&
1185
+ (l = void 0);
1186
+ var s = R(l) ? l : e.default;
1184
1187
  switch (e.type) {
1185
1188
  case 'select':
1186
1189
  case 'radio':
1187
- i = null != o ? o : te(e);
1190
+ p = null != s ? s : te(e);
1188
1191
  break;
1189
1192
  case 'checkboxes':
1190
- i = null != o ? o : te(e, !0);
1193
+ p = null != s ? s : te(e, !0);
1191
1194
  break;
1192
1195
  case 'color':
1193
- (('#fff' !== o && '#FFF' !== o) || (o = '#ffffff'),
1194
- (i = R(o) ? o : '#ffffff'));
1196
+ (('#fff' !== s && '#FFF' !== s) || (s = '#ffffff'),
1197
+ (p = R(s) ? s : '#ffffff'));
1195
1198
  break;
1196
1199
  case 'boolean':
1197
- i = !!R(o) && o;
1200
+ p = !!R(s) && s;
1198
1201
  break;
1199
1202
  case 'number':
1200
- i = R(o) ? o : void 0;
1203
+ p = R(s) ? s : void 0;
1204
+ break;
1205
+ case 'quantity':
1206
+ var u =
1207
+ (null === (r = e.properties) ||
1208
+ void 0 === r ||
1209
+ null === (r = r.quantity) ||
1210
+ void 0 === r
1211
+ ? void 0
1212
+ : r.default) || 'px',
1213
+ d =
1214
+ null !==
1215
+ (a =
1216
+ null === (i = e.properties) ||
1217
+ void 0 === i ||
1218
+ null === (i = i.unit) ||
1219
+ void 0 === i
1220
+ ? void 0
1221
+ : i.default) && void 0 !== a
1222
+ ? a
1223
+ : '';
1224
+ p = R(s) ? s : '' + d + u;
1201
1225
  break;
1202
1226
  case 'json':
1203
- var p = '';
1204
- if (h(o) || b(o)) p = o;
1205
- else if (x(o) || '' === o) p = {};
1227
+ var c = '';
1228
+ if (h(s) || b(s)) c = s;
1229
+ else if (x(s) || '' === s) c = {};
1206
1230
  else
1207
1231
  try {
1208
- p = JSON.parse(o);
1232
+ c = JSON.parse(s);
1209
1233
  } catch (e) {
1210
- p = {};
1234
+ c = {};
1211
1235
  }
1212
- i = p;
1236
+ p = c;
1213
1237
  break;
1214
1238
  default:
1215
- i =
1239
+ p =
1216
1240
  'input' === e.type && '0' === e.default
1217
- ? o || e.default
1218
- : R(o)
1219
- ? o
1241
+ ? s || e.default
1242
+ : R(s)
1243
+ ? s
1220
1244
  : void 0;
1221
1245
  }
1222
- return i;
1246
+ return p;
1223
1247
  }
1224
1248
  function ae(e, t) {
1225
1249
  var r = {},
@@ -1232,7 +1256,7 @@ function ae(e, t) {
1232
1256
  (n = void 0);
1233
1257
  var p = R(n) ? n : i.default;
1234
1258
  'dynamic-data' === a
1235
- ? ((r = q(o)),
1259
+ ? ((r = T(o)),
1236
1260
  p && h(p) && '{}' !== JSON.stringify(p) && (r = Object.assign(r, p)))
1237
1261
  : 'datasource' === a
1238
1262
  ? i.properties &&
@@ -1354,34 +1378,16 @@ function le(e, t) {
1354
1378
  r
1355
1379
  );
1356
1380
  }
1357
- function se(e, t) {
1358
- var r = '';
1359
- return (
1360
- 'object' === I(e.type) &&
1361
- e.properties &&
1362
- (e.propertyOrder ? e.propertyOrder : Object.keys(e.properties)).map(
1363
- function (a) {
1364
- var i = e.properties[a],
1365
- n = t[a];
1366
- ('array' === I(i.type) && 'object' === I(i.type)) ||
1367
- (n &&
1368
- i.isConditionProp &&
1369
- (r.indexOf('-') > 0 ? (r += '-' + n) : (r = n)));
1370
- },
1371
- ),
1372
- r
1373
- );
1374
- }
1375
- function ue(e) {
1381
+ function se(e) {
1376
1382
  var t = e.split('-');
1377
1383
  return (t.pop(), t.join('-'));
1378
1384
  }
1379
- function de(e) {
1385
+ function ue(e) {
1380
1386
  var t = e.split('-'),
1381
1387
  r = t.pop() || '';
1382
1388
  return [t.join('-'), r];
1383
1389
  }
1384
- var ce = [
1390
+ var de = [
1385
1391
  'key',
1386
1392
  'enum',
1387
1393
  'enumextra',
@@ -1413,41 +1419,41 @@ var ce = [
1413
1419
  export {
1414
1420
  s as DataSourceTypeList,
1415
1421
  l as EventTypeDataList,
1416
- ce as KeyWordList,
1422
+ de as KeyWordList,
1417
1423
  p as TypeDataList,
1418
1424
  pe as dataRoute2dataPath,
1419
1425
  N as evalExpression,
1420
- M as getCurPosition,
1426
+ V as getCurPosition,
1421
1427
  te as getDefaultOptionVal,
1422
1428
  I as getExpectType,
1423
- C as getJsonDataByKeyRoute,
1429
+ U as getJsonDataByKeyRoute,
1424
1430
  Q as getNextIndexRoute,
1425
1431
  _ as getParentIndexRoute,
1426
1432
  X as getParentIndexRoute_CurIndex,
1427
- ue as getParentKeyRoute,
1428
- de as getParentKeyRoute_CurKey,
1429
- U as getSchemaByIndexRoute,
1433
+ se as getParentKeyRoute,
1434
+ ue as getParentKeyRoute_CurKey,
1435
+ C as getSchemaByIndexRoute,
1430
1436
  w as getSchemaByKeyRoute,
1431
1437
  R as hasProperties,
1432
1438
  E as indexRoute2keyRoute,
1433
1439
  b as isArray,
1434
1440
  y as isBoolean,
1435
1441
  O as isColor,
1436
- W as isContainerSchema,
1442
+ Z as isContainerSchema,
1437
1443
  f as isDateStr,
1438
1444
  m as isDateTimeStr,
1439
1445
  H as isEmptySchema,
1440
1446
  k as isEqual,
1441
1447
  D as isEqualByIdT,
1442
1448
  x as isFunction,
1443
- V as isNewSchemaData,
1449
+ W as isNewSchemaData,
1444
1450
  c as isNumber,
1445
1451
  h as isObject,
1446
1452
  j as isQuantity,
1447
- G as isSameParent,
1453
+ M as isSameParent,
1448
1454
  g as isSelect,
1449
1455
  d as isString,
1450
- Z as isStructuredSchema,
1456
+ G as isStructuredSchema,
1451
1457
  v as isTimeStr,
1452
1458
  u as isURL,
1453
1459
  A as json2schema,
@@ -1456,14 +1462,13 @@ export {
1456
1462
  B as metaElemAnalyzer,
1457
1463
  ee as moveBackward,
1458
1464
  Y as moveForward,
1459
- q as objClone,
1465
+ T as objClone,
1460
1466
  z as oldSchemaToNewSchema,
1461
1467
  K as oldSchemaToNewSchemaV1,
1462
1468
  J as registerExpectType,
1463
- se as schema2conditionValue,
1464
1469
  ne as schema2json,
1465
1470
  oe as schemaMetaList,
1466
1471
  F as truncate,
1467
- S as urlParse,
1468
- T as urlStringify,
1472
+ q as urlParse,
1473
+ S as urlStringify,
1469
1474
  };
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@
48
48
  return u;
49
49
  },
50
50
  KeyWordList: function () {
51
- return fe;
51
+ return de;
52
52
  },
53
53
  TypeDataList: function () {
54
54
  return l;
@@ -60,7 +60,7 @@
60
60
  return U;
61
61
  },
62
62
  getCurPosition: function () {
63
- return G;
63
+ return V;
64
64
  },
65
65
  getDefaultOptionVal: function () {
66
66
  return re;
@@ -81,16 +81,16 @@
81
81
  return Y;
82
82
  },
83
83
  getParentKeyRoute: function () {
84
- return ce;
84
+ return se;
85
85
  },
86
86
  getParentKeyRoute_CurKey: function () {
87
- return de;
87
+ return ce;
88
88
  },
89
89
  getSchemaByIndexRoute: function () {
90
- return C;
90
+ return w;
91
91
  },
92
92
  getSchemaByKeyRoute: function () {
93
- return w;
93
+ return C;
94
94
  },
95
95
  hasProperties: function () {
96
96
  return N;
@@ -108,7 +108,7 @@
108
108
  return x;
109
109
  },
110
110
  isContainerSchema: function () {
111
- return V;
111
+ return W;
112
112
  },
113
113
  isDateStr: function () {
114
114
  return m;
@@ -141,7 +141,7 @@
141
141
  return O;
142
142
  },
143
143
  isSameParent: function () {
144
- return Z;
144
+ return G;
145
145
  },
146
146
  isSelect: function () {
147
147
  return h;
@@ -150,7 +150,7 @@
150
150
  return d;
151
151
  },
152
152
  isStructuredSchema: function () {
153
- return W;
153
+ return Z;
154
154
  },
155
155
  isTimeStr: function () {
156
156
  return b;
@@ -188,9 +188,6 @@
188
188
  registerExpectType: function () {
189
189
  return $;
190
190
  },
191
- schema2conditionValue: function () {
192
- return se;
193
- },
194
191
  schema2json: function () {
195
192
  return oe;
196
193
  },
@@ -992,7 +989,7 @@
992
989
  }
993
990
  return i;
994
991
  }
995
- function C(e, t, r) {
992
+ function w(e, t, r) {
996
993
  var i = t;
997
994
  if ((r && (i = k(t)), e))
998
995
  for (
@@ -1022,7 +1019,7 @@
1022
1019
  }
1023
1020
  return i;
1024
1021
  }
1025
- function w(e, t, r) {
1022
+ function C(e, t, r) {
1026
1023
  var i = t;
1027
1024
  if ((r && (i = k(t)), e && i))
1028
1025
  for (var n = e.split('-'), a = 0, o = n.length; a < o; a++) {
@@ -1145,15 +1142,11 @@
1145
1142
  var J = {
1146
1143
  array: 'array',
1147
1144
  boolean: 'boolean',
1148
- 'box-style': 'object',
1149
1145
  'padding-margin': 'object',
1150
1146
  codearea: 'string',
1151
1147
  color: 'string',
1152
- datasource: 'object',
1153
1148
  date: 'string',
1154
1149
  'date-time': 'string',
1155
- 'dynamic-data': 'object',
1156
- event: 'object',
1157
1150
  'func-body': 'string',
1158
1151
  htmlarea: 'string',
1159
1152
  image: 'string',
@@ -1162,13 +1155,17 @@
1162
1155
  number: 'number',
1163
1156
  'input-image': 'string',
1164
1157
  object: 'object',
1165
- quantity: 'object',
1158
+ quantity: 'string',
1166
1159
  radio: 'string',
1167
1160
  select: 'string',
1168
1161
  textarea: 'string',
1169
1162
  'text-editor': 'string',
1170
1163
  time: 'string',
1171
1164
  url: 'string',
1165
+ 'box-style': 'object',
1166
+ datasource: 'object',
1167
+ 'dynamic-data': 'object',
1168
+ event: 'object',
1172
1169
  };
1173
1170
  function I(e) {
1174
1171
  return J[e] || e;
@@ -1340,13 +1337,13 @@
1340
1337
  i = new Date('2024-10-05T00:01:00.691Z').getTime();
1341
1338
  return (r && new Date(r).getTime() >= i && (t = !0), t);
1342
1339
  }
1343
- function V(e) {
1340
+ function W(e) {
1344
1341
  var t = !1,
1345
1342
  r = I(e.type),
1346
1343
  i = void 0 === e.isContainer || e.isContainer;
1347
1344
  return ('object' === r && i && (t = !0), t);
1348
1345
  }
1349
- function W(e) {
1346
+ function Z(e) {
1350
1347
  var t = !0;
1351
1348
  return (
1352
1349
  'object' === e.type && e.propertyOrder && e.properties
@@ -1359,12 +1356,12 @@
1359
1356
  t
1360
1357
  );
1361
1358
  }
1362
- function Z(e, t) {
1359
+ function G(e, t) {
1363
1360
  var r = e.split('-'),
1364
1361
  i = t.split('-');
1365
1362
  return (r.pop(), i.pop(), r.join('-') === i.join('-'));
1366
1363
  }
1367
- function G(e, t) {
1364
+ function V(e, t) {
1368
1365
  for (
1369
1366
  var r = e.split('-'),
1370
1367
  i = t.split('-'),
@@ -1415,53 +1412,77 @@
1415
1412
  function ie(e, t) {
1416
1413
  var r,
1417
1414
  i,
1418
- n = void 0,
1419
- a = t;
1420
- N(a) &&
1415
+ n,
1416
+ a,
1417
+ o,
1418
+ p = void 0,
1419
+ l = t;
1420
+ N(l) &&
1421
1421
  N(e.default) &&
1422
- (typeof a != typeof e.default ||
1423
- ((r = a), (i = e.default), j(r) + '-' + g(r) != j(i) + '-' + g(i))) &&
1424
- (a = void 0);
1425
- var o = N(a) ? a : e.default;
1422
+ (typeof l != typeof e.default ||
1423
+ ((a = l), (o = e.default), j(a) + '-' + g(a) != j(o) + '-' + g(o))) &&
1424
+ (l = void 0);
1425
+ var u = N(l) ? l : e.default;
1426
1426
  switch (e.type) {
1427
1427
  case 'select':
1428
1428
  case 'radio':
1429
- n = null != o ? o : re(e);
1429
+ p = null != u ? u : re(e);
1430
1430
  break;
1431
1431
  case 'checkboxes':
1432
- n = null != o ? o : re(e, !0);
1432
+ p = null != u ? u : re(e, !0);
1433
1433
  break;
1434
1434
  case 'color':
1435
- (('#fff' !== o && '#FFF' !== o) || (o = '#ffffff'),
1436
- (n = N(o) ? o : '#ffffff'));
1435
+ (('#fff' !== u && '#FFF' !== u) || (u = '#ffffff'),
1436
+ (p = N(u) ? u : '#ffffff'));
1437
1437
  break;
1438
1438
  case 'boolean':
1439
- n = !!N(o) && o;
1439
+ p = !!N(u) && u;
1440
1440
  break;
1441
1441
  case 'number':
1442
- n = N(o) ? o : void 0;
1442
+ p = N(u) ? u : void 0;
1443
+ break;
1444
+ case 'quantity':
1445
+ var s =
1446
+ (null === (r = e.properties) ||
1447
+ void 0 === r ||
1448
+ null === (r = r.quantity) ||
1449
+ void 0 === r
1450
+ ? void 0
1451
+ : r.default) || 'px',
1452
+ c =
1453
+ null !==
1454
+ (i =
1455
+ null === (n = e.properties) ||
1456
+ void 0 === n ||
1457
+ null === (n = n.unit) ||
1458
+ void 0 === n
1459
+ ? void 0
1460
+ : n.default) && void 0 !== i
1461
+ ? i
1462
+ : '';
1463
+ p = N(u) ? u : '' + c + s;
1443
1464
  break;
1444
1465
  case 'json':
1445
- var p = '';
1446
- if (j(o) || g(o)) p = o;
1447
- else if (S(o) || '' === o) p = {};
1466
+ var d = '';
1467
+ if (j(u) || g(u)) d = u;
1468
+ else if (S(u) || '' === u) d = {};
1448
1469
  else
1449
1470
  try {
1450
- p = JSON.parse(o);
1471
+ d = JSON.parse(u);
1451
1472
  } catch (e) {
1452
- p = {};
1473
+ d = {};
1453
1474
  }
1454
- n = p;
1475
+ p = d;
1455
1476
  break;
1456
1477
  default:
1457
- n =
1478
+ p =
1458
1479
  'input' === e.type && '0' === e.default
1459
- ? o || e.default
1460
- : N(o)
1461
- ? o
1480
+ ? u || e.default
1481
+ : N(u)
1482
+ ? u
1462
1483
  : void 0;
1463
1484
  }
1464
- return n;
1485
+ return p;
1465
1486
  }
1466
1487
  function ne(e, t) {
1467
1488
  var r = {},
@@ -1599,34 +1620,16 @@
1599
1620
  r
1600
1621
  );
1601
1622
  }
1602
- function se(e, t) {
1603
- var r = '';
1604
- return (
1605
- 'object' === I(e.type) &&
1606
- e.properties &&
1607
- (e.propertyOrder ? e.propertyOrder : Object.keys(e.properties)).map(
1608
- function (i) {
1609
- var n = e.properties[i],
1610
- a = t[i];
1611
- ('array' === I(n.type) && 'object' === I(n.type)) ||
1612
- (a &&
1613
- n.isConditionProp &&
1614
- (r.indexOf('-') > 0 ? (r += '-' + a) : (r = a)));
1615
- },
1616
- ),
1617
- r
1618
- );
1619
- }
1620
- function ce(e) {
1623
+ function se(e) {
1621
1624
  var t = e.split('-');
1622
1625
  return (t.pop(), t.join('-'));
1623
1626
  }
1624
- function de(e) {
1627
+ function ce(e) {
1625
1628
  var t = e.split('-'),
1626
1629
  r = t.pop() || '';
1627
1630
  return [t.join('-'), r];
1628
1631
  }
1629
- var fe = [
1632
+ var de = [
1630
1633
  'key',
1631
1634
  'enum',
1632
1635
  'enumextra',
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @wibetter/json-utils v7.0.1
2
+ * @wibetter/json-utils v7.0.2
3
3
  * author: wibetter
4
4
  * build tool: AKFun
5
- * build time: Fri Feb 27 2026 11:56:39 GMT+0800 (中国标准时间)
5
+ * build time: Sun Mar 22 2026 19:16:08 GMT+0800 (中国标准时间)
6
6
  * build tool info: https://github.com/wibetter/akfun
7
7
  */
@@ -65,7 +65,6 @@ export * from './function/schema2json';
65
65
  export * from './function/schemaMetaList';
66
66
  export * from './function/json2treeData';
67
67
  export * from './function/getExpectType';
68
- export * from './function/schema2conditionValue';
69
68
  export * from './utils/index';
70
69
  export * from './utils/jsonData';
71
70
  export * from './utils/jsonSchema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wibetter/json-utils",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "description": "提供JSON相关的各类工具方法,比如schema转json、json转schema、json元数据分析等",
5
5
  "keywords": [
6
6
  "json工具包",
@@ -1,7 +0,0 @@
1
- /**
2
- * 收集当前schema中的所有条件子字段,根据其数值拼接成对应的 conditionValue
3
- */
4
- export declare function schema2conditionValue(
5
- jsonSchema: any,
6
- jsonData: any,
7
- ): string;