slim-select 3.2.0 → 3.4.0

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.
@@ -1,4 +1,4 @@
1
- import { kebabCase } from './helpers'
1
+ import { kebabCase, hasClassInTree } from './helpers'
2
2
  import { Optgroup, Option } from './store'
3
3
 
4
4
  export default class Select {
@@ -167,7 +167,7 @@ export default class Select {
167
167
  let classChanged = false
168
168
  let disabledChanged = false
169
169
  let optgroupOptionChanged = false
170
- let selectionChanged = false;
170
+ let selectionChanged = false
171
171
 
172
172
  // Loop through mutations and check various things
173
173
  for (const m of mutations) {
@@ -187,7 +187,7 @@ export default class Select {
187
187
  for (const n of Array.from(m.addedNodes)) {
188
188
  if (n.nodeName === 'OPTION' && (<HTMLOptionElement>n).value === this.select.value) {
189
189
  // we added a new option that's now the select value
190
- selectionChanged = true;
190
+ selectionChanged = true
191
191
  break
192
192
  }
193
193
  }
@@ -228,7 +228,7 @@ export default class Select {
228
228
  this.pendingOptionsChange = currentData
229
229
  }
230
230
  }
231
- if(selectionChanged) {
231
+ if (selectionChanged) {
232
232
  this.select.dispatchEvent(new Event('change'))
233
233
  }
234
234
  return
@@ -239,7 +239,7 @@ export default class Select {
239
239
  this.changeListen(true)
240
240
  }
241
241
 
242
- if(selectionChanged) {
242
+ if (selectionChanged) {
243
243
  this.select.dispatchEvent(new Event('change'))
244
244
  }
245
245
  }
@@ -566,14 +566,18 @@ export default class Select {
566
566
  const labelClickHandler = (e: MouseEvent) => {
567
567
  const target = e.target as HTMLElement
568
568
 
569
+ // Check if click is on SlimSelect UI elements (main div or content)
570
+ const isSlimSelectElement = hasClassInTree(target, this.select.dataset.id!)
571
+
569
572
  // Prevent default label behavior (focusing the select)
570
573
  // This needs to happen for all clicks on the label or its children
571
574
  // to prevent the browser from focusing the hidden select
572
575
  e.preventDefault()
573
576
  // e.stopPropagation() // dont stop propagation
574
577
 
575
- // Only handle the click if it's directly on the label
576
- if (target === label && this.onLabelClick) {
578
+ // Only trigger the toggle if the click is NOT on SlimSelect elements
579
+ // This allows clicking label text/children to toggle, while wrapped SlimSelect handles its own clicks
580
+ if (!isSlimSelectElement && this.onLabelClick) {
577
581
  this.onLabelClick()
578
582
  }
579
583
  }
@@ -36,7 +36,8 @@ const defaultSettings: { [key: string]: any } = {
36
36
  maxSelected: 1000,
37
37
  timeoutDelay: 200,
38
38
  maxValuesShown: 20,
39
- maxValuesMessage: '{number} selected'
39
+ maxValuesMessage: '{number} selected',
40
+ contentWidth: ''
40
41
  }
41
42
 
42
43
  describe('Settings module', () => {
@@ -25,6 +25,7 @@ export default class Settings {
25
25
  public closeOnSelect: boolean
26
26
  public contentLocation: HTMLElement | null
27
27
  public contentPosition: 'relative' | 'absolute' | 'fixed'
28
+ public contentWidth: string
28
29
  public openPosition: 'auto' | 'up' | 'down'
29
30
  public placeholderText: string
30
31
  public allowDeselect: boolean
@@ -60,6 +61,7 @@ export default class Settings {
60
61
  this.closeOnSelect = settings.closeOnSelect !== undefined ? settings.closeOnSelect : true
61
62
  this.contentLocation = settings.contentLocation || document.body
62
63
  this.contentPosition = settings.contentPosition || 'absolute'
64
+ this.contentWidth = settings.contentWidth || ''
63
65
  this.openPosition = settings.openPosition || 'auto' // options: auto, up, down
64
66
  this.placeholderText = settings.placeholderText !== undefined ? settings.placeholderText : 'Select Value'
65
67
  this.allowDeselect = settings.allowDeselect !== undefined ? settings.allowDeselect : false
@@ -362,6 +362,11 @@
362
362
  }
363
363
  }
364
364
 
365
+ &.ss-dir-above .ss-search {
366
+ border-bottom: none;
367
+ border-top: 1px solid var(--ss-border-color);
368
+ }
369
+
365
370
  .ss-list {
366
371
  flex: 1 1 auto;
367
372
  height: auto;