@classic-homes/theme-svelte 0.1.27 → 0.1.29

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.
@@ -95,6 +95,8 @@
95
95
  mobileBreakpoint?: Breakpoint;
96
96
  /** Content area padding: 'default' (p-4 lg:p-6), 'compact' (p-2 lg:p-4), 'none' (no padding) */
97
97
  contentPadding?: 'default' | 'compact' | 'none';
98
+ /** App identifier for per-app sidebar preferences storage */
99
+ appId?: string;
98
100
  /** Main content */
99
101
  children: Snippet;
100
102
  }
@@ -130,6 +132,7 @@
130
132
  headerSearch,
131
133
  mobileBreakpoint = 'lg',
132
134
  contentPadding = 'default',
135
+ appId,
133
136
  children,
134
137
  }: Props = $props();
135
138
 
@@ -174,7 +177,7 @@
174
177
 
175
178
  // Load persisted sidebar state and apply prop-based defaults
176
179
  $effect(() => {
177
- sidebarStore.initialize();
180
+ sidebarStore.initialize(appId);
178
181
 
179
182
  // Only apply prop-based initial state if no persisted state exists
180
183
  if (!sidebarStore.hasPersistedState && !isMobile) {
@@ -247,6 +250,7 @@
247
250
  {initialPinnedItems}
248
251
  {onPinnedChange}
249
252
  {pinIcon}
253
+ {appId}
250
254
  />
251
255
 
252
256
  <!-- Main Content Area -->
@@ -294,7 +298,7 @@
294
298
  {/if}
295
299
 
296
300
  <!-- Main Content -->
297
- <main id="main-content" class="flex-1 bg-content-bg {contentPaddingClass}">
301
+ <main id="main-content" class="flex-1 bg-content-bg relative z-0 {contentPaddingClass}">
298
302
  {@render children()}
299
303
  </main>
300
304
  </div>
@@ -75,6 +75,8 @@ interface Props {
75
75
  mobileBreakpoint?: Breakpoint;
76
76
  /** Content area padding: 'default' (p-4 lg:p-6), 'compact' (p-2 lg:p-4), 'none' (no padding) */
77
77
  contentPadding?: 'default' | 'compact' | 'none';
78
+ /** App identifier for per-app sidebar preferences storage */
79
+ appId?: string;
78
80
  /** Main content */
79
81
  children: Snippet;
80
82
  }
@@ -71,6 +71,8 @@
71
71
  onPinnedChange?: (pinnedIds: string[]) => void;
72
72
  /** Custom pin icon renderer */
73
73
  pinIcon?: Snippet<[{ isPinned: boolean }]>;
74
+ /** App identifier for per-app preferences storage */
75
+ appId?: string;
74
76
  /** Additional classes */
75
77
  class?: string;
76
78
  }
@@ -100,6 +102,7 @@
100
102
  initialPinnedItems,
101
103
  onPinnedChange,
102
104
  pinIcon,
105
+ appId,
103
106
  class: className,
104
107
  }: Props = $props();
105
108
 
@@ -128,6 +131,11 @@
128
131
  .filter((section) => section.items.length > 0)
129
132
  );
130
133
 
134
+ // Initialize store with appId for per-app preferences
135
+ $effect(() => {
136
+ sidebarStore.initialize(appId);
137
+ });
138
+
131
139
  // Initialize pinning from props
