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.
- package/README.md +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.js +291 -246
- package/dist/react/index.umd.js +2 -2
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +308 -263
- package/dist/slimselect.es.js.map +1 -1
- package/dist/slimselect.iife.js +1 -1
- package/dist/slimselect.iife.js.map +1 -1
- package/dist/slimselect.js +1 -1
- package/dist/slimselect.js.map +1 -1
- package/dist/vue/index.d.ts +7 -0
- package/dist/vue/index.js +214 -169
- package/dist/vue/index.umd.js +1 -1
- package/package.json +24 -23
- package/sitemap.js +21 -2
- package/src/slim-select/classes.test.ts +3 -3
- package/src/slim-select/classes.ts +40 -34
- package/src/slim-select/index.test.ts +26 -5
- package/src/slim-select/index.ts +12 -0
- package/src/slim-select/render.test.ts +216 -0
- package/src/slim-select/render.ts +204 -115
- package/src/slim-select/select.ts +11 -7
- package/src/slim-select/settings.test.ts +2 -1
- package/src/slim-select/settings.ts +2 -0
- package/src/slim-select/slimselect.scss +5 -0
|
@@ -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
|
|
576
|
-
|
|
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
|