@opentiny/vue-renderless 3.26.0 → 3.28.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/autocomplete/index.js +7 -2
- package/autocomplete/vue.js +1 -1
- package/base-select/index.js +189 -86
- package/base-select/vue.js +82 -20
- package/calendar-view/index.js +6 -3
- package/calendar-view/vue.js +9 -5
- package/color-picker/vue.js +4 -0
- package/color-select-panel/alpha-select/index.js +17 -12
- package/color-select-panel/alpha-select/vue.js +4 -2
- package/color-select-panel/hue-select/index.js +42 -11
- package/color-select-panel/hue-select/vue.js +32 -6
- package/color-select-panel/index.js +223 -39
- package/color-select-panel/linear-gradient/index.js +131 -0
- package/color-select-panel/linear-gradient/vue.js +21 -0
- package/color-select-panel/sv-select/index.js +12 -9
- package/color-select-panel/sv-select/vue.js +4 -2
- package/color-select-panel/utils/color-map.js +154 -0
- package/color-select-panel/utils/color-points.js +86 -0
- package/color-select-panel/utils/color.js +1 -1
- package/color-select-panel/utils/context.js +14 -0
- package/color-select-panel/vue.js +3 -3
- package/common/deps/infinite-scroll.js +1 -1
- package/dialog-box/index.js +3 -3
- package/dialog-box/vue.js +1 -0
- package/drawer/index.js +20 -0
- package/drawer/vue.js +9 -1
- package/dropdown/index.js +10 -4
- package/file-upload/index.js +18 -4
- package/form-item/index.js +28 -16
- package/form-item/vue.js +50 -11
- package/grid/static/array/eachTree.js +1 -0
- package/grid/utils/common.js +10 -3
- package/grid-select/index.js +418 -32
- package/grid-select/vue.js +103 -9
- package/guide/index.js +3 -3
- package/guide/vue.js +11 -1
- package/input/vue.js +2 -1
- package/package.json +3 -3
- package/picker/index.js +30 -13
- package/picker/vue.js +10 -0
- package/popover/index.js +1 -1
- package/rich-text/index.js +42 -0
- package/select/index.js +32 -15
- package/select/vue.js +31 -10
- package/select-dropdown/vue.js +8 -3
- package/select-wrapper/vue.js +134 -0
- package/slider/vue.js +7 -0
- package/space/index.js +30 -0
- package/space/vue.js +39 -0
- package/switch/vue.js +19 -0
- package/tab-nav/index.js +2 -2
- package/tabs-mf/index.js +9 -1
- package/tabs-mf/vue-nav.js +70 -22
- package/tabs-mf/vue-slider-bar.js +24 -0
- package/tabs-mf/vue.js +23 -5
- package/tag/index.js +1 -1
- package/transfer-panel/index.js +2 -1
- package/tree-menu/index.js +4 -0
- package/tree-menu/vue.js +3 -0
- package/tree-select/index.js +13 -4
- package/tree-select/vue.js +19 -3
- package/types/autocomplete.type.d.ts +2 -1
- package/types/color-select-panel.type.d.ts +197 -1
- package/types/date-picker.type.d.ts +38 -2
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-dd403065.d.ts → form.type-a54e1c06.d.ts} +2 -2
- package/types/form.type.d.ts +1 -1
- package/types/input.type.d.ts +1 -1
- package/types/modal.type.d.ts +4 -0
- package/types/numeric.type.d.ts +1 -1
- package/types/picker.type.d.ts +42 -2
- package/types/popeditor.type.d.ts +76 -4
- package/types/popover.type.d.ts +1 -1
- package/types/space.type.d.ts +31 -0
- package/types/switch.type.d.ts +2 -1
- package/types/transfer.type.d.ts +3 -3
- package/types/tree-menu.type.d.ts +38 -2
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-36a8374a.d.ts → upload-list.type-d5ff675d.d.ts} +1 -1
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
package/grid-select/index.js
CHANGED
|
@@ -2,9 +2,74 @@ import {
|
|
|
2
2
|
__spreadProps,
|
|
3
3
|
__spreadValues
|
|
4
4
|
} from "../chunk-G2ADBYYC.js";
|
|
5
|
+
import { find } from "@opentiny/utils";
|
|
6
|
+
const updateBaseSelect = ({ vm, props, data, label }) => {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
if (!vm.$refs.baseSelectRef) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
vm.$refs.baseSelectRef.updateSelectedData(data);
|
|
12
|
+
if (!props.multiple) {
|
|
13
|
+
const baseState = vm.$refs.baseSelectRef.state;
|
|
14
|
+
if (!baseState) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const currentLabel = label != null ? label : data && !Array.isArray(data) ? (_c = (_b = (_a = data.state) == null ? void 0 : _a.currentLabel) != null ? _b : data.currentLabel) != null ? _c : data[props.textField] : "";
|
|
18
|
+
baseState.selectedLabel = currentLabel || "";
|
|
19
|
+
if (props.filterable || props.searchable) {
|
|
20
|
+
baseState.query = currentLabel || "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const syncGridSelection = ({ props, vm, state, nextTick }) => () => {
|
|
25
|
+
if (!vm.$refs.gridRef) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
nextTick(() => {
|
|
29
|
+
try {
|
|
30
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
31
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || [];
|
|
32
|
+
if (props.multiple) {
|
|
33
|
+
if (Array.isArray(state.modelValue) && state.modelValue.length > 0) {
|
|
34
|
+
const rowsToSelect = fullData.filter((row) => state.modelValue.indexOf(row[props.valueField]) !== -1);
|
|
35
|
+
vm.$refs.gridRef.clearSelection();
|
|
36
|
+
if (rowsToSelect.length > 0) {
|
|
37
|
+
vm.$refs.gridRef.setSelection(rowsToSelect, true);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
vm.$refs.gridRef.clearSelection();
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
if (state.modelValue) {
|
|
44
|
+
const rowToSelect = fullData.find((row) => row[props.valueField] === state.modelValue);
|
|
45
|
+
vm.$refs.gridRef.clearRadioRow();
|
|
46
|
+
if (rowToSelect) {
|
|
47
|
+
vm.$refs.gridRef.setRadioRow(rowToSelect);
|
|
48
|
+
state.currentKey = rowToSelect[props.valueField];
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
vm.$refs.gridRef.clearRadioRow();
|
|
52
|
+
state.currentKey = "";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const handleVisibleChange = ({ api, state, props }) => (visible) => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (visible && state.isMounted) {
|
|
62
|
+
api.syncGridSelection();
|
|
63
|
+
if (props.remote && ((_a = props.remoteConfig) == null ? void 0 : _a.autoSearch) && state.firstAutoSearch !== false) {
|
|
64
|
+
api.filter("");
|
|
65
|
+
state.firstAutoSearch = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
5
69
|
const buildSelectConfig = ({ props, state }) => () => {
|
|
6
|
-
const checkRowKeys = state.gridCheckedData;
|
|
7
70
|
const selectConfig = props.selectConfig;
|
|
71
|
+
const rawCheckRowKeys = state.gridCheckedData;
|
|
72
|
+
const checkRowKeys = Array.isArray(rawCheckRowKeys) ? rawCheckRowKeys : rawCheckRowKeys && Array.isArray(rawCheckRowKeys.value) ? rawCheckRowKeys.value : [];
|
|
8
73
|
return Object.assign({}, selectConfig, { checkRowKeys });
|
|
9
74
|
};
|
|
10
75
|
const buildRadioConfig = ({ props, state }) => () => {
|
|
@@ -13,29 +78,32 @@ const buildRadioConfig = ({ props, state }) => () => {
|
|
|
13
78
|
const radioConfig = props.radioConfig;
|
|
14
79
|
return Object.assign({}, radioConfig, { checkRowKey, highlight });
|
|
15
80
|
};
|
|
16
|
-
const filter = ({ props, state, vm }) => (value) => {
|
|
81
|
+
const filter = ({ props, state, vm }) => async (value) => {
|
|
17
82
|
const { multiple, valueField, filterMethod, remote, remoteMethod } = props;
|
|
18
83
|
if ((props.filterable || props.searchable) && typeof filterMethod === "function") {
|
|
19
84
|
const table = vm.$refs.gridRef.$refs.tinyTable;
|
|
20
85
|
const fullData = table.getTableData().fullData;
|
|
21
86
|
vm.$refs.gridRef.scrollTo(null, 0);
|
|
22
|
-
table.
|
|
87
|
+
await table.loadData(filterMethod(value, fullData) || []);
|
|
23
88
|
vm.$refs.gridRef.handleTableData(!value);
|
|
24
89
|
state.previousQuery = value;
|
|
25
90
|
} else if (remote && typeof remoteMethod === "function") {
|
|
26
91
|
state.previousQuery = value;
|
|
27
92
|
remoteMethod(value, props.extraQueryParams).then((data) => {
|
|
28
93
|
if (multiple) {
|
|
29
|
-
const selectedIds = state.selected.map((sel) => sel[valueField]);
|
|
94
|
+
const selectedIds = Array.isArray(state.selected) ? state.selected.map((sel) => sel[valueField]) : [];
|
|
30
95
|
vm.$refs.gridRef.clearSelection();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
true
|
|
34
|
-
|
|
35
|
-
state.remoteData = data
|
|
96
|
+
const selectedRows = data.filter((row) => selectedIds.indexOf(row[valueField]) !== -1);
|
|
97
|
+
if (selectedRows.length > 0) {
|
|
98
|
+
vm.$refs.gridRef.setSelection(selectedRows, true);
|
|
99
|
+
}
|
|
100
|
+
state.remoteData = data;
|
|
36
101
|
} else {
|
|
37
102
|
vm.$refs.gridRef.clearRadioRow();
|
|
38
|
-
|
|
103
|
+
const selectedRow = find(data, (item) => props.modelValue === item[props.valueField]);
|
|
104
|
+
if (selectedRow) {
|
|
105
|
+
vm.$refs.gridRef.setRadioRow(selectedRow);
|
|
106
|
+
}
|
|
39
107
|
state.remoteData = data;
|
|
40
108
|
}
|
|
41
109
|
vm.$refs.gridRef.$refs.tinyTable.lastScrollTop = 0;
|
|
@@ -44,39 +112,357 @@ const filter = ({ props, state, vm }) => (value) => {
|
|
|
44
112
|
});
|
|
45
113
|
}
|
|
46
114
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
vm.$refs.baseSelectRef.hidePanel();
|
|
57
|
-
emit("update:modelValue", row);
|
|
58
|
-
emit("change", row);
|
|
115
|
+
const getcheckedData = ({ props, state }) => () => {
|
|
116
|
+
const checkedKey = [];
|
|
117
|
+
if (!Array.isArray(state.selected)) {
|
|
118
|
+
return props.modelValue ? [props.modelValue] : state.selected && state.selected[props.valueField] ? [state.selected[props.valueField]] : [];
|
|
119
|
+
} else {
|
|
120
|
+
state.selected.length > 0 && state.selected.forEach((item) => {
|
|
121
|
+
checkedKey.push(item[props.valueField]);
|
|
122
|
+
});
|
|
123
|
+
return checkedKey;
|
|
59
124
|
}
|
|
60
125
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
126
|
+
const getPluginOption = ({ api, props, state }) => (value) => {
|
|
127
|
+
var _a;
|
|
128
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
129
|
+
const { textField, valueField } = props;
|
|
130
|
+
const sourceData = isRemote ? state.remoteData : Array.isArray(state.gridData) ? state.gridData : ((_a = state.gridData) == null ? void 0 : _a.data) || [];
|
|
131
|
+
const selNode = find(sourceData, (item) => item[valueField] === value);
|
|
132
|
+
const items = [];
|
|
133
|
+
if (selNode) {
|
|
134
|
+
selNode.currentLabel = selNode[textField];
|
|
135
|
+
items.push(selNode);
|
|
136
|
+
}
|
|
137
|
+
return items;
|
|
138
|
+
};
|
|
139
|
+
const initQuery = ({ props, state, vm }) => (options = {}) => {
|
|
140
|
+
const { init } = options;
|
|
141
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
142
|
+
let selected;
|
|
143
|
+
if (isRemote && props.initQuery) {
|
|
144
|
+
let initData = props.initQuery(props.modelValue, props.extraQueryParams, !!init);
|
|
145
|
+
if (initData && initData.then) {
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
initData.then((selected2) => {
|
|
148
|
+
state.remoteData = selected2;
|
|
149
|
+
if (vm.$refs.gridRef) {
|
|
150
|
+
vm.$refs.gridRef.loadData(selected2);
|
|
151
|
+
}
|
|
152
|
+
resolve(selected2);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
selected = initData;
|
|
157
|
+
state.remoteData = selected;
|
|
158
|
+
if (vm.$refs.gridRef) {
|
|
159
|
+
vm.$refs.gridRef.loadData(selected);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return Promise.resolve(selected);
|
|
163
|
+
};
|
|
164
|
+
const mounted = ({ api, state, props, vm, nextTick }) => () => {
|
|
165
|
+
const initSelected = () => {
|
|
166
|
+
if (!state.modelValue || Array.isArray(state.modelValue) && state.modelValue.length === 0) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (props.multiple) {
|
|
170
|
+
let initialNodes = [];
|
|
171
|
+
if (Array.isArray(state.modelValue)) {
|
|
172
|
+
state.modelValue.forEach((value) => {
|
|
173
|
+
const option = api.getPluginOption(value);
|
|
174
|
+
initialNodes = initialNodes.concat(option);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const selected = initialNodes.map((node) => {
|
|
65
178
|
return __spreadProps(__spreadValues({}, node), {
|
|
66
179
|
currentLabel: node[props.textField],
|
|
67
|
-
value: node[props.valueField]
|
|
68
|
-
|
|
180
|
+
value: node[props.valueField]
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
updateBaseSelect({ vm, props, data: selected });
|
|
184
|
+
state.selected = selected;
|
|
185
|
+
if (vm.$refs.gridRef && selected.length > 0) {
|
|
186
|
+
vm.$refs.gridRef.clearSelection();
|
|
187
|
+
vm.$refs.gridRef.setSelection(selected, true);
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
const data = api.getPluginOption(state.modelValue)[0];
|
|
191
|
+
if (data) {
|
|
192
|
+
if (vm.$refs.baseSelectRef) {
|
|
193
|
+
updateBaseSelect({
|
|
194
|
+
vm,
|
|
195
|
+
props,
|
|
196
|
+
data: __spreadProps(__spreadValues({}, data), {
|
|
197
|
+
currentLabel: data[props.textField],
|
|
198
|
+
value: data[props.valueField],
|
|
199
|
+
state: {
|
|
200
|
+
currentLabel: data[props.textField]
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
state.selected = data;
|
|
206
|
+
state.currentKey = data[props.valueField];
|
|
207
|
+
if (vm.$refs.gridRef) {
|
|
208
|
+
vm.$refs.gridRef.clearRadioRow();
|
|
209
|
+
vm.$refs.gridRef.setRadioRow(data);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
nextTick(() => {
|
|
215
|
+
const initQueryPromise = api.initQuery({ init: true });
|
|
216
|
+
if (initQueryPromise && typeof initQueryPromise.then === "function") {
|
|
217
|
+
initQueryPromise.then(() => {
|
|
218
|
+
nextTick(() => {
|
|
219
|
+
initSelected();
|
|
220
|
+
});
|
|
221
|
+
}).catch(() => {
|
|
222
|
+
nextTick(() => {
|
|
223
|
+
initSelected();
|
|
69
224
|
});
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
initSelected();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
const watchValue = ({ api, props, vm, state }) => (newValue, oldValue) => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
if (props.multiple) {
|
|
234
|
+
let initialNodes = [];
|
|
235
|
+
if (Array.isArray(newValue) && newValue.length > 0) {
|
|
236
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
237
|
+
const sourceData = isRemote ? state.remoteData : Array.isArray(state.gridData) ? state.gridData : ((_a = state.gridData) == null ? void 0 : _a.data) || [];
|
|
238
|
+
if (vm.$refs.gridRef) {
|
|
239
|
+
try {
|
|
240
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
241
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || sourceData;
|
|
242
|
+
newValue.forEach((value) => {
|
|
243
|
+
const foundRow = fullData.find((item) => item[props.valueField] === value);
|
|
244
|
+
if (foundRow) {
|
|
245
|
+
initialNodes.push(foundRow);
|
|
246
|
+
} else {
|
|
247
|
+
const existing = state.selected.find((item) => item[props.valueField] === value);
|
|
248
|
+
if (existing) {
|
|
249
|
+
initialNodes.push(existing);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
} catch (e) {
|
|
254
|
+
newValue.forEach((value) => {
|
|
255
|
+
const foundRow = sourceData.find((item) => item[props.valueField] === value);
|
|
256
|
+
if (foundRow) {
|
|
257
|
+
initialNodes.push(foundRow);
|
|
258
|
+
} else {
|
|
259
|
+
const existing = state.selected.find((item) => item[props.valueField] === value);
|
|
260
|
+
if (existing) {
|
|
261
|
+
initialNodes.push(existing);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
newValue.forEach((value) => {
|
|
268
|
+
const foundRow = sourceData.find((item) => item[props.valueField] === value);
|
|
269
|
+
if (foundRow) {
|
|
270
|
+
initialNodes.push(foundRow);
|
|
271
|
+
} else {
|
|
272
|
+
const existing = state.selected.find((item) => item[props.valueField] === value);
|
|
273
|
+
if (existing) {
|
|
274
|
+
initialNodes.push(existing);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const selected = initialNodes.map((node) => {
|
|
281
|
+
return __spreadProps(__spreadValues({}, node), {
|
|
282
|
+
currentLabel: node[props.textField],
|
|
283
|
+
value: node[props.valueField]
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
if (vm.$refs.baseSelectRef) {
|
|
287
|
+
updateBaseSelect({ vm, props, data: selected });
|
|
288
|
+
}
|
|
289
|
+
state.selected = selected;
|
|
290
|
+
if (vm.$refs.gridRef) {
|
|
291
|
+
vm.$refs.gridRef.clearSelection();
|
|
292
|
+
if (selected.length > 0) {
|
|
293
|
+
try {
|
|
294
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
295
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || [];
|
|
296
|
+
const rowsToSelect = fullData.filter(
|
|
297
|
+
(row) => selected.some((sel) => sel[props.valueField] === row[props.valueField])
|
|
298
|
+
);
|
|
299
|
+
if (rowsToSelect.length > 0) {
|
|
300
|
+
vm.$refs.gridRef.setSelection(rowsToSelect, true);
|
|
301
|
+
}
|
|
302
|
+
} catch (e) {
|
|
303
|
+
vm.$refs.gridRef.setSelection(selected, true);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
if (!newValue) {
|
|
309
|
+
state.selected = {};
|
|
310
|
+
state.currentKey = "";
|
|
311
|
+
if (vm.$refs.gridRef) {
|
|
312
|
+
vm.$refs.gridRef.clearRadioRow();
|
|
313
|
+
}
|
|
314
|
+
if (vm.$refs.baseSelectRef) {
|
|
315
|
+
updateBaseSelect({ vm, props, data: null });
|
|
316
|
+
}
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const isRemote = (props.filterable || props.searchable) && props.remote && (typeof props.remoteMethod === "function" || typeof props.initQuery === "function");
|
|
320
|
+
const sourceData = isRemote ? state.remoteData : Array.isArray(state.gridData) ? state.gridData : ((_b = state.gridData) == null ? void 0 : _b.data) || [];
|
|
321
|
+
let data = null;
|
|
322
|
+
if (vm.$refs.gridRef) {
|
|
323
|
+
try {
|
|
324
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
325
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || sourceData;
|
|
326
|
+
data = fullData.find((item) => item[props.valueField] === newValue);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
data = sourceData.find((item) => item[props.valueField] === newValue);
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
data = sourceData.find((item) => item[props.valueField] === newValue);
|
|
332
|
+
}
|
|
333
|
+
if (!data && state.selected && typeof state.selected === "object" && !Array.isArray(state.selected) && state.selected[props.valueField] === newValue) {
|
|
334
|
+
data = state.selected;
|
|
335
|
+
}
|
|
336
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
337
|
+
updateBaseSelect({
|
|
338
|
+
vm,
|
|
339
|
+
props,
|
|
340
|
+
data: __spreadProps(__spreadValues({}, data), {
|
|
341
|
+
currentLabel: data[props.textField],
|
|
342
|
+
value: data[props.valueField],
|
|
343
|
+
state: {
|
|
344
|
+
currentLabel: data[props.textField]
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
});
|
|
348
|
+
state.selected = data;
|
|
349
|
+
state.currentKey = data[props.valueField];
|
|
350
|
+
if (vm.$refs.gridRef) {
|
|
351
|
+
vm.$refs.gridRef.clearRadioRow();
|
|
352
|
+
try {
|
|
353
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
354
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || [];
|
|
355
|
+
const rowToSelect = fullData.find((row) => row[props.valueField] === newValue);
|
|
356
|
+
if (rowToSelect) {
|
|
357
|
+
vm.$refs.gridRef.setRadioRow(rowToSelect);
|
|
358
|
+
} else {
|
|
359
|
+
vm.$refs.gridRef.setRadioRow(data);
|
|
360
|
+
}
|
|
361
|
+
} catch (e) {
|
|
362
|
+
vm.$refs.gridRef.setRadioRow(data);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
const radioChange = ({ props, vm, emit, state }) => ({ row }) => {
|
|
369
|
+
if (!props.multiple) {
|
|
370
|
+
updateBaseSelect({
|
|
371
|
+
vm,
|
|
372
|
+
props,
|
|
373
|
+
data: __spreadProps(__spreadValues({}, row), {
|
|
374
|
+
currentLabel: row[props.textField],
|
|
375
|
+
value: row[props.valueField],
|
|
376
|
+
state: {
|
|
377
|
+
currentLabel: row[props.textField]
|
|
378
|
+
}
|
|
70
379
|
})
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
|
|
380
|
+
});
|
|
381
|
+
state.selected = row;
|
|
382
|
+
state.currentKey = row[props.valueField];
|
|
383
|
+
state.modelValue = row[props.valueField];
|
|
384
|
+
vm.$refs.baseSelectRef.hidePanel();
|
|
385
|
+
emit("update:modelValue", row[props.valueField]);
|
|
386
|
+
emit("change", row[props.valueField]);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
const selectChange = ({ props, vm, emit, state, nextTick }) => ({ $table, selection, checked, row }) => {
|
|
390
|
+
if (props.multiple) {
|
|
391
|
+
const { textField, valueField } = props;
|
|
392
|
+
const remoteItem = (row2) => {
|
|
393
|
+
const removeItem = state.selected.find((item) => item[valueField] === row2[valueField]);
|
|
394
|
+
if (removeItem) {
|
|
395
|
+
const index = state.selected.indexOf(removeItem);
|
|
396
|
+
state.selected.splice(index, 1);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
if (row) {
|
|
400
|
+
if (checked) {
|
|
401
|
+
const exists = state.selected.find((item) => item[valueField] === row[valueField]);
|
|
402
|
+
if (!exists) {
|
|
403
|
+
state.selected.push(__spreadProps(__spreadValues({}, row), {
|
|
404
|
+
value: row[valueField],
|
|
405
|
+
currentLabel: row[textField]
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
remoteItem(row);
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
if (checked) {
|
|
413
|
+
selection.forEach((row2) => {
|
|
414
|
+
const exists = state.selected.find((item) => item[valueField] === row2[valueField]);
|
|
415
|
+
if (!exists) {
|
|
416
|
+
state.selected.push(__spreadProps(__spreadValues({}, row2), {
|
|
417
|
+
value: row2[valueField],
|
|
418
|
+
currentLabel: row2[textField]
|
|
419
|
+
}));
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
} else {
|
|
423
|
+
const tableData = ($table == null ? void 0 : $table.tableFullData) || [];
|
|
424
|
+
tableData.forEach((row2) => {
|
|
425
|
+
remoteItem(row2);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const selectedData = state.selected.map((node) => __spreadProps(__spreadValues({}, node), {
|
|
430
|
+
currentLabel: node[textField],
|
|
431
|
+
value: node[valueField],
|
|
432
|
+
isGrid: true
|
|
433
|
+
}));
|
|
434
|
+
updateBaseSelect({ vm, props, data: selectedData });
|
|
435
|
+
const currentValue = state.selected.map((item) => item[valueField]);
|
|
436
|
+
state.modelValue = currentValue;
|
|
437
|
+
emit("update:modelValue", currentValue);
|
|
438
|
+
emit("change", currentValue, state.selected);
|
|
439
|
+
if (vm.$refs.gridRef) {
|
|
440
|
+
nextTick(() => {
|
|
441
|
+
try {
|
|
442
|
+
const tableData = vm.$refs.gridRef.getTableData();
|
|
443
|
+
const fullData = (tableData == null ? void 0 : tableData.fullData) || [];
|
|
444
|
+
const rowsToSelect = fullData.filter((row2) => currentValue.indexOf(row2[valueField]) !== -1);
|
|
445
|
+
vm.$refs.gridRef.clearSelection();
|
|
446
|
+
if (rowsToSelect.length > 0) {
|
|
447
|
+
vm.$refs.gridRef.setSelection(rowsToSelect, true);
|
|
448
|
+
}
|
|
449
|
+
} catch (e) {
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
}
|
|
74
453
|
}
|
|
75
454
|
};
|
|
76
455
|
export {
|
|
77
456
|
buildRadioConfig,
|
|
78
457
|
buildSelectConfig,
|
|
79
458
|
filter,
|
|
459
|
+
getPluginOption,
|
|
460
|
+
getcheckedData,
|
|
461
|
+
handleVisibleChange,
|
|
462
|
+
initQuery,
|
|
463
|
+
mounted,
|
|
80
464
|
radioChange,
|
|
81
|
-
selectChange
|
|
465
|
+
selectChange,
|
|
466
|
+
syncGridSelection,
|
|
467
|
+
watchValue
|
|
82
468
|
};
|
package/grid-select/vue.js
CHANGED
|
@@ -1,27 +1,121 @@
|
|
|
1
1
|
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
buildRadioConfig,
|
|
4
|
+
buildSelectConfig,
|
|
5
|
+
filter,
|
|
6
|
+
getcheckedData,
|
|
7
|
+
getPluginOption,
|
|
8
|
+
handleVisibleChange,
|
|
9
|
+
initQuery,
|
|
10
|
+
mounted,
|
|
11
|
+
radioChange,
|
|
12
|
+
selectChange,
|
|
13
|
+
syncGridSelection,
|
|
14
|
+
watchValue
|
|
15
|
+
} from "./index";
|
|
16
|
+
const api = [
|
|
17
|
+
"state",
|
|
18
|
+
"buildRadioConfig",
|
|
19
|
+
"buildSelectConfig",
|
|
20
|
+
"filter",
|
|
21
|
+
"radioChange",
|
|
22
|
+
"selectChange",
|
|
23
|
+
"getcheckedData",
|
|
24
|
+
"getPluginOption",
|
|
25
|
+
"mounted",
|
|
26
|
+
"syncGridSelection",
|
|
27
|
+
"watchValue",
|
|
28
|
+
"handleVisibleChange"
|
|
29
|
+
];
|
|
30
|
+
const renderless = (props, { reactive, computed, watch, onMounted, nextTick }, { vm, emit }) => {
|
|
31
|
+
var _a;
|
|
5
32
|
const api2 = {};
|
|
33
|
+
const initGridData = () => {
|
|
34
|
+
if (props.gridOp) {
|
|
35
|
+
if (props.gridOp.data) {
|
|
36
|
+
return props.gridOp.data;
|
|
37
|
+
} else if (Array.isArray(props.gridOp)) {
|
|
38
|
+
return props.gridOp;
|
|
39
|
+
} else {
|
|
40
|
+
return props.gridOp;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { data: [], columns: [] };
|
|
44
|
+
};
|
|
6
45
|
const state = reactive({
|
|
7
46
|
value: props.modelValue,
|
|
8
|
-
gridData:
|
|
47
|
+
gridData: initGridData(),
|
|
9
48
|
remoteData: [],
|
|
10
|
-
selected: props.multiple ? [] : {}
|
|
49
|
+
selected: props.multiple ? [] : {},
|
|
50
|
+
currentKey: props.multiple ? "" : props.modelValue,
|
|
51
|
+
previousQuery: null,
|
|
52
|
+
modelValue: props.multiple ? Array.isArray(props.modelValue) ? [...props.modelValue] : [] : props.modelValue,
|
|
53
|
+
isMounted: false,
|
|
54
|
+
firstAutoSearch: ((_a = props.remoteConfig) == null ? void 0 : _a.autoSearch) || false
|
|
11
55
|
});
|
|
12
56
|
Object.assign(api2, {
|
|
13
57
|
state,
|
|
14
58
|
buildRadioConfig: buildRadioConfig({ props, state }),
|
|
15
59
|
buildSelectConfig: buildSelectConfig({ props, state }),
|
|
16
60
|
filter: filter({ props, state, vm }),
|
|
17
|
-
|
|
18
|
-
|
|
61
|
+
getcheckedData: getcheckedData({ props, state }),
|
|
62
|
+
getPluginOption: getPluginOption({ api: api2, props, state }),
|
|
63
|
+
initQuery: initQuery({ props, state, vm }),
|
|
64
|
+
mounted: mounted({ api: api2, state, props, vm, nextTick }),
|
|
65
|
+
radioChange: radioChange({ props, vm, emit, state }),
|
|
66
|
+
selectChange: selectChange({ props, vm, emit, state, nextTick }),
|
|
67
|
+
syncGridSelection: syncGridSelection({ props, vm, state, nextTick }),
|
|
68
|
+
handleVisibleChange: handleVisibleChange({ api: api2, state, props }),
|
|
69
|
+
watchValue: watchValue({ api: api2, props, vm, state })
|
|
19
70
|
});
|
|
71
|
+
state.gridCheckedData = computed(() => api2.getcheckedData());
|
|
20
72
|
watch(
|
|
21
|
-
() => props.gridOp
|
|
22
|
-
(
|
|
73
|
+
() => props.gridOp,
|
|
74
|
+
(gridOp) => {
|
|
75
|
+
if (gridOp) {
|
|
76
|
+
if (gridOp.data) {
|
|
77
|
+
state.gridData = gridOp.data;
|
|
78
|
+
} else if (Array.isArray(gridOp)) {
|
|
79
|
+
state.gridData = gridOp;
|
|
80
|
+
} else {
|
|
81
|
+
state.gridData = gridOp;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
23
85
|
{ immediate: true, deep: true }
|
|
24
86
|
);
|
|
87
|
+
watch(
|
|
88
|
+
() => props.modelValue,
|
|
89
|
+
() => {
|
|
90
|
+
if (props.multiple && Array.isArray(props.modelValue)) {
|
|
91
|
+
state.modelValue = [...props.modelValue];
|
|
92
|
+
} else {
|
|
93
|
+
state.modelValue = props.modelValue;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{ immediate: true, deep: true }
|
|
97
|
+
);
|
|
98
|
+
watch(
|
|
99
|
+
() => state.modelValue,
|
|
100
|
+
(newValue, oldValue) => {
|
|
101
|
+
if (state.isMounted) {
|
|
102
|
+
api2.watchValue(newValue, oldValue);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
watch(
|
|
107
|
+
() => props.extraQueryParams,
|
|
108
|
+
() => {
|
|
109
|
+
if (props.remote) {
|
|
110
|
+
api2.filter(state.previousQuery || "");
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{ deep: true, immediate: false }
|
|
114
|
+
);
|
|
115
|
+
onMounted(() => {
|
|
116
|
+
api2.mounted();
|
|
117
|
+
state.isMounted = true;
|
|
118
|
+
});
|
|
25
119
|
return api2;
|
|
26
120
|
};
|
|
27
121
|
export {
|
package/guide/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../chunk-G2ADBYYC.js";
|
|
2
2
|
import { xss } from "@opentiny/utils";
|
|
3
3
|
const createShepherd = ({ state, props, Shepherd, offset, designConfig }) => () => {
|
|
4
|
-
const tour = newTour(state, Shepherd, offset, designConfig);
|
|
4
|
+
const tour = newTour(state, Shepherd, offset, designConfig, props);
|
|
5
5
|
state.tour = tour;
|
|
6
6
|
const result = {};
|
|
7
7
|
const deepCopy = getItemCopy(props, tour, result);
|
|
@@ -68,10 +68,10 @@ const getItemCopy = (props, tour, result) => {
|
|
|
68
68
|
});
|
|
69
69
|
return result;
|
|
70
70
|
};
|
|
71
|
-
const newTour = (state, Shepherd, offset, designConfig) => {
|
|
71
|
+
const newTour = (state, Shepherd, offset, designConfig, props) => {
|
|
72
72
|
var _a, _b;
|
|
73
73
|
const tour = new Shepherd.Tour({
|
|
74
|
-
useModalOverlay: (_b = (_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.isUseModalOverlay
|
|
74
|
+
useModalOverlay: (_b = props.mask) != null ? _b : (_a = designConfig == null ? void 0 : designConfig.state) == null ? void 0 : _a.isUseModalOverlay,
|
|
75
75
|
defaultStepOptions: {
|
|
76
76
|
modalOverlayOpeningPadding: state.modalOverlayOpeningPadding,
|
|
77
77
|
modalOverlayOpeningRadius: state.modalOverlayOpeningRadius,
|
package/guide/vue.js
CHANGED
|
@@ -27,7 +27,17 @@ const renderless = (props, { reactive, onMounted, onBeforeUnmount, watch }, { de
|
|
|
27
27
|
mounted: mounted({ state, api: baseApi }),
|
|
28
28
|
beforeUnmount: beforeUnmount(state)
|
|
29
29
|
});
|
|
30
|
-
watch(
|
|
30
|
+
watch(
|
|
31
|
+
() => props.showStep,
|
|
32
|
+
(newVal) => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (newVal) {
|
|
35
|
+
api2.createShepherd();
|
|
36
|
+
} else {
|
|
37
|
+
(_a = state == null ? void 0 : state.tour) == null ? void 0 : _a.hide();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
);
|
|
31
41
|
onMounted(api2.mounted);
|
|
32
42
|
onBeforeUnmount(api2.beforeUnmount);
|
|
33
43
|
return api2;
|
package/input/vue.js
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
} from "./index";
|
|
42
42
|
import useStorageBox from "../tall-storage/vue-storage-box";
|
|
43
43
|
import { on, off } from "@opentiny/utils";
|
|
44
|
+
import { debounce } from "@opentiny/utils";
|
|
44
45
|
const api = [
|
|
45
46
|
"blur",
|
|
46
47
|
"showBox",
|
|
@@ -221,7 +222,7 @@ const mergeApi = ({
|
|
|
221
222
|
}),
|
|
222
223
|
handleFocus: handleFocus({ api: api2, emit, state }),
|
|
223
224
|
handleInput: handleInput({ api: api2, emit, nextTick, state }),
|
|
224
|
-
resizeTextarea: resizeTextarea({ api: api2, parent, vm, state, props }),
|
|
225
|
+
resizeTextarea: debounce(200, resizeTextarea({ api: api2, parent, vm, state, props })),
|
|
225
226
|
updateIconOffset: updateIconOffset(api2),
|
|
226
227
|
calcTextareaHeight: calcTextareaHeight({
|
|
227
228
|
api: api2,
|