132
140
  $effect(() => {
133
141
  // Set up the callback for pinned changes
@@ -64,6 +64,8 @@ interface Props {
64
64
  pinIcon?: Snippet<[{
65
65
  isPinned: boolean;
66
66
  }]>;
67
+ /** App identifier for per-app preferences storage */
68
+ appId?: string;
67
69
  /** Additional classes */
68
70
  class?: string;
69
71
  }
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * Sidebar Store - Svelte 5 runes-based state management for sidebar
3
+ *
4
+ * Supports per-app preferences via appId parameter. When an appId is set,
5
+ * all localStorage keys are namespaced to that app, allowing different
6
+ * apps to have independent sidebar preferences for the same user.
3
7
  */
4
8
  import type { NavSection, SidebarPreferences } from '../types/layout.js';
5
9
  declare class SidebarStore {
@@ -28,8 +32,15 @@ declare class SidebarStore {
28
32
  /**
29
33
  * Initialize store with persisted state.
30
34
  * Call this from a component's $effect to load saved state.
35
+ *
36
+ * @param appId - Optional app identifier for per-app preferences.
37
+ * When provided, localStorage keys are namespaced to this app.
31
38
  */
32
- initialize(): void;
39
+ initialize(appId?: string): void;
40
+ /**
41
+ * Get the current app ID
42
+ */
43
+ get appId(): string | undefined;
33
44
  /**
34
45
  * Toggle the sidebar open/closed state
35
46
  */
@@ -1,5 +1,9 @@
1
1
  /**
2
2
  * Sidebar Store - Svelte 5 runes-based state management for sidebar
3
+ *
4
+ * Supports per-app preferences via appId parameter. When an appId is set,
5
+ * all localStorage keys are namespaced to that app, allowing different
6
+ * apps to have independent sidebar preferences for the same user.
3
7
  */
4
8
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5
9
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -12,11 +16,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
12
16
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
13
17
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14
18
  };
15
- var _SidebarStore_instances, _SidebarStore_initialized, _SidebarStore_loadedFromStorage, _SidebarStore_loadedExpansionFromStorage, _SidebarStore_loadedPinnedFromStorage, _SidebarStore_onPinnedChange, _SidebarStore_persist, _SidebarStore_persistExpansion, _SidebarStore_persistPinned;
16
- const STORAGE_KEY = 'classic-theme-sidebar-open';
17
- const SECTIONS_STORAGE_KEY = 'classic-theme-sidebar-sections';
18
- const ITEMS_STORAGE_KEY = 'classic-theme-sidebar-items';
19
- const PINNED_STORAGE_KEY = 'classic-theme-sidebar-pinned';
19
+ var _SidebarStore_instances, _SidebarStore_initialized, _SidebarStore_loadedFromStorage, _SidebarStore_loadedExpansionFromStorage, _SidebarStore_loadedPinnedFromStorage, _SidebarStore_onPinnedChange, _SidebarStore_appId, _SidebarStore_getStorageKey, _SidebarStore_persist, _SidebarStore_persistExpansion, _SidebarStore_persistPinned;
20
+ const STORAGE_PREFIX = 'classic-theme-sidebar';
20
21
  class SidebarStore {
21
22
  constructor() {
22
23
  _SidebarStore_instances.add(this);
@@ -30,6 +31,7 @@ class SidebarStore {
30
31
  _SidebarStore_loadedExpansionFromStorage.set(this, false);
31
32
  _SidebarStore_loadedPinnedFromStorage.set(this, false);
32
33
  _SidebarStore_onPinnedChange.set(this, void 0);
34
+ _SidebarStore_appId.set(this, void 0);
33
35
  }
34
36
  /**
35
37
  * Whether the store has been initialized
@@ -58,32 +60,42 @@ class SidebarStore {
58
60
  /**
59
61
  * Initialize store with persisted state.
60
62
  * Call this from a component's $effect to load saved state.
63
+ *
64
+ * @param appId - Optional app identifier for per-app preferences.
65
+ * When provided, localStorage keys are namespaced to this app.
61
66
  */
62
- initialize() {
63
- if (__classPrivateFieldGet(this, _SidebarStore_initialized, "f") || typeof window === 'undefined')
67
+ initialize(appId) {
68
+ // If appId changed, reset and reinitialize
69
+ if (__classPrivateFieldGet(this, _SidebarStore_initialized, "f") && __classPrivateFieldGet(this, _SidebarStore_appId, "f") === appId)
64
70
  return;
71
+ if (typeof window === 'undefined')
72
+ return;
73
+ __classPrivateFieldSet(this, _SidebarStore_appId, appId, "f");
65
74
  __classPrivateFieldSet(this, _SidebarStore_initialized, true, "f");
75
+ __classPrivateFieldSet(this, _SidebarStore_loadedFromStorage, false, "f");
76
+ __classPrivateFieldSet(this, _SidebarStore_loadedExpansionFromStorage, false, "f");
77
+ __classPrivateFieldSet(this, _SidebarStore_loadedPinnedFromStorage, false, "f");
66
78
  try {
67
79
  // Load sidebar open state
68
- const stored = localStorage.getItem(STORAGE_KEY);
80
+ const stored = localStorage.getItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'open'));
69
81
  if (stored !== null) {
70
82
  this.isOpen = stored === 'true';
71
83
  __classPrivateFieldSet(this, _SidebarStore_loadedFromStorage, true, "f");
72
84
  }
73
85
  // Load expanded sections
74
- const sections = localStorage.getItem(SECTIONS_STORAGE_KEY);
86
+ const sections = localStorage.getItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'sections'));
75
87
  if (sections) {
76
88
  this.expandedSections = new Set(JSON.parse(sections));
77
89
  __classPrivateFieldSet(this, _SidebarStore_loadedExpansionFromStorage, true, "f");
78
90
  }
79
91
  // Load expanded items
80
- const items = localStorage.getItem(ITEMS_STORAGE_KEY);
92
+ const items = localStorage.getItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'items'));
81
93
  if (items) {
82
94
  this.expandedItems = new Set(JSON.parse(items));
83
95
  __classPrivateFieldSet(this, _SidebarStore_loadedExpansionFromStorage, true, "f");
84
96
  }
85
97
  // Load pinned items
86
- const pinned = localStorage.getItem(PINNED_STORAGE_KEY);
98
+ const pinned = localStorage.getItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'pinned'));
87
99
  if (pinned) {
88
100
  this.pinnedItems = new Set(JSON.parse(pinned));
89
101
  __classPrivateFieldSet(this, _SidebarStore_loadedPinnedFromStorage, true, "f");
@@ -93,6 +105,12 @@ class SidebarStore {
93
105
  // localStorage not available
94
106
  }
95
107
  }
