@melodicdev/components 3.1.0 → 4.0.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/assets/melodic-components.js +4269 -2377
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +5477 -3831
- package/lib/components/data-display/calendar-view/calendar-view-month.template.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view-month.template.js +17 -0
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts +23 -3
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.component.js +76 -21
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +9 -0
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.js +68 -19
- package/lib/components/data-display/data-grid/data-grid.component.d.ts +24 -0
- package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.component.js +104 -31
- package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.template.js +3 -0
- package/lib/components/data-display/table/table.component.d.ts +7 -0
- package/lib/components/data-display/table/table.component.d.ts.map +1 -1
- package/lib/components/data-display/table/table.component.js +20 -5
- package/lib/components/data-display/table/table.template.d.ts.map +1 -1
- package/lib/components/data-display/table/table.template.js +3 -0
- package/lib/components/data-display/table-core/index.d.ts +1 -0
- package/lib/components/data-display/table-core/index.d.ts.map +1 -1
- package/lib/components/data-display/table-core/index.js +1 -0
- package/lib/components/data-display/table-core/memo.d.ts +10 -0
- package/lib/components/data-display/table-core/memo.d.ts.map +1 -0
- package/lib/components/data-display/table-core/memo.js +20 -0
- package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.styles.js +25 -0
- package/lib/components/feedback/progress/progress.styles.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.styles.js +8 -3
- package/lib/components/feedback/spinner/spinner.styles.d.ts.map +1 -1
- package/lib/components/feedback/spinner/spinner.styles.js +2 -11
- package/lib/components/feedback/toast/toast-container.template.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast-container.template.js +4 -0
- package/lib/components/feedback/toast/toast.component.d.ts +3 -2
- package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.component.js +10 -0
- package/lib/components/feedback/toast/toast.service.d.ts +26 -6
- package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.service.js +53 -18
- package/lib/components/feedback/toast/toast.template.js +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts +7 -0
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +39 -0
- package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.template.js +5 -1
- package/lib/components/forms/button-group/button-group.component.d.ts +3 -2
- package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.js +11 -1
- package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -0
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +5 -1
- package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.template.js +2 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts +21 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.component.js +69 -2
- package/lib/components/forms/date-picker/calendar.template.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.template.js +6 -3
- package/lib/components/forms/date-picker/date-picker.component.d.ts +6 -0
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +41 -12
- package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload.component.js +15 -5
- package/lib/components/forms/form-field/form-field.component.d.ts +8 -0
- package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
- package/lib/components/forms/form-field/form-field.component.js +41 -6
- package/lib/components/forms/form-field/form-field.template.js +1 -1
- package/lib/components/forms/input/input.component.d.ts +26 -3
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/input/input.component.js +46 -6
- package/lib/components/forms/input/input.template.d.ts.map +1 -1
- package/lib/components/forms/input/input.template.js +9 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card-group.component.js +34 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card.component.js +7 -1
- package/lib/components/forms/radio-card-group/radio-card.template.js +1 -1
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +13 -1
- package/lib/components/forms/select/select.template.d.ts.map +1 -1
- package/lib/components/forms/select/select.template.js +5 -1
- package/lib/components/forms/textarea/textarea.component.d.ts +10 -3
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.component.js +10 -5
- package/lib/components/forms/textarea/textarea.template.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.template.js +2 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts +16 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/time-picker/time-picker.component.js +43 -3
- package/lib/components/foundation/container/container.component.js +5 -5
- package/lib/components/foundation/container/container.styles.d.ts.map +1 -1
- package/lib/components/foundation/container/container.styles.js +10 -0
- package/lib/components/foundation/stack/stack.component.d.ts +6 -0
- package/lib/components/foundation/stack/stack.component.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.component.js +11 -5
- package/lib/components/foundation/stack/stack.styles.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.styles.js +14 -0
- package/lib/components/general/icon/icon.template.d.ts.map +1 -1
- package/lib/components/general/icon/icon.template.js +7 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +2 -1
- package/lib/components/navigation/functions/match-by-route.function.d.ts +16 -0
- package/lib/components/navigation/functions/match-by-route.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/match-by-route.function.js +34 -0
- package/lib/components/navigation/functions/route-link.function.d.ts +20 -0
- package/lib/components/navigation/functions/route-link.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/route-link.function.js +34 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts +8 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.component.js +12 -2
- package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.styles.js +10 -0
- package/lib/components/navigation/pagination/pagination.template.js +2 -2
- package/lib/components/navigation/sidebar/sidebar-item.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar-item.template.js +5 -1
- package/lib/components/navigation/sidebar/sidebar.component.d.ts +12 -6
- package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.component.js +20 -12
- package/lib/components/navigation/sidebar/sidebar.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.template.js +5 -1
- package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.component.js +19 -1
- package/lib/components/navigation/steps/step.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.template.js +6 -0
- package/lib/components/navigation/steps/steps.component.d.ts +10 -0
- package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.component.js +42 -9
- package/lib/components/navigation/steps/steps.template.js +9 -0
- package/lib/components/navigation/tabs/tab-panel.styles.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.styles.js +7 -2
- package/lib/components/navigation/tabs/tabs.component.d.ts +10 -0
- package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.component.js +36 -7
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts +19 -9
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog-ref.class.js +37 -5
- package/lib/components/overlays/dropdown/dropdown.component.d.ts +7 -0
- package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown.component.js +26 -11
- package/lib/components/overlays/popover/popover.component.d.ts +8 -0
- package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
- package/lib/components/overlays/popover/popover.component.js +17 -0
- package/lib/components/overlays/tooltip/tooltip.component.d.ts +6 -5
- package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.component.js +14 -10
- package/lib/components/sections/app-shell/app-shell.component.d.ts +13 -0
- package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.component.js +45 -1
- package/lib/components/sections/app-shell/app-shell.styles.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.styles.js +15 -0
- package/lib/components/sections/app-shell/app-shell.template.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.template.js +5 -0
- package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.template.js +6 -1
- package/lib/directives/tooltip.directive.d.ts.map +1 -1
- package/lib/directives/tooltip.directive.js +39 -6
- package/lib/theme/functions/apply-theme.function.d.ts +4 -1
- package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
- package/lib/theme/functions/apply-theme.function.js +20 -4
- package/lib/theme/functions/create-theme.function.js +0 -1
- package/lib/utils/accessibility/cross-root-aria.d.ts +40 -0
- package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -0
- package/lib/utils/accessibility/cross-root-aria.js +97 -0
- package/lib/utils/accessibility/index.d.ts +1 -0
- package/lib/utils/accessibility/index.d.ts.map +1 -1
- package/lib/utils/accessibility/index.js +1 -0
- package/lib/utils/directives/index.d.ts +1 -0
- package/lib/utils/directives/index.d.ts.map +1 -1
- package/lib/utils/directives/index.js +1 -0
- package/lib/utils/directives/watch-light-slots.d.ts +20 -0
- package/lib/utils/directives/watch-light-slots.d.ts.map +1 -0
- package/lib/utils/directives/watch-light-slots.js +36 -0
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@ import { MelodicComponent } from '@melodicdev/core';
|
|
|
8
8
|
import { dataGridTemplate } from './data-grid.template.js';
|
|
9
9
|
import { dataGridStyles } from './data-grid.styles.js';
|
|
10
10
|
import { TableCore } from '../table-core/index.js';
|
|
11
|
+
import { memoOn } from '../table-core/index.js';
|
|
11
12
|
/**
|
|
12
13
|
* ml-data-grid — Full-featured data grid with virtual scrolling, sorting, filtering,
|
|
13
14
|
* selection, column resizing, column reordering, pinned columns, and pagination.
|
|
@@ -95,6 +96,19 @@ let DataGridComponent = class DataGridComponent {
|
|
|
95
96
|
});
|
|
96
97
|
this._resizeStartX = 0;
|
|
97
98
|
this._resizeStartWidth = 0;
|
|
99
|
+
/**
|
|
100
|
+
* Publish the header height as a CSS variable for the sticky filter row.
|
|
101
|
+
*
|
|
102
|
+
* `getBoundingClientRect()` forces a synchronous layout, and this ran on
|
|
103
|
+
* every render — including the render each `pointermove` of a column
|
|
104
|
+
* resize produced. Only write when the value actually changed, and skip
|
|
105
|
+
* entirely while resizing (the header height cannot change then).
|
|
106
|
+
*/
|
|
107
|
+
this._headerHeight = 0;
|
|
108
|
+
// ── Data pipeline ─────────────────────────────────────────────────────────────
|
|
109
|
+
this._filteredRowsMemo = memoOn();
|
|
110
|
+
this._sortedRowsMemo = memoOn();
|
|
111
|
+
this._pagedRowsMemo = memoOn();
|
|
98
112
|
this.isRowSelected = (index) => this._core.isRowSelected(index);
|
|
99
113
|
// ── Event handlers ────────────────────────────────────────────────────────────
|
|
100
114
|
this.handleSort = (col) => {
|
|
@@ -139,16 +153,24 @@ let DataGridComponent = class DataGridComponent {
|
|
|
139
153
|
if (this.resizingKey !== key)
|
|
140
154
|
return;
|
|
141
155
|
const delta = e.clientX - this._resizeStartX;
|
|
142
|
-
const col = this.columns.find(c => c.key === key);
|
|
156
|
+
const col = this.columns.find((c) => c.key === key);
|
|
143
157
|
const minW = col?.minWidth ?? 80;
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
const width = Math.max(minW, this._resizeStartWidth + delta);
|
|
159
|
+
// Writing to `colWidths` re-renders the entire grid — every row, every
|
|
160
|
+
// cell — on each pointermove. Drive the live drag through a CSS custom
|
|
161
|
+
// property instead and commit the value once, on pointerup.
|
|
162
|
+
this._pendingResizeWidth = width;
|
|
163
|
+
this.elementRef.style.setProperty(`--ml-grid-col-${key}`, `${width}px`);
|
|
148
164
|
};
|
|
165
|
+
this._pendingResizeWidth = null;
|
|
149
166
|
this.handleResizeEnd = () => {
|
|
150
167
|
if (!this.resizingKey)
|
|
151
168
|
return;
|
|
169
|
+
if (this._pendingResizeWidth !== null) {
|
|
170
|
+
this.colWidths = { ...this.colWidths, [this.resizingKey]: this._pendingResizeWidth };
|
|
171
|
+
this.elementRef.style.removeProperty(`--ml-grid-col-${this.resizingKey}`);
|
|
172
|
+
this._pendingResizeWidth = null;
|
|
173
|
+
}
|
|
152
174
|
this.elementRef.dispatchEvent(new CustomEvent('ml:column-resize', {
|
|
153
175
|
bubbles: true,
|
|
154
176
|
composed: true,
|
|
@@ -156,6 +178,44 @@ let DataGridComponent = class DataGridComponent {
|
|
|
156
178
|
}));
|
|
157
179
|
this.resizingKey = null;
|
|
158
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Keyboard equivalents for the header's mouse-only interactions.
|
|
183
|
+
*
|
|
184
|
+
* Enter/Space sorts; Ctrl/Cmd + Arrow moves the column. Drag-and-drop
|
|
185
|
+
* reordering and click-to-sort were otherwise unreachable without a mouse.
|
|
186
|
+
*/
|
|
187
|
+
this.handleHeaderKeyDown = (col, event) => {
|
|
188
|
+
if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
|
|
189
|
+
if (col.reorderable === false) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
this.moveColumn(col.key, event.key === 'ArrowLeft' ? -1 : 1);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (col.sortable && (event.key === 'Enter' || event.key === ' ')) {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
this.handleSort(col);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
/** Move a column `delta` positions and announce the new order. */
|
|
202
|
+
this.moveColumn = (key, delta) => {
|
|
203
|
+
const base = this.colOrder.length ? this.colOrder : this.columns.map((col) => col.key);
|
|
204
|
+
const order = [...base];
|
|
205
|
+
const from = order.indexOf(key);
|
|
206
|
+
const to = from + delta;
|
|
207
|
+
if (from === -1 || to < 0 || to >= order.length) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
order.splice(from, 1);
|
|
211
|
+
order.splice(to, 0, key);
|
|
212
|
+
this.colOrder = order;
|
|
213
|
+
this.elementRef.dispatchEvent(new CustomEvent('ml:column-reorder', {
|
|
214
|
+
bubbles: true,
|
|
215
|
+
composed: true,
|
|
216
|
+
detail: { order: this.colOrder }
|
|
217
|
+
}));
|
|
218
|
+
};
|
|
159
219
|
this.handleDragStart = (key, e) => {
|
|
160
220
|
this.draggingKey = key;
|
|
161
221
|
if (e.dataTransfer)
|
|
@@ -239,19 +299,23 @@ let DataGridComponent = class DataGridComponent {
|
|
|
239
299
|
this._core.attachScroller();
|
|
240
300
|
}
|
|
241
301
|
onRender() {
|
|
242
|
-
|
|
243
|
-
const shadow = this.elementRef.shadowRoot;
|
|
244
|
-
if (shadow) {
|
|
245
|
-
const headerRow = shadow.querySelector('.ml-data-grid__header-row');
|
|
246
|
-
if (headerRow) {
|
|
247
|
-
const h = headerRow.getBoundingClientRect().height;
|
|
248
|
-
if (h > 0) {
|
|
249
|
-
this.elementRef.style.setProperty('--ml-grid-header-h', `${h}px`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
302
|
+
this.syncHeaderHeight();
|
|
253
303
|
this._core.syncRenderWindow();
|
|
254
304
|
}
|
|
305
|
+
syncHeaderHeight() {
|
|
306
|
+
if (this.resizingKey) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const headerRow = this.elementRef.shadowRoot?.querySelector('.ml-data-grid__header-row');
|
|
310
|
+
if (!headerRow) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const height = headerRow.getBoundingClientRect().height;
|
|
314
|
+
if (height > 0 && height !== this._headerHeight) {
|
|
315
|
+
this._headerHeight = height;
|
|
316
|
+
this.elementRef.style.setProperty('--ml-grid-header-h', `${height}px`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
255
319
|
onDestroy() {
|
|
256
320
|
this._core.detach();
|
|
257
321
|
}
|
|
@@ -264,25 +328,34 @@ let DataGridComponent = class DataGridComponent {
|
|
|
264
328
|
}
|
|
265
329
|
this.colWidths = newWidths;
|
|
266
330
|
}
|
|
267
|
-
//
|
|
331
|
+
// The filter object is mutated in place, so its identity is not a usable
|
|
332
|
+
// memo key; its serialized contents are.
|
|
333
|
+
get _filterKey() {
|
|
334
|
+
return JSON.stringify(this.filters);
|
|
335
|
+
}
|
|
268
336
|
get filteredRows() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
337
|
+
// Memoized — see the note on ml-table.sortedRows.
|
|
338
|
+
return this._filteredRowsMemo([this.rows, this.serverSide, this._filterKey], () => {
|
|
339
|
+
if (this.serverSide)
|
|
340
|
+
return this.rows;
|
|
341
|
+
const entries = Object.entries(this.filters).filter(([, v]) => v !== '');
|
|
342
|
+
if (!entries.length)
|
|
343
|
+
return this.rows;
|
|
344
|
+
return this.rows.filter((row) => entries.every(([key, val]) => String(row[key] ?? '').toLowerCase().includes(val.toLowerCase())));
|
|
345
|
+
});
|
|
275
346
|
}
|
|
276
347
|
get sortedRows() {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return this._core.sortRows(this.filteredRows);
|
|
348
|
+
const filtered = this.filteredRows;
|
|
349
|
+
return this._sortedRowsMemo([filtered, this.serverSide, this.sortKey, this.sortDirection], () => this.serverSide ? filtered : this._core.sortRows(filtered));
|
|
280
350
|
}
|
|
281
351
|
get pagedRows() {
|
|
282
352
|
if (this.serverSide)
|
|
283
353
|
return this.rows;
|
|
284
|
-
const
|
|
285
|
-
return this.
|
|
354
|
+
const sorted = this.sortedRows;
|
|
355
|
+
return this._pagedRowsMemo([sorted, this.currentPage, this.pageSize], () => {
|
|
356
|
+
const start = (this.currentPage - 1) * this.pageSize;
|
|
357
|
+
return sorted.slice(start, start + this.pageSize);
|
|
358
|
+
});
|
|
286
359
|
}
|
|
287
360
|
get processedRows() {
|
|
288
361
|
return this.pagedRows;
|
|
@@ -317,9 +390,9 @@ let DataGridComponent = class DataGridComponent {
|
|
|
317
390
|
return colTotal + (this.selectable ? 44 : 0);
|
|
318
391
|
}
|
|
319
392
|
get gridTemplateColumns() {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
393
|
+
// `var(--ml-grid-col-<key>, <committed>px)` lets a live column drag
|
|
394
|
+
// update the layout by writing one custom property, without a render.
|
|
395
|
+
const cols = this.orderedColumns.map((col) => `var(--ml-grid-col-${col.key}, ${this.columnWidths[col.key] ?? 150}px)`).join(' ');
|
|
323
396
|
return this.selectable ? `44px ${cols}` : cols;
|
|
324
397
|
}
|
|
325
398
|
getPinnedLeftOffset(key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-grid.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAUlE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"data-grid.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAUlE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,6CAmOpD"}
|
|
@@ -69,6 +69,9 @@ export function dataGridTemplate(c) {
|
|
|
69
69
|
@dragend=${c.handleDragEnd}
|
|
70
70
|
@drop=${() => c.handleDrop(col.key)}
|
|
71
71
|
@click=${() => c.handleSort(col)}
|
|
72
|
+
@keydown=${(e) => c.handleHeaderKeyDown(col, e)}
|
|
73
|
+
tabindex=${col.sortable || col.reorderable !== false ? '0' : ''}
|
|
74
|
+
role="columnheader"
|
|
72
75
|
aria-sort=${c.sortKey === col.key
|
|
73
76
|
? (c.sortDirection === 'asc' ? 'ascending' : 'descending')
|
|
74
77
|
: 'none'}
|
|
@@ -84,6 +84,7 @@ export declare class TableComponent implements IElementRef, OnCreate, OnDestroy,
|
|
|
84
84
|
onRender(): void;
|
|
85
85
|
onDestroy(): void;
|
|
86
86
|
/** Rows sorted by current sort key/direction */
|
|
87
|
+
private readonly _sortedRowsMemo;
|
|
87
88
|
get sortedRows(): Record<string, unknown>[];
|
|
88
89
|
get visibleRows(): Record<string, unknown>[];
|
|
89
90
|
get topSpacerHeight(): number;
|
|
@@ -92,6 +93,12 @@ export declare class TableComponent implements IElementRef, OnCreate, OnDestroy,
|
|
|
92
93
|
get allSelected(): boolean;
|
|
93
94
|
get someSelected(): boolean;
|
|
94
95
|
isRowSelected: (index: number) => boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Sort headers were mouse-only: a `<th>` with a click handler is not
|
|
98
|
+
* focusable and does not respond to Enter/Space, so a keyboard user could
|
|
99
|
+
* not sort at all.
|
|
100
|
+
*/
|
|
101
|
+
handleHeaderKeyDown: (column: TableColumn, event: KeyboardEvent) => void;
|
|
95
102
|
handleSort: (column: TableColumn) => void;
|
|
96
103
|
handleSelectAll: () => void;
|
|
97
104
|
handleSelectRow: (index: number, event: Event) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAMa,cAAe,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAC3F,UAAU,EAAG,WAAW,CAAC;IAEhC;;;;OAIG;IACI,aAAa,UAAS;IAE7B,0CAA0C;IACnC,SAAS,UAAS;IAEzB,kDAAkD;IAC3C,gBAAgB,UAAS;IAEhC,0CAA0C;IACnC,UAAU,UAAS;IAE1B,kCAAkC;IAC3B,OAAO,UAAS;IAEvB,8BAA8B;IACvB,SAAS,UAAQ;IAExB,0BAA0B;IACnB,YAAY,UAAS;IAE5B,iBAAiB;IACV,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEhC,yBAAyB;IAClB,UAAU,SAAM;IAEvB,+BAA+B;IACxB,WAAW,SAAM;IAExB,2DAA2D;IACpD,OAAO,UAAS;IAEvB;;;;;OAKG;IACI,UAAU,UAAS;IAE1B,yBAAyB;IAClB,OAAO,EAAE,WAAW,EAAE,CAAM;IAEnC,eAAe;IACR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAM;IAE5C,kCAAkC;IAC3B,OAAO,SAAM;IAEpB,6BAA6B;IACtB,aAAa,EAAE,aAAa,CAAS;IAE5C,+BAA+B;IACxB,eAAe,EAAE,MAAM,EAAE,CAAM;IAI/B,UAAU,SAAK;IACf,QAAQ,SAAM;IAIrB,8EAA8E;IAC9E,OAAO,CAAC,KAAK,CAGV;IAIH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAIM,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAaxE,QAAQ,IAAI,IAAI;IAUhB,QAAQ,IAAI,IAAI;IAIhB,SAAS,IAAI,IAAI;IAMxB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuC;IAEvE,IAAW,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAOjD;IAED,IAAW,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAElD;IAED,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED,IAAW,kBAAkB,IAAI,MAAM,CAEtC;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,YAAY,IAAI,OAAO,CAEjC;IAEM,aAAa,GAAI,OAAO,MAAM,KAAG,OAAO,CAE7C;IAIF;;;;OAIG;IACI,mBAAmB,GAAI,QAAQ,WAAW,EAAE,OAAO,aAAa,KAAG,IAAI,CAO5E;IAEK,UAAU,GAAI,QAAQ,WAAW,KAAG,IAAI,CAE7C;IAEK,eAAe,QAAO,IAAI,CAE/B;IAEK,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,KAAK,KAAG,IAAI,CAE1D;IAEK,cAAc,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,IAAI,CAEzE;CACF"}
|
|
@@ -9,6 +9,7 @@ import { watchSlotPresence } from '../../../functions/index.js';
|
|
|
9
9
|
import { tableTemplate } from './table.template.js';
|
|
10
10
|
import { tableStyles } from './table.styles.js';
|
|
11
11
|
import { TableCore } from '../table-core/index.js';
|
|
12
|
+
import { memoOn } from '../table-core/index.js';
|
|
12
13
|
/**
|
|
13
14
|
* ml-table - Data table with sorting, selection, and custom cell rendering
|
|
14
15
|
*
|
|
@@ -92,10 +93,25 @@ let TableComponent = class TableComponent {
|
|
|
92
93
|
viewportSelector: '.ml-table__wrapper',
|
|
93
94
|
displayRows: () => this.sortedRows
|
|
94
95
|
});
|
|
96
|
+
// ── Data ──────────────────────────────────────────────────────────────────────
|
|
97
|
+
/** Rows sorted by current sort key/direction */
|
|
98
|
+
this._sortedRowsMemo = memoOn();
|
|
95
99
|
this.isRowSelected = (index) => {
|
|
96
100
|
return this._core.isRowSelected(index);
|
|
97
101
|
};
|
|
98
102
|
// ── Event handlers ────────────────────────────────────────────────────────────
|
|
103
|
+
/**
|
|
104
|
+
* Sort headers were mouse-only: a `<th>` with a click handler is not
|
|
105
|
+
* focusable and does not respond to Enter/Space, so a keyboard user could
|
|
106
|
+
* not sort at all.
|
|
107
|
+
*/
|
|
108
|
+
this.handleHeaderKeyDown = (column, event) => {
|
|
109
|
+
if (!column.sortable || (event.key !== 'Enter' && event.key !== ' ')) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
this.handleSort(column);
|
|
114
|
+
};
|
|
99
115
|
this.handleSort = (column) => {
|
|
100
116
|
this._core.handleSortClick(column);
|
|
101
117
|
};
|
|
@@ -143,12 +159,11 @@ let TableComponent = class TableComponent {
|
|
|
143
159
|
onDestroy() {
|
|
144
160
|
this._core.detach();
|
|
145
161
|
}
|
|
146
|
-
// ── Data ──────────────────────────────────────────────────────────────────────
|
|
147
|
-
/** Rows sorted by current sort key/direction */
|
|
148
162
|
get sortedRows() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
// Memoized: this is read by VirtualScroller.itemCount on every scroll
|
|
164
|
+
// event and several times per render, and each call cloned and sorted
|
|
165
|
+
// the whole dataset.
|
|
166
|
+
return this._sortedRowsMemo([this.rows, this.manualSort, this.sortKey, this.sortDirection], () => this.manualSort ? this.rows : this._core.sortRows(this.rows));
|
|
152
167
|
}
|
|
153
168
|
get visibleRows() {
|
|
154
169
|
return this._core.visibleRows;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"table.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,6CAkI9C"}
|
|
@@ -47,7 +47,10 @@ export function tableTemplate(c) {
|
|
|
47
47
|
[`ml-table__th--${col.align ?? 'left'}`]: true
|
|
48
48
|
})}
|
|
49
49
|
style=${col.width ? `width: ${col.width}` : ''}
|
|
50
|
+
tabindex=${col.sortable ? '0' : ''}
|
|
51
|
+
role=${col.sortable ? 'columnheader button' : ''}
|
|
50
52
|
@click=${() => c.handleSort(col)}
|
|
53
|
+
@keydown=${(e) => c.handleHeaderKeyDown(col, e)}
|
|
51
54
|
aria-sort=${c.sortKey === col.key ? (c.sortDirection === 'asc' ? 'ascending' : 'descending') : 'none'}
|
|
52
55
|
>
|
|
53
56
|
<span class="ml-table__th-content">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table-core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table-core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny dependency-keyed memo for derived row sets.
|
|
3
|
+
*
|
|
4
|
+
* `displayRows()` is called by `VirtualScroller.itemCount` on every scroll
|
|
5
|
+
* event and four to six times per render, and each call cloned, filtered and
|
|
6
|
+
* sorted the whole dataset. Memoizing on the identity of the inputs makes the
|
|
7
|
+
* repeat calls free while still recomputing the moment anything real changes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function memoOn<T>(): (deps: readonly unknown[], compute: () => T) => T;
|
|
10
|
+
//# sourceMappingURL=memo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table-core/memo.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAa7E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny dependency-keyed memo for derived row sets.
|
|
3
|
+
*
|
|
4
|
+
* `displayRows()` is called by `VirtualScroller.itemCount` on every scroll
|
|
5
|
+
* event and four to six times per render, and each call cloned, filtered and
|
|
6
|
+
* sorted the whole dataset. Memoizing on the identity of the inputs makes the
|
|
7
|
+
* repeat calls free while still recomputing the moment anything real changes.
|
|
8
|
+
*/
|
|
9
|
+
export function memoOn() {
|
|
10
|
+
let lastDeps = null;
|
|
11
|
+
let lastValue;
|
|
12
|
+
return (deps, compute) => {
|
|
13
|
+
if (lastDeps !== null && lastDeps.length === deps.length && lastDeps.every((dep, i) => Object.is(dep, deps[i]))) {
|
|
14
|
+
return lastValue;
|
|
15
|
+
}
|
|
16
|
+
lastDeps = deps;
|
|
17
|
+
lastValue = compute();
|
|
18
|
+
return lastValue;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/alert/alert.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"alert.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/alert/alert.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,iDAmKvB,CAAC"}
|
|
@@ -26,6 +26,31 @@ export const alertStyles = () => css `
|
|
|
26
26
|
/* Transition */
|
|
27
27
|
--ml-alert-transition-duration: var(--ml-duration-150);
|
|
28
28
|
--ml-alert-transition-easing: var(--ml-ease-in-out);
|
|
29
|
+
|
|
30
|
+
/* ── Alert: variants ──
|
|
31
|
+
Declared here so every property the rules reference has a value on
|
|
32
|
+
:host. Without these declarations the variant rules resolved against
|
|
33
|
+
nothing when the theme did not define them, and the alert rendered
|
|
34
|
+
transparent. */
|
|
35
|
+
--ml-alert-info-bg: var(--ml-color-info-subtle, var(--ml-color-surface-secondary));
|
|
36
|
+
--ml-alert-info-border: var(--ml-color-info-border, var(--ml-color-border));
|
|
37
|
+
--ml-alert-info-text: var(--ml-color-info-text, var(--ml-color-text));
|
|
38
|
+
--ml-alert-info-icon: var(--ml-color-info, var(--ml-color-text-secondary));
|
|
39
|
+
|
|
40
|
+
--ml-alert-success-bg: var(--ml-color-success-subtle, var(--ml-color-surface-secondary));
|
|
41
|
+
--ml-alert-success-border: var(--ml-color-success-border, var(--ml-color-border));
|
|
42
|
+
--ml-alert-success-text: var(--ml-color-success-text, var(--ml-color-text));
|
|
43
|
+
--ml-alert-success-icon: var(--ml-color-success, var(--ml-color-text-secondary));
|
|
44
|
+
|
|
45
|
+
--ml-alert-warning-bg: var(--ml-color-warning-subtle, var(--ml-color-surface-secondary));
|
|
46
|
+
--ml-alert-warning-border: var(--ml-color-warning-border, var(--ml-color-border));
|
|
47
|
+
--ml-alert-warning-text: var(--ml-color-warning-text, var(--ml-color-text));
|
|
48
|
+
--ml-alert-warning-icon: var(--ml-color-warning, var(--ml-color-text-secondary));
|
|
49
|
+
|
|
50
|
+
--ml-alert-error-bg: var(--ml-color-error-subtle, var(--ml-color-surface-secondary));
|
|
51
|
+
--ml-alert-error-border: var(--ml-color-error-border, var(--ml-color-border));
|
|
52
|
+
--ml-alert-error-text: var(--ml-color-error-text, var(--ml-color-text));
|
|
53
|
+
--ml-alert-error-icon: var(--ml-color-error, var(--ml-color-text-secondary));
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
:host([hidden]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/progress/progress.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"progress.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/progress/progress.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAkW1B,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { css } from '@melodicdev/core';
|
|
2
2
|
export const progressStyles = () => css `
|
|
3
3
|
:host {
|
|
4
|
+
/* ── Progress: track heights ── */
|
|
5
|
+
--ml-progress-sm-height: 4px;
|
|
6
|
+
--ml-progress-md-height: 8px;
|
|
7
|
+
--ml-progress-lg-height: 12px;
|
|
8
|
+
|
|
4
9
|
display: block;
|
|
5
10
|
|
|
6
11
|
/* ---- Linear ---- */
|
|
@@ -104,15 +109,15 @@ export const progressStyles = () => css `
|
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
.ml-progress--sm .ml-progress__track {
|
|
107
|
-
height:
|
|
112
|
+
height: var(--ml-progress-sm-height);
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
.ml-progress--md .ml-progress__track {
|
|
111
|
-
height:
|
|
116
|
+
height: var(--ml-progress-md-height);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
.ml-progress--lg .ml-progress__track {
|
|
115
|
-
height:
|
|
120
|
+
height: var(--ml-progress-lg-height);
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
.ml-progress__fill {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/spinner/spinner.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spinner.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/spinner/spinner.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,iDA4EzB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css } from '@melodicdev/core';
|
|
2
|
+
import { visuallyHiddenStyles } from '../../../utils/styles/visually-hidden.styles.js';
|
|
2
3
|
export const spinnerStyles = () => css `
|
|
3
4
|
:host {
|
|
4
5
|
display: inline-flex;
|
|
@@ -74,15 +75,5 @@ export const spinnerStyles = () => css `
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
position: absolute;
|
|
79
|
-
width: 1px;
|
|
80
|
-
height: 1px;
|
|
81
|
-
padding: 0;
|
|
82
|
-
margin: -1px;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
clip: rect(0, 0, 0, 0);
|
|
85
|
-
white-space: nowrap;
|
|
86
|
-
border: 0;
|
|
87
|
-
}
|
|
78
|
+
${visuallyHiddenStyles}
|
|
88
79
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-container.template.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast-container.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"toast-container.template.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast-container.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,uBAAuB,6CAehE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IElementRef, OnCreate } from '@melodicdev/core';
|
|
1
|
+
import type { IElementRef, OnCreate, OnDestroy } from '@melodicdev/core';
|
|
2
2
|
import type { ToastVariant } from './toast-config.interface.js';
|
|
3
3
|
/**
|
|
4
4
|
* ml-toast - Individual toast notification
|
|
@@ -10,7 +10,7 @@ import type { ToastVariant } from './toast-config.interface.js';
|
|
|
10
10
|
*
|
|
11
11
|
* @fires ml:dismiss - Emitted when the toast is dismissed
|
|
12
12
|
*/
|
|
13
|
-
export declare class ToastComponent implements IElementRef, OnCreate {
|
|
13
|
+
export declare class ToastComponent implements IElementRef, OnCreate, OnDestroy {
|
|
14
14
|
elementRef: HTMLElement;
|
|
15
15
|
/** Toast variant */
|
|
16
16
|
variant: ToastVariant;
|
|
@@ -27,6 +27,7 @@ export declare class ToastComponent implements IElementRef, OnCreate {
|
|
|
27
27
|
get title(): string;
|
|
28
28
|
set title(value: string);
|
|
29
29
|
onCreate(): void;
|
|
30
|
+
onDestroy(): void;
|
|
30
31
|
dismiss: () => void;
|
|
31
32
|
renderIcon: () => import("@melodicdev/core").TemplateResult;
|
|
32
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.component.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"toast.component.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE;;;;;;;;;GASG;AACH,qBAMa,cAAe,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAC/D,UAAU,EAAG,WAAW,CAAC;IAEhC,oBAAoB;IACb,OAAO,EAAE,YAAY,CAAU;IAEtC,2CAA2C;IACpC,UAAU,SAAM;IAEvB,oBAAoB;IACb,OAAO,SAAM;IAEpB,wDAAwD;IACjD,QAAQ,SAAQ;IAEvB,0BAA0B;IACnB,WAAW,UAAQ;IAE1B,OAAO,CAAC,MAAM,CAA8C;IAE5D,+GAA+G;IAC/G,IAAW,KAAK,IAAI,MAAM,CAEzB;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,MAAM,EAG7B;IAEM,QAAQ,IAAI,IAAI;IAMhB,SAAS,IAAI,IAAI;IAWjB,OAAO,QAAO,IAAI,CAcvB;IAEK,UAAU,kDASf;CACF"}
|
|
@@ -65,6 +65,16 @@ let ToastComponent = class ToastComponent {
|
|
|
65
65
|
this._timer = setTimeout(() => this.dismiss(), this.duration);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
onDestroy() {
|
|
69
|
+
// A toast removed before its timer fires (dismissAll, a route change,
|
|
70
|
+
// the container being torn down) left the timer armed; it then ran
|
|
71
|
+
// dismiss() on a detached element and kept the component alive until
|
|
72
|
+
// it fired.
|
|
73
|
+
if (this._timer) {
|
|
74
|
+
clearTimeout(this._timer);
|
|
75
|
+
this._timer = null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
68
78
|
};
|
|
69
79
|
ToastComponent = __decorate([
|
|
70
80
|
MelodicComponent({
|
|
@@ -12,21 +12,41 @@ import type { IToastConfig, ToastPosition } from './toast-config.interface.js';
|
|
|
12
12
|
* this._toastService.show({ variant: 'warning', title: 'Warning', message: '...' });
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
|
+
/** Handle to a shown toast, so the caller can dismiss it early. */
|
|
16
|
+
export interface IToastRef {
|
|
17
|
+
/** Remove the toast now. Safe to call more than once. */
|
|
18
|
+
dismiss(): void;
|
|
19
|
+
/** The toast element, for consumers that need to reach into it. */
|
|
20
|
+
readonly element: HTMLElement;
|
|
21
|
+
}
|
|
15
22
|
export declare class ToastService {
|
|
16
23
|
private _containerEl;
|
|
17
24
|
private _position;
|
|
25
|
+
/** Toasts currently on screen, oldest first. */
|
|
26
|
+
private readonly _active;
|
|
27
|
+
private _maxVisible;
|
|
28
|
+
/**
|
|
29
|
+
* Cap the number of toasts on screen at once (default 5, 0 = unlimited).
|
|
30
|
+
* Without a cap, a failing poll could stack hundreds of toasts over the
|
|
31
|
+
* whole viewport.
|
|
32
|
+
*/
|
|
33
|
+
setMaxVisible(max: number): void;
|
|
18
34
|
/** Set the default position for all toasts */
|
|
19
35
|
setPosition(position: ToastPosition): void;
|
|
20
|
-
/** Show a toast with full configuration */
|
|
21
|
-
show(config: IToastConfig):
|
|
36
|
+
/** Show a toast with full configuration. Returns a handle for dismissing it. */
|
|
37
|
+
show(config: IToastConfig): IToastRef;
|
|
22
38
|
/** Show an info toast */
|
|
23
|
-
info(title: string, message?: string):
|
|
39
|
+
info(title: string, message?: string): IToastRef;
|
|
24
40
|
/** Show a success toast */
|
|
25
|
-
success(title: string, message?: string):
|
|
41
|
+
success(title: string, message?: string): IToastRef;
|
|
26
42
|
/** Show a warning toast */
|
|
27
|
-
warning(title: string, message?: string):
|
|
43
|
+
warning(title: string, message?: string): IToastRef;
|
|
28
44
|
/** Show an error toast */
|
|
29
|
-
error(title: string, message?: string):
|
|
45
|
+
error(title: string, message?: string): IToastRef;
|
|
46
|
+
/** Remove every toast currently on screen. */
|
|
47
|
+
dismissAll(): void;
|
|
48
|
+
private forget;
|
|
49
|
+
private enforceMaxVisible;
|
|
30
50
|
private ensureContainer;
|
|
31
51
|
}
|
|
32
52
|
//# sourceMappingURL=toast.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.service.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE/E;;;;;;;;;;;;GAYG;AACH,qBACa,YAAY;IACxB,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAA8B;
|
|
1
|
+
{"version":3,"file":"toast.service.d.ts","sourceRoot":"","sources":["../../../../src/components/feedback/toast/toast.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE/E;;;;;;;;;;;;GAYG;AACH,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACzB,yDAAyD;IACzD,OAAO,IAAI,IAAI,CAAC;IAChB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC9B;AAED,qBACa,YAAY;IACxB,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAA8B;IAC/C,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,WAAW,CAAK;IAExB;;;;OAIG;IACI,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKvC,8CAA8C;IACvC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAQjD,gFAAgF;IACzE,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS;IA8B5C,yBAAyB;IAClB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAIvD,2BAA2B;IACpB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAI1D,2BAA2B;IACpB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAI1D,0BAA0B;IACnB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS;IAIxD,8CAA8C;IACvC,UAAU,IAAI,IAAI;IAOzB,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,eAAe;CAWvB"}
|