@qin-ui/antd-vue-pro 2.0.23 → 2.1.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.
@@ -1,6 +1,7 @@
1
1
  import { defineComponent, provide, renderSlot } from "vue";
2
2
  import { g as getObject } from "../core/index-BrBzu6aj.js";
3
3
  const getPopupContainer = (triggerNode) => triggerNode.closest(".ant-form");
4
+ const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
4
5
  const INJECT_CONFIG = {
5
6
  "pro-table": {
6
7
  injectionKey: Symbol(""),
@@ -110,7 +111,7 @@ const INJECT_CONFIG = {
110
111
  },
111
112
  switch: {
112
113
  injectionKey: Symbol(""),
113
- default: { modelName: "checked" }
114
+ default: { modelProp: "checked" }
114
115
  },
115
116
  slider: {
116
117
  injectionKey: Symbol(""),
@@ -131,10 +132,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
131
132
  },
132
133
  __name: "index",
133
134
  props: {
134
- componentVars: {}
135
+ componentVars: {},
136
+ componentMap: {}
135
137
  },
136
138
  setup(__props) {
137
139
  const props = __props;
140
+ if (props.componentMap) {
141
+ provide(INJECT_COMPONENTS, props.componentMap);
142
+ }
138
143
  if (props.componentVars) {
139
144
  Object.entries(props.componentVars).forEach(([key, val]) => {
140
145
  const config = INJECT_CONFIG[key];
@@ -148,6 +153,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
148
153
  }
149
154
  });
150
155
  export {
156
+ INJECT_COMPONENTS,
151
157
  INJECT_CONFIG,
152
158
  _sfc_main as default
153
159
  };
package/es/form/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { Form, Input, Textarea, InputSearch, InputPassword, InputNumber, Select, Cascader, DatePicker, RangePicker, TimePicker, CheckboxGroup, RadioGroup, Switch, Slider, TreeSelect, Transfer, Row, Col, FormItem } from "ant-design-vue";
1
+ import { Form, Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input, Row, Col, FormItem } from "ant-design-vue";
2
2
  import "ant-design-vue/es/table";
3
3
  import "ant-design-vue/es/config-provider/context";
4
4
  import { useProviderDisabled, useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
5
5
  import { colProps } from "ant-design-vue/es/grid/Col";
6
6
  import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
7
7
  import { defineComponent, provide, inject, useSlots, watchEffect, createBlock, openBlock, unref, mergeProps, withCtx, createVNode, renderSlot, computed, toValue, normalizeProps, guardReactiveProps, resolveComponent, createElementBlock, Fragment, renderList, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString } from "vue";
8
- import { INJECT_CONFIG } from "../component-provider/index.js";
8
+ import { INJECT_CONFIG, INJECT_COMPONENTS } from "../component-provider/index.js";
9
9
  import { I as InjectionFormKey, c as camelizeProperties, a as InjectionPathKey, g as getObject, u as useForm$1, b as useFields$1, d as useFormRef$1 } from "../core/index-BrBzu6aj.js";
10
10
  import { e } from "../core/index-BrBzu6aj.js";
11
11
  import { i as isPlainObject, t as toPath, o as omit, c as cloneDeep } from "../vendor/utils/lodash-es-p6jau26B.js";
@@ -51,25 +51,30 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
51
51
  };
52
52
  }
53
53
  });
54
- const FORM_ITEM_SLOT_KEYS = ["label", "extra", "help", "tooltip"];
55
- const COMPONENT_MAP = /* @__PURE__ */ new Map([
56
- ["input", Input],
57
- ["textarea", Textarea],
58
- ["input-search", InputSearch],
59
- ["input-password", InputPassword],
60
- ["input-number", InputNumber],
61
- ["select", Select],
62
- ["cascader", Cascader],
63
- ["date-picker", DatePicker],
64
- ["range-picker", RangePicker],
65
- ["time-picker", TimePicker],
66
- ["checkbox-group", CheckboxGroup],
67
- ["radio-group", RadioGroup],
68
- ["switch", Switch],
69
- ["slider", Slider],
70
- ["tree-select", TreeSelect],
71
- ["transfer", Transfer]
72
- ]);
54
+ const FORM_ITEM_SLOT_KEYS = [
55
+ "label",
56
+ "extra",
57
+ "help",
58
+ "tooltip"
59
+ ];
60
+ const componentMap = {
61
+ "input": Input,
62
+ "textarea": Textarea,
63
+ "input-search": InputSearch,
64
+ "input-password": InputPassword,
65
+ "input-number": InputNumber,
66
+ "select": Select,
67
+ "cascader": Cascader,
68
+ "date-picker": DatePicker,
69
+ "range-picker": RangePicker,
70
+ "time-picker": TimePicker,
71
+ "checkbox-group": CheckboxGroup,
72
+ "radio-group": RadioGroup,
73
+ "switch": Switch,
74
+ "slider": Slider,
75
+ "tree-select": TreeSelect,
76
+ "transfer": Transfer
77
+ };
73
78
  const TeleportComponentNamePrefix = "TeleportComponent_";
74
79
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
75
80
  __name: "index",
