primevue 4.3.9 → 4.4.1
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/AutoComplete.vue +19 -4
- package/autocomplete/BaseAutoComplete.vue +4 -0
- package/autocomplete/index.d.ts +20 -0
- package/autocomplete/index.mjs +35 -8
- package/autocomplete/index.mjs.map +1 -1
- package/autocomplete/style/index.d.ts +4 -0
- package/autocomplete/style/index.mjs +3 -1
- package/autocomplete/style/index.mjs.map +1 -1
- package/cascadeselect/CascadeSelect.vue +1 -1
- package/cascadeselect/index.mjs +1 -1
- package/cascadeselect/index.mjs.map +1 -1
- package/checkbox/Checkbox.vue +15 -2
- package/checkbox/index.mjs +14 -2
- package/checkbox/index.mjs.map +1 -1
- package/colorpicker/ColorPicker.vue +3 -4
- package/colorpicker/index.mjs +3 -3
- package/colorpicker/index.mjs.map +1 -1
- package/confirmdialog/ConfirmDialog.vue +1 -1
- package/confirmdialog/index.d.ts +5 -0
- package/confirmdialog/index.mjs +3 -2
- package/confirmdialog/index.mjs.map +1 -1
- package/datatable/ColumnFilter.vue +1 -1
- package/datatable/DataTable.vue +2 -2
- package/datatable/HeaderCheckbox.vue +3 -3
- package/datatable/index.mjs +13 -4
- package/datatable/index.mjs.map +1 -1
- package/datepicker/BaseDatePicker.vue +8 -0
- package/datepicker/DatePicker.vue +225 -105
- package/datepicker/index.d.ts +43 -2
- package/datepicker/index.mjs +303 -186
- package/datepicker/index.mjs.map +1 -1
- package/datepicker/style/index.d.ts +4 -0
- package/datepicker/style/index.mjs +5 -2
- package/datepicker/style/index.mjs.map +1 -1
- package/drawer/BaseDrawer.vue +4 -0
- package/drawer/Drawer.vue +5 -5
- package/drawer/index.d.ts +5 -0
- package/drawer/index.mjs +11 -7
- package/drawer/index.mjs.map +1 -1
- package/editor/Editor.vue +5 -1
- package/editor/index.mjs +5 -0
- package/editor/index.mjs.map +1 -1
- package/image/index.d.ts +5 -11
- package/inputmask/InputMask.vue +1 -2
- package/inputmask/index.mjs +1 -1
- package/inputmask/index.mjs.map +1 -1
- package/inputnumber/BaseInputNumber.vue +4 -0
- package/inputnumber/InputNumber.vue +30 -5
- package/inputnumber/index.d.ts +20 -0
- package/inputnumber/index.mjs +45 -7
- package/inputnumber/index.mjs.map +1 -1
- package/inputnumber/style/index.mjs +1 -0
- package/inputnumber/style/index.mjs.map +1 -1
- package/inputotp/InputOtp.vue +7 -3
- package/inputotp/index.mjs +6 -3
- package/inputotp/index.mjs.map +1 -1
- package/listbox/Listbox.vue +1 -1
- package/listbox/index.mjs +1 -1
- package/listbox/index.mjs.map +1 -1
- package/menu/Menu.vue +2 -2
- package/menu/index.mjs +1 -1
- package/menu/index.mjs.map +1 -1
- package/multiselect/MultiSelect.vue +10 -6
- package/multiselect/index.mjs +15 -11
- package/multiselect/index.mjs.map +1 -1
- package/package.json +5 -5
- package/panel/Panel.vue +1 -1
- package/panel/index.d.ts +4 -0
- package/panel/index.mjs +2 -1
- package/panel/index.mjs.map +1 -1
- package/password/BasePassword.vue +4 -0
- package/password/Password.vue +14 -2
- package/password/index.d.ts +20 -0
- package/password/index.mjs +26 -3
- package/password/index.mjs.map +1 -1
- package/password/style/index.d.ts +4 -0
- package/password/style/index.mjs +1 -0
- package/password/style/index.mjs.map +1 -1
- package/select/Select.vue +2 -1
- package/select/index.mjs +2 -1
- package/select/index.mjs.map +1 -1
- package/speeddial/SpeedDial.vue +1 -1
- package/speeddial/index.mjs +1 -1
- package/speeddial/index.mjs.map +1 -1
- package/splitbutton/SplitButton.vue +1 -1
- package/splitbutton/index.mjs +1 -1
- package/splitbutton/index.mjs.map +1 -1
- package/tree/BaseTree.vue +20 -0
- package/tree/Tree.vue +236 -4
- package/tree/TreeNode.vue +295 -3
- package/tree/index.d.ts +140 -0
- package/tree/index.mjs +637 -27
- package/tree/index.mjs.map +1 -1
- package/tree/style/index.mjs +9 -4
- package/tree/style/index.mjs.map +1 -1
- package/treenode/index.d.ts +12 -0
- package/treeselect/TreeSelect.vue +3 -2
- package/treeselect/index.mjs +6 -5
- package/treeselect/index.mjs.map +1 -1
- package/umd/primevue.min.js +1 -1
- package/web-types.json +1 -1
package/tree/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn } from '@primeuix/utils';
|
|
1
|
+
import { getAttribute, findSingle, find, getOuterWidth, getOuterHeight, cn } from '@primeuix/utils';
|
|
2
2
|
import { isFunction, resolveFieldData } from '@primeuix/utils/object';
|
|
3
3
|
import SearchIcon from '@primevue/icons/search';
|
|
4
4
|
import SpinnerIcon from '@primevue/icons/spinner';
|
|
@@ -7,14 +7,13 @@ import InputIcon from 'primevue/inputicon';
|
|
|
7
7
|
import InputText from 'primevue/inputtext';
|
|
8
8
|
import BaseComponent from '@primevue/core/basecomponent';
|
|
9
9
|
import TreeStyle from 'primevue/tree/style';
|
|
10
|
-
import {
|
|
10
|
+
import { reactive, resolveComponent, resolveDirective, createElementBlock, openBlock, mergeProps, createCommentVNode, createElementVNode, normalizeClass, withDirectives, createBlock, Fragment, resolveDynamicComponent, withCtx, withModifiers, createTextVNode, toDisplayString, renderList, renderSlot, createVNode } from 'vue';
|
|
11
11
|
import CheckIcon from '@primevue/icons/check';
|
|
12
12
|
import ChevronDownIcon from '@primevue/icons/chevrondown';
|
|
13
13
|
import ChevronRightIcon from '@primevue/icons/chevronright';
|
|
14
14
|
import MinusIcon from '@primevue/icons/minus';
|
|
15
15
|
import Checkbox from 'primevue/checkbox';
|
|
16
16
|
import Ripple from 'primevue/ripple';
|
|
17
|
-
import { resolveComponent, resolveDirective, createElementBlock, openBlock, mergeProps, createElementVNode, createCommentVNode, withDirectives, createBlock, Fragment, resolveDynamicComponent, normalizeClass, withCtx, withModifiers, createTextVNode, toDisplayString, renderList, renderSlot, createVNode } from 'vue';
|
|
18
17
|
|
|
19
18
|
var script$2 = {
|
|
20
19
|
name: 'BaseTree',
|
|
@@ -84,6 +83,26 @@ var script$2 = {
|
|
|
84
83
|
type: Number,
|
|
85
84
|
"default": 0
|
|
86
85
|
},
|
|
86
|
+
draggableNodes: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
"default": null
|
|
89
|
+
},
|
|
90
|
+
droppableNodes: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
"default": null
|
|
93
|
+
},
|
|
94
|
+
draggableScope: {
|
|
95
|
+
type: [String, Array],
|
|
96
|
+
"default": null
|
|
97
|
+
},
|
|
98
|
+
droppableScope: {
|
|
99
|
+
type: [String, Array],
|
|
100
|
+
"default": null
|
|
101
|
+
},
|
|
102
|
+
validateDrop: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
"default": false
|
|
105
|
+
},
|
|
87
106
|
ariaLabelledby: {
|
|
88
107
|
type: String,
|
|
89
108
|
"default": null
|
|
@@ -102,29 +121,82 @@ var script$2 = {
|
|
|
102
121
|
}
|
|
103
122
|
};
|
|
104
123
|
|
|
124
|
+
var dragState = reactive({
|
|
125
|
+
isDragging: false,
|
|
126
|
+
dragNode: null,
|
|
127
|
+
dragScope: null
|
|
128
|
+
});
|
|
129
|
+
var dragStartHandlers = new Set();
|
|
130
|
+
var dragStopHandlers = new Set();
|
|
131
|
+
function useTreeDragDropService() {
|
|
132
|
+
var startDrag = function startDrag(event) {
|
|
133
|
+
dragState.isDragging = true;
|
|
134
|
+
dragState.dragNode = event.node;
|
|
135
|
+
dragState.dragScope = event.scope;
|
|
136
|
+
dragStartHandlers.forEach(function (handler) {
|
|
137
|
+
return handler(event);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
var stopDrag = function stopDrag(event) {
|
|
141
|
+
dragState.isDragging = false;
|
|
142
|
+
dragState.dragNode = null;
|
|
143
|
+
dragState.dragScope = null;
|
|
144
|
+
dragStopHandlers.forEach(function (handler) {
|
|
145
|
+
return handler(event);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var onDragStart = function onDragStart(handler) {
|
|
149
|
+
dragStartHandlers.add(handler);
|
|
150
|
+
return function () {
|
|
151
|
+
return dragStartHandlers["delete"](handler);
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
var onDragStop = function onDragStop(handler) {
|
|
155
|
+
dragStopHandlers.add(handler);
|
|
156
|
+
return function () {
|
|
157
|
+
return dragStopHandlers["delete"](handler);
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
dragState: dragState,
|
|
162
|
+
startDrag: startDrag,
|
|
163
|
+
stopDrag: stopDrag,
|
|
164
|
+
onDragStart: onDragStart,
|
|
165
|
+
onDragStop: onDragStop
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
105
169
|
function _typeof$2(o) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$2(o); }
|
|
106
170
|
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
107
|
-
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
108
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
109
|
-
function _defineProperty$2(e, r, t) { return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
|
|
110
|
-
function _toPropertyKey$2(t) { var i = _toPrimitive$2(t, "string"); return "symbol" == _typeof$2(i) ? i : i + ""; }
|
|
111
|
-
function _toPrimitive$2(t, r) { if ("object" != _typeof$2(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$2(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
112
171
|
function _toConsumableArray$1(r) { return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread$1(); }
|
|
113
172
|
function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
114
173
|
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
115
174
|
function _iterableToArray$1(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
116
175
|
function _arrayWithoutHoles$1(r) { if (Array.isArray(r)) return _arrayLikeToArray$1(r); }
|
|
117
176
|
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
177
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
178
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
179
|
+
function _defineProperty$2(e, r, t) { return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; }
|
|
180
|
+
function _toPropertyKey$2(t) { var i = _toPrimitive$2(t, "string"); return "symbol" == _typeof$2(i) ? i : i + ""; }
|
|
181
|
+
function _toPrimitive$2(t, r) { if ("object" != _typeof$2(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$2(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
118
182
|
var script$1 = {
|
|
119
183
|
name: 'TreeNode',
|
|
120
184
|
hostName: 'Tree',
|
|
121
185
|
"extends": BaseComponent,
|
|
122
|
-
emits: ['node-toggle', 'node-click', 'checkbox-change'],
|
|
186
|
+
emits: ['node-toggle', 'node-click', 'checkbox-change', 'node-drop', 'value-change', 'node-dragenter', 'node-dragleave'],
|
|
123
187
|
props: {
|
|
124
188
|
node: {
|
|
125
189
|
type: null,
|
|
126
190
|
"default": null
|
|
127
191
|
},
|
|
192
|
+
parentNode: {
|
|
193
|
+
type: null,
|
|
194
|
+
"default": null
|
|
195
|
+
},
|
|
196
|
+
rootNodes: {
|
|
197
|
+
type: Array,
|
|
198
|
+
"default": null
|
|
199
|
+
},
|
|
128
200
|
expandedKeys: {
|
|
129
201
|
type: null,
|
|
130
202
|
"default": null
|
|
@@ -149,10 +221,38 @@ var script$1 = {
|
|
|
149
221
|
type: Number,
|
|
150
222
|
"default": null
|
|
151
223
|
},
|
|
224
|
+
draggableScope: {
|
|
225
|
+
type: [String, Array],
|
|
226
|
+
"default": null
|
|
227
|
+
},
|
|
228
|
+
draggableNodes: {
|
|
229
|
+
type: Boolean,
|
|
230
|
+
"default": null
|
|
231
|
+
},
|
|
232
|
+
droppableNodes: {
|
|
233
|
+
type: Boolean,
|
|
234
|
+
"default": null
|
|
235
|
+
},
|
|
236
|
+
validateDrop: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
"default": false
|
|
239
|
+
},
|
|
152
240
|
index: null
|
|
153
241
|
},
|
|
154
242
|
nodeTouched: false,
|
|
155
243
|
toggleClicked: false,
|
|
244
|
+
inject: {
|
|
245
|
+
$pcTree: {
|
|
246
|
+
"default": undefined
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
data: function data() {
|
|
250
|
+
return {
|
|
251
|
+
isPrevDropPointHovered: false,
|
|
252
|
+
isNextDropPointHovered: false,
|
|
253
|
+
isNodeDropHovered: false
|
|
254
|
+
};
|
|
255
|
+
},
|
|
156
256
|
mounted: function mounted() {
|
|
157
257
|
this.setAllNodesTabIndexes();
|
|
158
258
|
},
|
|
@@ -289,6 +389,205 @@ var script$1 = {
|
|
|
289
389
|
onTabKey: function onTabKey() {
|
|
290
390
|
this.setAllNodesTabIndexes();
|
|
291
391
|
},
|
|
392
|
+
removeNodeFromTree: function removeNodeFromTree(nodes, nodeToRemove) {
|
|
393
|
+
var _this2 = this;
|
|
394
|
+
return nodes.reduce(function (acc, node) {
|
|
395
|
+
if (node.key === nodeToRemove.key) {
|
|
396
|
+
return acc;
|
|
397
|
+
}
|
|
398
|
+
if (node.children && node.children.length > 0) {
|
|
399
|
+
var updatedChildren = _this2.removeNodeFromTree(node.children, nodeToRemove);
|
|
400
|
+
acc.push(_objectSpread$2(_objectSpread$2({}, node), {}, {
|
|
401
|
+
children: updatedChildren
|
|
402
|
+
}));
|
|
403
|
+
} else {
|
|
404
|
+
acc.push(node);
|
|
405
|
+
}
|
|
406
|
+
return acc;
|
|
407
|
+
}, []);
|
|
408
|
+
},
|
|
409
|
+
insertNodeInSiblings: function insertNodeInSiblings(nodes, targetKey, nodeToInsert, offset) {
|
|
410
|
+
var _this3 = this;
|
|
411
|
+
var targetIndex = nodes.findIndex(function (n) {
|
|
412
|
+
return n.key === targetKey;
|
|
413
|
+
});
|
|
414
|
+
if (targetIndex !== -1) {
|
|
415
|
+
return nodes.toSpliced(targetIndex + offset, 0, nodeToInsert);
|
|
416
|
+
}
|
|
417
|
+
return nodes.map(function (node) {
|
|
418
|
+
if (node.children && node.children.length > 0) {
|
|
419
|
+
return _objectSpread$2(_objectSpread$2({}, node), {}, {
|
|
420
|
+
children: _this3.insertNodeInSiblings(node.children, targetKey, nodeToInsert, offset)
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return node;
|
|
424
|
+
});
|
|
425
|
+
},
|
|
426
|
+
addNodeAsChild: function addNodeAsChild(nodes, parentKey, nodeToInsert) {
|
|
427
|
+
var _this4 = this;
|
|
428
|
+
return nodes.map(function (node) {
|
|
429
|
+
if (node.key === parentKey) {
|
|
430
|
+
return _objectSpread$2(_objectSpread$2({}, node), {}, {
|
|
431
|
+
children: [].concat(_toConsumableArray$1(node.children || []), [nodeToInsert])
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
if (node.children && node.children.length > 0) {
|
|
435
|
+
return _objectSpread$2(_objectSpread$2({}, node), {}, {
|
|
436
|
+
children: _this4.addNodeAsChild(node.children, parentKey, nodeToInsert)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return node;
|
|
440
|
+
});
|
|
441
|
+
},
|
|
442
|
+
insertNodeOnDrop: function insertNodeOnDrop() {
|
|
443
|
+
var _this$$pcTree = this.$pcTree,
|
|
444
|
+
dragNode = _this$$pcTree.dragNode,
|
|
445
|
+
dragNodeIndex = _this$$pcTree.dragNodeIndex,
|
|
446
|
+
dragNodeSubNodes = _this$$pcTree.dragNodeSubNodes,
|
|
447
|
+
dragDropService = _this$$pcTree.dragDropService;
|
|
448
|
+
if (!this.node || dragNodeIndex == null || !dragNode || !dragNodeSubNodes) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
var position = this.dropPosition;
|
|
452
|
+
var updatedNodes = this.removeNodeFromTree(this.rootNodes, dragNode);
|
|
453
|
+
if (position < 0) {
|
|
454
|
+
// insert before a Node
|
|
455
|
+
updatedNodes = this.insertNodeInSiblings(updatedNodes, this.node.key, dragNode, 0);
|
|
456
|
+
} else if (position > 0) {
|
|
457
|
+
// insert after a Node
|
|
458
|
+
updatedNodes = this.insertNodeInSiblings(updatedNodes, this.node.key, dragNode, 1);
|
|
459
|
+
} else {
|
|
460
|
+
// insert as child of a Node
|
|
461
|
+
updatedNodes = this.addNodeAsChild(updatedNodes, this.node.key, dragNode);
|
|
462
|
+
}
|
|
463
|
+
this.$emit('value-change', {
|
|
464
|
+
nodes: updatedNodes
|
|
465
|
+
});
|
|
466
|
+
dragDropService.stopDrag({
|
|
467
|
+
node: dragNode,
|
|
468
|
+
subNodes: updatedNodes,
|
|
469
|
+
index: dragNodeIndex
|
|
470
|
+
});
|
|
471
|
+
return updatedNodes;
|
|
472
|
+
},
|
|
473
|
+
onNodeDrop: function onNodeDrop(event) {
|
|
474
|
+
var _this5 = this;
|
|
475
|
+
if (this.isDroppable) {
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
event.stopPropagation();
|
|
478
|
+
var dragNode = this.$pcTree.dragNode;
|
|
479
|
+
var position = this.dropPosition;
|
|
480
|
+
var isValidDrop = position !== 0 || position === 0 && this.isNodeDroppable;
|
|
481
|
+
if (isValidDrop) {
|
|
482
|
+
if (this.validateDrop) {
|
|
483
|
+
this.$emit('node-drop', {
|
|
484
|
+
originalEvent: event,
|
|
485
|
+
value: this.rootNodes,
|
|
486
|
+
dragNode: dragNode,
|
|
487
|
+
dropNode: this.node,
|
|
488
|
+
index: this.index,
|
|
489
|
+
accept: function accept() {
|
|
490
|
+
var updatedNodes = _this5.insertNodeOnDrop();
|
|
491
|
+
_this5.$emit('node-drop', {
|
|
492
|
+
originalEvent: event,
|
|
493
|
+
value: updatedNodes,
|
|
494
|
+
dragNode: dragNode,
|
|
495
|
+
dropNode: _this5.node,
|
|
496
|
+
index: _this5.index
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
} else {
|
|
501
|
+
var updatedNodes = this.insertNodeOnDrop();
|
|
502
|
+
this.$emit('node-drop', {
|
|
503
|
+
originalEvent: event,
|
|
504
|
+
value: updatedNodes,
|
|
505
|
+
dragNode: dragNode,
|
|
506
|
+
dropNode: this.node,
|
|
507
|
+
index: this.index
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
this.isPrevDropPointHovered = false;
|
|
512
|
+
this.isNextDropPointHovered = false;
|
|
513
|
+
this.isNodeDropHovered = false;
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
onNodeDragStart: function onNodeDragStart(event) {
|
|
517
|
+
if (this.isNodeDraggable) {
|
|
518
|
+
event.dataTransfer.effectAllowed = 'all';
|
|
519
|
+
event.dataTransfer.setData('text', 'data');
|
|
520
|
+
var target = event.currentTarget;
|
|
521
|
+
var dragEl = target.cloneNode(true);
|
|
522
|
+
var toggler = dragEl.querySelector('[data-pc-section="nodetogglebutton"]');
|
|
523
|
+
var checkbox = dragEl.querySelector('[data-pc-name="pcnodecheckbox"]');
|
|
524
|
+
target.setAttribute('data-p-dragging', 'true');
|
|
525
|
+
dragEl.style.width = getOuterWidth(target) + 'px';
|
|
526
|
+
dragEl.style.height = getOuterHeight(target) + 'px';
|
|
527
|
+
dragEl.setAttribute('data-pc-section', 'drag-image');
|
|
528
|
+
toggler.style.visibility = 'hidden';
|
|
529
|
+
checkbox === null || checkbox === void 0 || checkbox.remove();
|
|
530
|
+
document.body.appendChild(dragEl);
|
|
531
|
+
event.dataTransfer.setDragImage(dragEl, 0, 0);
|
|
532
|
+
setTimeout(function () {
|
|
533
|
+
return document.body.removeChild(dragEl);
|
|
534
|
+
}, 0);
|
|
535
|
+
this.$pcTree.dragDropService.startDrag({
|
|
536
|
+
node: this.node,
|
|
537
|
+
subNodes: this.subNodes,
|
|
538
|
+
index: this.index,
|
|
539
|
+
scope: this.draggableScope
|
|
540
|
+
});
|
|
541
|
+
} else {
|
|
542
|
+
event.preventDefault();
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
onNodeDragOver: function onNodeDragOver(event) {
|
|
546
|
+
if (this.isDroppable) {
|
|
547
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
548
|
+
var nodeElement = event.currentTarget;
|
|
549
|
+
var rect = nodeElement.getBoundingClientRect();
|
|
550
|
+
var y = event.clientY - rect.top;
|
|
551
|
+
this.isPrevDropPointHovered = false;
|
|
552
|
+
this.isNextDropPointHovered = false;
|
|
553
|
+
this.isNodeDropHovered = false;
|
|
554
|
+
if (y < rect.height * 0.25) {
|
|
555
|
+
this.isPrevDropPointHovered = true;
|
|
556
|
+
} else if (y > rect.height * 0.75) {
|
|
557
|
+
this.isNextDropPointHovered = true;
|
|
558
|
+
} else if (this.isNodeDroppable) {
|
|
559
|
+
this.isNodeDropHovered = true;
|
|
560
|
+
}
|
|
561
|
+
} else {
|
|
562
|
+
event.dataTransfer.dropEffect = 'none';
|
|
563
|
+
}
|
|
564
|
+
if (this.droppableNodes) {
|
|
565
|
+
event.preventDefault();
|
|
566
|
+
event.stopPropagation();
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
onNodeDragEnter: function onNodeDragEnter() {
|
|
570
|
+
this.$emit('node-dragenter', {
|
|
571
|
+
node: this.node
|
|
572
|
+
});
|
|
573
|
+
},
|
|
574
|
+
onNodeDragLeave: function onNodeDragLeave() {
|
|
575
|
+
this.$emit('node-dragleave', {
|
|
576
|
+
node: this.node
|
|
577
|
+
});
|
|
578
|
+
this.isPrevDropPointHovered = false;
|
|
579
|
+
this.isNextDropPointHovered = false;
|
|
580
|
+
this.isNodeDropHovered = false;
|
|
581
|
+
},
|
|
582
|
+
onNodeDragEnd: function onNodeDragEnd(event) {
|
|
583
|
+
var _event$currentTarget;
|
|
584
|
+
(_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || _event$currentTarget.removeAttribute('data-p-dragging');
|
|
585
|
+
this.$pcTree.dragDropService.stopDrag({
|
|
586
|
+
node: this.node,
|
|
587
|
+
subNodes: this.subNodes,
|
|
588
|
+
index: this.index
|
|
589
|
+
});
|
|
590
|
+
},
|
|
292
591
|
setAllNodesTabIndexes: function setAllNodesTabIndexes() {
|
|
293
592
|
var nodes = find(this.$refs.currentNode.closest('[data-pc-section="rootchildren"]'), '[role="treeitem"]');
|
|
294
593
|
var hasSelectedNode = _toConsumableArray$1(nodes).some(function (node) {
|
|
@@ -464,6 +763,35 @@ var script$1 = {
|
|
|
464
763
|
},
|
|
465
764
|
ariaSelected: function ariaSelected() {
|
|
466
765
|
return this.checkboxMode ? this.checked : undefined;
|
|
766
|
+
},
|
|
767
|
+
isPrevDropPointActive: function isPrevDropPointActive() {
|
|
768
|
+
return this.isPrevDropPointHovered && this.isDroppable;
|
|
769
|
+
},
|
|
770
|
+
isNextDropPointActive: function isNextDropPointActive() {
|
|
771
|
+
return this.isNextDropPointHovered && this.isDroppable;
|
|
772
|
+
},
|
|
773
|
+
dropPosition: function dropPosition() {
|
|
774
|
+
return this.isPrevDropPointActive ? -1 : this.isNextDropPointActive ? 1 : 0;
|
|
775
|
+
},
|
|
776
|
+
subNodes: function subNodes() {
|
|
777
|
+
return this.parentNode ? this.parentNode.children : this.rootNodes;
|
|
778
|
+
},
|
|
779
|
+
isDraggable: function isDraggable() {
|
|
780
|
+
return this.draggableNodes;
|
|
781
|
+
},
|
|
782
|
+
isDroppable: function isDroppable() {
|
|
783
|
+
return this.droppableNodes && this.$pcTree.allowNodeDrop(this.node);
|
|
784
|
+
},
|
|
785
|
+
isNodeDraggable: function isNodeDraggable() {
|
|
786
|
+
var _this$node;
|
|
787
|
+
return ((_this$node = this.node) === null || _this$node === void 0 ? void 0 : _this$node.draggable) !== false && this.isDraggable;
|
|
788
|
+
},
|
|
789
|
+
isNodeDroppable: function isNodeDroppable() {
|
|
790
|
+
var _this$node2;
|
|
791
|
+
return ((_this$node2 = this.node) === null || _this$node2 === void 0 ? void 0 : _this$node2.droppable) !== false && this.isDroppable;
|
|
792
|
+
},
|
|
793
|
+
isNodeDropActive: function isNodeDropActive() {
|
|
794
|
+
return this.isNodeDropHovered && this.isNodeDroppable;
|
|
467
795
|
}
|
|
468
796
|
},
|
|
469
797
|
components: {
|
|
@@ -480,7 +808,7 @@ var script$1 = {
|
|
|
480
808
|
};
|
|
481
809
|
|
|
482
810
|
var _hoisted_1$1 = ["aria-label", "aria-selected", "aria-expanded", "aria-setsize", "aria-posinset", "aria-level", "aria-checked", "tabindex"];
|
|
483
|
-
var _hoisted_2$1 = ["data-p-selected", "data-p-selectable"];
|
|
811
|
+
var _hoisted_2$1 = ["draggable", "data-p-selected", "data-p-selectable"];
|
|
484
812
|
var _hoisted_3$1 = ["data-p-leaf"];
|
|
485
813
|
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
486
814
|
var _component_SpinnerIcon = resolveComponent("SpinnerIcon");
|
|
@@ -499,18 +827,41 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
499
827
|
"aria-level": $props.level,
|
|
500
828
|
"aria-checked": $options.ariaChecked,
|
|
501
829
|
tabindex: $props.index === 0 ? 0 : -1,
|
|
502
|
-
onKeydown: _cache[
|
|
830
|
+
onKeydown: _cache[14] || (_cache[14] = function () {
|
|
503
831
|
return $options.onKeyDown && $options.onKeyDown.apply($options, arguments);
|
|
504
832
|
})
|
|
505
|
-
}, $options.getPTOptions('node')), [
|
|
833
|
+
}, $options.getPTOptions('node')), [$options.isPrevDropPointActive ? (openBlock(), createElementBlock("div", {
|
|
834
|
+
key: 0,
|
|
835
|
+
"class": normalizeClass(_ctx.cx('dropPoint')),
|
|
836
|
+
"aria-hidden": "true"
|
|
837
|
+
}, null, 2)) : createCommentVNode("", true), createElementVNode("div", mergeProps({
|
|
506
838
|
"class": _ctx.cx('nodeContent'),
|
|
839
|
+
style: $props.node.style,
|
|
840
|
+
draggable: $options.isDraggable,
|
|
507
841
|
onClick: _cache[2] || (_cache[2] = function () {
|
|
508
842
|
return $options.onClick && $options.onClick.apply($options, arguments);
|
|
509
843
|
}),
|
|
510
844
|
onTouchend: _cache[3] || (_cache[3] = function () {
|
|
511
845
|
return $options.onTouchEnd && $options.onTouchEnd.apply($options, arguments);
|
|
512
846
|
}),
|
|
513
|
-
|
|
847
|
+
onDragstart: _cache[4] || (_cache[4] = function () {
|
|
848
|
+
return $options.onNodeDragStart && $options.onNodeDragStart.apply($options, arguments);
|
|
849
|
+
}),
|
|
850
|
+
onDragover: _cache[5] || (_cache[5] = function () {
|
|
851
|
+
return $options.onNodeDragOver && $options.onNodeDragOver.apply($options, arguments);
|
|
852
|
+
}),
|
|
853
|
+
onDragenter: _cache[6] || (_cache[6] = function () {
|
|
854
|
+
return $options.onNodeDragEnter && $options.onNodeDragEnter.apply($options, arguments);
|
|
855
|
+
}),
|
|
856
|
+
onDragleave: _cache[7] || (_cache[7] = function () {
|
|
857
|
+
return $options.onNodeDragLeave && $options.onNodeDragLeave.apply($options, arguments);
|
|
858
|
+
}),
|
|
859
|
+
onDragend: _cache[8] || (_cache[8] = function () {
|
|
860
|
+
return $options.onNodeDragEnd && $options.onNodeDragEnd.apply($options, arguments);
|
|
861
|
+
}),
|
|
862
|
+
onDrop: _cache[9] || (_cache[9] = function () {
|
|
863
|
+
return $options.onNodeDrop && $options.onNodeDrop.apply($options, arguments);
|
|
864
|
+
})
|
|
514
865
|
}, $options.getPTOptions('nodeContent'), {
|
|
515
866
|
"data-p-selected": $options.checkboxMode ? $options.checked : $options.selected,
|
|
516
867
|
"data-p-selectable": $options.selectable
|
|
@@ -584,14 +935,20 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
584
935
|
selected: $options.checkboxMode ? $options.checked : $options.selected
|
|
585
936
|
}, null, 8, ["node", "expanded", "selected"])) : (openBlock(), createElementBlock(Fragment, {
|
|
586
937
|
key: 1
|
|
587
|
-
}, [createTextVNode(toDisplayString($options.label($props.node)), 1)], 64))], 16)], 16, _hoisted_2$1), $options.
|
|
588
|
-
key:
|
|
938
|
+
}, [createTextVNode(toDisplayString($options.label($props.node)), 1)], 64))], 16)], 16, _hoisted_2$1), $options.isNextDropPointActive ? (openBlock(), createElementBlock("div", {
|
|
939
|
+
key: 1,
|
|
940
|
+
"class": normalizeClass(_ctx.cx('dropPoint')),
|
|
941
|
+
"aria-hidden": "true"
|
|
942
|
+
}, null, 2)) : createCommentVNode("", true), $options.hasChildren && $options.expanded ? (openBlock(), createElementBlock("ul", mergeProps({
|
|
943
|
+
key: 2,
|
|
589
944
|
"class": _ctx.cx('nodeChildren'),
|
|
590
945
|
role: "group"
|
|
591
946
|
}, _ctx.ptm('nodeChildren')), [(openBlock(true), createElementBlock(Fragment, null, renderList($props.node.children, function (childNode, index) {
|
|
592
947
|
return openBlock(), createBlock(_component_TreeNode, {
|
|
593
948
|
key: childNode.key,
|
|
594
949
|
node: childNode,
|
|
950
|
+
parentNode: $props.node,
|
|
951
|
+
rootNodes: $props.rootNodes,
|
|
595
952
|
templates: $props.templates,
|
|
596
953
|
level: $props.level + 1,
|
|
597
954
|
index: index,
|
|
@@ -602,9 +959,25 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
602
959
|
selectionMode: $props.selectionMode,
|
|
603
960
|
selectionKeys: $props.selectionKeys,
|
|
604
961
|
onCheckboxChange: $options.propagateUp,
|
|
962
|
+
draggableScope: $props.draggableScope,
|
|
963
|
+
draggableNodes: $props.draggableNodes,
|
|
964
|
+
droppableNodes: $props.droppableNodes,
|
|
965
|
+
validateDrop: $props.validateDrop,
|
|
966
|
+
onNodeDrop: _cache[10] || (_cache[10] = function ($event) {
|
|
967
|
+
return _ctx.$emit('node-drop', $event);
|
|
968
|
+
}),
|
|
969
|
+
onNodeDragenter: _cache[11] || (_cache[11] = function ($event) {
|
|
970
|
+
return _ctx.$emit('node-dragenter', $event);
|
|
971
|
+
}),
|
|
972
|
+
onNodeDragleave: _cache[12] || (_cache[12] = function ($event) {
|
|
973
|
+
return _ctx.$emit('node-dragleave', $event);
|
|
974
|
+
}),
|
|
975
|
+
onValueChange: _cache[13] || (_cache[13] = function ($event) {
|
|
976
|
+
return _ctx.$emit('value-change', $event);
|
|
977
|
+
}),
|
|
605
978
|
unstyled: _ctx.unstyled,
|
|
606
979
|
pt: _ctx.pt
|
|
607
|
-
}, null, 8, ["node", "templates", "level", "index", "loadingMode", "expandedKeys", "onNodeToggle", "onNodeClick", "selectionMode", "selectionKeys", "onCheckboxChange", "unstyled", "pt"]);
|
|
980
|
+
}, null, 8, ["node", "parentNode", "rootNodes", "templates", "level", "index", "loadingMode", "expandedKeys", "onNodeToggle", "onNodeClick", "selectionMode", "selectionKeys", "onCheckboxChange", "draggableScope", "draggableNodes", "droppableNodes", "validateDrop", "unstyled", "pt"]);
|
|
608
981
|
}), 128))], 16)) : createCommentVNode("", true)], 16, _hoisted_1$1);
|
|
609
982
|
}
|
|
610
983
|
|
|
@@ -627,18 +1000,58 @@ var script = {
|
|
|
627
1000
|
name: 'Tree',
|
|
628
1001
|
"extends": script$2,
|
|
629
1002
|
inheritAttrs: false,
|
|
630
|
-
emits: ['node-expand', 'node-collapse', 'update:expandedKeys', 'update:selectionKeys', 'node-select', 'node-unselect', 'filter'],
|
|
1003
|
+
emits: ['node-expand', 'node-collapse', 'update:expandedKeys', 'update:selectionKeys', 'node-select', 'node-unselect', 'filter', 'node-drop', 'node-dragenter', 'node-dragleave', 'update:value', 'drag-enter', 'drag-leave'],
|
|
631
1004
|
data: function data() {
|
|
632
1005
|
return {
|
|
633
1006
|
d_expandedKeys: this.expandedKeys || {},
|
|
634
|
-
filterValue: null
|
|
1007
|
+
filterValue: null,
|
|
1008
|
+
dragNode: null,
|
|
1009
|
+
dragNodeSubNodes: null,
|
|
1010
|
+
dragNodeIndex: null,
|
|
1011
|
+
dragNodeScope: null,
|
|
1012
|
+
dragHover: null
|
|
635
1013
|
};
|
|
636
1014
|
},
|
|
1015
|
+
inject: {
|
|
1016
|
+
$pcTreeSelect: {
|
|
1017
|
+
"default": null
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
dragDropService: null,
|
|
1021
|
+
dragStartCleanup: null,
|
|
1022
|
+
dragStopCleanup: null,
|
|
637
1023
|
watch: {
|
|
638
1024
|
expandedKeys: function expandedKeys(newValue) {
|
|
639
1025
|
this.d_expandedKeys = newValue;
|
|
640
1026
|
}
|
|
641
1027
|
},
|
|
1028
|
+
mounted: function mounted() {
|
|
1029
|
+
var _this = this;
|
|
1030
|
+
if (this.droppableNodes) {
|
|
1031
|
+
this.dragDropService = useTreeDragDropService();
|
|
1032
|
+
this.dragStartCleanup = this.dragDropService.onDragStart(function (event) {
|
|
1033
|
+
_this.dragNode = event.node;
|
|
1034
|
+
_this.dragNodeSubNodes = event.subNodes;
|
|
1035
|
+
_this.dragNodeIndex = event.index;
|
|
1036
|
+
_this.dragNodeScope = event.scope;
|
|
1037
|
+
});
|
|
1038
|
+
this.dragStopCleanup = this.dragDropService.onDragStop(function () {
|
|
1039
|
+
_this.dragNode = null;
|
|
1040
|
+
_this.dragNodeSubNodes = null;
|
|
1041
|
+
_this.dragNodeIndex = null;
|
|
1042
|
+
_this.dragNodeScope = null;
|
|
1043
|
+
_this.dragHover = false;
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
beforeUnmount: function beforeUnmount() {
|
|
1048
|
+
if (this.dragStartCleanup) {
|
|
1049
|
+
this.dragStartCleanup();
|
|
1050
|
+
}
|
|
1051
|
+
if (this.dragStopCleanup) {
|
|
1052
|
+
this.dragStopCleanup();
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
642
1055
|
methods: {
|
|
643
1056
|
onNodeToggle: function onNodeToggle(node) {
|
|
644
1057
|
var key = node.key;
|
|
@@ -794,6 +1207,169 @@ var script = {
|
|
|
794
1207
|
}) || matched;
|
|
795
1208
|
}
|
|
796
1209
|
return matched;
|
|
1210
|
+
},
|
|
1211
|
+
onNodeDrop: function onNodeDrop(event) {
|
|
1212
|
+
this.$emit('node-drop', event);
|
|
1213
|
+
},
|
|
1214
|
+
onNodeDragEnter: function onNodeDragEnter(event) {
|
|
1215
|
+
this.$emit('node-dragenter', event);
|
|
1216
|
+
},
|
|
1217
|
+
onNodeDragLeave: function onNodeDragLeave(event) {
|
|
1218
|
+
this.$emit('node-dragleave', event);
|
|
1219
|
+
},
|
|
1220
|
+
onValueChanged: function onValueChanged(event) {
|
|
1221
|
+
this.dragNodeSubNodes.splice(this.dragNodeIndex, 1);
|
|
1222
|
+
this.$emit('update:value', event.nodes);
|
|
1223
|
+
},
|
|
1224
|
+
allowDrop: function allowDrop(dragNode, dropNode, dragNodeScope) {
|
|
1225
|
+
if (!dragNode) {
|
|
1226
|
+
//prevent random html elements to be dragged
|
|
1227
|
+
return false;
|
|
1228
|
+
} else if (this.isValidDragScope(dragNodeScope)) {
|
|
1229
|
+
var allow = true;
|
|
1230
|
+
if (dropNode) {
|
|
1231
|
+
if (dragNode === dropNode) {
|
|
1232
|
+
allow = false;
|
|
1233
|
+
} else {
|
|
1234
|
+
var parent = dropNode.parent;
|
|
1235
|
+
while (parent != null) {
|
|
1236
|
+
if (parent === dragNode) {
|
|
1237
|
+
allow = false;
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
parent = parent.parent;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return allow;
|
|
1245
|
+
} else {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
allowNodeDrop: function allowNodeDrop(dropNode) {
|
|
1250
|
+
return this.allowDrop(this.dragNode, dropNode, this.dragNodeScope);
|
|
1251
|
+
},
|
|
1252
|
+
hasCommonScope: function hasCommonScope(dragScope, dropScope) {
|
|
1253
|
+
if (dragScope === null && dropScope === null) {
|
|
1254
|
+
return true;
|
|
1255
|
+
} else if (dragScope === null || dropScope === null) {
|
|
1256
|
+
return false;
|
|
1257
|
+
}
|
|
1258
|
+
if (typeof dropScope === 'string') {
|
|
1259
|
+
if (typeof dragScope === 'string') {
|
|
1260
|
+
return dragScope === dropScope;
|
|
1261
|
+
} else if (Array.isArray(dragScope)) {
|
|
1262
|
+
return dragScope.indexOf(dropScope) !== -1;
|
|
1263
|
+
}
|
|
1264
|
+
} else if (Array.isArray(dropScope)) {
|
|
1265
|
+
if (typeof dragScope === 'string') {
|
|
1266
|
+
return dropScope.indexOf(dragScope) !== -1;
|
|
1267
|
+
} else if (Array.isArray(dragScope)) {
|
|
1268
|
+
var _iterator3 = _createForOfIteratorHelper(dragScope),
|
|
1269
|
+
_step3;
|
|
1270
|
+
try {
|
|
1271
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1272
|
+
var ds = _step3.value;
|
|
1273
|
+
if (dropScope.indexOf(ds) !== -1) {
|
|
1274
|
+
return true;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
} catch (err) {
|
|
1278
|
+
_iterator3.e(err);
|
|
1279
|
+
} finally {
|
|
1280
|
+
_iterator3.f();
|
|
1281
|
+
}
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
return false;
|
|
1286
|
+
},
|
|
1287
|
+
isValidDragScope: function isValidDragScope(dragScope) {
|
|
1288
|
+
if (this.droppableScope === null) {
|
|
1289
|
+
return true;
|
|
1290
|
+
}
|
|
1291
|
+
return this.hasCommonScope(dragScope, this.droppableScope);
|
|
1292
|
+
},
|
|
1293
|
+
isSameTreeScope: function isSameTreeScope(dragScope) {
|
|
1294
|
+
return this.hasCommonScope(dragScope, this.draggableScope);
|
|
1295
|
+
},
|
|
1296
|
+
onDragOver: function onDragOver(event) {
|
|
1297
|
+
if (this.droppableNodes && this.allowDrop(this.dragNode, null, this.dragNodeScope)) {
|
|
1298
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
1299
|
+
} else {
|
|
1300
|
+
event.dataTransfer.dropEffect = 'none';
|
|
1301
|
+
}
|
|
1302
|
+
event.preventDefault();
|
|
1303
|
+
},
|
|
1304
|
+
onDragEnter: function onDragEnter(event) {
|
|
1305
|
+
if (this.droppableNodes && this.allowDrop(this.dragNode, null, this.dragNodeScope)) {
|
|
1306
|
+
this.dragHover = true;
|
|
1307
|
+
this.$emit('drag-enter', {
|
|
1308
|
+
originalEvent: event,
|
|
1309
|
+
value: this.value,
|
|
1310
|
+
dragNode: this.dragNode,
|
|
1311
|
+
dragNodeScope: this.dragNodeScope
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1315
|
+
onDragLeave: function onDragLeave(event) {
|
|
1316
|
+
if (this.droppableNodes) {
|
|
1317
|
+
var rect = event.currentTarget.getBoundingClientRect();
|
|
1318
|
+
if (event.x >= parseInt(rect.right) || event.x <= parseInt(rect.left) || event.y >= parseInt(rect.bottom) || event.y <= parseInt(rect.top)) {
|
|
1319
|
+
this.dragHover = false;
|
|
1320
|
+
}
|
|
1321
|
+
this.$emit('drag-leave', {
|
|
1322
|
+
originalEvent: event,
|
|
1323
|
+
value: this.value,
|
|
1324
|
+
dragNode: this.dragNode,
|
|
1325
|
+
dragNodeScope: this.dragNodeScope
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
processTreeDrop: function processTreeDrop(dragNode, dragNodeIndex) {
|
|
1330
|
+
this.dragNodeSubNodes.splice(dragNodeIndex, 1);
|
|
1331
|
+
var newValue = [].concat(_toConsumableArray(this.value || []), [dragNode]);
|
|
1332
|
+
this.$emit('update:value', newValue);
|
|
1333
|
+
this.dragDropService.stopDrag({
|
|
1334
|
+
node: dragNode
|
|
1335
|
+
});
|
|
1336
|
+
},
|
|
1337
|
+
onDrop: function onDrop(event) {
|
|
1338
|
+
var _this2 = this;
|
|
1339
|
+
if (this.droppableNodes) {
|
|
1340
|
+
event.preventDefault();
|
|
1341
|
+
var dragNode = this.dragNode;
|
|
1342
|
+
if (this.allowDrop(dragNode, null, this.dragNodeScope)) {
|
|
1343
|
+
var dragNodeIndex = this.dragNodeIndex;
|
|
1344
|
+
if (this.isSameTreeScope(this.dragNodeScope)) {
|
|
1345
|
+
this.dragDropService.stopDrag({
|
|
1346
|
+
node: dragNode
|
|
1347
|
+
});
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
if (this.validateDrop) {
|
|
1351
|
+
this.$emit('node-drop', {
|
|
1352
|
+
originalEvent: event,
|
|
1353
|
+
value: this.value,
|
|
1354
|
+
dragNode: dragNode,
|
|
1355
|
+
dropNode: null,
|
|
1356
|
+
index: dragNodeIndex,
|
|
1357
|
+
accept: function accept() {
|
|
1358
|
+
_this2.processTreeDrop(dragNode, dragNodeIndex);
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
} else {
|
|
1362
|
+
this.$emit('node-drop', {
|
|
1363
|
+
originalEvent: event,
|
|
1364
|
+
value: this.value,
|
|
1365
|
+
dragNode: dragNode,
|
|
1366
|
+
dropNode: null,
|
|
1367
|
+
index: dragNodeIndex
|
|
1368
|
+
});
|
|
1369
|
+
this.processTreeDrop(dragNode, dragNodeIndex);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
797
1373
|
}
|
|
798
1374
|
},
|
|
799
1375
|
computed: {
|
|
@@ -802,11 +1378,11 @@ var script = {
|
|
|
802
1378
|
var searchFields = isFunction(this.filterBy) ? [this.filterBy] : this.filterBy.split(',');
|
|
803
1379
|
var filterText = this.filterValue.trim().toLocaleLowerCase(this.filterLocale);
|
|
804
1380
|
var strict = this.filterMode === 'strict';
|
|
805
|
-
var
|
|
806
|
-
|
|
1381
|
+
var _iterator4 = _createForOfIteratorHelper(this.value),
|
|
1382
|
+
_step4;
|
|
807
1383
|
try {
|
|
808
|
-
for (
|
|
809
|
-
var node =
|
|
1384
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1385
|
+
var node = _step4.value;
|
|
810
1386
|
var _node = _objectSpread$1({}, node);
|
|
811
1387
|
var paramsWithoutNode = {
|
|
812
1388
|
searchFields: searchFields,
|
|
@@ -818,15 +1394,22 @@ var script = {
|
|
|
818
1394
|
}
|
|
819
1395
|
}
|
|
820
1396
|
} catch (err) {
|
|
821
|
-
|
|
1397
|
+
_iterator4.e(err);
|
|
822
1398
|
} finally {
|
|
823
|
-
|
|
1399
|
+
_iterator4.f();
|
|
824
1400
|
}
|
|
825
1401
|
return filteredNodes;
|
|
826
1402
|
},
|
|
827
1403
|
valueToRender: function valueToRender() {
|
|
828
1404
|
if (this.filterValue && this.filterValue.trim().length > 0) return this.filteredValue;else return this.value;
|
|
829
1405
|
},
|
|
1406
|
+
empty: function empty() {
|
|
1407
|
+
return !this.valueToRender || this.valueToRender.length === 0;
|
|
1408
|
+
},
|
|
1409
|
+
emptyMessageText: function emptyMessageText() {
|
|
1410
|
+
var _this$$primevue$confi;
|
|
1411
|
+
return ((_this$$primevue$confi = this.$primevue.config) === null || _this$$primevue$confi === void 0 || (_this$$primevue$confi = _this$$primevue$confi.locale) === null || _this$$primevue$confi === void 0 ? void 0 : _this$$primevue$confi.emptyMessage) || '';
|
|
1412
|
+
},
|
|
830
1413
|
containerDataP: function containerDataP() {
|
|
831
1414
|
return cn({
|
|
832
1415
|
loading: this.loading,
|
|
@@ -867,6 +1450,18 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
867
1450
|
var _component_TreeNode = resolveComponent("TreeNode");
|
|
868
1451
|
return openBlock(), createElementBlock("div", mergeProps({
|
|
869
1452
|
"class": _ctx.cx('root'),
|
|
1453
|
+
onDragover: _cache[1] || (_cache[1] = function () {
|
|
1454
|
+
return $options.onDragOver && $options.onDragOver.apply($options, arguments);
|
|
1455
|
+
}),
|
|
1456
|
+
onDragenter: _cache[2] || (_cache[2] = function () {
|
|
1457
|
+
return $options.onDragEnter && $options.onDragEnter.apply($options, arguments);
|
|
1458
|
+
}),
|
|
1459
|
+
onDragleave: _cache[3] || (_cache[3] = function () {
|
|
1460
|
+
return $options.onDragLeave && $options.onDragLeave.apply($options, arguments);
|
|
1461
|
+
}),
|
|
1462
|
+
onDrop: _cache[4] || (_cache[4] = function () {
|
|
1463
|
+
return $options.onDrop && $options.onDrop.apply($options, arguments);
|
|
1464
|
+
}),
|
|
870
1465
|
"data-p": $options.containerDataP
|
|
871
1466
|
}, _ctx.ptmi('root')), [_ctx.loading && _ctx.loadingMode === 'mask' ? (openBlock(), createElementBlock("div", mergeProps({
|
|
872
1467
|
key: 0,
|
|
@@ -927,7 +1522,8 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
927
1522
|
value: _ctx.value,
|
|
928
1523
|
expandedKeys: _ctx.expandedKeys,
|
|
929
1524
|
selectionKeys: _ctx.selectionKeys
|
|
930
|
-
}),
|
|
1525
|
+
}), !$options.empty ? (openBlock(), createElementBlock("ul", mergeProps({
|
|
1526
|
+
key: 0,
|
|
931
1527
|
"class": _ctx.cx('rootChildren'),
|
|
932
1528
|
role: "tree",
|
|
933
1529
|
"aria-labelledby": _ctx.ariaLabelledby,
|
|
@@ -936,6 +1532,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
936
1532
|
return openBlock(), createBlock(_component_TreeNode, {
|
|
937
1533
|
key: node.key,
|
|
938
1534
|
node: node,
|
|
1535
|
+
rootNodes: $options.valueToRender,
|
|
939
1536
|
templates: _ctx.$slots,
|
|
940
1537
|
level: _ctx.level + 1,
|
|
941
1538
|
index: index,
|
|
@@ -946,10 +1543,23 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
946
1543
|
selectionKeys: _ctx.selectionKeys,
|
|
947
1544
|
onCheckboxChange: $options.onCheckboxChange,
|
|
948
1545
|
loadingMode: _ctx.loadingMode,
|
|
1546
|
+
draggableNodes: _ctx.draggableNodes,
|
|
1547
|
+
droppableNodes: _ctx.droppableNodes,
|
|
1548
|
+
draggableScope: _ctx.draggableScope,
|
|
1549
|
+
validateDrop: _ctx.validateDrop,
|
|
1550
|
+
onNodeDrop: $options.onNodeDrop,
|
|
1551
|
+
onNodeDragenter: $options.onNodeDragEnter,
|
|
1552
|
+
onNodeDragleave: $options.onNodeDragLeave,
|
|
1553
|
+
onValueChange: $options.onValueChanged,
|
|
949
1554
|
unstyled: _ctx.unstyled,
|
|
950
1555
|
pt: _ctx.pt
|
|
951
|
-
}, null, 8, ["node", "templates", "level", "index", "expandedKeys", "onNodeToggle", "onNodeClick", "selectionMode", "selectionKeys", "onCheckboxChange", "loadingMode", "unstyled", "pt"]);
|
|
952
|
-
}), 128))], 16, _hoisted_3)
|
|
1556
|
+
}, null, 8, ["node", "rootNodes", "templates", "level", "index", "expandedKeys", "onNodeToggle", "onNodeClick", "selectionMode", "selectionKeys", "onCheckboxChange", "loadingMode", "draggableNodes", "droppableNodes", "draggableScope", "validateDrop", "onNodeDrop", "onNodeDragenter", "onNodeDragleave", "onValueChange", "unstyled", "pt"]);
|
|
1557
|
+
}), 128))], 16, _hoisted_3)) : $options.empty && !$options.$pcTreeSelect ? (openBlock(), createElementBlock("div", mergeProps({
|
|
1558
|
+
key: 1,
|
|
1559
|
+
"class": _ctx.cx('emptyMessage')
|
|
1560
|
+
}, _ctx.ptm('emptyMessage')), [renderSlot(_ctx.$slots, "empty", {}, function () {
|
|
1561
|
+
return [createTextVNode(toDisplayString($options.emptyMessageText), 1)];
|
|
1562
|
+
})], 16)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "footer", {
|
|
953
1563
|
value: _ctx.value,
|
|
954
1564
|
expandedKeys: _ctx.expandedKeys,
|
|
955
1565
|
selectionKeys: _ctx.selectionKeys
|