@qin-ui/antd-vue-pro 1.1.15 → 1.1.17

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, resolveDynamicComponent, createSlots, createTextVNode, createCommentVNode, useAttrs, 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;
@@ -15796,13 +15796,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15796
15796
  const props = __props;
15797
15797
  useProviderDisabled(computed(() => props.disabled));
15798
15798
  const updateRefs = inject(UPDATE_REFS);
15799
- const getPath = (fieldKey) => {
15800
- return [props.path, fieldKey].filter(Boolean).join(".");
15799
+ const getPath = (field) => {
15800
+ const path = (field == null ? void 0 : field.name) ?? [props.path, field == null ? void 0 : field.key].filter(Boolean);
15801
+ return toPath(path).join(".");
15801
15802
  };
15802
15803
  const setFormItemRef = (el, field) => {
15803
15804
  if (!el)
15804
15805
  return;
15805
- const path = getPath(field.key);
15806
+ const path = getPath(field);
15806
15807
  updateRefs == null ? void 0 : updateRefs("formItemRefs", path, el);
15807
15808
  };
15808
15809
  const proFormPropKeys = computed(() => {
@@ -15853,16 +15854,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15853
15854
  default: withCtx(() => [
15854
15855
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fields, (field, index2) => {
15855
15856
  return openBlock(), createElementBlock(Fragment, {
15856
- key: getPath(field.key) || index2
15857
+ key: getPath(field) || index2
15857
15858
  }, [
15858
- field && !field.hidden ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.grid ? unref(Col$1) : unref(_sfc_main$2)), mergeProps({
15859
+ field && !field.hidden ? (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({
15859
15860
  key: 0,
15861
+ component: _ctx.grid ? unref(Col$1) : void 0,
15860
15862
  ref_for: true
15861
- }, _ctx.grid ? unref(withDefaultGridItem)(field) : void 0), {
15863
+ }, unref(withDefaultGridItem)(field)), {
15862
15864
  default: withCtx(() => [
15863
15865
  createVNode(unref(_sfc_main$2), {
15864
15866
  component: field.container,
15865
- path: getPath(field.key)
15867
+ path: getPath(field)
15866
15868
  }, {
15867
15869
  default: withCtx(() => [
15868
15870
  createVNode(unref(FormItem$1), mergeProps({ ref_for: true }, withDefault(field), {
@@ -15871,15 +15873,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15871
15873
  class: field.className,
15872
15874
  style: field.style,
15873
15875
  "hide-feedback": field.hideFeedback,
15874
- name: _ctx.path ? unref(toPath)(getPath(field.key)) : getPath(field.key),
15875
- path: getPath(field.key)
15876
+ name: unref(toPath)(getPath(field)),
15877
+ path: getPath(field)
15876
15878
  }), createSlots({
15877
15879
  default: withCtx(() => [
15878
15880
  field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
15879
15881
  key: 0,
15880
15882
  grid: field.grid ?? _ctx.grid,
15881
15883
  fields: field.fields,
15882
- path: getPath(field.key),
15884
+ path: getPath(field),
15883
15885
  disabled: field.disabled
15884
15886
  }, null, 8, ["grid", "fields", "path", "disabled"])) : !field.component ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
15885
15887
  createTextVNode(' missing "component" prop ')
@@ -15888,7 +15890,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15888
15890
  ref_for: true
15889
15891
  }, unref(omitFormItemProps)(field), {
15890
15892
  label: field.label,
15891
- path: getPath(field.key)
15893
+ path: getPath(field)
15892
15894
  }), null, 16, ["label", "path"]))
15893
15895
  ]),
15894
15896
  _: 2
@@ -15896,11 +15898,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15896
15898
  renderList(field.slots, (slot, name) => {
15897
15899
  return {
15898
15900
  name,
15899
- fn: withCtx(() => [
15901
+ fn: withCtx((scoped) => [
15900
15902
  unref(FORM_ITEM_SLOT_KEYS).includes(name) ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({
15901
15903
  key: 0,
15904
+ path: getPath(field),
15905
+ component: slot,
15902
15906
  ref_for: true
15903
- }, { path: getPath(field.key) }, { component: slot }), null, 16, ["component"])) : createCommentVNode("", true)
15907
+ }, scoped), null, 16, ["path", "component"])) : createCommentVNode("", true)
15904
15908
  ])
15905
15909
  };
15906
15910
  })
@@ -15910,7 +15914,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15910
15914
  }, 1032, ["component", "path"])
15911
15915
  ]),
15912
15916
  _: 2
15913
- }, 1040)) : createCommentVNode("", true)
15917
+ }, 1040, ["component"])) : createCommentVNode("", true)
15914
15918
  ], 64);
15915
15919
  }), 128))
15916
15920
  ]),
@@ -15922,30 +15926,35 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15922
15926
  const index_vue_vue_type_style_index_0_lang = "";
