@qin-ui/antd-vue-pro 1.1.11 → 1.1.13

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/README.md CHANGED
@@ -226,8 +226,8 @@ ant-design-vue ui组件库form组件的二次封装
226
226
  appendField: AppendField;
227
227
  /** 在指定字段数据路径的字段配置前插入新的字段配置 */
228
228
  prependField: PrependField;
229
- /** 获取指定字段数据路径的字段所在分组字段的配置 */
230
- getParentField: GetParentField;
229
+ /** 获取指定字段数据路径的字段所在字段分组 */
230
+ getParentFields: GetParentFields;
231
231
  };
232
232
 
233
233
  /**
@@ -1,4 +1,4 @@
1
- import { inject, ref, h as h$1, getCurrentInstance, nextTick, reactive, defineComponent, createVNode, shallowRef, watch, unref, provide, watchEffect, onBeforeUnmount, computed, isRef, Fragment, Comment, Text, isVNode, onMounted, cloneVNode, Transition, withDirectives, resolveDirective, onUpdated, onUnmounted, toRef, withModifiers, vShow, onBeforeMount, Teleport, TransitionGroup, toRaw, resolveComponent, openBlock, createBlock, mergeProps, withCtx, createElementBlock, renderList, resolveDynamicComponent, normalizeProps, createSlots, createTextVNode, createCommentVNode, useAttrs, renderSlot, toDisplayString, shallowReactive } from "vue";
1
+ import { inject, ref, h as h$1, getCurrentInstance, nextTick, reactive, defineComponent, createVNode, shallowRef, watch, unref, provide, watchEffect, onBeforeUnmount, computed, isRef, Fragment, Comment, Text, isVNode, onMounted, cloneVNode, Transition, withDirectives, resolveDirective, onUpdated, onUnmounted, toRef, withModifiers, vShow, onBeforeMount, Teleport, TransitionGroup, toRaw, resolveComponent, openBlock, createBlock, mergeProps, withCtx, createElementBlock, renderList, resolveDynamicComponent, createSlots, createTextVNode, createCommentVNode, useAttrs, normalizeProps, renderSlot, toDisplayString, shallowReactive } from "vue";
2
2
  import { Input, Textarea, InputSearch, InputPassword, InputNumber, Select, Cascader, DatePicker as DatePicker$1, RangePicker, TimePicker as TimePicker$1, CheckboxGroup, RadioGroup, Switch, Slider, TreeSelect, Transfer, Row as Row$1, Col as Col$1, FormItem as FormItem$1, message, Form as Form$2 } from "ant-design-vue";
3
3
  import { INIT_PROPS_MAP, useInjectProps, INJECT_KEYS } from "../component-provider/index.js";
4
4
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
@@ -15744,15 +15744,15 @@ const UPDATE_ACTIVE_PATH = Symbol(
15744
15744
  "setActivePath"
15745
15745
  );
15746
15746
  const RULE_TYPE_MAP = /* @__PURE__ */ new Map([
15747
- ["value", "字段赋值"],
15748
- ["hidden", "字段隐藏/显示"],
15749
- ["disabled", "字段禁用/启用"],
15750
- ["options", "字段选项枚举变更"],
15751
- ["validateRule", "字段校验规则变更"],
15752
- ["fieldMergeOverrides", "字段配置变更"],
15753
- ["validate", "字段触发校验"],
15754
- ["clearValidate", "字段触发清除校验"],
15755
- ["message", "字段触发提示"]
15747
+ ["setValue", "字段赋值"],
15748
+ ["setHidden", "字段隐藏/显示"],
15749
+ ["setDisabled", "字段禁用/启用"],
15750
+ ["setOptions", "字段选项枚举变更"],
15751
+ ["setRules", "字段校验规则变更"],
15752
+ ["setField", "字段配置变更"],
15753
+ ["triggerValidate", "字段触发校验"],
15754
+ ["triggerClearValidate", "字段触发清除校验"],
15755
+ ["triggerMessage", "字段触发提示"]
15756
15756
  ]);
15757
15757
  const FunctionRegexp = /^\s*function\s*\w*\s*\([^)]*\)\s*{([\s\S]*)}/g;
