Skip to content

Commit e25e1c9

Browse files
author
WAY2\david.desmaisons
committed
Passing attribute from draggable component to create fathet component
1 parent 725c98d commit e25e1c9

File tree

6 files changed

+36
-20
lines changed

6 files changed

+36
-20
lines changed

dist/vuedraggable.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
'use strict';
2+
3+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4+
25
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
36

47
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
@@ -99,6 +102,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
99102
move: {
100103
type: Function,
101104
default: null
105+
},
106+
componentProps: {
107+
type: Object,
108+
required: false,
109+
default: null
102110
}
103111
};
104112

@@ -128,7 +136,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
128136
if (footer) {
129137
children = slots ? [].concat(_toConsumableArray(slots), _toConsumableArray(footer)) : [].concat(_toConsumableArray(footer));
130138
}
131-
return h(this.element, null, children);
139+
var attributes = this.componentProps ? { attrs: this.componentProps } : null;
140+
return h(this.element, attributes, children);
132141
},
133142
mounted: function mounted() {
134143
var _this3 = this;
@@ -365,7 +374,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
365374
return draggableComponent;
366375
}
367376

368-
if (typeof exports == "object") {
377+
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == "object") {
369378
var Sortable = require("sortablejs");
370379
module.exports = buildDraggable(Sortable);
371380
} else if (typeof define == "function" && define.amd) {
@@ -375,13 +384,5 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
375384
} else if (window && window.Vue && window.Sortable) {
376385
var draggable = buildDraggable(window.Sortable);
377386
Vue.component('draggable', draggable);
378-
} else {
379-
if(typeof window.Vue == "undefined") {
380-
throw 'Vue.js not found!';
381-
}
382-
383-
if(typeof window.Sortable == "undefined") {
384-
throw 'Sortable.js not found!';
385-
}
386387
}
387388
})();

dist/vuedraggable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Component2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<v-container>
2020
Hello world
2121

22-
<draggable element="v-layout" :list="listA" :options="sortOptions">
23-
<v-flex v-for="(element, index) in listA" :key="element.name">
22+
<draggable element="v-layout" :list="listA" :options="sortOptions" row wrap>
23+
<v-flex v-for="(element, index) in listA" :key="element.name" lg12>
2424
<span>{{ element.name }}</span>
2525
</v-flex>
2626
</draggable>

examples/dist/vuedraggable.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
110110
data: function data() {
111111
return {
112112
transitionMode: false,
113-
componentMode: false
113+
noneFunctionalComponentMode: false,
114+
init: false
114115
};
115116
},
116117
render: function render(h) {
@@ -132,8 +133,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
132133
mounted: function mounted() {
133134
var _this3 = this;
134135

135-
this.componentMode = this.element.toLowerCase() !== this.$el.nodeName.toLowerCase();
136-
if (this.componentMode && this.transitionMode) {
136+
this.noneFunctionalComponentMode = this.element.toLowerCase() !== this.$el.nodeName.toLowerCase();
137+
if (this.noneFunctionalComponentMode && this.transitionMode) {
137138
throw new Error('Transition-group inside component is not supported. Please alter element value or remove transition-group. Current element value: ' + this.element);
138139
}
139140
var optionsAdded = {};
@@ -189,7 +190,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
189190

190191
methods: {
191192
getChildrenNodes: function getChildrenNodes() {
192-
if (this.componentMode) {
193+
if (!this.init) {
194+
this.noneFunctionalComponentMode = this.noneFunctionalComponentMode && this.$children.length == 1;
195+
this.init = true;
196+
}
197+
198+
if (this.noneFunctionalComponentMode) {
193199
return this.$children[0].$slots.default;
194200
}
195201
var rawNodes = this.$slots.default;
@@ -359,7 +365,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
359365
return draggableComponent;
360366
}
361367

362-
if (typeof exports == "object") {
368+
if (typeof exports == "object") {
363369
var Sortable = require("sortablejs");
364370
module.exports = buildDraggable(Sortable);
365371
} else if (typeof define == "function" && define.amd) {
@@ -369,5 +375,13 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
369375
} else if (window && window.Vue && window.Sortable) {
370376
var draggable = buildDraggable(window.Sortable);
371377
Vue.component('draggable', draggable);
378+
} else {
379+
if(typeof window.Vue == "undefined") {
380+
throw 'Vue.js not found!';
381+
}
382+
383+
if(typeof window.Sortable == "undefined") {
384+
throw 'Sortable.js not found!';
385+
}
372386
}
373387
})();

0 commit comments

Comments
 (0)