@@ -93,7 +98,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
93
98
  field: {}
94
99
  },
95
100
  setup(__props) {
96
- const formItemPropKeys = Object.keys(formItemProps()).concat(["container"]);
101
+ const formItemPropKeys = Object.keys(formItemProps()).concat([
102
+ "formItemContainer"
103
+ ]);
97
104
  const gridItemPropKeys = Object.keys(colProps());
98
105
  const props = __props;
99
106
  const config = INJECT_CONFIG["pro-form-item"];
@@ -104,7 +111,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
104
111
  const componentProps = { slots: {} };
105
112
  const formItemSlots = {};
106
113
  if (isPlainObject(props.field)) {
107
- const { path, name, fields, className, style, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, ...rest } = props.field;
114
+ const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, ...rest } = props.field;
108
115
  const {
109
116
  class: injectClassName,
110
117
  style: injectStyle,
@@ -122,17 +129,19 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
122
129
  formItemProps2 = mergeProps(
123
130
  injectRest,
124
131
  { class: injectClassName, style: injectStyle },
125
- { class: toValue(className), style: toValue(style) }
132
+ { class: toValue(formItemClass), style: toValue(formItemStyle) },
133
+ formItemDataAttrs
126
134
  );
127
135
  Object.keys(rest).forEach((k) => {
128
136
  if (gridItemPropKeys.includes(k)) {
129
137
  gridItemProps2[k] = rest[k];
130
- } else if (formItemPropKeys.includes(k) || k.startsWith("data-form-item")) {
138
+ } else if (formItemPropKeys.includes(k)) {
131
139
  formItemProps2[k] = rest[k];
132
140
  } else {
133
141
  componentProps[k] = rest[k];
134
142
  }
135
143
  });
144
+ Object.assign(componentProps, componentDataAttrs);
136
145
  Object.keys(slots).forEach((k) => {
137
146
  if (FORM_ITEM_SLOT_KEYS.includes(k)) {
138
147
  formItemSlots[k] = slots[k];
@@ -207,7 +216,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
207
216
  createVNode(_sfc_main$4, { field }, {
208
217
  default: withCtx(({
209
218
  gridItemProps,
210
- formItemProps: { container, ...formItemProps2 },
219
+ formItemProps: { formItemContainer, ...formItemProps2 },
211
220
  componentProps,
212
221
  formItemSlots
213
222
  }) => [
@@ -216,7 +225,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
216
225
  }, { ref_for: true }, gridItemProps), {
217
226
  default: withCtx(() => [
218
227
  createVNode(unref(_sfc_main$1), {
219
- component: container,
228
+ component: formItemContainer,
220
229
  path
221
230
  }, {
222
231
  default: withCtx(() => [
@@ -278,9 +287,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
278
287
  const useForm = useForm$1;
279
288
  const getInitProps = (field) => {
280
289
  const { component } = field;
281
- const type = component === "input" ? "" : field.type;
282
- if (COMPONENT_MAP.has(component)) {
283
- const k = [component, type].filter(Boolean).join(".");
290
+ const picker = component === "date-picker" ? "" : field.picker;
291
+ if (typeof component === "string" && component in componentMap) {
292
+ const k = [component, picker].filter(Boolean).join(".");
284
293
  if (INJECT_CONFIG[k]) {
285
294
  const config = INJECT_CONFIG[k];
286
295
  const injectProps = inject(config.injectionKey, config.default);
@@ -340,18 +349,18 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
340
349
  const mergedProps = mergeProps(
341
350
  initProps,
342
351
  attrs,
343
- { class: attrs.componentClassName, style: attrs.componentStyle },
344
- { class: initProps.componentClassName, style: initProps.componentStyle },
352
+ { class: attrs.componentClass, style: attrs.componentStyle },
353
+ { class: initProps.componentClass, style: initProps.componentStyle },
345
354
  { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
346
- { modelName: attrs.modelName ?? initProps.modelName ?? "value" }
355
+ { modelProp: attrs.modelProp ?? initProps.modelProp ?? "value" }
347
356
  );
348
- const { valueFormatter, modelName, slots, componentClassName, componentStyle, componentContainer, ...rest } = mergedProps;
349
- const bindAttrs = omit(rest, [modelName, `onUpdate:${modelName}`]);
357
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
358
+ const bindAttrs = omit(rest, [modelProp, `onUpdate:${modelProp}`]);
350
359
  return {
351
360
  attrs: bindAttrs,
352
361
  slots,
353
362
  componentContainer,
354
- modelName,
363
+ modelProp,
355
364
  valueFormatter
356
365
  };
357
366
  });
@@ -359,8 +368,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
359
368
  `${TeleportComponentNamePrefix}${__props.path}`,
360
369
  void 0
361
370
  );
371
+ const customComponents = inject(INJECT_COMPONENTS, {});
362
372
  const is = computed(() => {
363
- return teleportComponent ?? COMPONENT_MAP.get(__props.component) ?? __props.component;
373
+ if (teleportComponent) return teleportComponent;
374
+ if (typeof __props.component === "string") {
375
+ return customComponents[__props.component] || componentMap[__props.component] || __props.component;
376
+ }
377
+ return __props.component;
364
378
  });
365
379
  __expose({
366
380
  getComponentRef: () => componentRef.value,
@@ -375,8 +389,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
375
389
  is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
376
390
  ref_key: "componentRef",
377
391
  ref: componentRef,
378
- [`${groupedAttrs.value.modelName}`]: value.value,
379
- [`onUpdate:${groupedAttrs.value.modelName}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
392
+ [`${groupedAttrs.value.modelProp}`]: value.value,
393
+ [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
380
394
  path: __props.path
381
395
  }), createSlots({ _: 2 }, [
382
396
  renderList(groupedAttrs.value.slots, (slot, name) => {
@@ -431,13 +445,13 @@ export {
431
445
  _sfc_main$2 as BaseField,
432
446
  _sfc_main$6 as BaseForm,
433
447
  _sfc_main$3 as BaseFormItem,
434
- COMPONENT_MAP,
435
448
  _sfc_main$1 as ContainerFragment,
436
449
  FORM_ITEM_SLOT_KEYS,
437
450
  InjectionFormKey,
438
451
  InjectionPathKey,
439
452
  _sfc_main as SlotComponent,
440
453
  TeleportComponentNamePrefix,
454
+ componentMap,
441
455
  _sfc_main$6 as default,
442
456
  getInitProps,
443
457
  useFields,
package/es/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AllowedComponentProps } from 'vue';
2
2
  import { App } from 'vue';
3
3
  import { ButtonSize } from 'ant-design-vue/es/button';
4
- import { CascaderProps } from 'ant-design-vue';
5
- import { CheckboxGroupProps } from 'ant-design-vue';
4
+ import { Cascader } from 'ant-design-vue';
5
+ import { CheckboxGroup } from 'ant-design-vue';
6
6
  import { ColProps } from 'ant-design-vue';
7
7
  import { ColSize } from 'ant-design-vue/es/grid';
8
8
  import { ColumnType } from 'ant-design-vue/es/table';
@@ -14,14 +14,16 @@ import { ComponentOptionsBase } from 'vue';
14
14
  import { ComponentOptionsMixin } from 'vue';
15
15
  import { ComponentProps } from 'vue-component-type-helpers';
16
16
  import { ComponentProvideOptions } from 'vue';
17
+ import { ComponentSlots } from 'vue-component-type-helpers';
17
18
  import { ComputedRef } from 'vue';
18
19
  import { CreateComponentPublicInstanceWithMixins } from 'vue';
19
20
  import { CSSProperties } from 'vue';
20
- import { DatePickerProps } from 'ant-design-vue';
21
+ import { DatePicker } from 'ant-design-vue';
21
22
  import { DefineComponent } from 'vue';
22
23
  import { ExtractPropTypes } from 'vue';
23
24
  import { FieldData } from 'ant-design-vue/es/form/interface';
24
25
  import { FormInstance } from 'ant-design-vue';
26
+ import { FormItem } from 'ant-design-vue';
25
27
  import { FormItemInstance } from 'ant-design-vue';
26
28
  import { FormItemProps } from 'ant-design-vue';
27
29
  import { FormLabelAlign } from 'ant-design-vue/es/form/interface';
@@ -30,15 +32,17 @@ import { GlobalComponents } from 'vue';
30
32
  import { GlobalDirectives } from 'vue';
31
33
  import { HTMLAttributes } from 'vue';
32
34
  import { InjectionKey } from 'vue';
33
- import { InputNumberProps } from 'ant-design-vue';
34
- import { InputProps } from 'ant-design-vue';
35
+ import { Input } from 'ant-design-vue';
36
+ import { InputNumber } from 'ant-design-vue';
37
+ import { InputPassword } from 'ant-design-vue';
38
+ import { InputSearch } from 'ant-design-vue';
35
39
  import { MaybeRef } from 'vue';
36
40
  import { Options as Options_2 } from 'scroll-into-view-if-needed';
37
41
  import { Plugin as Plugin_2 } from 'vue';
38
42
  import { PropType } from 'vue';
39
43
  import { PublicProps } from 'vue';
40
- import { RadioGroupProps } from 'ant-design-vue';
41
- import { RangePickerProps } from 'ant-design-vue/es/date-picker';
44
+ import { RadioGroup } from 'ant-design-vue';
45
+ import { RangePicker } from 'ant-design-vue';
42
46
  import { Raw } from 'vue';
43
47
  import { Reactive } from 'vue';
44
48
  import { Ref } from 'vue';
@@ -47,16 +51,15 @@ import { RequiredMark } from 'ant-design-vue/es/form/Form';
47
51
  import { RowProps } from 'ant-design-vue';
48
52
  import { RuleObject } from 'ant-design-vue/es/form';
49
53
  import { Select } from 'ant-design-vue';
50
- import { SelectProps } from 'ant-design-vue';
51
54
  import { ShallowUnwrapRef } from 'vue';
52
- import { SliderProps } from 'ant-design-vue';
55
+ import { Slider } from 'ant-design-vue';
53
56
  import { Slot } from 'vue';
54
- import { SwitchProps } from 'ant-design-vue';
57
+ import { Switch } from 'ant-design-vue';
55
58
  import { TableProps } from 'ant-design-vue';
56
- import { TextAreaProps } from 'ant-design-vue';
57
- import { TimePickerProps } from 'ant-design-vue';
58
- import { TransferProps } from 'ant-design-vue';
59
- import { TreeSelectProps } from 'ant-design-vue';
59
+ import { Textarea } from 'ant-design-vue';
60
+ import { TimePicker } from 'ant-design-vue';
61
+ import { Transfer } from 'ant-design-vue';
62
+ import { TreeSelect } from 'ant-design-vue';
60
63
  import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
61
64
  import { ValidateMessages } from 'ant-design-vue/es/form/interface';
62
65
  import { VNode } from 'vue';
@@ -123,17 +126,17 @@ export declare interface Base<D extends Data = Data> {
123
126
  * }
124
127
  * ```
125
128
  */
126
- slots?: Partial<Record<(typeof FORM_ITEM_SLOT_KEYS)[number], SlotComponentType>>;
129
+ slots?: Partial<ComponentSlots<typeof FormItem>>;
127
130
  /**
128
131
  * @description 字段formItem样式属性
129
132
  * @example { marginBottom: '8px', padding: '12px' }
130
133
  */
131
- style?: CSSProperties;
134
+ formItemStyle?: CSSProperties;
132
135
  /**
133
136
  * @description 字段formItem样式类名
134
137
  * @example 'custom-form-item' | 'required-field'
135
138
  */
136
- className?: string;
139
+ formItemClass?: string;
137
140
  /**
138
141
  * @description 嵌套子字段配置
139
142
  * @example [{ key: 'firstName', label: '名' }, { key: 'lastName', label: '姓' }]
@@ -148,7 +151,12 @@ export declare interface Base<D extends Data = Data> {
148
151
  * @description 字段formItem容器包裹组件
149
152
  * @example (props, ctx) => h('div', { class: 'custom-container' }, ctx.slots.default?.())
150
153
  */
151
- container?: ContainerComponent;
154
+ formItemContainer?: ContainerComponent;
155
+ /**
156
+ * @description 将属性附加到 FormItem 的 DOM 节点
157
+ * @example { 'data-form-item-test': 'test-value', 'aria-label': 'name' }
158
+ */
159
+ formItemDataAttrs?: Record<string, string>;
152
160
  /**
153
161
  * @description 字段component样式属性
154
162
  * @example { width: '100%', borderColor: '#d9d9d9' }
@@ -158,7 +166,7 @@ export declare interface Base<D extends Data = Data> {
158
166
  * @description 字段component样式类名
159
167
  * @example 'custom-input' | 'error-input'
160
168
  */
161
- componentClassName?: string;
169
+ componentClass?: string;
162
170
  /**
163
171
  * @description 字段component容器包裹组件
164
172
  * @example (props, ctx) => h('div', { class: 'input-wrapper' }, ctx.slots.default?.())
@@ -172,17 +180,12 @@ export declare interface Base<D extends Data = Data> {
172
180
  /**
173
181
  * @description 组件v-model双向绑定更新属性名,默认'value'
174
182
  */
175
- modelName?: string;
183
+ modelProp?: string;
176
184
  /**
177
- * @description 以data-form-item-开始的属性名将会被渲染至formItem的dom节点
178
- * @example { 'data-form-item-test': 'test-value' }
185
+ * @description 将属性附加到表单组件的 DOM 节点
186
+ * @example { 'data-test': 'input-value', 'aria-label': 'name' }
179
187
  */
180
- [key: `data-form-item-${string}`]: string;
181
- /**
182
- * @description 以data-component-开始的属性名将会被渲染至component的dom节点
183
- * @example { 'data-component-test': 'test-value' }
184
- */
185
- [key: `data-component-${string}`]: string;
188
+ componentDataAttrs?: Record<string, string>;
186
189
  }
187
190
 
188
191
  declare interface BaseColumn<D extends Data = Data> {
@@ -192,10 +195,24 @@ declare interface BaseColumn<D extends Data = Data> {
192
195
  [key: string]: any;
193
196
  }
194
197
 
195
- /**
196
- * @description 基础组件字符串名称类型
197
- */
198
- export declare type BaseComponentStringName = Exclude<Field['component'], RenderComponentType | undefined>;
198
+ export declare type BaseComponentMap = {
199
+ 'input': typeof Input;
200
+ 'textarea': typeof Textarea;
201
+ 'input-search': typeof InputSearch;
202
+ 'input-password': typeof InputPassword;
203
+ 'input-number': typeof InputNumber;
204
+ 'select': typeof Select;
205
+ 'cascader': typeof Cascader;
206
+ 'date-picker': typeof DatePicker;
207
+ 'range-picker': typeof RangePicker;
208
+ 'time-picker': typeof TimePicker;
209
+ 'checkbox-group': typeof CheckboxGroup;
210
+ 'radio-group': typeof RadioGroup;
211
+ 'switch': typeof Switch;
212
+ 'slider': typeof Slider;
213
+ 'tree-select': typeof TreeSelect;
214
+ 'transfer': typeof Transfer;
215
+ };
199
216
 
200
217
  export declare const BaseField: DefineComponent<Props, {
201
218
  getComponentRef: () => any;
@@ -244,8 +261,6 @@ declare type ButtonProps = {
244
261
  onClick: () => void;
245
262
  };
246
263
 
247
- declare type CascaderSlots = CompSlot<'clearIcon' | 'expandIcon' | 'maxTagPlaceholder' | 'notFoundContent' | 'removeIcon' | 'suffixIcon' | 'tagRender'>;
248
-
249
264
  export declare type Column<D extends Data = Data> = Omit<ColumnType, 'dataIndex' | 'key'> & {
250
265
  dataIndex?: KeyExpandString<Extract<keyof D, string>> | Paths<D>;
251
266
  key?: Path<D>;
@@ -258,15 +273,25 @@ export declare type Columns<D extends Data = Data> = Array<Column<D>>;
258
273
 
259
274
  declare type Columns_2<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = Array<C>;
260
275
 
261
- export declare const COMPONENT_MAP: Map<BaseComponentStringName, Component>;
262
-
263
- export declare type ComponentVars = Partial<RequiredComponentVars>;
264
-
265
276
  /**
266
- * @description 字段插槽类型
267
- * @template T - 插槽名称联合类型
277
+ * @description 暴露给外部扩充自定义组件类型的接口
278
+ * @example
279
+ * ```ts
280
+ * declare module 'antd-vue-pro' {
281
+ * interface ComponentMap {
282
+ * 'my-custom-input': typeof MyCustomInput;
283
+ * }
284
+ * }
285
+ * ```
268
286
  */
269
- declare type CompSlot<T extends string> = Partial<Record<KeyExpandString<T>, SlotComponentType>>;
287
+ export declare interface ComponentMap {
288
+ }
289
+
290
+ export declare const componentMap: BaseComponentMap;
291
+
292
+ export declare type ComponentName = keyof BaseComponentMap | keyof ComponentMap;
293
+
294
+ export declare type ComponentVars = Partial<RequiredComponentVars>;
270
295
 
271
296
  /**
272
297
  * @description 容器组件类型
@@ -277,8 +302,6 @@ export declare const ContainerFragment: __VLS_WithTemplateSlots<typeof __VLS_com
277
302
 
278
303
  declare type Data = Record<string, any>;
279
304
 
280
- declare type DatePickerSlots = CompSlot<'dateRender' | 'renderExtraFooter' | 'separator' | 'monthCellRender'>;
281
-
282
305
  declare type DeepPartial<T> = T extends object ? {
283
306
  [P in keyof T]?: DeepPartial<T[P]>;
284
307
  } : T;
@@ -415,72 +438,14 @@ declare type Fields_2<D extends Data = Data, F extends BaseField_2<D> = BaseFiel
415
438
  * @type {FieldTypeMap} 字段类型集合
416
439
  */
417
440
  export declare type FieldTypeMap<D extends Data = Data> = {
418
- /** 文本框 */
419
- 'input': WithCommon<{
420
- slots?: InputSlots;
421
- } & InputProps, D>;
422
- /** 文本域 */
423
- 'textarea': WithCommon<{
424
- slots?: InputSlots;
425
- } & TextAreaProps, D>;
426
- /** 文本框-密码 */
427
- 'input-password': WithCommon<{
428
- slots?: InputSlots;
429
- } & InputProps, D>;
430
- /** 文本框-搜索 */
431
- 'input-search': WithCommon<{
432
- slots?: InputSlots;
433
- } & InputProps, D>;
434
- /** 数字文本框 */
435
- 'input-number': WithCommon<{
436
- slots?: InputNumberSlots;
437
- } & InputNumberProps, D>;
438
- /** 下拉选择器 */
439
- 'select': WithCommon<{
440
- slots?: SelectSlots;
441
- } & SelectProps, D>;
442
- /** 级联选择器 */
443
- 'cascader': WithCommon<{
444
- slots?: CascaderSlots;
445
- } & CascaderProps, D>;
446
- /** 日期选择器 */
447
- 'date-picker': WithCommon<{
448
- slots?: DatePickerSlots;
449
- } & DatePickerProps, D>;
450
- /** 日期选择器-范围 */
451
- 'range-picker': WithCommon<{
452
- slots?: RangePickerSlots;
453
- } & RangePickerProps, D>;
454
- /** 时间选择器 */
455
- 'time-picker': WithCommon<{
456
- slots?: TimePickerSlots;
457
- } & TimePickerProps, D>;
458
- /** 复选框组 */
459
- 'checkbox-group': WithCommon<CheckboxGroupProps, D>;
460
- /** 单选框组 */
461
- 'radio-group': WithCommon<RadioGroupProps, D>;
462
- /** 开关 */
463
- 'switch': WithCommon<{
464
- slots?: SwitchSlots;
465
- } & SwitchProps, D>;
466
- /** 滑块 */
467
- 'slider': WithCommon<{
468
- slots?: SliderSlots;
469
- } & SliderProps, D>;
470
- /** 树形选择器 */
471
- 'tree-select': WithCommon<{
472
- slots?: TreeSelectSlots;
473
- } & TreeSelectProps, D>;
474
- /** 穿梭框 */
475
- 'transfer': WithCommon<{
476
- slots?: TransferSlots;
477
- } & TransferProps, D>;
478
441
  /** 自定义组件 */
479
- 'custom': {
442
+ custom: {
480
443
  component?: RenderComponentType | Raw<RenderComponentType>;
481
444
  } & WithCommon<{
482
445
  slots?: Slots;
483
446
  } & Record<string, any>, D>;
447
+ } & {
448
+ [K in ComponentName]: WithComponent<GetComponentType<K>, D>;
484
449
  };
485
450
 
486
451
  /**
@@ -503,12 +468,16 @@ declare type FormProps = Omit<FormProps_2, 'scrollToFirstError'> & {
503
468
 
504
469
  declare type _FormProps = Pick<Partial<FormProps>, 'colon' | 'disabled' | 'hideRequiredMark' | 'labelAlign' | 'labelCol' | 'labelWrap' | 'name' | 'wrapperCol'>;
505
470
 
506
- declare type FP<T extends Record<string, any>> = Partial<T & Pick<Base, 'valueFormatter' | 'componentContainer' | 'modelName'> & AllowedComponentProps>;
471
+ declare type FP<T extends Record<string, any>> = Partial<T & Pick<Base, 'valueFormatter' | 'componentContainer' | 'modelProp'> & AllowedComponentProps>;
472
+
473
+ export declare type GetComponentType<K extends ComponentName> = K extends keyof ComponentMap ? ComponentMap[K] : K extends keyof BaseComponentMap ? BaseComponentMap[K] : never;
507
474
 
508
475
  export declare const getInitProps: (field: Field) => Record<string, any>;
509
476
 
510
477
  export declare type Grid = boolean | (RowProps & {});
511
478
 
479
+ export declare const INJECT_COMPONENTS: InjectionKey<Partial<Record<string, Component>>>;
480
+
512
481
  export declare const INJECT_CONFIG: {
513
482
  [key in keyof RequiredComponentVars]: {
514
483
  injectionKey: InjectionKey<RequiredComponentVars[key]>;
@@ -520,10 +489,6 @@ export declare const InjectionFormKey: InjectionKey<any>;
520
489
 
521
490
  export declare const InjectionPathKey: InjectionKey<ComputedRef<string | undefined>>;
522
491
 
523
- declare type InputNumberSlots = CompSlot<'addonAfter' | 'addonBefore' | 'prefix' | 'upIcon' | 'downIcon'>;
524
-
525
- declare type InputSlots = CompSlot<'addonAfter' | 'addonBefore' | 'clearIcon' | 'prefix' | 'suffix'>;
526
-
527
492
  declare type IsRecord<T> = T extends object ? T extends ((...args: any[]) => any) | any[] | null ? false : true : false;
528
493
 
529
494
  declare type JoinPath<Prefix extends any[], Key extends PropertyKey> = [
@@ -540,7 +505,7 @@ declare type MaybeRefOrComputedRef<T = any> = MaybeRef<T> | ComputedRef<T>;
540
505
  /**
541
506
  * @description 不支持响应式的属性名
542
507
  */
543
- declare type NotSupportedRefOrGetterProps = 'component' | 'container' | 'componentContainer' | 'valueFormatter' | 'fields' | 'slots' | 'modelName';
508
+ declare type NotSupportedRefOrGetterProps = 'component' | 'formItemContainer' | 'componentContainer' | 'valueFormatter' | 'fields' | 'slots' | 'modelProp';
544
509
 
545
510
  declare type Option_2 = {
546
511
  label: string;
@@ -572,7 +537,8 @@ declare type PP<T extends Record<string, any>> = Partial<T & AllowedComponentPro
572
537
 
573
538
  export declare const ProComponentProvider: SFCWithInstall<{
574
539
  new (...args: any[]): CreateComponentPublicInstanceWithMixins<Readonly<{
575
- componentVars: ComponentVars;
540
+ componentVars?: ComponentVars;
541
+ componentMap?: Partial<Record<KeyExpandString<ComponentName>, Component>>;
576
542
  }> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
577
543
  P: {};
578
544
  B: {};
@@ -581,13 +547,15 @@ export declare const ProComponentProvider: SFCWithInstall<{
581
547
  M: {};
582
548
  Defaults: {};
583
549
  }, Readonly<{
584
- componentVars: ComponentVars;
550
+ componentVars?: ComponentVars;
551
+ componentMap?: Partial<Record<KeyExpandString<ComponentName>, Component>>;
585
552
  }> & Readonly<{}>, {}, {}, {}, {}, {}>;
586
553
  __isFragment?: never;
587
554
  __isTeleport?: never;
588
555
  __isSuspense?: never;
589
556
  } & ComponentOptionsBase<Readonly<{
590
- componentVars: ComponentVars;
557
+ componentVars?: ComponentVars;
558
+ componentMap?: Partial<Record<KeyExpandString<ComponentName>, Component>>;
591
559
  }> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {}, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & (new () => {
592
560
  $slots: {
593
561
  default?(_: {}): any;
@@ -761,7 +729,7 @@ export declare type ProTableInstance = ComponentExposed<typeof _default_2>;
761
729
 
762
730
  export declare type ProTableProps = ComponentProps<typeof _default_2>;
763
731
 
764
- declare type RangePickerSlots = CompSlot<'dateRender' | 'renderExtraFooter' | 'separator'>;
732
+ declare type ReadonlyFormItemProps = ComponentProps<typeof FormItem>;
765
733
 
766
734
  /**
767
735
  * @description 自定义组件
@@ -774,28 +742,14 @@ export declare type RequiredComponentVars = {
774
742
  'pro-form': PP<Omit<ProFormProps, 'form' | 'grid'> & {
775
743
  grid: Exclude<Grid, undefined | boolean>;
776
744
  }>;
777
- 'pro-form-item': PP<FormItemProps & Pick<ColProps, 'span' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'> & Pick<Base, 'container'>>;
778
- 'input': FP<InputProps>;
779
- 'textarea': FP<TextAreaProps>;
780
- 'input-password': FP<InputProps>;
781
- 'input-search': FP<InputProps>;
782
- 'input-number': FP<InputNumberProps>;
783
- 'select': FP<SelectProps>;
784
- 'cascader': FP<CascaderProps>;
785
- 'date-picker': FP<DatePickerProps>;
786
- 'date-picker.date': FP<DatePickerProps>;
787
- 'date-picker.week': FP<DatePickerProps>;
788
- 'date-picker.month': FP<DatePickerProps>;
789
- 'date-picker.year': FP<DatePickerProps>;
790
- 'date-picker.quarter': FP<DatePickerProps>;
791
- 'range-picker': FP<RangePickerProps>;
792
- 'time-picker': FP<TimePickerProps>;
793
- 'checkbox-group': FP<CheckboxGroupProps>;
794
- 'radio-group': FP<RadioGroupProps>;
795
- 'switch': FP<SwitchProps>;
796
- 'slider': FP<SliderProps>;
797
- 'tree-select': FP<TreeSelectProps>;
798
- 'transfer': FP<TransferProps>;
745
+ 'pro-form-item': PP<FormItemProps & Pick<ColProps, 'span' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'> & Pick<Base, 'formItemContainer'>>;
746
+ 'date-picker.date': FP<ComponentProps<GetComponentType<'date-picker'>>>;
747
+ 'date-picker.week': FP<ComponentProps<GetComponentType<'date-picker'>>>;
748
+ 'date-picker.month': FP<ComponentProps<GetComponentType<'date-picker'>>>;
749
+ 'date-picker.year': FP<ComponentProps<GetComponentType<'date-picker'>>>;
750
+ 'date-picker.quarter': FP<ComponentProps<GetComponentType<'date-picker'>>>;
751
+ } & {
752
+ [K in ComponentName]: FP<ComponentProps<GetComponentType<K>>>;
799
753
  };
800
754
 
801
755
  declare type SearchFormProps = {
@@ -807,8 +761,6 @@ declare type SearchFormProps = {
807
761
  expandButton?: Component<ExpandButtonProps> | DefineComponent<ExpandButtonProps>;
808
762
  } & /* @vue-ignore */ _FormProps & AllowedComponentProps;
809
763
 
810
- declare type SelectSlots = CompSlot<keyof InstanceType<typeof Select>['$slots']>;
811
-
812
764
  declare type SetColumn<D extends Data = Data, C extends BaseColumn<D> = BaseColumn<D>> = (key: Path<D>, column: C | ((pre: Readonly<C>) => C), options?: {
813
765
  updateType?: 'rewrite' | 'merge';
814
766
  } & UpdateColumnOptions) => void;
@@ -817,8 +769,6 @@ declare type SetPageParam = (pageParam: Partial<PageParam> | ((pre: Readonly<Pag
817
769
 
818
770
  declare type SFCWithInstall<T> = T & Plugin_2;
819
771
 
820
- declare type SliderSlots = CompSlot<'mark'>;
821
-
822
772
  export declare const SlotComponent: DefineComponent<Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
823
773
 
824
774
  /**
@@ -833,8 +783,6 @@ export declare type Slots = {
833
783
  [name: string]: SlotComponentType;
834
784
  };
835
785
 
836
- declare type SwitchSlots = CompSlot<'checkedChildren' | 'unCheckedChildren'>;
837
-
838
786
  /**
839
787
  * 重新定义 Table 类型,将 Column 类型绑定为 antd-vue-pro 的 Column<D>
840
788
  */
@@ -855,12 +803,6 @@ declare type Table_2<D extends Data = Data, T extends object = ExtendWithAny<D>,
855
803
 
856
804
  export declare const TeleportComponentNamePrefix = "TeleportComponent_";
857
805
 
858
- declare type TimePickerSlots = CompSlot<'clearIcon' | 'renderExtraFooter' | 'suffixIcon'>;
859
-
860
- declare type TransferSlots = CompSlot<'footer' | 'render'>;
861
-
862
- declare type TreeSelectSlots = CompSlot<'maxTagPlaceholder' | 'notFoundContent' | 'placeholder' | 'searchPlaceholder' | 'suffixIcon' | 'tagRender' | 'title'>;
863
-
864
806
  declare type UpdateColumnOptions = {
865
807
  all?: boolean;
866
808
  };
@@ -984,7 +926,9 @@ export declare type WithAdditionalMethodsGetter<T> = T & {
984
926
  /**
985
927
  * @description 获取传入FormItem组件的属性
986
928
  */
987
- getFormItemComputedProps?: () => Readonly<FormItemProps>;
929
+ getFormItemComputedProps?: () => Readonly<{
930
+ [x: string]: any;
931
+ }>;
988
932
  /**
989
933
  * @description 获取组件实例的方法
990
934
  */
@@ -998,7 +942,16 @@ export declare type WithAdditionalMethodsGetter<T> = T & {
998
942
  }>;
999
943
  };
1000
944
 
1001
- declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<FormItemProps, 'label'> & ColProps & Base<D>>;
945
+ declare type WithCommon<T, D extends Data = Data> = WithRef<T & Omit<ReadonlyFormItemProps, 'label'> & ColProps & Base<D>>;
946
+
947
+ /**
948
+ * @description 自动从 Vue 组件提取 Props 和 Slots,并加上公共表单字段属性
949
+ * @template T - Vue 组件类型
950
+ * @template D - 数据对象类型
951
+ */
952
+ declare type WithComponent<T extends abstract new (...args: any) => any, D extends Data = Data> = WithCommon<{
953
+ slots?: ComponentSlots<T>;
954
+ } & ComponentProps<T>, D>;
1002
955
 
1003
956
  /**
1004
957
  * @description 为对象属性添加响应式支持的类型
package/es/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./antd-vue-pro.css";
2
2
  import _sfc_main from "./form/index.js";
3
- import { BaseField, BaseFormItem, COMPONENT_MAP, ContainerFragment, FORM_ITEM_SLOT_KEYS, SlotComponent, TeleportComponentNamePrefix, getInitProps, useFields, useForm, useFormRef } from "./form/index.js";
3
+ import { BaseField, BaseFormItem, ContainerFragment, FORM_ITEM_SLOT_KEYS, SlotComponent, TeleportComponentNamePrefix, componentMap, getInitProps, useFields, useForm, useFormRef } from "./form/index.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";
7
- import { INJECT_CONFIG } from "./component-provider/index.js";
7
+ import { INJECT_COMPONENTS, INJECT_CONFIG } from "./component-provider/index.js";
8
8
  import { I, a, e } from "./core/index-BrBzu6aj.js";
9
9
  const withInstall = (comp) => {
10
10
  comp.install = (app) => {
@@ -27,9 +27,9 @@ export {
27
27
  BaseField,
28
28
  _sfc_main as BaseForm,
29
29
  BaseFormItem,
30
- COMPONENT_MAP,
31
30
  ContainerFragment,
32
31
  FORM_ITEM_SLOT_KEYS,
32
+ INJECT_COMPONENTS,
33
33
  INJECT_CONFIG,
34
34
  I as InjectionFormKey,
35
35
  a as InjectionPathKey,
@@ -38,6 +38,7 @@ export {
38
38
  ProTable,
39
39
  SlotComponent,
40
40
  TeleportComponentNamePrefix,
41
+ componentMap,
41
42
  index as default,
42
43
  getInitProps,
43
44
  useFields,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qin-ui/antd-vue-pro",
3
- "version": "2.0.23",
3
+ "version": "2.1.1",
4
4
  "description": "二次封装antd vue组件",
5
5
  "type": "module",
6
6
  "module": "es/index.js",
@@ -26,14 +26,17 @@
26
26
  "build": "vue-tsc && vite build"
27
27
  },
28
28
  "author": "dufan3715",
29
+ "bugs": {
30
+ "url": "https://github.com/dufan3715/pro-components/issues"
31
+ },
29
32
  "license": "MIT",
30
33
  "private": false,
31
34
  "peerDependencies": {
32
35
  "ant-design-vue": "^4",
33
36
  "vue": "^3.5.0"
34
37
  },
35
- "bugs": {
36
- "url": "https://github.com/dufan3715/pro-components/issues"
38
+ "dependencies": {
39
+ "vue-component-type-helpers": "^3.2.5"
37
40
  },
38
41
  "devDependencies": {
39
42
  "@qin-ui/core": "workspace:^",
@@ -41,8 +44,7 @@
41
44
  "ant-design-vue": "^4",
42
45
  "lodash-es": "^4.17.21",
43
46
  "scroll-into-view-if-needed": "^3.1.0",
44
- "vue": "^3.5.18",
45
- "vue-component-type-helpers": "^3.0.1"
47
+ "vue": "^3.5.18"
46
48
  },
47
49
  "sideEffects": false,
48
50
  "publishConfig": {