@dorsk/tsumikit 0.18.1 → 0.18.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.
@@ -8,7 +8,7 @@
8
8
  // would overflow. (CSS anchor positioning would replace the JS here once it
9
9
  // ships beyond Chromium; the popover semantics above are the hard part and
10
10
  // are broadly supported today.)
11
- import type { Snippet } from 'svelte';
11
+ import { tick, type Snippet } from 'svelte';
12
12
  import { place } from '../../floating';
13
13
 
14
14
  type Placement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
@@ -67,13 +67,22 @@
67
67
  const id = `pop-${Math.random().toString(36).slice(2, 8)}`;
68
68
  let triggerEl = $state<HTMLButtonElement | null>(null);
69
69
  let panelEl = $state<HTMLDivElement | null>(null);
70
+ // Panel content is mounted only after the first open, then kept alive so
71
+ // reopening is instant. The panel element itself always renders — the native
72
+ // `popovertarget` wiring needs its id present in the DOM at all times.
73
+ let opened = $state(false);
70
74
 
71
75
  function reposition() {
72
76
  if (triggerEl && panelEl) place(triggerEl, panelEl, placement, gap);
73
77
  }
74
78
 
75
- function onToggle(e: ToggleEvent) {
79
+ async function onToggle(e: ToggleEvent) {
76
80
  if (e.newState === 'open') {
81
+ const firstOpen = !opened;
82
+ opened = true;
83
+ // On the first open the content snippet mounts this tick; measure the
84
+ // panel only once it has, so placement accounts for its real size.
85
+ if (firstOpen) await tick();
77
86
  reposition();
78
87
  addEventListener('scroll', reposition, true);
79
88
  addEventListener('resize', reposition);
@@ -121,7 +130,9 @@
121
130
  aria-label={label}
122
131
  ontoggle={onToggle}
123
132
  >
124
- {@render children()}
133
+ {#if opened}
134
+ {@render children()}
135
+ {/if}
125
136
  </div>
126
137
 
127
138
  <style>
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import { type Snippet } from 'svelte';
2
2
  type Placement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
3
3
  type TriggerVariant = 'default' | 'primary' | 'ghost' | 'danger';
4
4
  type TriggerTone = 'none' | 'accent' | 'success' | 'info' | 'warn' | 'danger';
@@ -1,4 +1,4 @@
1
- import { type Schema } from './schema.ts';
1
+ import { type Schema } from './schema';
2
2
  export type SuggestKind = 'field' | 'operator' | 'value';
3
3
  export interface Suggestion {
4
4
  /** What to show on the row. */
@@ -6,7 +6,7 @@
6
6
  //
7
7
  // This is pure logic, deliberately UI-free so the Svelte organism stays dumb.
8
8
  // ─────────────────────────────────────────────────────────────────────────
9
- import { findField, operatorsFor, resolveValues, } from './schema.ts';
9
+ import { findField, operatorsFor, resolveValues, } from './schema';
10
10
  // Longest first so `>=`/`!:` win over `>`/`:`.
11
11
  const OP_CODES = ['!:', '!=', '>=', '<=', ':', '=', '>', '<'];
12
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorsk/tsumikit",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Minimal, dependency-free Svelte 5 + pure-CSS UI kit. Token-driven atoms, molecules & layouts with theming out of the box.",
5
5
  "type": "module",
6
6
  "license": "MIT",