@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/lib/SelectBox.js
CHANGED
|
@@ -78,7 +78,7 @@ const inputBackbufferCssProps = [
|
|
|
78
78
|
* @property {string|string[]} [additionalClasses]
|
|
79
79
|
* @property {'ltr'|'rtl'|'auto'} [direction='auto']
|
|
80
80
|
* @property {boolean} [disabled=false] Should start as disabled?
|
|
81
|
-
* @property {boolean} [
|
|
81
|
+
* @property {boolean} [readOnly=false] Should start as readOnly?
|
|
82
82
|
* @property {boolean} [clearable=true] Has clear button?
|
|
83
83
|
* @property {boolean} [hasOpenIndicator=true] has open/close indicator?
|
|
84
84
|
* @property {string} [placeholder=''] Placeholder text
|
|
@@ -124,7 +124,7 @@ export const DefaultOptions = {
|
|
|
124
124
|
el: null,
|
|
125
125
|
baseClassName: 'selectbox',
|
|
126
126
|
disabled: false,
|
|
127
|
-
|
|
127
|
+
readOnly: false,
|
|
128
128
|
clearable: true,
|
|
129
129
|
hasOpenIndicator: true,
|
|
130
130
|
placeholder: '',
|
|
@@ -223,7 +223,7 @@ class SelectBox {
|
|
|
223
223
|
listOptions: o.listOptions,
|
|
224
224
|
|
|
225
225
|
disabled: !!o.disabled,
|
|
226
|
-
|
|
226
|
+
readOnly: !!o.readOnly,
|
|
227
227
|
clearable: !!o.clearable,
|
|
228
228
|
hasOpenIndicator: !!o.hasOpenIndicator,
|
|
229
229
|
placeholder: o.placeholder,
|
|
@@ -306,7 +306,7 @@ class SelectBox {
|
|
|
306
306
|
p.multiItemEls = [];
|
|
307
307
|
|
|
308
308
|
this.enable(!p.disabled);
|
|
309
|
-
this.setReadOnly(!p.
|
|
309
|
+
this.setReadOnly(!p.readOnly);
|
|
310
310
|
|
|
311
311
|
this._setupDropdownMenu();
|
|
312
312
|
|
|
@@ -535,18 +535,18 @@ class SelectBox {
|
|
|
535
535
|
|
|
536
536
|
/**
|
|
537
537
|
* Sets read only mode
|
|
538
|
-
* @param {boolean=true}
|
|
538
|
+
* @param {boolean=true} readOnly Should the control be read only?
|
|
539
539
|
* @returns {SelectBox}
|
|
540
540
|
*/
|
|
541
|
-
setReadOnly(
|
|
541
|
+
setReadOnly(readOnly) {
|
|
542
542
|
const p = this._p;
|
|
543
543
|
|
|
544
|
-
if (
|
|
545
|
-
|
|
544
|
+
if (readOnly === undefined) {
|
|
545
|
+
readOnly = true;
|
|
546
546
|
}
|
|
547
|
-
p.
|
|
548
|
-
p.el.setAttribute('aria-
|
|
549
|
-
p.input.
|
|
547
|
+
p.readOnly = readOnly;
|
|
548
|
+
p.el.setAttribute('aria-readOnly', p.readOnly.toString());
|
|
549
|
+
p.input.readOnly = !(p.searchable || p.multi) || !!p.readOnly;
|
|
550
550
|
|
|
551
551
|
return this;
|
|
552
552
|
}
|
|
@@ -556,7 +556,7 @@ class SelectBox {
|
|
|
556
556
|
* @returns {boolean}
|
|
557
557
|
*/
|
|
558
558
|
isReadOnly() {
|
|
559
|
-
return !this._p.
|
|
559
|
+
return !this._p.readOnly;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
/**
|
|
@@ -1686,7 +1686,7 @@ class SelectBox {
|
|
|
1686
1686
|
spellcheck: 'false',
|
|
1687
1687
|
role: 'textbox',
|
|
1688
1688
|
'aria-autocomplete': 'list',
|
|
1689
|
-
readOnly: !(p.searchable || p.multi),
|
|
1689
|
+
readOnly: !(p.searchable || p.multi) || !!p.readOnly,
|
|
1690
1690
|
}),
|
|
1691
1691
|
);
|
|
1692
1692
|
}
|
|
@@ -1720,7 +1720,7 @@ class SelectBox {
|
|
|
1720
1720
|
if (!closestUntil(evt.target, `.${p.baseClassName}__item_remove`, evt.currentTarget))
|
|
1721
1721
|
return;
|
|
1722
1722
|
|
|
1723
|
-
if (p.disabled || p.
|
|
1723
|
+
if (p.disabled || p.readOnly) return;
|
|
1724
1724
|
|
|
1725
1725
|
this._removeMultiItemFromEvent(
|
|
1726
1726
|
/**@type Element*/
|
|
@@ -2088,7 +2088,7 @@ class SelectBox {
|
|
|
2088
2088
|
|
|
2089
2089
|
setTimeout(() => {
|
|
2090
2090
|
if (this[DestroyedSymbol]) return; // destroyed by event handler
|
|
2091
|
-
if (p.disabled || p.
|
|
2091
|
+
if (p.disabled || p.readOnly) return;
|
|
2092
2092
|
|
|
2093
2093
|
this._trigger('search:blur');
|
|
2094
2094
|
|
|
@@ -2232,7 +2232,7 @@ class SelectBox {
|
|
|
2232
2232
|
!p.multi &&
|
|
2233
2233
|
!dropList.hasFocusedItem() &&
|
|
2234
2234
|
!p.disabled &&
|
|
2235
|
-
!p.
|
|
2235
|
+
!p.readOnly
|
|
2236
2236
|
)) {
|
|
2237
2237
|
this.toggleList();
|
|
2238
2238
|
evt.preventDefault();
|
|
@@ -2244,20 +2244,20 @@ class SelectBox {
|
|
|
2244
2244
|
if (p.input) {
|
|
2245
2245
|
p.sink
|
|
2246
2246
|
.add(p.input, 'input.dropdown', () => {
|
|
2247
|
-
if (p.disabled || p.
|
|
2247
|
+
if (p.disabled || p.readOnly) return;
|
|
2248
2248
|
|
|
2249
2249
|
p.filterTerm = p.input.value.trim();
|
|
2250
2250
|
p.dropList?.setSearchTerm(p.filterTerm, true);
|
|
2251
2251
|
})
|
|
2252
2252
|
.add(p.input, 'click.dropdown', () => {
|
|
2253
|
-
if (p.disabled || p.
|
|
2253
|
+
if (p.disabled || p.readOnly) return;
|
|
2254
2254
|
|
|
2255
2255
|
if (!p.multi && p.searchable) {
|
|
2256
2256
|
this.openList();
|
|
2257
2257
|
}
|
|
2258
2258
|
})
|
|
2259
2259
|
.add(p.input, 'focus.dropdown', () => {
|
|
2260
|
-
if (p.disabled || p.
|
|
2260
|
+
if (p.disabled || p.readOnly) return;
|
|
2261
2261
|
|
|
2262
2262
|
this._trigger('search:focus');
|
|
2263
2263
|
|
|
@@ -2274,7 +2274,7 @@ class SelectBox {
|
|
|
2274
2274
|
|
|
2275
2275
|
p.sink
|
|
2276
2276
|
.add(p.el, 'mousedown.dropdown', () => {
|
|
2277
|
-
if (!p.multi && !p.searchable && !avoidToggleFromClick && !p.disabled && !p.
|
|
2277
|
+
if (!p.multi && !p.searchable && !avoidToggleFromClick && !p.disabled && !p.readOnly) {
|
|
2278
2278
|
this.toggleList();
|
|
2279
2279
|
}
|
|
2280
2280
|
avoidToggleFromClick = false;
|
|
@@ -2877,7 +2877,7 @@ class SelectBox {
|
|
|
2877
2877
|
if (p.input) p.input.readOnly = false;
|
|
2878
2878
|
p.el.classList.add(`${p.baseClassName}__searchable`);
|
|
2879
2879
|
} else {
|
|
2880
|
-
if (p.input) p.input.readOnly =
|
|
2880
|
+
if (p.input) p.input.readOnly = p.readOnly;
|
|
2881
2881
|
p.el.classList.remove(`${p.baseClassName}__searchable`);
|
|
2882
2882
|
}
|
|
2883
2883
|
|
|
@@ -3259,7 +3259,7 @@ class SelectBox {
|
|
|
3259
3259
|
_handleMultiKeydown(event) {
|
|
3260
3260
|
const p = this._p;
|
|
3261
3261
|
|
|
3262
|
-
if (p.disabled || p.
|
|
3262
|
+
if (p.disabled || p.readOnly) return;
|
|
3263
3263
|
|
|
3264
3264
|
const isRtl = getComputedStyle(p.el).direction === 'rtl';
|
|
3265
3265
|
|
package/package.json
CHANGED
package/vue/SelectBox.vue
CHANGED
|
@@ -40,9 +40,13 @@ export const PropTypes = {
|
|
|
40
40
|
type: Boolean,
|
|
41
41
|
default: false,
|
|
42
42
|
},
|
|
43
|
-
|
|
43
|
+
readOnly: {
|
|
44
44
|
type: Boolean,
|
|
45
|
-
|
|
45
|
+
required: false,
|
|
46
|
+
},
|
|
47
|
+
readonly: { // compatibility with simple readonly attr of inputs
|
|
48
|
+
type: Boolean,
|
|
49
|
+
required: false,
|
|
46
50
|
},
|
|
47
51
|
clearable: {
|
|
48
52
|
type: Boolean,
|
|
@@ -476,9 +480,14 @@ export default {
|
|
|
476
480
|
this.nonReactive.instance.disable(value);
|
|
477
481
|
},
|
|
478
482
|
|
|
479
|
-
|
|
483
|
+
readOnly() {
|
|
484
|
+
if (this.nonReactive.instance)
|
|
485
|
+
this.nonReactive.instance.setReadOnly(this.readOnly ?? this.readonly ?? false);
|
|
486
|
+
},
|
|
487
|
+
|
|
488
|
+
readonly() {
|
|
480
489
|
if (this.nonReactive.instance)
|
|
481
|
-
this.nonReactive.instance.setReadOnly(
|
|
490
|
+
this.nonReactive.instance.setReadOnly(this.readOnly ?? this.readonly ?? false);
|
|
482
491
|
},
|
|
483
492
|
|
|
484
493
|
clearable(value) {
|
|
@@ -810,7 +819,7 @@ export default {
|
|
|
810
819
|
baseClass: this.baseClass,
|
|
811
820
|
direction: this.direction,
|
|
812
821
|
disabled: this.disabled,
|
|
813
|
-
|
|
822
|
+
readOnly: this.readOnly ?? this.readonly ?? false,
|
|
814
823
|
clearable: this.clearable,
|
|
815
824
|
hasOpenIndicator: this.hasOpenIndicator,
|
|
816
825
|
placeholder: this.placeholder,
|