@phillipsharring/graspr-framework 0.2.4 → 0.2.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillipsharring/graspr-framework",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "HTMX + Handlebars + Tailwind frontend framework",
5
5
  "type": "module",
6
6
  "exports": {
@@ -52,6 +52,17 @@ function applyAuthState(authData) {
52
52
  loginLink?.removeAttribute('hidden');
53
53
  }
54
54
 
55
+ // Auth-visibility elements — show or hide based on auth state.
56
+ // Use hidden attribute in markup so they start invisible (no flash).
57
+ // data-show-if-auth: hidden by default, revealed when authenticated
58
+ // data-hide-if-auth: hidden by default, revealed when NOT authenticated
59
+ document.querySelectorAll('[data-show-if-auth]').forEach(el => {
60
+ if (authenticated) el.removeAttribute('hidden');
61
+ });
62
+ document.querySelectorAll('[data-hide-if-auth]').forEach(el => {
63
+ if (!authenticated) el.removeAttribute('hidden');
64
+ });
65
+
55
66
  // Widgets that require an authenticated session.
56
67
  // Track triggered elements in a WeakSet so each element only fires once,
57
68
  // even if multiple afterSwap/afterSettle handlers call applyAuthState while
@@ -62,6 +62,12 @@ document.body.addEventListener('htmx:beforeSwap', (e) => {
62
62
 
63
63
  if (!newApp) return;
64
64
 
65
+ // Preserve the page title — replacing serverResponse strips <head>
66
+ const newTitle = doc.querySelector('title');
67
+ if (newTitle) {
68
+ document.title = newTitle.textContent;
69
+ }
70
+
65
71
  detail.target = app;
66
72
  detail.serverResponse = newApp.outerHTML;
67
73
  detail.swapOverride = 'outerHTML';