@danielgindi/selectbox 1.0.31 → 1.0.32

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.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.31
2
+ * @danielgindi/selectbox 1.0.32
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
@@ -2163,7 +2163,9 @@ const inputBackbufferCssProps = [
2163
2163
  * @property {string} [multiItemLabelProp='short_label']
2164
2164
  * @property {number} [maxMultiItems] maximum number of multi items. The rest will get a single item to represent.
2165
2165
  * @property {function(count: number, items: DropList.ItemBase[]):string} [multiItemsRestLabelProvider] label for the item representing the rest of the items.
2166
- * @property {DropList.ItemBase[]|null} [items]
2166
+ * @property {DropList.ItemBase[]|null} [items] initial items
2167
+ * @property {*[]|null} [selectedValues] initial selected values
2168
+ * @property {*|*[]|null} [value] initial selected value
2167
2169
  * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderSingleItem]
2168
2170
  * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderSingleItem]
2169
2171
  * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderMultiItem]
@@ -2204,6 +2206,8 @@ const defaultOptions = {
2204
2206
  maxMultiItems: null,
2205
2207
  multiItemsRestLabelProvider: null,
2206
2208
  items: [],
2209
+ selectedValues: undefined,
2210
+ value: undefined,
2207
2211
  isLoadingMode: false,
2208
2212
  };
2209
2213
 
@@ -2302,12 +2306,12 @@ class SelectBox {
2302
2306
  renderNoResultsItem: o.renderNoResultsItem,
2303
2307
  unrenderNoResultsItem: o.unrenderNoResultsItem,
2304
2308
  filterFn: o.filterFn,
2305
- on: o.on,
2309
+ on: null,
2306
2310
  additionalClasses: o.additionalClasses,
2307
2311
 
2308
2312
  isLoadingMode: !!o.isLoadingMode,
2309
2313
 
2310
- items: o.items || [],
2314
+ items: [],
2311
2315
  filteredItems: null,
2312
2316
  itemsChanged: true,
2313
2317
 
@@ -2401,7 +2405,16 @@ class SelectBox {
2401
2405
  p.sink.add(window, 'resize', () => this._resizeInput());
2402
2406
  p.sink.add(window, 'orientationchange', () => this._resizeInput());
2403
2407
 
2404
- this.setItems(p.items);
2408
+ this.setItems(o.items);
2409
+
2410
+ if (o.multi && Array.isArray(o.selectedValues)) {
2411
+ this.setSelectedValues(o.selectedValues);
2412
+ } else if (o.value != null) {
2413
+ this.setValue(o.value);
2414
+ }
2415
+
2416
+ // Start firing events
2417
+ p.on = o.on || null;
2405
2418
 
2406
2419
  this._scheduleSync();
2407
2420