weg-shared-layout 0.0.38 → 0.0.40

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.
Files changed (30) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/weg-footer_2.cjs.entry.js +9 -10
  3. package/dist/collection/components/weg-footer/icons/instagram.svg +5 -5
  4. package/dist/collection/components/weg-footer/icons/linkedin.svg +3 -3
  5. package/dist/collection/components/weg-footer/icons/tiktok.svg +3 -3
  6. package/dist/collection/components/weg-footer/icons/youtube.svg +4 -4
  7. package/dist/collection/components/weg-footer/weg-footer.css +263 -263
  8. package/dist/collection/components/weg-footer/weg-footer.js +2 -2
  9. package/dist/collection/components/weg-header/weg-header.css +483 -483
  10. package/dist/collection/components/weg-header/weg-header.js +9 -10
  11. package/dist/collection/styles/shared.css +103 -103
  12. package/dist/components/weg-footer.js +1 -1
  13. package/dist/components/weg-header.js +1 -1
  14. package/dist/esm/weg-footer_2.entry.js +9 -10
  15. package/dist/weg-shared-layout/p-6f83b24a.entry.js +1 -0
  16. package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
  17. package/docs/README.md +49 -49
  18. package/docs/angular.md +400 -402
  19. package/docs/nextjs.md +302 -315
  20. package/docs/publishing.md +65 -65
  21. package/docs/react.md +257 -272
  22. package/docs/vanilla.md +124 -140
  23. package/package.json +81 -81
  24. package/readme.md +97 -96
  25. package/src/assets/dummy-data.json +1 -2
  26. package/src/constants/breakpoints.ts +7 -7
  27. package/src/styles/container.css +60 -60
  28. package/dist/weg-shared-layout/p-18d9facc.entry.js +0 -1
  29. /package/dist/types/Users/{rakin/Documents/WEG/repos → tan/Documents/code}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
  30. /package/dist/types/Users/{rakin/Documents/WEG/repos → tan/Documents/code}/weg-shared-layout/.stencil/test-utils/viewport.d.ts +0 -0
