@qin-ui/antd-vue-pro 1.1.16 → 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, 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;
@@ -15926,23 +15926,35 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15926
15926
  const index_vue_vue_type_style_index_0_lang = "";
15927
15927
  const useFields = (initFields) => {
15928
15928
  const fields = ref(initFields);
15929
- 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(".")) => {
15930
15930
  if (!path)
15931
15931
  return false;
15932
+ const { all = false } = options || {};
15932
15933
  for (let i2 = 0; i2 < fieldList.length; i2 += 1) {
15933
15934
  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
15935
  const fieldPath = `${parentFieldPath}[${i2}]`;
15940
- 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) {
15941
15947
  updater({ field, fieldIndex: i2, parentFields: fieldList, fieldPath });
15942
- return true;
15948
+ if (!all)
15949
+ return true;
15943
15950
  }
15944
- if (field.fields && updateField(path, updater, field.fields, selfPath, `${fieldPath}.fields`, parsedPath)) {
15945
- 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;
15946
15958
  }
15947
15959
  }
15948
15960
  return false;
@@ -15956,26 +15968,39 @@ const useFields = (initFields) => {
15956
15968
  });
15957
15969
  return res;
15958
15970
  };
15959
- const setField = (path, field, updateType = "merge") => {
15960
- if (!path)
15971
+ const setField = (path, field, options) => {
15972
+ if (!path || !field)
15961
15973
  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
- });
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
+ );
15970
15989
  };
15971
- const deleteField = (path) => {
15990
+ const deleteField = (path, options) => {
15972
15991
  if (!path)
15973
15992
  return;
15974
- updateField(path, ({ fieldIndex, parentFields }) => {
15975
- parentFields.splice(fieldIndex, 1);
15976
- });
15993
+ updateField(
15994
+ path,
15995
+ ({ fieldIndex, parentFields }) => {
15996
+ parentFields.splice(fieldIndex, 1);
15997
+ },
15998
+ options
15999
+ );
15977
16000
  };
15978
16001
  const addField = (path, field, placement) => {
16002
+ if (!field)
16003
+ return;
15979
16004
  if (path) {
15980
16005
  updateField(path, ({ fieldIndex, parentFields }) => {
15981
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-f9088d5a.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
@@ -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-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-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-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-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.16",
3
+ "version": "1.1.17",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "main": "",