@dodlhuat/basix 1.0.0 → 1.1.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.
Files changed (142) hide show
  1. package/README.md +1 -1
  2. package/css/accordion.scss +31 -22
  3. package/css/alert.scss +79 -27
  4. package/css/button.scss +151 -102
  5. package/css/card.scss +11 -12
  6. package/css/carousel.scss +123 -87
  7. package/css/chart.scss +9 -11
  8. package/css/chat-bubbles.scss +2 -2
  9. package/css/checkbox.scss +72 -55
  10. package/css/chips.scss +52 -52
  11. package/css/code-viewer.scss +73 -98
  12. package/css/datepicker.scss +20 -0
  13. package/css/dropdown.scss +151 -137
  14. package/css/editor.scss +9 -6
  15. package/css/file-uploader.scss +187 -195
  16. package/css/flyout-menu.scss +20 -13
  17. package/css/form.scss +168 -115
  18. package/css/gallery.scss +62 -63
  19. package/css/grid.scss +0 -1
  20. package/css/modal.scss +117 -72
  21. package/css/placeholder.scss +17 -12
  22. package/css/properties.scss +6 -0
  23. package/css/push-menu.scss +70 -23
  24. package/css/radiobutton.scss +86 -64
  25. package/css/range-slider.scss +136 -0
  26. package/css/scrollbar.scss +69 -69
  27. package/css/spinner.scss +41 -66
  28. package/css/style.css +4351 -3735
  29. package/css/style.css.map +1 -1
  30. package/css/style.scss +2 -1
  31. package/css/switch.scss +43 -42
  32. package/css/table.scss +61 -40
  33. package/css/tabs.scss +12 -7
  34. package/css/timeline.scss +72 -69
  35. package/css/timepicker.scss +151 -72
  36. package/css/toast.scss +49 -48
  37. package/css/tooltip.scss +112 -122
  38. package/css/tree.scss +135 -192
  39. package/css/typography.scss +70 -9
  40. package/css/virtual-dropdown.scss +201 -142
  41. package/js/carousel.js +45 -18
  42. package/js/carousel.ts +217 -173
  43. package/js/datepicker.js +505 -497
  44. package/js/datepicker.ts +9 -0
  45. package/js/editor.js +398 -415
  46. package/js/file-uploader.js +142 -128
  47. package/js/file-uploader.ts +364 -350
  48. package/js/gallery.js +22 -15
  49. package/js/gallery.ts +17 -12
  50. package/js/index.js +718 -720
  51. package/js/index.ts +7 -8
  52. package/js/push-menu.js +113 -101
  53. package/js/push-menu.ts +17 -2
  54. package/js/range-slider.js +26 -0
  55. package/js/range-slider.ts +33 -0
  56. package/js/timepicker.js +144 -98
  57. package/js/timepicker.ts +194 -131
  58. package/js/tree.js +56 -28
  59. package/js/tree.ts +239 -218
  60. package/package.json +1 -1
  61. package/css/accordion.css +0 -109
  62. package/css/accordion.css.map +0 -1
  63. package/css/alert.css +0 -57
  64. package/css/alert.css.map +0 -1
  65. package/css/button.css +0 -69
  66. package/css/button.css.map +0 -1
  67. package/css/card.css +0 -144
  68. package/css/card.css.map +0 -1
  69. package/css/carousel.css +0 -118
  70. package/css/carousel.css.map +0 -1
  71. package/css/chart.css +0 -159
  72. package/css/chart.css.map +0 -1
  73. package/css/chat-bubbles.css +0 -97
  74. package/css/chat-bubbles.css.map +0 -1
  75. package/css/checkbox.css +0 -77
  76. package/css/checkbox.css.map +0 -1
  77. package/css/chips.css +0 -72
  78. package/css/chips.css.map +0 -1
  79. package/css/code-viewer.css +0 -97
  80. package/css/code-viewer.css.map +0 -1
  81. package/css/colors.css +0 -63
  82. package/css/colors.css.map +0 -1
  83. package/css/datepicker.css +0 -264
  84. package/css/datepicker.css.map +0 -1
  85. package/css/defaults.css +0 -118
  86. package/css/defaults.css.map +0 -1
  87. package/css/dropdown.css +0 -146
  88. package/css/dropdown.css.map +0 -1
  89. package/css/editor.css +0 -413
  90. package/css/file-uploader.css +0 -194
  91. package/css/file-uploader.css.map +0 -1
  92. package/css/flyout-menu.css +0 -345
  93. package/css/flyout-menu.css.map +0 -1
  94. package/css/form-builder.css +0 -9
  95. package/css/form-builder.css.map +0 -1
  96. package/css/form-builder.scss +0 -11
  97. package/css/form.css +0 -130
  98. package/css/form.css.map +0 -1
  99. package/css/gallery.css +0 -91
  100. package/css/gallery.css.map +0 -1
  101. package/css/grid.css +0 -44
  102. package/css/grid.css.map +0 -1
  103. package/css/icons.css +0 -327
  104. package/css/icons.css.map +0 -1
  105. package/css/modal.css +0 -97
  106. package/css/modal.css.map +0 -1
  107. package/css/parameters.css +0 -1
  108. package/css/parameters.css.map +0 -1
  109. package/css/placeholder.css +0 -50
  110. package/css/placeholder.css.map +0 -1
  111. package/css/progress.css +0 -51
  112. package/css/progress.css.map +0 -1
  113. package/css/properties.css +0 -31
  114. package/css/properties.css.map +0 -1
  115. package/css/push-menu.css +0 -145
  116. package/css/push-menu.css.map +0 -1
  117. package/css/radiobutton.css +0 -91
  118. package/css/radiobutton.css.map +0 -1
  119. package/css/reset.css +0 -46
  120. package/css/reset.css.map +0 -1
  121. package/css/scrollbar.css +0 -91
  122. package/css/scrollbar.css.map +0 -1
  123. package/css/spinner.css +0 -118
  124. package/css/spinner.css.map +0 -1
  125. package/css/switch.css +0 -66
  126. package/css/switch.css.map +0 -1
  127. package/css/table.css +0 -201
  128. package/css/table.css.map +0 -1
  129. package/css/tabs.css +0 -135
  130. package/css/tabs.css.map +0 -1
  131. package/css/timeline.css +0 -69
  132. package/css/timeline.css.map +0 -1
  133. package/css/toast.css +0 -98
  134. package/css/toast.css.map +0 -1
  135. package/css/tooltip.css +0 -151
  136. package/css/tooltip.css.map +0 -1
  137. package/css/tree.css +0 -199
  138. package/css/tree.css.map +0 -1
  139. package/css/typography.css +0 -137
  140. package/css/typography.css.map +0 -1
  141. package/css/virtual-dropdown.css +0 -149
  142. package/css/virtual-dropdown.css.map +0 -1
