@danielgindi/selectbox 2.0.28 → 2.0.30
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/dist/lib.cjs.js +23 -23
- 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 +23 -23
- 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 +23 -23
- 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/SelectBox.js +22 -22
- package/package.json +1 -1
- package/vue/SelectBox.vue +14 -5
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.30
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -3388,7 +3388,7 @@ const inputBackbufferCssProps = [
|
|
|
3388
3388
|
* @property {string|string[]} [additionalClasses]
|
|
3389
3389
|
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
3390
3390
|
* @property {boolean} [disabled=false] Should start as disabled?
|
|
3391
|
-
* @property {boolean} [
|
|
3391
|
+
* @property {boolean} [readOnly=false] Should start as readOnly?
|
|
3392
3392
|
* @property {boolean} [clearable=true] Has clear button?
|
|
3393
3393
|
* @property {boolean} [hasOpenIndicator=true] has open/close indicator?
|
|
3394
3394
|
* @property {string} [placeholder=''] Placeholder text
|
|
@@ -3434,7 +3434,7 @@ const DefaultOptions = {
|
|
|
3434
3434
|
el: null,
|
|
3435
3435
|
baseClassName: 'selectbox',
|
|
3436
3436
|
disabled: false,
|
|
3437
|
-
|
|
3437
|
+
readOnly: false,
|
|
3438
3438
|
clearable: true,
|
|
3439
3439
|
hasOpenIndicator: true,
|
|
3440
3440
|
placeholder: '',
|
|
@@ -3533,7 +3533,7 @@ class SelectBox {
|
|
|
3533
3533
|
listOptions: o.listOptions,
|
|
3534
3534
|
|
|
3535
3535
|
disabled: !!o.disabled,
|
|
3536
|
-
|
|
3536
|
+
readOnly: !!o.readOnly,
|
|
3537
3537
|
clearable: !!o.clearable,
|
|
3538
3538
|
hasOpenIndicator: !!o.hasOpenIndicator,
|
|
3539
3539
|
placeholder: o.placeholder,
|
|
@@ -3616,7 +3616,7 @@ class SelectBox {
|
|
|
3616
3616
|
p.multiItemEls = [];
|
|
3617
3617
|
|
|
3618
3618
|
this.enable(!p.disabled);
|
|
3619
|
-
this.setReadOnly(!p.
|
|
3619
|
+
this.setReadOnly(!p.readOnly);
|
|
3620
3620
|
|
|
3621
3621
|
this._setupDropdownMenu();
|
|
3622
3622
|
|
|
@@ -3845,18 +3845,18 @@ class SelectBox {
|
|
|
3845
3845
|
|
|
3846
3846
|
/**
|
|
3847
3847
|
* Sets read only mode
|
|
3848
|
-
* @param {boolean=true}
|
|
3848
|
+
* @param {boolean=true} readOnly Should the control be read only?
|
|
3849
3849
|
* @returns {SelectBox}
|
|
3850
3850
|
*/
|
|
3851
|
-
setReadOnly(
|
|
3851
|
+
setReadOnly(readOnly) {
|
|
3852
3852
|
const p = this._p;
|
|
3853
3853
|
|
|
3854
|
-
if (
|
|
3855
|
-
|
|
3854
|
+
if (readOnly === undefined) {
|
|
3855
|
+
readOnly = true;
|
|
3856
3856
|
}
|
|
3857
|
-
p.
|
|
3858
|
-
p.el.setAttribute('aria-
|
|
3859
|
-
p.input.
|
|
3857
|
+
p.readOnly = readOnly;
|
|
3858
|
+
p.el.setAttribute('aria-readOnly', p.readOnly.toString());
|
|
3859
|
+
p.input.readOnly = !(p.searchable || p.multi) || !!p.readOnly;
|
|
3860
3860
|
|
|
3861
3861
|
return this;
|
|
3862
3862
|
}
|
|
@@ -3866,7 +3866,7 @@ class SelectBox {
|
|
|
3866
3866
|
* @returns {boolean}
|
|
3867
3867
|
*/
|
|
3868
3868
|
isReadOnly() {
|
|
3869
|
-
return !this._p.
|
|
3869
|
+
return !this._p.readOnly;
|
|
3870
3870
|
}
|
|
3871
3871
|
|
|
3872
3872
|
/**
|
|
@@ -4996,7 +4996,7 @@ class SelectBox {
|
|
|
4996
4996
|
spellcheck: 'false',
|
|
4997
4997
|
role: 'textbox',
|
|
4998
4998
|
'aria-autocomplete': 'list',
|
|
4999
|
-
readOnly: !(p.searchable || p.multi),
|
|
4999
|
+
readOnly: !(p.searchable || p.multi) || !!p.readOnly,
|
|
5000
5000
|
}),
|
|
5001
5001
|
);
|
|
5002
5002
|
}
|
|
@@ -5030,7 +5030,7 @@ class SelectBox {
|
|
|
5030
5030
|
if (!closestUntil(evt.target, `.${p.baseClassName}__item_remove`, evt.currentTarget))
|
|
5031
5031
|
return;
|
|
5032
5032
|
|
|
5033
|
-
if (p.disabled || p.
|
|
5033
|
+
if (p.disabled || p.readOnly) return;
|
|
5034
5034
|
|
|
5035
5035
|
this._removeMultiItemFromEvent(
|
|
5036
5036
|
/**@type Element*/
|
|
@@ -5398,7 +5398,7 @@ class SelectBox {
|
|
|
5398
5398
|
|
|
5399
5399
|
setTimeout(() => {
|
|
5400
5400
|
if (this[DestroyedSymbol]) return; // destroyed by event handler
|
|
5401
|
-
if (p.disabled || p.
|
|
5401
|
+
if (p.disabled || p.readOnly) return;
|
|
5402
5402
|
|
|
5403
5403
|
this._trigger('search:blur');
|
|
5404
5404
|
|
|
@@ -5542,7 +5542,7 @@ class SelectBox {
|
|
|
5542
5542
|
!p.multi &&
|
|
5543
5543
|
!dropList.hasFocusedItem() &&
|
|
5544
5544
|
!p.disabled &&
|
|
5545
|
-
!p.
|
|
5545
|
+
!p.readOnly
|
|
5546
5546
|
)) {
|
|
5547
5547
|
this.toggleList();
|
|
5548
5548
|
evt.preventDefault();
|
|
@@ -5554,20 +5554,20 @@ class SelectBox {
|
|
|
5554
5554
|
if (p.input) {
|
|
5555
5555
|
p.sink
|
|
5556
5556
|
.add(p.input, 'input.dropdown', () => {
|
|
5557
|
-
if (p.disabled || p.
|
|
5557
|
+
if (p.disabled || p.readOnly) return;
|
|
5558
5558
|
|
|
5559
5559
|
p.filterTerm = p.input.value.trim();
|
|
5560
5560
|
p.dropList?.setSearchTerm(p.filterTerm, true);
|
|
5561
5561
|
})
|
|
5562
5562
|
.add(p.input, 'click.dropdown', () => {
|
|
5563
|
-
if (p.disabled || p.
|
|
5563
|
+
if (p.disabled || p.readOnly) return;
|
|
5564
5564
|
|
|
5565
5565
|
if (!p.multi && p.searchable) {
|
|
5566
5566
|
this.openList();
|
|
5567
5567
|
}
|
|
5568
5568
|
})
|
|
5569
5569
|
.add(p.input, 'focus.dropdown', () => {
|
|
5570
|
-
if (p.disabled || p.
|
|
5570
|
+
if (p.disabled || p.readOnly) return;
|
|
5571
5571
|
|
|
5572
5572
|
this._trigger('search:focus');
|
|
5573
5573
|
|
|
@@ -5584,7 +5584,7 @@ class SelectBox {
|
|
|
5584
5584
|
|
|
5585
5585
|
p.sink
|
|
5586
5586
|
.add(p.el, 'mousedown.dropdown', () => {
|
|
5587
|
-
if (!p.multi && !p.searchable && !avoidToggleFromClick && !p.disabled && !p.
|
|
5587
|
+
if (!p.multi && !p.searchable && !avoidToggleFromClick && !p.disabled && !p.readOnly) {
|
|
5588
5588
|
this.toggleList();
|
|
5589
5589
|
}
|
|
5590
5590
|
avoidToggleFromClick = false;
|
|
@@ -6187,7 +6187,7 @@ class SelectBox {
|
|
|
6187
6187
|
if (p.input) p.input.readOnly = false;
|
|
6188
6188
|
p.el.classList.add(`${p.baseClassName}__searchable`);
|
|
6189
6189
|
} else {
|
|
6190
|
-
if (p.input) p.input.readOnly =
|
|
6190
|
+
if (p.input) p.input.readOnly = p.readOnly;
|
|
6191
6191
|
p.el.classList.remove(`${p.baseClassName}__searchable`);
|
|
6192
6192
|
}
|
|
6193
6193
|
|
|
@@ -6569,7 +6569,7 @@ class SelectBox {
|
|
|
6569
6569
|
_handleMultiKeydown(event) {
|
|
6570
6570
|
const p = this._p;
|
|
6571
6571
|
|
|
6572
|
-
if (p.disabled || p.
|
|
6572
|
+
if (p.disabled || p.readOnly) return;
|
|
6573
6573
|
|
|
6574
6574
|
const isRtl = getComputedStyle(p.el).direction === 'rtl';
|
|
6575
6575
|
|