@gx-design-vue/pro-table 0.2.0-alpha.2 → 0.2.0-alpha.21
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 -493
- package/dist/ProTable.js +902 -511
- package/dist/components/Drag/Handle.d.ts +90 -0
- package/dist/components/Drag/Handle.js +64 -0
- package/dist/components/Drag/Tbody.d.ts +17 -0
- package/dist/components/Drag/Tbody.js +27 -0
- package/dist/components/EllipsisText/index.d.ts +50 -0
- package/dist/components/EllipsisText/index.js +65 -0
- package/dist/components/ScrollBar/Bar.d.ts +79 -0
- package/dist/components/ScrollBar/Bar.js +84 -0
- package/dist/components/ScrollBar/Thumb.d.ts +50 -0
- package/dist/components/ScrollBar/{Thumb/index.js → Thumb.js} +67 -58
- package/dist/components/ScrollBar/context.d.ts +3 -4
- package/dist/components/ScrollBar/context.js +3 -5
- package/dist/components/ScrollBar/util.d.ts +6 -5
- package/dist/components/ScrollBar/util.js +1 -14
- package/dist/components/SearchForm/CollapseToggle.d.ts +53 -0
- package/dist/components/SearchForm/CollapseToggle.js +47 -0
- package/dist/components/SearchForm/FormItemContainer.d.ts +73 -0
- package/dist/components/SearchForm/FormItemContainer.js +225 -0
- package/dist/components/SearchForm/FormItemWrapper.d.ts +80 -0
- package/dist/components/SearchForm/FormItemWrapper.js +62 -0
- package/dist/components/SearchForm/SearchForm.d.ts +128 -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 +24 -0
- package/dist/components/Toolbar/FullscreenIcon.js +22 -0
- package/dist/components/Toolbar/ListToolBar.d.ts +109 -0
- package/dist/components/Toolbar/ListToolBar.js +101 -0
- package/dist/components/Toolbar/index.d.ts +101 -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 -5
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/useAutoScroll.d.ts +32 -0
- package/dist/hooks/useAutoScroll.js +127 -0
- package/dist/hooks/useBreakpoints.d.ts +13 -0
- package/dist/hooks/useBreakpoints.js +65 -0
- package/dist/hooks/useCellRender.d.ts +13 -0
- package/dist/hooks/useCellRender.js +40 -0
- package/dist/hooks/useColumnResize.d.ts +29 -0
- package/dist/hooks/useColumnResize.js +112 -0
- package/dist/hooks/useColumns.d.ts +35 -24
- package/dist/hooks/useColumns.js +89 -58
- package/dist/hooks/useDragHandleColumn.d.ts +26 -0
- package/dist/hooks/useDragHandleColumn.js +52 -0
- package/dist/hooks/useEllipsis.d.ts +20 -0
- package/dist/hooks/useEllipsis.js +51 -0
- package/dist/hooks/useFetchData.d.ts +42 -65
- package/dist/hooks/useFetchData.js +160 -176
- 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 +27 -11
- package/dist/hooks/usePagination.d.ts +10 -7
- package/dist/hooks/usePagination.js +38 -29
- package/dist/hooks/useRequestOptions.d.ts +18 -0
- package/dist/hooks/useRequestOptions.js +39 -0
- package/dist/hooks/useRowDrag.d.ts +42 -0
- package/dist/hooks/useRowDrag.js +268 -0
- package/dist/hooks/useRowSelection.d.ts +27 -15
- package/dist/hooks/useRowSelection.js +93 -80
- package/dist/hooks/useTable.d.ts +35 -77
- package/dist/hooks/useTable.js +76 -49
- package/dist/hooks/useTableForm.d.ts +17 -82
- package/dist/hooks/useTableForm.js +137 -52
- package/dist/hooks/useTableScroll.d.ts +33 -31
- package/dist/hooks/useTableScroll.js +71 -28
- package/dist/hooks/useTableSize.d.ts +17 -7
- package/dist/hooks/useTableSize.js +21 -9
- package/dist/index.d.ts +11 -7
- package/dist/index.js +10 -4
- package/dist/interface.d.ts +537 -0
- package/dist/interface.js +1 -0
- package/dist/pro-table.esm.js +8897 -4012
- package/dist/pro-table.js +4 -1
- package/dist/style/ellipsis.d.ts +13 -0
- package/dist/style/ellipsis.js +16 -0
- package/dist/style/fit-page.d.ts +4 -2
- package/dist/style/fit-page.js +10 -5
- package/dist/style/index.d.ts +3 -7
- package/dist/style/index.js +38 -76
- package/dist/style/list.d.ts +4 -2
- package/dist/style/list.js +2 -12
- package/dist/style/resizable.d.ts +8 -0
- package/dist/style/resizable.js +18 -0
- package/dist/style/row-drag.d.ts +8 -0
- package/dist/style/row-drag.js +44 -0
- package/dist/style/scroll.d.ts +4 -2
- package/dist/style/scroll.js +9 -9
- package/dist/style/search.d.ts +8 -0
- package/dist/{components/Form/style.js → style/search.js} +22 -9
- package/dist/theme/augment.d.ts +8 -0
- package/dist/theme/augment.js +1 -0
- package/dist/theme/interface/components.d.ts +8 -0
- package/dist/theme/interface/components.js +1 -0
- package/dist/utils/arrayMove.d.ts +9 -0
- package/dist/utils/arrayMove.js +15 -0
- package/dist/utils/dateFormat.d.ts +9 -0
- package/dist/utils/dateFormat.js +29 -0
- package/dist/utils/ellipsis.d.ts +19 -0
- package/dist/utils/ellipsis.js +30 -0
- package/dist/utils/flipAnimate.d.ts +25 -0
- package/dist/utils/flipAnimate.js +40 -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 +23 -11
- package/dist/components/Form/components/RequestSelect.d.ts +0 -50
- package/dist/components/Form/components/RequestSelect.js +0 -58
- package/dist/components/Form/hooks/useForm.d.ts +0 -11
- package/dist/components/Form/hooks/useForm.js +0 -32
- package/dist/components/Form/index.d.ts +0 -33
- package/dist/components/Form/index.js +0 -479
- 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 -30
- package/dist/components/Form/utils/dateFormat.d.ts +0 -22
- package/dist/components/Form/utils/dateFormat.js +0 -45
- package/dist/components/ListToolBar/index.d.ts +0 -60
- 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 -71
- package/dist/components/ScrollBar/Bar/props.d.ts +0 -25
- package/dist/components/ScrollBar/Bar/props.js +0 -18
- 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 -18
- package/dist/components/TableCell/index.d.ts +0 -37
- package/dist/components/TableCell/index.js +0 -72
- package/dist/components/ToolBar/FullscreenIcon.d.ts +0 -7
- package/dist/components/ToolBar/FullscreenIcon.js +0 -14
- package/dist/components/ToolBar/index.d.ts +0 -34
- package/dist/components/ToolBar/index.js +0 -100
- package/dist/hooks/tryOnActivated.d.ts +0 -6
- package/dist/hooks/tryOnActivated.js +0 -14
- package/dist/hooks/useDebounceFn.d.ts +0 -8
- package/dist/hooks/useDebounceFn.js +0 -34
- package/dist/hooks/useScrollArea.d.ts +0 -24
- package/dist/hooks/useScrollArea.js +0 -104
- package/dist/props.d.ts +0 -340
- package/dist/props.js +0 -251
- package/dist/types/ColumnTypings.d.ts +0 -129
- package/dist/types/ColumnTypings.js +0 -1
- package/dist/types/SlotsTypings.d.ts +0 -63
- package/dist/types/SlotsTypings.js +0 -13
- package/dist/types/TableTypings.d.ts +0 -359
- package/dist/types/TableTypings.js +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.js +0 -1
- package/dist/utils/utils.d.ts +0 -10
- package/dist/utils/utils.js +0 -91
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BAR_MAP, renderThumbStyle } from "
|
|
3
|
-
import { thumbProps } from "./props.js";
|
|
1
|
+
import { useInjectScrollBarContext } from "./context.js";
|
|
2
|
+
import { BAR_MAP, renderThumbStyle } from "./util.js";
|
|
4
3
|
import { computed, createVNode, defineComponent, onBeforeUnmount, ref } from "vue";
|
|
5
4
|
import { unit } from "@gx-design-vue/pro-provider";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { useEventListener } from "@vueuse/core";
|
|
6
|
+
//#region src/components/ScrollBar/Thumb.tsx
|
|
7
|
+
const thumbProps = {
|
|
8
|
+
vertical: Boolean,
|
|
9
|
+
size: String,
|
|
10
|
+
move: Number,
|
|
11
|
+
ratio: {
|
|
12
|
+
type: Number,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
always: Boolean,
|
|
16
|
+
barStyle: {
|
|
17
|
+
type: Object,
|
|
18
|
+
default: () => ({})
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var Thumb_default = /* @__PURE__ */ defineComponent({
|
|
22
|
+
name: "ScrollBarThumb",
|
|
23
|
+
inheritAttrs: false,
|
|
10
24
|
props: thumbProps,
|
|
11
25
|
setup(props) {
|
|
12
|
-
const
|
|
26
|
+
const scrollbar = useInjectScrollBarContext();
|
|
13
27
|
const instance = ref();
|
|
14
28
|
const thumb = ref();
|
|
15
29
|
const thumbState = ref({});
|
|
@@ -18,57 +32,61 @@ const Thumb = /* @__PURE__ */ defineComponent({
|
|
|
18
32
|
let cursorLeave = false;
|
|
19
33
|
let baseScrollHeight = 0;
|
|
20
34
|
let baseScrollWidth = 0;
|
|
21
|
-
let originalOnSelectStart = isClient ? document.onselectstart : null;
|
|
22
35
|
const bar = computed(() => BAR_MAP[props.vertical ? "vertical" : "horizontal"]);
|
|
23
36
|
const thumbStyle = computed(() => renderThumbStyle({
|
|
24
37
|
size: props.size,
|
|
25
38
|
move: props.move,
|
|
26
39
|
bar: bar.value
|
|
27
40
|
}));
|
|
28
|
-
const offsetRatio = computed(() =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const el = e.currentTarget;
|
|
35
|
-
if (!el) return;
|
|
36
|
-
thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
|
|
37
|
-
};
|
|
38
|
-
const clickTrackHandler = (e) => {
|
|
39
|
-
if (!thumb.value || !instance.value || !wrapElement.value) return;
|
|
40
|
-
const thumbPositionPercentage = (Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) - thumb.value[bar.value.offset] / 2) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
41
|
-
wrapElement.value[bar.value.scroll] = thumbPositionPercentage * wrapElement.value[bar.value.scrollSize] / 100;
|
|
42
|
-
};
|
|
43
|
-
function startDrag(e) {
|
|
44
|
-
if (!wrapElement.value) return;
|
|
45
|
-
e.stopImmediatePropagation();
|
|
46
|
-
cursorDown = true;
|
|
47
|
-
baseScrollHeight = wrapElement.value.scrollHeight;
|
|
48
|
-
baseScrollWidth = wrapElement.value.scrollWidth;
|
|
49
|
-
document.addEventListener("mousemove", mouseMoveDocumentHandler);
|
|
50
|
-
document.addEventListener("mouseup", mouseUpDocumentHandler);
|
|
51
|
-
originalOnSelectStart = document.onselectstart;
|
|
52
|
-
document.onselectstart = () => false;
|
|
41
|
+
const offsetRatio = computed(() => {
|
|
42
|
+
if (!instance.value || !thumb.value || !scrollbar?.wrapElement?.value) return 1;
|
|
43
|
+
return instance.value[bar.value.offset] ** 2 / scrollbar.wrapElement.value[bar.value.scrollSize] / props.ratio / thumb.value[bar.value.offset];
|
|
44
|
+
});
|
|
45
|
+
function restoreOnSelectStart(originalOnSelectStart) {
|
|
46
|
+
if (document.onselectstart !== originalOnSelectStart) document.onselectstart = originalOnSelectStart;
|
|
53
47
|
}
|
|
54
48
|
function mouseMoveDocumentHandler(e) {
|
|
55
|
-
if (!wrapElement.value) return;
|
|
56
|
-
if (!instance.value || !thumb.value) return;
|
|
57
|
-
if (cursorDown === false) return;
|
|
49
|
+
if (!scrollbar?.wrapElement?.value || !instance.value || !thumb.value || !cursorDown) return;
|
|
58
50
|
const prevPage = thumbState.value[bar.value.axis];
|
|
59
51
|
if (!prevPage) return;
|
|
60
52
|
const thumbPositionPercentage = ((instance.value.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1 - (thumb.value[bar.value.offset] - prevPage)) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
61
|
-
if (bar.value.scroll === "scrollLeft") wrapElement.value[bar.value.scroll] = thumbPositionPercentage * baseScrollWidth / 100;
|
|
62
|
-
else wrapElement.value[bar.value.scroll] = thumbPositionPercentage * baseScrollHeight / 100;
|
|
53
|
+
if (bar.value.scroll === "scrollLeft") scrollbar.wrapElement.value[bar.value.scroll] = thumbPositionPercentage * baseScrollWidth / 100;
|
|
54
|
+
else scrollbar.wrapElement.value[bar.value.scroll] = thumbPositionPercentage * baseScrollHeight / 100;
|
|
63
55
|
}
|
|
56
|
+
let originalOnSelectStart = document.onselectstart;
|
|
64
57
|
function mouseUpDocumentHandler() {
|
|
65
58
|
cursorDown = false;
|
|
66
59
|
thumbState.value[bar.value.axis] = 0;
|
|
67
60
|
document.removeEventListener("mousemove", mouseMoveDocumentHandler);
|
|
68
61
|
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
69
|
-
|
|
62
|
+
restoreOnSelectStart(originalOnSelectStart);
|
|
70
63
|
if (cursorLeave) visible.value = false;
|
|
71
64
|
}
|
|
65
|
+
function startDrag(e) {
|
|
66
|
+
if (!scrollbar?.wrapElement?.value) return;
|
|
67
|
+
e.stopImmediatePropagation();
|
|
68
|
+
cursorDown = true;
|
|
69
|
+
baseScrollHeight = scrollbar.wrapElement.value.scrollHeight;
|
|
70
|
+
baseScrollWidth = scrollbar.wrapElement.value.scrollWidth;
|
|
71
|
+
document.addEventListener("mousemove", mouseMoveDocumentHandler);
|
|
72
|
+
document.addEventListener("mouseup", mouseUpDocumentHandler);
|
|
73
|
+
originalOnSelectStart = document.onselectstart;
|
|
74
|
+
document.onselectstart = () => false;
|
|
75
|
+
}
|
|
76
|
+
function clickThumbHandler(e) {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
if (e.ctrlKey || [1, 2].includes(e.button)) return;
|
|
79
|
+
window.getSelection()?.removeAllRanges();
|
|
80
|
+
startDrag(e);
|
|
81
|
+
const el = e.currentTarget;
|
|
82
|
+
if (!el) return;
|
|
83
|
+
thumbState.value[bar.value.axis] = el[bar.value.offset] - (e[bar.value.client] - el.getBoundingClientRect()[bar.value.direction]);
|
|
84
|
+
}
|
|
85
|
+
function clickTrackHandler(e) {
|
|
86
|
+
if (!thumb.value || !instance.value || !scrollbar?.wrapElement?.value) return;
|
|
87
|
+
const thumbPositionPercentage = (Math.abs(e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) - thumb.value[bar.value.offset] / 2) * 100 * offsetRatio.value / instance.value[bar.value.offset];
|
|
88
|
+
scrollbar.wrapElement.value[bar.value.scroll] = thumbPositionPercentage * scrollbar.wrapElement.value[bar.value.scrollSize] / 100;
|
|
89
|
+
}
|
|
72
90
|
const mouseMoveScrollbarHandler = () => {
|
|
73
91
|
cursorLeave = false;
|
|
74
92
|
visible.value = !!props.size;
|
|
@@ -77,19 +95,17 @@ const Thumb = /* @__PURE__ */ defineComponent({
|
|
|
77
95
|
cursorLeave = true;
|
|
78
96
|
visible.value = cursorDown;
|
|
79
97
|
};
|
|
98
|
+
useEventListener(scrollbar?.scrollbarElement, "mousemove", mouseMoveScrollbarHandler);
|
|
99
|
+
useEventListener(scrollbar?.scrollbarElement, "mouseleave", mouseLeaveScrollbarHandler);
|
|
80
100
|
onBeforeUnmount(() => {
|
|
81
|
-
|
|
101
|
+
restoreOnSelectStart(originalOnSelectStart);
|
|
82
102
|
document.removeEventListener("mouseup", mouseUpDocumentHandler);
|
|
83
103
|
});
|
|
84
|
-
function restoreOnselectstart() {
|
|
85
|
-
if (document.onselectstart !== originalOnSelectStart) document.onselectstart = originalOnSelectStart;
|
|
86
|
-
}
|
|
87
|
-
useEventListener(scrollbarElement, "mousemove", mouseMoveScrollbarHandler);
|
|
88
|
-
useEventListener(scrollbarElement, "mouseleave", mouseLeaveScrollbarHandler);
|
|
89
104
|
return () => {
|
|
105
|
+
if (!scrollbar) return null;
|
|
90
106
|
const verticalStyle = bar.value.key === "vertical" ? {
|
|
91
|
-
height: `calc(100% - ${unit(tableHeaderHeight.value + 1)})`,
|
|
92
|
-
top: unit(tableHeaderHeight.value + 1)
|
|
107
|
+
height: `calc(100% - ${unit(scrollbar.tableHeaderHeight.value + 1)})`,
|
|
108
|
+
top: unit(scrollbar.tableHeaderHeight.value + 1)
|
|
93
109
|
} : {};
|
|
94
110
|
return createVNode("div", {
|
|
95
111
|
"ref": instance,
|
|
@@ -97,23 +113,16 @@ const Thumb = /* @__PURE__ */ defineComponent({
|
|
|
97
113
|
...props.barStyle,
|
|
98
114
|
...verticalStyle
|
|
99
115
|
},
|
|
100
|
-
"class":
|
|
101
|
-
`${className}-bar`,
|
|
102
|
-
`is-${bar.value.key}`,
|
|
103
|
-
hashId.value
|
|
104
|
-
],
|
|
116
|
+
"class": `${scrollbar.className}-bar is-${bar.value.key}`,
|
|
105
117
|
"onMousedown": clickTrackHandler
|
|
106
118
|
}, [createVNode("div", {
|
|
107
119
|
"ref": thumb,
|
|
108
|
-
"class": `${className}-thumb
|
|
120
|
+
"class": `${scrollbar.className}-thumb`,
|
|
109
121
|
"style": thumbStyle.value,
|
|
110
122
|
"onMousedown": clickThumbHandler
|
|
111
123
|
}, null)]);
|
|
112
124
|
};
|
|
113
125
|
}
|
|
114
126
|
});
|
|
115
|
-
Thumb.inheritAttrs = false;
|
|
116
|
-
var Thumb_default = Thumb;
|
|
117
|
-
|
|
118
127
|
//#endregion
|
|
119
|
-
export { Thumb_default as default };
|
|
128
|
+
export { Thumb_default as default, thumbProps };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
2
|
|
|
3
3
|
//#region src/components/ScrollBar/context.d.ts
|
|
4
|
-
interface
|
|
4
|
+
interface ScrollBarContext {
|
|
5
5
|
className: string;
|
|
6
|
-
hashId: Ref<string>;
|
|
7
6
|
tableHeaderHeight: Ref<number>;
|
|
8
7
|
tableScrollYHeight: Ref<number>;
|
|
9
8
|
scrollbarElement: Ref<HTMLElement | undefined>;
|
|
10
9
|
wrapElement: Ref<HTMLElement | undefined>;
|
|
11
10
|
}
|
|
12
|
-
declare const
|
|
11
|
+
declare const useProvideScrollBarContext: (args_0: ScrollBarContext) => ScrollBarContext, useInjectScrollBarContext: () => ScrollBarContext;
|
|
13
12
|
//#endregion
|
|
14
|
-
export {
|
|
13
|
+
export { ScrollBarContext, useInjectScrollBarContext, useProvideScrollBarContext };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createInjectionState } from "@vueuse/core";
|
|
3
2
|
//#region src/components/ScrollBar/context.ts
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
const [useProvideScrollBarContext, useInjectScrollBarContext] = createInjectionState((context) => context);
|
|
6
4
|
//#endregion
|
|
7
|
-
export {
|
|
5
|
+
export { useInjectScrollBarContext, useProvideScrollBarContext };
|
|
@@ -24,14 +24,15 @@ declare const BAR_MAP: {
|
|
|
24
24
|
readonly direction: "left";
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
type BarDirection = keyof typeof BAR_MAP;
|
|
27
28
|
declare function renderThumbStyle({
|
|
28
29
|
move,
|
|
29
30
|
size,
|
|
30
31
|
bar
|
|
31
|
-
}:
|
|
32
|
-
|
|
32
|
+
}: {
|
|
33
|
+
move: number;
|
|
34
|
+
size: string;
|
|
35
|
+
bar: typeof BAR_MAP[BarDirection];
|
|
33
36
|
}): CSSProperties;
|
|
34
|
-
declare function isStringNumber(val: string): boolean;
|
|
35
|
-
declare function addUnit(value?: string | number, defaultUnit?: string): string;
|
|
36
37
|
//#endregion
|
|
37
|
-
export { BAR_MAP,
|
|
38
|
+
export { BAR_MAP, BarDirection, GAP, renderThumbStyle };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { isNumber, isString } from "@gx-design-vue/pro-utils";
|
|
2
|
-
|
|
3
1
|
//#region src/components/ScrollBar/util.ts
|
|
4
2
|
const GAP = 4;
|
|
5
3
|
const BAR_MAP = {
|
|
@@ -30,16 +28,5 @@ function renderThumbStyle({ move, size, bar }) {
|
|
|
30
28
|
transform: `translate${bar.axis}(${move}%)`
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
|
-
function isStringNumber(val) {
|
|
34
|
-
if (!isString(val)) return false;
|
|
35
|
-
return !Number.isNaN(Number(val));
|
|
36
|
-
}
|
|
37
|
-
function addUnit(value, defaultUnit = "px") {
|
|
38
|
-
if (!value) return "";
|
|
39
|
-
if (isNumber(value) || isStringNumber(value)) return `${value}${defaultUnit}`;
|
|
40
|
-
else if (isString(value)) return value;
|
|
41
|
-
console.warn("utils/dom/style", "value 必须为数字");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
31
|
//#endregion
|
|
45
|
-
export { BAR_MAP, GAP,
|
|
32
|
+
export { BAR_MAP, GAP, renderThumbStyle };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PropType } from "vue";
|
|
2
|
+
import { CustomRender, WithFalse } from "@gx-design-vue/pro-utils";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SearchForm/CollapseToggle.d.ts
|
|
5
|
+
declare const CollapseToggle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
collapsed: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: any;
|
|
9
|
+
};
|
|
10
|
+
collapseRender: {
|
|
11
|
+
type: PropType<WithFalse<(collapsed?: boolean) => CustomRender> | undefined>;
|
|
12
|
+
default: any;
|
|
13
|
+
};
|
|
14
|
+
prefixCls: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
hashId: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
onToggle: {
|
|
23
|
+
type: PropType<(collapsed: boolean) => void>;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
+
collapsed: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: any;
|
|
30
|
+
};
|
|
31
|
+
collapseRender: {
|
|
32
|
+
type: PropType<WithFalse<(collapsed?: boolean) => CustomRender> | undefined>;
|
|
33
|
+
default: any;
|
|
34
|
+
};
|
|
35
|
+
prefixCls: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
39
|
+
hashId: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
onToggle: {
|
|
44
|
+
type: PropType<(collapsed: boolean) => void>;
|
|
45
|
+
required: true;
|
|
46
|
+
};
|
|
47
|
+
}>> & Readonly<{}>, {
|
|
48
|
+
hashId: string;
|
|
49
|
+
collapsed: boolean;
|
|
50
|
+
collapseRender: WithFalse<(collapsed?: boolean) => CustomRender>;
|
|
51
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { CollapseToggle };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
import { GIcon } from "@gx-design-vue/icon";
|
|
3
|
+
//#region src/components/SearchForm/CollapseToggle.tsx
|
|
4
|
+
const CollapseToggle = /* @__PURE__ */ defineComponent({
|
|
5
|
+
name: "ProTableCollapseToggle",
|
|
6
|
+
props: {
|
|
7
|
+
collapsed: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: void 0
|
|
10
|
+
},
|
|
11
|
+
collapseRender: {
|
|
12
|
+
type: [
|
|
13
|
+
Function,
|
|
14
|
+
Object,
|
|
15
|
+
Boolean
|
|
16
|
+
],
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
prefixCls: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
hashId: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ""
|
|
26
|
+
},
|
|
27
|
+
onToggle: {
|
|
28
|
+
type: Function,
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setup(props) {
|
|
33
|
+
return () => {
|
|
34
|
+
if (props.collapseRender === false) return null;
|
|
35
|
+
if (typeof props.collapseRender === "function") return createVNode("span", {
|
|
36
|
+
"class": [`${props.prefixCls}-search-control-text`, props.hashId],
|
|
37
|
+
"onClick": () => props.onToggle(!props.collapsed)
|
|
38
|
+
}, [props.collapseRender(props.collapsed)]);
|
|
39
|
+
return createVNode("span", {
|
|
40
|
+
"class": `${props.prefixCls}-search-control-text`,
|
|
41
|
+
"onClick": () => props.onToggle(!props.collapsed)
|
|
42
|
+
}, [props.collapsed ? "展开" : "收起", props.collapsed ? createVNode(GIcon, { "type": "DownOutlined" }, null) : createVNode(GIcon, { "type": "UpOutlined" }, null)]);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { CollapseToggle };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ProSearchMap } from "../../interface.js";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SearchForm/FormItemContainer.d.ts
|
|
5
|
+
declare const FormItemContainer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
prefixCls: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
record: {
|
|
11
|
+
type: PropType<ProSearchMap>;
|
|
12
|
+
required: true;
|
|
13
|
+
};
|
|
14
|
+
formState: {
|
|
15
|
+
type: PropType<Record<string, any>>;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
autoRequest: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
loading: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
onChange: {
|
|
27
|
+
type: PropType<(value: any, record: ProSearchMap, options?: {
|
|
28
|
+
key?: number;
|
|
29
|
+
}) => void>;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
onSubmit: {
|
|
33
|
+
type: PropType<() => void>;
|
|
34
|
+
default: any;
|
|
35
|
+
};
|
|
36
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
+
prefixCls: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
record: {
|
|
42
|
+
type: PropType<ProSearchMap>;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
45
|
+
formState: {
|
|
46
|
+
type: PropType<Record<string, any>>;
|
|
47
|
+
required: true;
|
|
48
|
+
};
|
|
49
|
+
autoRequest: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
53
|
+
loading: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
onChange: {
|
|
58
|
+
type: PropType<(value: any, record: ProSearchMap, options?: {
|
|
59
|
+
key?: number;
|
|
60
|
+
}) => void>;
|
|
61
|
+
required: true;
|
|
62
|
+
};
|
|
63
|
+
onSubmit: {
|
|
64
|
+
type: PropType<() => void>;
|
|
65
|
+
default: any;
|
|
66
|
+
};
|
|
67
|
+
}>> & Readonly<{}>, {
|
|
68
|
+
onSubmit: () => void;
|
|
69
|
+
loading: boolean;
|
|
70
|
+
autoRequest: boolean;
|
|
71
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
72
|
+
//#endregion
|
|
73
|
+
export { FormItemContainer };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { formatDateRangeArray, formatStringValue, resolveValueFormat } from "../../utils/dateFormat.js";
|
|
2
|
+
import { useRequestOptions } from "../../hooks/useRequestOptions.js";
|
|
3
|
+
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
4
|
+
import { Cascader, DatePicker, Input, InputNumber, Select, SpaceCompact, TimePicker, TreeSelect } from "antdv-next";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
//#region src/components/SearchForm/FormItemContainer.tsx
|
|
7
|
+
const { RangePicker } = DatePicker;
|
|
8
|
+
const FormItemContainer = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "ProTableFormItemContainer",
|
|
10
|
+
props: {
|
|
11
|
+
prefixCls: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
record: {
|
|
16
|
+
type: Object,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
formState: {
|
|
20
|
+
type: Object,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
autoRequest: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true
|
|
26
|
+
},
|
|
27
|
+
loading: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
onChange: {
|
|
32
|
+
type: Function,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
onSubmit: {
|
|
36
|
+
type: Function,
|
|
37
|
+
default: void 0
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setup(props) {
|
|
41
|
+
const { optionList, loading: requestLoading } = useRequestOptions({
|
|
42
|
+
fetch: props.record.request?.fetch,
|
|
43
|
+
manual: props.record.request?.manual,
|
|
44
|
+
debounceTime: props.record.request?.debounceTime
|
|
45
|
+
});
|
|
46
|
+
const rangeInputStyle = {
|
|
47
|
+
width: "calc((100% - 30px) / 2)",
|
|
48
|
+
flex: "0 0 calc((100% - 30px) / 2)",
|
|
49
|
+
minWidth: 0
|
|
50
|
+
};
|
|
51
|
+
function handleChange(value, options) {
|
|
52
|
+
props.onChange(value, props.record, options);
|
|
53
|
+
}
|
|
54
|
+
function renderText() {
|
|
55
|
+
const fields = props.record.field ?? {};
|
|
56
|
+
const inputProps = {
|
|
57
|
+
style: { width: "100%" },
|
|
58
|
+
value: props.formState[props.record.name],
|
|
59
|
+
placeholder: props.record.placeholder || "请输入",
|
|
60
|
+
allowClear: props.record.allowClear ?? true,
|
|
61
|
+
...fields
|
|
62
|
+
};
|
|
63
|
+
if (props.autoRequest) return createVNode(Input.Search, mergeProps(inputProps, {
|
|
64
|
+
"onSearch": () => props.onSubmit?.(),
|
|
65
|
+
"onChange": (e) => {
|
|
66
|
+
props.formState[props.record.name] = e.target?.value ?? e;
|
|
67
|
+
}
|
|
68
|
+
}), null);
|
|
69
|
+
return createVNode(Input, mergeProps(inputProps, { "onChange": (e) => handleChange(e.target?.value ?? e) }), null);
|
|
70
|
+
}
|
|
71
|
+
function renderNumber() {
|
|
72
|
+
return createVNode(InputNumber, mergeProps({
|
|
73
|
+
"style": { width: "100%" },
|
|
74
|
+
"value": props.formState[props.record.name],
|
|
75
|
+
"placeholder": props.record.placeholder || "请输入",
|
|
76
|
+
"onChange": (val) => handleChange(val ?? void 0)
|
|
77
|
+
}, props.record.field ?? {}), null);
|
|
78
|
+
}
|
|
79
|
+
function renderNumberRange() {
|
|
80
|
+
const name = props.record.name;
|
|
81
|
+
const value = props.formState[name];
|
|
82
|
+
const placeholder = Array.isArray(props.record.placeholder) ? props.record.placeholder : ["请输入", "请输入"];
|
|
83
|
+
return createVNode(SpaceCompact, {
|
|
84
|
+
"class": `${props.prefixCls}-search-input-compact`,
|
|
85
|
+
"style": { width: "100%" }
|
|
86
|
+
}, { default: () => [
|
|
87
|
+
createVNode(InputNumber, {
|
|
88
|
+
"value": value?.[0],
|
|
89
|
+
"placeholder": placeholder[0] || "请输入",
|
|
90
|
+
"onChange": (val) => handleChange(val, { key: 0 }),
|
|
91
|
+
"style": rangeInputStyle
|
|
92
|
+
}, null),
|
|
93
|
+
createVNode(Input, {
|
|
94
|
+
"disabled": true,
|
|
95
|
+
"value": "~",
|
|
96
|
+
"class": `${props.prefixCls}-number-range-separator`,
|
|
97
|
+
"style": {
|
|
98
|
+
width: 30,
|
|
99
|
+
flex: "0 0 30px",
|
|
100
|
+
pointerEvents: "none"
|
|
101
|
+
}
|
|
102
|
+
}, null),
|
|
103
|
+
createVNode(InputNumber, {
|
|
104
|
+
"value": value?.[1],
|
|
105
|
+
"placeholder": placeholder[1] || "请输入",
|
|
106
|
+
"onChange": (val) => handleChange(val, { key: 1 }),
|
|
107
|
+
"style": rangeInputStyle
|
|
108
|
+
}, null)
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function renderSelect() {
|
|
112
|
+
const isLoading = props.record.loading || requestLoading.value;
|
|
113
|
+
const options = props.record.request ? optionList.value : props.record.valueEnum || [];
|
|
114
|
+
const fields = props.record.field ?? {};
|
|
115
|
+
return createVNode(Select, mergeProps({
|
|
116
|
+
"style": { width: "100%" },
|
|
117
|
+
"value": isLoading ? void 0 : props.formState[props.record.name],
|
|
118
|
+
"optionFilterProp": "label",
|
|
119
|
+
"placeholder": props.record.placeholder || "请选择",
|
|
120
|
+
"showSearch": props.record.showSearch,
|
|
121
|
+
"allowClear": props.record.allowClear ?? true,
|
|
122
|
+
"loading": isLoading,
|
|
123
|
+
"options": options,
|
|
124
|
+
"onChange": (val) => handleChange(val ?? void 0)
|
|
125
|
+
}, fields), null);
|
|
126
|
+
}
|
|
127
|
+
function renderTreeSelect() {
|
|
128
|
+
const fields = props.record.field ?? {};
|
|
129
|
+
const isLoading = props.record.loading || requestLoading.value;
|
|
130
|
+
return createVNode(TreeSelect, mergeProps({
|
|
131
|
+
"style": { width: "100%" },
|
|
132
|
+
"value": props.formState[props.record.name],
|
|
133
|
+
"placeholder": props.record.placeholder || "请选择",
|
|
134
|
+
"allowClear": props.record.allowClear ?? true,
|
|
135
|
+
"treeData": isLoading ? [] : props.record.request ? optionList.value : props.record.valueEnum || [],
|
|
136
|
+
"loading": isLoading,
|
|
137
|
+
"onChange": (val) => handleChange(val ?? (fields.treeCheckable || fields.multiple ? [] : null))
|
|
138
|
+
}, fields), null);
|
|
139
|
+
}
|
|
140
|
+
function renderCascader() {
|
|
141
|
+
const fields = props.record.field ?? {};
|
|
142
|
+
const isLoading = props.record.loading || requestLoading.value;
|
|
143
|
+
return createVNode(Cascader, mergeProps({
|
|
144
|
+
"style": { width: "100%" },
|
|
145
|
+
"value": props.formState[props.record.name],
|
|
146
|
+
"placeholder": props.record.placeholder || "请选择",
|
|
147
|
+
"allowClear": props.record.allowClear ?? true,
|
|
148
|
+
"options": isLoading ? [] : props.record.request ? optionList.value : props.record.valueEnum || [],
|
|
149
|
+
"loading": isLoading,
|
|
150
|
+
"onChange": (val) => handleChange(val ?? void 0)
|
|
151
|
+
}, fields), null);
|
|
152
|
+
}
|
|
153
|
+
function renderDate() {
|
|
154
|
+
const format = resolveValueFormat(props.record.valueFormat, props.record.showTime);
|
|
155
|
+
return createVNode(DatePicker, mergeProps({
|
|
156
|
+
"style": { width: "100%" },
|
|
157
|
+
"value": props.formState[props.record.name] ? dayjs(props.formState[props.record.name]) : void 0,
|
|
158
|
+
"placeholder": props.record.placeholder || "请选择",
|
|
159
|
+
"allowClear": props.record.allowClear ?? true,
|
|
160
|
+
"format": format,
|
|
161
|
+
"showTime": props.record.showTime,
|
|
162
|
+
"onChange": (val) => handleChange(val ? formatStringValue(val, format) : null)
|
|
163
|
+
}, props.record.field ?? {}), null);
|
|
164
|
+
}
|
|
165
|
+
function renderDatePicker(picker, format, placeholder) {
|
|
166
|
+
const value = props.formState[props.record.name];
|
|
167
|
+
return createVNode(DatePicker, mergeProps({
|
|
168
|
+
"style": { width: "100%" },
|
|
169
|
+
"picker": picker,
|
|
170
|
+
"value": value ? dayjs(value, format) : void 0,
|
|
171
|
+
"placeholder": placeholder || "请选择",
|
|
172
|
+
"allowClear": props.record.allowClear ?? true,
|
|
173
|
+
"onChange": (val) => handleChange(val ? formatStringValue(val, format) : null)
|
|
174
|
+
}, props.record.field ?? {}), null);
|
|
175
|
+
}
|
|
176
|
+
function renderDateRange() {
|
|
177
|
+
const format = resolveValueFormat(props.record.valueFormat, props.record.showTime);
|
|
178
|
+
const value = props.formState[props.record.name];
|
|
179
|
+
const fields = props.record.field ?? {};
|
|
180
|
+
const placeholderValue = Array.isArray(props.record.placeholder) ? props.record.placeholder : ["开始日期", "结束日期"];
|
|
181
|
+
return createVNode(RangePicker, mergeProps({
|
|
182
|
+
"style": { width: "100%" },
|
|
183
|
+
"value": Array.isArray(value) && value.length === 2 ? formatDateRangeArray(value, format, "dayjs") : void 0,
|
|
184
|
+
"placeholder": placeholderValue,
|
|
185
|
+
"format": format,
|
|
186
|
+
"showTime": props.record.showTime,
|
|
187
|
+
"onChange": (val) => {
|
|
188
|
+
handleChange(val && Array.isArray(val) && val.length === 2 ? formatDateRangeArray(val, format, "string") : null);
|
|
189
|
+
}
|
|
190
|
+
}, fields), null);
|
|
191
|
+
}
|
|
192
|
+
function renderTime() {
|
|
193
|
+
const format = props.record.valueFormat || "HH:mm:ss";
|
|
194
|
+
return createVNode(TimePicker, mergeProps({
|
|
195
|
+
"style": { width: "100%" },
|
|
196
|
+
"value": props.formState[props.record.name] ? dayjs(props.formState[props.record.name], format) : void 0,
|
|
197
|
+
"placeholder": props.record.placeholder || "请选择",
|
|
198
|
+
"allowClear": props.record.allowClear ?? true,
|
|
199
|
+
"use12Hours": props.record.use12Hours,
|
|
200
|
+
"format": format,
|
|
201
|
+
"onChange": (val) => handleChange(val ? formatStringValue(val, format) : null)
|
|
202
|
+
}, props.record.field ?? {}), null);
|
|
203
|
+
}
|
|
204
|
+
return () => {
|
|
205
|
+
switch (props.record.valueType ?? "text") {
|
|
206
|
+
case "text": return renderText();
|
|
207
|
+
case "number": return renderNumber();
|
|
208
|
+
case "numberRange": return renderNumberRange();
|
|
209
|
+
case "select": return renderSelect();
|
|
210
|
+
case "treeSelect": return renderTreeSelect();
|
|
211
|
+
case "cascader": return renderCascader();
|
|
212
|
+
case "date": return renderDate();
|
|
213
|
+
case "dateWeek": return renderDatePicker("week", "YYYY-wo", props.record.placeholder || "请选择");
|
|
214
|
+
case "dateMonth": return renderDatePicker("month", "YYYY-MM", props.record.placeholder || "请选择");
|
|
215
|
+
case "dateQuarter": return renderDatePicker("quarter", "YYYY-QQ", props.record.placeholder || "请选择");
|
|
216
|
+
case "dateYear": return renderDatePicker("year", "YYYY", props.record.placeholder || "请选择");
|
|
217
|
+
case "dateRange": return renderDateRange();
|
|
218
|
+
case "time": return renderTime();
|
|
219
|
+
default: return renderText();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
//#endregion
|
|
225
|
+
export { FormItemContainer };
|