3h1-ui 3.0.0-next.81 → 3.0.0-next.83

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.
Files changed (3) hide show
  1. package/es/index.js +28 -14
  2. package/lib/index.js +28 -14
  3. package/package.json +3 -3
package/es/index.js CHANGED
@@ -16270,7 +16270,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
16270
16270
  });
16271
16271
  const formTable = "";
16272
16272
  const SHOW_ROW_COUNT = 10;
16273
- const ROW_HEIGHT = 48.67;
16273
+ const ROW_HEIGHT = 48.5;
16274
16274
  const BODY_HEIGHT = ROW_HEIGHT * SHOW_ROW_COUNT;
16275
16275
  const ShyFormTable = /* @__PURE__ */ defineComponent({
16276
16276
  props: {
@@ -16534,11 +16534,13 @@ const ShyFormTable = /* @__PURE__ */ defineComponent({
16534
16534
  }, null)])]);
16535
16535
  });
16536
16536
  const create = () => {
16537
- state.value = [{
16537
+ state.value = [...toRaw(state.value), {
16538
16538
  [props2.rowKey]: buildUUID()
16539
- }, ...toRaw(state.value)];
16539
+ }];
16540
16540
  curIndex.value = 0;
16541
- document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = curIndex.value * ROW_HEIGHT;
16541
+ nextTick(() => {
16542
+ document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = (state.value.length + 1) * ROW_HEIGHT;
16543
+ });
16542
16544
  emit("add", state.value);
16543
16545
  };
