@spaethtech/svelte-ui 0.7.1-dev.45.41387ea → 0.7.1-dev.47.cfe1a36

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.
@@ -125,6 +125,7 @@
125
125
  hoverExpandCloseMs = 200,
126
126
  side = "left",
127
127
  api = $bindable(),
128
+ activeMode = $bindable(),
128
129
  class: additionalClass = "",
129
130
  }: {
130
131
  items?: SideBarMenuItem[];
@@ -187,6 +188,9 @@
187
188
  * (SvelteKit `afterNavigate`, etc.) so a programmatic `goto()`/back-button closes the drawer +
188
189
  * any open popout and returns a stepped drawer to the top. */
189
190
  api?: SideBarMenuApi;
191
+ /** Read-only (bindable) — the currently active {@link SideBarMenuMode}. Bind it to decide whether
192
+ * your own header trigger should render (e.g. only in `drawer`/`stepped`). */
193
+ activeMode?: SideBarMenuMode;
190
194
  class?: string;
191
195
  } = $props();
192
196
 
@@ -216,8 +220,13 @@
216
220
  return active;
217
221
  }
218
222
 
219
- // SSR-safe default the effect below corrects on mount.
220
- let currentMode = $state<SideBarMenuMode>("expanded");
223
+ // Resolve the mode synchronously on the CLIENT at init (from the real viewport width) so the first
224
+ // client render is already correct — no post-hydration flash from `expanded` → the actual mode. On
225
+ // the server `window` is undefined, so SSR emits `expanded`; the client corrects during hydration
226
+ // (not via a delayed effect). The effect below keeps it in sync on subsequent viewport changes.
227
+ let currentMode = $state<SideBarMenuMode>(
228
+ typeof window !== "undefined" ? resolveMode(effectiveModes, window.innerWidth) : "expanded",
229
+ );
221
230
 
222
231
  $effect(() => {
223
232
  const map = effectiveModes;
@@ -234,6 +243,11 @@
234
243
  return () => queries.forEach((q) => q.removeEventListener("change", sync));
235
244
  });
236
245
 
246
+ // Mirror the resolved mode out for consumers (bindable, read-only).
247
+ $effect(() => {
248
+ activeMode = currentMode;
249
+ });
250
+
237
251
  const isStepped = $derived(currentMode === "stepped");
238
252
  const isDrawer = $derived(currentMode === "drawer" || currentMode === "stepped");
239
253
  // Dock side. `right` mirrors the frame, drawer slide, hamburger corner, popout side, and item layout.
@@ -135,8 +135,11 @@ type $$ComponentProps = {
135
135
  * (SvelteKit `afterNavigate`, etc.) so a programmatic `goto()`/back-button closes the drawer +
136
136
  * any open popout and returns a stepped drawer to the top. */
137
137
  api?: SideBarMenuApi;
138
+ /** Read-only (bindable) — the currently active {@link SideBarMenuMode}. Bind it to decide whether
139
+ * your own header trigger should render (e.g. only in `drawer`/`stepped`). */
140
+ activeMode?: SideBarMenuMode;
138
141
  class?: string;
139
142
  };
140
- declare const SideBarMenu: import("svelte").Component<$$ComponentProps, {}, "open" | "stepLevel" | "api">;
143
+ declare const SideBarMenu: import("svelte").Component<$$ComponentProps, {}, "open" | "stepLevel" | "api" | "activeMode">;
141
144
  type SideBarMenu = ReturnType<typeof SideBarMenu>;
142
145
  export default SideBarMenu;
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export type { Columns, Gap } from "./components/field-group.js";
41
41
  export { default as Disclosure } from "./components/Disclosure.svelte";
42
42
  export { default as Accordion } from "./components/Accordion.svelte";
43
43
  export { default as SideBarMenu } from "./components/SideBarMenu/SideBarMenu.svelte";
44
- export type { SideBarMenuItem, SideBarMenuBadge, SideBarMenuBadgeVariant, SideBarMenuApi, } from "./components/SideBarMenu/SideBarMenu.svelte";
44
+ export type { SideBarMenuItem, SideBarMenuBadge, SideBarMenuBadgeVariant, SideBarMenuApi, SideBarMenuMode, } from "./components/SideBarMenu/SideBarMenu.svelte";
45
45
  export { default as TabStrip } from "./components/TabStrip/TabStrip.svelte";
46
46
  export type { TabDefinition } from "./components/TabStrip/TabStrip.svelte";
47
47
  export { default as DataTable } from "./components/DataTable.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaethtech/svelte-ui",
3
- "version": "0.7.1-dev.45.41387ea",
3
+ "version": "0.7.1-dev.47.cfe1a36",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/spaethtech/svelte-ui.git"