@@ -60,11 +60,14 @@ return /******/ (function(modules) { // webpackBootstrap
6060 Object . defineProperty ( exports , "__esModule" , {
6161 value : true
6262 } ) ;
63+ exports . default = undefined ;
6364
64- 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 ; } ;
65+ var _typeof = typeof Symbol === " function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol ? "symbol" : typeof obj ; } ;
6566
6667 var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
6768
69+ var _class , _temp2 ;
70+
6871 var _react = __webpack_require__ ( 1 ) ;
6972
7073 var _react2 = _interopRequireDefault ( _react ) ;
@@ -79,161 +82,102 @@ return /******/ (function(modules) { // webpackBootstrap
7982
8083 function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
8184
85+ function _objectWithoutProperties ( obj , keys ) { var target = { } ; for ( var i in obj ) { if ( keys . indexOf ( i ) >= 0 ) continue ; if ( ! Object . prototype . hasOwnProperty . call ( obj , i ) ) continue ; target [ i ] = obj [ i ] ; } return target ; }
86+
8287 function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
8388
8489 function _possibleConstructorReturn ( self , call ) { if ( ! self ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return call && ( typeof call === "object" || typeof call === "function" ) ? call : self ; }
8590
8691 function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
8792
88- var defaultOptions = {
89- ref : 'list'
90- } ;
91-
9293 var store = {
9394 nextSibling : null ,
9495 activeComponent : null
9596 } ;
9697
97- var refName = 'sortableComponent' ;
98+ var _default = ( _temp2 = _class = function ( _React$Component ) {
99+ _inherits ( _default , _React$Component ) ;
98100
99- var extend = function extend ( target ) {
100- for ( var _len = arguments . length , sources = Array ( _len > 1 ? _len - 1 : 0 ) , _key = 1 ; _key < _len ; _key ++ ) {
101- sources [ _key - 1 ] = arguments [ _key ] ;
102- }
101+ function _default ( ) {
102+ var _Object$getPrototypeO ;
103103
104- if ( target === undefined || target === null ) {
105- throw new TypeError ( 'Cannot convert undefined or null to object' ) ;
106- }
104+ var _temp , _this , _ret ;
107105
108- var output = Object ( target ) ;
109- for ( var index = 0 ; index < sources . length ; index ++ ) {
110- var source = sources [ index ] ;
111- if ( source !== undefined && source !== null ) {
112- for ( var key in source ) {
113- if ( source . hasOwnProperty ( key ) ) {
114- output [ key ] = source [ key ] ;
115- }
116- }
106+ _classCallCheck ( this , _default ) ;
107+
108+ for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
109+ args [ _key ] = arguments [ _key ] ;
117110 }
111+
112+ return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , ( _Object$getPrototypeO = Object . getPrototypeOf ( _default ) ) . call . apply ( _Object$getPrototypeO , [ this ] . concat ( args ) ) ) , _this ) , _this . sortable = null , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
118113 }
119- return output ;
120- } ;
121114
122- var SortableMixin = function SortableMixin ( ) {
123- var options = arguments . length <= 0 || arguments [ 0 ] === undefined ? defaultOptions : arguments [ 0 ] ;
124- return function ( Component ) {
125- var _class , _temp2 ;
126-
127- return _temp2 = _class = function ( _React$Component ) {
128- _inherits ( _class , _React$Component ) ;
129-
130- function _class ( ) {
131- var _Object$getPrototypeO ;
132-
133- var _temp , _this , _ret ;
134-
135- _classCallCheck ( this , _class ) ;
136-
137- for ( var _len2 = arguments . length , args = Array ( _len2 ) , _key2 = 0 ; _key2 < _len2 ; _key2 ++ ) {
138- args [ _key2 ] = arguments [ _key2 ] ;
139- }
140-
141- return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , ( _Object$getPrototypeO = Object . getPrototypeOf ( _class ) ) . call . apply ( _Object$getPrototypeO , [ this ] . concat ( args ) ) ) , _this ) , _this . state = {
142- sortableInstance : null
143- } , _this . sortableOptions = extend ( { } , defaultOptions , options ) , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
144- }
145-
146- _createClass ( _class , [ {
147- key : 'componentDidMount' ,
148- value : function componentDidMount ( ) {
149- var _this2 = this ;
150-
151- [ // Bind callbacks
152- 'onStart' , 'onEnd' , 'onAdd' , 'onSort' , 'onUpdate' , 'onRemove' , 'onFilter' , 'onMove' ] . forEach ( function ( name ) {
153- _this2 . sortableOptions [ name ] = function ( evt ) {
154- if ( name === 'onStart' ) {
155- store . nextSibling = evt . item . nextElementSibling ;
156- store . activeComponent = _this2 ;
157- } else if ( name === 'onAdd' || name === 'onUpdate' ) {
158- evt . from . insertBefore ( evt . item , store . nextSibling ) ;
159-
160- var oldIndex = evt . oldIndex ;
161- var newIndex = evt . newIndex ;
162- var items = _this2 . props . items ;
163- var remoteItems = [ ] ;
164-
165- if ( name === 'onAdd' ) {
166- remoteItems = store . activeComponent . props . items ;
167- var item = remoteItems . splice ( oldIndex , 1 ) [ 0 ] ;
168- items . splice ( newIndex , 0 , item ) ;
169- } else {
170- items . splice ( newIndex , 0 , items . splice ( oldIndex , 1 ) [ 0 ] ) ;
171- }
172-
173- // Called by any change to the list (add / update / remove)
174- _this2 . props . onSort ( items ) ;
175-
176- if ( store . activeComponent !== _this2 ) {
177- store . activeComponent . props . onSort ( remoteItems ) ;
178- }
115+ _createClass ( _default , [ {
116+ key : 'componentDidMount' ,
117+ value : function componentDidMount ( ) {
118+ var _this2 = this ;
119+
120+ var _props = this . props ;
121+ var children = _props . children ;
122+ var className = _props . className ;
123+
124+ var options = _objectWithoutProperties ( _props , [ 'children' , 'className' ] ) ;
125+
126+ [ 'onStart' , 'onEnd' , 'onAdd' , 'onSort' , 'onUpdate' , 'onRemove' , 'onFilter' , 'onMove' ] . forEach ( function ( name ) {
127+ var eventHandler = options [ name ] ;
128+
129+ options [ name ] = function ( evt ) {
130+ if ( name === 'onStart' ) {
131+ store . nextSibling = evt . item . nextElementSibling ;
132+ store . activeComponent = _this2 ;
133+ } else if ( ( name === 'onAdd' || name === 'onUpdate' ) && _this2 . props . onChange ) {
134+ var items = _this2 . sortable . toArray ( ) ;
135+ var remote = store . activeComponent ;
136+ var remoteItems = remote . sortable . toArray ( ) ;
137+
138+ evt . from . insertBefore ( evt . item , store . nextSibling ) ;
139+
140+ if ( remote !== _this2 ) {
141+ if ( _typeof ( remote . props . group ) === 'object' && remote . props . group . pull === 'clone' ) {
142+ // Remove the node with the same data-reactid
143+ evt . item . parentNode . removeChild ( evt . item ) ;
179144 }
180145
181- setTimeout ( function ( ) {
182- _this2 . props [ name ] && _this2 . props [ name ] ( evt , _this2 . state . sortableInstance ) ;
183- } , 0 ) ;
184- } ;
185- } ) ;
186-
187- var sortableComponent = this . refs [ refName ] ;
188- this . initSortable ( sortableComponent ) ;
189- }
190- } , {
191- key : 'componentDidUpdate' ,
192- value : function componentDidUpdate ( prevProps , prevState ) {
193- var model = this . sortableOptions . model ;
194- var prevItems = prevProps [ model ] ;
195- var currItems = this . props [ model ] ;
196- if ( prevItems !== currItems ) {
197- this . initSortable ( this . refs [ refName ] ) ;
198- }
199- }
200- } , {
201- key : 'componentWillUnmount' ,
202- value : function componentWillUnmount ( ) {
203- this . destroySortable ( ) ;
204- }
205- } , {
206- key : 'initSortable' ,
207- value : function initSortable ( sortableComponent ) {
208- this . destroySortable ( ) ;
209- var domNode = _reactDom2 . default . findDOMNode ( sortableComponent . refs [ this . sortableOptions . ref ] || sortableComponent ) ;
210- var sortableInstance = _sortablejs2 . default . create ( domNode , this . sortableOptions ) ;
211- this . setState ( { sortableInstance : sortableInstance } ) ;
212- }
213- } , {
214- key : 'destroySortable' ,
215- value : function destroySortable ( ) {
216- if ( this . state . sortableInstance ) {
217- this . state . sortableInstance . destroy ( ) ;
218- this . setState ( { sortableInstance : null } ) ;
146+ remote . props . onChange && remote . props . onChange ( remoteItems , remote . sortable ) ;
147+ }
148+
149+ _this2 . props . onChange && _this2 . props . onChange ( items , _this2 . sortable ) ;
219150 }
220- }
221- } , {
222- key : 'render' ,
223- value : function render ( ) {
224- return _react2 . default . createElement ( Component , _extends ( { ref : refName } , this . props , this . state ) ) ;
225- }
226- } ] ) ;
227-
228- return _class ;
229- } ( _react2 . default . Component ) , _class . propTypes = {
230- items : _react2 . default . PropTypes . array . isRequired ,
231- onSort : _react2 . default . PropTypes . func . isRequired
232- } , _temp2 ;
233- } ;
234- } ;
235151
236- exports . default = SortableMixin ;
152+ setTimeout ( function ( ) {
153+ eventHandler && eventHandler ( evt ) ;
154+ } , 0 ) ;
155+ } ;
156+ } ) ;
157+
158+ this . sortable = _sortablejs2 . default . create ( _reactDom2 . default . findDOMNode ( this ) , options ) ;
159+ }
160+ } , {
161+ key : 'render' ,
162+ value : function render ( ) {
163+ var _props2 = this . props ;
164+ var children = _props2 . children ;
165+ var className = _props2 . className ;
166+ var tag = _props2 . tag ;
167+
168+ return _react2 . default . DOM [ tag ] ( { className : className } , children ) ;
169+ }
170+ } ] ) ;
171+
172+ return _default ;
173+ } ( _react2 . default . Component ) , _class . propTypes = {
174+ onChange : _react2 . default . PropTypes . func ,
175+ tag : _react2 . default . PropTypes . string
176+ } , _class . defaultProps = {
177+ tag : 'div'
178+ } , _temp2 ) ;
179+
180+ exports . default = _default ;
237181
238182/***/ } ,
239183/* 1 */
0 commit comments