@vue-ui-kit/ant 1.0.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.
Files changed (50) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/declarations/antProxy.d.ts +239 -0
  3. package/dist/declarations/type.d.ts +1 -0
  4. package/dist/es/index.js +2471 -0
  5. package/dist/index.d.ts +12 -0
  6. package/dist/packages/components/PForm.vue.d.ts +28 -0
  7. package/dist/packages/components/PFormGroup.vue.d.ts +29 -0
  8. package/dist/packages/components/PGrid.vue.d.ts +40 -0
  9. package/dist/packages/components/PGroupBlock.vue.d.ts +16 -0
  10. package/dist/packages/components/PromisePicker.vue.d.ts +48 -0
  11. package/dist/packages/components/RenderAntCell.d.ts +10 -0
  12. package/dist/packages/components/RenderAntItem.d.ts +17 -0
  13. package/dist/packages/components/RenderDefaultSlots.d.ts +14 -0
  14. package/dist/packages/components/RenderItemSlots.d.ts +10 -0
  15. package/dist/packages/components/RenderTitleSlots.d.ts +6 -0
  16. package/dist/packages/hooks/useMessage.d.ts +8 -0
  17. package/dist/packages/renders/Icon.d.ts +4 -0
  18. package/dist/packages/renders/TableInput.vue.d.ts +44 -0
  19. package/dist/packages/store/renderStore.d.ts +59 -0
  20. package/dist/packages/utils/AFormatters.d.ts +19 -0
  21. package/dist/packages/utils/core.d.ts +8 -0
  22. package/dist/packages/utils/is.d.ts +2 -0
  23. package/dist/packages/utils/treeHelper.d.ts +19 -0
  24. package/dist/style.css +1 -0
  25. package/package.json +72 -0
  26. package/src/declarations/README.md +9 -0
  27. package/src/declarations/antProxy.ts +255 -0
  28. package/src/declarations/global.d.ts +133 -0
  29. package/src/declarations/type.ts +1 -0
  30. package/src/index.ts +25 -0
  31. package/src/packages/components/PForm.vue +108 -0
  32. package/src/packages/components/PFormGroup.vue +90 -0
  33. package/src/packages/components/PGrid.vue +472 -0
  34. package/src/packages/components/PGroupBlock.vue +12 -0
  35. package/src/packages/components/PromisePicker.vue +64 -0
  36. package/src/packages/components/RenderAntCell.tsx +29 -0
  37. package/src/packages/components/RenderAntItem.tsx +54 -0
  38. package/src/packages/components/RenderDefaultSlots.tsx +44 -0
  39. package/src/packages/components/RenderItemSlots.tsx +24 -0
  40. package/src/packages/components/RenderTitleSlots.tsx +15 -0
  41. package/src/packages/hooks/useMessage.ts +19 -0
  42. package/src/packages/renders/Icon.ts +8 -0
  43. package/src/packages/renders/TableInput.vue +107 -0
  44. package/src/packages/store/renderStore.tsx +515 -0
  45. package/src/packages/styles/index.scss +184 -0
  46. package/src/packages/styles/variables.scss +3 -0
  47. package/src/packages/utils/AFormatters.ts +64 -0
  48. package/src/packages/utils/core.ts +52 -0
  49. package/src/packages/utils/is.ts +2 -0
  50. package/src/packages/utils/treeHelper.ts +72 -0
