@lavalogic/scoria 0.37.24 → 0.37.26
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.
|
@@ -46,7 +46,11 @@
|
|
|
46
46
|
onchange,
|
|
47
47
|
}: DateInputProps = $props();
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
// Null-safe: a fresh `<DateInput>` with no value passes `value=null`
|
|
50
|
+
// through the prop. The old `value.trim()` crashed with "Cannot read
|
|
51
|
+
// properties of null (reading 'trim')" the moment a required, empty
|
|
52
|
+
// DateInput rendered inside e.g. the Order Details collapsible card.
|
|
53
|
+
const isInvalid = $derived((required && !value?.trim()) || invalid);
|
|
50
54
|
|
|
51
55
|
function onkeydown(e: KeyboardEvent): void {
|
|
52
56
|
if (e.key === 'Enter') {
|
|
@@ -48,7 +48,11 @@
|
|
|
48
48
|
if (d == null) {
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
// Use `toLocaleString` for both lines so the visual format matches
|
|
52
|
+
// (only the time zone differs). The `timeZone: 'UTC'` override on
|
|
53
|
+
// the second call renders the same date / time but reinterpreted
|
|
54
|
+
// in UTC, which is what the user expects to see on hover.
|
|
55
|
+
return `Local: ${d.toLocaleString()}\nUTC: ${d.toLocaleString(undefined, { timeZone: 'UTC' })}`;
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
@@ -25,6 +25,41 @@
|
|
|
25
25
|
import HighlightAllHeader from './HighlightAllHeader.svelte';
|
|
26
26
|
import SelectAllHeader from './SelectAllHeader.svelte';
|
|
27
27
|
import type { TableHeadProps } from './TableHeadProps.js';
|
|
28
|
+
|
|
29
|
+
/** Per-column toggle queue. The header onclick fires this so multiple
|
|
30
|
+
* clicks within a small window stack and apply on a single timer
|
|
31
|
+
* flush, which lets a fast double-click cycle straight to desc (or
|
|
32
|
+
* to clear-sort) without the user having to wait for the asc state
|
|
33
|
+
* to apply and reload data first. Single clicks pay a ~150 ms delay
|
|
34
|
+
* before the toggle runs, which is below most users' perceived
|
|
35
|
+
* latency threshold while still wide enough to batch dblclicks. */
|
|
36
|
+
const SORT_DEBOUNCE_MS = 150;
|
|
37
|
+
const sortDebounce = new WeakMap<
|
|
38
|
+
object,
|
|
39
|
+
{ count: number; timer: ReturnType<typeof setTimeout> | null }
|
|
40
|
+
>();
|
|
41
|
+
function debouncedSortToggle(columnRef: object, handler: ((e?: unknown) => void) | undefined): void {
|
|
42
|
+
if (!handler) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let entry = sortDebounce.get(columnRef);
|
|
46
|
+
if (!entry) {
|
|
47
|
+
entry = { count: 0, timer: null };
|
|
48
|
+
sortDebounce.set(columnRef, entry);
|
|
49
|
+
}
|
|
50
|
+
entry.count += 1;
|
|
51
|
+
if (entry.timer != null) {
|
|
52
|
+
clearTimeout(entry.timer);
|
|
53
|
+
}
|
|
54
|
+
entry.timer = setTimeout(() => {
|
|
55
|
+
const toFire = entry!.count;
|
|
56
|
+
entry!.count = 0;
|
|
57
|
+
entry!.timer = null;
|
|
58
|
+
for (let i = 0; i < toFire; i++) {
|
|
59
|
+
handler();
|
|
60
|
+
}
|
|
61
|
+
}, SORT_DEBOUNCE_MS);
|
|
62
|
+
}
|
|
28
63
|
</script>
|
|
29
64
|
|
|
30
65
|
<script
|
|
@@ -290,7 +325,7 @@
|
|
|
290
325
|
hideTooltip(header.column.columnDef);
|
|
291
326
|
}}
|
|
292
327
|
class="contents"
|
|
293
|
-
onclick={header.column.getToggleSortingHandler()}
|
|
328
|
+
onclick={() => debouncedSortToggle(header.column, header.column.getToggleSortingHandler())}
|
|
294
329
|
>
|
|
295
330
|
<div class="th cursor-pointer select-none">
|
|
296
331
|
<div class="header-text-wrapper">
|
|
@@ -146,6 +146,10 @@ export function attachDropdownPortal(options) {
|
|
|
146
146
|
}
|
|
147
147
|
originalParent = dropdown.parentNode;
|
|
148
148
|
originalNextSibling = dropdown.nextSibling;
|
|
149
|
+
// Clear any `display: none` left over from a previous portalIn
|
|
150
|
+
// (see the defensive hide there) so the dropdown is visible
|
|
151
|
+
// once teleported into the new host.
|
|
152
|
+
dropdown.style.display = '';
|
|
149
153
|
// Append the dropdown to the nearest open native `<dialog>` ancestor
|
|
150
154
|
// when one exists, otherwise to `document.body`. A `<dialog>` opened
|
|
151
155
|
// via `showModal()` renders in the browser's top layer, which sits
|
|
@@ -200,6 +204,18 @@ export function attachDropdownPortal(options) {
|
|
|
200
204
|
dropdown.style.maxHeight = '';
|
|
201
205
|
dropdown.style.zIndex = '';
|
|
202
206
|
dropdown.removeAttribute('data-scoria-portal-dropdown');
|
|
207
|
+
// Defensive: if Svelecte left the dropdown without its own
|
|
208
|
+
// `display: none` (e.g. on certain transition-cancel race paths
|
|
209
|
+
// the open/close class flip and the inline style update arrive
|
|
210
|
+
// out of order), the dropdown would now be `position: static;
|
|
211
|
+
// display: block` in `document.body` and contribute its option
|
|
212
|
+
// list's height to the body scroll size - which is what surfaces
|
|
213
|
+
// as a stray page-level vertical scrollbar after toggling a
|
|
214
|
+
// select. Force `display: none` here; Svelecte will restore the
|
|
215
|
+
// inline style on next open via its own class-driven render.
|
|
216
|
+
if (!dropdown.classList.contains('is-open')) {
|
|
217
|
+
dropdown.style.display = 'none';
|
|
218
|
+
}
|
|
203
219
|
if (originalParent != null) {
|
|
204
220
|
if (originalNextSibling != null && originalNextSibling.parentNode === originalParent) {
|
|
205
221
|
originalParent.insertBefore(dropdown, originalNextSibling);
|