weg-shared-layout 0.0.27 → 0.0.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.
Files changed (31) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/weg-footer_2.cjs.entry.js +7 -7
  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 -270
  8. package/dist/collection/components/weg-footer/weg-footer.js +2 -2
  9. package/dist/collection/components/weg-header/weg-header.css +491 -474
  10. package/dist/collection/components/weg-header/weg-header.js +4 -4
  11. package/dist/collection/styles/shared.css +96 -72
  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 +7 -7
  15. package/dist/weg-shared-layout/p-ded6ae1c.entry.js +1 -0
  16. package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
  17. package/docs/README.md +51 -51
  18. package/docs/angular-16-compatibility.md +250 -250
  19. package/docs/angular-integration-guide.md +1035 -1035
  20. package/docs/angular.md +258 -258
  21. package/docs/nextjs.md +314 -314
  22. package/docs/publishing.md +65 -65
  23. package/docs/react.md +272 -272
  24. package/docs/vanilla.md +139 -139
  25. package/package.json +81 -79
  26. package/readme.md +97 -96
  27. package/src/constants/breakpoints.ts +7 -7
  28. package/src/styles/container.css +53 -0
  29. package/dist/weg-shared-layout/p-e6eadfa1.entry.js +0 -1
  30. /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/axe.d.ts +0 -0
  31. /package/dist/types/Users/{tan/Documents/code → rakin/Documents/WEG/repos}/weg-shared-layout/.stencil/test-utils/viewport.d.ts +0 -0
