@lavalogic/scoria 0.37.25 → 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
- const isInvalid = $derived((required && !value.trim()) || invalid);
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') {
@@ -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">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.37.25",
4
+ "version": "0.37.26",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },