@vue-ui-kit/ant 1.5.0 → 1.6.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/README.md +426 -0
- package/README.zh.md +480 -0
- package/dist/cjs/index.js +1 -1
- package/dist/declarations/antProxy.d.ts +3 -0
- package/dist/es/index.js +1011 -999
- package/dist/packages/components/PGrid.vue.d.ts +5 -1
- package/package.json +5 -2
- package/src/declarations/antProxy.ts +3 -1
- package/src/packages/components/PGrid.vue +39 -11
- package/tsconfig.json +41 -0
|
@@ -17,6 +17,7 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
17
17
|
selectedKeys: Array<string | number>;
|
|
18
18
|
records: D[];
|
|
19
19
|
}) => any) | undefined;
|
|
20
|
+
readonly onResetQuery?: (() => any) | undefined;
|
|
20
21
|
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<{}> & Readonly<{
|
|
21
22
|
onPick?: ((data: {
|
|
22
23
|
row: D;
|
|
@@ -34,7 +35,8 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
34
35
|
selectedKeys: Array<string | number>;
|
|
35
36
|
records: D[];
|
|
36
37
|
}) => any) | undefined;
|
|
37
|
-
|
|
38
|
+
onResetQuery?: (() => any) | undefined;
|
|
39
|
+
}>, never>, "onPick" | "onToolbarButtonClick" | "onToolbarToolClick" | "onResetQuery"> & PGridProps<D, F>> & import('vue').PublicProps;
|
|
38
40
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
39
41
|
commitProxy: {
|
|
40
42
|
query: import('lodash').DebouncedFunc<() => Promise<D[]>>;
|
|
@@ -48,6 +50,7 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
48
50
|
selectedRecords: import('vue').ComputedRef<D[]>;
|
|
49
51
|
$form: import('vue').ComputedRef<any>;
|
|
50
52
|
setLoadings: (value: boolean) => void;
|
|
53
|
+
resizeTable: () => void;
|
|
51
54
|
}>): void;
|
|
52
55
|
attrs: any;
|
|
53
56
|
slots: ReturnType<() => {}>;
|
|
@@ -68,6 +71,7 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
68
71
|
row: D;
|
|
69
72
|
field: string;
|
|
70
73
|
}): void;
|
|
74
|
+
(event: "resetQuery"): void;
|
|
71
75
|
} & {};
|
|
72
76
|
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
73
77
|
[key: string]: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-ui-kit/ant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Vue3 UI Kit based on Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"src"
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"README.zh.md",
|
|
20
|
+
"tsconfig.json"
|
|
18
21
|
],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"dev": "vue-tsc --noEmit --skipLibCheck & vite",
|
|
@@ -139,7 +139,8 @@ export interface ToolbarButtonProps extends PButtonProps {
|
|
|
139
139
|
|
|
140
140
|
export interface ToolbarConfig {
|
|
141
141
|
buttons?: Array<ToolbarButtonProps>;
|
|
142
|
-
tools?: Array<{ code: string; icon: string; type?: ButtonType }>;
|
|
142
|
+
tools?: Array<{ code: string; icon: string; type?: ButtonType; disabled?: boolean }>;
|
|
143
|
+
disabled?: boolean;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
export interface ResponsePathConfig<D = Recordable> {
|
|
@@ -259,6 +260,7 @@ export interface PGridInstance<D = Recordable, F = Recordable> {
|
|
|
259
260
|
$form: Recordable;
|
|
260
261
|
setLoadings: (value: boolean) => void;
|
|
261
262
|
setBtnLoading: (code: string, status: boolean) => void;
|
|
263
|
+
resizeTable: () => void;
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
export interface PFormInstance {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<script generic="D = Recordable, F = Recordable" lang="ts" name="PGrid" setup>
|
|
2
2
|
import { ColumnProps, PFormItemProps, PGridProps, ResponsePathConfig } from '#/antProxy';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
computed,
|
|
5
|
+
useAttrs,
|
|
6
|
+
ref,
|
|
7
|
+
Ref,
|
|
8
|
+
reactive,
|
|
9
|
+
onMounted,
|
|
10
|
+
watch,
|
|
11
|
+
toRefs,
|
|
12
|
+
onBeforeUnmount,
|
|
13
|
+
} from 'vue';
|
|
4
14
|
import { debounce, get, isArray, isFunction, isString, merge, omit, toNumber } from 'lodash-es';
|
|
5
15
|
import { eachTree } from '@/utils/treeHelper';
|
|
6
16
|
import { message as $message } from 'ant-design-vue';
|
|
@@ -44,6 +54,7 @@
|
|
|
44
54
|
});
|
|
45
55
|
const submitOnReset = true;
|
|
46
56
|
const boxEl = ref<HTMLDivElement>();
|
|
57
|
+
const pFormWrapper = ref<HTMLDivElement>();
|
|
47
58
|
const renderHeight = ref(500);
|
|
48
59
|
const selectedRowKeys = ref<Array<string | number>>([]);
|
|
49
60
|
const selectedCaches = ref<D[]>([]);
|
|
@@ -156,6 +167,7 @@
|
|
|
156
167
|
data: { data: D[]; code: string; selectedKeys: Array<string | number>; records: D[] },
|
|
157
168
|
): void;
|
|
158
169
|
(event: 'pick', data: { row: D; field: string }): void;
|
|
170
|
+
(event: 'resetQuery'): void;
|
|
159
171
|
}>();
|
|
160
172
|
// @ts-ignore
|
|
161
173
|
const selectedRecords = computed<D[]>(() =>
|
|
@@ -205,6 +217,7 @@
|
|
|
205
217
|
});
|
|
206
218
|
queryFormData.value = obj;
|
|
207
219
|
}
|
|
220
|
+
emit('resetQuery');
|
|
208
221
|
refreshForm();
|
|
209
222
|
}
|
|
210
223
|
|
|
@@ -377,6 +390,21 @@
|
|
|
377
390
|
},
|
|
378
391
|
{ deep: true },
|
|
379
392
|
);
|
|
393
|
+
const resizeTable = () => {
|
|
394
|
+
const pNode = boxEl.value?.parentElement;
|
|
395
|
+
const ph = pNode ? window.getComputedStyle(pNode).height : '0px';
|
|
396
|
+
const formHeight = pFormWrapper.value
|
|
397
|
+
? toNumber(window.getComputedStyle(pFormWrapper.value).height.replace('px', ''))
|
|
398
|
+
: 0;
|
|
399
|
+
|
|
400
|
+
renderHeight.value =
|
|
401
|
+
props.renderY ??
|
|
402
|
+
toNumber(ph.replace('px', '')) -
|
|
403
|
+
(props.fitHeight ?? 170) -
|
|
404
|
+
(!!props.toolbarConfig ? 30 : 0) -
|
|
405
|
+
formHeight;
|
|
406
|
+
enoughSpacing.value = toNumber(ph.replace('px', '')) > 600;
|
|
407
|
+
};
|
|
380
408
|
defineExpose({
|
|
381
409
|
commitProxy: {
|
|
382
410
|
query: debounceFetchData,
|
|
@@ -394,20 +422,16 @@
|
|
|
394
422
|
loading.table = value;
|
|
395
423
|
loading.toolbar = value;
|
|
396
424
|
},
|
|
425
|
+
resizeTable,
|
|
397
426
|
});
|
|
398
427
|
onMounted(() => {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const ph = pNode ? window.getComputedStyle(pNode).height : '0px';
|
|
402
|
-
renderHeight.value =
|
|
403
|
-
props.renderY ??
|
|
404
|
-
toNumber(ph.replace('px', '')) -
|
|
405
|
-
(props.fitHeight ?? 170) -
|
|
406
|
-
(!!props.toolbarConfig ? 30 : 0) -
|
|
407
|
-
Math.ceil((props.formConfig?.items?.length ?? 0) / 4) * 35;
|
|
408
|
-
enoughSpacing.value = toNumber(ph.replace('px', '')) > 600;
|
|
428
|
+
resizeTable();
|
|
429
|
+
window.addEventListener('resize', resizeTable);
|
|
409
430
|
resetQueryFormData(props.manualFetch);
|
|
410
431
|
});
|
|
432
|
+
onBeforeUnmount(() => {
|
|
433
|
+
window.removeEventListener('resize', resizeTable);
|
|
434
|
+
});
|
|
411
435
|
</script>
|
|
412
436
|
<template>
|
|
413
437
|
<div ref="boxEl" class="h-full p-wrapper flex flex-col gap-8px overflow-y-auto" v-bind="attrs">
|
|
@@ -416,6 +440,7 @@
|
|
|
416
440
|
<div
|
|
417
441
|
v-if="formConfig?.items?.some((s: PFormItemProps<F>) => s.field && s.itemRender)"
|
|
418
442
|
class="p-pane p-form-wrapper"
|
|
443
|
+
ref="pFormWrapper"
|
|
419
444
|
>
|
|
420
445
|
<a-spin :spinning="loading.form">
|
|
421
446
|
<a-form
|
|
@@ -505,6 +530,7 @@
|
|
|
505
530
|
<a-button
|
|
506
531
|
:type="btn.type"
|
|
507
532
|
:size="btn.size ?? 'small'"
|
|
533
|
+
:disabled="toolbarConfig.disabled || btn.disabled"
|
|
508
534
|
:loading="loading.toolbar || (!!btn.code && codeLoadings[btn.code])"
|
|
509
535
|
>
|
|
510
536
|
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
@@ -516,6 +542,7 @@
|
|
|
516
542
|
v-else-if="btn.code"
|
|
517
543
|
:type="btn.type"
|
|
518
544
|
:size="btn.size ?? 'small'"
|
|
545
|
+
:disabled="toolbarConfig.disabled || btn.disabled"
|
|
519
546
|
:loading="loading.toolbar || (!!btn.code && codeLoadings[btn.code])"
|
|
520
547
|
@click="debounceToolBtnClick(btn.code)"
|
|
521
548
|
>
|
|
@@ -533,6 +560,7 @@
|
|
|
533
560
|
:key="idx"
|
|
534
561
|
:type="tool.type"
|
|
535
562
|
size="small"
|
|
563
|
+
:disabled="toolbarConfig.disabled || tool.disabled"
|
|
536
564
|
@click="debounceToolToolClick(tool.code)"
|
|
537
565
|
:loading="loading.toolbar || (!!tool.code && codeLoadings[tool.code])"
|
|
538
566
|
>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
8
|
+
"noImplicitAny": false,
|
|
9
|
+
"types": [
|
|
10
|
+
"vite/client",
|
|
11
|
+
"node"
|
|
12
|
+
],
|
|
13
|
+
"jsx": "preserve",
|
|
14
|
+
"jsxImportSource": "vue",
|
|
15
|
+
"paths": {
|
|
16
|
+
"@/*": [
|
|
17
|
+
"./src/packages/*"
|
|
18
|
+
],
|
|
19
|
+
"#/*": [
|
|
20
|
+
"./src/declarations/*"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"plugins": [
|
|
24
|
+
// Transform paths in output .js files
|
|
25
|
+
{
|
|
26
|
+
"transform": "typescript-transform-paths"
|
|
27
|
+
},
|
|
28
|
+
// Transform paths for declarations files
|
|
29
|
+
{
|
|
30
|
+
"transform": "typescript-transform-paths",
|
|
31
|
+
"afterDeclarations": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"include": [
|
|
36
|
+
"src"
|
|
37
|
+
],
|
|
38
|
+
"exclude": [
|
|
39
|
+
"node_modules"
|
|
40
|
+
]
|
|
41
|
+
}
|