package/docs/nextjs.md CHANGED
@@ -1,314 +1,314 @@
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
- | `signed-in` prop | `false` | `true` — session flag from host app |
236
- | `user-name` prop | — | User's first name on Manage Account |
237
- | `wegAuthClick` event | `'sign-in'` on Sign in click | `'sign-out'` on Sign out click |
238
- | `event.preventDefault()` | Skip default navigation | Skip default redirect |
239
-
240
- **Signed-in nav (built into the component):** Find a job, Dashboard, Manage Account, Sign out.
241
-
242
- The logo **image** uses `layout.header.logoSrc` when signed out (bundled if omitted). The logo **link** always goes to WEG home.
243
-
244
- ## Passing `layout` — quick reference
245
-
246
- | Approach | Works in Next? |
247
- | --- | --- |
248
- | `layout={object}` on `<weg-header>` / `<weg-footer>` | **No** |
249
- | `layout={JSON.stringify(obj)}` in client wrapper | **Yes** (recommended) |
250
- | Pass object to `<SiteChrome layout={...} />`, stringify in child | **Yes** |
251
- | `ref` + `el.layout = obj` in `useEffect` | Yes (escape hatch) |
252
-
253
- ## TypeScript
254
-
255
- ### Server / client JSON imports
256
-
257
- ```json
258
- {
259
- "compilerOptions": {
260
- "resolveJsonModule": true,
261
- "moduleResolution": "bundler"
262
- }
263
- }
264
- ```
265
-
266
- ### JSX module augmentation
267
-
268
- ```ts
269
- // src/types/weg-shared-layout-jsx.d.ts
270
- import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
271
- import type { DetailedHTMLProps, HTMLAttributes } from 'react';
272
-
273
- declare module 'react' {
274
- namespace JSX {
275
- interface IntrinsicElements extends WegSharedLayoutJSX.IntrinsicElements {
276
- 'weg-header': WegSharedLayoutJSX.IntrinsicElements['weg-header'] &
277
- DetailedHTMLProps<HTMLAttributes<HTMLWegHeaderElement>, HTMLWegHeaderElement>;
278
- 'weg-footer': WegSharedLayoutJSX.IntrinsicElements['weg-footer'] &
279
- DetailedHTMLProps<HTMLAttributes<HTMLWegFooterElement>, HTMLWegFooterElement>;
280
- }
281
- }
282
- }
283
- ```
284
-
285
- ## Troubleshooting
286
-
287
- | Symptom | Likely cause | Fix |
288
- | --- | --- | --- |
289
- | `document is not defined` | Loader in Server Component | Keep registration in `"use client"` files only. |
290
- | Empty after hydration | Object passed to CE without stringify | `JSON.stringify` in client wrapper. |
291
- | Logo missing | Stale package | Logo is inlined in `logo-data.ts`; rebuild / upgrade. |
292
- | Header not clickable | Overlapping page content | `:host` uses `z-index: 20`; upgrade package if missing. |
293
- | Auth not updating | `signed-in` only on server | Manage session in client state / context. |
294
- | Hydration warning | Shadow DOM mismatch | `suppressHydrationWarning` on both tags. |
295
- | Build error | Package not transpiled | `transpilePackages: ['weg-shared-layout']`. |
296
-
297
- ## Integration checklist
298
-
299
- - [ ] `weg-shared-layout` installed
300
- - [ ] `transpilePackages` in `next.config`
301
- - [ ] Client `Header.tsx` / `Footer.tsx` with loader, tag imports, `JSON.stringify`, `suppressHydrationWarning`
302
- - [ ] Auth: `signed-in`, `user-name`, and `wegAuthClick` handler on header
303
- - [ ] Server `layout.tsx` imports client chrome only (no `defineCustomElements` on server)
304
- - [ ] Layout fetched or imported server-side, passed as serializable props
305
- - [ ] TypeScript augmentation for `'weg-header'` and `'weg-footer'`
306
- - [ ] Verified in browser after hydration
307
-
308
- ## See also
309
-
310
- - **[Documentation index](./README.md)**
311
- - **[React SPA](./react.md)**
312
- - **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
313
- - **[Plain HTML / vanilla JS](./vanilla.md)**
314
- - **[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`**, 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
+ | `signed-in` prop | `false` | `true` — session flag from host app |
236
+ | `user-name` prop | — | User's first name on Manage Account |
237
+ | `wegAuthClick` event | `'sign-in'` on Sign in click | `'sign-out'` on Sign out click |
238
+ | `event.preventDefault()` | Skip default navigation | Skip default redirect |
239
+
240
+ **Signed-in nav (built into the component):** Find a job, Dashboard, Manage Account, Sign out.
241
+
242
+ The logo **image** uses `layout.header.logoSrc` when signed out (bundled if omitted). The logo **link** always goes to WEG home.
243
+
244
+ ## Passing `layout` — quick reference
245
+
246
+ | Approach | Works in Next? |
247
+ | --- | --- |
248
+ | `layout={object}` on `<weg-header>` / `<weg-footer>` | **No** |
249
+ | `layout={JSON.stringify(obj)}` in client wrapper | **Yes** (recommended) |
250
+ | Pass object to `<SiteChrome layout={...} />`, stringify in child | **Yes** |
251
+ | `ref` + `el.layout = obj` in `useEffect` | Yes (escape hatch) |
252
+
253
+ ## TypeScript
254
+
255
+ ### Server / client JSON imports
256
+
257
+ ```json
258
+ {
259
+ "compilerOptions": {
260
+ "resolveJsonModule": true,
261
+ "moduleResolution": "bundler"
262
+ }
263
+ }
264
+ ```
265
+
266
+ ### JSX module augmentation
267
+
268
+ ```ts
269
+ // src/types/weg-shared-layout-jsx.d.ts
270
+ import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
271
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
272
+
273
+ declare module 'react' {
274
+ namespace JSX {
275
+ interface IntrinsicElements extends WegSharedLayoutJSX.IntrinsicElements {
276
+ 'weg-header': WegSharedLayoutJSX.IntrinsicElements['weg-header'] &
277
+ DetailedHTMLProps<HTMLAttributes<HTMLWegHeaderElement>, HTMLWegHeaderElement>;
278
+ 'weg-footer': WegSharedLayoutJSX.IntrinsicElements['weg-footer'] &
279
+ DetailedHTMLProps<HTMLAttributes<HTMLWegFooterElement>, HTMLWegFooterElement>;
280
+ }
281
+ }
282
+ }
283
+ ```
284
+
285
+ ## Troubleshooting
286
+
287
+ | Symptom | Likely cause | Fix |
288
+ | --- | --- | --- |
289
+ | `document is not defined` | Loader in Server Component | Keep registration in `"use client"` files only. |
290
+ | Empty after hydration | Object passed to CE without stringify | `JSON.stringify` in client wrapper. |
291
+ | Logo missing | Stale package | Logo is inlined in `logo-data.ts`; rebuild / upgrade. |
292
+ | Header not clickable | Overlapping page content | `:host` uses `z-index: 20`; upgrade package if missing. |
293
+ | Auth not updating | `signed-in` only on server | Manage session in client state / context. |
294
+ | Hydration warning | Shadow DOM mismatch | `suppressHydrationWarning` on both tags. |
295
+ | Build error | Package not transpiled | `transpilePackages: ['weg-shared-layout']`. |
296
+
297
+ ## Integration checklist
298
+
299
+ - [ ] `weg-shared-layout` installed
300
+ - [ ] `transpilePackages` in `next.config`
301
+ - [ ] Client `Header.tsx` / `Footer.tsx` with loader, tag imports, `JSON.stringify`, `suppressHydrationWarning`
302
+ - [ ] Auth: `signed-in`, `user-name`, and `wegAuthClick` handler on header
303
+ - [ ] Server `layout.tsx` imports client chrome only (no `defineCustomElements` on server)
304
+ - [ ] Layout fetched or imported server-side, passed as serializable props
305
+ - [ ] TypeScript augmentation for `'weg-header'` and `'weg-footer'`
306
+ - [ ] Verified in browser after hydration
307
+
308
+ ## See also
309
+
310
+ - **[Documentation index](./README.md)**
311
+ - **[React SPA](./react.md)**
312
+ - **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
313
+ - **[Plain HTML / vanilla JS](./vanilla.md)**
314
+ - **[Package readme](../readme.md)**