15758
15758
  const ArrowFunctionRegexp = /^\s*(?:\([^)]*\)|\w+)\s*=>\s*\(?({[\s\S]*}|[^;]*)\)?/g;
@@ -15779,7 +15779,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15779
15779
  "hideFeedback"
15780
15780
  ];
15781
15781
  const props = __props;
15782
- useProviderDisabled(ref(props.disabled));
15782
+ useProviderDisabled(computed(() => props.disabled));
15783
15783
  const updateRefs = inject(UPDATE_REFS);
15784
15784
  const getPath = (fieldKey) => {
15785
15785
  return [props.path, fieldKey].filter(Boolean).join(".");
@@ -15840,14 +15840,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15840
15840
  return openBlock(), createElementBlock(Fragment, {
15841
15841
  key: getPath(field.key) || index2
15842
15842
  }, [
15843
- field && !field.hidden ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.grid ? unref(Col$1) : unref(_sfc_main$2)), normalizeProps(mergeProps({ key: 0 }, _ctx.grid ? unref(withDefaultGridItem)(field) : void 0)), {
15843
+ field && !field.hidden ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.grid ? unref(Col$1) : unref(_sfc_main$2)), mergeProps({
15844
+ key: 0,
15845
+ ref_for: true
15846
+ }, _ctx.grid ? unref(withDefaultGridItem)(field) : void 0), {
15844
15847
  default: withCtx(() => [
15845
15848
  createVNode(unref(_sfc_main$2), {
15846
15849
  component: field.container,
15847
15850
  path: getPath(field.key)
15848
15851
  }, {
15849
15852
  default: withCtx(() => [
15850
- createVNode(unref(FormItem$1), mergeProps(withDefault(field), {
15853
+ createVNode(unref(FormItem$1), mergeProps({ ref_for: true }, withDefault(field), {
15851
15854
  ref_for: true,
15852
15855
  ref: (el) => setFormItemRef(el, field),
15853
15856
  class: field.className,
@@ -15865,7 +15868,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15865
15868
  disabled: field.disabled
15866
15869
  }, null, 8, ["grid", "fields", "path", "disabled"])) : !field.component ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
15867
15870
  createTextVNode(' missing "component" prop ')
15868
- ], 64)) : (openBlock(), createBlock(unref(BaseField), mergeProps({ key: 2 }, unref(omitFormItemProps)(field), {
15871
+ ], 64)) : (openBlock(), createBlock(unref(BaseField), mergeProps({
15872
+ key: 2,
15873
+ ref_for: true
15874
+ }, unref(omitFormItemProps)(field), {
15869
15875
  label: field.label,
15870
15876
  path: getPath(field.key)
15871
15877
  }), null, 16, ["label", "path"]))
@@ -15876,7 +15882,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15876
15882
  return {
15877
15883
  name,
15878
15884
  fn: withCtx(() => [
15879
- unref(FORM_ITEM_SLOT_KEYS).includes(name) ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({ key: 0 }, { path: getPath(field.key) }, { component: slot }), null, 16, ["component"])) : createCommentVNode("", true)
15885
+ unref(FORM_ITEM_SLOT_KEYS).includes(name) ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({
15886
+ key: 0,
15887
+ ref_for: true
15888
+ }, { path: getPath(field.key) }, { component: slot }), null, 16, ["component"])) : createCommentVNode("", true)
15880
15889
  ])
15881
15890
  };
15882
15891
  })
@@ -15896,86 +15905,70 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15896
15905
  }
15897
15906
  });
15898
15907
  const index_vue_vue_type_style_index_0_lang = "";
15899
- const generateFieldMap = (fields, prePath = "", preFieldPath = "", fieldMap = {}) => {
15900
- fields.forEach((field, index2) => {
15901
- let path;
15902
- if (prePath) {
15903
- path = field.key ? `${prePath}.${field.key}` : prePath;
15904
- } else {
15905
- path = field.key || "";
15906
- }
15907
- const fieldPath = `${preFieldPath || ""}[${index2}]`;
15908
- if (path && !fieldMap[path]) {
15909
- fieldMap[path] = { field, fieldPath };
15910
- }
15911
- if (field.fields) {
15912
- generateFieldMap(
15913
- field.fields,
15914
- path,
15915
- `${fieldPath}.fields`,
15916
- fieldMap
15917
- );
15918
- }
15919
- });
15920
- return fieldMap;
15921
- };
15922
15908
  const useFields = (initFields) => {
15923
15909
  const fields = ref(initFields);
15924
- const fieldMap = computed(() => {
15925
- return generateFieldMap(fields.value);
15926
- });
15927
- const getField = (path) => {
15928
- var _a;
15910
+ const updateField = (path, updater, fieldList = fields.value, parentPath = "", parentFieldPath = "", parsedPath = toPath(path).join(".")) => {
15929
15911
  if (!path)
15930
- return void 0;
15931
- return (_a = fieldMap.value[path]) == null ? void 0 : _a.field;
15912
+ return false;
15913
+ for (let i2 = 0; i2 < fieldList.length; i2 += 1) {
15914
+ const field = fieldList[i2];
15915
+ const { key = "" } = field;
15916
+ const concatPath = `${parentPath}${parentPath && key ? "." : ""}${key}`;
15917
+ const selfPath = toPath(concatPath).join(".");
15918
+ if (!parsedPath.startsWith(selfPath))
15919
+ continue;
15920
+ const fieldPath = `${parentFieldPath}[${i2}]`;
15921
+ if (selfPath && selfPath === parsedPath) {
15922
+ updater({ field, fieldIndex: i2, parentFields: fieldList, fieldPath });
15923
+ return true;
15924
+ }
15925
+ if (field.fields && updateField(
15926
+ path,
15927
+ updater,
15928
+ field.fields,
15929
+ selfPath,
15930
+ `${fieldPath}.fields`,
15931
+ parsedPath
15932
+ )) {
15933
+ return true;
15934
+ }
15935
+ }
15936
+ return false;
15932
15937
  };
15933
- const getFieldPath = (path) => {
15934
- var _a;
15938
+ const getField = (path) => {
15935
15939
  if (!path)
15936
15940
  return void 0;
15937
- return (_a = fieldMap.value[path]) == null ? void 0 : _a.fieldPath;
15941
+ let res;
15942
+ updateField(path, ({ field }) => {
15943
+ res = field;
15944
+ });
15945
+ return res;
15938
15946
  };
15939
15947
  const setField = (path, field, updateType = "merge") => {
15940
- const fieldPath = getFieldPath(path);
15941
- if (!fieldPath)
15942
- return;
15943
- let value = field;
15944
- const preField = getField(path);
15945
- if (typeof field === "function") {
15946
- value = field(preField);
15947
- }
15948
- const newField = updateType === "rewrite" ? value : { ...preField, ...value };
15949
- set$1(fields.value, fieldPath, newField);
15950
- };
15951
- function findFieldIndex(path) {
15952
- var _a;
15953
- const fieldPath = getFieldPath(path);
15954
- if (!fieldPath)
15955
- return -1;
15956
- return +(((_a = fieldPath.split(".").at(-1)) == null ? void 0 : _a.replaceAll(/.*\[(\d+)\]/g, "$1")) || -1);
15957
- }
15958
- const getParentField = (path) => {
15959
15948
  if (!path)
15960
- return void 0;
15961
- const groupFieldPath = path.split(".").slice(0, -1).join(".");
15962
- return getField(groupFieldPath);
15949
+ return;
15950
+ updateField(path, ({ field: preField, fieldIndex, parentFields }) => {
15951
+ let value = field;
15952
+ if (typeof field === "function") {
15953
+ value = field(preField);
15954
+ }
15955
+ const newField = updateType === "rewrite" ? value : { ...preField, ...value };
15956
+ parentFields[fieldIndex] = newField;
15957
+ });
15963
15958
  };
15964
15959
  const deleteField = (path) => {
15965
15960
  if (!path)
15966
15961
  return;
15967
- const fieldIndex = findFieldIndex(path);
15968
- const group = getParentField(path);
15969
- const groupFields = group ? group.fields : fields.value;
15970
- groupFields == null ? void 0 : groupFields.splice(fieldIndex, 1);
15962
+ updateField(path, ({ fieldIndex, parentFields }) => {
15963
+ parentFields.splice(fieldIndex, 1);
15964
+ });
15971
15965
  };
15972
15966
  const addField = (path, field, placement) => {
15973
15967
  if (path) {
15974
- const fieldIndex = findFieldIndex(path);
15975
- const group = getParentField(path);
15976
- const groupFields = group ? group.fields : fields.value;
15977
- const index2 = placement === "after" ? fieldIndex + 1 : fieldIndex;
15978
- groupFields.splice(index2, 0, field);
15968
+ updateField(path, ({ fieldIndex, parentFields }) => {
15969
+ const index2 = placement === "after" ? fieldIndex + 1 : fieldIndex;
15970
+ parentFields.splice(index2, 0, field);
15971
+ });
15979
15972
  } else if (placement === "after") {
15980
15973
  fields.value.push(field);
15981
15974
  } else {
@@ -15988,15 +15981,33 @@ const useFields = (initFields) => {
15988
15981
  const prependField = (path, field) => {
15989
15982
  addField(path, field, "before");
15990
15983
  };
15984
+ const getFieldPath = (path) => {
15985
+ if (!path)
15986
+ return void 0;
15987
+ let res;
15988
+ updateField(path, ({ fieldPath }) => {
15989
+ res = fieldPath;
15990
+ });
15991
+ return res;
15992
+ };
15993
+ const getParentFields = (path) => {
15994
+ if (!path)
15995
+ return void 0;
15996
+ let res;
15997
+ updateField(path, ({ parentFields }) => {
15998
+ res = parentFields;
15999
+ });
16000
+ return res;
16001
+ };
15991
16002
  return {
15992
16003
  fields,
15993
16004
  getField,
15994
- getParentField,
15995
16005
  setField,
15996
16006
  deleteField,
15997
- getFieldPath,
15998
16007
  appendField,
15999
- prependField
16008
+ prependField,
16009
+ getFieldPath,
16010
+ getParentFields
16000
16011
  };
16001
16012
  };
16002
16013
  const useFormData = (initFormData) => {
@@ -16191,21 +16202,21 @@ async function runRules(rules2, baseParam) {
16191
16202
  [`${path}`, ["gray"]]
16192
16203
  ]);
16193
16204
  switch (type4) {
16194
- case "value": {
16205
+ case "setValue": {
16195
16206
  form.setFormData(path, value);
16196
16207
  nextTick(() => run(path, "onUpdateValue"));
16197
16208
  break;
16198
16209
  }
16199
- case "hidden":
16200
- form.setField(path, (preField) => ({ ...preField, hidden: value }));
16210
+ case "setHidden":
16211
+ form.setField(path, { hidden: value });
16201
16212
  break;
16202
- case "disabled":
16203
- form.setField(path, (preField) => ({ ...preField, disabled: value }));
16213
+ case "setDisabled":
16214
+ form.setField(path, { disabled: value });
16204
16215
  break;
16205
- case "options":
16206
- form.setField(path, (preField) => ({ ...preField, options: value }));
16216
+ case "setOptions":
16217
+ form.setField(path, { options: value });
16207
16218
  break;
16208
- case "validateRule": {
16219
+ case "setRules": {
16209
16220
  const validateRule2 = [];
16210
16221
  for (let validateRuleIndex = 0; validateRuleIndex < value.length; validateRuleIndex += 1) {
16211
16222
  const validateRuleItem = value[validateRuleIndex];
@@ -16231,14 +16242,14 @@ async function runRules(rules2, baseParam) {
16231
16242
  form.setField(path, (preField) => ({ ...preField, rule: validateRule2 }));
16232
16243
  break;
16233
16244
  }
16234
- case "fieldMergeOverrides":
16245
+ case "setField":
16235
16246
  form.setField(path, (preField) => ({ ...preField, ...value }));
16236
16247
  break;
16237
- case "validate":
16248
+ case "triggerValidate":
16238
16249
  break;
16239
- case "clearValidate":
16250
+ case "triggerClearValidate":
16240
16251
  break;
16241
- case "message":
16252
+ case "triggerMessage":
16242
16253
  message2.info(value);
16243
16254
  break;
16244
16255
  default: {
@@ -16277,8 +16288,8 @@ const runCommands = async ({ path, trigger, ...baseParam }) => {
16277
16288
  ]);
16278
16289
  for (let logicIndex = 0; logicIndex < logics.length; logicIndex += 1) {
16279
16290
  const logic = logics[logicIndex];
16280
- const { conditions, rules: rules2 } = logic;
16281
- if (conditions.length === 0 || rules2.length === 0)
16291
+ const { conditions, actions } = logic;
16292
+ if (conditions.length === 0 || actions.length === 0)
16282
16293
  return;
16283
16294
  logQueue.push([
16284
16295
  [`逻辑${logicIndex + 1}:`, ["large", "purple"]],
@@ -16292,7 +16303,7 @@ const runCommands = async ({ path, trigger, ...baseParam }) => {
16292
16303
  return;
16293
16304
  const conditionsValid = await validateConditions(conditions, baseParam);
16294
16305
  if (conditionsValid) {
16295
- await runRules(rules2, baseParam);
16306
+ await runRules(actions, baseParam);
16296
16307
  }
16297
16308
  }
16298
16309
  logQueue.push([
@@ -16430,8 +16441,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16430
16441
  const methods = { ...rewriteMethod("onUpdateValue") };
16431
16442
  switch (compType) {
16432
16443
  case "input":
16433
- Object.assign(methods, rewriteMethod("onBlur"), rewriteMethod("onFocus"));
16434
- break;
16435
16444
  case "input-number":
16436
16445
  Object.assign(methods, rewriteMethod("onBlur"), rewriteMethod("onFocus"));
16437
16446
  break;
@@ -16453,12 +16462,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16453
16462
  return;
16454
16463
  updateRefs == null ? void 0 : updateRefs("fieldRefs", props.path, el);
16455
16464
  };
16456
- onMounted(() => {
16457
- var _a, _b, _c;
16458
- if (attrs.autoCommand && ((_b = (_a = attrs.autoCommand) == null ? void 0 : _a.onInit) == null ? void 0 : _b.length) > 0) {
16459
- (_c = command == null ? void 0 : command.value) == null ? void 0 : _c.run(props.path, "onInit");
16460
- }
16461
- });
16462
16465
  function handleFocus(...args) {
16463
16466
  var _a;
16464
16467
  updateActivePath == null ? void 0 : updateActivePath(props.path);
@@ -16497,7 +16500,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16497
16500
  };
16498
16501
  }
16499
16502
  });
16500
- const index_vue_vue_type_style_index_0_scoped_9a3bf1a0_lang = "";
16503
+ const index_vue_vue_type_style_index_0_scoped_f87938bb_lang = "";
16501
16504
  const _export_sfc = (sfc, props) => {
16502
16505
  const target = sfc.__vccOpts || sfc;
16503
16506
  for (const [key, val] of props) {
@@ -16505,7 +16508,7 @@ const _export_sfc = (sfc, props) => {
16505
16508
  }
16506
16509
  return target;
16507
16510
  };
16508
- const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-9a3bf1a0"]]);
16511
+ const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f87938bb"]]);
16509
16512
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16510
16513
  ...{
16511
16514
  name: "ContainerFragment",
@@ -16607,10 +16610,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16607
16610
  updateActivePath(path);
16608
16611
  };
16609
16612
  const command = computed(() => {
16610
- return props.form && !props.autoCommandDisabled ? useCommand({
16611
- refs: exposed.refs,
16612
- form: props.form
16613
- }) : null;
16613
+ return props.form && !props.autoCommandDisabled ? useCommand({ refs: exposed.refs, form: props.form }) : null;
16614
16614
  });
16615
16615
  const formInstanceRef = ref(null);
16616
16616
  onMounted(() => {
package/es/form/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { l, B, d, i, C, b, f, F, k, G, R, e, j, U, h, _, m, p, n, s, q, u, r, t } from "./index-2a04ad4a.js";
1
+ import { l, B, d, i, C, b, f, F, k, G, R, e, j, U, h, _, m, p, n, s, q, u, r, t } from "./index-c1a5e7f6.js";
2
2
  import "vue";
3
3
  import "ant-design-vue";
4
4
  import "../component-provider/index.js";