@dodlhuat/basix 1.4.2 → 1.4.3
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 +13 -1
- package/css/calendar.scss +4 -3
- package/css/code-viewer.scss +1 -1
- package/css/datepicker.scss +83 -70
- package/css/editor.scss +2 -1
- package/css/flyout-menu.scss +2 -1
- package/css/form.scss +11 -32
- package/css/mixins.scss +25 -0
- package/css/range-slider.scss +7 -6
- package/css/stepper.scss +2 -1
- package/css/style.css +84 -71
- package/css/style.css.map +1 -1
- package/css/style.min.css +1 -1
- package/css/style.min.css.map +1 -1
- package/css/timepicker.scss +1 -1
- package/css/virtual-dropdown.scss +6 -16
- package/js/bottom-sheet.d.ts +3 -5
- package/js/bottom-sheet.js +39 -58
- package/js/calendar.d.ts +1 -2
- package/js/calendar.js +77 -84
- package/js/carousel.d.ts +1 -1
- package/js/carousel.js +22 -14
- package/js/chart.d.ts +1 -1
- package/js/chart.js +104 -65
- package/js/code-viewer.d.ts +1 -1
- package/js/code-viewer.js +7 -18
- package/js/color-picker.d.ts +2 -2
- package/js/color-picker.js +20 -22
- package/js/context-menu.d.ts +1 -1
- package/js/context-menu.js +10 -12
- package/js/datepicker.d.ts +14 -3
- package/js/datepicker.js +180 -99
- package/js/dropdown.d.ts +1 -1
- package/js/dropdown.js +4 -5
- package/js/editor.d.ts +1 -1
- package/js/editor.js +30 -34
- package/js/file-uploader.d.ts +2 -9
- package/js/file-uploader.js +57 -86
- package/js/flyout-menu.d.ts +3 -3
- package/js/flyout-menu.js +20 -22
- package/js/gallery.d.ts +1 -2
- package/js/gallery.js +14 -20
- package/js/group-picker.d.ts +1 -1
- package/js/group-picker.js +22 -29
- package/js/lightbox.d.ts +2 -2
- package/js/lightbox.js +28 -27
- package/js/listeners.d.ts +7 -0
- package/js/listeners.js +14 -0
- package/js/modal.d.ts +2 -1
- package/js/modal.js +13 -20
- package/js/popover.d.ts +2 -2
- package/js/popover.js +42 -37
- package/js/position.js +3 -5
- package/js/push-menu.d.ts +2 -0
- package/js/push-menu.js +21 -15
- package/js/range-slider.d.ts +2 -2
- package/js/range-slider.js +7 -6
- package/js/scroll.js +4 -7
- package/js/scrollbar.d.ts +3 -3
- package/js/scrollbar.js +39 -42
- package/js/select.d.ts +1 -1
- package/js/select.js +19 -23
- package/js/sidebar-nav.d.ts +1 -1
- package/js/sidebar-nav.js +13 -9
- package/js/stepper.d.ts +1 -1
- package/js/stepper.js +9 -11
- package/js/table.d.ts +1 -1
- package/js/table.js +24 -23
- package/js/tabs.d.ts +1 -1
- package/js/tabs.js +10 -17
- package/js/theme.d.ts +1 -0
- package/js/theme.js +6 -15
- package/js/timepicker.d.ts +8 -6
- package/js/timepicker.js +36 -36
- package/js/toast.d.ts +2 -1
- package/js/toast.js +8 -4
- package/js/tooltip.d.ts +1 -4
- package/js/tooltip.js +14 -23
- package/js/tree.d.ts +0 -1
- package/js/tree.js +6 -11
- package/js/utils.js +7 -8
- package/js/virtual-dropdown.d.ts +1 -1
- package/js/virtual-dropdown.js +26 -28
- package/package.json +1 -1
- package/css/calendar.css +0 -928
- package/css/guitar-chords.css +0 -251
- package/js/form-builder.js +0 -107
- package/js/guitar-chords.js +0 -268
- package/js/lazy-loader.js +0 -121
- package/js/request.js +0 -51
package/js/virtual-dropdown.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeHtml } from './utils.js';
|
|
2
|
+
import { ListenerGroup } from './listeners.js';
|
|
2
3
|
class VirtualDropdown {
|
|
3
4
|
container;
|
|
4
5
|
options;
|
|
@@ -21,11 +22,9 @@ class VirtualDropdown {
|
|
|
21
22
|
filteredOptions;
|
|
22
23
|
isOpen;
|
|
23
24
|
scrollTop;
|
|
24
|
-
|
|
25
|
+
listeners = new ListenerGroup();
|
|
25
26
|
constructor(config) {
|
|
26
|
-
const containerElement = typeof config.container === 'string'
|
|
27
|
-
? document.querySelector(config.container)
|
|
28
|
-
: config.container;
|
|
27
|
+
const containerElement = typeof config.container === 'string' ? document.querySelector(config.container) : config.container;
|
|
29
28
|
if (!containerElement) {
|
|
30
29
|
throw new Error('Container element not found');
|
|
31
30
|
}
|
|
@@ -34,8 +33,8 @@ class VirtualDropdown {
|
|
|
34
33
|
this.multiSelect = config.multiSelect ?? false;
|
|
35
34
|
this.searchable = config.searchable ?? false;
|
|
36
35
|
this.placeholder = config.placeholder || 'Select...';
|
|
37
|
-
this.renderLimit = config.renderLimit
|
|
38
|
-
this.itemHeight = config.itemHeight
|
|
36
|
+
this.renderLimit = config.renderLimit ?? 20;
|
|
37
|
+
this.itemHeight = config.itemHeight ?? 40;
|
|
39
38
|
this.onSelect = config.onSelect ?? null;
|
|
40
39
|
this.anchorName = `--vd-${Math.random().toString(36).slice(2, 9)}`;
|
|
41
40
|
this.selectedValues = new Set();
|
|
@@ -87,7 +86,7 @@ class VirtualDropdown {
|
|
|
87
86
|
return element;
|
|
88
87
|
}
|
|
89
88
|
bindEvents() {
|
|
90
|
-
const sig = { signal: this.
|
|
89
|
+
const sig = { signal: this.listeners.signal };
|
|
91
90
|
this.trigger.addEventListener('click', () => this.toggle(), sig);
|
|
92
91
|
this.trigger.addEventListener('keydown', (e) => {
|
|
93
92
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -122,7 +121,12 @@ class VirtualDropdown {
|
|
|
122
121
|
}, sig);
|
|
123
122
|
}
|
|
124
123
|
toggle() {
|
|
125
|
-
this.isOpen
|
|
124
|
+
if (this.isOpen) {
|
|
125
|
+
this.close();
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.open();
|
|
129
|
+
}
|
|
126
130
|
}
|
|
127
131
|
open() {
|
|
128
132
|
this.isOpen = true;
|
|
@@ -146,7 +150,7 @@ class VirtualDropdown {
|
|
|
146
150
|
}
|
|
147
151
|
else {
|
|
148
152
|
const lowerQuery = query.toLowerCase();
|
|
149
|
-
this.filteredOptions = this.options.filter(opt => opt.label.toLowerCase().includes(lowerQuery));
|
|
153
|
+
this.filteredOptions = this.options.filter((opt) => opt.label.toLowerCase().includes(lowerQuery));
|
|
150
154
|
}
|
|
151
155
|
this.listWrapper.scrollTop = 0;
|
|
152
156
|
this.scrollTop = 0;
|
|
@@ -180,29 +184,25 @@ class VirtualDropdown {
|
|
|
180
184
|
`;
|
|
181
185
|
})
|
|
182
186
|
.join('');
|
|
183
|
-
this.content.querySelectorAll('.dropdown-item').forEach(item => {
|
|
184
|
-
|
|
187
|
+
this.content.querySelectorAll('.dropdown-item').forEach((item) => {
|
|
188
|
+
item.addEventListener('click', (e) => {
|
|
185
189
|
e.stopPropagation();
|
|
186
190
|
const value = item.dataset.value;
|
|
187
|
-
if (value)
|
|
191
|
+
if (value)
|
|
188
192
|
this.handleSelect(value);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const handleItemKeydown = (e) => {
|
|
193
|
+
});
|
|
194
|
+
item.addEventListener('keydown', (e) => {
|
|
192
195
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
193
196
|
e.preventDefault();
|
|
194
197
|
const value = item.dataset.value;
|
|
195
|
-
if (value)
|
|
198
|
+
if (value)
|
|
196
199
|
this.handleSelect(value);
|
|
197
|
-
}
|
|
198
200
|
}
|
|
199
|
-
};
|
|
200
|
-
item.addEventListener('click', handleItemClick);
|
|
201
|
-
item.addEventListener('keydown', handleItemKeydown);
|
|
201
|
+
});
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
handleSelect(valueString) {
|
|
205
|
-
const selectedOpt = this.filteredOptions.find(o => String(o.value) === valueString);
|
|
205
|
+
const selectedOpt = this.filteredOptions.find((o) => String(o.value) === valueString);
|
|
206
206
|
if (!selectedOpt)
|
|
207
207
|
return;
|
|
208
208
|
const val = selectedOpt.value;
|
|
@@ -221,9 +221,7 @@ class VirtualDropdown {
|
|
|
221
221
|
this.close();
|
|
222
222
|
}
|
|
223
223
|
this.updateTrigger();
|
|
224
|
-
|
|
225
|
-
this.onSelect(Array.from(this.selectedValues));
|
|
226
|
-
}
|
|
224
|
+
this.onSelect?.(Array.from(this.selectedValues));
|
|
227
225
|
}
|
|
228
226
|
updateTrigger() {
|
|
229
227
|
if (this.selectedValues.size === 0) {
|
|
@@ -238,7 +236,7 @@ class VirtualDropdown {
|
|
|
238
236
|
}
|
|
239
237
|
else {
|
|
240
238
|
const val = Array.from(this.selectedValues)[0];
|
|
241
|
-
const opt = this.options.find(o => o.value === val);
|
|
239
|
+
const opt = this.options.find((o) => o.value === val);
|
|
242
240
|
this.triggerText.textContent = opt ? opt.label : String(val);
|
|
243
241
|
}
|
|
244
242
|
}
|
|
@@ -248,8 +246,8 @@ class VirtualDropdown {
|
|
|
248
246
|
}
|
|
249
247
|
setValue(values) {
|
|
250
248
|
this.selectedValues.clear();
|
|
251
|
-
values.forEach(val => {
|
|
252
|
-
if (this.options.some(opt => opt.value === val)) {
|
|
249
|
+
values.forEach((val) => {
|
|
250
|
+
if (this.options.some((opt) => opt.value === val)) {
|
|
253
251
|
this.selectedValues.add(val);
|
|
254
252
|
}
|
|
255
253
|
});
|
|
@@ -268,7 +266,7 @@ class VirtualDropdown {
|
|
|
268
266
|
destroy() {
|
|
269
267
|
if (this.isOpen)
|
|
270
268
|
this.menu.hidePopover();
|
|
271
|
-
this.
|
|
269
|
+
this.listeners.destroy();
|
|
272
270
|
this.container.innerHTML = '';
|
|
273
271
|
this.container.classList.remove('custom-dropdown', 'open');
|
|
274
272
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodlhuat/basix",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Basix is intended as a starter for the rapid development of a design. Each design element can be added individually to include only the data required. It is using plain javascript / typescript and therefore is not dependent on any plugin.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./css/*": "./css/*",
|