1
+ 'use strict' ;
2
+
3
+ Object . defineProperty ( exports , "__esModule" , {
4
+ value : true
5
+ } ) ;
6
+
7
+ 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 ; } ; } ( ) ;
8
+
9
+ var _find = require ( 'lodash/find' ) ;
10
+
11
+ var _find2 = _interopRequireDefault ( _find ) ;
12
+
13
+ var _sortBy = require ( 'lodash/sortBy' ) ;
14
+
15
+ var _sortBy2 = _interopRequireDefault ( _sortBy ) ;
16
+
17
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
18
+
19
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
20
+
21
+ var Manager = function ( ) {
22
+ function Manager ( ) {
23
+ _classCallCheck ( this , Manager ) ;
24
+
25
+ this . refs = { } ;
26
+ }
27
+
28
+ _createClass ( Manager , [ {
29
+ key : 'add' ,
30
+ value : function add ( collection , ref ) {
31
+ if ( ! this . refs [ collection ] ) {
32
+ this . refs [ collection ] = [ ] ;
33
+ }
34
+
35
+ this . refs [ collection ] . push ( ref ) ;
36
+ }
37
+ } , {
38
+ key : 'remove' ,
39
+ value : function remove ( collection , ref ) {
40
+ var index = this . getIndex ( collection , ref ) ;
41
+
42
+ if ( index !== - 1 ) {
43
+ this . refs [ collection ] . splice ( index , 1 ) ;
44
+ }
45
+ }
46
+ } , {
47
+ key : 'isActive' ,
48
+ value : function isActive ( ) {
49
+ return this . active ;
50
+ }
51
+ } , {
52
+ key : 'getActive' ,
53
+ value : function getActive ( ) {
54
+ var _this = this ;
55
+
56
+ return ( 0 , _find2 . default ) ( this . refs [ this . active . collection ] ,
57
+ // eslint-disable-next-line eqeqeq
58
+ function ( _ref ) {
59
+ var node = _ref . node ;
60
+ return node . sortableInfo . index == _this . active . index ;
61
+ } ) ;
62
+ }
63
+ } , {
64
+ key : 'getIndex' ,
65
+ value : function getIndex ( collection , ref ) {
66
+ return this . refs [ collection ] . indexOf ( ref ) ;
67
+ }
68
+ } , {
69
+ key : 'getOrderedRefs' ,
70
+ value : function getOrderedRefs ( ) {
71
+ var collection = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : this . active . collection ;
72
+
73
+ return ( 0 , _sortBy2 . default ) ( this . refs [ collection ] , function ( _ref2 ) {
74
+ var node = _ref2 . node ;
75
+ return node . sortableInfo . index ;
76
+ } ) ;
77
+ }
78
+ } ] ) ;
79
+
80
+ return Manager ;
81
+ } ( ) ;
82
+
83
+ exports . default = Manager ;
0 commit comments