@danielgindi/selectbox 2.0.55 → 2.0.57

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/lib/DropList.js CHANGED
@@ -67,6 +67,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
67
67
  * @property {boolean} [isHeaderVisible=false] show header element
68
68
  * @property {boolean} [isFooterVisible=false] show footer element
69
69
  * @property {boolean} [searchable=false] include inline search box
70
+ * @property {string} [searchPlaceholder=''] placeholder text for the inline search box
70
71
  * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
71
72
  * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
72
73
  * @property {boolean} [filterOnEmptyTerm=false] call the filter function on empty search term too
@@ -142,6 +143,7 @@ export const DefaultOptions = {
142
143
  isHeaderVisible: false,
143
144
  isFooterVisible: false,
144
145
  searchable: false,
146
+ searchPlaceholder: '',
145
147
  noResultsText: 'No matching results',
146
148
  filterThrottleWindow: 300,
147
149
  filterOnEmptyTerm: false,
@@ -214,6 +216,7 @@ class DropList {
214
216
  positionOptionsProvider: o.positionOptionsProvider ?? null,
215
217
 
216
218
  searchable: o.searchable,
219
+ searchPlaceholder: o.searchPlaceholder,
217
220
  isHeaderVisible: o.isHeaderVisible,
218
221
  isFooterVisible: o.isFooterVisible,
219
222
 
@@ -2104,6 +2107,7 @@ class DropList {
2104
2107
  autocapitalize: 'off',
2105
2108
  spellcheck: 'false',
2106
2109
  'aria-autocomplete': 'list',
2110
+ placeholder: p.searchPlaceholder || '',
2107
2111
  });
2108
2112
 
2109
2113
  p.headerEl.appendChild(p.searchInput);
@@ -2116,6 +2120,20 @@ class DropList {
2116
2120
  this.setHeaderVisible(searchable);
2117
2121
  }
2118
2122
 
2123
+ /**
2124
+ * Set the placeholder text of the inline search box
2125
+ * @param {string} placeholder
2126
+ */
2127
+ setSearchPlaceholder(placeholder) {
2128
+ const p = this._p;
2129
+
2130
+ p.searchPlaceholder = placeholder || '';
2131
+
2132
+ if (p.searchInput) {
2133
+ p.searchInput.placeholder = p.searchPlaceholder;
2134
+ }
2135
+ }
2136
+
2119
2137
  hasFocusedItem() {
2120
2138
  return this._p.focusItemIndex > -1 && this._p.focusItemIndex < this._p.items.length;
2121
2139
  }
@@ -3392,8 +3410,11 @@ class DropList {
3392
3410
  setElementWidth(el, newOuterWidth, true, true);
3393
3411
 
3394
3412
  const elComputedStyle = getComputedStyle(el);
3395
- let bordersWidth = (parseFloat(elComputedStyle.borderLeftWidth) || 0) + (parseFloat(elComputedStyle.borderRightWidth) || 0);
3396
- let scrollWidth = el.scrollWidth + bordersWidth;
3413
+ let extraElWidth = (parseFloat(elComputedStyle.borderLeftWidth) || 0) +
3414
+ (parseFloat(elComputedStyle.borderRightWidth) || 0)+
3415
+ (parseFloat(elComputedStyle.paddingLeft) || 0)+
3416
+ (parseFloat(elComputedStyle.paddingRight) || 0);
3417
+ let scrollWidth = el.scrollWidth + extraElWidth;
3397
3418
  if (scrollWidth > newOuterWidth) {
3398
3419
  // consider scrollWidth delta
3399
3420
  let delta = scrollWidth - newOuterWidth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielgindi/selectbox",
3
- "version": "2.0.55",
3
+ "version": "2.0.57",
4
4
  "description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
5
5
  "main": "dist/lib.cjs.min.js",
6
6
  "module": "lib/index.js",
package/vue/DropList.vue CHANGED
@@ -50,17 +50,21 @@ export const PropTypes = {
50
50
  type: Boolean,
51
51
  default: false,
52
52
  },
53
- isHeaderVisible: {
54
- type: Boolean,
55
- default: false,
56
- },
57
- isFooterVisible: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- searchable: {
62
- type: Boolean,
63
- default: false,
53
+ isHeaderVisible: {
54
+ type: Boolean,
55
+ default: false,
56
+ },
57
+ isFooterVisible: {
58
+ type: Boolean,
59
+ default: false,
60
+ },
61
+ searchable: {
62
+ type: Boolean,
63
+ default: false,
64
+ },
65
+ searchPlaceholder: {
66
+ type: String,
67
+ required: false,
64
68
  },
65
69
  noResultsText: {
66
70
  type: String,
@@ -211,12 +215,12 @@ export default {
211
215
  opts.direction = this.direction;
212
216
  }
213
217
 
214
- for (let key of ['autoItemBlur', 'capturesFocus', 'multi',
215
- 'autoCheckGroupChildren', 'useExactTargetWidth', 'constrainToWindow',
216
- 'autoFlipDirection', 'estimateWidth',
217
- 'isHeaderVisible', 'isFooterVisible',
218
- 'searchable', 'filterOnEmptyTerm',
219
- 'filterGroups', 'filterEmptyGroups']) {
218
+ for (let key of ['autoItemBlur', 'capturesFocus', 'multi',
219
+ 'autoCheckGroupChildren', 'useExactTargetWidth', 'constrainToWindow',
220
+ 'autoFlipDirection', 'estimateWidth',
221
+ 'isHeaderVisible', 'isFooterVisible',
222
+ 'searchable', 'filterOnEmptyTerm',
223
+ 'filterGroups', 'filterEmptyGroups']) {
220
224
  if (typeof this[key] === 'boolean') {
221
225
  opts[key] = this[key];
222
226
  }
@@ -238,6 +242,8 @@ export default {
238
242
  opts.keyDownHandler = this.keyDownHandler;
239
243
  }
240
244
 
245
+ opts.searchPlaceholder = this.searchPlaceholder;
246
+
241
247
  opts.renderItem = this.renderItem ?? createSlotBasedRenderFunc(this, 'item');
242
248
 
243
249
  opts.unrenderItem = this.unrenderItem;
@@ -357,19 +363,24 @@ export default {
357
363
  this.relayout();
358
364
  },
359
365
 
360
- isHeaderVisible(v) {
361
- if (this.nonReactive.instance)
362
- this.nonReactive.instance.setHeaderVisible(v);
363
- this.relayout();
364
- },
365
-
366
- isFooterVisible(v) {
367
- if (this.nonReactive.instance)
368
- this.nonReactive.instance.setFooterVisible(v);
369
- this.relayout();
370
- },
371
-
372
- positionOptions: {
366
+ searchPlaceholder(value) {
367
+ if (this.nonReactive.instance)
368
+ this.nonReactive.instance.setSearchPlaceholder(value ?? DefaultOptions.searchPlaceholder);
369
+ },
370
+
371
+ isHeaderVisible(v) {
372
+ if (this.nonReactive.instance)
373
+ this.nonReactive.instance.setHeaderVisible(v);
374
+ this.relayout();
375
+ },
376
+
377
+ isFooterVisible(v) {
378
+ if (this.nonReactive.instance)
379
+ this.nonReactive.instance.setFooterVisible(v);
380
+ this.relayout();
381
+ },
382
+
383
+ positionOptions: {
373
384
  deep: true,
374
385
  handler() {
375
386
  this.relayout();
@@ -463,16 +474,16 @@ export default {
463
474
  }
464
475
 
465
476
  const headerRenderer = createSlotBasedRenderFunc(this, 'header');
466
- if (headerRenderer) {
467
- headerRenderer({}, list.getHeaderElement());
468
- }
469
-
470
- const footerRenderer = createSlotBasedRenderFunc(this, 'footer');
471
- if (footerRenderer) {
472
- footerRenderer({}, list.getFooterElement());
473
- }
474
-
475
- list.show();
477
+ if (headerRenderer) {
478
+ headerRenderer({}, list.getHeaderElement());
479
+ }
480
+
481
+ const footerRenderer = createSlotBasedRenderFunc(this, 'footer');
482
+ if (footerRenderer) {
483
+ footerRenderer({}, list.getFooterElement());
484
+ }
485
+
486
+ list.show();
476
487
 
477
488
  this._setupAutoRelayout();
478
489
  },
@@ -541,17 +552,17 @@ export default {
541
552
  this.nonReactive.instance.relayout();
542
553
  },
543
554
 
544
- getHeaderElement() {
545
- if (this.nonReactive.instance)
546
- return this.nonReactive.instance.getHeaderElement();
547
- },
548
-
549
- getFooterElement() {
550
- if (this.nonReactive.instance)
551
- return this.nonReactive.instance.getFooterElement();
552
- },
553
-
554
- elContains(other, considerSublists = true) {
555
+ getHeaderElement() {
556
+ if (this.nonReactive.instance)
557
+ return this.nonReactive.instance.getHeaderElement();
558
+ },
559
+
560
+ getFooterElement() {
561
+ if (this.nonReactive.instance)
562
+ return this.nonReactive.instance.getFooterElement();
563
+ },
564
+
565
+ elContains(other, considerSublists = true) {
555
566
  return !!this.listRef?.elContains(other, considerSublists);
556
567
  },
557
568
  },