knt-shared 1.7.12 → 1.8.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/dist/index.esm.js CHANGED
@@ -3396,6 +3396,13 @@ function getComponent(name) {
3396
3396
  }
3397
3397
  return name;
3398
3398
  }
3399
+ const componentsNeedTrim = /* @__PURE__ */ new Set([
3400
+ "Input",
3401
+ "InputPassword",
3402
+ "Textarea",
3403
+ "AutoComplete",
3404
+ "Mention"
3405
+ ]);
3399
3406
  const componentsNeedPlaceholder = /* @__PURE__ */ new Set([
3400
3407
  "Input",
3401
3408
  "InputNumber",
@@ -4202,6 +4209,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4202
4209
  resetButtonText: { default: "重置" },
4203
4210
  showActionButtons: { type: Boolean, default: true },
4204
4211
  readonly: { type: Boolean },
4212
+ autoTrim: { type: Boolean, default: true },
4205
4213
  context: {}
4206
4214
  },
4207
4215
  emits: ["register", "submit", "reset", "validate"],
@@ -4365,6 +4373,19 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4365
4373
  }
4366
4374
  return (component == null ? void 0 : component.name) || "Input";
4367
4375
  };
4376
+ const shouldTrimField = (schema) => {
4377
+ const componentType = typeof schema.component === "string" ? schema.component : "";
4378
+ if (!componentsNeedTrim.has(componentType)) return false;
4379
+ if (schema.trim !== void 0) return schema.trim;
4380
+ return unref(getProps).autoTrim ?? false;
4381
+ };
4382
+ const handleFieldBlur = (schema) => {
4383
+ if (!shouldTrimField(schema)) return;
4384
+ const val = formModel[schema.field];
4385
+ if (typeof val === "string") {
4386
+ formModel[schema.field] = val.trim();
4387
+ }
4388
+ };
4368
4389
  const renderSlotContent = (slotConfig, slotData) => {
4369
4390
  if (isVNode(slotConfig)) {
4370
4391
  return slotConfig;
@@ -4625,7 +4646,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4625
4646
  modelValue: formModel[schema.field],
4626
4647
  "onUpdate:modelValue": ($event) => formModel[schema.field] = $event,
4627
4648
  placeholder: getPlaceholderText(schema)
4628
- }, { ref_for: true }, getComponentProps(schema)), createSlots({ _: 2 }, [
4649
+ }, { ref_for: true }, getComponentProps(schema), {
4650
+ onBlur: ($event) => handleFieldBlur(schema)
4651
+ }), createSlots({ _: 2 }, [
4629
4652
  renderList(schema.componentSlots, (slotConfig, slotName) => {
4630
4653
  return {
4631
4654
  name: slotName,
@@ -4634,7 +4657,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4634
4657
  ])
4635
4658
  };
4636
4659
  })
4637
- ]), 1040, ["modelValue", "onUpdate:modelValue", "placeholder"]))
4660
+ ]), 1040, ["modelValue", "onUpdate:modelValue", "placeholder", "onBlur"]))
4638
4661
  ];
4639
4662
  }),
4640
4663
  _: 2
@@ -6684,7 +6707,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6684
6707
  selectedRows.value = dedupeRowsByKey([...otherPagesRows, ...frozenRows]);
6685
6708
  }
6686
6709
  }
6687
- emit("selectAll", checked);
6710
+ emit("selectAll", checked, selectableRows, selectableKeys);
6688
6711
  };
6689
6712
  const handleExpand = (record, expanded) => {
6690
6713
  emit("expand", record, expanded);
@@ -7425,7 +7448,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7425
7448
  };
7426
7449
  }
7427
7450
  });
7428
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-4e9be0fe"]]);
7451
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-8f4a5d2c"]]);
7429
7452
  function useTable(options = {}) {
7430
7453
  const tableRef = ref(null);
7431
7454
  const formRef = ref(null);