@opentiny/vue-renderless 3.9.2 → 3.10.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/action-sheet/vue.js +25 -2
- package/anchor/index.js +3 -3
- package/anchor/vue.js +7 -1
- package/area/index.js +4 -4
- package/button/vue.js +4 -2
- package/button-group/index.js +8 -1
- package/button-group/vue.js +5 -10
- package/calendar/index.js +14 -14
- package/calendar-bar/index.js +3 -3
- package/carousel-item/index.js +1 -1
- package/cascader/vue.js +1 -1
- package/cascader-mobile/index.js +299 -0
- package/cascader-mobile/vue.js +102 -0
- package/cascader-panel/store.js +3 -1
- package/chart-boxplot/index.js +0 -1
- package/chart-core/deps/constants.js +20 -2
- package/chart-core/index.js +9 -1
- package/chart-core/modules/extend.js +14 -1
- package/chart-gauge/index.js +3 -1
- package/chart-graph/index.js +3 -1
- package/chart-map/index.js +11 -1
- package/chart-scatter/index.js +10 -2
- package/chart-waterfall/index.js +4 -1
- package/checkbox/index.js +16 -14
- package/checkbox/vue.js +14 -10
- package/checkbox-button/vue.js +7 -3
- package/column-list-item/vue.js +10 -1
- package/common/bigInt.js +4 -11
- package/common/date.js +2 -2
- package/common/deps/ResizeObserver.js +3 -1
- package/common/deps/date-util.js +9 -1
- package/common/deps/date.js +18 -5
- package/common/deps/fastdom/async.js +41 -0
- package/common/deps/fastdom/index.js +9 -0
- package/common/deps/fastdom/sandbox.js +53 -0
- package/common/deps/fastdom/singleton.js +80 -0
- package/common/deps/fullscreen/screenfull.js +16 -2
- package/common/deps/memorize.js +3 -3
- package/common/deps/popup-manager.js +0 -1
- package/common/deps/requestAnimationFrame.js +1 -1
- package/common/deps/throttle.js +2 -2
- package/common/deps/tree-model/node.js +23 -11
- package/common/deps/tree-model/tree-store.js +28 -7
- package/common/deps/vue-popper.js +14 -2
- package/common/deps/vue-popup.js +16 -23
- package/common/index.js +7 -35
- package/common/runtime.js +1 -1
- package/common/validate/rules/type.js +3 -1
- package/credit-card-form/vue.js +2 -2
- package/date-panel/index.js +35 -31
- package/date-panel/vue.js +12 -12
- package/date-picker/index.js +9 -5
- package/date-picker/vue.js +20 -8
- package/date-picker-mobile/index.js +3 -3
- package/date-range/index.js +91 -19
- package/date-range/vue.js +19 -11
- package/date-table/index.js +39 -6
- package/date-table/vue.js +2 -2
- package/dept/index.js +1 -1
- package/detail-page/vue.js +9 -1
- package/dialog-box/index.js +11 -2
- package/dialog-box/vue.js +30 -6
- package/dialog-select/index.js +27 -5
- package/dialog-select/vue.js +11 -4
- package/drop-roles/index.js +3 -1
- package/dropdown/index.js +28 -7
- package/dropdown/vue.js +12 -7
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +3 -3
- package/dropdown-item/vue.js +12 -10
- package/dropdown-menu/index.js +13 -14
- package/dropdown-menu/vue.js +8 -7
- package/espace/vue.js +9 -1
- package/fall-menu/vue.js +12 -1
- package/file-upload/index.js +137 -89
- package/file-upload/vue.js +24 -14
- package/filter/index.js +1 -1
- package/filter/vue.js +1 -3
- package/floating-button/index.js +73 -0
- package/floating-button/vue.js +35 -0
- package/form/index.js +13 -4
- package/form/vue.js +7 -2
- package/form-item/index.js +4 -1
- package/form-item/vue.js +6 -3
- package/fullscreen/vue.js +24 -3
- package/grid/plugins/exportExcel.js +54 -8
- package/grid/static/base/helperGetHGSKeys.js +1 -4
- package/grid/utils/common.js +15 -11
- package/grid/utils/dom.js +5 -1
- package/guide/index.js +2 -3
- package/hrapprover/index.js +3 -1
- package/index-bar/vue.js +8 -1
- package/input/index.js +1 -11
- package/input/vue.js +6 -12
- package/ip-address/index.js +66 -33
- package/ip-address/vue.js +8 -1
- package/link-menu/vue.js +22 -2
- package/locales/index.js +4 -2
- package/logon-user/index.js +3 -1
- package/logout/index.js +6 -2
- package/milestone/vue.js +1 -1
- package/mini-picker/index.js +12 -10
- package/mini-picker/vue.js +10 -10
- package/modal/index.js +5 -3
- package/modal/vue.js +4 -2
- package/month-range/index.js +18 -18
- package/month-range/vue.js +16 -4
- package/month-table/index.js +7 -3
- package/multi-select/vue.js +1 -9
- package/nav-menu/index.js +33 -4
- package/nav-menu/vue.js +9 -1
- package/notify/vue.js +12 -1
- package/numeric/vue.js +6 -2
- package/option/index.js +10 -2
- package/option/vue.js +20 -9
- package/option-group/index.js +3 -1
- package/package.json +2 -1
- package/picker/index.js +88 -17
- package/picker/vue.js +42 -17
- package/picker-column/index.js +6 -6
- package/picker-column/vue.js +5 -5
- package/popconfirm/vue.js +3 -1
- package/popeditor/index.js +55 -13
- package/popeditor/vue.js +23 -7
- package/popover/vue.js +1 -2
- package/popup/vue.js +15 -2
- package/progress/index.js +9 -7
- package/progress/vue.js +12 -4
- package/pull-refresh/vue.js +10 -1
- package/query-builder/index.js +9 -0
- package/query-builder/vue.js +18 -0
- package/radio/vue.js +3 -1
- package/radio-button/vue.js +1 -1
- package/rate/index.js +8 -2
- package/rate/vue.js +27 -4
- package/recycle-scroller/index.js +0 -1
- package/scrollbar/vue-bar.js +18 -2
- package/search/index.js +12 -5
- package/search/vue.js +7 -5
- package/select/index.js +596 -304
- package/select/vue.js +167 -101
- package/select-dropdown/vue.js +8 -6
- package/select-mobile/index.js +26 -13
- package/select-mobile/vue.js +14 -5
- package/select-view/index.js +5 -21
- package/select-view/vue.js +0 -3
- package/selected-box/index.js +3 -1
- package/slider/index.js +5 -5
- package/slider/vue.js +16 -0
- package/slider-button/index.js +41 -0
- package/slider-button/vue.js +36 -0
- package/slider-button-group/slide-button.js +142 -0
- package/slider-button-group/vue.js +52 -0
- package/steps/slide-bar.js +0 -1
- package/switch/index.js +1 -1
- package/switch/vue.js +1 -1
- package/tab-bar/index.js +8 -6
- package/tab-nav/index.js +19 -13
- package/tab-nav/vue.js +10 -9
- package/tabs/index.js +21 -17
- package/tabs/vue.js +1 -4
- package/tag/vue.js +2 -1
- package/tag-group/index.js +23 -10
- package/tag-group/vue.js +5 -4
- package/time/index.js +8 -8
- package/time/vue.js +9 -9
- package/time-line/index.js +24 -2
- package/time-line/vue.js +30 -4
- package/time-panel/index.js +2 -2
- package/time-panel/vue.js +2 -2
- package/time-range/index.js +24 -21
- package/time-range/vue.js +26 -16
- package/time-spinner/index.js +32 -21
- package/time-spinner/vue.js +37 -12
- package/timeline-item/index.js +77 -0
- package/timeline-item/vue.js +44 -0
- package/toggle-menu/vue.js +0 -1
- package/tooltip/index.js +11 -12
- package/tooltip/vue.js +11 -1
- package/top-box/vue.js +13 -1
- package/tree/index.js +228 -15
- package/tree/vue.js +119 -15
- package/tree-menu/index.js +35 -0
- package/tree-menu/vue.js +27 -5
- package/tree-node/index.js +75 -10
- package/tree-node/vue.js +45 -23
- package/upload/index.js +90 -49
- package/upload/vue.js +22 -10
- package/upload-dragger/index.js +4 -3
- package/upload-list/index.js +67 -16
- package/upload-list/vue.js +26 -9
- package/user/index.js +7 -4
- package/user-link/index.js +2 -1
- package/wizard/index.js +4 -1
- package/wizard/vue.js +19 -2
- package/year-range/index.js +1 -1
- package/year-range/vue.js +3 -3
- package/year-table/index.js +2 -2
package/tree/vue.js
CHANGED
|
@@ -46,7 +46,27 @@ import {
|
|
|
46
46
|
clearCurrentStore,
|
|
47
47
|
initIsCurrent,
|
|
48
48
|
beforeUnmount,
|
|
49
|
-
wrapMounted
|
|
49
|
+
wrapMounted,
|
|
50
|
+
switchToggle,
|
|
51
|
+
initTreeStore,
|
|
52
|
+
getSameDataIndex,
|
|
53
|
+
loopGetTreeData,
|
|
54
|
+
cancelDelete,
|
|
55
|
+
deleteAction,
|
|
56
|
+
deleteConfirm,
|
|
57
|
+
openEdit,
|
|
58
|
+
saveNode,
|
|
59
|
+
addNode,
|
|
60
|
+
editNode,
|
|
61
|
+
closeEdit,
|
|
62
|
+
saveEdit,
|
|
63
|
+
setAddDisabledKeys,
|
|
64
|
+
setEditDisabledKeys,
|
|
65
|
+
setDeleteDisabledKeys,
|
|
66
|
+
initPlainNodeStore,
|
|
67
|
+
handleCheckPlainNode,
|
|
68
|
+
handleClickPlainNode,
|
|
69
|
+
setCheckedByNodeKey
|
|
50
70
|
} from "./index";
|
|
51
71
|
const api = [
|
|
52
72
|
"state",
|
|
@@ -76,15 +96,37 @@ const api = [
|
|
|
76
96
|
"handleKeydown",
|
|
77
97
|
"setCurrentRadio",
|
|
78
98
|
"expandAllNodes",
|
|
79
|
-
"clearCurrentStore"
|
|
99
|
+
"clearCurrentStore",
|
|
100
|
+
"switchToggle",
|
|
101
|
+
"initTreeStore",
|
|
102
|
+
"getSameDataIndex",
|
|
103
|
+
"loopGetTreeData",
|
|
104
|
+
"cancelDelete",
|
|
105
|
+
"deleteAction",
|
|
106
|
+
"deleteConfirm",
|
|
107
|
+
"openEdit",
|
|
108
|
+
"saveNode",
|
|
109
|
+
"addNode",
|
|
110
|
+
"editNode",
|
|
111
|
+
"closeEdit",
|
|
112
|
+
"saveEdit",
|
|
113
|
+
"setAddDisabledKeys",
|
|
114
|
+
"setEditDisabledKeys",
|
|
115
|
+
"setDeleteDisabledKeys",
|
|
116
|
+
"handleCheckPlainNode",
|
|
117
|
+
"handleClickPlainNode",
|
|
118
|
+
"setCheckedByNodeKey"
|
|
80
119
|
];
|
|
81
120
|
const initState = ({ reactive, emitter, props, computed, api: api2 }) => {
|
|
82
121
|
const state = reactive({
|
|
122
|
+
loaded: false,
|
|
123
|
+
checkEasily: false,
|
|
83
124
|
root: null,
|
|
84
125
|
store: null,
|
|
85
126
|
treeItems: null,
|
|
86
127
|
currentNode: null,
|
|
87
128
|
checkboxItems: [],
|
|
129
|
+
isEmpty: false,
|
|
88
130
|
emitter: emitter(),
|
|
89
131
|
expandIcon: props.expandIcon,
|
|
90
132
|
shrinkIcon: props.shrinkIcon,
|
|
@@ -97,9 +139,28 @@ const initState = ({ reactive, emitter, props, computed, api: api2 }) => {
|
|
|
97
139
|
set: (data) => api2.setChildren(data)
|
|
98
140
|
}),
|
|
99
141
|
treeItemArray: computed(() => api2.computedTreeItemArray(props, state)),
|
|
100
|
-
isEmpty: computed(() => api2.computedIsEmpty(props, state)),
|
|
101
142
|
showEmptyText: computed(() => api2.computedShowEmptyText(props, state)),
|
|
102
|
-
currentStore: { flag: false, node: null }
|
|
143
|
+
currentStore: { flag: false, node: null },
|
|
144
|
+
action: {
|
|
145
|
+
deleteDisabled: [],
|
|
146
|
+
editDisabled: [],
|
|
147
|
+
addDisabled: [],
|
|
148
|
+
show: false,
|
|
149
|
+
node: null,
|
|
150
|
+
data: [],
|
|
151
|
+
label: "",
|
|
152
|
+
type: "",
|
|
153
|
+
isLeaf: false,
|
|
154
|
+
isSaveChildNode: false,
|
|
155
|
+
referenceElm: null,
|
|
156
|
+
popoverVisible: false
|
|
157
|
+
},
|
|
158
|
+
treeEdit: {
|
|
159
|
+
addData: [],
|
|
160
|
+
deleteData: [],
|
|
161
|
+
editData: []
|
|
162
|
+
},
|
|
163
|
+
plainNodeStore: {}
|
|
103
164
|
});
|
|
104
165
|
return state;
|
|
105
166
|
};
|
|
@@ -112,8 +173,8 @@ const initApi = ({ state, dispatch, broadcast, props, vm, constants, t, emit, re
|
|
|
112
173
|
computedTreeItemArray: computedTreeItemArray(),
|
|
113
174
|
computedIsEmpty: computedIsEmpty(),
|
|
114
175
|
watchDefaultCheckedKeys: watchDefaultCheckedKeys(state),
|
|
115
|
-
watchData: watchData(state),
|
|
116
|
-
watchCheckboxItems: watchCheckboxItems(
|
|
176
|
+
watchData: watchData({ state }),
|
|
177
|
+
watchCheckboxItems: watchCheckboxItems(),
|
|
117
178
|
watchCheckStrictly: watchCheckStrictly(state),
|
|
118
179
|
updated: updated({ vm, state }),
|
|
119
180
|
filter: filter({ props, state }),
|
|
@@ -141,36 +202,79 @@ const initApi = ({ state, dispatch, broadcast, props, vm, constants, t, emit, re
|
|
|
141
202
|
setCurrentRadio: setCurrentRadio({ props, state }),
|
|
142
203
|
expandAllNodes: expandAllNodes({ state }),
|
|
143
204
|
dragStart: dragStart({ props, state, emit }),
|
|
144
|
-
dragOver: dragOver({ props, state, emit,
|
|
205
|
+
dragOver: dragOver({ props, state, emit, vm }),
|
|
145
206
|
dragEnd: dragEnd({ state, emit }),
|
|
146
207
|
clearCurrentStore: clearCurrentStore(state),
|
|
147
|
-
initIsCurrent: debounce(20, initIsCurrent({ props, state }))
|
|
208
|
+
initIsCurrent: debounce(20, initIsCurrent({ props, state })),
|
|
209
|
+
setCheckedByNodeKey: setCheckedByNodeKey({ props, state })
|
|
148
210
|
});
|
|
149
|
-
const initWatcher = ({ watch, props, api: api2 }) => {
|
|
211
|
+
const initWatcher = ({ watch, props, api: api2, state }) => {
|
|
150
212
|
watch(() => props.defaultCheckedKeys, api2.watchDefaultCheckedKeys);
|
|
151
213
|
watch(() => props.defaultExpandedKeys, api2.watchDefaultExpandedKeys);
|
|
152
214
|
watch(() => props.defaultExpandedKeysHighlight, api2.initIsCurrent);
|
|
153
|
-
watch(() => props.data, api2.watchData);
|
|
215
|
+
watch(() => props.data, api2.watchData, { deep: true });
|
|
154
216
|
watch(() => props.checkboxItems, api2.watchCheckboxItems);
|
|
155
217
|
watch(() => props.checkStrictly, api2.watchCheckStrictly);
|
|
156
218
|
watch(() => props.defaultCheckedKeys, api2.setCurrentRadio, { immediate: true });
|
|
219
|
+
watch(
|
|
220
|
+
() => props.deleteDisabledKeys,
|
|
221
|
+
(value) => state.action.deleteDisabled = value || [],
|
|
222
|
+
{ immediate: true }
|
|
223
|
+
);
|
|
224
|
+
watch(
|
|
225
|
+
() => props.editDisabledKeys,
|
|
226
|
+
(value) => state.action.editDisabled = value || [],
|
|
227
|
+
{ immediate: true }
|
|
228
|
+
);
|
|
229
|
+
watch(
|
|
230
|
+
() => props.addDisabledKeys,
|
|
231
|
+
(value) => state.action.addDisabled = value || [],
|
|
232
|
+
{ immediate: true }
|
|
233
|
+
);
|
|
234
|
+
watch(
|
|
235
|
+
() => state.root,
|
|
236
|
+
() => {
|
|
237
|
+
state.isEmpty = api2.computedIsEmpty(props, state);
|
|
238
|
+
api2.initPlainNodeStore();
|
|
239
|
+
},
|
|
240
|
+
{ deep: true }
|
|
241
|
+
);
|
|
157
242
|
};
|
|
158
|
-
const renderless = (props, { computed, onMounted, onUpdated, reactive, watch, provide, onBeforeUnmount }, { vm, t,
|
|
243
|
+
const renderless = (props, { computed, onMounted, onUpdated, reactive, watch, provide, onBeforeUnmount }, { vm, t, emit, constants, broadcast, dispatch, service, emitter, nextTick }) => {
|
|
159
244
|
const api2 = {};
|
|
160
245
|
const state = initState({ reactive, emitter, props, computed, api: api2 });
|
|
161
246
|
provide("parentEmitter", state.emitter);
|
|
162
|
-
Object.assign(api2, initApi({ state, dispatch, broadcast, props, vm, constants, t, emit
|
|
247
|
+
Object.assign(api2, initApi({ state, dispatch, broadcast, props, vm, constants, t, emit }), {
|
|
163
248
|
closeMenu: closeMenu(state),
|
|
164
249
|
mounted: mounted({ api: api2, vm }),
|
|
165
250
|
created: created({ api: api2, props, state }),
|
|
166
251
|
getCurrentKey: getCurrentKey({ api: api2, props }),
|
|
167
252
|
handleNodeExpand: handleNodeExpand(emit),
|
|
168
|
-
beforeUnmount: beforeUnmount({ api: api2, vm }),
|
|
253
|
+
beforeUnmount: beforeUnmount({ api: api2, vm, state }),
|
|
169
254
|
wrapMounted: wrapMounted({ api: api2, props, service }),
|
|
170
|
-
|
|
255
|
+
initTreeStore: initTreeStore({ api: api2, props, state, emit }),
|
|
256
|
+
deleteAction: deleteAction({ state, api: api2, emit }),
|
|
257
|
+
deleteConfirm: deleteConfirm({ state }),
|
|
258
|
+
getSameDataIndex,
|
|
259
|
+
loopGetTreeData,
|
|
260
|
+
cancelDelete: cancelDelete({ state }),
|
|
261
|
+
openEdit: openEdit({ props, state, api: api2, emit }),
|
|
262
|
+
saveNode: saveNode({ state, emit, api: api2 }),
|
|
263
|
+
addNode: addNode({ api: api2 }),
|
|
264
|
+
editNode: editNode({ state }),
|
|
265
|
+
closeEdit: closeEdit({ props, state, api: api2, emit }),
|
|
266
|
+
saveEdit: saveEdit({ props, state, emit }),
|
|
267
|
+
setAddDisabledKeys: setAddDisabledKeys({ state }),
|
|
268
|
+
setEditDisabledKeys: setEditDisabledKeys({ state }),
|
|
269
|
+
setDeleteDisabledKeys: setDeleteDisabledKeys({ state }),
|
|
270
|
+
watchDefaultExpandedKeys: watchDefaultExpandedKeys({ state, api: api2, nextTick }),
|
|
271
|
+
switchToggle: switchToggle({ state }),
|
|
272
|
+
initPlainNodeStore: initPlainNodeStore({ props, state }),
|
|
273
|
+
handleCheckPlainNode: handleCheckPlainNode({ props, emit }),
|
|
274
|
+
handleClickPlainNode: handleClickPlainNode(emit)
|
|
171
275
|
});
|
|
172
276
|
api2.created();
|
|
173
|
-
initWatcher({ watch, props, api: api2 });
|
|
277
|
+
initWatcher({ watch, props, api: api2, state });
|
|
174
278
|
onMounted(api2.wrapMounted);
|
|
175
279
|
onUpdated(api2.updated);
|
|
176
280
|
onBeforeUnmount(api2.beforeUnmount);
|
package/tree-menu/index.js
CHANGED
|
@@ -81,11 +81,44 @@ const currentChange = (emit) => (data, node) => {
|
|
|
81
81
|
emit("current-change", data, node);
|
|
82
82
|
};
|
|
83
83
|
const getTitle = (props) => (label) => props.showTitle ? label : "";
|
|
84
|
+
const collapseChange = ({ state, props, emit }) => () => {
|
|
85
|
+
if (props.collapsible) {
|
|
86
|
+
state.isCollapsed = !state.isCollapsed;
|
|
87
|
+
emit("collapse-change", state.isCollapsed);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const collapseMenu = ({ state, props, api }) => () => {
|
|
91
|
+
if (props.collapsible && !state.isCollapsed) {
|
|
92
|
+
api.collapseChange();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const expandMenu = ({ state, props, api }) => () => {
|
|
96
|
+
if (props.collapsible && state.isCollapsed) {
|
|
97
|
+
api.collapseChange();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const setCurrentKey = ({ vm }) => (key) => {
|
|
101
|
+
vm.$refs.tree.setCurrentKey(key);
|
|
102
|
+
};
|
|
103
|
+
const getCurrentKey = ({ vm }) => () => {
|
|
104
|
+
return vm.$refs.tree.getCurrentKey();
|
|
105
|
+
};
|
|
106
|
+
const setCurrentNode = ({ vm }) => (key) => {
|
|
107
|
+
vm.$refs.tree.setCurrentKey(key);
|
|
108
|
+
};
|
|
109
|
+
const getCurrentNode = ({ vm }) => () => {
|
|
110
|
+
return vm.$refs.tree.getCurrentNode();
|
|
111
|
+
};
|
|
84
112
|
export {
|
|
85
113
|
check,
|
|
86
114
|
checkChange,
|
|
115
|
+
collapseChange,
|
|
116
|
+
collapseMenu,
|
|
87
117
|
currentChange,
|
|
118
|
+
expandMenu,
|
|
88
119
|
filterNode,
|
|
120
|
+
getCurrentKey,
|
|
121
|
+
getCurrentNode,
|
|
89
122
|
getTitle,
|
|
90
123
|
initData,
|
|
91
124
|
nodeClick,
|
|
@@ -96,6 +129,8 @@ export {
|
|
|
96
129
|
nodeDragStart,
|
|
97
130
|
nodeDrop,
|
|
98
131
|
nodeExpand,
|
|
132
|
+
setCurrentKey,
|
|
133
|
+
setCurrentNode,
|
|
99
134
|
setMenuKey,
|
|
100
135
|
watchFilterText
|
|
101
136
|
};
|
package/tree-menu/vue.js
CHANGED
|
@@ -15,7 +15,14 @@ import {
|
|
|
15
15
|
checkChange,
|
|
16
16
|
check,
|
|
17
17
|
currentChange,
|
|
18
|
-
getTitle
|
|
18
|
+
getTitle,
|
|
19
|
+
collapseChange,
|
|
20
|
+
collapseMenu,
|
|
21
|
+
expandMenu,
|
|
22
|
+
setCurrentKey,
|
|
23
|
+
getCurrentKey,
|
|
24
|
+
setCurrentNode,
|
|
25
|
+
getCurrentNode
|
|
19
26
|
} from "./index";
|
|
20
27
|
const api = [
|
|
21
28
|
"state",
|
|
@@ -34,14 +41,22 @@ const api = [
|
|
|
34
41
|
"checkChange",
|
|
35
42
|
"check",
|
|
36
43
|
"currentChange",
|
|
37
|
-
"getTitle"
|
|
44
|
+
"getTitle",
|
|
45
|
+
"collapseChange",
|
|
46
|
+
"collapseMenu",
|
|
47
|
+
"expandMenu",
|
|
48
|
+
"setCurrentKey",
|
|
49
|
+
"getCurrentKey",
|
|
50
|
+
"setCurrentNode",
|
|
51
|
+
"getCurrentNode"
|
|
38
52
|
];
|
|
39
|
-
const renderless = (props, { watch, reactive, onMounted }, { t, service, refs, emit }) => {
|
|
53
|
+
const renderless = (props, { watch, reactive, onMounted }, { t, service, refs, emit, vm }) => {
|
|
40
54
|
service = service || { base: {} };
|
|
41
55
|
service = { getMenuDataSync: props.getMenuDataSync || service.base.getMenuDataSync };
|
|
42
56
|
const state = reactive({
|
|
43
57
|
data: [],
|
|
44
|
-
filterText: ""
|
|
58
|
+
filterText: "",
|
|
59
|
+
isCollapsed: false
|
|
45
60
|
});
|
|
46
61
|
Object.assign(api, {
|
|
47
62
|
t,
|
|
@@ -61,7 +76,14 @@ const renderless = (props, { watch, reactive, onMounted }, { t, service, refs, e
|
|
|
61
76
|
watchFilterText: watchFilterText(refs),
|
|
62
77
|
getTitle: getTitle(props),
|
|
63
78
|
setMenuKey: setMenuKey(api),
|
|
64
|
-
initData: initData({ state, props, service, api })
|
|
79
|
+
initData: initData({ state, props, service, api }),
|
|
80
|
+
collapseChange: collapseChange({ state, props, emit }),
|
|
81
|
+
collapseMenu: collapseMenu({ state, props, api }),
|
|
82
|
+
expandMenu: expandMenu({ state, props, api }),
|
|
83
|
+
setCurrentKey: setCurrentKey({ vm }),
|
|
84
|
+
getCurrentKey: getCurrentKey({ vm }),
|
|
85
|
+
setCurrentNode: setCurrentNode({ vm }),
|
|
86
|
+
getCurrentNode: getCurrentNode({ vm })
|
|
65
87
|
});
|
|
66
88
|
watch(
|
|
67
89
|
() => props.data,
|
package/tree-node/index.js
CHANGED
|
@@ -47,25 +47,46 @@ const handleSelectChange = ({ props, state }) => (checked, indeterminate) => {
|
|
|
47
47
|
state.oldChecked = checked;
|
|
48
48
|
state.indeterminate = indeterminate;
|
|
49
49
|
};
|
|
50
|
-
const handleClick = ({ api, vm, props, state
|
|
50
|
+
const handleClick = ({ api, vm, props, state }) => (e) => {
|
|
51
51
|
const store = state.tree.state.store;
|
|
52
52
|
state.tree.clearCurrentStore(props.node);
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (!state.tree.onlyCheckChildren) {
|
|
54
|
+
store.setCurrentNode(props.node);
|
|
55
|
+
!props.node.disabled && state.tree.$emit("current-change", store.currentNode ? store.currentNode.data : null, store.currentNode);
|
|
56
|
+
} else if (props.node.isLeaf && !props.node.disabled) {
|
|
57
|
+
store.setCurrentNode(props.node);
|
|
58
|
+
state.tree.$emit("current-change", store.currentNode ? store.currentNode.data : null, store.currentNode);
|
|
59
|
+
}
|
|
55
60
|
state.tree.currentNode = vm;
|
|
56
61
|
if (state.tree.checkOnClickNode && !props.node.disabled) {
|
|
57
62
|
e.target.checked = !props.node.checked;
|
|
58
63
|
api.handleCheckChange(null, e);
|
|
59
64
|
}
|
|
60
|
-
const isCheck = props.showCheckbox ? refs.checkbox && !refs.checkbox.$el.contains(e.target) : true;
|
|
61
|
-
|
|
65
|
+
const isCheck = props.showCheckbox ? vm.$refs.checkbox && !vm.$refs.checkbox.$el.contains(e.target) : true;
|
|
66
|
+
if (state.tree.onlyCheckChildren) {
|
|
67
|
+
if (props.node.isLeaf && !props.node.disabled) {
|
|
68
|
+
state.tree.$emit("node-click", props.node.data, props.node, vm);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (!state.tree.collapsible || !state.tree.expandOnClickNode) {
|
|
73
|
+
!props.node.disabled && state.tree.$emit("node-click", props.node.data, props.node, vm);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!state.tree.onlyCheckChildren) {
|
|
78
|
+
if (state.tree.expandOnClickNode && isCheck) {
|
|
79
|
+
api.handleExpandClick(isCheck);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
api.handleExpandClick(false);
|
|
83
|
+
}
|
|
62
84
|
};
|
|
63
85
|
const closeMenu = (state) => () => {
|
|
64
86
|
state.showMenu = false;
|
|
65
87
|
};
|
|
66
88
|
const handleContextMenu = ({ treeRoot, vm, props, state, nextTick }) => (event) => {
|
|
67
89
|
const listeners = treeRoot.vm.$listeners;
|
|
68
|
-
const refs = vm.$refs;
|
|
69
90
|
if (treeRoot.showContextmenu || listeners["node-contextmenu"]) {
|
|
70
91
|
event.stopPropagation();
|
|
71
92
|
event.preventDefault();
|
|
@@ -77,10 +98,10 @@ const handleContextMenu = ({ treeRoot, vm, props, state, nextTick }) => (event)
|
|
|
77
98
|
state.showMenu = true;
|
|
78
99
|
state.tree.$parent.menuInstance = vm;
|
|
79
100
|
nextTick(() => {
|
|
80
|
-
const menuWidth = refs.menuContext.offsetWidth;
|
|
101
|
+
const menuWidth = vm.$refs.menuContext.offsetWidth;
|
|
81
102
|
const treeWidth = state.tree.$parent.$el.offsetWidth;
|
|
82
103
|
if (event.clientY > -10) {
|
|
83
|
-
state.menuposition.top = `${refs.node.offsetTop + refs.node.childNodes[0].offsetHeight / 2}px`;
|
|
104
|
+
state.menuposition.top = `${vm.$refs.node.offsetTop + vm.$refs.node.childNodes[0].offsetHeight / 2}px`;
|
|
84
105
|
}
|
|
85
106
|
if (event.clientX > -10) {
|
|
86
107
|
if (menuWidth > treeWidth) {
|
|
@@ -115,9 +136,12 @@ const handleExpandClick = ({ emit, vm, props, state }) => (nodeClickFlag) => {
|
|
|
115
136
|
const handleCheckChange = ({ nextTick, props, state }) => (value, event = {}) => {
|
|
116
137
|
if (event.type === "click" || event.type === "mousedown") {
|
|
117
138
|
props.node.setChecked(event.target.checked, !state.tree.checkStrictly);
|
|
118
|
-
return;
|
|
119
139
|
}
|
|
120
|
-
|
|
140
|
+
if (props.checkEasily && state.tree.checkStrictly) {
|
|
141
|
+
!state.tree.checkOnClickNode && props.node.setChecked(event.target.checked, true, false, false, true);
|
|
142
|
+
} else {
|
|
143
|
+
!state.tree.checkOnClickNode && props.node.setChecked(event.target.checked, !state.tree.checkStrictly);
|
|
144
|
+
}
|
|
121
145
|
nextTick(() => {
|
|
122
146
|
const store = state.tree.state.store;
|
|
123
147
|
state.tree.$emit("check", props.node.data, {
|
|
@@ -183,9 +207,48 @@ const watchExpandedChange = ({ state, props }) => (value) => {
|
|
|
183
207
|
sibling: props.node
|
|
184
208
|
});
|
|
185
209
|
};
|
|
210
|
+
const openEdit = ({ state, vm }) => (node) => {
|
|
211
|
+
state.tree.state.emitter.emit("tree-node-edit", node);
|
|
212
|
+
setTimeout(() => {
|
|
213
|
+
const inputRef = vm.$refs.editInput || vm.$el.querySelector("input");
|
|
214
|
+
inputRef && inputRef.focus();
|
|
215
|
+
}, 300);
|
|
216
|
+
};
|
|
217
|
+
const closeEdit = ({ state }) => () => {
|
|
218
|
+
state.tree.state.emitter.emit("tree-node-edit", null);
|
|
219
|
+
};
|
|
220
|
+
const saveEdit = ({ state }) => (event) => {
|
|
221
|
+
event.stopPropagation();
|
|
222
|
+
state.tree.state.emitter.emit("tree-node-save");
|
|
223
|
+
};
|
|
224
|
+
const deleteNode = ({ state }) => (event, node) => {
|
|
225
|
+
state.tree.state.emitter.emit("tree-node-delete", event, node);
|
|
226
|
+
};
|
|
227
|
+
const addNode = ({ state, props, api }) => (event, node) => {
|
|
228
|
+
props.node.expand();
|
|
229
|
+
api.openEdit();
|
|
230
|
+
state.tree.state.emitter.emit("tree-node-add", event, node);
|
|
231
|
+
};
|
|
232
|
+
const computedExpandIcon = () => ({ showLine }, { tree, expanded, isSaaSTheme }) => {
|
|
233
|
+
if (tree.icon) {
|
|
234
|
+
return tree.icon;
|
|
235
|
+
}
|
|
236
|
+
if (showLine) {
|
|
237
|
+
return expanded ? "icon-minus-square" : "icon-plus-square";
|
|
238
|
+
}
|
|
239
|
+
return isSaaSTheme ? "icon-arrow-bottom" : "icon-chevron-right";
|
|
240
|
+
};
|
|
241
|
+
const computedIndent = () => ({ node, showLine }, { tree }) => {
|
|
242
|
+
return (node.level > 1 ? 1 : 0) * (tree.indent + (showLine ? 8 : 0)) + tree.baseIndent + "px";
|
|
243
|
+
};
|
|
186
244
|
export {
|
|
245
|
+
addNode,
|
|
246
|
+
closeEdit,
|
|
187
247
|
closeMenu,
|
|
248
|
+
computedExpandIcon,
|
|
249
|
+
computedIndent,
|
|
188
250
|
created,
|
|
251
|
+
deleteNode,
|
|
189
252
|
getNodeKey,
|
|
190
253
|
handleCheckChange,
|
|
191
254
|
handleChildNodeExpand,
|
|
@@ -200,6 +263,8 @@ export {
|
|
|
200
263
|
handleExpandIconClick,
|
|
201
264
|
handleSelectChange,
|
|
202
265
|
onSiblingToggleExpand,
|
|
266
|
+
openEdit,
|
|
267
|
+
saveEdit,
|
|
203
268
|
watchChecked,
|
|
204
269
|
watchExpanded,
|
|
205
270
|
watchExpandedChange,
|
package/tree-node/vue.js
CHANGED
|
@@ -18,8 +18,14 @@ import {
|
|
|
18
18
|
watchChecked,
|
|
19
19
|
watchExpanded,
|
|
20
20
|
closeMenu,
|
|
21
|
+
openEdit,
|
|
22
|
+
addNode,
|
|
23
|
+
saveEdit,
|
|
24
|
+
deleteNode,
|
|
21
25
|
onSiblingToggleExpand,
|
|
22
|
-
watchExpandedChange
|
|
26
|
+
watchExpandedChange,
|
|
27
|
+
computedExpandIcon,
|
|
28
|
+
computedIndent
|
|
23
29
|
} from "./index";
|
|
24
30
|
const api = [
|
|
25
31
|
"state",
|
|
@@ -35,25 +41,35 @@ const api = [
|
|
|
35
41
|
"handleSelectChange",
|
|
36
42
|
"handleContextMenu",
|
|
37
43
|
"handleExpandIconClick",
|
|
44
|
+
"openEdit",
|
|
45
|
+
"addNode",
|
|
46
|
+
"saveEdit",
|
|
47
|
+
"deleteNode",
|
|
38
48
|
"handleCheckChange"
|
|
39
49
|
];
|
|
40
|
-
const initState = ({ reactive, treeRoot, props, emitter, $parentEmitter }) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const initState = ({ reactive, treeRoot, props, emitter, $parentEmitter, vm, api: api2, computed }) => {
|
|
51
|
+
const state = reactive({
|
|
52
|
+
tree: treeRoot,
|
|
53
|
+
expanded: false,
|
|
54
|
+
oldChecked: null,
|
|
55
|
+
indeterminate: null,
|
|
56
|
+
oldIndeterminate: null,
|
|
57
|
+
expandIcon: props.expandIcon,
|
|
58
|
+
childNodeRendered: false,
|
|
59
|
+
showMenu: false,
|
|
60
|
+
menuposition: { position: "absolute", top: 0, left: 0 },
|
|
61
|
+
shrinkIcon: props.shrinkIcon,
|
|
62
|
+
expandIconColor: props.expandIconColor,
|
|
63
|
+
shrinkIconColor: props.shrinkIconColor,
|
|
64
|
+
emitter: emitter(),
|
|
65
|
+
parentEmitter: $parentEmitter,
|
|
66
|
+
isSaaSTheme: (props.theme || vm.theme) === "saas",
|
|
67
|
+
computedExpandIcon: computed(() => api2.computedExpandIcon(treeRoot, state)),
|
|
68
|
+
computedIndent: computed(() => api2.computedIndent(props, state))
|
|
69
|
+
});
|
|
70
|
+
return state;
|
|
71
|
+
};
|
|
72
|
+
const initApi = ({ api: api2, state, dispatch, broadcast, vm, props, parent, treeRoot, nextTick, emit }) => {
|
|
57
73
|
Object.assign(api2, {
|
|
58
74
|
state,
|
|
59
75
|
dispatch,
|
|
@@ -73,11 +89,17 @@ const initApi = ({ api: api2, state, dispatch, broadcast, vm, props, parent, tre
|
|
|
73
89
|
handleContentClick: handleContentClick({ nextTick, props, state, emit }),
|
|
74
90
|
onSiblingToggleExpand: onSiblingToggleExpand({ state, props }),
|
|
75
91
|
watchExpandedChange: watchExpandedChange({ state, props }),
|
|
76
|
-
handleClick: handleClick({ api: api2, vm, props, state
|
|
92
|
+
handleClick: handleClick({ api: api2, vm, props, state }),
|
|
77
93
|
watchIndeterminate: watchIndeterminate({ api: api2, props }),
|
|
78
94
|
watchChecked: watchChecked({ api: api2, props }),
|
|
95
|
+
openEdit: openEdit({ state, vm }),
|
|
96
|
+
addNode: addNode({ state, props, api: api2 }),
|
|
97
|
+
saveEdit: saveEdit({ state }),
|
|
98
|
+
deleteNode: deleteNode({ state }),
|
|
79
99
|
handleChildNodeExpand: handleChildNodeExpand(state),
|
|
80
|
-
handleExpandIconClick: handleExpandIconClick({ api: api2, state })
|
|
100
|
+
handleExpandIconClick: handleExpandIconClick({ api: api2, state }),
|
|
101
|
+
computedExpandIcon: computedExpandIcon(),
|
|
102
|
+
computedIndent: computedIndent()
|
|
81
103
|
});
|
|
82
104
|
};
|
|
83
105
|
const initWatcher = ({ watch, state, api: api2, props }) => {
|
|
@@ -86,15 +108,15 @@ const initWatcher = ({ watch, state, api: api2, props }) => {
|
|
|
86
108
|
watch(() => props.node.checked, api2.watchChecked, { deep: true });
|
|
87
109
|
watch(() => props.node.expanded, api2.watchExpanded, { deep: true });
|
|
88
110
|
};
|
|
89
|
-
const renderless = (props, { reactive, watch, inject, provide }, { parent: parentVm, vm, nextTick, emit, broadcast, dispatch,
|
|
111
|
+
const renderless = (props, { reactive, watch, inject, provide, computed }, { parent: parentVm, vm, nextTick, emit, broadcast, dispatch, emitter }) => {
|
|
90
112
|
const api2 = {};
|
|
91
113
|
const parent = inject("parentTree") || parentVm;
|
|
92
114
|
const treeRoot = inject("TreeRoot");
|
|
93
115
|
const $parentEmitter = inject("parentEmitter");
|
|
94
|
-
const state = initState({ reactive, treeRoot, props, emitter, $parentEmitter });
|
|
116
|
+
const state = initState({ reactive, treeRoot, props, emitter, $parentEmitter, vm, api: api2, computed });
|
|
95
117
|
state.parentEmitter.on("sibling-node-toggle-expand", (event) => api2.onSiblingToggleExpand(event));
|
|
96
118
|
provide("parentEmitter", state.emitter);
|
|
97
|
-
initApi({ api: api2, state, dispatch, broadcast, vm, props, parent, treeRoot, nextTick, emit
|
|
119
|
+
initApi({ api: api2, state, dispatch, broadcast, vm, props, parent, treeRoot, nextTick, emit });
|
|
98
120
|
initWatcher({ watch, state, api: api2, props });
|
|
99
121
|
api2.created((childrenKey) => {
|
|
100
122
|
watch(
|