package/docs/nextjs.md CHANGED
@@ -1,315 +1,302 @@
1
- # Next.js (App Router)
2
-
3
- Guide for **Next.js 13+ App Router** (`app/` directory). For Vite/CRA-style client-only React, see **[React SPA](./react.md)**.
4
-
5
- ## Components
6
-
7
- | Tag | Purpose |
8
- | --- | --- |
9
- | `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
10
- | `<weg-footer>` | Site footer — social, menu, legal text |
11
-
12
- Both accept **`layout`** (JSON string recommended in Next). `<weg-header>` also accepts **`signed-in`**, **`user-name`**, and emits **`wegAuthClick`**.
13
-
14
- ## Why Next.js is different
15
-
16
- | Topic | SPA (React 19) | Next.js App Router |
17
- | --- | --- | --- |
18
- | **Where components run** | Client only | Must be in **Client Components** (`"use client"`) |
19
- | **Server Components** | N/A | Default in `app/` — cannot call `defineCustomElements()` |
20
- | **SSR output** | N/A | Often empty custom-element tags until client hydrates |
21
- | **`layout={object}` on CE** | Works on React 19+ | **Unreliable** — use **`JSON.stringify(layout)`** |
22
- | **Auth state** | `signed-in` prop | Set in client wrapper from session hook / context |
23
-
24
- ## Requirements
25
-
26
- | Requirement | Notes |
27
- | --- | --- |
28
- | **Next.js 13+** | App Router (`app/layout.tsx`) |
29
- | **`transpilePackages`** | Next must compile `weg-shared-layout` |
30
- | **`suppressHydrationWarning`** | Recommended on both tags (SSR placeholder vs client shadow DOM) |
31
- | **TypeScript** | `resolveJsonModule` if importing `weg-shared-layout/dummy-data.json` on the server |
32
-
33
- ## Install
34
-
35
- ```bash
36
- npm i weg-shared-layout
37
- # or
38
- pnpm add weg-shared-layout
39
- ```
40
-
41
- ## 1. Transpile the package
42
-
43
- ```ts
44
- // next.config.ts
45
- import type { NextConfig } from 'next';
46
-
47
- const nextConfig: NextConfig = {
48
- transpilePackages: ['weg-shared-layout'],
49
- };
50
-
51
- export default nextConfig;
52
- ```
53
-
54
- ## 2. Auth constants (host app)
55
-
56
- Keep sign-in/out URLs in your app — not imported from `weg-shared-layout`:
57
-
58
- ```ts
59
- // src/auth.ts
60
- export const HEADER_SIGN_IN = {
61
- label: 'Sign in',
62
- href: 'https://account.warwickemploymentgroup.com/account/login',
63
- };
64
-
65
- export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
66
- ```
67
-
68
- ## 3. Client layout components
69
-
70
- ```tsx
71
- // src/components/layout/Header.tsx
72
- 'use client';
73
-
74
- import { useCallback } from 'react';
75
- import { defineCustomElements } from 'weg-shared-layout/loader';
76
- import { ACCOUNT_LOGIN_HREF, HEADER_SIGN_IN } from '@/auth';
77
- import 'weg-shared-layout/weg-header';
78
-
79
- defineCustomElements();
80
-
81
- import type { LayoutData } from 'weg-shared-layout/layout-data';
82
- // Or: import layoutFixture from 'weg-shared-layout/dummy-data.json';
83
- // type LayoutData = typeof layoutFixture;
84
-
85
- export function Header({
86
- layout,
87
- signedIn,
88
- userName,
89
- onSignedInChange,
90
- }: {
91
- layout: LayoutData;
92
- signedIn: boolean;
93
- userName?: string;
94
- onSignedInChange?: (signedIn: boolean) => void;
95
- }) {
96
- const onAuthClick = useCallback(
97
- (event: CustomEvent<{ action: 'sign-in' | 'sign-out' }>) => {
98
- event.preventDefault();
99
-
100
- if (event.detail.action === 'sign-out') {
101
- onSignedInChange?.(false);
102
- window.location.href = ACCOUNT_LOGIN_HREF;
103
- return;
104
- }
105
-
106
- window.location.href = HEADER_SIGN_IN.href;
107
- },
108
- [layout, onSignedInChange],
109
- );
110
-
111
- return (
112
- <weg-header
113
- layout={JSON.stringify(layout)}
114
- signedIn={signedIn}
115
- {...(userName ? { userName } : {})}
116
- suppressHydrationWarning
117
- onWegAuthClick={onAuthClick}
118
- />
119
- );
120
- }
121
- ```
122
-
123
- ```tsx
124
- // src/components/layout/Footer.tsx
125
- 'use client';
126
-
127
- import { defineCustomElements } from 'weg-shared-layout/loader';
128
- import 'weg-shared-layout/weg-footer';
129
-
130
- defineCustomElements();
131
-
132
- export function Footer({ layout }: { layout: unknown }) {
133
- return <weg-footer layout={JSON.stringify(layout)} suppressHydrationWarning />;
134
- }
135
- ```
136
-
137
- ```tsx
138
- // src/components/layout/SiteChrome.tsx — optional wrapper
139
- 'use client';
140
-
141
- import { useState } from 'react';
142
- import { Header } from './Header';
143
- import { Footer } from './Footer';
144
-
145
- export function SiteChrome({
146
- layout,
147
- children,
148
- }: {
149
- layout: unknown;
150
- children: React.ReactNode;
151
- }) {
152
- const [signedIn, setSignedIn] = useState(false);
153
- const userName = signedIn ? 'Alex' : undefined; // from your session
154
-
155
- return (
156
- <>
157
- <Header
158
- layout={layout}
159
- signedIn={signedIn}
160
- userName={userName}
161
- onSignedInChange={setSignedIn}
162
- />
163
- {children}
164
- <Footer layout={layout} />
165
- </>
166
- );
167
- }
168
- ```
169
-
170
- ### Why `JSON.stringify` and `suppressHydrationWarning`
171
-
172
- | Line | Purpose |
173
- | --- | --- |
174
- | `layout={JSON.stringify(layout)}` | Serializable across RSC → client; component parses JSON |
175
- | `suppressHydrationWarning` | Server renders empty tag; client fills shadow DOM |
176
- | `'use client'` | Registration and auth handlers need the browser |
177
-
178
- Do **not** pass `layout={layoutObject}` directly on the custom elements in Next.
179
-
180
- ## 4. Server layout
181
-
182
- ```tsx
183
- // app/layout.tsx (Server Component)
184
- import { SiteChrome } from '@/components/layout/SiteChrome';
185
- import layout from 'weg-shared-layout/dummy-data.json';
186
-
187
- export default function RootLayout({ children }: { children: React.ReactNode }) {
188
- return (
189
- <html lang="en">
190
- <body>
191
- <SiteChrome layout={layout}>{children}</SiteChrome>
192
- </body>
193
- </html>
194
- );
195
- }
196
- ```
197
-
198
- ## 5. Production: fetch layout on the server
199
-
200
- ```tsx
201
- // app/layout.tsx
202
- import { SiteChrome } from '@/components/layout/SiteChrome';
203
-
204
- const LAYOUT_URL = 'https://weg-payload-test.vercel.app/api/layout';
205
-
206
- async function getLayout() {
207
- const res = await fetch(LAYOUT_URL, { next: { revalidate: 60 } });
208
- if (!res.ok) throw new Error('Failed to load layout');
209
- return res.json();
210
- }
211
-
212
- export default async function RootLayout({ children }: { children: React.ReactNode }) {
213
- const layout = await getLayout();
214
-
215
- return (
216
- <html lang="en">
217
- <body>
218
- <SiteChrome layout={layout}>{children}</SiteChrome>
219
- </body>
220
- </html>
221
- );
222
- }
223
- ```
224
-
225
- Pass the plain object into the Client Component; **stringify inside** the header/footer wrappers.
226
-
227
- Wire **`signedIn`** and **`userName`** from your auth provider (session hook / context in a client wrapper).
228
-
229
- ## Header auth reference
230
-
231
- | API | Signed out | Signed in |
232
- | --- | --- | --- |
233
- | `layout.header.menu` | CMS nav rendered (groups + flat links incl. Sign in) | Ignored — built-in nav used |
234
- | `layout.header.logoSrc` | Logo image URL (bundled if omitted) | Built-in bundled logo |
235
- | `layout.header.logoHref` | Logo link URL | WEG homepage |
236
- | `signed-in` prop | `false` | `true` — session flag from host app |
237
- | `user-name` prop | — | User's first name on Manage Account |
238
- | `wegAuthClick` event | `'sign-in'` on Sign in click | `'sign-out'` on Sign out click |
239
- | `event.preventDefault()` | Skip default navigation | Skip default redirect |
240
-
241
- **Signed-in nav (built into the component):** Find a job, Dashboard, Manage Account, Sign out.
242
-
243
- The logo **image** uses `layout.header.logoSrc` when signed out (bundled if omitted). The logo **link** uses `layout.header.logoHref` when provided; otherwise it defaults to the WEG homepage.
244
-
245
- ## Passing `layout` — quick reference
246
-
247
- | Approach | Works in Next? |
248
- | --- | --- |
249
- | `layout={object}` on `<weg-header>` / `<weg-footer>` | **No** |
250
- | `layout={JSON.stringify(obj)}` in client wrapper | **Yes** (recommended) |
251
- | Pass object to `<SiteChrome layout={...} />`, stringify in child | **Yes** |
252
- | `ref` + `el.layout = obj` in `useEffect` | Yes (escape hatch) |
253
-
254
- ## TypeScript
255
-
256
- ### Server / client JSON imports
257
-
258
- ```json
259
- {
260
- "compilerOptions": {
261
- "resolveJsonModule": true,
262
- "moduleResolution": "bundler"
263
- }
264
- }
265
- ```
266
-
267
- ### JSX module augmentation
268
-
269
- ```ts
270
- // src/types/weg-shared-layout-jsx.d.ts
271
- import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
272
- import type { DetailedHTMLProps, HTMLAttributes } from 'react';
273
-
274
- declare module 'react' {
275
- namespace JSX {
276
- interface IntrinsicElements extends WegSharedLayoutJSX.IntrinsicElements {
277
- 'weg-header': WegSharedLayoutJSX.IntrinsicElements['weg-header'] &
278
- DetailedHTMLProps<HTMLAttributes<HTMLWegHeaderElement>, HTMLWegHeaderElement>;
279
- 'weg-footer': WegSharedLayoutJSX.IntrinsicElements['weg-footer'] &
280
- DetailedHTMLProps<HTMLAttributes<HTMLWegFooterElement>, HTMLWegFooterElement>;
281
- }
282
- }
283
- }
284
- ```
285
-
286
- ## Troubleshooting
287
-
288
- | Symptom | Likely cause | Fix |
289
- | --- | --- | --- |
290
- | `document is not defined` | Loader in Server Component | Keep registration in `"use client"` files only. |
291
- | Empty after hydration | Object passed to CE without stringify | `JSON.stringify` in client wrapper. |
292
- | Logo missing | Stale package | Logo is inlined in `logo-data.ts`; rebuild / upgrade. |
293
- | Header not clickable | Overlapping page content | `:host` uses `z-index: 20`; upgrade package if missing. |
294
- | Auth not updating | `signed-in` only on server | Manage session in client state / context. |
295
- | Hydration warning | Shadow DOM mismatch | `suppressHydrationWarning` on both tags. |
296
- | Build error | Package not transpiled | `transpilePackages: ['weg-shared-layout']`. |
297
-
298
- ## Integration checklist
299
-
300
- - [ ] `weg-shared-layout` installed
301
- - [ ] `transpilePackages` in `next.config`
302
- - [ ] Client `Header.tsx` / `Footer.tsx` with loader, tag imports, `JSON.stringify`, `suppressHydrationWarning`
303
- - [ ] Auth: `signed-in`, `user-name`, and `wegAuthClick` handler on header
304
- - [ ] Server `layout.tsx` imports client chrome only (no `defineCustomElements` on server)
305
- - [ ] Layout fetched or imported server-side, passed as serializable props
306
- - [ ] TypeScript augmentation for `'weg-header'` and `'weg-footer'`
307
- - [ ] Verified in browser after hydration
308
-
309
- ## See also
310
-
311
- - **[Documentation index](./README.md)**
312
- - **[React SPA](./react.md)**
313
- - **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
314
- - **[Plain HTML / vanilla JS](./vanilla.md)**
315
- - **[Package readme](../readme.md)**
1
+ # Next.js (App Router)
2
+
3
+ Guide for **Next.js 13+ App Router** (`app/` directory). For Vite/CRA-style client-only React, see **[React SPA](./react.md)**.
4
+
5
+ ## Components
6
+
7
+ | Tag | Purpose |
8
+ | --- | --- |
9
+ | `<weg-header>` | Site header — bundled logo, CMS nav (signed out), built-in nav (signed in), Sign in / Manage Account / Sign out |
10
+ | `<weg-footer>` | Site footer — social, menu, legal text |
11
+
12
+ Both accept **`layout`** (JSON string recommended in Next). `<weg-header>` also accepts **`signed-in`**, **`user-name`**, **`account-base-url`**, and emits **`wegAuthClick`**.
13
+
14
+ ## Why Next.js is different
15
+
16
+ | Topic | SPA (React 19) | Next.js App Router |
17
+ | --- | --- | --- |
18
+ | **Where components run** | Client only | Must be in **Client Components** (`"use client"`) |
19
+ | **Server Components** | N/A | Default in `app/` — cannot call `defineCustomElements()` |
20
+ | **SSR output** | N/A | Often empty custom-element tags until client hydrates |
21
+ | **`layout={object}` on CE** | Works on React 19+ | **Unreliable** — use **`JSON.stringify(layout)`** |
22
+ | **Auth state** | `signed-in` prop | Set in client wrapper from session hook / context |
23
+
24
+ ## Requirements
25
+
26
+ | Requirement | Notes |
27
+ | --- | --- |
28
+ | **Next.js 13+** | App Router (`app/layout.tsx`) |
29
+ | **`transpilePackages`** | Next must compile `weg-shared-layout` |
30
+ | **`suppressHydrationWarning`** | Recommended on both tags (SSR placeholder vs client shadow DOM) |
31
+ | **TypeScript** | `resolveJsonModule` if importing `weg-shared-layout/dummy-data.json` on the server |
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ npm i weg-shared-layout
37
+ # or
38
+ pnpm add weg-shared-layout
39
+ ```
40
+
41
+ ## 1. Transpile the package
42
+
43
+ ```ts
44
+ // next.config.ts
45
+ import type { NextConfig } from 'next';
46
+
47
+ const nextConfig: NextConfig = {
48
+ transpilePackages: ['weg-shared-layout'],
49
+ };
50
+
51
+ export default nextConfig;
52
+ ```
53
+
54
+ ## 2. Sign-out handling
55
+
56
+ Sign-in comes from your CMS `header.menu` like any other link. Handle sign-out via **`wegAuthClick`** — call your logout API, then redirect (e.g. to `/`).
57
+
58
+ ## 3. Client layout components
59
+
60
+ ```tsx
61
+ // src/components/layout/Header.tsx
62
+ 'use client';
63
+
64
+ import { useCallback } from 'react';
65
+ import { defineCustomElements } from 'weg-shared-layout/loader';
66
+ import 'weg-shared-layout/weg-header';
67
+
68
+ defineCustomElements();
69
+
70
+ import type { LayoutData } from 'weg-shared-layout/layout-data';
71
+ // Or: import layoutFixture from 'weg-shared-layout/dummy-data.json';
72
+ // type LayoutData = typeof layoutFixture;
73
+
74
+ export function Header({
75
+ layout,
76
+ signedIn,
77
+ userName,
78
+ onSignedInChange,
79
+ }: {
80
+ layout: LayoutData;
81
+ signedIn: boolean;
82
+ userName?: string;
83
+ onSignedInChange?: (signedIn: boolean) => void;
84
+ }) {
85
+ const onAuthClick = useCallback(
86
+ async (event: CustomEvent<{ action: 'sign-in' | 'sign-out' }>) => {
87
+ if (event.detail.action !== 'sign-out') return;
88
+
89
+ event.preventDefault();
90
+ await logout();
91
+ onSignedInChange?.(false);
92
+ window.location.assign('/');
93
+ },
94
+ [onSignedInChange],
95
+ );
96
+
97
+ return (
98
+ <weg-header
99
+ layout={JSON.stringify(layout)}
100
+ signedIn={signedIn}
101
+ {...(userName ? { userName } : {})}
102
+ suppressHydrationWarning
103
+ onWegAuthClick={onAuthClick}
104
+ />
105
+ );
106
+ }
107
+ ```
108
+
109
+ ```tsx
110
+ // src/components/layout/Footer.tsx
111
+ 'use client';
112
+
113
+ import { defineCustomElements } from 'weg-shared-layout/loader';
114
+ import 'weg-shared-layout/weg-footer';
115
+
116
+ defineCustomElements();
117
+
118
+ export function Footer({ layout }: { layout: unknown }) {
119
+ return <weg-footer layout={JSON.stringify(layout)} suppressHydrationWarning />;
120
+ }
121
+ ```
122
+
123
+ ```tsx
124
+ // src/components/layout/SiteChrome.tsx — optional wrapper
125
+ 'use client';
126
+
127
+ import { useState } from 'react';
128
+ import { Header } from './Header';
129
+ import { Footer } from './Footer';
130
+
131
+ export function SiteChrome({
132
+ layout,
133
+ children,
134
+ }: {
135
+ layout: unknown;
136
+ children: React.ReactNode;
137
+ }) {
138
+ const [signedIn, setSignedIn] = useState(false);
139
+ const userName = signedIn ? 'Alex' : undefined; // from your session
140
+
141
+ return (
142
+ <>
143
+ <Header
144
+ layout={layout}
145
+ signedIn={signedIn}
146
+ userName={userName}
147
+ onSignedInChange={setSignedIn}
148
+ />
149
+ {children}
150
+ <Footer layout={layout} />
151
+ </>
152
+ );
153
+ }
154
+ ```
155
+
156
+ ### Why `JSON.stringify` and `suppressHydrationWarning`
157
+
158
+ | Line | Purpose |
159
+ | --- | --- |
160
+ | `layout={JSON.stringify(layout)}` | Serializable across RSC → client; component parses JSON |
161
+ | `suppressHydrationWarning` | Server renders empty tag; client fills shadow DOM |
162
+ | `'use client'` | Registration and auth handlers need the browser |
163
+
164
+ Do **not** pass `layout={layoutObject}` directly on the custom elements in Next.
165
+
166
+ ## 4. Server layout
167
+
168
+ ```tsx
169
+ // app/layout.tsx (Server Component)
170
+ import { SiteChrome } from '@/components/layout/SiteChrome';
171
+ import layout from 'weg-shared-layout/dummy-data.json';
172
+
173
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
174
+ return (
175
+ <html lang="en">
176
+ <body>
177
+ <SiteChrome layout={layout}>{children}</SiteChrome>
178
+ </body>
179
+ </html>
180
+ );
181
+ }
182
+ ```
183
+
184
+ ## 5. Production: fetch layout on the server
185
+
186
+ ```tsx
187
+ // app/layout.tsx
188
+ import { SiteChrome } from '@/components/layout/SiteChrome';
189
+
190
+ const LAYOUT_URL = 'https://weg-payload-test.vercel.app/api/layout';
191
+
192
+ async function getLayout() {
193
+ const res = await fetch(LAYOUT_URL, { next: { revalidate: 60 } });
194
+ if (!res.ok) throw new Error('Failed to load layout');
195
+ return res.json();
196
+ }
197
+
198
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
199
+ const layout = await getLayout();
200
+
201
+ return (
202
+ <html lang="en">
203
+ <body>
204
+ <SiteChrome layout={layout}>{children}</SiteChrome>
205
+ </body>
206
+ </html>
207
+ );
208
+ }
209
+ ```
210
+
211
+ Pass the plain object into the Client Component; **stringify inside** the header/footer wrappers.
212
+
213
+ Wire **`signedIn`** and **`userName`** from your auth provider (session hook / context in a client wrapper).
214
+
215
+ ## Header auth reference
216
+
217
+ | API | Signed out | Signed in |
218
+ | --- | --- | --- |
219
+ | `layout.header.menu` | CMS nav rendered (groups + flat links incl. sign-in) | Ignored — built-in nav used |
220
+ | `layout.header.logoSrc` | Logo image URL (bundled if omitted) | Built-in bundled logo |
221
+ | `layout.header.logoHref` | Logo link URL | WEG homepage |
222
+ | `signed-in` prop | `false` | `true` — session flag from host app |
223
+ | `user-name` prop | — | User's first name on Manage Account |
224
+ | `account-base-url` prop | — | Account portal origin for signed-in links (optional) |
225
+ | `wegAuthClick` event | Sign-in follows link `href` | `'sign-out'` — host handles logout and redirect |
226
+ | `event.preventDefault()` | Skip default navigation | Required — sign-out has no built-in redirect |
227
+
228
+ **Signed-in nav (built into the component):** Find a job, Dashboard, Manage Account, Sign out.
229
+
230
+ The logo **image** uses `layout.header.logoSrc` when signed out (bundled if omitted). The logo **link** uses `layout.header.logoHref` when provided; otherwise it defaults to the WEG homepage.
231
+
232
+ ## Passing `layout` — quick reference
233
+
234
+ | Approach | Works in Next? |
235
+ | --- | --- |
236
+ | `layout={object}` on `<weg-header>` / `<weg-footer>` | **No** |
237
+ | `layout={JSON.stringify(obj)}` in client wrapper | **Yes** (recommended) |
238
+ | Pass object to `<SiteChrome layout={...} />`, stringify in child | **Yes** |
239
+ | `ref` + `el.layout = obj` in `useEffect` | Yes (escape hatch) |
240
+
241
+ ## TypeScript
242
+
243
+ ### Server / client JSON imports
244
+
245
+ ```json
246
+ {
247
+ "compilerOptions": {
248
+ "resolveJsonModule": true,
249
+ "moduleResolution": "bundler"
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### JSX module augmentation
255
+
256
+ ```ts
257
+ // src/types/weg-shared-layout-jsx.d.ts
258
+ import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
259
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
260
+
261
+ declare module 'react' {
262
+ namespace JSX {
263
+ interface IntrinsicElements extends WegSharedLayoutJSX.IntrinsicElements {
264
+ 'weg-header': WegSharedLayoutJSX.IntrinsicElements['weg-header'] &
265
+ DetailedHTMLProps<HTMLAttributes<HTMLWegHeaderElement>, HTMLWegHeaderElement>;
266
+ 'weg-footer': WegSharedLayoutJSX.IntrinsicElements['weg-footer'] &
267
+ DetailedHTMLProps<HTMLAttributes<HTMLWegFooterElement>, HTMLWegFooterElement>;
268
+ }
269
+ }
270
+ }
271
+ ```
272
+
273
+ ## Troubleshooting
274
+
275
+ | Symptom | Likely cause | Fix |
276
+ | --- | --- | --- |
277
+ | `document is not defined` | Loader in Server Component | Keep registration in `"use client"` files only. |
278
+ | Empty after hydration | Object passed to CE without stringify | `JSON.stringify` in client wrapper. |
279
+ | Logo missing | Stale package | Logo is inlined in `logo-data.ts`; rebuild / upgrade. |
280
+ | Header not clickable | Overlapping page content | `:host` uses `z-index: 20`; upgrade package if missing. |
281
+ | Auth not updating | `signed-in` only on server | Manage session in client state / context. |
282
+ | Hydration warning | Shadow DOM mismatch | `suppressHydrationWarning` on both tags. |
283
+ | Build error | Package not transpiled | `transpilePackages: ['weg-shared-layout']`. |
284
+
285
+ ## Integration checklist
286
+
287
+ - [ ] `weg-shared-layout` installed
288
+ - [ ] `transpilePackages` in `next.config`
289
+ - [ ] Client `Header.tsx` / `Footer.tsx` with loader, tag imports, `JSON.stringify`, `suppressHydrationWarning`
290
+ - [ ] Auth: `signed-in`, `user-name`, `account-base-url` (optional), and `wegAuthClick` handler on header
291
+ - [ ] Server `layout.tsx` imports client chrome only (no `defineCustomElements` on server)
292
+ - [ ] Layout fetched or imported server-side, passed as serializable props
293
+ - [ ] TypeScript augmentation for `'weg-header'` and `'weg-footer'`
294
+ - [ ] Verified in browser after hydration
295
+
296
+ ## See also
297
+
298
+ - **[Documentation index](./README.md)**
299
+ - **[React SPA](./react.md)**
300
+ - **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
301
+ - **[Plain HTML / vanilla JS](./vanilla.md)**
302
+ - **[Package readme](../readme.md)**