15923
15927
  const useFields = (initFields) => {
15924
15928
  const fields = ref(initFields);
15925
- const updateField = (path, updater, fieldList = fields.value, parentPath = "", parentFieldPath = "", parsedPath = toPath(path).join(".")) => {
15929
+ const updateField = (path, updater, options, fieldList = fields.value, parentPath = "", parentFieldPath = "", parsedPath = typeof path === "function" ? "" : toPath(path).join(".")) => {
15926
15930
  if (!path)
15927
15931
  return false;
15932
+ const { all = false } = options || {};
15928
15933
  for (let i2 = 0; i2 < fieldList.length; i2 += 1) {
15929
15934
  const field = fieldList[i2];
15930
- const { key = "" } = field;
15931
- const concatPath = `${parentPath}${parentPath && key ? "." : ""}${key}`;
15932
- const selfPath = toPath(concatPath).join(".");
15933
- if (!parsedPath.startsWith(selfPath))
15934
- continue;
15935
15935
  const fieldPath = `${parentFieldPath}[${i2}]`;
15936
- if (selfPath && selfPath === parsedPath) {
15936
+ let found = false;
15937
+ let selfPath = "";
15938
+ if (typeof path === "function") {
15939
+ found = path(shallowReadonly(field));
15940
+ } else {
15941
+ const { name, key = "" } = field;
15942
+ const concatPath = name ?? `${parentPath}${parentPath && key ? "." : ""}${key}`;
15943
+ selfPath = toPath(concatPath).join(".");
15944
+ found = !!selfPath && selfPath === parsedPath;
15945
+ }
15946
+ if (found) {
15937
15947
  updater({ field, fieldIndex: i2, parentFields: fieldList, fieldPath });
15938
- return true;
15948
+ if (!all)
15949
+ return true;
15939
15950
  }
15940
- if (field.fields && updateField(
15941
- path,
15942
- updater,
15943
- field.fields,
15944
- selfPath,
15945
- `${fieldPath}.fields`,
15946
- parsedPath
15947
- )) {
15948
- return true;
15951
+ if (parsedPath.includes(".") && !parsedPath.startsWith(selfPath)) {
15952
+ if (!all)
15953
+ continue;
15954
+ }
15955
+ if (field.fields && updateField(path, updater, options, field.fields, selfPath, `${fieldPath}.fields`, parsedPath)) {
15956
+ if (!all)
15957
+ return true;
15949
15958
  }
15950
15959
  }
15951
15960
  return false;
@@ -15959,26 +15968,39 @@ const useFields = (initFields) => {
15959
15968
  });
15960
15969
  return res;
15961
15970
  };
15962
- const setField = (path, field, updateType = "merge") => {
15963
- if (!path)
15971
+ const setField = (path, field, options) => {
15972
+ if (!path || !field)
15964
15973
  return;
15965
- updateField(path, ({ field: preField, fieldIndex, parentFields }) => {
15966
- let value = field;
15967
- if (typeof field === "function") {
15968
- value = field(preField);
15969
- }
15970
- const newField = updateType === "rewrite" ? value : { ...preField, ...value };
15971
- parentFields[fieldIndex] = newField;
15972
- });
15974
+ const { updateType = "merge", ...rest } = options || {};
15975
+ updateField(
15976
+ path,
15977
+ ({ field: preField, fieldIndex, parentFields }) => {
15978
+ let value = field;
15979
+ if (typeof field === "function") {
15980
+ value = field(preField);
15981
+ }
15982
+ if (!value)
15983
+ return;
15984
+ const newField = updateType === "rewrite" ? value : { ...preField, ...value };
15985
+ parentFields[fieldIndex] = newField;
15986
+ },
15987
+ rest
15988
+ );
15973
15989
  };
15974
- const deleteField = (path) => {
15990
+ const deleteField = (path, options) => {
15975
15991
  if (!path)
15976
15992
  return;
15977
- updateField(path, ({ fieldIndex, parentFields }) => {
15978
- parentFields.splice(fieldIndex, 1);
15979
- });
15993
+ updateField(
15994
+ path,
15995
+ ({ fieldIndex, parentFields }) => {
15996
+ parentFields.splice(fieldIndex, 1);
15997
+ },
15998
+ options
15999
+ );
15980
16000
  };
15981
16001
  const addField = (path, field, placement) => {
16002
+ if (!field)
16003
+ return;
15982
16004
  if (path) {
15983
16005
  updateField(path, ({ fieldIndex, parentFields }) => {
15984
16006
  const index2 = placement === "after" ? fieldIndex + 1 : fieldIndex;
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-46e84b2b.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-7ee4d75c.js";
2
2
  import "vue";
3
3
  import "ant-design-vue";
4
4
  import "../component-provider/index.js";
package/es/index.d.ts CHANGED
@@ -408,7 +408,7 @@ export declare type Condition = {
408
408
  disabled?: boolean;
409
409
  };
410
410
 
411
- export declare type ContainerComponent = Component<DefaultProps>;
411
+ export declare type ContainerComponent = Component<DefaultProps> | null;
412
412
 
413
413
  export declare const ContainerFragment: __VLS_WithTemplateSlots_2<DefineComponent<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<Props_4>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_4<Props_4>>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
414
414
  default?(_: {}): any;
@@ -1136,7 +1136,7 @@ declare type DefaultProps = {
1136
1136
  [key: string]: any;
1137
1137
  };
1138
1138
 
1139
- export declare type DeleteField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => void;
1139
+ export declare type DeleteField<D extends FormData_2 = FormData_2> = (path: Path<D>, options?: UpdateFieldOptions) => void;
1140
1140
 
1141
1141
  /**
1142
1142
  * @type {string} Expression - 表达式字符串 需要是一个js表达式字符串或者一个函数字符串,表达式的执行结果或者函数的返回值将作为结果返回
@@ -1248,6 +1248,8 @@ export declare type FieldType = {
1248
1248
  } & Record<string, any>;
1249
1249
  };
1250
1250
 
1251
+ export declare type FindBy<D extends FormData_2 = FormData_2> = (field: Readonly<Field<D>>) => boolean;
1252
+
1251
1253
  declare type FlattenKeys<T, P extends string = ''> = T extends FormData_2 ? {
1252
1254
  [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
1255
  }[keyof KnownKeys<T>] : P;
@@ -1274,13 +1276,13 @@ export declare const FunctionRegexp: RegExp;
1274
1276
 
1275
1277
  export declare const GET_REF: InjectionKey<GetRef>;
1276
1278
 
1277
- export declare type GetField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Field<D> | undefined;
1279
+ export declare type GetField<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Readonly<Field<D>> | undefined;
1278
1280
 
1279
- export declare type GetFieldPath<D extends FormData_2 = FormData_2> = (path?: Path<D>) => string | undefined;
1281
+ export declare type GetFieldPath<D extends FormData_2 = FormData_2> = (path: Path<D>) => string | undefined;
1280
1282
 
1281
1283
  export declare type GetFormData<D extends FormData_2 = FormData_2> = (path?: Path<D>) => DeepReadonly<any>;
1282
1284
 
1283
- export declare type GetParentFields<D extends FormData_2 = FormData_2> = (path?: Path<D>) => Field<D> | undefined;
1285
+ export declare type GetParentFields<D extends FormData_2 = FormData_2> = (path: Path<D>) => Fields<D> | undefined;
1284
1286
 
1285
1287
  export declare type GetRef = {
1286
1288
  (type: 'formItemRefs', path: string): FormItemInstance;
@@ -5544,7 +5546,12 @@ declare type SelectSlots = FieldSlot<keyof InstanceType<typeof Select>['$slots']
5544
5546
 
5545
5547
  export declare type SetActivePath<D extends FormData_2 = FormData_2> = (path: Path<D> | undefined) => void;
5546
5548
 
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;
5549
+ 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?: {
5550
+ /**
5551
+ * 更新方式 rewrite替换重写,merge合并(默认)
5552
+ */
5553
+ updateType?: 'rewrite' | 'merge';
5554
+ } & UpdateFieldOptions) => void;
5548
5555
 
5549
5556
  export declare type SetFormData<D extends FormData_2 = FormData_2> = {
5550
5557
  (path: Path<D>, value: any | ((preValue: DeepReadonly<any>) => any)): void;
@@ -5591,6 +5598,13 @@ export declare const UPDATE_FORM_DATA: InjectionKey<UpdateFormData>;
5591
5598
 
5592
5599
  export declare const UPDATE_REFS: InjectionKey<UpdateRefs>;
5593
5600
 
5601
+ export declare type UpdateFieldOptions = {
5602
+ /**
5603
+ * 更新所有符合条件的字段,默认false(仅更新第一个)
5604
+ */
5605
+ all?: boolean;
5606
+ };
5607
+
5594
5608
  export declare type UpdateFormData = (path: string, value: any) => void;
5595
5609
 
5596
5610
  export declare type UpdateRefs = (type: keyof Refs, path: string, childRef: Record<string, any>) => void;
@@ -5616,7 +5630,7 @@ export declare type UseFields<D extends FormData_2 = FormData_2> = (initFields:
5616
5630
  getField: GetField<D>;
5617
5631
  /** 设置指定字段数据路径的字段配置 */
5618
5632
  setField: SetField<D>;
5619
- /** 删除指定字段数据路径的字段配置 */
5633
+ /** 删除指定字段数据路径的字段配置, 或许你更应该使用setField(path, { hidden: true })来隐藏字段 */
5620
5634
  deleteField: DeleteField<D>;
5621
5635
  /** 根据字段数据路径获取字段配置路径 */
5622
5636
  getFieldPath: GetFieldPath<D>;
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./style.css";
2
- import { _ as _sfc_main } from "./form/index-46e84b2b.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-46e84b2b.js";
2
+ import { _ as _sfc_main } from "./form/index-7ee4d75c.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-7ee4d75c.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";
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-46e84b2b.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-7ee4d75c.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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "main": "",