@gx-design-vue/pro-table 0.2.0-alpha.8 → 0.2.0-alpha.9
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/ProTable.d.ts +14 -492
- package/dist/ProTable.js +818 -518
- package/dist/components/ScrollBar/Bar.d.ts +81 -0
- package/dist/components/ScrollBar/Bar.js +84 -0
- package/dist/components/ScrollBar/Thumb.d.ts +52 -0
- package/dist/components/ScrollBar/{Thumb/index.js → Thumb.js} +67 -55
- package/dist/components/ScrollBar/context.d.ts +3 -4
- package/dist/components/ScrollBar/context.js +3 -3
- package/dist/components/ScrollBar/util.d.ts +6 -5
- package/dist/components/ScrollBar/util.js +1 -12
- package/dist/components/SearchForm/CollapseToggle.d.ts +55 -0
- package/dist/components/SearchForm/CollapseToggle.js +47 -0
- package/dist/components/SearchForm/FormItemContainer.d.ts +75 -0
- package/dist/components/SearchForm/FormItemContainer.js +225 -0
- package/dist/components/SearchForm/FormItemWrapper.d.ts +82 -0
- package/dist/components/SearchForm/FormItemWrapper.js +62 -0
- package/dist/components/SearchForm/SearchForm.d.ts +130 -0
- package/dist/components/SearchForm/SearchForm.js +319 -0
- package/dist/components/SearchForm/index.d.ts +2 -0
- package/dist/components/SearchForm/index.js +2 -0
- package/dist/components/Toolbar/FullscreenIcon.d.ts +26 -0
- package/dist/components/Toolbar/FullscreenIcon.js +22 -0
- package/dist/components/Toolbar/ListToolBar.d.ts +111 -0
- package/dist/components/Toolbar/ListToolBar.js +101 -0
- package/dist/components/Toolbar/index.d.ts +103 -0
- package/dist/components/Toolbar/index.js +101 -0
- package/dist/components/Toolbar/style.d.ts +8 -0
- package/dist/components/{ListToolBar → Toolbar}/style.js +32 -27
- package/dist/context/TableContext.d.ts +15 -27
- package/dist/context/TableContext.js +3 -3
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/useBreakpoints.d.ts +13 -0
- package/dist/hooks/useBreakpoints.js +57 -0
- package/dist/hooks/useCellRender.d.ts +13 -0
- package/dist/hooks/useCellRender.js +28 -0
- package/dist/hooks/useColumnResize.d.ts +30 -0
- package/dist/hooks/useColumnResize.js +110 -0
- package/dist/hooks/useColumns.d.ts +35 -24
- package/dist/hooks/useColumns.js +89 -56
- package/dist/hooks/useFetchData.d.ts +40 -65
- package/dist/hooks/useFetchData.js +157 -172
- package/dist/hooks/useFitPage.d.ts +19 -0
- package/dist/hooks/useFitPage.js +90 -0
- package/dist/hooks/useKeepAliveReload.d.ts +21 -0
- package/dist/hooks/useKeepAliveReload.js +24 -0
- package/dist/hooks/useLoading.d.ts +18 -7
- package/dist/hooks/useLoading.js +26 -8
- package/dist/hooks/usePagination.d.ts +10 -7
- package/dist/hooks/usePagination.js +37 -26
- package/dist/hooks/useRequestOptions.d.ts +18 -0
- package/dist/hooks/useRequestOptions.js +39 -0
- package/dist/hooks/useRowSelection.d.ts +27 -15
- package/dist/hooks/useRowSelection.js +92 -77
- package/dist/hooks/useTable.d.ts +19 -77
- package/dist/hooks/useTable.js +66 -54
- package/dist/hooks/useTableForm.d.ts +15 -83
- package/dist/hooks/useTableForm.js +93 -57
- package/dist/hooks/useTableScroll.d.ts +33 -31
- package/dist/hooks/useTableScroll.js +71 -26
- package/dist/hooks/useTableSize.d.ts +17 -7
- package/dist/hooks/useTableSize.js +20 -6
- package/dist/index.d.ts +10 -7
- package/dist/index.js +9 -3
- package/dist/interface.d.ts +492 -0
- package/dist/pro-table.esm.js +3512 -3965
- package/dist/pro-table.js +1 -1
- package/dist/style/fit-page.d.ts +4 -2
- package/dist/style/fit-page.js +9 -3
- package/dist/style/index.d.ts +4 -6
- package/dist/style/index.js +24 -74
- package/dist/style/list.d.ts +4 -2
- package/dist/style/list.js +1 -10
- package/dist/style/resizable.d.ts +8 -0
- package/dist/style/resizable.js +18 -0
- package/dist/style/scroll.d.ts +4 -2
- package/dist/style/scroll.js +8 -6
- package/dist/style/search.d.ts +8 -0
- package/dist/{components/Form/style.js → style/search.js} +22 -8
- package/dist/theme/augment.d.ts +8 -0
- package/dist/theme/interface/components.d.ts +8 -0
- package/dist/utils/dateFormat.d.ts +9 -0
- package/dist/utils/dateFormat.js +29 -0
- package/dist/utils/formConstants.d.ts +9 -0
- package/dist/utils/formConstants.js +29 -0
- package/dist/utils/valueFormat.d.ts +9 -0
- package/dist/utils/valueFormat.js +27 -0
- package/package.json +10 -9
- package/dist/components/Form/components/RequestSelect.d.ts +0 -50
- package/dist/components/Form/components/RequestSelect.js +0 -56
- package/dist/components/Form/hooks/useForm.d.ts +0 -11
- package/dist/components/Form/hooks/useForm.js +0 -30
- package/dist/components/Form/index.d.ts +0 -32
- package/dist/components/Form/index.js +0 -504
- package/dist/components/Form/style.d.ts +0 -6
- package/dist/components/Form/utils/config.d.ts +0 -9
- package/dist/components/Form/utils/config.js +0 -29
- package/dist/components/Form/utils/dateFormat.d.ts +0 -22
- package/dist/components/Form/utils/dateFormat.js +0 -43
- package/dist/components/ListToolBar/index.d.ts +0 -59
- package/dist/components/ListToolBar/index.js +0 -123
- package/dist/components/ListToolBar/style.d.ts +0 -6
- package/dist/components/ScrollBar/Bar/index.d.ts +0 -49
- package/dist/components/ScrollBar/Bar/index.js +0 -68
- package/dist/components/ScrollBar/Bar/props.d.ts +0 -25
- package/dist/components/ScrollBar/Bar/props.js +0 -17
- package/dist/components/ScrollBar/Thumb/index.d.ts +0 -40
- package/dist/components/ScrollBar/Thumb/props.d.ts +0 -20
- package/dist/components/ScrollBar/Thumb/props.js +0 -17
- package/dist/components/TableCell/index.d.ts +0 -37
- package/dist/components/TableCell/index.js +0 -69
- package/dist/components/ToolBar/FullscreenIcon.d.ts +0 -7
- package/dist/components/ToolBar/FullscreenIcon.js +0 -11
- package/dist/components/ToolBar/index.d.ts +0 -34
- package/dist/components/ToolBar/index.js +0 -97
- package/dist/hooks/tryOnActivated.d.ts +0 -6
- package/dist/hooks/tryOnActivated.js +0 -12
- package/dist/hooks/useDebounceFn.d.ts +0 -8
- package/dist/hooks/useDebounceFn.js +0 -31
- package/dist/hooks/useScrollArea.d.ts +0 -24
- package/dist/hooks/useScrollArea.js +0 -102
- package/dist/props.d.ts +0 -340
- package/dist/props.js +0 -247
- package/dist/types/ColumnTypings.d.ts +0 -130
- package/dist/types/SlotsTypings.d.ts +0 -63
- package/dist/types/SlotsTypings.js +0 -12
- package/dist/types/TableTypings.d.ts +0 -359
- package/dist/types/index.d.ts +0 -9
- package/dist/utils/utils.d.ts +0 -10
- package/dist/utils/utils.js +0 -89
- /package/dist/{types/ColumnTypings.js → interface.js} +0 -0
- /package/dist/{types/TableTypings.js → theme/augment.js} +0 -0
- /package/dist/{types/index.js → theme/interface/components.js} +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { useProBreakpoints } from "../../hooks/useBreakpoints.js";
|
|
2
|
+
import { formatDateRangeArray, formatStringValue, resolveValueFormat } from "../../utils/dateFormat.js";
|
|
3
|
+
import { CollapseToggle } from "./CollapseToggle.js";
|
|
4
|
+
import { FormItemContainer } from "./FormItemContainer.js";
|
|
5
|
+
import { FormItemWrapper } from "./FormItemWrapper.js";
|
|
6
|
+
import { computed, createVNode, defineComponent, isVNode, ref, watch } from "vue";
|
|
7
|
+
import { classNames, filterEmpty, isArray, isBoolean, isNumber, isObject } from "@gx-design-vue/pro-utils";
|
|
8
|
+
import { Button } from "antdv-next";
|
|
9
|
+
import { cloneDeep as cloneDeep$1 } from "es-toolkit";
|
|
10
|
+
//#region src/components/SearchForm/SearchForm.tsx
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13
|
+
}
|
|
14
|
+
const ProTableSearchForm = /* @__PURE__ */ defineComponent({
|
|
15
|
+
name: "ProTableSearchForm",
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: {
|
|
18
|
+
prefixCls: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
formColumns: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
formState: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
defaultFormSearch: {
|
|
31
|
+
type: Object,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
formConfig: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: void 0
|
|
37
|
+
},
|
|
38
|
+
formAutoRequest: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
formActions: {
|
|
43
|
+
type: Object,
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
loading: {
|
|
47
|
+
type: [Boolean, Object],
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
cardBordered: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
proClasses: {
|
|
55
|
+
type: Object,
|
|
56
|
+
default: () => ({})
|
|
57
|
+
},
|
|
58
|
+
proStyles: {
|
|
59
|
+
type: Object,
|
|
60
|
+
default: () => ({})
|
|
61
|
+
},
|
|
62
|
+
onSearch: {
|
|
63
|
+
type: Function,
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
onReset: {
|
|
67
|
+
type: Function,
|
|
68
|
+
default: void 0
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setup(props, { slots, expose }) {
|
|
72
|
+
const collapsed = ref(props.formConfig?.collapsed ?? props.formConfig?.defaultCollapsed);
|
|
73
|
+
watch(() => props.formConfig?.collapsed, (value) => {
|
|
74
|
+
collapsed.value = value;
|
|
75
|
+
});
|
|
76
|
+
const { getRowItemsPerBreakpoint } = useProBreakpoints();
|
|
77
|
+
const formConfig = computed(() => props.formConfig);
|
|
78
|
+
const formAutoRequest = computed(() => props.formAutoRequest);
|
|
79
|
+
const formActions = computed(() => props.formActions);
|
|
80
|
+
const breakpoint = computed(() => {
|
|
81
|
+
if (formConfig.value?.breakpoint && isObject(formConfig.value.breakpoint) && Object.keys(formConfig.value.breakpoint).length > 0) return formConfig.value.breakpoint;
|
|
82
|
+
});
|
|
83
|
+
const rowLength = computed(() => {
|
|
84
|
+
return getRowItemsPerBreakpoint(formConfig.value?.span, breakpoint.value);
|
|
85
|
+
});
|
|
86
|
+
const gap = computed(() => {
|
|
87
|
+
const gapValue = formConfig.value?.gap;
|
|
88
|
+
return typeof gapValue === "number" ? `${gapValue}px` : gapValue ?? "16px";
|
|
89
|
+
});
|
|
90
|
+
const formItemLabel = computed(() => formConfig.value?.label);
|
|
91
|
+
const showResetButton = computed(() => {
|
|
92
|
+
if (isBoolean(formActions.value?.reset)) return formActions.value.reset;
|
|
93
|
+
return !formAutoRequest.value;
|
|
94
|
+
});
|
|
95
|
+
function handleFormFieldChange(value, record, options) {
|
|
96
|
+
const name = record.name;
|
|
97
|
+
const valueType = record.valueType ?? "text";
|
|
98
|
+
let newValue = value;
|
|
99
|
+
switch (valueType) {
|
|
100
|
+
case "text": break;
|
|
101
|
+
case "number":
|
|
102
|
+
newValue = value ?? void 0;
|
|
103
|
+
break;
|
|
104
|
+
case "numberRange":
|
|
105
|
+
if ((options?.key === 0 || options?.key === 1) && props.formState[name]) {
|
|
106
|
+
const updated = [...Array.isArray(props.formState[name]) ? props.formState[name] : []];
|
|
107
|
+
if (options?.key !== void 0) updated[options.key] = value ?? "";
|
|
108
|
+
newValue = updated;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "select":
|
|
112
|
+
newValue = value ?? void 0;
|
|
113
|
+
break;
|
|
114
|
+
case "treeSelect":
|
|
115
|
+
newValue = value ?? (record.field?.treeCheckable || record.field?.multiple ? [] : null);
|
|
116
|
+
break;
|
|
117
|
+
case "cascader":
|
|
118
|
+
newValue = value ?? void 0;
|
|
119
|
+
break;
|
|
120
|
+
case "date": {
|
|
121
|
+
const format = resolveValueFormat(record.valueFormat, record.showTime);
|
|
122
|
+
newValue = value ? formatStringValue(value, format) : null;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "dateWeek":
|
|
126
|
+
newValue = value ? formatStringValue(value, "YYYY-wo") : null;
|
|
127
|
+
break;
|
|
128
|
+
case "dateMonth":
|
|
129
|
+
newValue = value ? formatStringValue(value, "YYYY-MM") : null;
|
|
130
|
+
break;
|
|
131
|
+
case "dateQuarter":
|
|
132
|
+
newValue = value ? formatStringValue(value, "YYYY-QQ") : null;
|
|
133
|
+
break;
|
|
134
|
+
case "dateYear":
|
|
135
|
+
newValue = value ? formatStringValue(value, "YYYY") : null;
|
|
136
|
+
break;
|
|
137
|
+
case "dateRange": {
|
|
138
|
+
const format = resolveValueFormat(record.valueFormat, record.showTime);
|
|
139
|
+
newValue = value && isArray(value) && value.length === 2 ? formatDateRangeArray(value, format, "string") : null;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case "time":
|
|
143
|
+
newValue = value ? formatStringValue(value, record.valueFormat || "HH:mm:ss") : null;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
props.formState[name] = newValue;
|
|
147
|
+
handleAutoSubmit();
|
|
148
|
+
}
|
|
149
|
+
function handleAutoSubmit() {
|
|
150
|
+
if (formAutoRequest.value) handleSubmit();
|
|
151
|
+
}
|
|
152
|
+
function handleSubmit() {
|
|
153
|
+
const searchParams = buildFormSearchParams();
|
|
154
|
+
props.onSearch(searchParams);
|
|
155
|
+
}
|
|
156
|
+
function handleManualSubmit() {
|
|
157
|
+
const searchParams = buildFormSearchParams();
|
|
158
|
+
props.onSearch(searchParams, "submit");
|
|
159
|
+
}
|
|
160
|
+
function buildFormSearchParams() {
|
|
161
|
+
const searchParams = cloneDeep$1(props.formState);
|
|
162
|
+
for (const record of props.formColumns) {
|
|
163
|
+
const valueType = record.valueType ?? "text";
|
|
164
|
+
const name = record.name;
|
|
165
|
+
if (valueType === "text") searchParams[name] = props.formState[name] ?? record.initialValue;
|
|
166
|
+
if (valueType === "dateRange" && (record.rangeStartName || record.rangeEndName)) {
|
|
167
|
+
const rangeValue = searchParams[name];
|
|
168
|
+
searchParams[record.rangeStartName || "start"] = Array.isArray(rangeValue) ? rangeValue[0] : void 0;
|
|
169
|
+
searchParams[record.rangeEndName || "end"] = Array.isArray(rangeValue) ? rangeValue[1] : void 0;
|
|
170
|
+
delete searchParams[name];
|
|
171
|
+
}
|
|
172
|
+
if (valueType === "cascader" && record.valueKey === "single") {
|
|
173
|
+
const value = searchParams[name];
|
|
174
|
+
searchParams[name] = Array.isArray(value) ? value[value.length - 1] : void 0;
|
|
175
|
+
}
|
|
176
|
+
if (valueType === "numberRange") {
|
|
177
|
+
const value = searchParams[name];
|
|
178
|
+
searchParams[name] = Array.isArray(value) && value.some((val) => isNumber(val)) ? value : void 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return searchParams;
|
|
182
|
+
}
|
|
183
|
+
function resetForm() {
|
|
184
|
+
const defaults = cloneDeep$1(props.defaultFormSearch);
|
|
185
|
+
Object.keys(props.formState).forEach((key) => {
|
|
186
|
+
props.formState[key] = key in defaults ? defaults[key] : void 0;
|
|
187
|
+
});
|
|
188
|
+
for (const record of props.formColumns) if (record.valueType === "dateRange" && (record.rangeStartName || record.rangeEndName)) {
|
|
189
|
+
const startKey = record.rangeStartName || "start";
|
|
190
|
+
const endKey = record.rangeEndName || "end";
|
|
191
|
+
if (defaults[startKey] !== void 0 || defaults[endKey] !== void 0) props.formState[record.name] = [defaults[startKey], defaults[endKey]];
|
|
192
|
+
}
|
|
193
|
+
const searchParams = buildFormSearchParams();
|
|
194
|
+
props.onSearch(searchParams, "reset");
|
|
195
|
+
props.onReset?.(searchParams);
|
|
196
|
+
}
|
|
197
|
+
function handleCollapseToggle(status) {
|
|
198
|
+
collapsed.value = status;
|
|
199
|
+
}
|
|
200
|
+
expose({
|
|
201
|
+
handleSubmit,
|
|
202
|
+
resetForm
|
|
203
|
+
});
|
|
204
|
+
function getFormItemStyle(index, itemsPerRow, containerGap) {
|
|
205
|
+
const rowWidth = { width: `calc((100% - (${itemsPerRow - 1} * ${containerGap})) / ${itemsPerRow})` };
|
|
206
|
+
return (index + 1) % itemsPerRow === 0 ? {
|
|
207
|
+
...rowWidth,
|
|
208
|
+
marginRight: 0
|
|
209
|
+
} : {
|
|
210
|
+
...rowWidth,
|
|
211
|
+
marginRight: containerGap
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return () => {
|
|
215
|
+
const formNode = [...props.formColumns];
|
|
216
|
+
const normalizedSlots = filterEmpty(slots.default?.() || []);
|
|
217
|
+
const mergedFormItems = sortFormItemsByOrder([...formNode, ...normalizedSlots.map((item) => ({
|
|
218
|
+
...item,
|
|
219
|
+
order: item.props?.order ?? void 0
|
|
220
|
+
}))]);
|
|
221
|
+
const itemsPerRow = rowLength.value;
|
|
222
|
+
const containerGap = gap.value;
|
|
223
|
+
const totalItems = mergedFormItems.length;
|
|
224
|
+
const isCollapsed = collapsed.value !== false;
|
|
225
|
+
const showCollapse = totalItems > itemsPerRow;
|
|
226
|
+
const renderFormItem = (item, index) => {
|
|
227
|
+
const formItemStyle = getFormItemStyle(index, itemsPerRow, containerGap);
|
|
228
|
+
const label = isVNode(item) ? item.props?.label : item.label;
|
|
229
|
+
const labelWidth = (isVNode(item) ? item.props?.labelWidth : item.labelWidth) ?? formItemLabel.value?.width;
|
|
230
|
+
const labelAlign = (isVNode(item) ? item.props?.labelAlign : item.labelAlign) ?? formItemLabel.value?.align;
|
|
231
|
+
if (isVNode(item)) return createVNode(FormItemWrapper, {
|
|
232
|
+
"label": label,
|
|
233
|
+
"labelWidth": labelWidth,
|
|
234
|
+
"labelAlign": labelAlign,
|
|
235
|
+
"colon": formItemLabel.value?.colon,
|
|
236
|
+
"globalLabelGap": formItemLabel.value?.gap,
|
|
237
|
+
"prefixCls": props.prefixCls,
|
|
238
|
+
"formItemStyle": formItemStyle
|
|
239
|
+
}, _isSlot(item) ? item : { default: () => [item] });
|
|
240
|
+
return createVNode(FormItemWrapper, {
|
|
241
|
+
"key": String(item.name ?? item.key ?? index),
|
|
242
|
+
"label": item.label,
|
|
243
|
+
"labelWidth": labelWidth,
|
|
244
|
+
"labelAlign": labelAlign,
|
|
245
|
+
"colon": formItemLabel.value?.colon,
|
|
246
|
+
"globalLabelGap": formItemLabel.value?.gap,
|
|
247
|
+
"prefixCls": props.prefixCls,
|
|
248
|
+
"formItemStyle": formItemStyle
|
|
249
|
+
}, { default: () => [createVNode(FormItemContainer, {
|
|
250
|
+
"prefixCls": props.prefixCls,
|
|
251
|
+
"record": item,
|
|
252
|
+
"formState": props.formState,
|
|
253
|
+
"autoRequest": formAutoRequest.value,
|
|
254
|
+
"loading": typeof props.loading === "boolean" ? props.loading : false,
|
|
255
|
+
"onChange": handleFormFieldChange,
|
|
256
|
+
"onSubmit": handleAutoSubmit
|
|
257
|
+
}, null)] });
|
|
258
|
+
};
|
|
259
|
+
const renderActionButtons = () => {
|
|
260
|
+
if (!showResetButton.value && formAutoRequest.value) return null;
|
|
261
|
+
return createVNode("div", {
|
|
262
|
+
"class": [`${props.prefixCls}-search-buttons`, props.proClasses.searchButtons],
|
|
263
|
+
"style": props.proStyles.searchButtons
|
|
264
|
+
}, [showResetButton.value && createVNode(Button, {
|
|
265
|
+
"key": "reset",
|
|
266
|
+
"onClick": resetForm
|
|
267
|
+
}, { default: () => [formActions.value?.resetText || "重置"] }), !formAutoRequest.value && createVNode(Button, {
|
|
268
|
+
"key": "submit",
|
|
269
|
+
"type": "primary",
|
|
270
|
+
"loading": typeof props.loading === "boolean" ? props.loading : false,
|
|
271
|
+
"onClick": handleManualSubmit
|
|
272
|
+
}, { default: () => [formActions.value?.searchText || "查询"] })]);
|
|
273
|
+
};
|
|
274
|
+
const renderCollapseToggle = (show, isCollapsedState) => {
|
|
275
|
+
if (formConfig.value?.collapseRender === false && !renderActionButtons()) return null;
|
|
276
|
+
const actionBtns = renderActionButtons();
|
|
277
|
+
if (!show && !actionBtns) return null;
|
|
278
|
+
return createVNode("div", {
|
|
279
|
+
"class": [`${props.prefixCls}-search-control`, props.proClasses.searchControl],
|
|
280
|
+
"style": {
|
|
281
|
+
flex: 1,
|
|
282
|
+
justifyContent: "flex-end",
|
|
283
|
+
...props.proStyles.searchControl
|
|
284
|
+
}
|
|
285
|
+
}, [createVNode("div", { "class": [`${props.prefixCls}-search-control-content`, props.proClasses.searchContent] }, [actionBtns, show && createVNode(CollapseToggle, {
|
|
286
|
+
"collapsed": isCollapsedState,
|
|
287
|
+
"collapseRender": formConfig.value?.collapseRender,
|
|
288
|
+
"prefixCls": props.prefixCls,
|
|
289
|
+
"onToggle": handleCollapseToggle
|
|
290
|
+
}, null)])]);
|
|
291
|
+
};
|
|
292
|
+
const borderedCls = props.cardBordered ? `${props.prefixCls}-search-border` : "";
|
|
293
|
+
const visibleItemCount = totalItems <= itemsPerRow || !isCollapsed ? totalItems : Math.max(itemsPerRow - 1, 0);
|
|
294
|
+
return createVNode("div", {
|
|
295
|
+
"class": classNames(props.proClasses.search, `${props.prefixCls}-search`, borderedCls, formConfig.value?.className),
|
|
296
|
+
"style": props.proStyles.search
|
|
297
|
+
}, [mergedFormItems.slice(0, visibleItemCount).map((item, index) => renderFormItem(item, index)), renderCollapseToggle(showCollapse, isCollapsed)]);
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
function sortFormItemsByOrder(items) {
|
|
302
|
+
let maxOrder = items.reduce((max, item) => {
|
|
303
|
+
return item.order !== void 0 ? Math.max(max, item.order) : max;
|
|
304
|
+
}, 0);
|
|
305
|
+
const sorted = items.map((item) => {
|
|
306
|
+
if (item.order === void 0) {
|
|
307
|
+
maxOrder += 1;
|
|
308
|
+
return {
|
|
309
|
+
...item,
|
|
310
|
+
order: maxOrder
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
return item;
|
|
314
|
+
});
|
|
315
|
+
sorted.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
316
|
+
return sorted;
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
export { ProTableSearchForm as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
import * as _$vue_jsx_runtime0 from "vue/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Toolbar/FullscreenIcon.d.ts
|
|
6
|
+
declare const FullscreenIcon: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
7
|
+
isFullscreen: {
|
|
8
|
+
type: BooleanConstructor;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
onToggle: {
|
|
12
|
+
type: PropType<() => void>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
}>, () => _$vue_jsx_runtime0.JSX.Element, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
16
|
+
isFullscreen: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
required: true;
|
|
19
|
+
};
|
|
20
|
+
onToggle: {
|
|
21
|
+
type: PropType<() => void>;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { FullscreenIcon };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
import { Tooltip } from "antdv-next";
|
|
3
|
+
import { FullscreenExitOutlined, FullscreenOutlined } from "@antdv-next/icons";
|
|
4
|
+
//#region src/components/Toolbar/FullscreenIcon.tsx
|
|
5
|
+
const FullscreenIcon = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "ProTableFullscreenIcon",
|
|
7
|
+
props: {
|
|
8
|
+
isFullscreen: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
onToggle: {
|
|
13
|
+
type: Function,
|
|
14
|
+
required: true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(props) {
|
|
18
|
+
return () => createVNode(Tooltip, { "title": props.isFullscreen ? "退出全屏" : "全屏" }, { default: () => [createVNode("span", { "onClick": props.onToggle }, [props.isFullscreen ? createVNode(FullscreenExitOutlined, null, null) : createVNode(FullscreenOutlined, null, null)])] });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export { FullscreenIcon };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ToolbarPlacement } from "../../interface.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import { PropType, VNode } from "vue";
|
|
4
|
+
import * as _$vue_jsx_runtime0 from "vue/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Toolbar/ListToolBar.d.ts
|
|
7
|
+
interface ListToolBarSetting {
|
|
8
|
+
icon: VNode;
|
|
9
|
+
tooltip?: string;
|
|
10
|
+
key?: string;
|
|
11
|
+
onClick?: (key?: string) => void;
|
|
12
|
+
}
|
|
13
|
+
declare const ListToolBar: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
14
|
+
prefixCls: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
headerTitle: {
|
|
19
|
+
type: any;
|
|
20
|
+
default: any;
|
|
21
|
+
};
|
|
22
|
+
headerTitleTip: {
|
|
23
|
+
type: any;
|
|
24
|
+
default: any;
|
|
25
|
+
};
|
|
26
|
+
titleTipText: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: any;
|
|
29
|
+
};
|
|
30
|
+
settings: {
|
|
31
|
+
type: PropType<VNode[]>;
|
|
32
|
+
default: () => any[];
|
|
33
|
+
};
|
|
34
|
+
actions: {
|
|
35
|
+
type: PropType<VNode[]>;
|
|
36
|
+
default: () => any[];
|
|
37
|
+
};
|
|
38
|
+
actionsPlacement: {
|
|
39
|
+
type: PropType<ToolbarPlacement>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
listToolAfter: {
|
|
43
|
+
type: any;
|
|
44
|
+
default: any;
|
|
45
|
+
};
|
|
46
|
+
proClasses: {
|
|
47
|
+
type: ObjectConstructor;
|
|
48
|
+
default: () => {};
|
|
49
|
+
};
|
|
50
|
+
proStyles: {
|
|
51
|
+
type: ObjectConstructor;
|
|
52
|
+
default: () => {};
|
|
53
|
+
};
|
|
54
|
+
}>, () => _$vue_jsx_runtime0.JSX.Element, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
55
|
+
prefixCls: {
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
required: true;
|
|
58
|
+
};
|
|
59
|
+
headerTitle: {
|
|
60
|
+
type: any;
|
|
61
|
+
default: any;
|
|
62
|
+
};
|
|
63
|
+
headerTitleTip: {
|
|
64
|
+
type: any;
|
|
65
|
+
default: any;
|
|
66
|
+
};
|
|
67
|
+
titleTipText: {
|
|
68
|
+
type: StringConstructor;
|
|
69
|
+
default: any;
|
|
70
|
+
};
|
|
71
|
+
settings: {
|
|
72
|
+
type: PropType<VNode[]>;
|
|
73
|
+
default: () => any[];
|
|
74
|
+
};
|
|
75
|
+
actions: {
|
|
76
|
+
type: PropType<VNode[]>;
|
|
77
|
+
default: () => any[];
|
|
78
|
+
};
|
|
79
|
+
actionsPlacement: {
|
|
80
|
+
type: PropType<ToolbarPlacement>;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
listToolAfter: {
|
|
84
|
+
type: any;
|
|
85
|
+
default: any;
|
|
86
|
+
};
|
|
87
|
+
proClasses: {
|
|
88
|
+
type: ObjectConstructor;
|
|
89
|
+
default: () => {};
|
|
90
|
+
};
|
|
91
|
+
proStyles: {
|
|
92
|
+
type: ObjectConstructor;
|
|
93
|
+
default: () => {};
|
|
94
|
+
};
|
|
95
|
+
}>> & Readonly<{}>, {
|
|
96
|
+
actions: VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
|
97
|
+
[key: string]: any;
|
|
98
|
+
}>[];
|
|
99
|
+
proClasses: Record<string, any>;
|
|
100
|
+
proStyles: Record<string, any>;
|
|
101
|
+
titleTipText: string;
|
|
102
|
+
actionsPlacement: ToolbarPlacement;
|
|
103
|
+
headerTitle: any;
|
|
104
|
+
listToolAfter: any;
|
|
105
|
+
headerTitleTip: any;
|
|
106
|
+
settings: VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
}>[];
|
|
109
|
+
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { ListToolBar, ListToolBarSetting };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { computed, createVNode, defineComponent, isVNode } from "vue";
|
|
2
|
+
import { Tooltip } from "antdv-next";
|
|
3
|
+
import { InfoCircleOutlined } from "@antdv-next/icons";
|
|
4
|
+
//#region src/components/Toolbar/ListToolBar.tsx
|
|
5
|
+
function renderSettingItem(setting) {
|
|
6
|
+
if (isVNode(setting)) return setting;
|
|
7
|
+
if (!setting) return null;
|
|
8
|
+
const { icon, tooltip, onClick, key } = setting;
|
|
9
|
+
if (icon && tooltip) return createVNode(Tooltip, {
|
|
10
|
+
"title": tooltip,
|
|
11
|
+
"key": key
|
|
12
|
+
}, { default: () => [createVNode("span", {
|
|
13
|
+
"key": key,
|
|
14
|
+
"onClick": () => {
|
|
15
|
+
if (onClick) onClick(key);
|
|
16
|
+
}
|
|
17
|
+
}, [icon])] });
|
|
18
|
+
return icon;
|
|
19
|
+
}
|
|
20
|
+
const ListToolBar = /* @__PURE__ */ defineComponent({
|
|
21
|
+
name: "ProTableListToolBar",
|
|
22
|
+
props: {
|
|
23
|
+
prefixCls: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
headerTitle: {
|
|
28
|
+
type: null,
|
|
29
|
+
default: void 0
|
|
30
|
+
},
|
|
31
|
+
headerTitleTip: {
|
|
32
|
+
type: null,
|
|
33
|
+
default: void 0
|
|
34
|
+
},
|
|
35
|
+
titleTipText: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: void 0
|
|
38
|
+
},
|
|
39
|
+
settings: {
|
|
40
|
+
type: Array,
|
|
41
|
+
default: () => []
|
|
42
|
+
},
|
|
43
|
+
actions: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default: () => []
|
|
46
|
+
},
|
|
47
|
+
actionsPlacement: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "right"
|
|
50
|
+
},
|
|
51
|
+
listToolAfter: {
|
|
52
|
+
type: null,
|
|
53
|
+
default: void 0
|
|
54
|
+
},
|
|
55
|
+
proClasses: {
|
|
56
|
+
type: Object,
|
|
57
|
+
default: () => ({})
|
|
58
|
+
},
|
|
59
|
+
proStyles: {
|
|
60
|
+
type: Object,
|
|
61
|
+
default: () => ({})
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
setup(props) {
|
|
65
|
+
const hasTitle = computed(() => !!(props.headerTitleTip || props.headerTitle));
|
|
66
|
+
const leftActions = computed(() => props.actionsPlacement === "left" ? props.actions : []);
|
|
67
|
+
const rightActions = computed(() => props.actionsPlacement === "right" ? props.actions : []);
|
|
68
|
+
const hasLeft = computed(() => hasTitle.value || leftActions.value.length > 0);
|
|
69
|
+
const hasRight = computed(() => props.settings.length > 0 || rightActions.value.length > 0);
|
|
70
|
+
return () => {
|
|
71
|
+
if (!hasLeft.value && !hasRight.value && !props.listToolAfter) return null;
|
|
72
|
+
const prefix = props.prefixCls;
|
|
73
|
+
const leftNode = hasLeft.value || hasRight.value ? createVNode("div", {
|
|
74
|
+
"class": `${prefix}-list-toolbar-left`,
|
|
75
|
+
"style": props.proStyles.toolbarLeft
|
|
76
|
+
}, [hasTitle.value && createVNode("div", {
|
|
77
|
+
"class": [`${prefix}-list-toolbar-title`, props.proClasses.toolbarTitle],
|
|
78
|
+
"style": props.proStyles.toolbarTitle
|
|
79
|
+
}, [props.headerTitle, props.headerTitleTip && createVNode(Tooltip, { "title": props.titleTipText }, { default: () => [typeof props.headerTitleTip === "boolean" ? createVNode(InfoCircleOutlined, null, null) : props.headerTitleTip] })]), leftActions.value.length > 0 && createVNode("div", { "class": `${prefix}-list-toolbar-actions` }, [leftActions.value])]) : hasRight.value ? createVNode("div", {
|
|
80
|
+
"class": `${prefix}-list-toolbar-left`,
|
|
81
|
+
"style": props.proStyles.toolbarLeft
|
|
82
|
+
}, null) : null;
|
|
83
|
+
const rightNode = hasRight.value ? createVNode("div", {
|
|
84
|
+
"class": [`${prefix}-list-toolbar-right`, props.proClasses.toolbarRight],
|
|
85
|
+
"style": props.proStyles.toolbarRight
|
|
86
|
+
}, [rightActions.value.length > 0 && createVNode("div", { "class": `${prefix}-list-toolbar-actions` }, [rightActions.value]), props.settings.length > 0 && createVNode("div", { "class": `${prefix}-list-toolbar-setting-items` }, [props.settings.map((setting, index) => createVNode("div", {
|
|
87
|
+
"key": index,
|
|
88
|
+
"class": `${prefix}-list-toolbar-setting-item`
|
|
89
|
+
}, [renderSettingItem(setting)]))])]) : null;
|
|
90
|
+
return createVNode("div", {
|
|
91
|
+
"class": [`${prefix}-list-toolbar`, props.proClasses.toolbar],
|
|
92
|
+
"style": props.proStyles.toolbar
|
|
93
|
+
}, [(leftNode || rightNode) && createVNode("div", { "class": `${prefix}-list-toolbar-container` }, [leftNode, rightNode]), props.listToolAfter && createVNode("div", {
|
|
94
|
+
"class": [`${prefix}-list-toolbar-after`, props.proClasses.toolbarAfter],
|
|
95
|
+
"style": props.proStyles.toolbarAfter
|
|
96
|
+
}, [props.listToolAfter])]);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//#endregion
|
|
101
|
+
export { ListToolBar };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ToolbarPlacement } from "../../interface.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import { PropType, VNode } from "vue";
|
|
4
|
+
import * as _$vue_jsx_runtime0 from "vue/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Toolbar/index.d.ts
|
|
7
|
+
declare const Toolbar: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
8
|
+
prefixCls: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
options: {
|
|
13
|
+
type: any;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
titleTipText: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: any;
|
|
19
|
+
};
|
|
20
|
+
actionsPlacement: {
|
|
21
|
+
type: PropType<ToolbarPlacement>;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
actions: {
|
|
25
|
+
type: PropType<VNode[]>;
|
|
26
|
+
default: () => any[];
|
|
27
|
+
};
|
|
28
|
+
headerTitle: {
|
|
29
|
+
type: any;
|
|
30
|
+
default: any;
|
|
31
|
+
};
|
|
32
|
+
listToolAfter: {
|
|
33
|
+
type: any;
|
|
34
|
+
default: any;
|
|
35
|
+
};
|
|
36
|
+
headerTitleTip: {
|
|
37
|
+
type: any;
|
|
38
|
+
default: any;
|
|
39
|
+
};
|
|
40
|
+
proClasses: {
|
|
41
|
+
type: ObjectConstructor;
|
|
42
|
+
default: () => {};
|
|
43
|
+
};
|
|
44
|
+
proStyles: {
|
|
45
|
+
type: ObjectConstructor;
|
|
46
|
+
default: () => {};
|
|
47
|
+
};
|
|
48
|
+
}>, () => _$vue_jsx_runtime0.JSX.Element, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
49
|
+
prefixCls: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
required: true;
|
|
52
|
+
};
|
|
53
|
+
options: {
|
|
54
|
+
type: any;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
titleTipText: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: any;
|
|
60
|
+
};
|
|
61
|
+
actionsPlacement: {
|
|
62
|
+
type: PropType<ToolbarPlacement>;
|
|
63
|
+
default: string;
|
|
64
|
+
};
|
|
65
|
+
actions: {
|
|
66
|
+
type: PropType<VNode[]>;
|
|
67
|
+
default: () => any[];
|
|
68
|
+
};
|
|
69
|
+
headerTitle: {
|
|
70
|
+
type: any;
|
|
71
|
+
default: any;
|
|
72
|
+
};
|
|
73
|
+
listToolAfter: {
|
|
74
|
+
type: any;
|
|
75
|
+
default: any;
|
|
76
|
+
};
|
|
77
|
+
headerTitleTip: {
|
|
78
|
+
type: any;
|
|
79
|
+
default: any;
|
|
80
|
+
};
|
|
81
|
+
proClasses: {
|
|
82
|
+
type: ObjectConstructor;
|
|
83
|
+
default: () => {};
|
|
84
|
+
};
|
|
85
|
+
proStyles: {
|
|
86
|
+
type: ObjectConstructor;
|
|
87
|
+
default: () => {};
|
|
88
|
+
};
|
|
89
|
+
}>> & Readonly<{}>, {
|
|
90
|
+
actions: VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
}>[];
|
|
93
|
+
proClasses: Record<string, any>;
|
|
94
|
+
proStyles: Record<string, any>;
|
|
95
|
+
options: any;
|
|
96
|
+
titleTipText: string;
|
|
97
|
+
actionsPlacement: ToolbarPlacement;
|
|
98
|
+
headerTitle: any;
|
|
99
|
+
listToolAfter: any;
|
|
100
|
+
headerTitleTip: any;
|
|
101
|
+
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { Toolbar, Toolbar as default };
|