@@ -0,0 +1,184 @@
1
+ @import 'variables';
2
+
3
+ .p-pane {
4
+ background-color: var(--p-theme-bg);
5
+ padding: 16px;
6
+ border-radius: 4px;
7
+ }
8
+
9
+ //region patch for env without unocss/tailwind/windicss
10
+ .w-full {
11
+ width: 100%;
12
+ }
13
+
14
+ .h-0 {
15
+ height: 0;
16
+ }
17
+
18
+ .h-full {
19
+ height: 100%;
20
+ }
21
+
22
+ .flex {
23
+ display: flex;
24
+ }
25
+
26
+ .flex-col {
27
+ flex-direction: column;
28
+ }
29
+
30
+ .flex-1 {
31
+ flex: 1;
32
+ }
33
+
34
+ .items-center {
35
+ align-items: center;
36
+ }
37
+
38
+ .justify-between {
39
+ justify-content: space-between;
40
+ }
41
+
42
+ .gap-4px {
43
+ gap: 4px;
44
+ }
45
+
46
+ .gap-8px {
47
+ gap: 8px;
48
+ }
49
+
50
+ .pt-8px {
51
+ padding-top: 8px;
52
+ }
53
+
54
+ .px-16px {
55
+ padding-left: 16px;
56
+ padding-right: 16px;
57
+ }
58
+
59
+ .mt-4px {
60
+ margin-top: 4px;
61
+ }
62
+
63
+ .text-right {
64
+ text-align: right;
65
+ }
66
+
67
+ .overflow-y-auto {
68
+ overflow-y: auto;
69
+ }
70
+
71
+ //endregion
72
+
73
+ //region P family styles
74
+ .p-theme-bg {
75
+ background-color: var(--p-theme-bg);
76
+ }
77
+
78
+ .p-wrapper {
79
+ .p-form-wrapper {
80
+ z-index: 4;
81
+ }
82
+
83
+ .p-toolbar-wrapper {
84
+ box-shadow: 0 8px #fff;
85
+ border-radius: 0.5em 0.5em 0 0;
86
+ margin-bottom: -0.5em;
87
+ }
88
+
89
+ .ant-form {
90
+ .ant-form-item {
91
+ margin-bottom: 0;
92
+
93
+ .ant-form-item-label {
94
+ display: flex;
95
+ align-items: start;
96
+ justify-content: flex-end;
97
+
98
+ & > label {
99
+ white-space: break-spaces;
100
+ align-items: flex-start;
101
+ height: fit-content;
102
+ padding-top: 0.36em;
103
+
104
+ &:after {
105
+ padding-left: 4px;
106
+ margin-inline-start: unset;
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ &.ant-form-vertical {
113
+ .ant-form-item {
114
+ .ant-form-item-label {
115
+ justify-content: flex-start;
116
+ font-weight: 600;
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ .ant-table-sticky-scroll {
123
+ visibility: hidden;
124
+ }
125
+
126
+ .ant-table-header.ant-table-sticky-holder {
127
+ //overflow: unset !important;
128
+
129
+ &:before {
130
+ content: '';
131
+ width: 100%;
132
+ position: absolute;
133
+ height: 22px;
134
+ display: block;
135
+ backdrop-filter: blur(2px);
136
+ top: -16px;
137
+ }
138
+ }
139
+
140
+ .ant-table-wrapper .ant-table-pagination.ant-pagination {
141
+ margin: unset;
142
+ padding: 16px 0;
143
+ }
144
+
145
+ .p-inner-scroll {
146
+ & > .ant-table-wrapper {
147
+ height: 100%;
148
+
149
+ & > .ant-spin-nested-loading {
150
+ height: 100%;
151
+
152
+ & > .ant-spin-container {
153
+ height: 100%;
154
+ display: flex;
155
+ flex-direction: column;
156
+
157
+ & > .ant-table {
158
+ //flex: 1;
159
+ //height: 0;
160
+ //overflow: auto;
161
+ /*border-radius: unset; 修复模糊问题 according to https://stackoverflow.com/questions/49349337/chrome-text-blur-with-overflow-yscroll-and-fixed-height*/
162
+ border-radius: unset;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ //endregion
171
+
172
+ @each $align in right center {
173
+ /**/
174
+ .p-content-align-#{$align}.ant-form-item .ant-form-item-control-input-content {
175
+ display: flex;
176
+ @if $align == right {
177
+ justify-content: flex-end;
178
+ } @else {
179
+ justify-content: center;
180
+ }
181
+ align-items: center;
182
+ text-align: #{$align};
183
+ }
184
+ }
@@ -0,0 +1,3 @@
1
+ :root {
2
+ --p-theme-bg: #fff;
3
+ }
@@ -0,0 +1,64 @@
1
+ import { isArray, isFunction, isString, toNumber } from 'lodash-es';
2
+ import { valued } from '@/utils/is';
3
+ import { CellFuncArg, ColumnProps } from '#/antProxy';
4
+
5
+ const emptyStr = `-`;
6
+ export const antFormatters = {
7
+ toString: ({ cellValue }) => (cellValue ? (cellValue.toString?.() ?? emptyStr) : emptyStr),
8
+ // 格式化选项
9
+ formatByOptions: ({ cellValue }, options: IOption[], separator = ',') => {
10
+ if (cellValue === undefined || cellValue === null) {
11
+ return emptyStr;
12
+ }
13
+ // 多选时逗号分隔
14
+ if (isArray(cellValue)) {
15
+ if (cellValue.length > 0) {
16
+ const finder = options.filter((item) => cellValue.includes(item.value));
17
+ return finder.length ? finder.map((item) => item.label).join(separator) : emptyStr;
18
+ } else {
19
+ return emptyStr;
20
+ }
21
+ }
22
+ // 单选时
23
+ const finder = options.find((item) => item.value === cellValue);
24
+ return finder ? finder.label : emptyStr;
25
+ },
26
+ // 格式化性别
27
+ formatSex: ({ cellValue }) => {
28
+ return valued(cellValue) ? (toNumber(cellValue) === 1 ? '男' : '女') : emptyStr;
29
+ },
30
+ };
31
+ export const renderAntFormat = <D = Recordable>(
32
+ formatter: string | [string, ...Array<any>] | ((arg: CellFuncArg<D>) => any),
33
+ {
34
+ record,
35
+ index,
36
+ column,
37
+ field,
38
+ }: { record: D; index: number; field?: string; column: ColumnProps<D> },
39
+ ) => {
40
+ if (isString(formatter) && antFormatters[formatter]) {
41
+ const func = antFormatters[formatter];
42
+ return func({ row: record, rowIndex: index, cellValue: field ? record[field] : null });
43
+ } else if (isArray(formatter) && antFormatters[formatter[0]] && formatter.length > 1) {
44
+ const func = antFormatters[formatter[0]];
45
+ return func(
46
+ { row: record, rowIndex: index, cellValue: field ? record[field] : null },
47
+ ...formatter.slice(1),
48
+ );
49
+ } else if (isFunction(formatter)) {
50
+ return formatter({
51
+ row: record,
52
+ rowIndex: index,
53
+ cellValue: field ? record[field] : null,
54
+ column,
55
+ });
56
+ } else {
57
+ return field ? record[field] : null;
58
+ }
59
+ };
60
+ export const addFormatter = (
61
+ formatter: Record<string, (a: CellFuncArg, ...args: any[]) => any>,
62
+ ) => {
63
+ Object.assign(antFormatters, formatter);
64
+ };
@@ -0,0 +1,52 @@
1
+ import { ColumnProps, Responsive } from '#/antProxy';
2
+ import { TableColumnGroupType, TableColumnType } from 'ant-design-vue';
3
+ import { isArray, isNumber, omit, zipObject } from 'lodash-es';
4
+ import { valued } from '@/utils/is';
5
+
6
+ export const cleanCol = (col: ColumnProps): TableColumnType | TableColumnGroupType<Recordable> => {
7
+ return {
8
+ dataIndex: col.field,
9
+ key: col.field,
10
+ title: col.title,
11
+ ...omit(col, ['children', 'slots', 'cellRender', 'formatter']),
12
+ children: col.children?.map((subCol) => cleanCol(subCol)),
13
+ };
14
+ };
15
+
16
+ export const defaultItemResponsive: Responsive = { xs: 24, sm: 24, md: 12, lg: 8, xl: 8, xxl: 6 };
17
+ export const defaultLabelCol: Responsive = { xs: 12, sm: 5, md: 6, lg: 6, xl: 5, xxl: 4 }; //defaultItemResponsive对应的labelCol 大概4字
18
+ export const labelColDict: Record<number, Responsive> = {
19
+ 1: { xs: 12, sm: 5, md: 6, lg: 6, xl: 5, xxl: 4 },
20
+ 2: { xs: 12, sm: 5, md: 6, lg: 6, xl: 5, xxl: 4 },
21
+ 3: { xs: 12, sm: 5, md: 6, lg: 6, xl: 5, xxl: 5 },
22
+ 4: { xs: 12, sm: 4, md: 6, lg: 9, xl: 7, xxl: 6 },
23
+ 5: { xs: 12, sm: 4, md: 6, lg: 9, xl: 7, xxl: 6 },
24
+ 6: { xs: 12, sm: 6, md: 8, lg: 10, xl: 7, xxl: 8 },
25
+ 7: { xs: 12, sm: 6, md: 8, lg: 10, xl: 9, xxl: 9 },
26
+ 8: { xs: 12, sm: 6, md: 8, lg: 10, xl: 7, xxl: 9 },
27
+ 9: { xs: 12, sm: 6, md: 8, lg: 10, xl: 9, xxl: 10 },
28
+ };
29
+ export const get24rest = (exist: number[]) => {
30
+ /*24为一行,获取最后一行余数,为0则是24*/
31
+ const total = exist.reduce((prev, cur) => prev + cur, 0);
32
+ const rest = (24 - total) % 24;
33
+ const firstRest = rest === 0 ? 24 : rest < 0 ? 24 + rest : rest;
34
+ /*当其依然为1时使其为24*/
35
+ return firstRest > 1 ? firstRest : 24;
36
+ };
37
+ const resKeys = ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
38
+ export const getButtonResponsive = (itemResponsive: number | Responsive[]) => {
39
+ const existResponsive: Responsive[] = isArray(itemResponsive)
40
+ ? itemResponsive
41
+ : isNumber(itemResponsive)
42
+ ? Array.from({ length: itemResponsive }, () => defaultItemResponsive)
43
+ : [];
44
+ return zipObject(
45
+ resKeys,
46
+ resKeys.map((key) =>
47
+ existResponsive.every((e) => valued(e[key]))
48
+ ? get24rest(existResponsive.map((e) => e[key]!))
49
+ : 24,
50
+ ),
51
+ );
52
+ };
@@ -0,0 +1,2 @@
1
+ export const noValue = (val: any) => val === null || val === undefined || val === '';
2
+ export const valued = (val: any) => !noValue(val);
@@ -0,0 +1,72 @@
1
+ interface TreeConfig {
2
+ children?: string;
3
+ }
4
+
5
+ type TreeDefaultHandler<T> = (
6
+ arent: null | ITreeAble<T>,
7
+ parent: ITreeAble<T>[],
8
+ treeData: (
9
+ item: T | ITreeAble<T>,
10
+ index?: number,
11
+ treeData?: ITreeAble<T>[],
12
+ paths?: string[],
13
+ parent?: null | ITreeAble<T>,
14
+ nodes?: Array<T | ITreeAble<T>>,
15
+ ) => any,
16
+ iterate: any,
17
+ context: string[],
18
+ path: Array<T | ITreeAble<T>>,
19
+ node: string,
20
+ parseChildren: TreeConfig,
21
+ ) => any;
22
+
23
+ const helperCreateTreeFunc = <T extends Recordable>(handle: TreeDefaultHandler<T>) => {
24
+ return function (
25
+ treeData: ITreeAble<T>[],
26
+ iterate: (item: T | ITreeAble<T>) => any,
27
+ options?: TreeConfig,
28
+ context?: any,
29
+ ) {
30
+ const opts = options || {};
31
+ const optChildren = opts.children || 'children';
32
+ return handle(null, treeData, iterate, context, [], [], optChildren, opts);
33
+ };
34
+ };
35
+ const eachTreeItem = <T extends Recordable>(
36
+ parent: null | ITreeAble<T>,
37
+ treeData: ITreeAble<T>[],
38
+ iterate: (
39
+ item: T | ITreeAble<T>,
40
+ index?: number,
41
+ treeData?: ITreeAble<T>[],
42
+ paths?: string[],
43
+ parent?: null | ITreeAble<T>,
44
+ nodes?: Array<T | ITreeAble<T>>,
45
+ ) => any,
46
+ context: any,
47
+ path: string[],
48
+ node: Array<T | ITreeAble<T>>,
49
+ parseChildren: string,
50
+ opts: TreeConfig,
51
+ ) => {
52
+ let paths: string[], nodes: Array<T | ITreeAble<T>>;
53
+ treeData.forEach((item, index) => {
54
+ paths = path.concat(['' + index]);
55
+ nodes = node.concat([item]);
56
+ iterate.call(context, item, index, treeData, paths, parent, nodes);
57
+ if (item && parseChildren) {
58
+ paths.push(parseChildren);
59
+ eachTreeItem(
60
+ item,
61
+ item[parseChildren] || [],
62
+ iterate,
63
+ context,
64
+ paths,
65
+ nodes,
66
+ parseChildren,
67
+ opts,
68
+ );
69
+ }
70
+ });
71
+ };
72
+ export const eachTree = helperCreateTreeFunc(eachTreeItem);