@vue-ui-kit/ant 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { default as PGroupBlock } from './packages/components/PGroupBlock.vue';
8
8
  import { default as PromisePicker } from './packages/components/PromisePicker.vue';
9
9
  import { addFormatter } from './packages/utils/AFormatters';
10
10
  import { addRender } from './packages/store/renderStore';
11
- import { setUIKitConfig, getUIKitConfig, resetUIKitConfig, UIKitConfig } from './packages/utils/config';
11
+ import { setUIKitConfig, getUIKitConfig, resetUIKitConfig, getTooltipRenderer, UIKitConfig } from './packages/utils/config';
12
12
  declare function setup(config?: Partial<UIKitConfig>): void;
13
13
  declare const _default: {
14
14
  install(app: App): void;
@@ -19,5 +19,5 @@ declare const _default: {
19
19
  export default _default;
20
20
  export * from './declarations/antProxy';
21
21
  export * from './packages/utils/core';
22
- export { setup, setUIKitConfig, getUIKitConfig, resetUIKitConfig, type UIKitConfig };
22
+ export { setup, setUIKitConfig, getUIKitConfig, resetUIKitConfig, getTooltipRenderer, type UIKitConfig, };
23
23
  export { PForm, PGrid, PCanvasTable, PCanvasGrid, PFormGroup, PGroupBlock, PromisePicker, addFormatter, addRender, };
@@ -1,10 +1,28 @@
1
- declare const _default: import('vue').DefineSetupFnComponent<{
2
- cellRender: any;
3
- renderTableParams: any;
4
- defaultHandler: any;
5
- }, {}, {}, {
6
- cellRender: any;
7
- renderTableParams: any;
8
- defaultHandler: any;
9
- } & {}, import('vue').PublicProps>;
1
+ import { CellRender, RenderTableParams } from '../../declarations/antProxy';
2
+ declare const _default: new <D extends Recordable = Recordable<any>>(props: {
3
+ cellRender: CellRender;
4
+ renderTableParams: RenderTableParams<D>;
5
+ defaultHandler: {
6
+ [key: string]: (...args: any[]) => any;
7
+ };
8
+ } & {} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps) => import('vue').CreateComponentPublicInstanceWithMixins<{
9
+ cellRender: CellRender;
10
+ renderTableParams: RenderTableParams<D>;
11
+ defaultHandler: {
12
+ [key: string]: (...args: any[]) => any;
13
+ };
14
+ } & {}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, import('vue').ComponentProvideOptions, {
15
+ P: {};
16
+ B: {};
17
+ D: {};
18
+ C: {};
19
+ M: {};
20
+ Defaults: {};
21
+ }, {
22
+ cellRender: CellRender;
23
+ renderTableParams: RenderTableParams<D>;
24
+ defaultHandler: {
25
+ [key: string]: (...args: any[]) => any;
26
+ };
27
+ } & {}, {}, {}, {}, {}, {}>;
10
28
  export default _default;
@@ -1,14 +1,34 @@
1
- declare const _default: import('vue').DefineSetupFnComponent<{
2
- row: any;
3
- column: any;
4
- rowIndex: any;
5
- defaultHandler: any;
6
- tableData: any;
7
- }, {}, {}, {
8
- row: any;
9
- column: any;
10
- rowIndex: any;
11
- defaultHandler: any;
12
- tableData: any;
13
- } & {}, import('vue').PublicProps>;
1
+ import { ColumnProps } from '../../declarations/antProxy';
2
+ declare const _default: new <D extends Recordable = Recordable<any>>(props: {
3
+ tableData: D[];
4
+ row: D;
5
+ column: ColumnProps<D>;
6
+ rowIndex: number;
7
+ defaultHandler?: {
8
+ [key: string]: (...args: any[]) => any;
9
+ };
10
+ } & {} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps) => import('vue').CreateComponentPublicInstanceWithMixins<{
11
+ tableData: D[];
12
+ row: D;
13
+ column: ColumnProps<D>;
14
+ rowIndex: number;
15
+ defaultHandler?: {
16
+ [key: string]: (...args: any[]) => any;
17
+ };
18
+ } & {}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, import('vue').ComponentProvideOptions, {
19
+ P: {};
20
+ B: {};
21
+ D: {};
22
+ C: {};
23
+ M: {};
24
+ Defaults: {};
25
+ }, {
26
+ tableData: D[];
27
+ row: D;
28
+ column: ColumnProps<D>;
29
+ rowIndex: number;
30
+ defaultHandler?: {
31
+ [key: string]: (...args: any[]) => any;
32
+ };
33
+ } & {}, {}, {}, {}, {}, {}>;
14
34
  export default _default;
@@ -1,10 +1,25 @@
1
- declare const _default: import('vue').DefineSetupFnComponent<{
2
- cellRender: any;
3
- renderTableParams: any;
4
- }, "blur"[], {}, {
5
- cellRender: any;
6
- renderTableParams: any;
1
+ import { CellRender, RenderTableParams } from '../../declarations/antProxy';
2
+ declare const _default: new <D extends Recordable = Recordable<any>>(props: {
3
+ cellRender: CellRender;
4
+ renderTableParams: RenderTableParams<D>;
7
5
  } & {
8
6
  onBlur?: ((...args: any[]) => any) | undefined;
9
- }, import('vue').PublicProps>;
7
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps) => import('vue').CreateComponentPublicInstanceWithMixins<{
8
+ cellRender: CellRender;
9
+ renderTableParams: RenderTableParams<D>;
10
+ } & {
11
+ onBlur?: ((...args: any[]) => any) | undefined;
12
+ }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "blur"[], import('vue').PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, import('vue').ComponentProvideOptions, {
13
+ P: {};
14
+ B: {};
15
+ D: {};
16
+ C: {};
17
+ M: {};
18
+ Defaults: {};
19
+ }, {
20
+ cellRender: CellRender;
21
+ renderTableParams: RenderTableParams<D>;
22
+ } & {
23
+ onBlur?: ((...args: any[]) => any) | undefined;
24
+ }, {}, {}, {}, {}, {}>;
10
25
  export default _default;
@@ -1,12 +1,25 @@
1
- declare const _default: import('vue').DefineSetupFnComponent<{
2
- item: any;
3
- formData: any;
4
- passTrigger: any;
5
- passDelayTrigger: any;
6
- }, {}, {}, {
7
- item: any;
8
- formData: any;
9
- passTrigger: any;
10
- passDelayTrigger: any;
11
- } & {}, import('vue').PublicProps>;
1
+ import { PFormItemProps } from '../../declarations/antProxy';
2
+ declare const _default: new <F extends Recordable = Recordable<any>>(props: {
3
+ formData: F;
4
+ item: PFormItemProps<F>;
5
+ passTrigger: (cusFields?: string | string[]) => void;
6
+ passDelayTrigger: (cusFields?: string | string[], time?: number) => void;
7
+ } & {} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps) => import('vue').CreateComponentPublicInstanceWithMixins<{
8
+ formData: F;
9
+ item: PFormItemProps<F>;
10
+ passTrigger: (cusFields?: string | string[]) => void;
11
+ passDelayTrigger: (cusFields?: string | string[], time?: number) => void;
12
+ } & {}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, import('vue').ComponentProvideOptions, {
13
+ P: {};
14
+ B: {};
15
+ D: {};
16
+ C: {};
17
+ M: {};
18
+ Defaults: {};
19
+ }, {
20
+ formData: F;
21
+ item: PFormItemProps<F>;
22
+ passTrigger: (cusFields?: string | string[]) => void;
23
+ passDelayTrigger: (cusFields?: string | string[], time?: number) => void;
24
+ } & {}, {}, {}, {}, {}, {}>;
12
25
  export default _default;
@@ -1,6 +1,16 @@
1
- declare const _default: import('vue').DefineSetupFnComponent<{
2
- column: any;
3
- }, {}, {}, {
4
- column: any;
5
- } & {}, import('vue').PublicProps>;
1
+ import { ColumnProps } from '../../declarations/antProxy';
2
+ declare const _default: new <D extends Recordable = Recordable<any>>(props: {
3
+ column: ColumnProps<D>;
4
+ } & {} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps) => import('vue').CreateComponentPublicInstanceWithMixins<{
5
+ column: ColumnProps<D>;
6
+ } & {}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, import('vue').ComponentProvideOptions, {
7
+ P: {};
8
+ B: {};
9
+ D: {};
10
+ C: {};
11
+ M: {};
12
+ Defaults: {};
13
+ }, {
14
+ column: ColumnProps<D>;
15
+ } & {}, {}, {}, {}, {}, {}>;
6
16
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { PFormProps, PGridProps } from '../../declarations/antProxy';
2
2
  import { ConfigType } from 'e-virt-table';
3
+ import { VNode } from 'vue';
3
4
  export interface UIKitConfig {
4
5
  form?: {
5
6
  labelCol?: any;
@@ -13,8 +14,15 @@ export interface UIKitConfig {
13
14
  striped?: boolean;
14
15
  };
15
16
  canvasTable?: ConfigType;
17
+ /**
18
+ * 自定义 tooltip 渲染函数,替换全局所有 a-tooltip。
19
+ * @param defaultSlot 原 tooltip 触发元素(图标等)
20
+ * @param content tooltip 内容,字符串或返回 VNode 的函数
21
+ */
22
+ renderTooltip?: (defaultSlot: () => VNode, content: string | (() => VNode)) => VNode;
16
23
  }
17
24
  export declare function setUIKitConfig(config: Partial<UIKitConfig>): void;
25
+ export declare function getTooltipRenderer(): UIKitConfig['renderTooltip'];
18
26
  export declare function getUIKitConfig(): UIKitConfig;
19
27
  export declare function getFormDefaults(): Partial<PFormProps>;
20
28
  export declare function getGridDefaults(): Partial<PGridProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-ui-kit/ant",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Vue3 UI Kit based on Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -29,7 +29,7 @@
29
29
  "scripts": {
30
30
  "dev": "vue-tsc --noEmit --skipLibCheck & vite",
31
31
  "build": "ts-patch install && vite build",
32
- "prepack": "rimraf dist && yarn build",
32
+ "prepack": "rimraf dist && pnpm build",
33
33
  "prepare": "husky",
34
34
  "lint:lint-staged": "lint-staged",
35
35
  "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\""
@@ -75,11 +75,13 @@ export interface PFormItemProps<F extends Recordable = Recordable> {
75
75
  }
76
76
 
77
77
  export interface PFormProps<F extends Recordable = Recordable> extends FormProps {
78
+ name?: string;
78
79
  items: PFormItemProps<F>[];
79
80
  customReset?: () => void;
80
81
  }
81
82
 
82
83
  export interface PBlockProps<F extends Recordable = Recordable> {
84
+ name?: string;
83
85
  getFormSetting: (data: Partial<F>) => PFormProps<Partial<F>>;
84
86
  source: Partial<F>;
85
87
  }
@@ -114,6 +116,7 @@ export interface GroupMenuItem<F extends Recordable = Recordable> {
114
116
  }
115
117
 
116
118
  export interface PFormGroupProps<F extends Recordable = Recordable> {
119
+ name?: string;
117
120
  getFormSetting: (data: Partial<F>) => PFormProps<Partial<F>>;
118
121
  title?: string;
119
122
  tabLabel?: string;
package/src/index.ts CHANGED
@@ -8,7 +8,13 @@ import PGroupBlock from '@/components/PGroupBlock.vue';
8
8
  import PromisePicker from '@/components/PromisePicker.vue';
9
9
  import { addFormatter } from '@/utils/AFormatters';
10
10
  import { addRender } from '@/store/renderStore';
11
- import { setUIKitConfig, getUIKitConfig, resetUIKitConfig, UIKitConfig } from '@/utils/config';
11
+ import {
12
+ setUIKitConfig,
13
+ getUIKitConfig,
14
+ resetUIKitConfig,
15
+ getTooltipRenderer,
16
+ UIKitConfig,
17
+ } from '@/utils/config';
12
18
 
13
19
  // 创建setup方法
14
20
  function setup(config?: Partial<UIKitConfig>) {
@@ -37,7 +43,14 @@ export * from '#/antProxy';
37
43
  export * from '@/utils/core';
38
44
 
39
45
  // 导出配置方法
40
- export { setup, setUIKitConfig, getUIKitConfig, resetUIKitConfig, type UIKitConfig };
46
+ export {
47
+ setup,
48
+ setUIKitConfig,
49
+ getUIKitConfig,
50
+ resetUIKitConfig,
51
+ getTooltipRenderer,
52
+ type UIKitConfig,
53
+ };
41
54
 
42
55
  // 直接导出组件,使用户可以直接导入使用
43
56
  export {
@@ -75,7 +75,14 @@
75
75
  v-if="items.some((s: PFormItemProps<F>) => (s.field && s.itemRender) || s.slots?.default)"
76
76
  class="p-pane p-wrapper"
77
77
  >
78
- <a-form :key="renderFormKey" ref="formEl" :model="formData" v-bind="fc" @submit="handleSubmit">
78
+ <a-form
79
+ :name="name"
80
+ :key="renderFormKey"
81
+ ref="formEl"
82
+ :model="formData"
83
+ v-bind="fc"
84
+ @submit="handleSubmit"
85
+ >
79
86
  <a-row :gutter="[6, 12]">
80
87
  <p-form-col
81
88
  v-for="(item, idx) in items"
@@ -4,9 +4,11 @@
4
4
  import RenderAntItem from '@/components/RenderAntItem';
5
5
  import RenderItemSlots from '@/components/RenderItemSlots';
6
6
  import { InfoCircleOutlined } from '@ant-design/icons-vue';
7
+ import { Tooltip as ATooltip } from 'ant-design-vue';
7
8
  import { v4 as uuid_v4 } from 'uuid';
8
- import { ref } from 'vue';
9
+ import { ref, computed, h } from 'vue';
9
10
  import { isEqual, debounce, isFunction, omit } from 'xe-utils';
11
+ import { getTooltipRenderer } from '@/utils/config';
10
12
 
11
13
  const props = defineProps<{
12
14
  item: PFormItemProps<T>;
@@ -36,6 +38,31 @@
36
38
  renderFormKey.value = uuid_v4();
37
39
  };
38
40
  const debounceRefreshCol = debounce(refreshCol, 100);
41
+
42
+ // 将 tooltipConfig 统一渲染为函数式组件,支持全局 renderTooltip 替换
43
+ const tooltipNode = computed<(() => any) | null>(() => {
44
+ if (!props.item.tooltipConfig) return null;
45
+ const config = props.item.tooltipConfig;
46
+ const renderTooltip = getTooltipRenderer();
47
+ const defaultSlot = () => h(InfoCircleOutlined, { class: 'cursor-pointer py-4 px-2' });
48
+ const content: string | (() => any) = isFunction(config.title)
49
+ ? config.title
50
+ : String(config.title ?? '');
51
+
52
+ if (renderTooltip) {
53
+ return () => renderTooltip(defaultSlot, content);
54
+ }
55
+
56
+ // 默认使用 a-tooltip
57
+ return () =>
58
+ isFunction(config.title)
59
+ ? h(ATooltip, omit(config, ['title']) as any, {
60
+ default: defaultSlot,
61
+ title: () => h('div', { innerHTML: config.title!() }),
62
+ })
63
+ : h(ATooltip, config as any, { default: defaultSlot });
64
+ });
65
+
39
66
  watchPreviousDeep(
40
67
  () => props.item,
41
68
  (cur, old) => {
@@ -96,19 +123,8 @@
96
123
  @trigger="handleTrigger"
97
124
  />
98
125
  <span v-else />
99
- <template v-if="item.tooltipConfig" #tooltip>
100
- <a-tooltip
101
- v-if="isFunction(item.tooltipConfig.title)"
102
- v-bind="omit(item.tooltipConfig, ['title'])"
103
- >
104
- <info-circle-outlined class="cursor-pointer py-4 px-2" />
105
- <template #title>
106
- <div v-html="item.tooltipConfig.title()" />
107
- </template>
108
- </a-tooltip>
109
- <a-tooltip v-else v-bind="item.tooltipConfig">
110
- <info-circle-outlined class="cursor-pointer py-4 px-2" />
111
- </a-tooltip>
126
+ <template v-if="tooltipNode" #tooltip>
127
+ <component :is="tooltipNode" />
112
128
  </template>
113
129
  </a-form-item>
114
130
  </a-col>
@@ -310,6 +310,7 @@
310
310
  ref="blockInstance"
311
311
  :key="idx"
312
312
  :source="item"
313
+ :name="name ? `${name}_${idx}` : undefined"
313
314
  :get-form-setting="getFormSetting"
314
315
  @focus.capture="debounceHandleBlockFocus(idx)"
315
316
  @click.capture="debounceHandleBlockFocus(idx)"
@@ -537,6 +537,7 @@
537
537
  >
538
538
  <a-spin :spinning="loading.form">
539
539
  <a-form
540
+ :name="formConfig?.name"
540
541
  :key="renderFormKey"
541
542
  ref="formEl"
542
543
  :model="queryFormData"
@@ -13,5 +13,5 @@
13
13
  });
14
14
  </script>
15
15
  <template>
16
- <p-form ref="formEl" v-bind="formSetting" :data="source!" />
16
+ <p-form :name="name" ref="formEl" v-bind="formSetting" :data="source!" />
17
17
  </template>
@@ -1,6 +1,7 @@
1
1
  import { PFormProps, PGridProps } from '#/antProxy';
2
2
  import { ConfigType } from 'e-virt-table';
3
3
  import { clone } from 'xe-utils';
4
+ import type { VNode } from 'vue';
4
5
 
5
6
  // 全局配置接口
6
7
  export interface UIKitConfig {
@@ -16,6 +17,12 @@ export interface UIKitConfig {
16
17
  striped?: boolean;
17
18
  };
18
19
  canvasTable?: ConfigType;
20
+ /**
21
+ * 自定义 tooltip 渲染函数,替换全局所有 a-tooltip。
22
+ * @param defaultSlot 原 tooltip 触发元素(图标等)
23
+ * @param content tooltip 内容,字符串或返回 VNode 的函数
24
+ */
25
+ renderTooltip?: (defaultSlot: () => VNode, content: string | (() => VNode)) => VNode;
19
26
  }
20
27
 
21
28
  // 默认配置
@@ -55,9 +62,15 @@ export function setUIKitConfig(config: Partial<UIKitConfig>): void {
55
62
  ...currentConfig.canvasTable,
56
63
  ...config.canvasTable,
57
64
  },
65
+ renderTooltip: config.renderTooltip ?? currentConfig.renderTooltip,
58
66
  };
59
67
  }
60
68
 
69
+ // 获取自定义 tooltip 渲染函数
70
+ export function getTooltipRenderer(): UIKitConfig['renderTooltip'] {
71
+ return currentConfig.renderTooltip;
72
+ }
73
+
61
74
  // 获取配置
62
75
  export function getUIKitConfig(): UIKitConfig {
63
76
  return currentConfig;