@qin-ui/antd-vue-pro 1.1.16 → 1.1.18

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.
@@ -1,4 +1,4 @@
1
- import { inject, ref, h as h$1, getCurrentInstance, nextTick, reactive, defineComponent, createVNode, shallowRef, watch, unref, provide, watchEffect, onBeforeUnmount, computed, triggerRef, 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, createSlots, createTextVNode, createCommentVNode, useAttrs, resolveDynamicComponent, normalizeProps, 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, triggerRef, 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, createSlots, createTextVNode, createCommentVNode, shallowReadonly, useAttrs, resolveDynamicComponent, 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;
@@ -15191,7 +15191,7 @@ function getPropByPath(obj, path, strict) {
15191
15191
  isValid: tempObj && keyArr[i2] in tempObj
15192
15192
  };
15193
15193
  }
15194
- function useForm$1(modelRef) {
15194
+ function useForm$2(modelRef) {
15195
15195
  let rulesRef = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ref({});
15196
15196
  let options = arguments.length > 2 ? arguments[2] : void 0;
15197
15197
  const initialModel = cloneDeep(unref(modelRef));
@@ -15463,7 +15463,7 @@ const Form = defineComponent({
15463
15463
  colon: true
15464
15464
  }),
15465
15465
  Item: FormItem,
15466
- useForm: useForm$1,
15466
+ useForm: useForm$2,
15467
15467
  // emits: ['finishFailed', 'submit', 'finish', 'validate'],
15468
15468
  setup(props, _ref) {
15469
15469
  let {
@@ -15752,8 +15752,6 @@ const FORM_DATA = Symbol("formData");
15752
15752
  const UPDATE_FORM_DATA = Symbol(
15753
15753
  "updateFormData"
15754
15754
  );
15755
- const UPDATE_REFS = Symbol("updateRefs");
15756
- const GET_REF = Symbol("getRef");
15757
15755
  const COMMAND = Symbol("command");
15758
15756
  const UPDATE_ACTIVE_PATH = Symbol(
15759
15757
  "setActivePath"
@@ -15795,16 +15793,26 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15795
15793
  ];
15796
15794
  const props = __props;
15797
15795
  useProviderDisabled(computed(() => props.disabled));
15798
- const updateRefs = inject(UPDATE_REFS);
15799
15796
  const getPath = (field) => {
15800
15797
  const path = (field == null ? void 0 : field.name) ?? [props.path, field == null ? void 0 : field.key].filter(Boolean);
15801
15798
  return toPath(path).join(".");
15802
15799
  };
15800
+ const formItemRefs = ref();
15803
15801
  const setFormItemRef = (el, field) => {
15802
+ var _a;
15803
+ if (!el)
15804
+ return;
15805
+ if (((_a = field.getFormItemRef) == null ? void 0 : _a.call(field)) === el)
15806
+ return;
15807
+ Object.assign(field, { getFormItemRef: () => el });
15808
+ };
15809
+ const setComponentRef = (el, field) => {
15810
+ var _a;
15804
15811
  if (!el)
15805
15812
  return;
15806
- const path = getPath(field);
15807
- updateRefs == null ? void 0 : updateRefs("formItemRefs", path, el);
15813
+ if (((_a = field.getComponentRef) == null ? void 0 : _a.call(field)) === el)
15814
+ return;
15815
+ Object.assign(field, { getComponentRef: () => el });
15808
15816
  };
15809
15817
  const proFormPropKeys = computed(() => {
15810
15818
  return [
@@ -15869,12 +15877,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15869
15877
  default: withCtx(() => [
15870
15878
  createVNode(unref(FormItem$1), mergeProps({ ref_for: true }, withDefault(field), {
15871
15879
  ref_for: true,
15872
- ref: (el) => setFormItemRef(el, field),
15880
+ ref_key: "formItemRefs",
15881
+ ref: formItemRefs,
15873
15882
  class: field.className,
15874
15883
  style: field.style,
15875
15884
  "hide-feedback": field.hideFeedback,
15876
15885
  name: unref(toPath)(getPath(field)),
15877
- path: getPath(field)
15886
+ path: getPath(field),
15887
+ onVnodeMounted: () => {
15888
+ var _a;
15889
+ return setFormItemRef((_a = formItemRefs.value) == null ? void 0 : _a[index2], field);
15890
+ }
15878
15891
  }), createSlots({
15879
15892
  default: withCtx(() => [
15880
15893
  field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
@@ -15890,8 +15903,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15890
15903
  ref_for: true
15891
15904
  }, unref(omitFormItemProps)(field), {
15892
15905
  label: field.label,
15893
- path: getPath(field)
15894
- }), null, 16, ["label", "path"]))
15906
+ path: getPath(field),
15907
+ onSetComponentRef: (el) => setComponentRef(el, field),
15908
+ onFieldChange: () => {
15909
+ var _a;
15910
+ return (_a = formItemRefs.value) == null ? void 0 : _a[index2].onFieldChange();
15911
+ },
15912
+ onFieldBlur: () => {
15913
+ var _a;
15914
+ return (_a = formItemRefs.value) == null ? void 0 : _a[index2].onFieldBlur();
15915
+ }
15916
+ }), null, 16, ["label", "path", "onSetComponentRef", "onFieldChange", "onFieldBlur"]))
15895
15917
  ]),
15896
15918
  _: 2
15897
15919
  }, [
@@ -15908,7 +15930,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15908
15930
  ])
15909
15931
  };
15910
15932
  })
