@opentiny/vue-renderless 3.23.0 → 3.25.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/anchor/index.js +1 -1
- package/cascader-node/vue.js +1 -0
- package/date-range/index.js +1 -1
- package/dialog-select/index.js +4 -2
- package/dialog-select/vue.js +2 -2
- package/file-upload/index.js +32 -9
- package/grid/plugins/exportExcel.js +1 -2
- package/grid/utils/column.js +96 -64
- package/grid/utils/common.js +79 -20
- package/grid/utils/dom.js +70 -97
- package/grid-select/index.js +2 -2
- package/input/index.js +2 -2
- package/input/vue.js +1 -2
- package/package.json +3 -3
- package/pager/vue.js +1 -0
- package/qr-code/vue.js +1 -1
- package/search/index.js +2 -1
- package/select/index.js +4 -3
- package/types/action-menu.type.d.ts +1 -0
- package/types/action-sheet.type.d.ts +1 -0
- package/types/alert.type.d.ts +1 -0
- package/types/amount.type.d.ts +1 -0
- package/types/area.type.d.ts +1 -0
- package/types/async-flowchart.type.d.ts +1 -0
- package/types/autocomplete.type.d.ts +1 -0
- package/types/badge.type.d.ts +1 -0
- package/types/breadcrumb-item.type.d.ts +1 -0
- package/types/breadcrumb.type.d.ts +1 -0
- package/types/button-group.type.d.ts +1 -0
- package/types/button.type.d.ts +6 -0
- package/types/cascader.type.d.ts +1 -0
- package/types/checkbox.type.d.ts +1 -0
- package/types/collapse-item.type.d.ts +1 -0
- package/types/collapse.type.d.ts +1 -0
- package/types/dialog-box.type.d.ts +1 -0
- package/types/divider.type.d.ts +1 -0
- package/types/drawer.type.d.ts +1 -0
- package/types/{dropdown-item.type-c9badbc1.d.ts → dropdown-item.type-b3ced3ce.d.ts} +2 -0
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +1 -0
- package/types/fall-menu.type.d.ts +1 -0
- package/types/file-upload.type.d.ts +1 -1
- package/types/float-button.type.d.ts +1 -0
- package/types/floatbar.type.d.ts +1 -0
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-4e0ec0a1.d.ts → form.type-dd403065.d.ts} +2 -0
- package/types/form.type.d.ts +1 -1
- package/types/image.type.d.ts +1 -0
- package/types/{index-a975a7a2.d.ts → index-cada95ca.d.ts} +2 -0
- package/types/input.type.d.ts +1 -0
- package/types/ip-address.type.d.ts +1 -0
- package/types/link.type.d.ts +1 -0
- package/types/load-list.type.d.ts +1 -0
- package/types/loading.type.d.ts +1 -0
- package/types/milestone.type.d.ts +1 -0
- package/types/mind-map.type.d.ts +1 -0
- package/types/modal.type.d.ts +1 -0
- package/types/nav-menu.type.d.ts +1 -0
- package/types/numeric.type.d.ts +1 -0
- package/types/pager.type.d.ts +1 -1
- package/types/popconfirm.type.d.ts +1 -0
- package/types/popeditor.type.d.ts +5 -0
- package/types/popover.type.d.ts +1 -0
- package/types/progress.type.d.ts +1 -0
- package/types/radio-button.type.d.ts +1 -0
- package/types/radio-group.type.d.ts +1 -0
- package/types/radio.type.d.ts +1 -0
- package/types/rate.type.d.ts +1 -0
- package/types/search.type.d.ts +1 -0
- package/types/skeleton-item.type.d.ts +1 -0
- package/types/skeleton.type.d.ts +1 -0
- package/types/slider.type.d.ts +1 -0
- package/types/statistic.type.d.ts +1 -0
- package/types/steps.type.d.ts +5 -0
- package/types/switch.type.d.ts +1 -0
- package/types/tab-bar.type.d.ts +1 -1
- package/types/tab-item.type.d.ts +1 -0
- package/types/tab-nav.type.d.ts +1 -1
- package/types/tabs.type.d.ts +1 -0
- package/types/tag-group.type.d.ts +1 -0
- package/types/tag.type.d.ts +1 -0
- package/types/{time-line.type-9fb16096.d.ts → time-line.type-ad280ca5.d.ts} +2 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/tooltip.type.d.ts +1 -0
- package/types/transfer.type.d.ts +1 -0
- package/types/tree-menu.type.d.ts +1 -0
- package/types/upload-dragger.type.d.ts +2 -1
- package/types/{upload-list.type-eaf82b7a.d.ts → upload-list.type-36a8374a.d.ts} +4 -1
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-contact.type.d.ts +1 -0
- package/types/user-head.type.d.ts +3 -2
- package/types/wizard.type.d.ts +1 -0
package/anchor/index.js
CHANGED
package/cascader-node/vue.js
CHANGED
|
@@ -20,6 +20,7 @@ const renderless = (props, { computed, reactive, inject, watch }, { dispatch })
|
|
|
20
20
|
inActivePath: computed(() => api2.isInPath(parent.state.activePath)),
|
|
21
21
|
inCheckedPath: computed(() => api2.comptCheckPath()),
|
|
22
22
|
value: computed(() => props.node.getValueByOption()),
|
|
23
|
+
// 仅 mf 用到nodeLabel
|
|
23
24
|
nodeLabel: computed(() => {
|
|
24
25
|
return parent.state.renderLabelFn ? parent.state.renderLabelFn({ node: props.node, data: props.node.data }) : props.node.label;
|
|
25
26
|
})
|
package/date-range/index.js
CHANGED
|
@@ -139,7 +139,7 @@ const handleClear = ({ emit, state }) => () => {
|
|
|
139
139
|
state.rightDate = nextMonth1(state.leftDate);
|
|
140
140
|
state.rangeState.selecting = false;
|
|
141
141
|
state.rangeState.endDate = null;
|
|
142
|
-
emit("pick",
|
|
142
|
+
emit("pick", []);
|
|
143
143
|
};
|
|
144
144
|
const handleChangeRange = (state, props) => (val) => {
|
|
145
145
|
if (props.readonly) {
|
package/dialog-select/index.js
CHANGED
|
@@ -119,7 +119,7 @@ const selectedBoxInit = ({ props, vm, nextTick }) => () => {
|
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
const selectedBoxClear = ({ props, state, vm }) => () => {
|
|
122
|
+
const selectedBoxClear = ({ props, state, vm, emit }) => () => {
|
|
123
123
|
const { multi, popseletor } = props;
|
|
124
124
|
if (multi && popseletor === "grid") {
|
|
125
125
|
vm.$refs.multiGrid.clearSelection();
|
|
@@ -130,6 +130,7 @@ const selectedBoxClear = ({ props, state, vm }) => () => {
|
|
|
130
130
|
state.selectedValues = [];
|
|
131
131
|
state.selectedDatas = [];
|
|
132
132
|
state.selectedChanged = true;
|
|
133
|
+
emit("clear");
|
|
133
134
|
};
|
|
134
135
|
const setTreeSelection = ({ api, state, vm, props }) => (keys, value) => {
|
|
135
136
|
const tree = vm.$refs.multiTree;
|
|
@@ -205,7 +206,7 @@ const setSelection = ({ props, api }) => (data, value) => {
|
|
|
205
206
|
}
|
|
206
207
|
};
|
|
207
208
|
const getSelection = ({ state }) => () => state.selectedDatas;
|
|
208
|
-
const selectedBoxDelete = ({ props, state, vm }) => ({ option: row }) => {
|
|
209
|
+
const selectedBoxDelete = ({ props, state, vm, emit }) => ({ option: row }) => {
|
|
209
210
|
const { multi, popseletor } = props;
|
|
210
211
|
if (multi && popseletor === "grid") {
|
|
211
212
|
vm.$refs.multiGrid.setSelection(
|
|
@@ -222,6 +223,7 @@ const selectedBoxDelete = ({ props, state, vm }) => ({ option: row }) => {
|
|
|
222
223
|
state.selectedDatas = [...state.selectedDatas.slice(0, index), ...state.selectedDatas.slice(index + 1)];
|
|
223
224
|
state.selectedChanged = true;
|
|
224
225
|
}
|
|
226
|
+
emit("delete", row);
|
|
225
227
|
};
|
|
226
228
|
const selectedBoxDrag = ({ props, state }) => ({ state: { select } }) => {
|
|
227
229
|
if (select && select.length) {
|
package/dialog-select/vue.js
CHANGED
|
@@ -92,8 +92,8 @@ const renderless = (props, { reactive, computed, watch }, { vm, nextTick, emit,
|
|
|
92
92
|
state,
|
|
93
93
|
computedGridColumns: computedGridColumns(props),
|
|
94
94
|
selectedBoxInit: selectedBoxInit({ props, vm, nextTick }),
|
|
95
|
-
selectedBoxClear: selectedBoxClear({ props, state, vm }),
|
|
96
|
-
selectedBoxDelete: selectedBoxDelete({ props, state, vm }),
|
|
95
|
+
selectedBoxClear: selectedBoxClear({ props, state, vm, emit }),
|
|
96
|
+
selectedBoxDelete: selectedBoxDelete({ props, state, vm, emit }),
|
|
97
97
|
selectedBoxDrag: selectedBoxDrag({ props, state }),
|
|
98
98
|
doMultiTreeFilter: doMultiTreeFilter({ props, state, nextTick, vm }),
|
|
99
99
|
multiTreeFilterNode: multiTreeFilterNode(props),
|
package/file-upload/index.js
CHANGED
|
@@ -133,6 +133,14 @@ const onBeforeIsPromise = ({
|
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
135
|
};
|
|
136
|
+
const isAcceptType = (acceptArray, file, constants, fileType) => {
|
|
137
|
+
return acceptArray.some((type) => {
|
|
138
|
+
if (type.toLowerCase() === constants.IMAGE_TYPE) {
|
|
139
|
+
return constants.FILE_TYPE.PICTURE.split("/").includes(fileType);
|
|
140
|
+
}
|
|
141
|
+
return new RegExp(`(${type.trim()})$`, "i").test(file.name);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
136
144
|
const getFileType = ({ file }) => {
|
|
137
145
|
const { name, url } = file;
|
|
138
146
|
let fileType = "";
|
|
@@ -164,7 +172,7 @@ const beforeUpload = ({
|
|
|
164
172
|
constants,
|
|
165
173
|
t,
|
|
166
174
|
state
|
|
167
|
-
}) => (file, autoRemove, doUpload) => {
|
|
175
|
+
}) => (file, autoRemove, doUpload, isMergeUpload = false) => {
|
|
168
176
|
if (state.isEdm && file.name.length > 255) {
|
|
169
177
|
remove({ api, file, autoRemove });
|
|
170
178
|
return Modal.message({
|
|
@@ -176,15 +184,30 @@ const beforeUpload = ({
|
|
|
176
184
|
let isValid = true;
|
|
177
185
|
const accept = state.isEdm ? state.accept : props.accept;
|
|
178
186
|
const types = constants.FILE_TYPE[state.triggerClickType.toUpperCase()];
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
const acceptArray = accept ? accept.split(",") : [];
|
|
188
|
+
let fileType = "";
|
|
189
|
+
if (isMergeUpload) {
|
|
190
|
+
const fileRow = [];
|
|
191
|
+
fileType = file.raw.flatMap((f) => {
|
|
192
|
+
const type = getFileType({ file: f });
|
|
193
|
+
if (accept) {
|
|
194
|
+
const isExist = isAcceptType(acceptArray, f, constants, type);
|
|
195
|
+
isExist ? fileRow.push(f) : remove({ api, file: f, autoRemove });
|
|
196
|
+
} else {
|
|
197
|
+
fileRow.push(f);
|
|
184
198
|
}
|
|
185
|
-
return
|
|
199
|
+
return type;
|
|
186
200
|
});
|
|
187
|
-
|
|
201
|
+
if (!fileRow.length) {
|
|
202
|
+
isValid = false;
|
|
203
|
+
}
|
|
204
|
+
file.raw = fileRow;
|
|
205
|
+
} else {
|
|
206
|
+
fileType = getFileType({ file });
|
|
207
|
+
if (accept) {
|
|
208
|
+
const isExist = isAcceptType(acceptArray, file, constants, fileType);
|
|
209
|
+
!isExist && (isValid = false);
|
|
210
|
+
}
|
|
188
211
|
}
|
|
189
212
|
if (state.triggerClickType && types) {
|
|
190
213
|
const isExist = types.split("/").includes(fileType);
|
|
@@ -465,7 +488,7 @@ const handleStart = ({
|
|
|
465
488
|
if (!state.isEdm && props.autoUpload) {
|
|
466
489
|
if (props.multiple && props.mergeService) {
|
|
467
490
|
const handler = (file) => vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw);
|
|
468
|
-
rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler);
|
|
491
|
+
rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler, true);
|
|
469
492
|
} else {
|
|
470
493
|
rawFiles.forEach((rawFile) => {
|
|
471
494
|
const file = api.getFile(rawFile);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "../../chunk-G2ADBYYC.js";
|
|
2
|
-
import { extend } from "@opentiny/utils";
|
|
3
|
-
import { browserInfo } from "@opentiny/utils";
|
|
2
|
+
import { extend, browserInfo } from "@opentiny/utils";
|
|
4
3
|
const isIE = browserInfo.name === "ie";
|
|
5
4
|
const rgbRegExp = /^rgba?\((\d+),\s(\d+),\s(\d+)([\s\S]*)\)$/;
|
|
6
5
|
const hexRegExp = /^#([a-zA-Z0-9]{3}|[a-zA-Z0-9]{6})$/;
|
package/grid/utils/column.js
CHANGED
|
@@ -2,72 +2,104 @@ import "../../chunk-G2ADBYYC.js";
|
|
|
2
2
|
import { isBoolean } from "../static";
|
|
3
3
|
import { initFilter } from "./common";
|
|
4
4
|
let columnUniqueId = 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
column.footerClassName = context.footerClassName;
|
|
29
|
-
column.indexMethod = context.indexMethod;
|
|
30
|
-
column.formatText = context.formatText;
|
|
31
|
-
column.formatValue = context.formatValue;
|
|
32
|
-
setColumnFormat(column, context);
|
|
33
|
-
column.sortable = context.sortable;
|
|
34
|
-
column.sortBy = context.sortBy;
|
|
35
|
-
column.sortMethod = context.sortMethod;
|
|
36
|
-
column.remoteSort = context.remoteSort;
|
|
37
|
-
column.filterMultiple = isBoolean(context.filterMultiple) ? context.filterMultiple : true;
|
|
38
|
-
column.filterMethod = context.filterMethod;
|
|
39
|
-
column.filterRender = context.filterRender;
|
|
40
|
-
column.filter = context.filter && initFilter(context.filter);
|
|
41
|
-
column.treeNode = context.treeNode;
|
|
42
|
-
column.renderer = context.renderer;
|
|
43
|
-
column.editor = context.editor;
|
|
44
|
-
column.operationConfig = context.operationConfig;
|
|
45
|
-
column.equals = context.equals;
|
|
5
|
+
class FixedDetails {
|
|
6
|
+
constructor(fixedType) {
|
|
7
|
+
this.isLeft = fixedType === "left";
|
|
8
|
+
this.isLeftLast = false;
|
|
9
|
+
this.isRight = fixedType === "right";
|
|
10
|
+
this.isRightFirst = false;
|
|
11
|
+
this.left = 0;
|
|
12
|
+
this.right = 0;
|
|
13
|
+
}
|
|
14
|
+
getStyle(rightExtra = 0) {
|
|
15
|
+
const { isLeft, left, isRight, right } = this;
|
|
16
|
+
return {
|
|
17
|
+
left: isLeft ? `${left}px` : void 0,
|
|
18
|
+
right: isRight ? `${right + rightExtra}px` : void 0
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
getClass() {
|
|
22
|
+
const { isLeftLast, isRightFirst } = this;
|
|
23
|
+
return {
|
|
24
|
+
"fixed-left-last__column": isLeftLast,
|
|
25
|
+
"fixed-right-first__column": isRightFirst
|
|
26
|
+
};
|
|
27
|
+
}
|
|
46
28
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
29
|
+
class ColumnConfig {
|
|
30
|
+
constructor(context, { renderHeader, renderCell, renderData } = {}, config = {}) {
|
|
31
|
+
this.id = `col_${++columnUniqueId}`;
|
|
32
|
+
this.type = context.type;
|
|
33
|
+
this.prop = context.prop;
|
|
34
|
+
this.rules = context.rules;
|
|
35
|
+
this.required = context.required;
|
|
36
|
+
this.property = context.field || context.prop;
|
|
37
|
+
this.title = context.title;
|
|
38
|
+
this.label = context.label;
|
|
39
|
+
this.width = context.width;
|
|
40
|
+
this.minWidth = context.minWidth;
|
|
41
|
+
this.resizable = context.resizable;
|
|
42
|
+
this._fixed = context.fixed;
|
|
43
|
+
this._fixedDetails = context.fixed ? new FixedDetails(context.fixed) : void 0;
|
|
44
|
+
this.align = context.align;
|
|
45
|
+
this.headerAlign = context.headerAlign;
|
|
46
|
+
this.footerAlign = context.footerAlign;
|
|
47
|
+
this.showOverflow = context.showOverflow;
|
|
48
|
+
this.showHeaderOverflow = context.showHeaderOverflow;
|
|
49
|
+
this.showTip = context.showTip;
|
|
50
|
+
this.showHeaderTip = context.showHeaderTip;
|
|
51
|
+
this.className = context.class || context.className;
|
|
52
|
+
this.headerClassName = context.headerClassName;
|
|
53
|
+
this.footerClassName = context.footerClassName;
|
|
54
|
+
this.indexMethod = context.indexMethod;
|
|
55
|
+
this.formatText = context.formatText;
|
|
56
|
+
this.formatValue = context.formatValue;
|
|
57
|
+
this.format = context.formatConfig;
|
|
58
|
+
this.sortable = context.sortable;
|
|
59
|
+
this.sortBy = context.sortBy;
|
|
60
|
+
this.sortMethod = context.sortMethod;
|
|
61
|
+
this.remoteSort = context.remoteSort;
|
|
62
|
+
this.filterMultiple = isBoolean(context.filterMultiple) ? context.filterMultiple : true;
|
|
63
|
+
this.filterMethod = context.filterMethod;
|
|
64
|
+
this.filterRender = context.filterRender;
|
|
65
|
+
this.filter = context.filter && initFilter(context.filter);
|
|
66
|
+
this.treeNode = context.treeNode;
|
|
67
|
+
this.renderer = context.renderer;
|
|
68
|
+
this.editor = context.editor;
|
|
69
|
+
this.operationConfig = context.operationConfig;
|
|
70
|
+
this.equals = context.equals;
|
|
71
|
+
this.params = context.params;
|
|
72
|
+
this.visible = true;
|
|
73
|
+
this.level = 1;
|
|
74
|
+
this.rowSpan = 1;
|
|
75
|
+
this.colSpan = 1;
|
|
76
|
+
this.order = null;
|
|
77
|
+
this.renderWidth = 0;
|
|
78
|
+
this.renderHeight = 0;
|
|
79
|
+
this.resizeWidth = 0;
|
|
80
|
+
this.renderLeft = 0;
|
|
81
|
+
this.model = {};
|
|
82
|
+
this.renderHeader = renderHeader || context.renderHeader;
|
|
83
|
+
this.renderCell = renderCell || context.renderCell;
|
|
84
|
+
this.renderData = renderData;
|
|
85
|
+
this.showIcon = isBoolean(context.showIcon) ? context.showIcon : true;
|
|
86
|
+
this.loading = false;
|
|
87
|
+
this.slots = context.slots;
|
|
88
|
+
this.own = context;
|
|
89
|
+
this.asyncPrefix = config.constant.asyncPrefix;
|
|
90
|
+
}
|
|
91
|
+
set fixed(val) {
|
|
92
|
+
this._fixed = val;
|
|
93
|
+
this._fixedDetails = val ? new FixedDetails(val) : void 0;
|
|
94
|
+
}
|
|
95
|
+
get fixed() {
|
|
96
|
+
return this._fixed;
|
|
97
|
+
}
|
|
98
|
+
get fixedDetails() {
|
|
99
|
+
return this._fixedDetails;
|
|
100
|
+
}
|
|
68
101
|
}
|
|
69
102
|
const getColumnConfig = (context, options, config) => context instanceof ColumnConfig ? context : new ColumnConfig(context, options, config);
|
|
70
103
|
export {
|
|
71
|
-
getColumnConfig
|
|
72
|
-
setColumnFormat
|
|
104
|
+
getColumnConfig
|
|
73
105
|
};
|
package/grid/utils/common.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__spreadValues
|
|
3
3
|
} from "../../chunk-G2ADBYYC.js";
|
|
4
|
-
import { isNull } from "@opentiny/utils";
|
|
5
|
-
import {
|
|
6
|
-
import { get, isFunction, set } from "../static";
|
|
4
|
+
import { isNull, find, isFunction } from "@opentiny/utils";
|
|
5
|
+
import { get, set } from "../static";
|
|
7
6
|
const gridSize = ["medium", "small", "mini"];
|
|
8
7
|
const getSize = ({ size, $parent }) => size || ($parent && gridSize.includes($parent.size) ? $parent.size : null);
|
|
9
8
|
const getFuncText = (content) => isFunction(content) ? content() : content;
|
|
@@ -12,17 +11,42 @@ const getRowid = ($table, row) => {
|
|
|
12
11
|
const rowId = get(row, getRowkey($table));
|
|
13
12
|
return rowId ? encodeURIComponent(rowId) : "";
|
|
14
13
|
};
|
|
15
|
-
const getColumnList = (columns) => {
|
|
14
|
+
const getColumnList = (columns, options = {}, level = 0) => {
|
|
16
15
|
const result = [];
|
|
17
|
-
columns.forEach((column) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
columns.forEach((column, index) => {
|
|
17
|
+
var _a;
|
|
18
|
+
const hasChildren = (_a = column.children) == null ? void 0 : _a.length;
|
|
19
|
+
if (!options.hasFixed && column.fixed) {
|
|
20
|
+
options.hasFixed = true;
|
|
21
|
+
}
|
|
22
|
+
if (!options.isCheckable && column.type === "selection") {
|
|
23
|
+
options.isCheckable = true;
|
|
22
24
|
}
|
|
25
|
+
if (level === 0 && !options.isGroup && hasChildren) {
|
|
26
|
+
options.isGroup = true;
|
|
27
|
+
}
|
|
28
|
+
options.columnCaches.push({ colid: column.id, column, index });
|
|
29
|
+
result.push.apply(result, hasChildren ? getColumnList(column.children, options, level + 1) : [column]);
|
|
23
30
|
});
|
|
24
31
|
return result;
|
|
25
32
|
};
|
|
33
|
+
const repairFixed = (root) => {
|
|
34
|
+
const subtree = [];
|
|
35
|
+
let fixed;
|
|
36
|
+
const recursive = (col) => {
|
|
37
|
+
subtree.push(col);
|
|
38
|
+
if (!fixed && col.fixed) {
|
|
39
|
+
fixed = col.fixed;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(col.children) && col.children.length > 0) {
|
|
42
|
+
col.children.forEach((col2) => recursive(col2));
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
recursive(root);
|
|
46
|
+
if (fixed) {
|
|
47
|
+
subtree.forEach((c) => c.fixed = fixed);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
26
50
|
const getClass = (property, params) => property ? isFunction(property) ? property(params) : property : "";
|
|
27
51
|
const getFilters = (filters) => (filters || []).map(({ label, value, data, checked }) => ({
|
|
28
52
|
label,
|
|
@@ -32,17 +56,25 @@ const getFilters = (filters) => (filters || []).map(({ label, value, data, check
|
|
|
32
56
|
checked: !!checked
|
|
33
57
|
}));
|
|
34
58
|
const initFilter = (filter) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const {
|
|
61
|
+
values,
|
|
62
|
+
value: valueKey = "value",
|
|
63
|
+
checked: checkedKey = "checked",
|
|
64
|
+
condition,
|
|
65
|
+
enumable,
|
|
66
|
+
multi,
|
|
67
|
+
inputFilter
|
|
68
|
+
} = filter;
|
|
69
|
+
const value = ((_a = values == null ? void 0 : values.filter) == null ? void 0 : _a.call(values, (i) => i[checkedKey]).map((i) => i[valueKey])) || [];
|
|
70
|
+
const hasChecked = (_c = (_b = values == null ? void 0 : values.some) == null ? void 0 : _b.call(values, (i) => i[checkedKey])) != null ? _c : false;
|
|
71
|
+
const filterOptions = {
|
|
72
|
+
condition: { input: "", relation: "equals", empty: null, type: null, value },
|
|
73
|
+
hasFilter: inputFilter && !!(condition == null ? void 0 : condition.input) || enumable && multi && hasChecked || false,
|
|
74
|
+
custom: null,
|
|
75
|
+
showClear: true
|
|
76
|
+
};
|
|
77
|
+
return __spreadValues(__spreadValues({}, filterOptions), filter);
|
|
46
78
|
};
|
|
47
79
|
const formatText = (value) => `${isNull(value) ? "" : value}`;
|
|
48
80
|
const setCellValue = (row, column, value) => {
|
|
@@ -116,8 +148,33 @@ const getListeners = ($attrs, $listeners) => {
|
|
|
116
148
|
});
|
|
117
149
|
return listeners;
|
|
118
150
|
};
|
|
151
|
+
function dfsCopy(tree, callback, parent = void 0, isTree = false, childrenKey = "children") {
|
|
152
|
+
let copy;
|
|
153
|
+
if (Array.isArray(tree)) {
|
|
154
|
+
copy = [];
|
|
155
|
+
tree.forEach((node, index) => {
|
|
156
|
+
const copyItem = callback(node, index, parent);
|
|
157
|
+
if (copyItem) {
|
|
158
|
+
copy.push(copyItem);
|
|
159
|
+
}
|
|
160
|
+
if (isTree) {
|
|
161
|
+
const children = node[childrenKey];
|
|
162
|
+
if (children) {
|
|
163
|
+
const childrenCopy = dfsCopy(children, callback, node, isTree, childrenKey);
|
|
164
|
+
if (copyItem) {
|
|
165
|
+
copyItem[childrenKey] = childrenCopy;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return copy;
|
|
172
|
+
}
|
|
173
|
+
let rowUniqueId = 0;
|
|
174
|
+
const getRowUniqueId = () => `row_${++rowUniqueId}`;
|
|
119
175
|
export {
|
|
120
176
|
assemColumn,
|
|
177
|
+
dfsCopy,
|
|
121
178
|
emitEvent,
|
|
122
179
|
formatText,
|
|
123
180
|
getCellValue,
|
|
@@ -126,11 +183,13 @@ export {
|
|
|
126
183
|
getFilters,
|
|
127
184
|
getFuncText,
|
|
128
185
|
getListeners,
|
|
186
|
+
getRowUniqueId,
|
|
129
187
|
getRowid,
|
|
130
188
|
getRowkey,
|
|
131
189
|
getSize,
|
|
132
190
|
gridSize,
|
|
133
191
|
hasChildrenList,
|
|
134
192
|
initFilter,
|
|
193
|
+
repairFixed,
|
|
135
194
|
setCellValue
|
|
136
195
|
};
|
package/grid/utils/dom.js
CHANGED
|
@@ -8,8 +8,12 @@ const CELL_CLS = ".tiny-grid-cell";
|
|
|
8
8
|
const ROW_CLS = ".tiny-grid-body__row";
|
|
9
9
|
const isPx = (val) => val && /^\d+(px)?$/.test(val);
|
|
10
10
|
const isScale = (val) => val && /^\d+%$/.test(val);
|
|
11
|
-
const updateCellTitle = (event) => {
|
|
12
|
-
|
|
11
|
+
const updateCellTitle = (event, td) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const cellEl = td ? td.querySelector(".tiny-grid-cell-text") || td.querySelector(CELL_CLS) : (_a = event.currentTarget) == null ? void 0 : _a.querySelector(CELL_CLS);
|
|
14
|
+
if (!cellEl) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
13
17
|
const content = cellEl.innerText;
|
|
14
18
|
if (cellEl.getAttribute("title") !== content) {
|
|
15
19
|
cellEl.setAttribute("title", content);
|
|
@@ -17,109 +21,75 @@ const updateCellTitle = (event) => {
|
|
|
17
21
|
};
|
|
18
22
|
const rowToVisible = ($table, row) => {
|
|
19
23
|
$table.$nextTick(() => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
const { $refs, scrollYLoad, rowHeight, headerHeight, footerHeight, _tileInfo, _graphInfo } = $table;
|
|
25
|
+
const { tableBody: bodyVm } = $refs;
|
|
26
|
+
const { $el } = bodyVm;
|
|
27
|
+
const { map } = _tileInfo;
|
|
28
|
+
const { graphed } = _graphInfo;
|
|
29
|
+
const trEl = $el.querySelector(`[${ATTR_NAME}="${getRowid($table, row)}"]`);
|
|
30
|
+
const visibleStart = headerHeight;
|
|
31
|
+
const visibleEnd = $el.clientHeight - footerHeight;
|
|
32
|
+
const scrollTop = $el.scrollTop;
|
|
33
|
+
let position, trHeight;
|
|
34
|
+
let flag = false;
|
|
35
|
+
if (scrollYLoad) {
|
|
36
|
+
position = headerHeight + rowHeight * graphed.indexOf(map.get(row)) - scrollTop;
|
|
37
|
+
trHeight = rowHeight;
|
|
38
|
+
flag = true;
|
|
39
|
+
} else if (trEl) {
|
|
40
|
+
position = trEl.offsetTop - scrollTop;
|
|
41
|
+
trHeight = trEl.clientHeight;
|
|
42
|
+
flag = true;
|
|
43
|
+
}
|
|
44
|
+
if (flag) {
|
|
45
|
+
if (position < visibleStart) {
|
|
46
|
+
$el.scrollTop = scrollTop - (visibleStart - position);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
position += trHeight;
|
|
50
|
+
if (position > visibleEnd) {
|
|
51
|
+
$el.scrollTop = scrollTop + (position - visibleEnd);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
});
|
|
46
55
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
from.fixed === "left" && (scrollLeft = 0);
|
|
51
|
-
from.fixed === "right" && (scrollLeft = body.scrollWidth);
|
|
56
|
+
const colToVisible = ($table, column) => {
|
|
57
|
+
if (column.fixed) {
|
|
58
|
+
return;
|
|
52
59
|
}
|
|
53
|
-
return scrollLeft;
|
|
54
|
-
}
|
|
55
|
-
function computeScrollLeft($table, td) {
|
|
56
|
-
const { tableBody } = $table.$refs;
|
|
57
|
-
const { visibleColumn } = $table;
|
|
58
|
-
const { scrollLeft: bodyLeft, clientWidth: bodyWidth } = tableBody.$el;
|
|
59
|
-
let leftWidth = 0;
|
|
60
|
-
let rightWidth = 0;
|
|
61
|
-
visibleColumn.forEach((column) => {
|
|
62
|
-
if (column.fixed === "left") {
|
|
63
|
-
leftWidth += column.renderWidth;
|
|
64
|
-
} else if (column.fixed === "right") {
|
|
65
|
-
rightWidth += column.renderWidth;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const tdLeft = td._accumulateRenderWidth || td.offsetLeft + (td.offsetParent ? td.offsetParent.offsetLeft : 0);
|
|
69
|
-
const tdWidth = td._renderWidth || td.clientWidth;
|
|
70
|
-
let scrollLeft;
|
|
71
|
-
if (tdLeft < bodyLeft + leftWidth) {
|
|
72
|
-
scrollLeft = tdLeft - leftWidth;
|
|
73
|
-
} else if (tdLeft + tdWidth > bodyLeft + bodyWidth - rightWidth) {
|
|
74
|
-
scrollLeft = tdLeft + tdWidth - bodyWidth + rightWidth;
|
|
75
|
-
} else {
|
|
76
|
-
scrollLeft = bodyLeft;
|
|
77
|
-
}
|
|
78
|
-
return scrollLeft;
|
|
79
|
-
}
|
|
80
|
-
function setBodyLeft(body, td, $table, column, move) {
|
|
81
|
-
const { isLeftArrow, isRightArrow, from } = move || {};
|
|
82
|
-
const bodyScollLeft = computeScrollLeft($table, td);
|
|
83
|
-
$table.scrollTo(bodyScollLeft);
|
|
84
|
-
$table.lastScrollLeft = bodyScollLeft;
|
|
85
|
-
if (from) {
|
|
86
|
-
const direction = isLeftArrow ? "left" : isRightArrow ? "right" : null;
|
|
87
|
-
const fixedDom = $table.elemStore[`${direction}-body-list`];
|
|
88
|
-
const mainBody = $table.elemStore["main-body-wrapper"];
|
|
89
|
-
const { left, right } = td.getBoundingClientRect();
|
|
90
|
-
let offset = 0;
|
|
91
|
-
if (isLeftArrow && fixedDom) {
|
|
92
|
-
const div = fixedDom.querySelector("td.fixed__column");
|
|
93
|
-
const division = div ? div.getBoundingClientRect().left : fixedDom.getBoundingClientRect().right;
|
|
94
|
-
division > left && (offset = left - division);
|
|
95
|
-
}
|
|
96
|
-
if (isRightArrow && fixedDom) {
|
|
97
|
-
const div = fixedDom.querySelector("td:not(.fixed__column)") || fixedDom;
|
|
98
|
-
const division = div.getBoundingClientRect().left;
|
|
99
|
-
division < right && (offset = right - division);
|
|
100
|
-
}
|
|
101
|
-
mainBody.scrollLeft = getFixedLeft($table, from, column, body, offset);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const colToVisible = ($table, column, move) => {
|
|
105
60
|
$table.$nextTick(() => {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
61
|
+
const { $refs, scrollXLoad, visibleColumn, columnStore } = $table;
|
|
62
|
+
const { tableBody: bodyVm } = $refs;
|
|
63
|
+
const { $el } = bodyVm;
|
|
64
|
+
const { leftList, rightList } = columnStore;
|
|
65
|
+
const tdEl = $el.querySelector(`.${column.id}`);
|
|
66
|
+
const visibleStart = leftList.reduce((p, c) => p += c.renderWidth, 0);
|
|
67
|
+
const visibleEnd = $el.clientWidth - rightList.reduce((p, c) => p += c.renderWidth, 0);
|
|
68
|
+
const scrollLeft = $el.scrollLeft;
|
|
69
|
+
const colWidth = column.renderWidth;
|
|
70
|
+
let position;
|
|
71
|
+
let flag = false;
|
|
72
|
+
if (scrollXLoad) {
|
|
73
|
+
flag = true;
|
|
74
|
+
position = -scrollLeft;
|
|
75
|
+
for (const col of visibleColumn) {
|
|
76
|
+
if (col === column)
|
|
115
77
|
break;
|
|
116
|
-
|
|
117
|
-
|
|
78
|
+
position += col.renderWidth;
|
|
79
|
+
}
|
|
80
|
+
} else if (tdEl) {
|
|
81
|
+
flag = true;
|
|
82
|
+
position = tdEl.offsetLeft - scrollLeft;
|
|
83
|
+
}
|
|
84
|
+
if (flag) {
|
|
85
|
+
if (position < visibleStart) {
|
|
86
|
+
$el.scrollLeft = scrollLeft - (visibleStart - position);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
position += colWidth;
|
|
90
|
+
if (position > visibleEnd) {
|
|
91
|
+
$el.scrollLeft = scrollLeft + (position - visibleEnd);
|
|
118
92
|
}
|
|
119
|
-
gridbodyEl.scrollLeft = computeScrollLeft($table, {
|
|
120
|
-
_accumulateRenderWidth: scrollLeft,
|
|
121
|
-
_renderWidth: column.renderWidth
|
|
122
|
-
});
|
|
123
93
|
}
|
|
124
94
|
});
|
|
125
95
|
};
|
|
@@ -130,6 +100,9 @@ const hasDataTag = (el, value) => {
|
|
|
130
100
|
if (el.host) {
|
|
131
101
|
el = el.host;
|
|
132
102
|
}
|
|
103
|
+
if (!(el == null ? void 0 : el.getAttribute)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
133
106
|
return (" " + el.getAttribute("data-tag") + " ").includes(" " + value + " ");
|
|
134
107
|
};
|
|
135
108
|
const getEventTargetNode = (event, container, queryCls) => {
|