shineout 3.2.0 → 3.2.2-beta.1

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/cjs/index.js CHANGED
@@ -476,5 +476,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
476
476
  // 此文件由脚本自动生成,请勿直接修改。
477
477
  // This file was generated automatically by a script. Please do not modify it directly.
478
478
  var _default = exports.default = {
479
- version: '3.2.0'
479
+ version: '3.2.2-beta.1'
480
480
  };
package/dist/shineout.js CHANGED
@@ -6439,16 +6439,16 @@ __webpack_require__.d(color_namespaceObject, {
6439
6439
  });
6440
6440
 
6441
6441
  // NAMESPACE OBJECT: ./src/utils/flat.ts
6442
- var flat_namespaceObject = {};
6443
- __webpack_require__.r(flat_namespaceObject);
6444
- __webpack_require__.d(flat_namespaceObject, {
6445
- flatten: function() { return flatten; },
6442
+ var utils_flat_namespaceObject = {};
6443
+ __webpack_require__.r(utils_flat_namespaceObject);
6444
+ __webpack_require__.d(utils_flat_namespaceObject, {
6445
+ flatten: function() { return flat_flatten; },
6446
6446
  flattenArray: function() { return flat_flattenArray; },
6447
6447
  getSthByName: function() { return getSthByName; },
6448
- insertPoint: function() { return flat_insertPoint; },
6449
- insertValue: function() { return insertValue; },
6448
+ insertPoint: function() { return utils_flat_insertPoint; },
6449
+ insertValue: function() { return flat_insertValue; },
6450
6450
  removeSthByName: function() { return removeSthByName; },
6451
- spliceValue: function() { return spliceValue; },
6451
+ spliceValue: function() { return flat_spliceValue; },
6452
6452
  unflatten: function() { return unflatten; }
6453
6453
  });
6454
6454
 
@@ -6555,7 +6555,7 @@ __webpack_require__.d(src_utils_namespaceObject, {
6555
6555
  detect: function() { return detect_namespaceObject; },
6556
6556
  doc: function() { return dom_document_namespaceObject; },
6557
6557
  element: function() { return dom_element_namespaceObject; },
6558
- flat: function() { return flat_namespaceObject; },
6558
+ flat: function() { return utils_flat_namespaceObject; },
6559
6559
  func: function() { return utils_func_namespaceObject; },
6560
6560
  hash: function() { return hash_createHash; },
6561
6561
  is: function() { return utils_is_namespaceObject; },
@@ -11960,7 +11960,7 @@ var handleStyle = function handleStyle(style) {
11960
11960
  };
11961
11961
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
11962
11962
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
11963
- /* harmony default export */ var version = ('3.2.0');
11963
+ /* harmony default export */ var version = ('3.2.2-beta.1');
11964
11964
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
11965
11965
 
11966
11966
 
@@ -27208,9 +27208,9 @@ function $getKey(gen, d, index) {
27208
27208
  if (typeof gen === 'function') return gen(d, index);
27209
27209
  return index;
27210
27210
  }
27211
- function getKey(gen, d, index) {
27211
+ function getKey(gen, d, index, ignoreError) {
27212
27212
  var key = $getKey(gen, d, index);
27213
- if (typeof key !== 'string' && typeof key !== 'number') {
27213
+ if (typeof key !== 'string' && typeof key !== 'number' && !ignoreError) {
27214
27214
  console.error(new Error("keygen result expect a string or a number, get '".concat(typeof_default()(key), "'")));
27215
27215
  }
27216
27216
  return key;
@@ -44388,6 +44388,90 @@ var Provider = function Provider(props) {
44388
44388
  })
44389
44389
  });
44390
44390
  };
44391
+ ;// CONCATENATED MODULE: ../hooks/src/utils/flat.ts
44392
+
44393
+
44394
+
44395
+ function flat_insertPoint(name) {
44396
+ var reg = /(\[\d+\])/gi;
44397
+ return name.replace(reg, function (s, m, i) {
44398
+ return s.replace(m, i === 0 ? m : ".".concat(m));
44399
+ });
44400
+ }
44401
+ function flatten(data, skipArray) {
44402
+ if (is_isEmpty(data)) return data;
44403
+ var result = {};
44404
+ function recurse(cur, prop) {
44405
+ if (Object(cur) !== cur || typeof cur === 'function' || cur instanceof Date || cur instanceof Error || skipArray && Array.isArray(cur)) {
44406
+ if (!(cur === undefined && /\[\d+\]$/.test(prop))) {
44407
+ result[prop] = cur;
44408
+ }
44409
+ } else if (Array.isArray(cur)) {
44410
+ if (cur.length === 0) {
44411
+ result[prop] = [];
44412
+ } else {
44413
+ for (var i = 0, l = cur.length; i < l; i++) {
44414
+ recurse(cur[i], prop ? "".concat(prop, "[").concat(i, "]") : "[".concat(i, "]"));
44415
+ }
44416
+ }
44417
+ } else {
44418
+ var empty = true;
44419
+ if (typeof_default()(cur) === 'object') {
44420
+ // eslint-disable-next-line
44421
+ for (var p in cur) {
44422
+ empty = false;
44423
+ recurse(cur[p], prop ? "".concat(prop, ".").concat(p) : p);
44424
+ }
44425
+ if (empty) {
44426
+ result[prop] = {};
44427
+ }
44428
+ }
44429
+ }
44430
+ }
44431
+ recurse(data, '');
44432
+ return result;
44433
+ }
44434
+ function insertValue(obj, name, index, value) {
44435
+ Object.keys(obj).filter(function (n) {
44436
+ return n.indexOf("".concat(name, "[")) === 0;
44437
+ }).sort().reverse().forEach(function (n) {
44438
+ // const reg = new RegExp(`${name}\\[(\\d+)\\]`)
44439
+ var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
44440
+ var match = reg.exec(n);
44441
+ var i = parseInt(match[1], 10);
44442
+ if (i < index) return;
44443
+ var newName = n.replace(reg, "".concat(name, "[").concat(i + 1, "]"));
44444
+ if (obj[n]) obj[newName] = obj[n];
44445
+ delete obj[n];
44446
+ });
44447
+ var newValue = flatten(defineProperty_default()({}, "".concat(name, "[").concat(index, "]"), value));
44448
+ Object.keys(newValue).forEach(function (k) {
44449
+ if (newValue[k] !== undefined) obj[k] = newValue[k];
44450
+ });
44451
+ }
44452
+ function spliceValue(obj, name, index) {
44453
+ var names = Object.keys(obj).filter(function (n) {
44454
+ return n === name || n.indexOf("".concat(name, "[")) === 0;
44455
+ }).sort();
44456
+ names.forEach(function (n) {
44457
+ if (n === name && !Array.isArray(obj[name])) return;
44458
+ if (n === name && Array.isArray(obj[name])) {
44459
+ obj[name].splice(index, 1);
44460
+ return;
44461
+ }
44462
+ var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
44463
+ var match = reg.exec(n);
44464
+ var i = parseInt(match[1], 10);
44465
+ if (i < index) return;
44466
+ if (i === index) {
44467
+ delete obj[n];
44468
+ return;
44469
+ }
44470
+ var newName = n.replace(reg, "".concat(name, "[").concat(i - 1, "]"));
44471
+ obj[newName] = obj[n];
44472
+ delete obj[n];
44473
+ });
44474
+ }
44391
44475
  ;// CONCATENATED MODULE: ../hooks/src/components/use-form/use-form.ts
44392
44476
 
44393
44477
 
@@ -44398,6 +44482,7 @@ var Provider = function Provider(props) {
44398
44482
 
44399
44483
 
44400
44484
 
44485
+
44401
44486
  var globalKey = '__global__&&@@';
44402
44487
 
44403
44488
 
@@ -44470,6 +44555,15 @@ var useForm = function useForm(props) {
44470
44555
  update();
44471
44556
  });
44472
44557
  };
44558
+ var updateFieldsets = use_persist_fn(function (name) {
44559
+ var na = "".concat(name, "[");
44560
+ var no = "".concat(name, ".");
44561
+ context.names.forEach(function (key) {
44562
+ if (key.startsWith(na) || key.startsWith(no)) {
44563
+ update(key);
44564
+ }
44565
+ });
44566
+ });
44473
44567
  var handleSubmitError = function handleSubmitError(err) {
44474
44568
  onError === null || onError === void 0 || onError(err);
44475
44569
  if (!props.scrollToError) return;
@@ -44587,6 +44681,14 @@ var useForm = function useForm(props) {
44587
44681
  context.errors[name] = e;
44588
44682
  update(name);
44589
44683
  });
44684
+ var insertError = use_persist_fn(function (name, index, error) {
44685
+ insertValue(context.errors, name, index, error);
44686
+ updateFieldsets(name);
44687
+ });
44688
+ var spliceError = use_persist_fn(function (name, index) {
44689
+ spliceValue(context.errors, name, index);
44690
+ updateFieldsets(name);
44691
+ });
44590
44692
  var submit = use_persist_fn(function () {
44591
44693
  var withValidate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
44592
44694
  if (disabled) return;
@@ -44643,6 +44745,17 @@ var useForm = function useForm(props) {
44643
44745
  other === null || other === void 0 || (_other$onSubmit = other.onSubmit) === null || _other$onSubmit === void 0 || _other$onSubmit.call(other, e);
44644
44746
  };
44645
44747
  };
44748
+ var validateFieldset = function validateFieldset(name) {
44749
+ var na = "".concat(name, "[");
44750
+ var no = "".concat(name, ".");
44751
+ var fields = [];
44752
+ context.names.forEach(function (key) {
44753
+ if (key.startsWith(na) || key.startsWith(no)) {
44754
+ fields.push(key);
44755
+ }
44756
+ });
44757
+ validateFields(fields).catch(function () {});
44758
+ };
44646
44759
  var getDefaultValue = function getDefaultValue() {
44647
44760
  var v = utils_immer_produce(defaultValue, function (draft) {
44648
44761
  Object.keys(context.defaultValues).forEach(function (key) {
@@ -44748,7 +44861,10 @@ var useForm = function useForm(props) {
44748
44861
  setError: setError,
44749
44862
  getErrors: getErrors,
44750
44863
  clearValidate: clearValidate,
44751
- validateFields: validateFields
44864
+ validateFields: validateFields,
44865
+ validateFieldset: validateFieldset,
44866
+ insertError: insertError,
44867
+ spliceError: spliceError
44752
44868
  });
44753
44869
  var formConfig = external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo(function () {
44754
44870
  return {
@@ -45094,7 +45210,8 @@ var useFormFieldSet = function useFormFieldSet(props) {
45094
45210
  ProviderValue: ProviderValue,
45095
45211
  error: error,
45096
45212
  value: value,
45097
- onChange: onChange
45213
+ onChange: onChange,
45214
+ name: name
45098
45215
  };
45099
45216
  };
45100
45217
  /* harmony default export */ var use_form_fieldset = (useFormFieldSet);
@@ -45111,6 +45228,7 @@ var FormFieldSet = function FormFieldSet(props) {
45111
45228
  ids: []
45112
45229
  }),
45113
45230
  context = _React$useRef.current;
45231
+ var formFunc = useFormFunc();
45114
45232
  var getValidateProps = usePersistFn(function () {
45115
45233
  return props;
45116
45234
  });
@@ -45124,16 +45242,16 @@ var FormFieldSet = function FormFieldSet(props) {
45124
45242
  }),
45125
45243
  Provider = _useFormFieldSet.Provider,
45126
45244
  ProviderValue = _useFormFieldSet.ProviderValue,
45127
- value = _useFormFieldSet.value,
45128
45245
  error = _useFormFieldSet.error,
45129
- _onChange = _useFormFieldSet.onChange;
45246
+ _onChange = _useFormFieldSet.onChange,
45247
+ name = _useFormFieldSet.name;
45130
45248
  if (typeof children !== 'function') {
45131
45249
  return /*#__PURE__*/(0,jsx_runtime.jsx)(Provider, {
45132
45250
  value: ProviderValue,
45133
45251
  children: children
45134
45252
  });
45135
45253
  }
45136
- var valueArr = value || [];
45254
+ var valueArr = (formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name)) || [];
45137
45255
  valueArr = Array.isArray(valueArr) ? valueArr : [valueArr];
45138
45256
  var result = [];
45139
45257
  if (valueArr.length === 0 && valueArr && empty) {
@@ -45144,6 +45262,7 @@ var FormFieldSet = function FormFieldSet(props) {
45144
45262
  });
45145
45263
  _onChange(newValue);
45146
45264
  context.ids.push(generateUUID());
45265
+ formFunc === null || formFunc === void 0 || formFunc.insertError(name, 0);
45147
45266
  })
45148
45267
  }, 'empty'));
45149
45268
  }
