@dodlhuat/basix 1.4.1 → 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.
Files changed (90) hide show
  1. package/README.md +38 -1
  2. package/css/calendar.scss +4 -3
  3. package/css/code-viewer.scss +1 -1
  4. package/css/datepicker.scss +83 -70
  5. package/css/editor.scss +2 -1
  6. package/css/flyout-menu.scss +2 -1
  7. package/css/form.scss +11 -32
  8. package/css/mixins.scss +25 -0
  9. package/css/range-slider.scss +63 -6
  10. package/css/stepper.scss +2 -1
  11. package/css/style.css +124 -71
  12. package/css/style.css.map +1 -1
  13. package/css/style.min.css +1 -1
  14. package/css/style.min.css.map +1 -1
  15. package/css/timepicker.scss +1 -1
  16. package/css/virtual-dropdown.scss +6 -16
  17. package/js/bottom-sheet.d.ts +3 -5
  18. package/js/bottom-sheet.js +39 -58
  19. package/js/calendar.d.ts +1 -2
  20. package/js/calendar.js +77 -84
  21. package/js/carousel.d.ts +1 -1
  22. package/js/carousel.js +22 -14
  23. package/js/chart.d.ts +1 -1
  24. package/js/chart.js +104 -65
  25. package/js/code-viewer.d.ts +1 -1
  26. package/js/code-viewer.js +7 -18
  27. package/js/color-picker.d.ts +2 -2
  28. package/js/color-picker.js +20 -22
  29. package/js/context-menu.d.ts +1 -1
  30. package/js/context-menu.js +10 -12
  31. package/js/datepicker.d.ts +14 -3
  32. package/js/datepicker.js +180 -99
  33. package/js/dropdown.d.ts +1 -1
  34. package/js/dropdown.js +4 -5
  35. package/js/editor.d.ts +1 -1
  36. package/js/editor.js +30 -34
  37. package/js/file-uploader.d.ts +2 -9
  38. package/js/file-uploader.js +57 -86
  39. package/js/flyout-menu.d.ts +3 -3
  40. package/js/flyout-menu.js +20 -22
  41. package/js/gallery.d.ts +1 -2
  42. package/js/gallery.js +14 -20
  43. package/js/group-picker.d.ts +1 -1
  44. package/js/group-picker.js +22 -29
  45. package/js/lightbox.d.ts +2 -2
  46. package/js/lightbox.js +28 -27
  47. package/js/listeners.d.ts +7 -0
  48. package/js/listeners.js +14 -0
  49. package/js/modal.d.ts +2 -1
  50. package/js/modal.js +13 -20
  51. package/js/popover.d.ts +2 -2
  52. package/js/popover.js +42 -37
  53. package/js/position.js +3 -5
  54. package/js/push-menu.d.ts +2 -0
  55. package/js/push-menu.js +21 -15
  56. package/js/range-slider.d.ts +15 -1
  57. package/js/range-slider.js +67 -7
  58. package/js/scroll.js +4 -7
  59. package/js/scrollbar.d.ts +3 -3
  60. package/js/scrollbar.js +39 -42
  61. package/js/select.d.ts +1 -1
  62. package/js/select.js +19 -23
  63. package/js/sidebar-nav.d.ts +1 -1
  64. package/js/sidebar-nav.js +13 -9
  65. package/js/stepper.d.ts +1 -1
  66. package/js/stepper.js +9 -11
  67. package/js/table.d.ts +1 -1
  68. package/js/table.js +24 -23
  69. package/js/tabs.d.ts +1 -1
  70. package/js/tabs.js +10 -17
  71. package/js/theme.d.ts +1 -0
  72. package/js/theme.js +6 -15
  73. package/js/timepicker.d.ts +8 -6
  74. package/js/timepicker.js +36 -36
  75. package/js/toast.d.ts +2 -1
  76. package/js/toast.js +8 -4
  77. package/js/tooltip.d.ts +1 -4
  78. package/js/tooltip.js +14 -23
  79. package/js/tree.d.ts +0 -1
  80. package/js/tree.js +6 -11
  81. package/js/utils.js +7 -8
  82. package/js/virtual-dropdown.d.ts +1 -1
  83. package/js/virtual-dropdown.js +26 -28
  84. package/package.json +1 -1
  85. package/css/calendar.css +0 -928
  86. package/css/guitar-chords.css +0 -251
  87. package/js/form-builder.js +0 -107
  88. package/js/guitar-chords.js +0 -268
  89. package/js/lazy-loader.js +0 -121
  90. package/js/request.js +0 -51
