@danielgindi/selectbox 1.0.105 → 1.0.108
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/README.md +13 -0
- package/css/droplist.css +1 -1
- package/css/droplist.css.map +1 -1
- package/css/selectbox.css +1 -1
- package/css/selectbox.css.map +1 -1
- package/dist/lib.cjs.js +866 -241
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +59 -3
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +866 -241
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/lib/DropList.js +27 -0
- package/lib/SelectBox.js +31 -2
- package/package.json +13 -13
- package/scss/droplist.scss +35 -32
- package/scss/selectbox.scss +56 -36
- package/vue/DropList.vue +13 -0
- package/vue/SelectBox.vue +13 -0
- package/vue/utils/slots.js +4 -4
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 1.0.
|
|
2
|
+
* @danielgindi/selectbox 1.0.108
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -23,6 +23,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
23
23
|
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
24
24
|
* @property {string} [baseClassName='droplist'] class name for the menu root element
|
|
25
25
|
* @property {string|string[]} [additionalClasses]
|
|
26
|
+
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
26
27
|
* @property {boolean} [autoItemBlur=true] Should we automatically blur the focused item when the droplist loses focus?
|
|
27
28
|
* @property {number} [autoItemBlurDelay=300] How long to wait before deciding to blur the focused item (when the droplist loses focus)?
|
|
28
29
|
* @property {boolean} [capturesFocus=true] Should this DropList be added to the TAB-key stack?
|
|
@@ -139,6 +140,8 @@ class DropList {
|
|
|
139
140
|
|
|
140
141
|
baseClassName: o.baseClassName,
|
|
141
142
|
additionalClasses: o.additionalClasses,
|
|
143
|
+
direction: o.direction === 'ltr' ? 'ltr' : o.direction === 'rtl' ? 'rtl' : 'auto',
|
|
144
|
+
|
|
142
145
|
autoItemBlur: o.autoItemBlur,
|
|
143
146
|
autoItemBlurDelay: o.autoItemBlurDelay,
|
|
144
147
|
capturesFocus: o.capturesFocus,
|
|
@@ -362,6 +365,27 @@ class DropList {
|
|
|
362
365
|
return this;
|
|
363
366
|
}
|
|
364
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Sets the appropriate direction for the droplist
|
|
370
|
+
* @param {'ltr'|'rtl'|'auto'} direction
|
|
371
|
+
* @return {DropList}
|
|
372
|
+
*/
|
|
373
|
+
setDirection(direction) {
|
|
374
|
+
const p = this._p;
|
|
375
|
+
p.direction = direction === 'ltr' ? 'ltr' : direction === 'rtl' ? 'rtl' : 'auto';
|
|
376
|
+
this._syncBaseClasses();
|
|
377
|
+
return this;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Gets the supplied direction for the droplist
|
|
382
|
+
* @return {'ltr'|'rtl'|'auto'}
|
|
383
|
+
*/
|
|
384
|
+
getDirection() {
|
|
385
|
+
const p = this._p;
|
|
386
|
+
return p.direction;
|
|
387
|
+
}
|
|
388
|
+
|
|
365
389
|
/**
|
|
366
390
|
* @param {string} prop
|
|
367
391
|
* @returns {DropList}
|
|
@@ -436,6 +460,9 @@ class DropList {
|
|
|
436
460
|
|
|
437
461
|
let classes = [p.baseClassName];
|
|
438
462
|
|
|
463
|
+
if (p.direction === 'ltr' || p.direction === 'rtl')
|
|
464
|
+
classes.push(`${p.baseClassName}__` + p.direction);
|
|
465
|
+
|
|
439
466
|
if (p.additionalClasses) {
|
|
440
467
|
classes = classes.concat(p.additionalClasses);
|
|
441
468
|
}
|
|
@@ -2294,6 +2321,8 @@ const inputBackbufferCssProps = [
|
|
|
2294
2321
|
* @property {DropList.Options} [listOptions] options to pass to the `DropList`
|
|
2295
2322
|
* @property {Element} [el] An element to attach to, instead of creating a new one
|
|
2296
2323
|
* @property {string} [baseClassName='selectbox'] class name for the menu root element
|
|
2324
|
+
* @property {string|string[]} [additionalClasses]
|
|
2325
|
+
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
2297
2326
|
* @property {boolean} [disabled=false] Should start as disabled?
|
|
2298
2327
|
* @property {boolean} [clearable=true] Has clear button?
|
|
2299
2328
|
* @property {boolean} [hasOpenIndicator=true] has open/close indicator?
|
|
@@ -2332,7 +2361,6 @@ const inputBackbufferCssProps = [
|
|
|
2332
2361
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
2333
2362
|
* @property {function(items: DropList.ItemBase[], term: string):(DropList.ItemBase[]|null)} [filterFn]
|
|
2334
2363
|
* @property {function(name: string, ...args)} [on]
|
|
2335
|
-
* @property {string|string[]} [additionalClasses]
|
|
2336
2364
|
* @property {boolean} [isLoadingMode]
|
|
2337
2365
|
* */
|
|
2338
2366
|
const defaultOptions = {
|
|
@@ -2426,6 +2454,8 @@ class SelectBox {
|
|
|
2426
2454
|
ownsEl: true,
|
|
2427
2455
|
|
|
2428
2456
|
baseClassName: o.baseClassName,
|
|
2457
|
+
additionalClasses: o.additionalClasses,
|
|
2458
|
+
direction: o.direction === 'ltr' ? 'ltr' : o.direction === 'rtl' ? 'rtl' : 'auto',
|
|
2429
2459
|
|
|
2430
2460
|
listOptions: o.listOptions,
|
|
2431
2461
|
|
|
@@ -2469,7 +2499,6 @@ class SelectBox {
|
|
|
2469
2499
|
on: o.on || null,
|
|
2470
2500
|
silenceEvents: true,
|
|
2471
2501
|
mitt: mitt(),
|
|
2472
|
-
additionalClasses: o.additionalClasses,
|
|
2473
2502
|
|
|
2474
2503
|
isLoadingMode: !!o.isLoadingMode,
|
|
2475
2504
|
|
|
@@ -3576,6 +3605,9 @@ class SelectBox {
|
|
|
3576
3605
|
|
|
3577
3606
|
this._trigger('open:before', { list: p.dropList });
|
|
3578
3607
|
|
|
3608
|
+
// Propagate direction to droplist
|
|
3609
|
+
p.dropList.setDirection(getComputedStyle(p.el).direction);
|
|
3610
|
+
|
|
3579
3611
|
p.dropList.show(this._getDropListPositionOptions());
|
|
3580
3612
|
this._repositionDropList();
|
|
3581
3613
|
|
|
@@ -3670,6 +3702,27 @@ class SelectBox {
|
|
|
3670
3702
|
return this._p.isLoadingMode;
|
|
3671
3703
|
}
|
|
3672
3704
|
|
|
3705
|
+
/**
|
|
3706
|
+
* Sets the appropriate direction for the selectbox
|
|
3707
|
+
* @param {'ltr'|'rtl'|'auto'} direction
|
|
3708
|
+
* @return {SelectBox}
|
|
3709
|
+
*/
|
|
3710
|
+
setDirection(direction) {
|
|
3711
|
+
const p = this._p;
|
|
3712
|
+
p.direction = direction === 'ltr' ? 'ltr' : direction === 'rtl' ? 'rtl' : 'auto';
|
|
3713
|
+
this._syncBaseClasses();
|
|
3714
|
+
return this;
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
/**
|
|
3718
|
+
* Gets the supplied direction for the selectbox
|
|
3719
|
+
* @return {'ltr'|'rtl'|'auto'}
|
|
3720
|
+
*/
|
|
3721
|
+
getDirection() {
|
|
3722
|
+
const p = this._p;
|
|
3723
|
+
return p.direction;
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3673
3726
|
/**
|
|
3674
3727
|
* Can be called in case that the selectbox was attached to the dom late and has a weird size.
|
|
3675
3728
|
* @returns {SelectBox}
|
|
@@ -3920,6 +3973,9 @@ class SelectBox {
|
|
|
3920
3973
|
if (p.searchable || p.multi)
|
|
3921
3974
|
classes.push(`${p.baseClassName}__searchable`);
|
|
3922
3975
|
|
|
3976
|
+
if (p.direction === 'ltr' || p.direction === 'rtl')
|
|
3977
|
+
classes.push(`${p.baseClassName}__` + p.direction);
|
|
3978
|
+
|
|
3923
3979
|
if (p.additionalClasses) {
|
|
3924
3980
|
classes = classes.concat(p.additionalClasses);
|
|
3925
3981
|
}
|