108
+ /**
109
+ * Get the current app ID
110
+ */
111
+ get appId() {
112
+ return __classPrivateFieldGet(this, _SidebarStore_appId, "f");
113
+ }
96
114
  /**
97
115
  * Toggle the sidebar open/closed state
98
116
  */
@@ -292,11 +310,15 @@ class SidebarStore {
292
310
  };
293
311
  }
294
312
  }
295
- _SidebarStore_initialized = new WeakMap(), _SidebarStore_loadedFromStorage = new WeakMap(), _SidebarStore_loadedExpansionFromStorage = new WeakMap(), _SidebarStore_loadedPinnedFromStorage = new WeakMap(), _SidebarStore_onPinnedChange = new WeakMap(), _SidebarStore_instances = new WeakSet(), _SidebarStore_persist = function _SidebarStore_persist() {
313
+ _SidebarStore_initialized = new WeakMap(), _SidebarStore_loadedFromStorage = new WeakMap(), _SidebarStore_loadedExpansionFromStorage = new WeakMap(), _SidebarStore_loadedPinnedFromStorage = new WeakMap(), _SidebarStore_onPinnedChange = new WeakMap(), _SidebarStore_appId = new WeakMap(), _SidebarStore_instances = new WeakSet(), _SidebarStore_getStorageKey = function _SidebarStore_getStorageKey(suffix) {
314
+ return __classPrivateFieldGet(this, _SidebarStore_appId, "f")
315
+ ? `${STORAGE_PREFIX}-${__classPrivateFieldGet(this, _SidebarStore_appId, "f")}-${suffix}`
316
+ : `${STORAGE_PREFIX}-${suffix}`;
317
+ }, _SidebarStore_persist = function _SidebarStore_persist() {
296
318
  if (typeof window === 'undefined')
297
319
  return;
298
320
  try {
299
- localStorage.setItem(STORAGE_KEY, String(this.isOpen));
321
+ localStorage.setItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'open'), String(this.isOpen));
300
322
  }
301
323
  catch {
302
324
  // localStorage not available
@@ -305,8 +327,8 @@ _SidebarStore_initialized = new WeakMap(), _SidebarStore_loadedFromStorage = new
305
327
  if (typeof window === 'undefined')
306
328
  return;
307
329
  try {
308
- localStorage.setItem(SECTIONS_STORAGE_KEY, JSON.stringify([...this.expandedSections]));
309
- localStorage.setItem(ITEMS_STORAGE_KEY, JSON.stringify([...this.expandedItems]));
330
+ localStorage.setItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'sections'), JSON.stringify([...this.expandedSections]));
331
+ localStorage.setItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'items'), JSON.stringify([...this.expandedItems]));
310
332
  }
311
333
  catch {
312
334
  // localStorage not available
@@ -315,7 +337,7 @@ _SidebarStore_initialized = new WeakMap(), _SidebarStore_loadedFromStorage = new
315
337
  if (typeof window === 'undefined')
316
338
  return;
317
339
  try {
318
- localStorage.setItem(PINNED_STORAGE_KEY, JSON.stringify([...this.pinnedItems]));
340
+ localStorage.setItem(__classPrivateFieldGet(this, _SidebarStore_instances, "m", _SidebarStore_getStorageKey).call(this, 'pinned'), JSON.stringify([...this.pinnedItems]));
319
341
  }
320
342
  catch {
321
343
  // localStorage not available
@@ -246,6 +246,8 @@ export interface DashboardLayoutProps {
246
246
  }]>;
247
247
  /** Header search configuration */
248
248
  headerSearch?: HeaderSearchConfig;
249
+ /** App identifier for per-app sidebar preferences storage */
250
+ appId?: string;
249
251
  /** Main content */
250
252
  children: Snippet;
251
253
  }
@@ -332,6 +334,8 @@ export interface SidebarProps {
332
334
  pinIcon?: Snippet<[{
333
335
  isPinned: boolean;
334
336
  }]>;
337
+ /** App identifier for per-app sidebar preferences storage */
338
+ appId?: string;
335
339
  /** Additional classes */
336
340
  class?: string;
337
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/theme-svelte",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Svelte components for the Classic theme system",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",