package/js/tree.js CHANGED
@@ -22,9 +22,7 @@ class TreeComponent {
22
22
  selectedNode;
23
23
  options;
24
24
  constructor(elementOrSelector, data, options = {}) {
25
- const container = typeof elementOrSelector === 'string'
26
- ? document.querySelector(elementOrSelector)
27
- : elementOrSelector;
25
+ const container = typeof elementOrSelector === 'string' ? document.querySelector(elementOrSelector) : elementOrSelector;
28
26
  if (!container) {
29
27
  throw new Error(`TreeComponent: Element not found for selector "${elementOrSelector}"`);
30
28
  }
@@ -32,14 +30,11 @@ class TreeComponent {
32
30
  this.data = data;
33
31
  this.selectedNode = null;
34
32
  this.options = options;
35
- this.init();
36
- }
37
- init() {
38
33
  this.render();
39
34
  }
40
35
  render() {
41
36
  this.container.innerHTML = '';
42
- this.data.forEach(node => {
37
+ this.data.forEach((node) => {
43
38
  this.renderNode(node, this.container);
44
39
  });
45
40
  }
@@ -107,7 +102,7 @@ class TreeComponent {
107
102
  childrenUl.classList.add('expanded');
108
103
  childrenUl.style.height = 'auto';
109
104
  }
110
- node.children.forEach(child => {
105
+ node.children.forEach((child) => {
111
106
  this.renderNode(child, childrenUl);
112
107
  });
113
108
  return childrenUl;
@@ -126,13 +121,13 @@ class TreeComponent {
126
121
  }
127
122
  }
128
123
  expandChildren(container) {
129
- container.style.height = container.scrollHeight + 'px';
124
+ container.style.height = `${container.scrollHeight}px`;
130
125
  container.addEventListener('transitionend', () => {
131
126
  container.style.height = 'auto';
132
127
  }, { once: true });
133
128
  }
134
129
  collapseChildren(container) {
135
- container.style.height = container.offsetHeight + 'px';
130
+ container.style.height = `${container.offsetHeight}px`;
136
131
  requestAnimationFrame(() => {
137
132
  container.style.height = '0';
138
133
  });
@@ -172,7 +167,7 @@ class TreeComponent {
172
167
  });
173
168
  }
174
169
  traverseNodes(nodes, callback) {
175
- nodes.forEach(node => {
170
+ nodes.forEach((node) => {
176
171
  callback(node);
177
172
  if (node.children.length > 0) {
178
173
  this.traverseNodes(node.children, callback);
package/js/utils.js CHANGED
@@ -9,10 +9,10 @@ const utils = {
9
9
  },
10
10
  value(element) {
11
11
  if (element.hasAttribute('value')) {
12
- return element.getAttribute('value') || '';
12
+ return element.getAttribute('value');
13
13
  }
14
14
  if (element.hasAttribute('data-value')) {
15
- return element.getAttribute('data-value') || '';
15
+ return element.getAttribute('data-value');
16
16
  }
17
17
  return element.innerText;
18
18
  },
@@ -26,11 +26,11 @@ const utils = {
26
26
  return undefined;
27
27
  },
28
28
  isList(element) {
29
- return NodeList.prototype.isPrototypeOf(element);
29
+ return element instanceof NodeList;
30
30
  },
31
31
  isHidden(element) {
32
32
  return element.offsetParent === null;
33
- }
33
+ },
34
34
  };
35
35
  function escapeHtml(text) {
36
36
  const div = document.createElement('div');
@@ -40,11 +40,10 @@ function escapeHtml(text) {
40
40
  function sanitizeHtml(html) {
41
41
  const parser = new DOMParser();
42
42
  const doc = parser.parseFromString(html, 'text/html');
43
- doc.querySelectorAll('script, style, iframe, object, embed').forEach(el => el.remove());
44
- doc.querySelectorAll('*').forEach(el => {
43
+ doc.querySelectorAll('script, style, iframe, object, embed').forEach((el) => el.remove());
44
+ doc.querySelectorAll('*').forEach((el) => {
45
45
  for (const attr of Array.from(el.attributes)) {
46
- if (attr.name.startsWith('on') ||
47
- attr.value.trim().toLowerCase().startsWith('javascript:')) {
46
+ if (attr.name.startsWith('on') || attr.value.trim().toLowerCase().startsWith('javascript:')) {
48
47
  el.removeAttribute(attr.name);
49
48
  }
50
49
  }
@@ -34,7 +34,7 @@ declare class VirtualDropdown {
34
34
  private filteredOptions;
35
35
  private isOpen;
36
36
  private scrollTop;
37
- private abortController;
37
+ private listeners;
38
38
  constructor(config: VirtualDropdownConfig);
39
39
  private init;
40
40
  private renderBase;
@@ -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
- abortController = new AbortController();
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 || 20;
38
- this.itemHeight = config.itemHeight || 40;
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.abortController.signal };
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 ? this.close() : this.open();
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
- const handleItemClick = (e) => {
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
- if (this.onSelect) {
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.abortController.abort();
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.1",
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/*",