package/js/gallery.js CHANGED
@@ -8,9 +8,8 @@ class MasonryGallery {
8
8
  this.handleScroll = () => {
9
9
  if (this.isFetching)
10
10
  return;
11
- const { scrollTop, scrollHeight, clientHeight } = document.documentElement;
12
- if (scrollTop + clientHeight >=
13
- scrollHeight - this.options.scrollThreshold) {
11
+ const rect = this.container.getBoundingClientRect();
12
+ if (rect.bottom > 0 && rect.bottom <= window.innerHeight + this.options.scrollThreshold) {
14
13
  this.loadMoreImages();
15
14
  }
16
15
  };
@@ -24,7 +23,7 @@ class MasonryGallery {
24
23
  minColumnWidth: options.minColumnWidth ?? 250,
25
24
  scrollThreshold: options.scrollThreshold ?? 100,
26
25
  reload: 2,
27
- fetchFunction: options.fetchFunction ?? this.fetchMockImages(),
26
+ fetchFunction: options.fetchFunction ?? this.fetchMockImages,
28
27
  };
29
28
  this.init();
30
29
  }
@@ -85,8 +84,8 @@ class MasonryGallery {
85
84
  this.addToShortestColumn(item);
86
85
  });
87
86
  }
88
- async loadMoreImages() {
89
- this.reloaded++;
87
+ async loadMoreImages(isAutoFill = false) {
88
+ if (!isAutoFill) this.reloaded++;
90
89
  if (this.options.reload > 0 && this.reloaded > this.options.reload) {
91
90
  console.warn("Maximum reload limit reached.");
92
91
  return;
@@ -96,7 +95,7 @@ class MasonryGallery {
96
95
  this.isFetching = true;
97
96
  this.toggleLoader(true);
98
97
  try {
99
- const newImages = await this.options.fetchFunction;
98
+ const newImages = await this.options.fetchFunction();
100
99
  this.renderImages(newImages);
101
100
  }
102
101
  catch (error) {
@@ -105,6 +104,14 @@ class MasonryGallery {
105
104
  finally {
106
105
  this.isFetching = false;
107
106
  this.toggleLoader(false);
107
+ // If the rendered content doesn't fill the viewport, auto-load the next
108
+ // batch without waiting for a scroll event (multi-column layout is shorter)
109
+ requestAnimationFrame(() => {
110
+ const rect = this.container.getBoundingClientRect();
111
+ if (rect.bottom <= window.innerHeight + this.options.scrollThreshold) {
112
+ this.loadMoreImages(true);
113
+ }
114
+ });
108
115
  }
109
116
  }
110
117
  toggleLoader(show) {
@@ -112,9 +119,9 @@ class MasonryGallery {
112
119
  this.loader.classList.toggle("hidden", !show);
113
120
  }
114
121
  }
115
- fetchMockImages() {
122
+ fetchMockImages = () => {
116
123
  throw Error("Method not implemented.");
117
- }
124
+ };
118
125
  renderImages(imageDataList) {
119
126
  imageDataList.forEach((data) => {
120
127
  const item = this.createCard(data);
@@ -135,12 +142,12 @@ class MasonryGallery {
135
142
  createCard(data) {
136
143
  const div = document.createElement("div");
137
144
  div.className = "masonry-item";
138
- div.innerHTML = `
139
- <img src="${this.escapeHtml(data.src)}" alt="${this.escapeHtml(data.title)}" loading="lazy">
140
- <div class="masonry-item-info">
141
- <h3 class="masonry-item-title">${this.escapeHtml(data.title)}</h3>
142
- <p class="masonry-item-desc">${this.escapeHtml(data.desc)}</p>
143
- </div>
145
+ div.innerHTML = `
146
+ <img src="${this.escapeHtml(data.src)}" alt="${this.escapeHtml(data.title)}" loading="lazy">
147
+ <div class="masonry-item-info">
148
+ <h3 class="masonry-item-title">${this.escapeHtml(data.title)}</h3>
149
+ <p class="masonry-item-desc">${this.escapeHtml(data.desc)}</p>
150
+ </div>
144
151
  `;
145
152
  return div;
146
153
  }
package/js/gallery.ts CHANGED
@@ -9,7 +9,7 @@ interface MasonryGalleryOptions {
9
9
  scrollThreshold?: number;
10
10
  loaderSelector?: string;
11
11
  reload?: number;
12
- fetchFunction?: Promise<ImageData[]>;
12
+ fetchFunction?: () => Promise<ImageData[]>;
13
13
  }
14
14
 
15
15
  class MasonryGallery {
@@ -34,7 +34,7 @@ class MasonryGallery {
34
34
  minColumnWidth: options.minColumnWidth ?? 250,
35
35
  scrollThreshold: options.scrollThreshold ?? 100,
36
36
  reload: 2,
37
- fetchFunction: options.fetchFunction ?? this.fetchMockImages(),
37
+ fetchFunction: options.fetchFunction ?? this.fetchMockImages,
38
38
  };
39
39
 
40
40
  this.init();
@@ -117,17 +117,14 @@ class MasonryGallery {
117
117
  private handleScroll = (): void => {
118
118
  if (this.isFetching) return;
119
119
 
120
- const { scrollTop, scrollHeight, clientHeight } = document.documentElement;
121
- if (
122
- scrollTop + clientHeight >=
123
- scrollHeight - this.options.scrollThreshold
124
- ) {
120
+ const rect = this.container.getBoundingClientRect();
121
+ if (rect.bottom > 0 && rect.bottom <= window.innerHeight + this.options.scrollThreshold) {
125
122
  this.loadMoreImages();
126
123
  }
127
124
  };
128
125
 
129
- private async loadMoreImages(): Promise<void> {
130
- this.reloaded++;
126
+ private async loadMoreImages(isAutoFill = false): Promise<void> {
127
+ if (!isAutoFill) this.reloaded++;
131
128
  if (this.options.reload > 0 && this.reloaded > this.options.reload) {
132
129
  console.warn("Maximum reload limit reached.");
133
130
  return;
@@ -138,13 +135,21 @@ class MasonryGallery {
138
135
  this.toggleLoader(true);
139
136
 
140
137
  try {
141
- const newImages = await this.options.fetchFunction;
138
+ const newImages = await this.options.fetchFunction();
142
139
  this.renderImages(newImages);
143
140
  } catch (error) {
144
141
  throw new Error("Error loading images: " + error);
145
142
  } finally {
146
143
  this.isFetching = false;
147
144
  this.toggleLoader(false);
145
+ // If the rendered content doesn't fill the viewport, auto-load the next
146
+ // batch without waiting for a scroll event (multi-column layout is shorter)
147
+ requestAnimationFrame(() => {
148
+ const rect = this.container.getBoundingClientRect();
149
+ if (rect.bottom <= window.innerHeight + this.options.scrollThreshold) {
150
+ this.loadMoreImages(true);
151
+ }
152
+ });
148
153
  }
149
154
  }
150
155
 
@@ -154,9 +159,9 @@ class MasonryGallery {
154
159
  }
155
160
  }
156
161
 
157
- private fetchMockImages(): Promise<ImageData[]> {
162
+ private fetchMockImages = (): Promise<ImageData[]> => {
158
163
  throw Error("Method not implemented.");
159
- }
164
+ };
160
165
 
161
166
  private renderImages(imageDataList: ImageData[]): void {
162
167
  imageDataList.forEach((data) => {