@danielgindi/selectbox 2.0.26 → 2.0.27
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/css/selectbox.css +1 -1
- package/css/selectbox.css.map +1 -1
- package/dist/lib.cjs.js +34 -12
- 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 +33 -11
- 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 +34 -12
- 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 +2 -2
- package/lib/SelectBox.js +30 -8
- package/package.json +1 -1
- package/scss/selectbox.scss +17 -3
- package/vue/DropList.vue +129 -127
- package/vue/SelectBox.vue +245 -230
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.27
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
|
|
@@ -142,7 +142,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
142
142
|
/** */
|
|
143
143
|
|
|
144
144
|
/** @type {DropList.Options} */
|
|
145
|
-
|
|
145
|
+
const DefaultOptions$1 = {
|
|
146
146
|
baseClassName: 'droplist',
|
|
147
147
|
|
|
148
148
|
autoItemBlur: true,
|
|
@@ -201,7 +201,7 @@ class DropList {
|
|
|
201
201
|
* @param {DropList.Options} options
|
|
202
202
|
*/
|
|
203
203
|
constructor(options) {
|
|
204
|
-
const o = { ...
|
|
204
|
+
const o = { ...DefaultOptions$1 };
|
|
205
205
|
|
|
206
206
|
for (let [key, value] of Object.entries(/**@type Object*/options))
|
|
207
207
|
if (value !== undefined)
|
|
@@ -3406,6 +3406,7 @@ const inputBackbufferCssProps = [
|
|
|
3406
3406
|
* @property {string} [labelProp='label']
|
|
3407
3407
|
* @property {string} [valueProp='value']
|
|
3408
3408
|
* @property {string} [multiItemLabelProp='short_label']
|
|
3409
|
+
* @property {'after'|'before'|'none'} [multiItemRemovePosition='after']
|
|
3409
3410
|
* @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
|
|
3410
3411
|
* @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
|
|
3411
3412
|
* @property {DropList.ItemBase[]|null} [items] initial items
|
|
@@ -3428,7 +3429,7 @@ const inputBackbufferCssProps = [
|
|
|
3428
3429
|
* @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
|
|
3429
3430
|
* @property {string[]} [clearInputWhen=['single_close','multi_select_single']] clear input box when closing the droplist or selecting <code>['single_close', 'multi_close', 'multi_select_single']</code>
|
|
3430
3431
|
* */
|
|
3431
|
-
const
|
|
3432
|
+
const DefaultOptions = {
|
|
3432
3433
|
el: null,
|
|
3433
3434
|
baseClassName: 'selectbox',
|
|
3434
3435
|
disabled: false,
|
|
@@ -3455,6 +3456,7 @@ const defaultOptions = {
|
|
|
3455
3456
|
labelProp: 'label',
|
|
3456
3457
|
valueProp: 'value',
|
|
3457
3458
|
multiItemLabelProp: 'short_label',
|
|
3459
|
+
multiItemRemovePosition: 'after',
|
|
3458
3460
|
maxMultiItems: null,
|
|
3459
3461
|
multiItemsRestLabelProvider: null,
|
|
3460
3462
|
items: [],
|
|
@@ -3513,7 +3515,7 @@ class SelectBox {
|
|
|
3513
3515
|
* @param {SelectBox.Options} options
|
|
3514
3516
|
*/
|
|
3515
3517
|
constructor(options) {
|
|
3516
|
-
const o = { ...
|
|
3518
|
+
const o = { ...DefaultOptions };
|
|
3517
3519
|
|
|
3518
3520
|
for (let [key, value] of Object.entries(/**@type Object*/options))
|
|
3519
3521
|
if (value !== undefined)
|
|
@@ -3551,6 +3553,7 @@ class SelectBox {
|
|
|
3551
3553
|
labelProp: o.labelProp,
|
|
3552
3554
|
valueProp: o.valueProp,
|
|
3553
3555
|
multiItemLabelProp: o.multiItemLabelProp,
|
|
3556
|
+
multiItemRemovePosition: o.multiItemRemovePosition,
|
|
3554
3557
|
|
|
3555
3558
|
maxMultiItems: o.maxMultiItems,
|
|
3556
3559
|
multiItemsRestLabelProvider: o.multiItemsRestLabelProvider,
|
|
@@ -4463,6 +4466,18 @@ class SelectBox {
|
|
|
4463
4466
|
setMultiItemLabelProp(prop) {
|
|
4464
4467
|
const p = this._p;
|
|
4465
4468
|
p.multiItemLabelProp = prop;
|
|
4469
|
+
this._scheduleSync('render_items');
|
|
4470
|
+
return this;
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
/**
|
|
4474
|
+
* @param {'before'|'after'|'none'} position
|
|
4475
|
+
* @returns {SelectBox}
|
|
4476
|
+
*/
|
|
4477
|
+
setMultiItemRemovePosition(position) {
|
|
4478
|
+
const p = this._p;
|
|
4479
|
+
p.multiItemRemovePosition = position;
|
|
4480
|
+
this._scheduleSync('render_items');
|
|
4466
4481
|
return this;
|
|
4467
4482
|
}
|
|
4468
4483
|
|
|
@@ -6183,22 +6198,29 @@ class SelectBox {
|
|
|
6183
6198
|
if (label === false)
|
|
6184
6199
|
return null;
|
|
6185
6200
|
|
|
6201
|
+
const elRemove = createElement('span', {
|
|
6202
|
+
class: `${p.baseClassName}__item_remove`,
|
|
6203
|
+
role: 'presentation',
|
|
6204
|
+
});
|
|
6205
|
+
|
|
6186
6206
|
const itemEl = createElement('li',
|
|
6187
6207
|
{
|
|
6188
6208
|
class: `${p.baseClassName}__item`,
|
|
6189
6209
|
tabindex: '0',
|
|
6190
6210
|
title: label,
|
|
6191
6211
|
},
|
|
6192
|
-
[
|
|
6193
|
-
createElement('span', {
|
|
6194
|
-
class: `${p.baseClassName}__item_remove`,
|
|
6195
|
-
role: 'presentation',
|
|
6196
|
-
}),
|
|
6197
|
-
],
|
|
6198
6212
|
);
|
|
6199
6213
|
|
|
6214
|
+
if (p.multiItemRemovePosition === 'before') {
|
|
6215
|
+
itemEl.appendChild(elRemove);
|
|
6216
|
+
}
|
|
6217
|
+
|
|
6200
6218
|
this._renderMultiItemContent(item, itemEl);
|
|
6201
6219
|
|
|
6220
|
+
if (p.multiItemRemovePosition === 'after') {
|
|
6221
|
+
itemEl.appendChild(elRemove);
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6202
6224
|
itemEl[ItemSymbol] = item;
|
|
6203
6225
|
|
|
6204
6226
|
return itemEl;
|