@vue-ui-kit/ant 2.4.5 → 2.5.0
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/cjs/index.js +4 -4
- package/dist/es/index.js +1476 -1337
- package/dist/index.d.ts +2901 -756
- package/package.json +84 -82
- package/src/declarations/antProxy.ts +48 -0
- package/src/index.ts +5 -1
- package/src/packages/components/PCanvasGrid.vue +147 -42
- package/src/packages/components/PDescription.vue +50 -0
- package/src/packages/components/PDescriptionContent.tsx +46 -0
- package/src/packages/components/PGrid.vue +26 -17
- package/src/packages/renders/Icon.ts +11 -3
- package/src/packages/store/renderStore.tsx +51 -2
- package/src/packages/utils/config.ts +11 -0
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
setup
|
|
6
6
|
>
|
|
7
7
|
import { ColumnProps, PFormItemProps, PGridProps, ResponsePathConfig } from '#/antProxy';
|
|
8
|
+
// 锚定 ant-design-vue 间接依赖的类型路径,避免 vue-tsc 推断默认导出时引用 .pnpm 物理路径触发 TS2742
|
|
9
|
+
import type {} from 'scroll-into-view-if-needed';
|
|
10
|
+
import type {} from 'vue-types';
|
|
8
11
|
import PFormCol from '@/components/PFormCol.vue';
|
|
9
12
|
import RenderDefaultSlots from '@/components/RenderDefaultSlots';
|
|
10
13
|
import RenderTitleSlots from '@/components/RenderTitleSlots';
|
|
11
14
|
import { $confirm } from '@/hooks/useMessage';
|
|
12
15
|
import Icon from '@/renders/Icon';
|
|
13
|
-
import { getGridDefaults } from '@/utils/config';
|
|
14
16
|
import {
|
|
15
17
|
createAutoViewportBoxController,
|
|
16
18
|
parseAutoViewportBoxOffset,
|
|
17
19
|
type AutoViewportBoxController,
|
|
18
20
|
type AutoViewportBoxOffsetInput,
|
|
19
21
|
} from '@/utils/autoViewportBox';
|
|
22
|
+
import { getGridDefaults } from '@/utils/config';
|
|
20
23
|
import { cleanCol, defaultLabelCol } from '@/utils/core';
|
|
21
24
|
import { isGoodValue } from '@/utils/is';
|
|
22
25
|
import { eachTree } from '@/utils/treeHelper';
|
|
@@ -678,12 +681,14 @@
|
|
|
678
681
|
:ghost="btn.ghost"
|
|
679
682
|
:block="btn.block"
|
|
680
683
|
>
|
|
681
|
-
<
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
684
|
+
<div class="flex items-center gap-4px">
|
|
685
|
+
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
686
|
+
<template v-if="btn.content && isStringContent(renderContent(btn.content))">
|
|
687
|
+
{{ renderContent(btn.content) }}
|
|
688
|
+
</template>
|
|
689
|
+
<component v-else-if="btn.content" :is="renderContent(btn.content)" />
|
|
690
|
+
<DownOutlined />
|
|
691
|
+
</div>
|
|
687
692
|
</a-button>
|
|
688
693
|
</a-dropdown>
|
|
689
694
|
<a-button
|
|
@@ -698,11 +703,13 @@
|
|
|
698
703
|
:block="btn.block"
|
|
699
704
|
@click="debounceToolBtnClick(btn.code)"
|
|
700
705
|
>
|
|
701
|
-
<
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
+
<div class="flex items-center gap-4px">
|
|
707
|
+
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
708
|
+
<template v-if="btn.content && isStringContent(renderContent(btn.content))">
|
|
709
|
+
{{ renderContent(btn.content) }}
|
|
710
|
+
</template>
|
|
711
|
+
<component v-else-if="btn.content" :is="renderContent(btn.content)" />
|
|
712
|
+
</div>
|
|
706
713
|
</a-button>
|
|
707
714
|
<div v-else></div>
|
|
708
715
|
</template>
|
|
@@ -723,11 +730,13 @@
|
|
|
723
730
|
@click="debounceToolToolClick(tool.code)"
|
|
724
731
|
:loading="loading.toolbar || (!!tool.code && codeLoadings[tool.code])"
|
|
725
732
|
>
|
|
726
|
-
<
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
733
|
+
<div class="flex items-center gap-4px">
|
|
734
|
+
<Icon v-if="tool.icon" :icon="tool.icon" />
|
|
735
|
+
<template v-if="tool.content && isStringContent(renderContent(tool.content))">
|
|
736
|
+
{{ renderContent(tool.content) }}
|
|
737
|
+
</template>
|
|
738
|
+
<component v-else-if="tool.content" :is="renderContent(tool.content)" />
|
|
739
|
+
</div>
|
|
731
740
|
</a-button>
|
|
732
741
|
</template>
|
|
733
742
|
</span>
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { createVNode } from 'vue';
|
|
1
|
+
import { createVNode, type VNode } from 'vue';
|
|
2
2
|
import * as $Icon from '@ant-design/icons-vue';
|
|
3
|
-
|
|
3
|
+
import { getUIKitConfig } from '@/utils/config';
|
|
4
|
+
|
|
5
|
+
const Icon = (props: { icon: string }): VNode | null => {
|
|
4
6
|
const { icon } = props;
|
|
7
|
+
const customRender = getUIKitConfig().icon?.render;
|
|
8
|
+
if (customRender) {
|
|
9
|
+
const custom = customRender(icon);
|
|
10
|
+
if (custom) return custom as VNode;
|
|
11
|
+
}
|
|
5
12
|
const antIcon: { [key: string]: any } = $Icon;
|
|
6
|
-
|
|
13
|
+
if (antIcon[icon]) return createVNode(antIcon[icon]);
|
|
14
|
+
return null;
|
|
7
15
|
};
|
|
8
16
|
export default Icon;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RenderFormParams,
|
|
3
|
+
RenderOptions,
|
|
4
|
+
RenderReadonlyParams,
|
|
5
|
+
RenderTableParams,
|
|
6
|
+
} from '#/antProxy';
|
|
2
7
|
import {
|
|
3
8
|
Button,
|
|
4
9
|
Dropdown,
|
|
@@ -49,6 +54,11 @@ export interface RenderWorkshop {
|
|
|
49
54
|
params: RenderTableParams,
|
|
50
55
|
defaultHandler: Recordable,
|
|
51
56
|
) => any;
|
|
57
|
+
renderReadonly?: (
|
|
58
|
+
options: RenderOptions,
|
|
59
|
+
params: RenderReadonlyParams,
|
|
60
|
+
defaultHandler: Recordable,
|
|
61
|
+
) => any;
|
|
52
62
|
renderEdit?: (
|
|
53
63
|
model: Ref<any>,
|
|
54
64
|
options: RenderOptions,
|
|
@@ -191,6 +201,21 @@ const renderBasic = (name: string) => {
|
|
|
191
201
|
<DynamicComponent is={name} {...props} />
|
|
192
202
|
);
|
|
193
203
|
},
|
|
204
|
+
renderReadonly(
|
|
205
|
+
{ props = {}, attrs = {} }: RenderOptions,
|
|
206
|
+
{ data, field }: RenderReadonlyParams,
|
|
207
|
+
) {
|
|
208
|
+
return field ? (
|
|
209
|
+
<DynamicComponent
|
|
210
|
+
is={name}
|
|
211
|
+
v-model:value={data[field]}
|
|
212
|
+
{...attrs}
|
|
213
|
+
{...merge({}, antDefaultProps[name], { disabled: true }, props)}
|
|
214
|
+
/>
|
|
215
|
+
) : (
|
|
216
|
+
<DynamicComponent is={name} {...merge({}, { disabled: true }, props)} />
|
|
217
|
+
);
|
|
218
|
+
},
|
|
194
219
|
renderEdit(
|
|
195
220
|
model: Ref<any>,
|
|
196
221
|
{ props = antDefaultProps[name] ?? {}, attrs = {}, events = {} }: RenderOptions,
|
|
@@ -516,6 +541,15 @@ const renders: RenderFactory = {
|
|
|
516
541
|
/>
|
|
517
542
|
) : null;
|
|
518
543
|
},
|
|
544
|
+
renderReadonly({ props = {}, options }: RenderOptions, { data, field }: RenderReadonlyParams) {
|
|
545
|
+
return valued(field) ? (
|
|
546
|
+
<RadioGroup
|
|
547
|
+
v-model:value={data[field!]}
|
|
548
|
+
{...merge({}, { disabled: true }, props)}
|
|
549
|
+
options={props.options ?? options ?? []}
|
|
550
|
+
/>
|
|
551
|
+
) : null;
|
|
552
|
+
},
|
|
519
553
|
},
|
|
520
554
|
$autoComplete: {
|
|
521
555
|
renderItemContent(
|
|
@@ -559,6 +593,11 @@ const renders: RenderFactory = {
|
|
|
559
593
|
/>
|
|
560
594
|
) : null;
|
|
561
595
|
},
|
|
596
|
+
renderReadonly({ props = {} }: RenderOptions, { data, field }: RenderReadonlyParams) {
|
|
597
|
+
return valued(field) ? (
|
|
598
|
+
<Switch v-model:checked={data[field!]} {...merge({}, { disabled: true }, props)} />
|
|
599
|
+
) : null;
|
|
600
|
+
},
|
|
562
601
|
},
|
|
563
602
|
$checkbox: {
|
|
564
603
|
renderItemContent(
|
|
@@ -588,6 +627,15 @@ const renders: RenderFactory = {
|
|
|
588
627
|
/>
|
|
589
628
|
) : null;
|
|
590
629
|
},
|
|
630
|
+
renderReadonly({ props = {}, options }: RenderOptions, { data, field }: RenderReadonlyParams) {
|
|
631
|
+
return valued(field) ? (
|
|
632
|
+
<CheckboxGroup
|
|
633
|
+
v-model:value={data[field!]}
|
|
634
|
+
{...merge({}, { disabled: true }, props)}
|
|
635
|
+
options={props.options ?? options ?? []}
|
|
636
|
+
/>
|
|
637
|
+
) : null;
|
|
638
|
+
},
|
|
591
639
|
},
|
|
592
640
|
$paragraph: {
|
|
593
641
|
renderDefault({ props = {} }: RenderOptions, { row, field }: RenderTableParams) {
|
|
@@ -690,7 +738,7 @@ const renders: RenderFactory = {
|
|
|
690
738
|
};
|
|
691
739
|
export const addRender = (
|
|
692
740
|
name: string,
|
|
693
|
-
{ renderItemContent, renderDefault, renderEdit }: RenderWorkshop,
|
|
741
|
+
{ renderItemContent, renderDefault, renderReadonly, renderEdit }: RenderWorkshop,
|
|
694
742
|
) => {
|
|
695
743
|
if (renders.hasOwnProperty(name)) {
|
|
696
744
|
console.warn(`render ${name} already exists, you are trying to override it`);
|
|
@@ -698,6 +746,7 @@ export const addRender = (
|
|
|
698
746
|
renders[name] = {
|
|
699
747
|
renderItemContent,
|
|
700
748
|
renderDefault,
|
|
749
|
+
renderReadonly,
|
|
701
750
|
renderEdit,
|
|
702
751
|
};
|
|
703
752
|
};
|
|
@@ -26,6 +26,12 @@ export interface UIKitConfig {
|
|
|
26
26
|
* @param content tooltip 内容,字符串或返回 VNode 的函数
|
|
27
27
|
*/
|
|
28
28
|
renderTooltip?: (defaultSlot: () => VNode, content: string | (() => VNode)) => VNode;
|
|
29
|
+
/**
|
|
30
|
+
* 自定义图标:按 `icon` 名字渲染;返回值为真时优先于 `@ant-design/icons-vue` 同名组件。
|
|
31
|
+
*/
|
|
32
|
+
icon?: {
|
|
33
|
+
render?: (name: string) => unknown;
|
|
34
|
+
};
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
// 默认配置
|
|
@@ -45,6 +51,7 @@ const defaultConfig: UIKitConfig = {
|
|
|
45
51
|
ENABLE_FINDER: true,
|
|
46
52
|
AUTO_ROW_HEIGHT: true,
|
|
47
53
|
},
|
|
54
|
+
icon: {},
|
|
48
55
|
};
|
|
49
56
|
|
|
50
57
|
// 当前配置(可被修改)
|
|
@@ -66,6 +73,10 @@ export function setUIKitConfig(config: Partial<UIKitConfig>): void {
|
|
|
66
73
|
...config.canvasTable,
|
|
67
74
|
},
|
|
68
75
|
renderTooltip: config.renderTooltip ?? currentConfig.renderTooltip,
|
|
76
|
+
icon: {
|
|
77
|
+
...currentConfig.icon,
|
|
78
|
+
...config.icon,
|
|
79
|
+
},
|
|
69
80
|
};
|
|
70
81
|
}
|
|
71
82
|
|