@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/dist/lib.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 2.0.26
2
+ * @danielgindi/selectbox 2.0.27
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  (function (global, factory) {
@@ -6367,7 +6367,7 @@
6367
6367
  /** */
6368
6368
 
6369
6369
  /** @type {DropList.Options} */
6370
- let defaultOptions$1 = {
6370
+ const DefaultOptions$1 = {
6371
6371
  baseClassName: 'droplist',
6372
6372
 
6373
6373
  autoItemBlur: true,
@@ -6426,7 +6426,7 @@
6426
6426
  * @param {DropList.Options} options
6427
6427
  */
6428
6428
  constructor(options) {var _o$positionOptionsPro;
6429
- const o = _objectSpread2({}, defaultOptions$1);
6429
+ const o = _objectSpread2({}, DefaultOptions$1);
6430
6430
 
6431
6431
  for (let [key, value] of Object.entries(/**@type Object*/options))
6432
6432
  if (value !== undefined)
@@ -9893,6 +9893,7 @@
9893
9893
  * @property {string} [labelProp='label']
9894
9894
  * @property {string} [valueProp='value']
9895
9895
  * @property {string} [multiItemLabelProp='short_label']
9896
+ * @property {'after'|'before'|'none'} [multiItemRemovePosition='after']
9896
9897
  * @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
9897
9898
  * @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
9898
9899
  * @property {DropList.ItemBase[]|null} [items] initial items
@@ -9915,7 +9916,7 @@
9915
9916
  * @property {boolean} [closeListWhenLoading] whether we should close the list automatically when loading
9916
9917
  * @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>
9917
9918
  * */
9918
- const defaultOptions = {
9919
+ const DefaultOptions = {
9919
9920
  el: null,
9920
9921
  baseClassName: 'selectbox',
9921
9922
  disabled: false,
@@ -9942,6 +9943,7 @@
9942
9943
  labelProp: 'label',
9943
9944
  valueProp: 'value',
9944
9945
  multiItemLabelProp: 'short_label',
9946
+ multiItemRemovePosition: 'after',
9945
9947
  maxMultiItems: null,
9946
9948
  multiItemsRestLabelProvider: null,
9947
9949
  items: [],
@@ -10000,7 +10002,7 @@
10000
10002
  * @param {SelectBox.Options} options
10001
10003
  */
10002
10004
  constructor(options) {
10003
- const o = _objectSpread2({}, defaultOptions);
10005
+ const o = _objectSpread2({}, DefaultOptions);
10004
10006
 
10005
10007
  for (let [key, value] of Object.entries(/**@type Object*/options))
10006
10008
  if (value !== undefined)
@@ -10038,6 +10040,7 @@
10038
10040
  labelProp: o.labelProp,
10039
10041
  valueProp: o.valueProp,
10040
10042
  multiItemLabelProp: o.multiItemLabelProp,
10043
+ multiItemRemovePosition: o.multiItemRemovePosition,
10041
10044
 
10042
10045
  maxMultiItems: o.maxMultiItems,
10043
10046
  multiItemsRestLabelProvider: o.multiItemsRestLabelProvider,
@@ -10950,6 +10953,18 @@
10950
10953
  setMultiItemLabelProp(prop) {
10951
10954
  const p = this._p;
10952
10955
  p.multiItemLabelProp = prop;
10956
+ this._scheduleSync('render_items');
10957
+ return this;
10958
+ }
10959
+
10960
+ /**
10961
+ * @param {'before'|'after'|'none'} position
10962
+ * @returns {SelectBox}
10963
+ */
10964
+ setMultiItemRemovePosition(position) {
10965
+ const p = this._p;
10966
+ p.multiItemRemovePosition = position;
10967
+ this._scheduleSync('render_items');
10953
10968
  return this;
10954
10969
  }
10955
10970
 
@@ -12670,22 +12685,29 @@
12670
12685
  if (label === false)
12671
12686
  return null;
12672
12687
 
12688
+ const elRemove = Dom.createElement('span', {
12689
+ class: "".concat(p.baseClassName, "__item_remove"),
12690
+ role: 'presentation'
12691
+ });
12692
+
12673
12693
  const itemEl = Dom.createElement('li',
12674
12694
  {
12675
12695
  class: "".concat(p.baseClassName, "__item"),
12676
12696
  tabindex: '0',
12677
12697
  title: label
12678
- },
12679
- [
12680
- Dom.createElement('span', {
12681
- class: "".concat(p.baseClassName, "__item_remove"),
12682
- role: 'presentation'
12683
- })]
12684
-
12698
+ }
12685
12699
  );
12686
12700
 
12701
+ if (p.multiItemRemovePosition === 'before') {
12702
+ itemEl.appendChild(elRemove);
12703
+ }
12704
+
12687
12705
  this._renderMultiItemContent(item, itemEl);
12688
12706
 
12707
+ if (p.multiItemRemovePosition === 'after') {
12708
+ itemEl.appendChild(elRemove);
12709
+ }
12710
+
12689
12711
  itemEl[ItemSymbol] = item;
12690
12712
 
12691
12713
  return itemEl;