@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
value : true
5
5
} ) ;
6
6
7
- 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 ; } ;
8
-
9
7
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 ; } ;
10
8
9
+ 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 ; } ;
10
+
11
11
exports . position = position ;
12
12
exports . placement = placement ;
13
- exports . opposite = opposite ;
13
+ exports . complete = complete ;
14
14
exports . intersection = intersection ;
15
15
exports . strip = strip ;
16
16
exports . amend = amend ;
@@ -105,32 +105,23 @@ function placement(place, content, origin) {
105
105
}
106
106
107
107
/**
108
- * Returns an opposite direction based on the given.
108
+ * Completes missing directions in given direction(s) .
109
109
*
110
- * @param {string|Array } dir - 'top', 'right', 'bottom', or 'left'.
111
- * @return {string } an opposite direction.
112
- * @throw
110
+ * @param {string|Array } dir - a direction or a list of directions.
111
+ * @return {Array }
113
112
*/
114
- function opposite ( dir ) {
115
- var place = dir ;
116
-
117
- // Alrays use first direction if Array is passed
118
- if ( ( typeof place === 'undefined' ? 'undefined' : _typeof ( place ) ) === 'object' && typeof place . length === 'number' && 0 < place . length ) {
119
- place = place [ 0 ] ;
120
- }
121
-
122
- switch ( place ) {
123
- case 'top' :
124
- return 'bottom' ;
125
- case 'bottom' :
126
- return 'top' ;
127
- case 'right' :
128
- return 'left' ;
129
- case 'left' :
130
- return 'right' ;
113
+ var DIRS = [ 'top' , 'right' , 'bottom' , 'left' ] ;
114
+ function complete ( dir ) {
115
+ if ( typeof dir === 'string' ) {
116
+ dir = [ dir ] ;
117
+ } else {
118
+ dir = [ ] . concat ( _toConsumableArray ( dir ) ) ;
131
119
}
132
120
133
- throw new Error ( 'Unknown direction: "' + dir + '"' ) ;
121
+ var missings = DIRS . filter ( function ( d ) {
122
+ return dir . indexOf ( d ) === - 1 ;
123
+ } ) ;
124
+ return dir . concat ( missings ) ;
134
125
}
135
126
136
127
/**
@@ -234,7 +225,7 @@ function overDirs(tip, el) {
234
225
* Places and adjusts a tooltip.
235
226
*
236
227
* @param {Object } content - DOM element which contans a content.
237
- * @param {Object } props
228
+ * @param {Object } props - props set from Tooltip component.
238
229
* @return {Object } 'offset': style data to locate, 'place': final direction of the tooltip
239
230
*/
240
231
function adjust ( content , props ) {
@@ -249,8 +240,8 @@ function adjust(content, props) {
249
240
return p . trim ( ) ;
250
241
} ) ;
251
242
}
252
- if ( auto && place . length === 1 ) {
253
- place . push ( opposite ( place ) ) ;
243
+ if ( auto ) {
244
+ place = complete ( place ) ;
254
245
}
255
246
256
247
var pos = undefined ,
0 commit comments