weg-shared-layout 0.0.26 → 0.0.27
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/docs/README.md +51 -0
- package/docs/angular-16-compatibility.md +27 -12
- package/docs/angular-integration-guide.md +35 -8
- package/docs/angular.md +39 -13
- package/docs/nextjs.md +19 -11
- package/docs/publishing.md +20 -3
- package/docs/react.md +26 -15
- package/docs/vanilla.md +3 -2
- package/package.json +5 -2
- package/readme.md +15 -2
package/docs/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Documentation index
|
|
2
|
+
|
|
3
|
+
Guides for integrating **`weg-shared-layout`** (`<weg-header>`, `<weg-footer>`) in host applications.
|
|
4
|
+
|
|
5
|
+
Layout shape uses **`header.menu`** (unified nav) and **`footer.menu`** (columns). Reference JSON: [`src/assets/dummy-data.json`](../src/assets/dummy-data.json).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Choose a guide
|
|
10
|
+
|
|
11
|
+
| Guide | Audience |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| **[../readme.md](../readme.md)** | Package overview, install, abbreviated layout shape |
|
|
14
|
+
| **[angular-integration-guide.md](./angular-integration-guide.md)** | Angular 16+ — full step-by-step, HTTP, API mapping, testing, SSR |
|
|
15
|
+
| **[angular.md](./angular.md)** | Angular quick start (checklist + copy-paste) |
|
|
16
|
+
| **[angular-16-compatibility.md](./angular-16-compatibility.md)** | Angular 16 + TS 4.9/5.x — Stencil `.d.ts` errors, `moduleResolution`, subpath imports |
|
|
17
|
+
| **[../demo/angular16/README.md](../demo/angular16/README.md)** | **Runnable Angular 16 demo** — same code as npm install (`file:../..` only for maintainers) |
|
|
18
|
+
| **[react.md](./react.md)** | React 19+ SPA (Vite, CRA, etc.) |
|
|
19
|
+
| **[nextjs.md](./nextjs.md)** | Next.js 13+ App Router |
|
|
20
|
+
| **[vanilla.md](./vanilla.md)** | Plain HTML / vanilla JS + bundler |
|
|
21
|
+
| **[publishing.md](./publishing.md)** | Maintainers — npm publish, `prepack`, release checklist |
|
|
22
|
+
|
|
23
|
+
External reference (newer Angular, signals): [weg-angular-demo](https://github.com/jobsac/weg-angular-demo).
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Package entry points
|
|
28
|
+
|
|
29
|
+
Published subpaths (see [`package.json` `exports`](../package.json)):
|
|
30
|
+
|
|
31
|
+
| Import | Purpose |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `weg-shared-layout/loader` | **`defineCustomElements()`** — register all tags (recommended) |
|
|
34
|
+
| `weg-shared-layout/dummy-data.json` | Sample layout JSON + `typeof` for app types |
|
|
35
|
+
| `weg-shared-layout/layout-data` | Types only (`LayoutData`, etc.) — no Stencil runtime `.d.ts` |
|
|
36
|
+
| `weg-shared-layout/weg-header` | Single-tag side-effect import (needs modern `moduleResolution`) |
|
|
37
|
+
| `weg-shared-layout/weg-footer` | Single-tag side-effect import |
|
|
38
|
+
|
|
39
|
+
TypeScript apps should set **`resolveJsonModule": true`** and **`moduleResolution": "bundler"`** (or `"node16"` / `"nodenext"`). Classic **`"node"`** often fails to resolve these subpaths. See **[angular-16-compatibility.md](./angular-16-compatibility.md)**.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Maintainer scripts
|
|
44
|
+
|
|
45
|
+
From repo root:
|
|
46
|
+
|
|
47
|
+
| Script | Action |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `npm run build` | Stencil build → `dist/`, `loader/` |
|
|
50
|
+
| `npm run demo:angular16` | Build library + `ng serve` in `demo/angular16` |
|
|
51
|
+
| `npm run demo:angular16:build` | Build library + production build of demo |
|
|
@@ -6,6 +6,7 @@ Guide for teams on **Angular 16** who see TypeScript errors from `weg-shared-lay
|
|
|
6
6
|
| --- | --- |
|
|
7
7
|
| **[angular-integration-guide.md](./angular-integration-guide.md)** | Full integration steps |
|
|
8
8
|
| **[angular.md](./angular.md)** | Quick start |
|
|
9
|
+
| **[demo/angular16/README.md](../demo/angular16/README.md)** | Copy-paste Angular 16 app (npm-style imports) |
|
|
9
10
|
| **This doc** | `stencil-public-runtime.d.ts` / `Mixin<const …>` errors, subpath import resolution, layout typing on TS 4.9 |
|
|
10
11
|
|
|
11
12
|
---
|
|
@@ -174,27 +175,33 @@ Example local interfaces (equivalent to package shapes; adjust if your API diffe
|
|
|
174
175
|
```ts
|
|
175
176
|
export interface LayoutLink {
|
|
176
177
|
label: string;
|
|
177
|
-
href
|
|
178
|
+
href?: string;
|
|
179
|
+
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
180
|
+
items?: LayoutLink[];
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
export interface LayoutHeaderData {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
links?: LayoutLink[];
|
|
184
|
-
signIn?: LayoutLink;
|
|
185
|
-
signOut?: { label: string; href?: string };
|
|
184
|
+
logoSrc?: string;
|
|
185
|
+
menu?: LayoutLink[];
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
export type LayoutHeaderAuthAction = 'sign-in' | 'sign-out';
|
|
189
189
|
|
|
190
|
+
export interface LayoutFooterSocialLink {
|
|
191
|
+
platform: 'LinkedIn' | 'Instagram' | 'TikTok' | 'YouTube';
|
|
192
|
+
href: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface LayoutFooterData {
|
|
196
|
+
menu?: LayoutLink[][];
|
|
197
|
+
social?: LayoutFooterSocialLink[];
|
|
198
|
+
credits?: string;
|
|
199
|
+
copyright?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
190
202
|
export interface LayoutData {
|
|
191
203
|
header?: Partial<LayoutHeaderData>;
|
|
192
|
-
footer?: Partial<
|
|
193
|
-
social: unknown;
|
|
194
|
-
columns: unknown;
|
|
195
|
-
credits: unknown;
|
|
196
|
-
copyright: unknown;
|
|
197
|
-
}>;
|
|
204
|
+
footer?: Partial<LayoutFooterData>;
|
|
198
205
|
}
|
|
199
206
|
```
|
|
200
207
|
|
|
@@ -228,8 +235,16 @@ Pair with **`defineCustomElements()`** in `main.ts` and **`CUSTOM_ELEMENTS_SCHEM
|
|
|
228
235
|
|
|
229
236
|
---
|
|
230
237
|
|
|
238
|
+
## In-repo Angular 16 demo
|
|
239
|
+
|
|
240
|
+
Runnable app: **[demo/angular16/README.md](../demo/angular16/README.md)** — same imports as a published npm install (`weg-shared-layout/dummy-data.json`, `weg-shared-layout/loader`); only the `package.json` dependency line differs (`file:../..` vs `^0.0.x`). Run with `npm run demo:angular16` from repo root.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
231
244
|
## Related
|
|
232
245
|
|
|
246
|
+
- [Documentation index](./README.md)
|
|
233
247
|
- [Angular integration guide](./angular-integration-guide.md)
|
|
234
248
|
- [Angular quick start](./angular.md)
|
|
249
|
+
- [In-repo Angular 16 demo](../demo/angular16/README.md)
|
|
235
250
|
- [Publishing](./publishing.md)
|
|
@@ -7,7 +7,8 @@ Step-by-step guide for **Angular 16+** (standalone or NgModule). Covers static f
|
|
|
7
7
|
| **This guide** | First integration, production setup, API mapping, testing, SSR |
|
|
8
8
|
| **[angular.md](./angular.md)** | Short copy-paste quick start (same steps, fewer words) |
|
|
9
9
|
| **[angular-16-compatibility.md](./angular-16-compatibility.md)** | TS 4.9 / `stencil-public-runtime` errors, subpath import / `moduleResolution` |
|
|
10
|
-
| **[
|
|
10
|
+
| **[demo/angular16/README.md](../demo/angular16/README.md)** | In-repo Angular 16 app — **same imports as npm install** (copy-paste guide) |
|
|
11
|
+
| **[weg-angular-demo](https://github.com/jobsac/weg-angular-demo)** | Runnable reference app (newer Angular) |
|
|
11
12
|
|
|
12
13
|
---
|
|
13
14
|
|
|
@@ -35,7 +36,7 @@ Copy this list while integrating:
|
|
|
35
36
|
|
|
36
37
|
- [ ] **Step 1** — `npm i weg-shared-layout`
|
|
37
38
|
- [ ] **Step 2** — `defineCustomElements()` in `main.ts` **before** bootstrap
|
|
38
|
-
- [ ] **Step 3** — `resolveJsonModule`
|
|
39
|
+
- [ ] **Step 3** — TypeScript: `resolveJsonModule`, `skipLibCheck`, `moduleResolution` (`bundler` or `node16`) — see [Step 3](#step-3--typescript-import-layout-json)
|
|
39
40
|
- [ ] **Step 4** — `src/app/auth.ts` with sign-in URL constants (host app, not from package)
|
|
40
41
|
- [ ] **Step 5** — `CUSTOM_ELEMENTS_SCHEMA` on the shell `@Component` (or `@NgModule`) that owns `<weg-header>` / `<weg-footer>`
|
|
41
42
|
- [ ] **Step 6** — Shell template with **`[layout]`** property binding (not `layout="..."`)
|
|
@@ -74,6 +75,9 @@ The components do not depend on signals, RxJS, or standalone vs NgModule — onl
|
|
|
74
75
|
| **Property binding** | `[layout]="obj"` — not `layout="{{ obj }}"` |
|
|
75
76
|
| **`CUSTOM_ELEMENTS_SCHEMA`** | On every component template that uses the tags; **does not** cascade to routed children |
|
|
76
77
|
| **One-time registration** | `defineCustomElements()` once per browser load (recommended) |
|
|
78
|
+
| **TypeScript 5.0+** (Angular 16.1+) | Recommended for JSON/subpath imports; use `skipLibCheck` if staying on 4.9 — [angular-16-compatibility](./angular-16-compatibility.md) |
|
|
79
|
+
|
|
80
|
+
**Runnable Angular 16 example (same imports as npm):** [demo/angular16/README.md](../demo/angular16/README.md).
|
|
77
81
|
|
|
78
82
|
---
|
|
79
83
|
|
|
@@ -117,20 +121,33 @@ import 'weg-shared-layout/weg-footer';
|
|
|
117
121
|
|
|
118
122
|
If header/footer are empty but tags appear in the DOM, registration did not run or ran too late.
|
|
119
123
|
|
|
124
|
+
Side-effect imports need **`moduleResolution": "bundler"`** (or `"node16"`). If you cannot change that, use the **loader only** — see [angular-16-compatibility.md](./angular-16-compatibility.md).
|
|
125
|
+
|
|
120
126
|
---
|
|
121
127
|
|
|
122
128
|
### Step 3 — TypeScript: import layout JSON
|
|
123
129
|
|
|
124
|
-
In
|
|
130
|
+
In **`tsconfig.json`** and/or **`tsconfig.app.json`** (Angular 16 + TypeScript 5.1 example — matches [demo/angular16](../demo/angular16/README.md)):
|
|
125
131
|
|
|
126
132
|
```json
|
|
127
133
|
{
|
|
128
134
|
"compilerOptions": {
|
|
129
|
-
"
|
|
130
|
-
|
|
135
|
+
"skipLibCheck": true,
|
|
136
|
+
"resolveJsonModule": true,
|
|
137
|
+
"moduleResolution": "bundler"
|
|
138
|
+
},
|
|
139
|
+
"include": ["src/**/*.ts"]
|
|
131
140
|
}
|
|
132
141
|
```
|
|
133
142
|
|
|
143
|
+
| Option | Why |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `skipLibCheck` | Skips Stencil `stencil-public-runtime.d.ts` (TS 5 syntax) when on TS 4.9 |
|
|
146
|
+
| `resolveJsonModule` | Allows `import … from 'weg-shared-layout/dummy-data.json'` |
|
|
147
|
+
| `moduleResolution: "bundler"` | Resolves package `exports` (`loader`, `dummy-data.json`) |
|
|
148
|
+
|
|
149
|
+
Use **`node16`** instead of **`bundler`** if required by your toolchain. Classic **`node`** does not resolve subpaths reliably.
|
|
150
|
+
|
|
134
151
|
Create a shared layout type in `src/app/layout.types.ts`:
|
|
135
152
|
|
|
136
153
|
```ts
|
|
@@ -149,6 +166,14 @@ import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
|
149
166
|
|
|
150
167
|
Production: same shape from your API (e.g. [`GET /api/layout`](https://weg-payload-test.vercel.app/api/layout)).
|
|
151
168
|
|
|
169
|
+
Types without JSON import:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import type { LayoutData } from 'weg-shared-layout/layout-data';
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
(requires `./layout-data` in package `exports` — see published version.)
|
|
176
|
+
|
|
152
177
|
---
|
|
153
178
|
|
|
154
179
|
### Step 4 — Auth URLs in your app (not from the package)
|
|
@@ -732,7 +757,7 @@ Bind the result the same way as Step 7.
|
|
|
732
757
|
| HTTP layout | `layout$` + `\| async` | `layout = toSignal(loadLayout())` |
|
|
733
758
|
| Update signed in | `this.signedIn = true` | `this.signedIn.set(true)` |
|
|
734
759
|
|
|
735
|
-
Full code for both variants: **Step 6** and **Step 7** above, and [angular.md §
|
|
760
|
+
Full code for both variants: **Step 6** and **Step 7** above, and [angular.md §6](./angular.md#6-layout-shell--pick-one).
|
|
736
761
|
|
|
737
762
|
---
|
|
738
763
|
|
|
@@ -976,7 +1001,7 @@ $0.userName
|
|
|
976
1001
|
| File | Role |
|
|
977
1002
|
| --- | --- |
|
|
978
1003
|
| `src/main.ts` | `defineCustomElements()` then bootstrap |
|
|
979
|
-
| `tsconfig.app.json` | `resolveJsonModule:
|
|
1004
|
+
| `tsconfig.json` / `tsconfig.app.json` | `skipLibCheck`, `resolveJsonModule`, `moduleResolution: bundler` (or `node16`) |
|
|
980
1005
|
| `src/app/auth.ts` | `HEADER_SIGN_IN`, `ACCOUNT_LOGIN_HREF` |
|
|
981
1006
|
| `src/app/layout.types.ts` | `export type LayoutData = typeof layoutFixture` |
|
|
982
1007
|
| `src/app/layout.service.ts` | HTTP / API mapping (Step 7, optional arrays) |
|
|
@@ -1000,9 +1025,11 @@ $0.userName
|
|
|
1000
1025
|
|
|
1001
1026
|
### Related docs
|
|
1002
1027
|
|
|
1028
|
+
- [Documentation index](./README.md)
|
|
1003
1029
|
- [Angular 16 / TypeScript 4.9 compatibility](./angular-16-compatibility.md)
|
|
1030
|
+
- [In-repo Angular 16 demo](../demo/angular16/README.md)
|
|
1004
1031
|
- [Quick start (angular.md)](./angular.md)
|
|
1005
1032
|
- [Package readme](../readme.md)
|
|
1006
1033
|
- [Plain HTML / vanilla JS](./vanilla.md)
|
|
1007
1034
|
- [React SPA](./react.md)
|
|
1008
|
-
- [
|
|
1035
|
+
- [External reference app (newer Angular)](https://github.com/jobsac/weg-angular-demo)
|
package/docs/angular.md
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Short quick start for Angular 16+. For the full **step-by-step** guide (HTTP, API mapping, testing, SSR, troubleshooting), see **[angular-integration-guide.md](./angular-integration-guide.md)**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| Demo | When |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| **[demo/angular16/README.md](../demo/angular16/README.md)** | Angular **16** — same imports as `npm i` (in-repo: `file:../..`) |
|
|
8
|
+
| [weg-angular-demo](https://github.com/jobsac/weg-angular-demo) | Newer Angular (signals) |
|
|
6
9
|
|
|
7
10
|
## Integration checklist
|
|
8
11
|
|
|
9
12
|
- [ ] `npm i weg-shared-layout`
|
|
10
13
|
- [ ] `defineCustomElements()` in `main.ts` **before** bootstrap
|
|
11
|
-
- [ ] `resolveJsonModule`
|
|
14
|
+
- [ ] `skipLibCheck`, `resolveJsonModule`, `moduleResolution: "bundler"` (or `node16`) — see [Step 3 in integration guide](./angular-integration-guide.md#step-3--typescript-import-layout-json)
|
|
12
15
|
- [ ] `auth.ts` with `HEADER_SIGN_IN` / `ACCOUNT_LOGIN_HREF` (host app constants)
|
|
13
16
|
- [ ] `CUSTOM_ELEMENTS_SCHEMA` on the shell component that uses the tags
|
|
14
17
|
- [ ] `[layout]="layoutObject"` on `<weg-header>` and `<weg-footer>`
|
|
@@ -45,18 +48,41 @@ defineCustomElements();
|
|
|
45
48
|
bootstrapApplication(App, appConfig).catch((err) => console.error(err));
|
|
46
49
|
```
|
|
47
50
|
|
|
48
|
-
**Alternative** — side-effect imports (one of these approaches, not both):
|
|
51
|
+
**Alternative** — side-effect imports (one of these approaches, not both; needs `moduleResolution` `bundler` / `node16`):
|
|
49
52
|
|
|
50
53
|
```ts
|
|
51
54
|
import 'weg-shared-layout/weg-header';
|
|
52
55
|
import 'weg-shared-layout/weg-footer';
|
|
53
56
|
```
|
|
54
57
|
|
|
55
|
-
## 3.
|
|
58
|
+
## 3. Layout types + TypeScript
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// src/app/layout.types.ts
|
|
62
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
63
|
+
|
|
64
|
+
export type LayoutData = typeof layoutFixture;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
// tsconfig.json (or tsconfig.app.json) — required for JSON + package subpaths
|
|
69
|
+
{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
"skipLibCheck": true,
|
|
72
|
+
"resolveJsonModule": true,
|
|
73
|
+
"moduleResolution": "bundler"
|
|
74
|
+
},
|
|
75
|
+
"include": ["src/**/*.ts"]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Angular 16 pitfalls (Stencil `.d.ts`, classic `node` resolution): **[angular-16-compatibility.md](./angular-16-compatibility.md)**.
|
|
80
|
+
|
|
81
|
+
## 4. Allow custom elements in templates
|
|
56
82
|
|
|
57
83
|
Add `schemas: [CUSTOM_ELEMENTS_SCHEMA]` to every `@Component` (or `@NgModule`) whose template uses `<weg-header>` or `<weg-footer>`. Does **not** cascade to `router-outlet` children.
|
|
58
84
|
|
|
59
|
-
##
|
|
85
|
+
## 5. Auth constants
|
|
60
86
|
|
|
61
87
|
```ts
|
|
62
88
|
// src/app/auth.ts
|
|
@@ -68,18 +94,18 @@ export const HEADER_SIGN_IN = {
|
|
|
68
94
|
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
69
95
|
```
|
|
70
96
|
|
|
71
|
-
##
|
|
97
|
+
## 6. Layout shell — pick one
|
|
72
98
|
|
|
73
99
|
Use **`[layout]="..."`** so Angular sets the JavaScript `layout` property, not an HTML attribute.
|
|
74
100
|
|
|
75
101
|
| Variant | Angular | Template bindings |
|
|
76
102
|
| --- | --- | --- |
|
|
77
|
-
| **
|
|
78
|
-
| **
|
|
103
|
+
| **6A** Plain properties | 16+ | `[layout]="layoutData"` |
|
|
104
|
+
| **6B** Signals | 16.1+ | `[layout]="layoutData()"` |
|
|
79
105
|
|
|
80
106
|
Full HTTP examples: integration guide **[Step 7A / 7B](./angular-integration-guide.md#step-7--load-layout-from-your-api)**.
|
|
81
107
|
|
|
82
|
-
###
|
|
108
|
+
### 6A — Plain properties (Angular 16+)
|
|
83
109
|
|
|
84
110
|
```ts
|
|
85
111
|
// src/app/app.ts
|
|
@@ -130,11 +156,9 @@ export class App {
|
|
|
130
156
|
<weg-footer [layout]="layoutData"></weg-footer>
|
|
131
157
|
```
|
|
132
158
|
|
|
133
|
-
Enable `resolveJsonModule` in `tsconfig.app.json` if you import `dummy-data.json`.
|
|
134
|
-
|
|
135
159
|
In production, load the same shape from your API — see **[Step 7A](./angular-integration-guide.md#step-7a--http-with-rxjs--async-pipe-pairs-with-6a)**. If your API returns separate arrays, see **[mapping section](./angular-integration-guide.md#optional-api-returns-separate-arrays-not-one-layout-object)**.
|
|
136
160
|
|
|
137
|
-
###
|
|
161
|
+
### 6B — Signals (Angular 16.1+)
|
|
138
162
|
|
|
139
163
|
```ts
|
|
140
164
|
// src/app/app.ts
|
|
@@ -191,7 +215,7 @@ HTTP with signals: **[Step 7B](./angular-integration-guide.md#step-7b--http-with
|
|
|
191
215
|
|
|
192
216
|
## Header: `signed-in`, `user-name`, `wegAuthClick`
|
|
193
217
|
|
|
194
|
-
| Input / output | Binding (
|
|
218
|
+
| Input / output | Binding (6A) | Binding (6B) | Notes |
|
|
195
219
|
| --- | --- | --- | --- |
|
|
196
220
|
| CMS nav | `[layout]="layoutData"` | `[layout]="layoutData()"` | `header.menu` — groups (`items`) and flat links (`href`) when signed out |
|
|
197
221
|
| Session state | `[signedIn]="signedIn"` | `[signedIn]="signedIn()"` | `true` → built-in signed-in nav |
|
|
@@ -224,6 +248,8 @@ More detail: **[integration guide § Troubleshooting](./angular-integration-guid
|
|
|
224
248
|
|
|
225
249
|
## See also
|
|
226
250
|
|
|
251
|
+
- **[Documentation index](./README.md)**
|
|
252
|
+
- **[In-repo Angular 16 demo](../demo/angular16/README.md)**
|
|
227
253
|
- **[Angular 16 / TS 4.9 compatibility](./angular-16-compatibility.md)** — `stencil-public-runtime` errors, subpath imports
|
|
228
254
|
- **[Angular integration guide (step-by-step)](./angular-integration-guide.md)**
|
|
229
255
|
- **[React SPA](./react.md)**
|
package/docs/nextjs.md
CHANGED
|
@@ -28,6 +28,7 @@ Both accept **`layout`** (JSON string recommended in Next). `<weg-header>` also
|
|
|
28
28
|
| **Next.js 13+** | App Router (`app/layout.tsx`) |
|
|
29
29
|
| **`transpilePackages`** | Next must compile `weg-shared-layout` |
|
|
30
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 |
|
|
31
32
|
|
|
32
33
|
## Install
|
|
33
34
|
|
|
@@ -77,16 +78,9 @@ import 'weg-shared-layout/weg-header';
|
|
|
77
78
|
|
|
78
79
|
defineCustomElements();
|
|
79
80
|
|
|
80
|
-
type LayoutData
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
menu?: {
|
|
84
|
-
label: string;
|
|
85
|
-
href?: string;
|
|
86
|
-
items?: { label: string; href: string }[];
|
|
87
|
-
}[];
|
|
88
|
-
};
|
|
89
|
-
};
|
|
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;
|
|
90
84
|
|
|
91
85
|
export function Header({
|
|
92
86
|
layout,
|
|
@@ -258,6 +252,19 @@ The logo **image** uses `layout.header.logoSrc` when signed out (bundled if omit
|
|
|
258
252
|
|
|
259
253
|
## TypeScript
|
|
260
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
|
+
|
|
261
268
|
```ts
|
|
262
269
|
// src/types/weg-shared-layout-jsx.d.ts
|
|
263
270
|
import type { JSX as WegSharedLayoutJSX } from 'weg-shared-layout';
|
|
@@ -300,7 +307,8 @@ declare module 'react' {
|
|
|
300
307
|
|
|
301
308
|
## See also
|
|
302
309
|
|
|
310
|
+
- **[Documentation index](./README.md)**
|
|
303
311
|
- **[React SPA](./react.md)**
|
|
304
|
-
- **[Angular](./angular.md)**
|
|
312
|
+
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
305
313
|
- **[Plain HTML / vanilla JS](./vanilla.md)**
|
|
306
314
|
- **[Package readme](../readme.md)**
|
package/docs/publishing.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Publishing packs **whatever is already on disk** under the paths listed in [`package.json` `files`](../package.json) (for this package: `dist/`, `loader/`, and `dummy-data.json`). It does **not** automatically run `npm run build` unless a lifecycle script does.
|
|
6
6
|
|
|
7
|
-
If you publish with an empty, missing, or half-built `dist/`, consumers get a broken tarball (missing `
|
|
7
|
+
If you publish with an empty, missing, or half-built `dist/`, consumers get a broken tarball (missing `loader/index.js`, missing `dist/components/*.js`, missing type declarations, etc.).
|
|
8
8
|
|
|
9
9
|
## What this repo does
|
|
10
10
|
|
|
@@ -33,9 +33,22 @@ So the Stencil output and generated `loader/` are always fresh in the tarball.
|
|
|
33
33
|
npm pack --dry-run
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Inspect the dry-run file list and spot-check for
|
|
36
|
+
Inspect the dry-run file list and spot-check for:
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
- `loader/index.js`, `loader/index.d.ts`
|
|
39
|
+
- `dist/components/weg-header.js`, `dist/components/weg-footer.js`
|
|
40
|
+
- `src/assets/dummy-data.json` (via `exports["./dummy-data.json"]`)
|
|
41
|
+
- `dist/types/types/layout-data.d.ts` (via `exports["./layout-data"]`)
|
|
42
|
+
|
|
43
|
+
3. Smoke-test the Angular 16 demo (optional but recommended):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run demo:angular16:build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See [demo/angular16/README.md](../demo/angular16/README.md).
|
|
50
|
+
|
|
51
|
+
4. Publish (runs `prepack` → build again):
|
|
39
52
|
|
|
40
53
|
```bash
|
|
41
54
|
npm publish
|
|
@@ -43,6 +56,10 @@ So the Stencil output and generated `loader/` are always fresh in the tarball.
|
|
|
43
56
|
|
|
44
57
|
Use `npm publish --dry-run` if you want to exercise the full pack pipeline without uploading.
|
|
45
58
|
|
|
59
|
+
## What consumers import
|
|
60
|
+
|
|
61
|
+
Documented in [docs/README.md](./README.md): `loader`, `dummy-data.json`, `layout-data` (types), and per-tag subpaths. Angular 16 apps need modern `moduleResolution` or the loader-only pattern — [angular-16-compatibility.md](./angular-16-compatibility.md).
|
|
62
|
+
|
|
46
63
|
## CI
|
|
47
64
|
|
|
48
65
|
If you publish from CI, run **`npm run build`** (or rely on **`npm publish`**, which triggers **`prepack`**) in the same job before `npm publish`, and ensure **devDependencies** (e.g. `@stencil/core`) are installed so `stencil build` succeeds.
|
package/docs/react.md
CHANGED
|
@@ -19,7 +19,7 @@ Both are **presentational** [Stencil](https://stenciljs.com/) Web Components. Th
|
|
|
19
19
|
| --- | --- |
|
|
20
20
|
| **React 19+** | React 19 maps custom-element props to DOM **properties** when possible. Older React often sets props as string **attributes**, which breaks object payloads. |
|
|
21
21
|
| **Bundler** | Must resolve `node_modules` ESM/CJS from `weg-shared-layout`. |
|
|
22
|
-
| **TypeScript (optional)** |
|
|
22
|
+
| **TypeScript (optional)** | `resolveJsonModule` + `moduleResolution` `bundler` / `node16` for JSON/subpath imports; module augmentation below. |
|
|
23
23
|
|
|
24
24
|
## Install
|
|
25
25
|
|
|
@@ -39,7 +39,7 @@ import { defineCustomElements } from 'weg-shared-layout/loader';
|
|
|
39
39
|
defineCustomElements();
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
**Alternative** — side-effect imports per tag (requires modern `moduleResolution`; see [angular-16-compatibility](./angular-16-compatibility.md#error-2-cannot-find-module-weg-shared-layoutweg-header)):
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
45
|
import 'weg-shared-layout/weg-header';
|
|
@@ -89,17 +89,7 @@ export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
|
89
89
|
|
|
90
90
|
### Signed out
|
|
91
91
|
|
|
92
|
-
Pass CMS/API layout with unified
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
// auth.ts (host app)
|
|
96
|
-
export const HEADER_SIGN_IN = {
|
|
97
|
-
label: 'Sign in',
|
|
98
|
-
href: 'https://account.warwickemploymentgroup.com/account/login',
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const ACCOUNT_LOGIN_HREF = HEADER_SIGN_IN.href;
|
|
102
|
-
```
|
|
92
|
+
Pass CMS/API layout with unified **`header.menu`**. Use [`dummy-data.json`](../src/assets/dummy-data.json) for the full shape — nav groups use `items`, flat links and Sign in use `href`.
|
|
103
93
|
|
|
104
94
|
### Signed in
|
|
105
95
|
|
|
@@ -213,7 +203,27 @@ export function SiteLayout({ children }: { children: React.ReactNode }) {
|
|
|
213
203
|
|
|
214
204
|
Replace the URL with your CMS/API. Keep the object shape aligned with `dummy-data.json`.
|
|
215
205
|
|
|
216
|
-
## TypeScript
|
|
206
|
+
## TypeScript
|
|
207
|
+
|
|
208
|
+
### JSON + package subpaths
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"compilerOptions": {
|
|
213
|
+
"resolveJsonModule": true,
|
|
214
|
+
"moduleResolution": "bundler"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import layoutFixture from 'weg-shared-layout/dummy-data.json';
|
|
221
|
+
export type LayoutData = typeof layoutFixture;
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Or types only: `import type { LayoutData } from 'weg-shared-layout/layout-data'`.
|
|
225
|
+
|
|
226
|
+
### JSX module augmentation
|
|
217
227
|
|
|
218
228
|
Add once (e.g. `src/types/weg-shared-layout-jsx.d.ts`):
|
|
219
229
|
|
|
@@ -255,7 +265,8 @@ declare module 'react' {
|
|
|
255
265
|
|
|
256
266
|
## See also
|
|
257
267
|
|
|
268
|
+
- **[Documentation index](./README.md)**
|
|
258
269
|
- **[Next.js App Router](./nextjs.md)**
|
|
259
|
-
- **[Angular](./angular.md)**
|
|
270
|
+
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
260
271
|
- **[Plain HTML / vanilla JS](./vanilla.md)**
|
|
261
272
|
- **[Package readme](../readme.md)**
|
package/docs/vanilla.md
CHANGED
|
@@ -13,7 +13,7 @@ Payload shape: [`dummy-data.json`](../src/assets/dummy-data.json) (see [readme](
|
|
|
13
13
|
|
|
14
14
|
## Install & register
|
|
15
15
|
|
|
16
|
-
With a bundler that resolves `node_modules`
|
|
16
|
+
With a bundler that resolves `node_modules` and package **`exports`** (TypeScript: `resolveJsonModule` + `moduleResolution` `bundler` or `node16` — see [angular-16-compatibility](./angular-16-compatibility.md)):
|
|
17
17
|
|
|
18
18
|
```html
|
|
19
19
|
<weg-header id="header"></weg-header>
|
|
@@ -132,7 +132,8 @@ document.getElementById('footer').layout = layout;
|
|
|
132
132
|
|
|
133
133
|
## See also
|
|
134
134
|
|
|
135
|
+
- **[Documentation index](./README.md)**
|
|
135
136
|
- **[React SPA](./react.md)**
|
|
136
137
|
- **[Next.js App Router](./nextjs.md)**
|
|
137
|
-
- **[Angular](./angular.md)**
|
|
138
|
+
- **[Angular](./angular.md)** · **[Angular 16 demo](../demo/angular16/README.md)**
|
|
138
139
|
- **[Package readme](../readme.md)**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weg-shared-layout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "Shared layout Web Components built with Stencil",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -53,7 +53,10 @@
|
|
|
53
53
|
"start": "stencil build --dev --watch --serve",
|
|
54
54
|
"test": "stencil-test --prod",
|
|
55
55
|
"test:watch": "stencil-test --prod --watch",
|
|
56
|
-
"generate": "stencil generate"
|
|
56
|
+
"generate": "stencil generate",
|
|
57
|
+
"demo:angular16:install": "npm install --prefix demo/angular16",
|
|
58
|
+
"demo:angular16:build": "npm run build && npm run build --prefix demo/angular16",
|
|
59
|
+
"demo:angular16": "npm run build && npm run start --prefix demo/angular16"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
62
|
"@csstools/postcss-global-data": "^4.0.0",
|
package/readme.md
CHANGED
|
@@ -62,19 +62,32 @@ header.addEventListener('wegAuthClick', (event) => {
|
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
- **From npm:** `import layout from 'weg-shared-layout/dummy-data.json'`
|
|
65
|
+
- **From npm:** `import layout from 'weg-shared-layout/dummy-data.json'` — in TypeScript set `resolveJsonModule` and `moduleResolution` to `bundler` or `node16` (see [docs/angular-16-compatibility.md](./docs/angular-16-compatibility.md)).
|
|
66
66
|
- **In this repo:** [`src/assets/dummy-data.json`](src/assets/dummy-data.json)
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
### Package imports (TypeScript / bundlers)
|
|
69
|
+
|
|
70
|
+
| Subpath | Use |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `weg-shared-layout/loader` | `defineCustomElements()` — **recommended** |
|
|
73
|
+
| `weg-shared-layout/dummy-data.json` | Sample layout + `typeof` for app types |
|
|
74
|
+
| `weg-shared-layout/layout-data` | Types only (`LayoutData`, …) |
|
|
75
|
+
| `weg-shared-layout/weg-header` / `weg-footer` | Side-effect tag registration |
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
Full index: **[docs/README.md](./docs/README.md)**.
|
|
69
80
|
|
|
70
81
|
| Guide | Doc |
|
|
71
82
|
| --- | --- |
|
|
72
83
|
| Angular (quick start) | [docs/angular.md](./docs/angular.md) |
|
|
73
84
|
| Angular (step-by-step integration) | [docs/angular-integration-guide.md](./docs/angular-integration-guide.md) |
|
|
74
85
|
| Angular 16 / TypeScript 4.9 | [docs/angular-16-compatibility.md](./docs/angular-16-compatibility.md) |
|
|
86
|
+
| Angular 16 demo (in-repo, npm-style imports) | [demo/angular16/README.md](./demo/angular16/README.md) |
|
|
75
87
|
| React (SPA, client-only) | [docs/react.md](./docs/react.md) |
|
|
76
88
|
| Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
|
|
77
89
|
| Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
|
|
90
|
+
| Publishing (maintainers) | [docs/publishing.md](./docs/publishing.md) |
|
|
78
91
|
|
|
79
92
|
## Publishing (maintainers)
|
|
80
93
|
|