15911
- ]), 1040, ["class", "style", "hide-feedback", "name", "path"])
15933
+ ]), 1040, ["class", "style", "hide-feedback", "name", "path", "onVnodeMounted"])
15912
15934
  ]),
15913
15935
  _: 2
15914
15936
  }, 1032, ["component", "path"])
@@ -15926,23 +15948,35 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15926
15948
  const index_vue_vue_type_style_index_0_lang = "";
15927
15949
  const useFields = (initFields) => {
15928
15950
  const fields = ref(initFields);
15929
- const updateField = (path, updater, fieldList = fields.value, parentPath = "", parentFieldPath = "", parsedPath = toPath(path).join(".")) => {
15951
+ const updateField = (path, updater, options, fieldList = fields.value, parentPath = "", parentFieldPath = "", parsedPath = typeof path === "function" ? "" : toPath(path).join(".")) => {
15930
15952
  if (!path)
15931
15953
  return false;
15954
+ const { all = false } = options || {};
15932
15955
  for (let i2 = 0; i2 < fieldList.length; i2 += 1) {
15933
15956
  const field = fieldList[i2];
15934
- const { name, key = "" } = field;
15935
- const concatPath = name ?? `${parentPath}${parentPath && key ? "." : ""}${key}`;
15936
- const selfPath = toPath(concatPath).join(".");
15937
- if (parsedPath.includes(".") && !parsedPath.startsWith(selfPath))
15938
- continue;
15939
15957
  const fieldPath = `${parentFieldPath}[${i2}]`;
15940
- if (selfPath && selfPath === parsedPath) {
15958
+ let found = false;
15959
+ let selfPath = "";
15960
+ if (typeof path === "function") {
15961
+ found = path(shallowReadonly(field));
15962
+ } else {
15963
+ const { name, key = "" } = field;
15964
+ const concatPath = name ?? `${parentPath}${parentPath && key ? "." : ""}${key}`;
15965
+ selfPath = toPath(concatPath).join(".");
15966
+ found = !!selfPath && selfPath === parsedPath;
15967
+ }
15968
+ if (found) {
15941
15969
  updater({ field, fieldIndex: i2, parentFields: fieldList, fieldPath });
15942
- return true;
15970
+ if (!all)
15971
+ return true;
15943
15972
  }
15944
- if (field.fields && updateField(path, updater, field.fields, selfPath, `${fieldPath}.fields`, parsedPath)) {
15945
- return true;
15973
+ if (parsedPath.includes(".") && !parsedPath.startsWith(selfPath)) {
15974
+ if (!all)
15975
+ continue;
15976
+ }
15977
+ if (field.fields && updateField(path, updater, options, field.fields, selfPath, `${fieldPath}.fields`, parsedPath)) {
15978
+ if (!all)
15979
+ return true;
15946
15980
  }
15947
15981
  }
15948
15982
  return false;
@@ -15956,26 +15990,39 @@ const useFields = (initFields) => {
15956
15990
  });
15957
15991
  return res;
15958
15992
  };
15959
- const setField = (path, field, updateType = "merge") => {
15960
- if (!path)
15993
+ const setField = (path, field, options) => {
15994
+ if (!path || !field)
15961
15995
  return;
15962
- updateField(path, ({ field: preField, fieldIndex, parentFields }) => {
15963
- let value = field;
15964
- if (typeof field === "function") {
15965
- value = field(preField);
15966
- }
15967
- const newField = updateType === "rewrite" ? value : { ...preField, ...value };
15968
- parentFields[fieldIndex] = newField;
15969
- });
15996
+ const { updateType = "merge", ...rest } = options || {};
15997
+ updateField(
15998
+ path,
15999
+ ({ field: preField, fieldIndex, parentFields }) => {
16000
+ let value = field;
16001
+ if (typeof field === "function") {
16002
+ value = field(preField);
16003
+ }
16004
+ if (!value)
16005
+ return;
16006
+ const newField = updateType === "rewrite" ? value : { ...preField, ...value };
16007
+ parentFields[fieldIndex] = newField;
16008
+ },
16009
+ rest
16010
+ );
15970
16011
  };
15971
- const deleteField = (path) => {
16012
+ const deleteField = (path, options) => {
15972
16013
  if (!path)
15973
16014
  return;
15974
- updateField(path, ({ fieldIndex, parentFields }) => {
15975
- parentFields.splice(fieldIndex, 1);
15976
- });
16015
+ updateField(
16016
+ path,
16017
+ ({ fieldIndex, parentFields }) => {
16018
+ parentFields.splice(fieldIndex, 1);
16019
+ },
16020
+ options
16021
+ );
15977
16022
  };
15978
16023
  const addField = (path, field, placement) => {
16024
+ if (!field)
16025
+ return;
15979
16026
  if (path) {
15980
16027
  updateField(path, ({ fieldIndex, parentFields }) => {
15981
16028
  const index2 = placement === "after" ? fieldIndex + 1 : fieldIndex;
@@ -16022,6 +16069,7 @@ const useFields = (initFields) => {
16022
16069
  getParentFields
16023
16070
  };
16024
16071
  };
16072
+ const useFields$1 = useFields;
16025
16073
  const useFormData = (initFormData) => {
16026
16074
  const formData = ref(initFormData);
16027
16075
  const activePath = ref();
@@ -16057,6 +16105,7 @@ const useFormData = (initFormData) => {
16057
16105
  };
16058
16106
  return { formData, getFormData, setFormData, activePath, setActivePath };
16059
16107
  };
16108
+ const useFormData$1 = useFormData;
16060
16109
  const useFormRef = () => {
16061
16110
  const formRef = ref();
16062
16111
  const setFormRef = (val) => {
@@ -16064,13 +16113,15 @@ const useFormRef = () => {
16064
16113
  };
16065
16114
  return { formRef, setFormRef };
16066
16115
  };
16116
+ const useFormRef$1 = useFormRef;
16067
16117
  const useForm = (initFormData = {}, initFields = []) => {
16068
16118
  return {
16069
- ...useFormData(initFormData),
16070
- ...useFields(initFields),
16071
- ...useFormRef()
16119
+ ...useFormData$1(initFormData),
16120
+ ...useFields$1(initFields),
16121
+ ...useFormRef$1()
16072
16122
  };
16073
16123
  };
16124
+ const useForm$1 = useForm;
16074
16125
  const isFunctionString = (param) => {
16075
16126
  FunctionRegexp.lastIndex = 0;
16076
16127
  ArrowFunctionRegexp.lastIndex = 0;
@@ -16187,7 +16238,7 @@ async function validateConditions(conditions, baseParam) {
16187
16238
  return result;
16188
16239
  }
16189
16240
  async function runRules(rules2, baseParam) {
16190
- const { form, run, refs, message: message2, logQueue } = baseParam;
16241
+ const { form, run, message: message2, logQueue } = baseParam;
16191
16242
  logQueue.push([[`逻辑执行规则: `, ["purple", "indent2"]]]);
16192
16243
  for (let ruleIndex = 0; ruleIndex < rules2.length; ruleIndex += 1) {
16193
16244
  const rule = rules2[ruleIndex];
@@ -16326,7 +16377,7 @@ const runCommands = async ({ path, trigger, ...baseParam }) => {
16326
16377
  ]);
16327
16378
  }
16328
16379
  };
16329
- const useCommand = ({ refs, form }) => {
16380
+ const useCommand = (form) => {
16330
16381
  let message$1;
16331
16382
  try {
16332
16383
  message$1 = message;
@@ -16340,7 +16391,6 @@ const useCommand = ({ refs, form }) => {
16340
16391
  path,
16341
16392
  trigger,
16342
16393
  form,
16343
- refs,
16344
16394
  message: message$1,
16345
16395
  run,
16346
16396
  logQueue
@@ -16359,6 +16409,7 @@ const useCommand = ({ refs, form }) => {
16359
16409
  };
16360
16410
  return { run };
16361
16411
  };
16412
+ const useCommand$1 = useCommand;
16362
16413
  const useInitProps = () => {
16363
16414
  const initPropsMap = /* @__PURE__ */ new Map();
16364
16415
  INIT_PROPS_MAP.forEach((val, key) => {
@@ -16375,6 +16426,7 @@ const useInitProps = () => {
16375
16426
  };
16376
16427
  return { getInitProps };
16377
16428
  };
16429
+ const useInitProps$1 = useInitProps;
16378
16430
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16379
16431
  ...{
16380
16432
  name: "BaseField"
@@ -16385,20 +16437,23 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16385
16437
  path: { default: "" },
16386
16438
  label: { default: "" }
16387
16439
  },
16388
- setup(__props) {
16440
+ emits: ["setComponentRef", "fieldChange", "fieldBlur"],
16441
+ setup(__props, { emit: __emit }) {
16389
16442
  const props = __props;
16443
+ const emit = __emit;
16390
16444
  const formData = inject(FORM_DATA);
16391
16445
  const updateFormData = inject(UPDATE_FORM_DATA);
16392
- const updateRefs = inject(UPDATE_REFS);
16393
- const getRef = inject(GET_REF);
16394
16446
  const command = inject(COMMAND);
16395
16447
  const updateActivePath = inject(UPDATE_ACTIVE_PATH);
16396
- const { getInitProps } = useInitProps();
16397
- const triggerRefChange = () => {
16448
+ const { getInitProps } = useInitProps$1();
16449
+ const componentRef = ref();
16450
+ const componentMounted = () => {
16451
+ emit("setComponentRef", componentRef.value);
16452
+ };
16453
+ const triggerFormItemChange = () => {
16398
16454
  if (typeof props.component === "string" && COMPONENT_MAP.has(props.component))
16399
16455
  return;
16400
- const formItemRef = getRef == null ? void 0 : getRef("formItemRefs", props.path);
16401
- formItemRef == null ? void 0 : formItemRef.onFieldChange();
16456
+ emit("fieldChange");
16402
16457
  };
16403
16458
  const value = computed({
16404
16459
  get() {
@@ -16411,7 +16466,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16411
16466
  return;
16412
16467
  }
16413
16468
  updateFormData == null ? void 0 : updateFormData(props.path, val);
16414
- triggerRefChange();
16469
+ triggerFormItemChange();
16415
16470
  }
16416
16471
  });
16417
16472
  const forceUpdateKey = ref(0);
@@ -16472,11 +16527,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16472
16527
  const is = computed(() => {
16473
16528
  return COMPONENT_MAP.get(props.component) ?? props.component;
16474
16529
  });
16475
- const setComponentRef = (el) => {
16476
- if (!el)
16477
- return;
16478
- updateRefs == null ? void 0 : updateRefs("fieldRefs", props.path, el);
16479
- };
16480
16530
  function handleFocus(...args) {
16481
16531
  var _a;
16482
16532
  updateActivePath == null ? void 0 : updateActivePath(props.path);
@@ -16489,12 +16539,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16489
16539
  }, {
16490
16540
  default: withCtx(() => [
16491
16541
  (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: forceUpdateKey.value }, unref(omit$1)(mergedAttrs.value, "componentContainer"), {
16492
- ref: setComponentRef,
16542
+ ref_key: "componentRef",
16543
+ ref: componentRef,
16493
16544
  [modelName.value]: value.value,
16494
16545
  ["onUpdate:" + modelName.value]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
16495
16546
  class: [unref(attrs).componentClassName, "field-component"],
16496
16547
  style: unref(attrs).componentStyle,
16497
16548
  path: _ctx.path,
16549
+ onVnodeMounted: componentMounted,
16498
16550
  onFocus: handleFocus
16499
16551
  }), createSlots({ _: 2 }, [
16500
16552
  renderList(unref(attrs).slots, (slot, name) => {
@@ -16515,7 +16567,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16515
16567
  };
16516
16568
  }
16517
16569
  });
16518
- const index_vue_vue_type_style_index_0_scoped_5475a3b8_lang = "";
16570
+ const index_vue_vue_type_style_index_0_scoped_aebf904c_lang = "";
16519
16571
  const _export_sfc = (sfc, props) => {
16520
16572
  const target = sfc.__vccOpts || sfc;
16521
16573
  for (const [key, val] of props) {
@@ -16523,7 +16575,7 @@ const _export_sfc = (sfc, props) => {
16523
16575
  }
16524
16576
  return target;
16525
16577
  };
16526
- const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-5475a3b8"]]);
16578
+ const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-aebf904c"]]);
16527
16579
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16528
16580
  ...{
16529
16581
  name: "ContainerFragment",
@@ -16580,19 +16632,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16580
16632
  const injectProps = useInjectProps(INJECT_KEYS["pro-form"]);
16581
16633
  const injectAttrs = omit$1(injectProps, Object.keys(props));
16582
16634
  const emit = __emit;
16583
- const refs = {
16584
- formItemRefs: {},
16585
- fieldRefs: {}
16586
- };
16587
- const updateRefs = (type4, path, childRef) => {
16588
- if (!path)
16589
- return;
16590
- refs[type4][path] = childRef;
16591
- };
16592
- const getRef = (type4, path) => {
16593
- return refs[type4][path];
16594
- };
16595
- const exposed = shallowReactive({ refs, getRef });
16596
16635
  const updateActivePath = (path) => {
16597
16636
  var _a, _b;
16598
16637
  if (props.form) {
@@ -16625,8 +16664,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16625
16664
  updateActivePath(path);
16626
16665
  };
16627
16666
  const command = computed(() => {
16628
- return props.form && !props.autoCommandDisabled ? useCommand({ refs: exposed.refs, form: props.form }) : null;
16667
+ return props.form && !props.autoCommandDisabled ? useCommand$1(props.form) : null;
16629
16668
  });
16669
+ const exposed = shallowReactive({});
16630
16670
  const formInstanceRef = ref(null);
16631
16671
  onMounted(() => {
16632
16672
  var _a;
@@ -16639,8 +16679,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16639
16679
  });
16640
16680
  provide(FORM_DATA, _formData);
16641
16681
  provide(UPDATE_FORM_DATA, updateFormData);
16642
- provide(UPDATE_REFS, updateRefs);
16643
- provide(GET_REF, getRef);
16644
16682
  provide(COMMAND, command);
16645
16683
  provide(UPDATE_ACTIVE_PATH, updateActivePath);
16646
16684
  __expose(exposed);
@@ -16668,7 +16706,6 @@ export {
16668
16706
  BaseField as B,
16669
16707
  COMPONENT_MAP as C,
16670
16708
  FORM_ITEM_SLOT_KEYS as F,
16671
- GET_REF as G,
16672
16709
  RULE_TYPE_MAP as R,
16673
16710
  UPDATE_FORM_DATA as U,
16674
16711
  _sfc_main as _,
@@ -16679,18 +16716,17 @@ export {
16679
16716
  _sfc_main$1 as e,
16680
16717
  FORM_DATA as f,
16681
16718
  get$1 as g,
16682
- UPDATE_REFS as h,
16683
- COMMAND as i,
16684
- UPDATE_ACTIVE_PATH as j,
16685
- FunctionRegexp as k,
16686
- ArrowFunctionRegexp as l,
16687
- isFunctionString as m,
16688
- jsonStringifyReplacer as n,
16719
+ COMMAND as h,
16720
+ UPDATE_ACTIVE_PATH as i,
16721
+ FunctionRegexp as j,
16722
+ ArrowFunctionRegexp as k,
16723
+ isFunctionString as l,
16724
+ jsonStringifyReplacer as m,
16725
+ jsonParseReviver as n,
16689
16726
  omit$1 as o,
16690
- jsonParseReviver as p,
16691
- useFields as q,
16692
- useFormData as r,
16693
- useCommand as s,
16694
- useInitProps as t,
16695
- useForm as u
16727
+ useFields$1 as p,
16728
+ useFormData$1 as q,
16729
+ useCommand$1 as r,
16730
+ useInitProps$1 as s,
16731
+ useForm$1 as u
16696
16732
  };
package/es/form/index.js CHANGED
@@ -1,30 +1,28 @@
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-f9088d5a.js";
1
+ import { k, B, d, h, C, b, f, F, j, R, e, i, U, _, l, n, m, r, p, u, q, s } from "./index-e6fc6e90.js";
2
2
  import "vue";
3
3
  import "ant-design-vue";
4
4
  import "../component-provider/index.js";
5
5
  export {
6
- l as ArrowFunctionRegexp,
6
+ k as ArrowFunctionRegexp,
7
7
  B as BaseField,
8
8
  d as BaseFormItem,
9
- i as COMMAND,
9
+ h as COMMAND,
10
10
  C as COMPONENT_MAP,
11
11
  b as ContainerFragment,
12
12
  f as FORM_DATA,
13
13
  F as FORM_ITEM_SLOT_KEYS,
14
- k as FunctionRegexp,
15
- G as GET_REF,
14
+ j as FunctionRegexp,
16
15
  R as RULE_TYPE_MAP,
17
16
  e as SlotComponent,
18
- j as UPDATE_ACTIVE_PATH,
17
+ i as UPDATE_ACTIVE_PATH,
19
18
  U as UPDATE_FORM_DATA,
20
- h as UPDATE_REFS,
21
19
  _ as default,
22
- m as isFunctionString,
23
- p as jsonParseReviver,
24
- n as jsonStringifyReplacer,
25
- s as useCommand,
26
- q as useFields,
20
+ l as isFunctionString,
21
+ n as jsonParseReviver,
22
+ m as jsonStringifyReplacer,
23
+ r as useCommand,
24
+ p as useFields,
27
25
  u as useForm,
28
- r as useFormData,
29
- t as useInitProps
26
+ q as useFormData,
27
+ s as useInitProps
30
28
  };
package/es/index.d.ts CHANGED
@@ -258,14 +258,22 @@ export declare const BaseField: DefineComponent<ExtractPropTypes<__VLS_WithDefau
258
258
  path: string;
259
259
  label: string;
260
260
  getFormItemRef: undefined;
261
- }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_3<__VLS_TypePropsToRuntimeProps_3<Props_3>, {
261
+ }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
262
+ setComponentRef: (el: any) => void;
263
+ fieldChange: () => void;
264
+ fieldBlur: () => void;
265
+ }, string, PublicProps, Readonly<ExtractPropTypes<__VLS_WithDefaults_3<__VLS_TypePropsToRuntimeProps_3<Props_3>, {
262
266
  component: () => VNode<RendererNode, RendererElement, {
263
267
  [key: string]: any;
264
268
  }>;
265
269
  path: string;
266
270
  label: string;
267
271
  getFormItemRef: undefined;
268
- }>>> & Readonly<{}>, {
272
+ }>>> & Readonly<{
273
+ onSetComponentRef?: ((el: any) => any) | undefined;
274
+ onFieldChange?: (() => any) | undefined;
275
+ onFieldBlur?: (() => any) | undefined;
276
+ }>, {
269
277
  label: SlotComponentType;
270
278
  component: "input" | "textarea" | "input-password" | "input-search" | "input-number" | "select" | "cascader" | "date-picker" | "range-picker" | "time-picker" | "checkbox-group" | "radio-group" | "switch" | "slider" | "tree-select" | "transfer" | RenderComponentType | Raw<RenderComponentType>;
271
279
  path: string;
@@ -439,8 +447,6 @@ declare const _default_2: __VLS_WithTemplateSlots<DefineComponent<ExtractPropTyp
439
447
  autoCommandDisabled: boolean;
440
448
  activePath: undefined;
441
449
  }>>, {
442
- refs: Refs;
443
- getRef: GetRef;
444
450
  resetFields: (name?: NamePath | undefined) => void;
445
451
  clearValidate: (name?: NamePath | undefined) => void;
446
452
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
@@ -1136,7 +1142,7 @@ declare type DefaultProps = {
1136
1142
  [key: string]: any;
1137
1143
  };
1138
1144
 
1139
- export declare type DeleteField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => void;
1145
+ export declare type DeleteField<D extends FormData_2 = FormData_2> = (path: Path<D>, options?: UpdateFieldOptions) => void;
1140
1146
 
1141
1147
  /**
1142
1148
  * @type {string} Expression - 表达式字符串 需要是一个js表达式字符串或者一个函数字符串,表达式的执行结果或者函数的返回值将作为结果返回
@@ -1248,6 +1254,8 @@ export declare type FieldType = {
1248
1254
  } & Record<string, any>;
1249
1255
  };
1250
1256
 
1257
+ export declare type FindBy<D extends FormData_2 = FormData_2> = (field: Readonly<Field<D>>) => boolean;
1258
+
1251
1259
  declare type FlattenKeys<T, P extends string = ''> = T extends FormData_2 ? {
1252
1260
  [K in keyof KnownKeys<T>]: K extends string ? KnownKeys<T>[K] extends any[] ? `${P}${K}` | K : `${P}${K}` | K | FlattenKeys<T[K], `${P}${K}.`> extends infer U ? U extends `${infer V}.` ? V : U : never : never;
1253
1261
  }[keyof KnownKeys<T>] : P;
@@ -1272,20 +1280,13 @@ declare interface FormProps extends FormProps_2 {
1272
1280
  */
1273
1281
  export declare const FunctionRegexp: RegExp;
1274
1282
 
1275
- export declare const GET_REF: InjectionKey<GetRef>;
1283
+ export declare type GetField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Readonly<WithRefGetter<Field<D>>> | undefined;
1276
1284
 
1277
- export declare type GetField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Field<D> | undefined;
1278
-
1279
- export declare type GetFieldPath<D extends FormData_2 = FormData_2> = (path?: Path<D>) => string | undefined;
1285
+ export declare type GetFieldPath<D extends FormData_2 = FormData_2> = (path: Path<D>) => string | undefined;
1280
1286
 
1281
1287
  export declare type GetFormData<D extends FormData_2 = FormData_2> = (path?: Path<D>) => DeepReadonly<any>;
1282
1288
 
1283
- export declare type GetParentFields<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Field<D> | undefined;
1284
-
1285
- export declare type GetRef = {
1286
- (type: 'formItemRefs', path: string): FormItemInstance;
1287
- (type: 'fieldRefs', path: string): any;
1288
- };
1289
+ export declare type GetParentFields<D extends FormData_2 = FormData_2> = (path: Path<D>) => Fields<D> | undefined;
1289
1290
 
1290
1291
  export declare type Grid = boolean | RowProps;
1291
1292
 
@@ -2035,8 +2036,6 @@ export declare const ProForm: SFCWithInstall<{
2035
2036
  "onUpdate:formData"?: ((val: FormData_2) => any) | undefined;
2036
2037
  "onUpdate:activePath"?: ((val: string | undefined) => any) | undefined;
2037
2038
  }>, {
2038
- refs: Refs;
2039
- getRef: GetRef;
2040
2039
  resetFields: (name?: NamePath | undefined) => void;
2041
2040
  clearValidate: (name?: NamePath | undefined) => void;
2042
2041
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
@@ -2235,8 +2234,6 @@ export declare const ProForm: SFCWithInstall<{
2235
2234
  "onUpdate:formData"?: ((val: FormData_2) => any) | undefined;
2236
2235
  "onUpdate:activePath"?: ((val: string | undefined) => any) | undefined;
2237
2236
  }>, {
2238
- refs: Refs;
2239
- getRef: GetRef;
2240
2237
  resetFields: (name?: NamePath | undefined) => void;
2241
2238
  clearValidate: (name?: NamePath | undefined) => void;
2242
2239
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
@@ -2429,8 +2426,6 @@ export declare const ProForm: SFCWithInstall<{
2429
2426
  "onUpdate:formData"?: ((val: FormData_2) => any) | undefined;
2430
2427
  "onUpdate:activePath"?: ((val: string | undefined) => any) | undefined;
2431
2428
  }>, {
2432
- refs: Refs;
2433
- getRef: GetRef;
2434
2429
  resetFields: (name?: NamePath | undefined) => void;
2435
2430
  clearValidate: (name?: NamePath | undefined) => void;
2436
2431
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<{
@@ -5527,11 +5522,6 @@ export declare type ProTableProps = ProTableInstance['$props'];
5527
5522
 
5528
5523
  declare type RangePickerSlots = FieldSlot<'dateRender' | 'renderExtraFooter' | 'separator'>;
5529
5524
 
5530
- export declare type Refs = {
5531
- formItemRefs: Record<string, FormItemInstance>;
5532
- fieldRefs: Record<string, any>;
5533
- };
5534
-
5535
5525
  /**
5536
5526
  * @description 自定义组件
5537
5527
  * @example (p, ctx) => h('div', ctx.attrs)
@@ -5544,7 +5534,12 @@ declare type SelectSlots = FieldSlot<keyof InstanceType<typeof Select>['$slots']
5544
5534
 
5545
5535
  export declare type SetActivePath<D extends FormData_2 = FormData_2> = (path: Path<D> | undefined) => void;
5546
5536
 
5547
- export declare type SetField<D extends FormData_2 = FormData_2> = (path: Path<D> | undefined, field: Field<D> | ((preField: ReturnType<GetField<D>>) => Field<D>), updateType?: 'rewrite' | 'merge') => void;
5537
+ export declare type SetField<D extends FormData_2 = FormData_2> = (path: Path<D> | FindBy<D> | undefined, field: Field<D> | ((preField: Readonly<Field<D>>) => Field<D>), options?: {
5538
+ /**
5539
+ * 更新方式 rewrite替换重写,merge合并(默认)
5540
+ */
5541
+ updateType?: 'rewrite' | 'merge';
5542
+ } & UpdateFieldOptions) => void;
5548
5543
 
5549
5544
  export declare type SetFormData<D extends FormData_2 = FormData_2> = {
5550
5545
  (path: Path<D>, value: any | ((preValue: DeepReadonly<any>) => any)): void;
@@ -5589,16 +5584,16 @@ export declare const UPDATE_ACTIVE_PATH: InjectionKey<SetActivePath>;
5589
5584
 
5590
5585
  export declare const UPDATE_FORM_DATA: InjectionKey<UpdateFormData>;
5591
5586
 
5592
- export declare const UPDATE_REFS: InjectionKey<UpdateRefs>;
5587
+ export declare type UpdateFieldOptions = {
5588
+ /**
5589
+ * 更新所有符合条件的字段,默认false(仅更新第一个)
5590
+ */
5591
+ all?: boolean;
5592
+ };
5593
5593
 
5594
5594
  export declare type UpdateFormData = (path: string, value: any) => void;
5595
5595
 
5596
- export declare type UpdateRefs = (type: keyof Refs, path: string, childRef: Record<string, any>) => void;
5597
-
5598
- export declare type UseCommand = (param: {
5599
- refs: Refs;
5600
- form: Form;
5601
- }) => {
5596
+ export declare type UseCommand = (form: Form) => {
5602
5597
  run: (path: string, trigger: CommandTrigger) => void;
5603
5598
  };
5604
5599
 
@@ -5616,7 +5611,7 @@ export declare type UseFields<D extends FormData_2 = FormData_2> = (initFields:
5616
5611
  getField: GetField<D>;
5617
5612
  /** 设置指定字段数据路径的字段配置 */
5618
5613
  setField: SetField<D>;
5619
- /** 删除指定字段数据路径的字段配置 */
5614
+ /** 删除指定字段数据路径的字段配置, 或许你更应该使用setField(path, { hidden: true })来隐藏字段 */
5620
5615
  deleteField: DeleteField<D>;
5621
5616
  /** 根据字段数据路径获取字段配置路径 */
5622
5617
  getFieldPath: GetFieldPath<D>;
@@ -5690,4 +5685,9 @@ declare type VModelProps<T = any> = {
5690
5685
  'onUpdate:value'?: (val: T) => void;
5691
5686
  };
5692
5687
 
5688
+ export declare type WithRefGetter<T> = T & {
5689
+ getFormItemRef?: () => FormItemInstance;
5690
+ getComponentRef?: () => any;
5691
+ };
5692
+
5693
5693
  export { }
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./style.css";
2
- import { _ as _sfc_main } from "./form/index-f9088d5a.js";
3
- 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 "./form/index-f9088d5a.js";
2
+ import { _ as _sfc_main } from "./form/index-e6fc6e90.js";
3
+ import { k, B, d, h, C, b, f, F, j, R, e, i, U, l, n, m, r, p, u, q, s } from "./form/index-e6fc6e90.js";
4
4
  import BaseTable from "./table/index.js";
5
5
  import { useTable } from "./table/index.js";
6
6
  import _sfc_main$1 from "./component-provider/index.js";
@@ -25,16 +25,15 @@ const index = {
25
25
  }
26
26
  };
27
27
  export {
28
- l as ArrowFunctionRegexp,
28
+ k as ArrowFunctionRegexp,
29
29
  B as BaseField,
30
30
  d as BaseFormItem,
31
- i as COMMAND,
31
+ h as COMMAND,
32
32
  C as COMPONENT_MAP,
33
33
  b as ContainerFragment,
34
34
  f as FORM_DATA,
35
35
  F as FORM_ITEM_SLOT_KEYS,
36
- k as FunctionRegexp,
37
- G as GET_REF,
36
+ j as FunctionRegexp,
38
37
  INIT_PROPS_MAP,
39
38
  INJECT_KEYS,
40
39
  ProComponentProvider,
@@ -42,18 +41,17 @@ export {
42
41
  ProTable,
43
42
  R as RULE_TYPE_MAP,
44
43
  e as SlotComponent,
45
- j as UPDATE_ACTIVE_PATH,
44
+ i as UPDATE_ACTIVE_PATH,
46
45
  U as UPDATE_FORM_DATA,
47
- h as UPDATE_REFS,
48
46
  index as default,
49
- m as isFunctionString,
50
- p as jsonParseReviver,
51
- n as jsonStringifyReplacer,
52
- s as useCommand,
53
- q as useFields,
47
+ l as isFunctionString,
48
+ n as jsonParseReviver,
49
+ m as jsonStringifyReplacer,
50
+ r as useCommand,
51
+ p as useFields,
54
52
  u as useForm,
55
- r as useFormData,
56
- t as useInitProps,
53
+ q as useFormData,
54
+ s as useInitProps,
57
55
  useInjectProps,
58
56
  useProviderProps,
59
57
  useTable
package/es/style.css CHANGED
@@ -1,7 +1,7 @@
1
1
  .ant-form-item:has(> [hide-feedback='true']) {
2
2
  margin-bottom: 0;
3
3
  }
4
- .field-component[data-v-5475a3b8]:not(.ant-switch) {
4
+ .field-component[data-v-aebf904c]:not(.ant-switch) {
5
5
  width: 100%;
6
6
  min-width: 120px;
7
7
  }
package/es/table/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createVNode, defineComponent, ref, onMounted, openBlock, createElementBlock, unref, normalizeStyle, createElementVNode, withCtx, createTextVNode, createBlock, toDisplayString, createCommentVNode, mergeModels, useModel, computed, watch, Fragment, renderList, withModifiers, renderSlot, useAttrs, useSlots, mergeProps, createSlots, normalizeProps, guardReactiveProps, nextTick } from "vue";
2
2
  import { Button, Space, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
3
3
  import { useInjectProps, INJECT_KEYS } from "../component-provider/index.js";
4
- import { A as AntdIcon, _ as _sfc_main$6, g as get, a as _export_sfc, o as omit, b as _sfc_main$7, c as cloneDeep, u as useForm } from "../form/index-f9088d5a.js";
4
+ import { A as AntdIcon, _ as _sfc_main$6, g as get, a as _export_sfc, o as omit, b as _sfc_main$7, c as cloneDeep, u as useForm } from "../form/index-e6fc6e90.js";
5
5
  var ColumnHeightOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M840 836H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm0-724H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM610.8 378c6 0 9.4-7 5.7-11.7L515.7 238.7a7.14 7.14 0 00-11.3 0L403.6 366.3a7.23 7.23 0 005.7 11.7H476v268h-62.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V378h62.8z" } }] }, "name": "column-height", "theme": "outlined" };
6
6
  const ColumnHeightOutlinedSvg = ColumnHeightOutlined$2;
7
7
  function _objectSpread$2(target) {
@@ -670,7 +670,8 @@ const useTable = ({
670
670
  resetQueryParams
671
671
  };
672
672
  };
673
+ const useTable$1 = useTable;
673
674
  export {
674
675
  BaseTable as default,
675
- useTable
676
+ useTable$1 as useTable
676
677
  };
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
- "main": "",
6
+ "main": "es/index.js",
7
7
  "module": "es/index.js",
8
8
  "types": "es/index.d.ts",
9
9
  "files": [
10
- "es"
10
+ "es",
11
+ "README.md",
12
+ "LICENSE"
11
13
  ],
12
14
  "homepage": "https://github.com/dufan3715/pro-components.git",
13
15
  "repository": {
@@ -17,12 +19,6 @@
17
19
  "scripts": {
18
20
  "build": "vue-tsc && vite build"
19
21
  },
20
- "keywords": [
21
- "vue",
22
- "ant-design-vue",
23
- "antd-vue-pro",
24
- "form components"
25
- ],
26
22
  "author": "dufan3715",
27
23
  "license": "MIT",
28
24
  "private": false,
@@ -35,8 +31,29 @@
35
31
  },
36
32
  "devDependencies": {
37
33
  "@ant-design/icons-vue": "^7.0.1",
34
+ "@types/lodash-es": "^4.17.12",
38
35
  "ant-design-vue": "^4.2.5",
39
36
  "lodash-es": "^4.17.21",
40
37
  "vue": "^3.5.12"
41
- }
38
+ },
39
+ "sideEffects": false,
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "registry": "https://registry.npmjs.org/"
43
+ },
44
+ "engines": {
45
+ "node": ">=16"
46
+ },
47
+ "keywords": [
48
+ "vue",
49
+ "antd",
50
+ "ant-design-vue",
51
+ "antd-vue-pro",
52
+ "pro-components",
53
+ "ui",
54
+ "form",
55
+ "table",
56
+ "pro-form",
57
+ "pro-table"
58
+ ]
42
59
  }