@@ -45165,31 +45284,39 @@ var FormFieldSet = function FormFieldSet(props) {
45165
45284
  index: i,
45166
45285
  error: errorList,
45167
45286
  onChange: function onChange(val) {
45168
- var newValue = form_fieldset_produce(valueArr, function (draft) {
45287
+ var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
45288
+ var newValue = form_fieldset_produce(oldValue, function (draft) {
45169
45289
  draft[i] = val;
45170
45290
  });
45171
45291
  _onChange(newValue);
45292
+ formFunc === null || formFunc === void 0 || formFunc.validateFieldset("".concat(name, "[").concat(i, "]"));
45172
45293
  },
45173
45294
  onInsert: function onInsert(val) {
45174
- var newValue = form_fieldset_produce(valueArr, function (draft) {
45295
+ var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
45296
+ var newValue = form_fieldset_produce(oldValue, function (draft) {
45175
45297
  draft.splice(i, 0, val);
45176
45298
  });
45177
45299
  _onChange(newValue);
45178
45300
  context.ids.splice(i, 0, generateUUID());
45301
+ formFunc === null || formFunc === void 0 || formFunc.insertError(name, i);
45179
45302
  },
45180
45303
  onAppend: function onAppend(val) {
45181
- var newValue = form_fieldset_produce(valueArr, function (draft) {
45304
+ var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
45305
+ var newValue = form_fieldset_produce(oldValue, function (draft) {
45182
45306
  draft.splice(i + 1, 0, val);
45183
45307
  });
45184
45308
  _onChange(newValue);
45185
45309
  context.ids.splice(i + 1, 0, generateUUID());
45310
+ formFunc === null || formFunc === void 0 || formFunc.insertError(name, i + 1);
45186
45311
  },
45187
45312
  onRemove: function onRemove() {
45188
- var newValue = form_fieldset_produce(valueArr, function (draft) {
45313
+ var oldValue = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue(name);
45314
+ var newValue = form_fieldset_produce(oldValue, function (draft) {
45189
45315
  draft.splice(i, 1);
45190
45316
  });
45191
45317
  _onChange(newValue);
45192
45318
  context.ids.splice(i, 1);
45319
+ formFunc === null || formFunc === void 0 || formFunc.spliceError(name, i);
45193
45320
  }
45194
45321
  })
45195
45322
  }, ids[i]));
@@ -51371,7 +51498,7 @@ var MenuItem = function MenuItem(props) {
51371
51498
  }
51372
51499
  }) : null;
51373
51500
  var item = render_render(props.renderItem, props.dataItem, props.index);
51374
- var link = props.linkKey ? getKey(props.linkKey, props.dataItem, props.index) : undefined;
51501
+ var link = props.linkKey ? getKey(props.linkKey, props.dataItem, props.index, true) : undefined;
51375
51502
  var title = null;
51376
51503
  if (isLink(item)) {
51377
51504
  var mergeClass = classnames_default()(classes === null || classes === void 0 ? void 0 : classes.title, item.props && item.props.className);
@@ -61347,13 +61474,13 @@ function fade(color) {
61347
61474
 
61348
61475
 
61349
61476
 
61350
- function flat_insertPoint(name) {
61477
+ function utils_flat_insertPoint(name) {
61351
61478
  var reg = /(\[\d+\])/gi;
61352
61479
  return name.replace(reg, function (s, m, i) {
61353
61480
  return s.replace(m, i === 0 ? m : ".".concat(m));
61354
61481
  });
61355
61482
  }
61356
- function flatten(data, skipArray) {
61483
+ function flat_flatten(data, skipArray) {
61357
61484
  if (utils_is_isEmpty(data)) return data;
61358
61485
  var result = {};
61359
61486
  function recurse(cur, prop) {
@@ -61402,7 +61529,7 @@ function unflatten(rawdata) {
61402
61529
 
61403
61530
  // eslint-disable-next-line
61404
61531
  Object.keys(data).sort().forEach(function (p) {
61405
- var pathWithPoint = flat_insertPoint(p);
61532
+ var pathWithPoint = utils_flat_insertPoint(p);
61406
61533
  cur = result;
61407
61534
  prop = '';
61408
61535
  last = 0;
@@ -61418,7 +61545,7 @@ function unflatten(rawdata) {
61418
61545
  });
61419
61546
  return result[''];
61420
61547
  }
61421
- function insertValue(obj, name, index, value) {
61548
+ function flat_insertValue(obj, name, index, value) {
61422
61549
  Object.keys(obj).filter(function (n) {
61423
61550
  return n.indexOf("".concat(name, "[")) === 0;
61424
61551
  }).sort().reverse().forEach(function (n) {
@@ -61431,12 +61558,12 @@ function insertValue(obj, name, index, value) {
61431
61558
  if (obj[n]) obj[newName] = obj[n];
61432
61559
  delete obj[n];
61433
61560
  });
61434
- var newValue = flatten(defineProperty_default()({}, "".concat(name, "[").concat(index, "]"), value));
61561
+ var newValue = flat_flatten(defineProperty_default()({}, "".concat(name, "[").concat(index, "]"), value));
61435
61562
  Object.keys(newValue).forEach(function (k) {
61436
61563
  if (newValue[k] !== undefined) obj[k] = newValue[k];
61437
61564
  });
61438
61565
  }
61439
- function spliceValue(obj, name, index) {
61566
+ function flat_spliceValue(obj, name, index) {
61440
61567
  var names = Object.keys(obj).filter(function (n) {
61441
61568
  return n === name || n.indexOf("".concat(name, "[")) === 0;
61442
61569
  }).sort();
@@ -61467,7 +61594,7 @@ var isNameWithPath = function isNameWithPath(name, path) {
61467
61594
  var getSthByName = function getSthByName(name, source) {
61468
61595
  if (source[name]) return source[name];
61469
61596
  var result = unflatten(source);
61470
- name = flat_insertPoint(name);
61597
+ name = utils_flat_insertPoint(name);
61471
61598
  name.split('.').forEach(function (n) {
61472
61599
  var match = /^\[(\d+)\]$/.exec(n);
61473
61600
  // eslint-disable-next-line
@@ -61482,7 +61609,7 @@ var getSthByName = function getSthByName(name, source) {
61482
61609
  var removeSthByName = function removeSthByName(name, source) {
61483
61610
  var match = /(.*)\[(\d+)\]$/.exec(name);
61484
61611
  if (match) {
61485
- spliceValue(source, match[1], parseInt(match[2], 10));
61612
+ flat_spliceValue(source, match[1], parseInt(match[2], 10));
61486
61613
  } else {
61487
61614
  Object.keys(source).forEach(function (n) {
61488
61615
  if (isNameWithPath(n, name)) delete source[n];
@@ -61674,7 +61801,7 @@ var objects_deepMerge = function deepMerge() {
61674
61801
  return dest;
61675
61802
  };
61676
61803
  function objects_pathGenerator(raw) {
61677
- var path = flat_insertPoint(raw);
61804
+ var path = utils_flat_insertPoint(raw);
61678
61805
  var reg = /^\[(\d+)\]$/;
61679
61806
  var pathModeValues = objects_objectValues(objects_PATH_MODE);
61680
61807
  var index = 0;
@@ -62900,7 +63027,7 @@ var upload_interface = __webpack_require__(4412);
62900
63027
 
62901
63028
 
62902
63029
  /* harmony default export */ var src_0 = ({
62903
- version: '3.2.0'
63030
+ version: '3.2.2-beta.1'
62904
63031
  });
62905
63032
  }();
62906
63033
  /******/ return __webpack_exports__;