@danielgindi/selectbox 2.0.65 → 2.0.66
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 +130 -103
- package/dist/lib.cjs.js +193 -89
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +193 -89
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +193 -89
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/types/DropList.d.ts +13 -1
- package/dist/types/DropList.d.ts.map +1 -1
- package/dist/types/SelectBox.d.ts +7 -1
- package/dist/types/SelectBox.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +35 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/vue/DropList.vue +19 -5
- package/vue/SelectBox.vue +19 -5
- package/vue/component-types.d.ts +4 -0
package/README.md
CHANGED
|
@@ -1,103 +1,130 @@
|
|
|
1
|
-
# @danielgindi/selectbox
|
|
2
|
-
|
|
3
|
-
A full featured selectbox and drop down.
|
|
4
|
-
|
|
5
|
-
* Virtual list (can show a list with millions of items)
|
|
6
|
-
* Live search right there in the box
|
|
7
|
-
* Single or multi mode
|
|
8
|
-
* Tags (items in the search box)
|
|
9
|
-
* Custom item rendering
|
|
10
|
-
* Variable height items
|
|
11
|
-
* Highly configurable
|
|
12
|
-
* No dependency on any ui framework
|
|
13
|
-
* Can work in any framework or in vanilla js
|
|
14
|
-
* Has existing Vue bindings
|
|
15
|
-
* The droplist part can be used separately for floating menus etc.
|
|
16
|
-
|
|
17
|
-
This is a real good component, which is the product of evolution over years. Until I sat down one day and refactored it into one cool thing.
|
|
18
|
-
I really hope to get this documented so everyone can enjoy it.
|
|
19
|
-
|
|
20
|
-
### Installing
|
|
21
|
-
|
|
22
|
-
* adding to package.json: `npm i --save @danielgindi/selectbox`
|
|
23
|
-
* vanilla js:
|
|
24
|
-
```js
|
|
25
|
-
import { SelectBox, DropList } from '@danielgindi/selectbox';
|
|
26
|
-
```
|
|
27
|
-
* vuejs:
|
|
28
|
-
```js
|
|
29
|
-
import { SelectBox, DropList } from '@danielgindi/selectbox/vue';
|
|
30
|
-
```
|
|
31
|
-
* add the scss:
|
|
32
|
-
```scss
|
|
33
|
-
@import '@danielgindi/selectbox/scss/droplist';
|
|
34
|
-
@import '@danielgindi/selectbox/scss/selectbox'; /* depends on droplist css */
|
|
35
|
-
```
|
|
36
|
-
* or the compiled css:
|
|
37
|
-
```css
|
|
38
|
-
@import '@danielgindi/selectbox/css/droplist';
|
|
39
|
-
@import '@danielgindi/selectbox/css/selectbox'; /* depends on droplist css */
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Example
|
|
43
|
-
|
|
44
|
-
You are welcome to open a PR and add examples, docs, and demo pages :-)
|
|
45
|
-
|
|
46
|
-
## Api
|
|
47
|
-
|
|
48
|
-
You are welcome to open a PR and add some api docs :-)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
# @danielgindi/selectbox
|
|
2
|
+
|
|
3
|
+
A full featured selectbox and drop down.
|
|
4
|
+
|
|
5
|
+
* Virtual list (can show a list with millions of items)
|
|
6
|
+
* Live search right there in the box
|
|
7
|
+
* Single or multi mode
|
|
8
|
+
* Tags (items in the search box)
|
|
9
|
+
* Custom item rendering
|
|
10
|
+
* Variable height items
|
|
11
|
+
* Highly configurable
|
|
12
|
+
* No dependency on any ui framework
|
|
13
|
+
* Can work in any framework or in vanilla js
|
|
14
|
+
* Has existing Vue bindings
|
|
15
|
+
* The droplist part can be used separately for floating menus etc.
|
|
16
|
+
|
|
17
|
+
This is a real good component, which is the product of evolution over years. Until I sat down one day and refactored it into one cool thing.
|
|
18
|
+
I really hope to get this documented so everyone can enjoy it.
|
|
19
|
+
|
|
20
|
+
### Installing
|
|
21
|
+
|
|
22
|
+
* adding to package.json: `npm i --save @danielgindi/selectbox`
|
|
23
|
+
* vanilla js:
|
|
24
|
+
```js
|
|
25
|
+
import { SelectBox, DropList } from '@danielgindi/selectbox';
|
|
26
|
+
```
|
|
27
|
+
* vuejs:
|
|
28
|
+
```js
|
|
29
|
+
import { SelectBox, DropList } from '@danielgindi/selectbox/vue';
|
|
30
|
+
```
|
|
31
|
+
* add the scss:
|
|
32
|
+
```scss
|
|
33
|
+
@import '@danielgindi/selectbox/scss/droplist';
|
|
34
|
+
@import '@danielgindi/selectbox/scss/selectbox'; /* depends on droplist css */
|
|
35
|
+
```
|
|
36
|
+
* or the compiled css:
|
|
37
|
+
```css
|
|
38
|
+
@import '@danielgindi/selectbox/css/droplist';
|
|
39
|
+
@import '@danielgindi/selectbox/css/selectbox'; /* depends on droplist css */
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
|
|
44
|
+
You are welcome to open a PR and add examples, docs, and demo pages :-)
|
|
45
|
+
|
|
46
|
+
## Api
|
|
47
|
+
|
|
48
|
+
You are welcome to open a PR and add some api docs :-)
|
|
49
|
+
|
|
50
|
+
### Managing z-index
|
|
51
|
+
|
|
52
|
+
A `DropList` (standalone, or owned by a `SelectBox`) can have its z-index set by the `zIndex` option:
|
|
53
|
+
a fixed number/string, or a function resolved every time the list is shown.
|
|
54
|
+
Set it globally on `DropListDefaultOptions`, so it applies everywhere - including the lists of `SelectBox`es:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { DropListDefaultOptions } from '@danielgindi/selectbox';
|
|
58
|
+
|
|
59
|
+
DropListDefaultOptions.zIndex = ({ owner, selectBox, dropList, positionOptions }) => {
|
|
60
|
+
// `owner` is the SelectBox's element for a SelectBox's list,
|
|
61
|
+
// otherwise the `target` of the position options (or `null`).
|
|
62
|
+
// `selectBox` is the owning SelectBox instance, or `null`.
|
|
63
|
+
const popup = owner?.closest('.popup');
|
|
64
|
+
if (popup)
|
|
65
|
+
return Number(getComputedStyle(popup).zIndex) + 1;
|
|
66
|
+
return null; // keep the CSS z-index
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
* Per instance: `new DropList({ zIndex })`, `new SelectBox({ listOptions: { zIndex } })`,
|
|
71
|
+
`dropList.setZIndex(zIndex)`, `selectBox.setListZIndex(zIndex)`.
|
|
72
|
+
* Vue: `<DropList :z-index="...">`, `<SelectBox :list-z-index="...">`.
|
|
73
|
+
* Call `dropList.updateZIndex()` to re-resolve while the list is open.
|
|
74
|
+
* Sub-item lists inherit their parent list's z-index.
|
|
75
|
+
* Returning `null`/`undefined` leaves the CSS z-index (`10000` in `droplist.scss`) in effect.
|
|
76
|
+
|
|
77
|
+
## Vite
|
|
78
|
+
|
|
79
|
+
When using with Vite - you'll need to add this `optimizeDeps to` `vite.config.js`:
|
|
80
|
+
```
|
|
81
|
+
optimizeDeps: {
|
|
82
|
+
include: [
|
|
83
|
+
'fast-deep-equal',
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Otherwise, Vite will complain about `fast-deep-equal` entry point.
|
|
89
|
+
|
|
90
|
+
## Me
|
|
91
|
+
* Hi! I am Daniel Cohen Gindi. Or in short- Daniel.
|
|
92
|
+
* danielgindi@gmail.com is my email address.
|
|
93
|
+
* That's all you need to know.
|
|
94
|
+
|
|
95
|
+
## Help
|
|
96
|
+
|
|
97
|
+
If you want to help, you could:
|
|
98
|
+
* Actually code, and issue pull requests
|
|
99
|
+
* Test the library under different conditions and browsers
|
|
100
|
+
* Create more demo pages
|
|
101
|
+
* Spread the word
|
|
102
|
+
* [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=45T5QNATLCPS2)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
All the code here is under MIT license. Which means you could do virtually anything with the code.
|
|
108
|
+
I will appreciate it very much if you keep an attribution where appropriate.
|
|
109
|
+
|
|
110
|
+
The MIT License (MIT)
|
|
111
|
+
|
|
112
|
+
Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)
|
|
113
|
+
|
|
114
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
115
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
116
|
+
in the Software without restriction, including without limitation the rights
|
|
117
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
118
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
119
|
+
furnished to do so, subject to the following conditions:
|
|
120
|
+
|
|
121
|
+
The above copyright notice and this permission notice shall be included in all
|
|
122
|
+
copies or substantial portions of the Software.
|
|
123
|
+
|
|
124
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
125
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
126
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
127
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
128
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
129
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
130
|
+
SOFTWARE.
|
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.66
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -122,6 +122,7 @@ var DefaultOptions = {
|
|
|
122
122
|
labelProp: "label",
|
|
123
123
|
valueProp: "value",
|
|
124
124
|
on: null,
|
|
125
|
+
zIndex: null,
|
|
125
126
|
isHeaderVisible: false,
|
|
126
127
|
isFooterVisible: false,
|
|
127
128
|
searchable: false,
|
|
@@ -166,6 +167,9 @@ var DropList = class DropList {
|
|
|
166
167
|
unrenderNoResultsItem: o.unrenderNoResultsItem,
|
|
167
168
|
on: o.on || null,
|
|
168
169
|
positionOptionsProvider: o.positionOptionsProvider ?? null,
|
|
170
|
+
zIndex: o.zIndex ?? null,
|
|
171
|
+
appliedZIndex: null,
|
|
172
|
+
ownerSelectBox: null,
|
|
169
173
|
onError: o.onError,
|
|
170
174
|
searchable: o.searchable,
|
|
171
175
|
searchPlaceholder: o.searchPlaceholder,
|
|
@@ -266,12 +270,13 @@ var DropList = class DropList {
|
|
|
266
270
|
itemEl.className = `${p.baseClassName}__item`;
|
|
267
271
|
const classList = itemEl.classList;
|
|
268
272
|
if (item) {
|
|
269
|
-
if (p.multi)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
if (p.multi) {
|
|
274
|
+
if (item._nocheck) classList.add(`${p.baseClassName}__item_multi_nocheck`);
|
|
275
|
+
else {
|
|
276
|
+
classList.add(`${p.baseClassName}__item_multi`);
|
|
277
|
+
if (item._checked) classList.add(`${p.baseClassName}__item_checked`);
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
275
280
|
classList.add(`${p.baseClassName}__item_single`);
|
|
276
281
|
if (p.singleSelectedValue !== void 0 && item.value === p.singleSelectedValue) {
|
|
277
282
|
classList.add(`${p.baseClassName}__item_selected`);
|
|
@@ -736,6 +741,70 @@ var DropList = class DropList {
|
|
|
736
741
|
return this._p.positionOptionsProvider;
|
|
737
742
|
}
|
|
738
743
|
/**
|
|
744
|
+
* Sets the z-index: a fixed value, a resolver function, or `null` to use the CSS z-index.
|
|
745
|
+
* Applied immediately if the DropList is visible.
|
|
746
|
+
*/
|
|
747
|
+
setZIndex(zIndex) {
|
|
748
|
+
const p = this._p;
|
|
749
|
+
zIndex = zIndex ?? null;
|
|
750
|
+
if (p.zIndex === zIndex) return this;
|
|
751
|
+
p.zIndex = zIndex;
|
|
752
|
+
this.updateZIndex();
|
|
753
|
+
return this;
|
|
754
|
+
}
|
|
755
|
+
getZIndex() {
|
|
756
|
+
return this._p.zIndex;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Re-resolves the z-index (re-invoking a resolver function) and applies it.
|
|
760
|
+
* The z-index is resolved automatically on `show()`, so call this only when the stacking
|
|
761
|
+
* order around the owner changes while the DropList is open. Does nothing while hidden.
|
|
762
|
+
*/
|
|
763
|
+
updateZIndex() {
|
|
764
|
+
const p = this._p;
|
|
765
|
+
if (!this.isVisible()) return this;
|
|
766
|
+
this._applyZIndex(p.positionOptionsProvider?.() ?? p.lastPositionOptions ?? null);
|
|
767
|
+
return this;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Marks this DropList as owned by a SelectBox, for `DropListZIndexContext`.
|
|
771
|
+
* @internal
|
|
772
|
+
*/
|
|
773
|
+
_setOwnerSelectBox(selectBox) {
|
|
774
|
+
this._p.ownerSelectBox = selectBox;
|
|
775
|
+
}
|
|
776
|
+
/** @internal */
|
|
777
|
+
_resolveZIndex(positionOptions) {
|
|
778
|
+
const p = this._p;
|
|
779
|
+
const option = p.zIndex;
|
|
780
|
+
let zIndex;
|
|
781
|
+
if (typeof option === "function") {
|
|
782
|
+
const context = {
|
|
783
|
+
dropList: this,
|
|
784
|
+
owner: p.ownerSelectBox?.el ?? positionOptions?.target ?? null,
|
|
785
|
+
selectBox: p.ownerSelectBox,
|
|
786
|
+
positionOptions
|
|
787
|
+
};
|
|
788
|
+
try {
|
|
789
|
+
zIndex = option(context);
|
|
790
|
+
} catch (err) {
|
|
791
|
+
reportError(p.onError, err, { source: "zIndex" });
|
|
792
|
+
zIndex = null;
|
|
793
|
+
}
|
|
794
|
+
} else zIndex = option;
|
|
795
|
+
if (zIndex == null || zIndex === "") return null;
|
|
796
|
+
return String(zIndex);
|
|
797
|
+
}
|
|
798
|
+
/** @internal */
|
|
799
|
+
_applyZIndex(positionOptions) {
|
|
800
|
+
const p = this._p;
|
|
801
|
+
const zIndex = this._resolveZIndex(positionOptions);
|
|
802
|
+
if (zIndex !== null) p.el.style.zIndex = zIndex;
|
|
803
|
+
else if (p.appliedZIndex !== null) p.el.style.zIndex = "";
|
|
804
|
+
p.appliedZIndex = zIndex;
|
|
805
|
+
p.currentSubDropList?.droplist?.updateZIndex();
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
739
808
|
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
|
|
740
809
|
* instead of the default `console.error`/`console.warn`.
|
|
741
810
|
*/
|
|
@@ -804,13 +873,15 @@ var DropList = class DropList {
|
|
|
804
873
|
return our;
|
|
805
874
|
});
|
|
806
875
|
}
|
|
807
|
-
if (!Array.isArray(filteredItems))
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
876
|
+
if (!Array.isArray(filteredItems)) {
|
|
877
|
+
if (term) {
|
|
878
|
+
const matcher = new RegExp(escapeRegex(term), "i");
|
|
879
|
+
filteredItems = p.items.filter((x) => {
|
|
880
|
+
if (!filterGroups && x._group) return true;
|
|
881
|
+
return matcher.test(x.label);
|
|
882
|
+
});
|
|
883
|
+
} else filteredItems = null;
|
|
884
|
+
}
|
|
814
885
|
p.filteredItems = filteredItems;
|
|
815
886
|
if (filteredItems && filterEmptyGroups) {
|
|
816
887
|
let lastGroup = -1;
|
|
@@ -1021,8 +1092,10 @@ var DropList = class DropList {
|
|
|
1021
1092
|
};
|
|
1022
1093
|
viewCss.left += anchor.left - position.left;
|
|
1023
1094
|
if (positionOptions.offset) {
|
|
1024
|
-
if (positionOptions.offset.y)
|
|
1025
|
-
|
|
1095
|
+
if (positionOptions.offset.y) {
|
|
1096
|
+
if (invertYPos) viewCss.top -= positionOptions.offset.y;
|
|
1097
|
+
else viewCss.top += positionOptions.offset.y;
|
|
1098
|
+
}
|
|
1026
1099
|
if (positionOptions.offset.x) {
|
|
1027
1100
|
let rtl = elComputedStyle.direction === "rtl";
|
|
1028
1101
|
viewCss.left += rtl ? -positionOptions.offset.x : positionOptions.offset.x;
|
|
@@ -1152,6 +1225,7 @@ var DropList = class DropList {
|
|
|
1152
1225
|
p.lastPositionOptions = null;
|
|
1153
1226
|
if (positionOptions === void 0) positionOptions = p.positionOptionsProvider?.() ?? p.lastPositionOptions;
|
|
1154
1227
|
else p.lastPositionOptions = positionOptions;
|
|
1228
|
+
this._applyZIndex(positionOptions ?? null);
|
|
1155
1229
|
if (positionOptions) {
|
|
1156
1230
|
const elComputedStyle = getComputedStyle(el);
|
|
1157
1231
|
const originalMaxHeight = el.style.maxHeight;
|
|
@@ -1353,7 +1427,8 @@ var DropList = class DropList {
|
|
|
1353
1427
|
valueProp: p.valueProp,
|
|
1354
1428
|
renderItem: p.renderItem,
|
|
1355
1429
|
unrenderItem: p.unrenderItem,
|
|
1356
|
-
positionOptionsProvider: () => p.currentSubDropList.showOptions
|
|
1430
|
+
positionOptionsProvider: () => p.currentSubDropList.showOptions,
|
|
1431
|
+
zIndex: () => this._p?.appliedZIndex ?? null
|
|
1357
1432
|
});
|
|
1358
1433
|
let onBlur = (event) => {
|
|
1359
1434
|
if (this[DestroyedSymbol$1]) return;
|
|
@@ -2176,14 +2251,18 @@ var DropList = class DropList {
|
|
|
2176
2251
|
_updateWidth(positionOptions) {
|
|
2177
2252
|
const p = this._p, el = p.el;
|
|
2178
2253
|
let targetWidth = 0;
|
|
2179
|
-
if (positionOptions)
|
|
2180
|
-
|
|
2181
|
-
|
|
2254
|
+
if (positionOptions) {
|
|
2255
|
+
if (typeof positionOptions.updateWidth === "number") targetWidth = positionOptions.updateWidth;
|
|
2256
|
+
else if (positionOptions.targetWidth != null) targetWidth = positionOptions.targetWidth;
|
|
2257
|
+
else targetWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(positionOptions.target, true, true);
|
|
2258
|
+
}
|
|
2182
2259
|
let autoWidth = 0;
|
|
2183
|
-
if (!p.useExactTargetWidth || !targetWidth)
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2260
|
+
if (!p.useExactTargetWidth || !targetWidth) {
|
|
2261
|
+
if (p.estimateWidth || p.virtualListHelper.isVirtual()) autoWidth = p.lastMeasureItemWidth;
|
|
2262
|
+
else {
|
|
2263
|
+
el.style.width = "";
|
|
2264
|
+
autoWidth = (0, _danielgindi_dom_utils_lib_Css.getElementWidth)(el, true, true);
|
|
2265
|
+
}
|
|
2187
2266
|
}
|
|
2188
2267
|
let newOuterWidth = Math.max(autoWidth, targetWidth);
|
|
2189
2268
|
(0, _danielgindi_dom_utils_lib_Css.setElementWidth)(el, newOuterWidth, true, true);
|
|
@@ -2812,6 +2891,22 @@ var SelectBox = class {
|
|
|
2812
2891
|
this._setupDropdownMenu();
|
|
2813
2892
|
return this;
|
|
2814
2893
|
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Sets `listOptions.zIndex` without recreating the DropList.
|
|
2896
|
+
* `undefined` falls back to `DropListDefaultOptions.zIndex`.
|
|
2897
|
+
*/
|
|
2898
|
+
setListZIndex(zIndex) {
|
|
2899
|
+
const p = this._p;
|
|
2900
|
+
p.listOptions = {
|
|
2901
|
+
...p.listOptions,
|
|
2902
|
+
zIndex
|
|
2903
|
+
};
|
|
2904
|
+
p.dropList?.setZIndex(zIndex === void 0 ? DefaultOptions.zIndex : zIndex);
|
|
2905
|
+
return this;
|
|
2906
|
+
}
|
|
2907
|
+
getListZIndex() {
|
|
2908
|
+
return this._p.listOptions?.zIndex;
|
|
2909
|
+
}
|
|
2815
2910
|
setRenderSingleItem(render, unrender) {
|
|
2816
2911
|
const p = this._p;
|
|
2817
2912
|
p.renderSingleItem = render;
|
|
@@ -3232,23 +3327,27 @@ var SelectBox = class {
|
|
|
3232
3327
|
this._registerDropdownEvents();
|
|
3233
3328
|
}
|
|
3234
3329
|
}
|
|
3235
|
-
if (p.hasOpenIndicator !== !!p.openIndicator)
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3330
|
+
if (p.hasOpenIndicator !== !!p.openIndicator) {
|
|
3331
|
+
if (p.hasOpenIndicator) {
|
|
3332
|
+
p.openIndicator = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__open_indicator` });
|
|
3333
|
+
p.el.appendChild(p.openIndicator);
|
|
3334
|
+
p.el.classList.add(`${p.baseClassName}__has_open_indicator`);
|
|
3335
|
+
} else {
|
|
3336
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.openIndicator);
|
|
3337
|
+
delete p.openIndicator;
|
|
3338
|
+
p.el.classList.remove(`${p.baseClassName}__has_open_indicator`);
|
|
3339
|
+
}
|
|
3243
3340
|
}
|
|
3244
|
-
if (p.isLoadingMode !== !!p.spinner)
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3341
|
+
if (p.isLoadingMode !== !!p.spinner) {
|
|
3342
|
+
if (p.isLoadingMode) {
|
|
3343
|
+
p.spinner = (0, _danielgindi_dom_utils_lib_Dom.createElement)("span", { class: `${p.baseClassName}__spinner` });
|
|
3344
|
+
p.el.appendChild(p.spinner);
|
|
3345
|
+
p.el.classList.add(`${p.baseClassName}__has_spinner`);
|
|
3346
|
+
} else {
|
|
3347
|
+
(0, _danielgindi_dom_utils_lib_DomCompat.remove)(p.spinner);
|
|
3348
|
+
delete p.spinner;
|
|
3349
|
+
p.el.classList.remove(`${p.baseClassName}__has_spinner`);
|
|
3350
|
+
}
|
|
3252
3351
|
}
|
|
3253
3352
|
}
|
|
3254
3353
|
/**
|
|
@@ -3375,21 +3474,22 @@ var SelectBox = class {
|
|
|
3375
3474
|
p.selectionChanged = true;
|
|
3376
3475
|
p.resortBySelectionNeeded = true;
|
|
3377
3476
|
const hasGroupSync = !!event.isCheckingGroup;
|
|
3378
|
-
if (p.showSelection)
|
|
3379
|
-
if (
|
|
3380
|
-
|
|
3381
|
-
if (
|
|
3477
|
+
if (p.showSelection) {
|
|
3478
|
+
if (checked) {
|
|
3479
|
+
if (dropList.itemCount() === 1 && p.clearInputWhen.includes("multi_select_single")) this._setInputText("");
|
|
3480
|
+
if (p.sortSelectedItems) {
|
|
3481
|
+
if (!hasGroupSync) this._scheduleSync("full");
|
|
3482
|
+
} else {
|
|
3483
|
+
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length > p.maxMultiItems) this._scheduleSync("addOrUpdateMultiItemRestElement");
|
|
3484
|
+
else this._scheduleSync("addMultiItemElement", item);
|
|
3485
|
+
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3486
|
+
}
|
|
3382
3487
|
} else {
|
|
3383
|
-
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length
|
|
3384
|
-
else this._scheduleSync("
|
|
3488
|
+
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length === p.maxMultiItems) this._scheduleSync("removeMultiItemRestElement");
|
|
3489
|
+
else this._scheduleSync("removeMultiItemElement", item);
|
|
3385
3490
|
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3386
3491
|
}
|
|
3387
|
-
} else
|
|
3388
|
-
if (p.maxMultiItems != null && (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).length === p.maxMultiItems) this._scheduleSync("removeMultiItemRestElement");
|
|
3389
|
-
else this._scheduleSync("removeMultiItemElement", item);
|
|
3390
|
-
if (!hasGroupSync) this._scheduleSync("render_base");
|
|
3391
|
-
}
|
|
3392
|
-
else if (p.multi) this._scheduleSync("syncPlaceholder");
|
|
3492
|
+
} else if (p.multi) this._scheduleSync("syncPlaceholder");
|
|
3393
3493
|
this._trigger(checked ? "addsel" : "removesel", {
|
|
3394
3494
|
value,
|
|
3395
3495
|
item,
|
|
@@ -3435,6 +3535,7 @@ var SelectBox = class {
|
|
|
3435
3535
|
}
|
|
3436
3536
|
}
|
|
3437
3537
|
});
|
|
3538
|
+
dropList._setOwnerSelectBox(this);
|
|
3438
3539
|
p.sink.add(dropList.el, "mousedown", preventDropListMouseDownBlur);
|
|
3439
3540
|
this._registerDropdownEvents();
|
|
3440
3541
|
}
|
|
@@ -3808,9 +3909,10 @@ var SelectBox = class {
|
|
|
3808
3909
|
_syncPlaceholder() {
|
|
3809
3910
|
const p = this._p, multiItemLabelProp = p.multiItemLabelProp;
|
|
3810
3911
|
let placeholder = "";
|
|
3811
|
-
if (p.multi && !p.showSelection)
|
|
3812
|
-
|
|
3813
|
-
|
|
3912
|
+
if (p.multi && !p.showSelection) {
|
|
3913
|
+
if (typeof p.multiPlaceholderFormatter === "function") placeholder = p.multiPlaceholderFormatter(p.selectedItems);
|
|
3914
|
+
else placeholder = p.selectedItems.length === 0 ? p.placeholder || "" : defaultMultiPlaceholderFormatter(p.selectedItems, p.labelProp);
|
|
3915
|
+
} else if (p.selectedItems.length === 0 || !p.showSelection || p.selectedItems.every((x) => x[multiItemLabelProp] === false)) placeholder = p.placeholder == null ? "" : p.placeholder + "";
|
|
3814
3916
|
p.input.setAttribute("placeholder", placeholder);
|
|
3815
3917
|
if (p.showPlaceholderInTooltip) p.input.setAttribute("title", placeholder);
|
|
3816
3918
|
else p.input.removeAttribute("title");
|
|
@@ -3934,46 +4036,48 @@ var SelectBox = class {
|
|
|
3934
4036
|
else if (kEvent.key === keycode_js.VALUE_BACK_SPACE) nextFocus = (0, _danielgindi_dom_utils_lib_Dom.prev)(itemEl, `.${p.baseClassName}__item,.${p.baseClassName}__search_wrapper`);
|
|
3935
4037
|
} else if (/click|mouse|touch/.test(originatingEvent.type)) nextFocus = (0, _danielgindi_dom_utils_lib_Dom.next)(itemEl, `.${p.baseClassName}__item,.${p.baseClassName}__search_wrapper`);
|
|
3936
4038
|
const item = itemEl[ItemSymbol], value = item[p.valueProp];
|
|
3937
|
-
if (item !== void 0)
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
4039
|
+
if (item !== void 0) {
|
|
4040
|
+
if (value === RestMultiItemsSymbol) {
|
|
4041
|
+
let items = (p.treatGroupSelectionAsItems ? p.selectedItems : p.selectedItems.filter((x) => !x._group)).slice(p.maxMultiItems);
|
|
4042
|
+
let itemsToRemove = [];
|
|
4043
|
+
for (let item of items) {
|
|
4044
|
+
let removeselEvt = {
|
|
4045
|
+
value: item[p.valueProp],
|
|
4046
|
+
item,
|
|
4047
|
+
cancel: false
|
|
4048
|
+
};
|
|
4049
|
+
this._trigger("removesel:before", removeselEvt);
|
|
4050
|
+
if (!removeselEvt.cancel) itemsToRemove.push(item);
|
|
4051
|
+
}
|
|
4052
|
+
if (itemsToRemove.length > 0) {
|
|
4053
|
+
this._removeMultiItemElementByIndex(p.multiItemEls.length - 1);
|
|
4054
|
+
for (let item of itemsToRemove) {
|
|
4055
|
+
let idx = p.selectedItems.indexOf(item);
|
|
4056
|
+
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
4057
|
+
if (idx !== -1) {
|
|
4058
|
+
p.selectedItems.splice(idx, 1);
|
|
4059
|
+
p.selectedValues.splice(idx, 1);
|
|
4060
|
+
p.selectionChanged = true;
|
|
4061
|
+
p.resortBySelectionNeeded = true;
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
if (items.length > itemsToRemove.length) this._addMultiItemRestElement();
|
|
4066
|
+
if (itemsToRemove.length > 0) this._scheduleSync("render_list");
|
|
4067
|
+
} else {
|
|
3941
4068
|
let removeselEvt = {
|
|
3942
|
-
value
|
|
4069
|
+
value,
|
|
3943
4070
|
item,
|
|
3944
4071
|
cancel: false
|
|
3945
4072
|
};
|
|
3946
4073
|
this._trigger("removesel:before", removeselEvt);
|
|
3947
|
-
if (
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
if (idx === -1) idx = p.selectedValues.indexOf(item[p.valueProp]);
|
|
3954
|
-
if (idx !== -1) {
|
|
3955
|
-
p.selectedItems.splice(idx, 1);
|
|
3956
|
-
p.selectedValues.splice(idx, 1);
|
|
3957
|
-
p.selectionChanged = true;
|
|
3958
|
-
p.resortBySelectionNeeded = true;
|
|
3959
|
-
}
|
|
3960
|
-
}
|
|
4074
|
+
if (removeselEvt.cancel) return this;
|
|
4075
|
+
this._removeMultiItem(item);
|
|
4076
|
+
this._trigger("removesel", {
|
|
4077
|
+
value,
|
|
4078
|
+
item
|
|
4079
|
+
});
|
|
3961
4080
|
}
|
|
3962
|
-
if (items.length > itemsToRemove.length) this._addMultiItemRestElement();
|
|
3963
|
-
if (itemsToRemove.length > 0) this._scheduleSync("render_list");
|
|
3964
|
-
} else {
|
|
3965
|
-
let removeselEvt = {
|
|
3966
|
-
value,
|
|
3967
|
-
item,
|
|
3968
|
-
cancel: false
|
|
3969
|
-
};
|
|
3970
|
-
this._trigger("removesel:before", removeselEvt);
|
|
3971
|
-
if (removeselEvt.cancel) return this;
|
|
3972
|
-
this._removeMultiItem(item);
|
|
3973
|
-
this._trigger("removesel", {
|
|
3974
|
-
value,
|
|
3975
|
-
item
|
|
3976
|
-
});
|
|
3977
4081
|
}
|
|
3978
4082
|
if (!nextFocus) nextFocus = p.el.querySelector(`.${p.baseClassName}__item, .${p.baseClassName}__search_field`);
|
|
3979
4083
|
if (hasClass(nextFocus, `${p.baseClassName}__search_wrapper`)) nextFocus = nextFocus.querySelector("input");
|