16544
16546
  const remove = (index2) => {
@@ -16559,7 +16561,7 @@ const ShyFormTable = /* @__PURE__ */ defineComponent({
16559
16561
  }) => {
16560
16562
  var _a2, _b;
16561
16563
  const errKey = `${column2.dataIndex}-${record[props2.rowKey]}Info`;
16562
- if (!column2.required)
16564
+ if (!column2.required && !column2.rules)
16563
16565
  return [];
16564
16566
  if ((_a2 = rulesRef[errKey]) == null ? void 0 : _a2.rules)
16565
16567
  return (_b = rulesRef[errKey]) == null ? void 0 : _b.rules;
@@ -16589,8 +16591,27 @@ const ShyFormTable = /* @__PURE__ */ defineComponent({
16589
16591
  return column2.rules;
16590
16592
  rulesRef[errKey].rules = cloneDeep(column2.rules);
16591
16593
  rulesRef[errKey].rules.forEach((item) => {
16592
- if (!item.validator || !isFunction$4(item.validator))
16594
+ if (!item.validator || !isFunction$4(item.validator)) {
16595
+ item.validator = async (rule, value) => {
16596
+ rulesRef[errKey].show = false;
16597
+ if (!rule.pattern && !rule.required)
16598
+ return Promise.resolve();
16599
+ if ((column2.required || rule.required) && isNil(value)) {
16600
+ const prefix = column2.type.toLocaleLowerCase().includes("input") ? "请输入" : "请选择";
16601
+ const errMsg = `${prefix}${column2.title}`;
16602
+ rulesRef[errKey].show = true;
16603
+ rulesRef[errKey].msg = errMsg;
16604
+ return Promise.reject(errMsg);
16605
+ }
16606
+ if (rule.pattern && !rule.pattern.test(value)) {
16607
+ rulesRef[errKey].show = true;
16608
+ rulesRef[errKey].msg = rule.message;
16609
+ return Promise.reject(rule.message);
16610
+ }
16611
+ return Promise.resolve();
16612
+ };
16593
16613
  return;
16614
+ }
16594
16615
  const validator = item.validator;
16595
16616
  item.validator = async (rule, value) => {
16596
16617
  try {
@@ -16672,6 +16693,7 @@ const ShyFormTable = /* @__PURE__ */ defineComponent({
16672
16693
  document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = curIndex.value * ROW_HEIGHT;
16673
16694
  }, true);
16674
16695
  tableWrapperRef.value.addEventListener("scroll", handleScroll, true);
16696
+ dataSource.value = state.value.length > SHOW_ROW_COUNT ? state.value.slice(curIndex.value, curIndex.value + SHOW_ROW_COUNT) : state.value.slice(0, SHOW_ROW_COUNT);
16675
16697
  });
16676
16698
  onUnmounted(() => {
16677
16699
  window.removeEventListener("scroll", () => {
@@ -21833,7 +21855,6 @@ const FormItem = /* @__PURE__ */ defineComponent({
21833
21855
  type: Boolean
21834
21856
  }
21835
21857
  },
21836
- emits: ["clearCurrValidate"],
21837
21858
  setup(props2, {
21838
21859
  slots,
21839
21860
  emit,
@@ -21998,9 +22019,6 @@ const FormItem = /* @__PURE__ */ defineComponent({
21998
22019
  dynamicRules,
21999
22020
  required
22000
22021
  } = props2.schema;
22001
- if (props2.schema.component !== "Table") {
22002
- emit("clearCurrValidate", unref(getValues).field);
22003
- }
22004
22022
  if (isFunction$4(dynamicRules)) {
22005
22023
  return dynamicRules(unref(getValues));
22006
22024
  }
@@ -23170,9 +23188,6 @@ const ShyForm = /* @__PURE__ */ defineComponent({
23170
23188
  scrollToField
23171
23189
  };
23172
23190
  provide("formActionType", formActionType);
23173
- const clearCurrValidate = (field) => {
23174
- clearValidate([field]);
23175
- };
23176
23191
  const isTableForm = computed(() => {
23177
23192
  return !!getBindValue.value.tableAction;
23178
23193
  });
@@ -23248,7 +23263,6 @@ const ShyForm = /* @__PURE__ */ defineComponent({
23248
23263
  "allDefaultValues": defaultValueRef.value,
23249
23264
  "formModel": formModel,
23250
23265
  "setFormModel": setFormModel,
23251
- "onClearCurrValidate": clearCurrValidate,
23252
23266
  "class": {
23253
23267
  [`${prefixCls2}-table-form-item`]: isTableForm.value
23254
23268
  },
package/lib/index.js CHANGED
@@ -16294,7 +16294,7 @@ const _sfc_main$X = /* @__PURE__ */ vue.defineComponent({
16294
16294
  });
16295
16295
  const formTable = "";
16296
16296
  const SHOW_ROW_COUNT = 10;
16297
- const ROW_HEIGHT = 48.67;
16297
+ const ROW_HEIGHT = 48.5;
16298
16298
  const BODY_HEIGHT = ROW_HEIGHT * SHOW_ROW_COUNT;
16299
16299
  const ShyFormTable = /* @__PURE__ */ vue.defineComponent({
16300
16300
  props: {
@@ -16558,11 +16558,13 @@ const ShyFormTable = /* @__PURE__ */ vue.defineComponent({
16558
16558
  }, null)])]);
16559
16559
  });
16560
16560
  const create = () => {
16561
- state.value = [{
16561
+ state.value = [...vue.toRaw(state.value), {
16562
16562
  [props2.rowKey]: utils.buildUUID()
16563
- }, ...vue.toRaw(state.value)];
16563
+ }];
16564
16564
  curIndex.value = 0;
16565
- document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = curIndex.value * ROW_HEIGHT;
16565
+ vue.nextTick(() => {
16566
+ document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = (state.value.length + 1) * ROW_HEIGHT;
16567
+ });
16566
16568
  emit("add", state.value);
16567
16569
  };
16568
16570
  const remove = (index2) => {
@@ -16583,7 +16585,7 @@ const ShyFormTable = /* @__PURE__ */ vue.defineComponent({
16583
16585
  }) => {
16584
16586
  var _a2, _b;
16585
16587
  const errKey = `${column2.dataIndex}-${record[props2.rowKey]}Info`;
16586
- if (!column2.required)
16588
+ if (!column2.required && !column2.rules)
16587
16589
  return [];
16588
16590
  if ((_a2 = rulesRef[errKey]) == null ? void 0 : _a2.rules)
16589
16591
  return (_b = rulesRef[errKey]) == null ? void 0 : _b.rules;
@@ -16613,8 +16615,27 @@ const ShyFormTable = /* @__PURE__ */ vue.defineComponent({
16613
16615
  return column2.rules;
16614
16616
  rulesRef[errKey].rules = cloneDeep(column2.rules);
16615
16617
  rulesRef[errKey].rules.forEach((item) => {
16616
- if (!item.validator || !utils.isFunction(item.validator))
16618
+ if (!item.validator || !utils.isFunction(item.validator)) {
16619
+ item.validator = async (rule, value) => {
16620
+ rulesRef[errKey].show = false;
16621
+ if (!rule.pattern && !rule.required)
16622
+ return Promise.resolve();
16623
+ if ((column2.required || rule.required) && isNil(value)) {
16624
+ const prefix = column2.type.toLocaleLowerCase().includes("input") ? "请输入" : "请选择";
16625
+ const errMsg = `${prefix}${column2.title}`;
16626
+ rulesRef[errKey].show = true;
16627
+ rulesRef[errKey].msg = errMsg;
16628
+ return Promise.reject(errMsg);
16629
+ }
16630
+ if (rule.pattern && !rule.pattern.test(value)) {
16631
+ rulesRef[errKey].show = true;
16632
+ rulesRef[errKey].msg = rule.message;
16633
+ return Promise.reject(rule.message);
16634
+ }
16635
+ return Promise.resolve();
16636
+ };
16617
16637
  return;
16638
+ }
16618
16639
  const validator = item.validator;
16619
16640
  item.validator = async (rule, value) => {
16620
16641
  try {
@@ -16696,6 +16717,7 @@ const ShyFormTable = /* @__PURE__ */ vue.defineComponent({
16696
16717
  document.querySelector(`.${prefixCls2}-scroll-bar-wrapper`).scrollTop = curIndex.value * ROW_HEIGHT;
16697
16718
  }, true);
16698
16719
  tableWrapperRef.value.addEventListener("scroll", handleScroll, true);
16720
+ dataSource.value = state.value.length > SHOW_ROW_COUNT ? state.value.slice(curIndex.value, curIndex.value + SHOW_ROW_COUNT) : state.value.slice(0, SHOW_ROW_COUNT);
16699
16721
  });
16700
16722
  vue.onUnmounted(() => {
16701
16723
  window.removeEventListener("scroll", () => {
@@ -21857,7 +21879,6 @@ const FormItem = /* @__PURE__ */ vue.defineComponent({
21857
21879
  type: Boolean
21858
21880
  }
21859
21881
  },
21860
- emits: ["clearCurrValidate"],
21861
21882
  setup(props2, {
21862
21883
  slots,
21863
21884
  emit,
@@ -22022,9 +22043,6 @@ const FormItem = /* @__PURE__ */ vue.defineComponent({
22022
22043
  dynamicRules,
22023
22044
  required
22024
22045
  } = props2.schema;
22025
- if (props2.schema.component !== "Table") {
22026
- emit("clearCurrValidate", vue.unref(getValues).field);
22027
- }
22028
22046
  if (utils.isFunction(dynamicRules)) {
22029
22047
  return dynamicRules(vue.unref(getValues));
22030
22048
  }
@@ -23194,9 +23212,6 @@ const ShyForm = /* @__PURE__ */ vue.defineComponent({
23194
23212
  scrollToField
23195
23213
  };
23196
23214
  vue.provide("formActionType", formActionType);
23197
- const clearCurrValidate = (field) => {
23198
- clearValidate([field]);
23199
- };
23200
23215
  const isTableForm = vue.computed(() => {
23201
23216
  return !!getBindValue.value.tableAction;
23202
23217
  });
@@ -23272,7 +23287,6 @@ const ShyForm = /* @__PURE__ */ vue.defineComponent({
23272
23287
  "allDefaultValues": defaultValueRef.value,
23273
23288
  "formModel": formModel,
23274
23289
  "setFormModel": setFormModel,
23275
- "onClearCurrValidate": clearCurrValidate,
23276
23290
  "class": {
23277
23291
  [`${prefixCls2}-table-form-item`]: isTableForm.value
23278
23292
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3h1-ui",
3
- "version": "3.0.0-next.81",
3
+ "version": "3.0.0-next.83",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -29,9 +29,9 @@
29
29
  "vue-json-pretty": "^2.2.3",
30
30
  "vxe-table": "^4.3.6",
31
31
  "xe-utils": "^3.5.7",
32
- "@shy-plugins/use": "1.0.1-next.3",
33
32
  "@shy-plugins/tinymce": "^1.0.6",
34
- "@shy-plugins/utils": "1.0.0-next.1"
33
+ "@shy-plugins/utils": "1.0.0-next.1",
34
+ "@shy-plugins/use": "1.0.1-next.3"
35
35
  },
36
36
  "types": "es/ui/index.d.ts",
37
37
  "devDependencies": {