weg-shared-layout 0.0.49 → 0.0.51
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/dist/cjs/{index-CC8e1qRm.js → index-Bq6Rv2aB.js} +678 -8
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/weg-footer_2.cjs.entry.js +6 -6
- package/dist/cjs/weg-shared-layout.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/weg-footer/weg-footer.css +4 -0
- package/dist/collection/components/weg-header/weg-header.js +4 -4
- package/dist/components/index.js +1 -1
- package/dist/components/p-Dgj30LnS.js +1 -0
- package/dist/components/weg-footer.js +1 -1
- package/dist/components/weg-header.js +1 -1
- package/dist/esm/{index-D8pmhPiH.js → index-B5Q4zIrC.js} +678 -8
- package/dist/esm/loader.js +2 -2
- package/dist/esm/weg-footer_2.entry.js +6 -6
- package/dist/esm/weg-shared-layout.js +3 -3
- package/dist/types/stencil-public-runtime.d.ts +1 -0
- package/dist/weg-shared-layout/p-5a26415d.entry.js +1 -0
- package/dist/weg-shared-layout/p-B5Q4zIrC.js +2 -0
- package/dist/weg-shared-layout/weg-shared-layout.esm.js +1 -1
- package/docs/README.md +54 -54
- package/docs/angular.md +440 -440
- package/docs/nextjs.md +313 -313
- package/docs/publishing.md +65 -65
- package/docs/react.md +291 -291
- package/docs/vanilla.md +159 -159
- package/hydrate/index.d.ts +287 -0
- package/hydrate/index.js +24735 -0
- package/hydrate/index.mjs +24725 -0
- package/hydrate/package.json +12 -0
- package/package.json +20 -15
- package/readme.md +121 -121
- package/src/types/menus-data.ts +44 -44
- package/src/utils/menus.ts +65 -65
- package/dist/components/p-CtYuWNO6.js +0 -1
- package/dist/weg-shared-layout/p-6737bde4.entry.js +0 -1
- package/dist/weg-shared-layout/p-D8pmhPiH.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weg-shared-layout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"description": "Shared layout Web Components built with Stencil",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
"import": "./loader/index.js",
|
|
28
28
|
"require": "./loader/index.cjs.js"
|
|
29
29
|
},
|
|
30
|
+
"./hydrate": {
|
|
31
|
+
"types": "./hydrate/index.d.ts",
|
|
32
|
+
"import": "./hydrate/index.mjs",
|
|
33
|
+
"require": "./hydrate/index.js"
|
|
34
|
+
},
|
|
30
35
|
"./weg21-bootstrap.json": "./src/assets/weg21-bootstrap.json",
|
|
31
36
|
"./weg21-menus.json": "./src/assets/weg21-menus.json",
|
|
32
37
|
"./layout-data": {
|
|
@@ -52,6 +57,7 @@
|
|
|
52
57
|
"homepage": "https://github.com/jobsac/weg-shared-layout#readme",
|
|
53
58
|
"files": [
|
|
54
59
|
"dist/",
|
|
60
|
+
"hydrate/",
|
|
55
61
|
"docs/",
|
|
56
62
|
"loader/",
|
|
57
63
|
"src/assets/weg21-bootstrap.json",
|
|
@@ -61,21 +67,10 @@
|
|
|
61
67
|
"src/constants/",
|
|
62
68
|
"src/styles/container.css"
|
|
63
69
|
],
|
|
64
|
-
"scripts": {
|
|
65
|
-
"prepack": "pnpm run build",
|
|
66
|
-
"build": "stencil build",
|
|
67
|
-
"start": "stencil build --dev --watch --serve --no-open",
|
|
68
|
-
"test": "stencil-test --prod",
|
|
69
|
-
"test:watch": "stencil-test --prod --watch",
|
|
70
|
-
"generate": "stencil generate",
|
|
71
|
-
"demo:angular16:install": "pnpm install --dir demo/angular16",
|
|
72
|
-
"demo:angular16:build": "pnpm run build && pnpm run build --dir demo/angular16",
|
|
73
|
-
"demo:angular16": "pnpm run build && pnpm run start --dir demo/angular16"
|
|
74
|
-
},
|
|
75
70
|
"devDependencies": {
|
|
76
71
|
"@csstools/postcss-global-data": "~4.0.0",
|
|
77
72
|
"@stencil-community/postcss": "~2.2.0",
|
|
78
|
-
"@stencil/core": "~4.
|
|
73
|
+
"@stencil/core": "~4.43.5",
|
|
79
74
|
"@stencil/vitest": "~1.8.3",
|
|
80
75
|
"@types/node": "~22.13.5",
|
|
81
76
|
"@vitest/browser-playwright": "~4.0.0",
|
|
@@ -89,5 +84,15 @@
|
|
|
89
84
|
"contributors": [
|
|
90
85
|
"Tan Ahmed <tan.ahmed@warwick.ac.uk>",
|
|
91
86
|
"Rakin Ahmed <rakin.ahmed@warwick.ac.uk>"
|
|
92
|
-
]
|
|
93
|
-
|
|
87
|
+
],
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "stencil build",
|
|
90
|
+
"start": "stencil build --dev --watch --serve --no-open",
|
|
91
|
+
"test": "stencil-test --prod",
|
|
92
|
+
"test:watch": "stencil-test --prod --watch",
|
|
93
|
+
"generate": "stencil generate",
|
|
94
|
+
"demo:angular16:install": "pnpm --dir demo/angular16 install",
|
|
95
|
+
"demo:angular16:build": "pnpm --dir demo/angular16 run build",
|
|
96
|
+
"demo:angular16": "pnpm --dir demo/angular16 run start"
|
|
97
|
+
}
|
|
98
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
# weg-shared-layout
|
|
2
|
-
|
|
3
|
-
> Shared layout Web Components.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i weg-shared-layout
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## How it works
|
|
12
|
-
|
|
13
|
-
`<weg-header>` and `<weg-footer>` are **presentational** Web Components: they do **not** fetch data.
|
|
14
|
-
|
|
15
|
-
Load layout from the **WEG CMS WEG21 API**, then pass the mapped object to `layout` on each tag:
|
|
16
|
-
|
|
17
|
-
| Endpoint | Purpose |
|
|
18
|
-
| --- | --- |
|
|
19
|
-
| `GET https://warwickemploymentgroup.com/api/v1/weg21` | Logo URLs, footer social + legal copy |
|
|
20
|
-
| `GET …/api/v1/weg21/menus` | Header (`ext` / `int`) and footer link columns |
|
|
21
|
-
|
|
22
|
-
Both require the `wcms-api-key` header. Use `fetchWeg21Layout` from `weg-shared-layout/menus`:
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import { fetchWeg21Layout } from 'weg-shared-layout/menus';
|
|
26
|
-
|
|
27
|
-
const layout = await fetchWeg21Layout({
|
|
28
|
-
apiKey: process.env.WCMS_API_KEY,
|
|
29
|
-
});
|
|
30
|
-
// layout.header.menu, layout.footer.menu, layout.footer.social, …
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
[`weg21-bootstrap.json`](src/assets/weg21-bootstrap.json) and [`weg21-menus.json`](src/assets/weg21-menus.json) mirror the **WEG21 API response schemas** (`GET /api/v1/weg21` and `/menus`). Map to `layout` with `dummyWeg21LayoutData()` or `menusToLayoutData`.
|
|
34
|
-
|
|
35
|
-
### Layout shape (abbreviated)
|
|
36
|
-
|
|
37
|
-
```json
|
|
38
|
-
{
|
|
39
|
-
"header": {
|
|
40
|
-
"menu": [
|
|
41
|
-
{ "label": "Find a job", "items": [{ "label": "Graduates", "href": "…" }] },
|
|
42
|
-
{ "label": "Sign in", "href": "…" }
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
"footer": {
|
|
46
|
-
"menu": [[{ "label": "About WEG", "href": "…" }]],
|
|
47
|
-
"social": [{ "platform": "LinkedIn", "href": "…" }],
|
|
48
|
-
"credits": "…",
|
|
49
|
-
"copyright": "…"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
| Field | Used when | Notes |
|
|
55
|
-
| --- | --- | --- |
|
|
56
|
-
| `header.logoSrc` | Signed out | Optional CMS logo URL; bundled PNG if omitted |
|
|
57
|
-
| `header.logoHref` | Always | Optional logo link URL; WEG homepage if omitted |
|
|
58
|
-
| `header.menu` | Signed out | Groups use `items`; flat links use `href` |
|
|
59
|
-
| `footer.menu` | Always | `LayoutLink[][]` — one column per inner array |
|
|
60
|
-
| `footer.social` | Always | LinkedIn, Instagram, TikTok, or YouTube |
|
|
61
|
-
| `footer.credits` / `footer.copyright` | Always | Legal copy |
|
|
62
|
-
|
|
63
|
-
### Auth (Sign in / Sign out)
|
|
64
|
-
|
|
65
|
-
**Signed out**: renders `header.menu`. Sign-in is a normal link — add `{ "label": "Sign in", "href": "…" }` like Register or Career advice. The header recognizes it by label or login URL and follows `href` on click.
|
|
66
|
-
|
|
67
|
-
**Signed in** (`signed-in` true): ignores CMS `header.menu` and shows built-in Find a job, Dashboard, Manage Account, and Sign out.
|
|
68
|
-
|
|
69
|
-
Set **`signed-in`** from your app session state. Pass **`user-name`** for Manage Account. Pass **`account-base-url`** when account links should point at a non-production portal. Pass **`current-path`** (e.g. `/career-advice/my-article`) to highlight the active nav item. **Sign out** emits **`wegAuthClick`** — the host must call `event.preventDefault()` and run your logout flow (API call, clear session, redirect).
|
|
70
|
-
|
|
71
|
-
### Nav active state
|
|
72
|
-
|
|
73
|
-
| Link type | Match rule |
|
|
74
|
-
| --- | --- |
|
|
75
|
-
| Flat nav link | Prefix — `/career-advice` matches `/career-advice/foo` |
|
|
76
|
-
| Dropdown child | Exact pathname (+ query when href includes `?`) |
|
|
77
|
-
| Dropdown parent | Active background when any child matches |
|
|
78
|
-
| Sign in / Sign out | Never highlighted |
|
|
79
|
-
|
|
80
|
-
Active links use **`weg-purple-200`** (`#CDCFF8`). Omit `current-path` to disable active styling.
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
header.addEventListener('wegAuthClick', async (event) => {
|
|
84
|
-
if (event.detail.action !== 'sign-out') return;
|
|
85
|
-
event.preventDefault();
|
|
86
|
-
await logout();
|
|
87
|
-
window.location.assign('/');
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Package imports (TypeScript / bundlers)
|
|
92
|
-
|
|
93
|
-
| Subpath | Use |
|
|
94
|
-
| --- | --- |
|
|
95
|
-
| `weg-shared-layout/loader` | `defineCustomElements()` — **recommended** |
|
|
96
|
-
| `weg-shared-layout/menus` | `fetchWeg21Layout`, `menusToLayoutData` |
|
|
97
|
-
| `weg-shared-layout/menus-data` | WEG21 API types (`MenusData`, …) |
|
|
98
|
-
| `weg-shared-layout/layout-data` | `<weg-header>` / `<weg-footer>` types (`LayoutData`, …) |
|
|
99
|
-
| `weg-shared-layout/weg21-bootstrap.json` | `GET /api/v1/weg21` schema sample |
|
|
100
|
-
| `weg-shared-layout/weg21-menus.json` | `GET /api/v1/weg21/menus` schema sample |
|
|
101
|
-
| `weg-shared-layout/weg-header` / `weg-footer` | Side-effect tag registration |
|
|
102
|
-
| `weg-shared-layout/styles/container.css` | Shared `.container` width and gutter utility |
|
|
103
|
-
|
|
104
|
-
## Documentation
|
|
105
|
-
|
|
106
|
-
Full index: **[docs/README.md](./docs/README.md)**.
|
|
107
|
-
|
|
108
|
-
| Guide | Doc |
|
|
109
|
-
| --- | --- |
|
|
110
|
-
| Angular 16 | [docs/angular.md](./docs/angular.md) |
|
|
111
|
-
| Angular 16 demo (runnable) | [demo/angular16/README.md](./demo/angular16/README.md) |
|
|
112
|
-
| React (SPA, client-only) | [docs/react.md](./docs/react.md) |
|
|
113
|
-
| Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
|
|
114
|
-
| Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
|
|
115
|
-
| Publishing (maintainers) | [docs/publishing.md](./docs/publishing.md) |
|
|
116
|
-
|
|
117
|
-
## Publishing (maintainers)
|
|
118
|
-
|
|
119
|
-
**`npm publish` does not run `npm run build` by itself** — it packs what is on disk. This package uses a **`prepack`** script so a full Stencil build runs before every `npm pack` / `npm publish`, avoiding incomplete tarballs.
|
|
120
|
-
|
|
121
|
-
Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.
|
|
1
|
+
# weg-shared-layout
|
|
2
|
+
|
|
3
|
+
> Shared layout Web Components.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i weg-shared-layout
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
`<weg-header>` and `<weg-footer>` are **presentational** Web Components: they do **not** fetch data.
|
|
14
|
+
|
|
15
|
+
Load layout from the **WEG CMS WEG21 API**, then pass the mapped object to `layout` on each tag:
|
|
16
|
+
|
|
17
|
+
| Endpoint | Purpose |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `GET https://warwickemploymentgroup.com/api/v1/weg21` | Logo URLs, footer social + legal copy |
|
|
20
|
+
| `GET …/api/v1/weg21/menus` | Header (`ext` / `int`) and footer link columns |
|
|
21
|
+
|
|
22
|
+
Both require the `wcms-api-key` header. Use `fetchWeg21Layout` from `weg-shared-layout/menus`:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { fetchWeg21Layout } from 'weg-shared-layout/menus';
|
|
26
|
+
|
|
27
|
+
const layout = await fetchWeg21Layout({
|
|
28
|
+
apiKey: process.env.WCMS_API_KEY,
|
|
29
|
+
});
|
|
30
|
+
// layout.header.menu, layout.footer.menu, layout.footer.social, …
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
[`weg21-bootstrap.json`](src/assets/weg21-bootstrap.json) and [`weg21-menus.json`](src/assets/weg21-menus.json) mirror the **WEG21 API response schemas** (`GET /api/v1/weg21` and `/menus`). Map to `layout` with `dummyWeg21LayoutData()` or `menusToLayoutData`.
|
|
34
|
+
|
|
35
|
+
### Layout shape (abbreviated)
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"header": {
|
|
40
|
+
"menu": [
|
|
41
|
+
{ "label": "Find a job", "items": [{ "label": "Graduates", "href": "…" }] },
|
|
42
|
+
{ "label": "Sign in", "href": "…" }
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"footer": {
|
|
46
|
+
"menu": [[{ "label": "About WEG", "href": "…" }]],
|
|
47
|
+
"social": [{ "platform": "LinkedIn", "href": "…" }],
|
|
48
|
+
"credits": "…",
|
|
49
|
+
"copyright": "…"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Field | Used when | Notes |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `header.logoSrc` | Signed out | Optional CMS logo URL; bundled PNG if omitted |
|
|
57
|
+
| `header.logoHref` | Always | Optional logo link URL; WEG homepage if omitted |
|
|
58
|
+
| `header.menu` | Signed out | Groups use `items`; flat links use `href` |
|
|
59
|
+
| `footer.menu` | Always | `LayoutLink[][]` — one column per inner array |
|
|
60
|
+
| `footer.social` | Always | LinkedIn, Instagram, TikTok, or YouTube |
|
|
61
|
+
| `footer.credits` / `footer.copyright` | Always | Legal copy |
|
|
62
|
+
|
|
63
|
+
### Auth (Sign in / Sign out)
|
|
64
|
+
|
|
65
|
+
**Signed out**: renders `header.menu`. Sign-in is a normal link — add `{ "label": "Sign in", "href": "…" }` like Register or Career advice. The header recognizes it by label or login URL and follows `href` on click.
|
|
66
|
+
|
|
67
|
+
**Signed in** (`signed-in` true): ignores CMS `header.menu` and shows built-in Find a job, Dashboard, Manage Account, and Sign out.
|
|
68
|
+
|
|
69
|
+
Set **`signed-in`** from your app session state. Pass **`user-name`** for Manage Account. Pass **`account-base-url`** when account links should point at a non-production portal. Pass **`current-path`** (e.g. `/career-advice/my-article`) to highlight the active nav item. **Sign out** emits **`wegAuthClick`** — the host must call `event.preventDefault()` and run your logout flow (API call, clear session, redirect).
|
|
70
|
+
|
|
71
|
+
### Nav active state
|
|
72
|
+
|
|
73
|
+
| Link type | Match rule |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| Flat nav link | Prefix — `/career-advice` matches `/career-advice/foo` |
|
|
76
|
+
| Dropdown child | Exact pathname (+ query when href includes `?`) |
|
|
77
|
+
| Dropdown parent | Active background when any child matches |
|
|
78
|
+
| Sign in / Sign out | Never highlighted |
|
|
79
|
+
|
|
80
|
+
Active links use **`weg-purple-200`** (`#CDCFF8`). Omit `current-path` to disable active styling.
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
header.addEventListener('wegAuthClick', async (event) => {
|
|
84
|
+
if (event.detail.action !== 'sign-out') return;
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
await logout();
|
|
87
|
+
window.location.assign('/');
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Package imports (TypeScript / bundlers)
|
|
92
|
+
|
|
93
|
+
| Subpath | Use |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `weg-shared-layout/loader` | `defineCustomElements()` — **recommended** |
|
|
96
|
+
| `weg-shared-layout/menus` | `fetchWeg21Layout`, `menusToLayoutData` |
|
|
97
|
+
| `weg-shared-layout/menus-data` | WEG21 API types (`MenusData`, …) |
|
|
98
|
+
| `weg-shared-layout/layout-data` | `<weg-header>` / `<weg-footer>` types (`LayoutData`, …) |
|
|
99
|
+
| `weg-shared-layout/weg21-bootstrap.json` | `GET /api/v1/weg21` schema sample |
|
|
100
|
+
| `weg-shared-layout/weg21-menus.json` | `GET /api/v1/weg21/menus` schema sample |
|
|
101
|
+
| `weg-shared-layout/weg-header` / `weg-footer` | Side-effect tag registration |
|
|
102
|
+
| `weg-shared-layout/styles/container.css` | Shared `.container` width and gutter utility |
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
Full index: **[docs/README.md](./docs/README.md)**.
|
|
107
|
+
|
|
108
|
+
| Guide | Doc |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| Angular 16 | [docs/angular.md](./docs/angular.md) |
|
|
111
|
+
| Angular 16 demo (runnable) | [demo/angular16/README.md](./demo/angular16/README.md) |
|
|
112
|
+
| React (SPA, client-only) | [docs/react.md](./docs/react.md) |
|
|
113
|
+
| Next.js (App Router) | [docs/nextjs.md](./docs/nextjs.md) |
|
|
114
|
+
| Plain HTML / vanilla JS | [docs/vanilla.md](./docs/vanilla.md) |
|
|
115
|
+
| Publishing (maintainers) | [docs/publishing.md](./docs/publishing.md) |
|
|
116
|
+
|
|
117
|
+
## Publishing (maintainers)
|
|
118
|
+
|
|
119
|
+
**`npm publish` does not run `npm run build` by itself** — it packs what is on disk. This package uses a **`prepack`** script so a full Stencil build runs before every `npm pack` / `npm publish`, avoiding incomplete tarballs.
|
|
120
|
+
|
|
121
|
+
Details, checklist, and CI notes: **[docs/publishing.md](./docs/publishing.md)**.
|
package/src/types/menus-data.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WEG21 API types — mirrors wegcms-v2 `src/weg-shared-layout/menus-types.ts`.
|
|
3
|
-
* @see GET /api/v1/weg21
|
|
4
|
-
* @see GET /api/v1/weg21/menus
|
|
5
|
-
*/
|
|
6
|
-
export type LayoutPlatform = 'LinkedIn' | 'Instagram' | 'TikTok' | 'YouTube';
|
|
7
|
-
|
|
8
|
-
export type LayoutSocialLink = {
|
|
9
|
-
platform: LayoutPlatform;
|
|
10
|
-
href: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type MenuItemProps = {
|
|
14
|
-
label: string;
|
|
15
|
-
href?: string;
|
|
16
|
-
items?: MenuItemProps[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type HeaderMenuProps = {
|
|
20
|
-
ext: MenuItemProps[];
|
|
21
|
-
int: MenuItemProps[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type FooterMenuProps = MenuItemProps[][];
|
|
25
|
-
|
|
26
|
-
/** `GET /api/v1/weg21/menus` response body. */
|
|
27
|
-
export type MenusProps = {
|
|
28
|
-
header: HeaderMenuProps;
|
|
29
|
-
footer: FooterMenuProps;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type Weg21FooterProps = {
|
|
33
|
-
social_links: LayoutSocialLink[];
|
|
34
|
-
credit: string;
|
|
35
|
-
copyright: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/** `GET /api/v1/weg21` response body. */
|
|
39
|
-
export type Weg21BootstrapProps = {
|
|
40
|
-
logo: string;
|
|
41
|
-
favicon: string;
|
|
42
|
-
menus: string;
|
|
43
|
-
footer: Weg21FooterProps;
|
|
44
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* WEG21 API types — mirrors wegcms-v2 `src/weg-shared-layout/menus-types.ts`.
|
|
3
|
+
* @see GET /api/v1/weg21
|
|
4
|
+
* @see GET /api/v1/weg21/menus
|
|
5
|
+
*/
|
|
6
|
+
export type LayoutPlatform = 'LinkedIn' | 'Instagram' | 'TikTok' | 'YouTube';
|
|
7
|
+
|
|
8
|
+
export type LayoutSocialLink = {
|
|
9
|
+
platform: LayoutPlatform;
|
|
10
|
+
href: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type MenuItemProps = {
|
|
14
|
+
label: string;
|
|
15
|
+
href?: string;
|
|
16
|
+
items?: MenuItemProps[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type HeaderMenuProps = {
|
|
20
|
+
ext: MenuItemProps[];
|
|
21
|
+
int: MenuItemProps[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type FooterMenuProps = MenuItemProps[][];
|
|
25
|
+
|
|
26
|
+
/** `GET /api/v1/weg21/menus` response body. */
|
|
27
|
+
export type MenusProps = {
|
|
28
|
+
header: HeaderMenuProps;
|
|
29
|
+
footer: FooterMenuProps;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Weg21FooterProps = {
|
|
33
|
+
social_links: LayoutSocialLink[];
|
|
34
|
+
credit: string;
|
|
35
|
+
copyright: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** `GET /api/v1/weg21` response body. */
|
|
39
|
+
export type Weg21BootstrapProps = {
|
|
40
|
+
logo: string;
|
|
41
|
+
favicon: string;
|
|
42
|
+
menus: string;
|
|
43
|
+
footer: Weg21FooterProps;
|
|
44
|
+
};
|
package/src/utils/menus.ts
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import type { LayoutData } from '../types/layout-data';
|
|
2
|
-
import type { MenusProps, Weg21BootstrapProps } from '../types/menus-data';
|
|
3
|
-
import bootstrapDummy from '../assets/weg21-bootstrap.json';
|
|
4
|
-
import menusDummy from '../assets/weg21-menus.json';
|
|
5
|
-
|
|
6
|
-
export const DEFAULT_WEG21_API_BASE = 'https://warwickemploymentgroup.com/api/v1/weg21';
|
|
7
|
-
|
|
8
|
-
export const WEG21_BOOTSTRAP_DUMMY = bootstrapDummy as Weg21BootstrapProps;
|
|
9
|
-
export const WEG21_MENUS_DUMMY = menusDummy as MenusProps;
|
|
10
|
-
|
|
11
|
-
export type MenusToLayoutOptions = {
|
|
12
|
-
/** Which header nav slice maps to `header.menu`. Default: `ext` (public marketing nav). */
|
|
13
|
-
headerMenu?: 'ext' | 'int';
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export function menusToLayoutData(
|
|
17
|
-
bootstrap: Pick<Weg21BootstrapProps, 'footer'>,
|
|
18
|
-
menus: MenusProps,
|
|
19
|
-
options: MenusToLayoutOptions = {},
|
|
20
|
-
): LayoutData {
|
|
21
|
-
const headerMenu = options.headerMenu === 'int' ? menus.header.int : menus.header.ext;
|
|
22
|
-
const { credit, copyright, social_links } = bootstrap.footer;
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
header: { menu: headerMenu },
|
|
26
|
-
footer: {
|
|
27
|
-
menu: menus.footer,
|
|
28
|
-
social: social_links,
|
|
29
|
-
credits: credit.trim() || undefined,
|
|
30
|
-
copyright: copyright.trim() || undefined,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Offline layout from package WEG21 dummy fixtures (`weg21-bootstrap.json` + `weg21-menus.json`). */
|
|
36
|
-
export function dummyWeg21LayoutData(options: MenusToLayoutOptions = {}): LayoutData {
|
|
37
|
-
return menusToLayoutData(WEG21_BOOTSTRAP_DUMMY, WEG21_MENUS_DUMMY, options);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type FetchWeg21LayoutOptions = MenusToLayoutOptions & {
|
|
41
|
-
apiBase?: string;
|
|
42
|
-
apiKey?: string;
|
|
43
|
-
fetch?: typeof fetch;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export async function fetchWeg21Layout(options: FetchWeg21LayoutOptions = {}): Promise<LayoutData> {
|
|
47
|
-
const apiBase = (options.apiBase ?? DEFAULT_WEG21_API_BASE).replace(/\/$/, '');
|
|
48
|
-
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
49
|
-
const headers: Record<string, string> = { accept: 'application/json' };
|
|
50
|
-
if (options.apiKey) headers['wcms-api-key'] = options.apiKey;
|
|
51
|
-
|
|
52
|
-
const [bootstrapRes, menusRes] = await Promise.all([
|
|
53
|
-
fetchFn(apiBase, { headers }),
|
|
54
|
-
fetchFn(`${apiBase}/menus`, { headers }),
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
if (!bootstrapRes.ok || !menusRes.ok) {
|
|
58
|
-
throw new Error(`WEG21 API error: bootstrap=${bootstrapRes.status} menus=${menusRes.status}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const bootstrap = (await bootstrapRes.json()) as Weg21BootstrapProps;
|
|
62
|
-
const menus = (await menusRes.json()) as MenusProps;
|
|
63
|
-
|
|
64
|
-
return menusToLayoutData(bootstrap, menus, options);
|
|
65
|
-
}
|
|
1
|
+
import type { LayoutData } from '../types/layout-data';
|
|
2
|
+
import type { MenusProps, Weg21BootstrapProps } from '../types/menus-data';
|
|
3
|
+
import bootstrapDummy from '../assets/weg21-bootstrap.json';
|
|
4
|
+
import menusDummy from '../assets/weg21-menus.json';
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_WEG21_API_BASE = 'https://warwickemploymentgroup.com/api/v1/weg21';
|
|
7
|
+
|
|
8
|
+
export const WEG21_BOOTSTRAP_DUMMY = bootstrapDummy as Weg21BootstrapProps;
|
|
9
|
+
export const WEG21_MENUS_DUMMY = menusDummy as MenusProps;
|
|
10
|
+
|
|
11
|
+
export type MenusToLayoutOptions = {
|
|
12
|
+
/** Which header nav slice maps to `header.menu`. Default: `ext` (public marketing nav). */
|
|
13
|
+
headerMenu?: 'ext' | 'int';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function menusToLayoutData(
|
|
17
|
+
bootstrap: Pick<Weg21BootstrapProps, 'footer'>,
|
|
18
|
+
menus: MenusProps,
|
|
19
|
+
options: MenusToLayoutOptions = {},
|
|
20
|
+
): LayoutData {
|
|
21
|
+
const headerMenu = options.headerMenu === 'int' ? menus.header.int : menus.header.ext;
|
|
22
|
+
const { credit, copyright, social_links } = bootstrap.footer;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
header: { menu: headerMenu },
|
|
26
|
+
footer: {
|
|
27
|
+
menu: menus.footer,
|
|
28
|
+
social: social_links,
|
|
29
|
+
credits: credit.trim() || undefined,
|
|
30
|
+
copyright: copyright.trim() || undefined,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Offline layout from package WEG21 dummy fixtures (`weg21-bootstrap.json` + `weg21-menus.json`). */
|
|
36
|
+
export function dummyWeg21LayoutData(options: MenusToLayoutOptions = {}): LayoutData {
|
|
37
|
+
return menusToLayoutData(WEG21_BOOTSTRAP_DUMMY, WEG21_MENUS_DUMMY, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type FetchWeg21LayoutOptions = MenusToLayoutOptions & {
|
|
41
|
+
apiBase?: string;
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
fetch?: typeof fetch;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export async function fetchWeg21Layout(options: FetchWeg21LayoutOptions = {}): Promise<LayoutData> {
|
|
47
|
+
const apiBase = (options.apiBase ?? DEFAULT_WEG21_API_BASE).replace(/\/$/, '');
|
|
48
|
+
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
49
|
+
const headers: Record<string, string> = { accept: 'application/json' };
|
|
50
|
+
if (options.apiKey) headers['wcms-api-key'] = options.apiKey;
|
|
51
|
+
|
|
52
|
+
const [bootstrapRes, menusRes] = await Promise.all([
|
|
53
|
+
fetchFn(apiBase, { headers }),
|
|
54
|
+
fetchFn(`${apiBase}/menus`, { headers }),
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
if (!bootstrapRes.ok || !menusRes.ok) {
|
|
58
|
+
throw new Error(`WEG21 API error: bootstrap=${bootstrapRes.status} menus=${menusRes.status}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const bootstrap = (await bootstrapRes.json()) as Weg21BootstrapProps;
|
|
62
|
+
const menus = (await menusRes.json()) as MenusProps;
|
|
63
|
+
|
|
64
|
+
return menusToLayoutData(bootstrap, menus, options);
|
|
65
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t,e,n){const o="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==o;){const o=Object.getOwnPropertyDescriptor(t,e);if(o&&(!n||o.get))return o;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var o;Object.entries(null!=(o=n.o.t)?o:{}).map((([o,[l]])=>{if(31&l||32&l){const l=e[o],s=t(Object.getPrototypeOf(e),o,!0)||Object.getOwnPropertyDescriptor(e,o);s&&Object.defineProperty(e,o,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.l.has(o)?e[o]=n.l.get(o):void 0!==l&&(e[o]=l)}}))},o=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},l=(t,e)=>e in t,s=(t,e)=>(0,console.error)(t,e),r=new Map,i="http://www.w3.org/1999/xlink",c="undefined"!=typeof window?window:{},u=c.HTMLElement||class{},f={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,o)=>t.addEventListener(e,n,o),rel:(t,e,n,o)=>t.removeEventListener(e,n,o),ce:(t,e)=>new CustomEvent(t,e)},a=(()=>{var t;let e=!1;try{null==(t=c.document)||t.addEventListener("e",null,Object.defineProperty({},"passive",{get(){e=!0}}))}catch(t){}return e})(),h=(()=>{try{return!!c.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),p=!!h&&(()=>!!c.document&&Object.getOwnPropertyDescriptor(c.document.adoptedStyleSheets,"length").writable)(),d=!1,m=[],v=[],b=(t,e)=>n=>{t.push(n),d||(d=!0,e&&4&f.i?w($):f.raf($))},y=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){s(t)}t.length=0},$=()=>{y(m),y(v),(d=m.length>0)&&f.raf($)},w=t=>Promise.resolve(undefined).then(t),g=b(v,!0),j=t=>{const e=new URL(t,f.u);return e.origin!==c.location.origin?e.href:e.pathname},O=t=>f.u=t;function S(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(p?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var k,M=new WeakMap,E=t=>"sc-"+t.h,x=t=>"object"==(t=typeof t)||"function"===t,C=(t,e,...n)=>{let o=null,l=null,s=!1,r=!1;const i=[],c=e=>{for(let n=0;n<e.length;n++)o=e[n],Array.isArray(o)?c(o):null!=o&&"boolean"!=typeof o&&((s="function"!=typeof t&&!x(o))&&(o=String(o)),s&&r?i[i.length-1].p+=o:i.push(s?A(null,o):o),r=s)};if(c(n),e){e.key&&(l=e.key);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter((e=>t[e])).join(" "))}}if("function"==typeof t)return t(null===e?{}:e,i,_);const u=A(t,null);return u.m=e,i.length>0&&(u.v=i),u.$=l,u},A=(t,e)=>({i:0,j:t,p:null!=e?e:null,O:null,v:null,m:null,$:null}),L={},_={forEach:(t,e)=>t.map(D).forEach(e),map:(t,e)=>t.map(D).map(e).map(H)},D=t=>({vattrs:t.m,vchildren:t.v,vkey:t.$,vname:t.S,vtag:t.j,vtext:t.p}),H=t=>{if("function"==typeof t.vtag){const e={...t.vattrs};return t.vkey&&(e.key=t.vkey),t.vname&&(e.name=t.vname),C(t.vtag,e,...t.vchildren||[])}const e=A(t.vtag,t.vtext);return e.m=t.vattrs,e.v=t.vchildren,e.$=t.vkey,e.S=t.vname,e},P=t=>{if(!t)return;const e=Object.keys(t);if(0===e.length)return;let n=!1;for(const o of e){if(n)break;for(const e of t[o])if("string"==typeof e){n=!0;break}}if(!n)return t;const o={};for(const n of e)o[n]=t[n].map((t=>"string"==typeof t?{[t]:0}:t));return o},R=(t,e)=>null==t||x(t)?t:4&e?"false"!==t&&(""===t||!!t):1&e?String(t):t,U=(t,e)=>{const n=t;return{emit:t=>W(n,e,{bubbles:!0,composed:!0,cancelable:!0,detail:t})}},W=(t,e,n)=>{const o=f.ce(e,n);return t.dispatchEvent(o),o},N=(t,e,n,s,r,u)=>{if(n===s)return;let a=l(t,e),h=e.toLowerCase();if("class"===e){const e=t.classList,o=q(n);let l=q(s);e.remove(...o.filter((t=>t&&!l.includes(t)))),e.add(...l.filter((t=>t&&!o.includes(t))))}else if("style"===e){for(const e in n)s&&null!=s[e]||(e.includes("-")?t.style.removeProperty(e):t.style[e]="");for(const e in s)n&&s[e]===n[e]||(e.includes("-")?t.style.setProperty(e,s[e]):t.style[e]=s[e])}else if("key"===e);else if("ref"===e)s&&et(s,t);else if(t.__lookupSetter__(e)||"o"!==e[0]||"n"!==e[1]){if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let l;{const e=o(t);if(e&&e.o&&e.o.t){const t=e.o.t[n];t&&t[1]&&(l=t[1])}}return l||(l=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==s||!1===s?!1===s&&""!==t.getAttribute(l)||t.removeAttribute(l):t.setAttribute(l,!0===s?"":s))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=s}catch(t){}return}{const o=x(s);if((a||o&&null!==s)&&!r)try{if(t.tagName.includes("-"))t[e]!==s&&(t[e]=s);else{const o=null==s?"":s;"list"===e?a=!1:null!=n&&t[e]===o||("function"==typeof t.__lookupSetter__(e)?t[e]=o:t.setAttribute(e,o))}}catch(t){}let l=!1;h!==(h=h.replace(/^xlink\:?/,""))&&(e=h,l=!0),null==s||!1===s?!1===s&&""!==t.getAttribute(e)||(l?t.removeAttributeNS(i,e):t.removeAttribute(e)):(!a||4&u||r)&&!o&&1===t.nodeType&&(s=!0===s?"":s,l?t.setAttributeNS(i,e,s):t.setAttribute(e,s))}}else if(e="-"===e[2]?e.slice(3):l(c,h)?h.slice(2):h[2]+e.slice(3),n||s){const o=e.endsWith(z);e=e.replace(F,""),n&&f.rel(t,e,n,o),s&&f.ael(t,e,s,o)}},V=/\s/,q=t=>("object"==typeof t&&t&&"baseVal"in t&&(t=t.baseVal),t&&"string"==typeof t?t.split(V):[]),z="Capture",F=new RegExp(z+"$"),T=(t,e,n)=>{const o=11===e.O.nodeType&&e.O.host?e.O.host:e.O,l=t&&t.m||{},s=e.m||{};for(const t of Y(Object.keys(l)))t in s||N(o,t,l[t],void 0,n,e.i);for(const t of Y(Object.keys(s)))N(o,t,l[t],s[t],n,e.i)};function Y(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var Z=!1,B=[],G=[],I=(t,e,n)=>{const o=e.v[n];let l,s,r=0;if(null!=o.p)l=o.O=c.document.createTextNode(o.p);else{if(Z||(Z="svg"===o.j),!c.document)throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(l=o.O=c.document.createElementNS(Z?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",o.j),Z&&"foreignObject"===o.j&&(Z=!1),T(null,o,Z),o.v){const e="template"===o.j?l.content:l;for(r=0;r<o.v.length;++r)s=I(t,o,r),s&&e.appendChild(s)}"svg"===o.j?Z=!1:"foreignObject"===l.tagName&&(Z=!0)}return l["s-hn"]=k,l},J=(t,e,n,o,l,s)=>{let r,i=t;for(i.shadowRoot&&i.tagName===k&&(i=i.shadowRoot),"template"===n.j&&(i=i.content);l<=s;++l)o[l]&&(r=I(null,n,l),r&&(o[l].O=r,nt(i,r,e)))},K=(t,e,n)=>{for(let o=e;o<=n;++o){const e=t[o];if(e){const t=e.O;tt(e),t&&t.remove()}}},Q=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.$&&e.$&&(t.$=e.$),!0):t.$===e.$),X=(t,e,n=!1)=>{const o=e.O=t.O,l=t.v,s=e.v,r=e.j,i=e.p;null==i?(T(t,e,Z="svg"===r||"foreignObject"!==r&&Z),null!==l&&null!==s?((t,e,n,o,l=!1)=>{let s,r,i=0,c=0,u=0,f=0,a=e.length-1,h=e[0],p=e[a],d=o.length-1,m=o[0],v=o[d];const b="template"===n.j?t.content:t;for(;i<=a&&c<=d;)if(null==h)h=e[++i];else if(null==p)p=e[--a];else if(null==m)m=o[++c];else if(null==v)v=o[--d];else if(Q(h,m,l))X(h,m,l),h=e[++i],m=o[++c];else if(Q(p,v,l))X(p,v,l),p=e[--a],v=o[--d];else if(Q(h,v,l))X(h,v,l),nt(b,h.O,p.O.nextSibling),h=e[++i],v=o[--d];else if(Q(p,m,l))X(p,m,l),nt(b,p.O,h.O),p=e[--a],m=o[++c];else{for(u=-1,f=i;f<=a;++f)if(e[f]&&null!==e[f].$&&e[f].$===m.$){u=f;break}u>=0?(r=e[u],r.j!==m.j?s=I(e&&e[c],n,u):(X(r,m,l),e[u]=void 0,s=r.O),m=o[++c]):(s=I(e&&e[c],n,c),m=o[++c]),s&&nt(h.O.parentNode,s,h.O)}i>a?J(t,null==o[d+1]?null:o[d+1].O,n,o,c,d):c>d&&K(e,i,a)})(o,l,e,s,n):null!==s?(null!==t.p&&(o.textContent=""),J(o,null,e,s,0,s.length-1)):!n&&null!==l&&K(l,0,l.length-1),Z&&"svg"===r&&(Z=!1)):t.p!==i&&(o.data=i)},tt=t=>{t.m&&t.m.ref&&B.push((()=>t.m.ref(null))),t.v&&t.v.map(tt)},et=(t,e)=>{G.push((()=>t(e)))},nt=(t,e,n)=>t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n),ot=(t,e,n=!1)=>{const o=t.$hostElement$,l=t.o,s=t.k||A(null,null);var r;const i=(r=e)&&r.j===L?e:C(null,null,e);if(k=o.tagName,l.M&&(i.m=i.m||{},l.M.forEach((([t,e])=>{i.m[e]=o[t]}))),n&&i.m)for(const t of Object.keys(i.m))o.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.m[t]=o[t]);i.j=null,i.i|=4,t.k=i,i.O=s.O=o.shadowRoot||o,X(s,i,n),B.forEach((t=>t())),B.length=0,G.forEach((t=>t())),G.length=0},lt=(t,e)=>{if(e&&!t.C&&e["s-p"]){const n=e["s-p"].push(new Promise((o=>t.C=()=>{e["s-p"].splice(n-1,1),o()})))}},st=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);lt(t,t.A);const n=()=>rt(t,e);if(!e)return g(n);queueMicrotask((()=>{n()}))},rt=(t,e)=>{const n=t.$hostElement$,o=n;if(!o)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let l;return l=pt(o,e?"componentWillLoad":"componentWillUpdate",void 0,n),l=it(l,(()=>pt(o,"componentWillRender",void 0,n))),it(l,(()=>ut(t,o,e)))},it=(t,e)=>ct(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),ct=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,ut=async(t,e,n)=>{var o;const l=t.$hostElement$,s=l["s-rc"];n&&(t=>{const e=t.o,n=t.$hostElement$,o=e.i,l=((t,e)=>{var n,o,l;const s=E(e),i=r.get(s);if(!c.document)return s;if(t=11===t.nodeType?t:c.document,i)if("string"==typeof i){let l,r=M.get(t=t.head||t);if(r||M.set(t,r=new Set),!r.has(s)){l=c.document.createElement("style"),l.textContent=i;const u=null!=(n=f.L)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=c.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=u&&l.setAttribute("nonce",u),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(l,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(h){const e=new(null!=(o=t.defaultView)?o:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(i),p?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=i+e.textContent:t.prepend(l)}else t.append(l);1&e.i&&t.insertBefore(l,null),4&e.i&&(l.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),r&&r.add(s)}}else{let e=M.get(t);if(e||M.set(t,e=new Set),!e.has(s)){const n=null!=(l=t.defaultView)?l:t.ownerDocument.defaultView;let o;if(i.constructor===n.CSSStyleSheet)o=i;else{o=new n.CSSStyleSheet;for(let t=0;t<i.cssRules.length;t++)o.insertRule(i.cssRules[t].cssText,t)}p?t.adoptedStyleSheets.push(o):t.adoptedStyleSheets=[...t.adoptedStyleSheets,o],e.add(s)}}return s})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&o&&(n["s-sc"]=l,n.classList.add(l+"-h"))})(t);ft(t,e,l,n),s&&(s.map((t=>t())),l["s-rc"]=void 0);{const e=null!=(o=l["s-p"])?o:[],n=()=>at(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},ft=(t,e,n,o)=>{try{e=e.render(),t.i&=-17,t.i|=2,ot(t,e,o)}catch(e){s(e,t.$hostElement$)}return null},at=t=>{const e=t.$hostElement$,n=e,o=t.A;pt(n,"componentDidRender",void 0,e),64&t.i?pt(n,"componentDidUpdate",void 0,e):(t.i|=64,dt(e),pt(n,"componentDidLoad",void 0,e),t._(e),o||ht()),t.C&&(t.C(),t.C=void 0),512&t.i&&w((()=>st(t,!1))),t.i&=-517},ht=()=>{w((()=>W(c,"appload",{detail:{namespace:"weg-shared-layout"}})))},pt=(t,e,n,o)=>{if(t&&t[e])try{return t[e](n)}catch(t){s(t,o)}},dt=t=>t.classList.add("hydrated"),mt=(t,e,n,l)=>{const r=o(t);if(!r)return;const i=t,c=r.l.get(e),u=r.i,f=i;n=R(n,l.t[e][0]);const a=Number.isNaN(c)&&Number.isNaN(n);if(n!==c&&!a){if(r.l.set(e,n),l.D){const t=l.D[e];t&&t.map((t=>{try{const[[o,l]]=Object.entries(t);(128&u||1&l)&&(f?f[o](n,c,e):r.H.push((()=>{r.P[o](n,c,e)})))}catch(t){s(t,i)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||st(r,!1)}}},vt=(e,n)=>{var l,s;const r=e.prototype;{e.watchers&&!n.D&&(n.D=P(e.watchers)),e.deserializers&&!n.R&&(n.R=e.deserializers),e.serializers&&!n.U&&(n.U=e.serializers);const i=Object.entries(null!=(l=n.t)?l:{});i.map((([e,[l]])=>{if(31&l||32&l){const{get:s,set:i}=t(r,e)||{};s&&(n.t[e][0]|=2048),i&&(n.t[e][0]|=4096),Object.defineProperty(r,e,{get(){return s?s.apply(this):(t=e,o(this).l.get(t));var t},configurable:!0,enumerable:!0}),Object.defineProperty(r,e,{set(t){const s=o(this);if(s){if(i)return void 0===(32&l?this[e]:s.$hostElement$[e])&&s.l.get(e)&&(t=s.l.get(e)),i.apply(this,[R(t,l)]),void mt(this,e,t=32&l?this[e]:s.$hostElement$[e],n);mt(this,e,t,n)}}})}}));{const t=new Map;r.attributeChangedCallback=function(e,l,s){f.jmp((()=>{var c;const u=t.get(e),f=o(this);if(this.hasOwnProperty(u),r.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==s)return;if(null==u){const t=null==f?void 0:f.i;if(f&&t&&!(8&t)&&s!==l){const o=this,r=null==(c=n.D)?void 0:c[e];null==r||r.forEach((n=>{const[[r,i]]=Object.entries(n);null!=o[r]&&(128&t||1&i)&&o[r].call(o,s,l,e)}))}return}const a=i.find((([t])=>t===u)),h=a&&4&a[1][0],p=h&&null===s&&void 0===this[u];h&&(s=null!==s&&"false"!==s);const d=Object.getOwnPropertyDescriptor(r,u);p||s==this[u]||d.get&&!d.set||(this[u]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n.D)?s:{}),...i.filter((([t,e])=>31&e[0])).map((([e,o])=>{var l;const s=o[1]||e;return t.set(s,e),512&o[0]&&(null==(l=n.M)||l.push([e,s])),s}))]))}}return e},bt=(t,e)=>{const l={i:e[0],h:e[1]};try{l.t=e[2],l.W=e[3],l.D=P(t.D),l.R=t.R,l.U=t.U,l.M=[];const i=t.prototype.connectedCallback,c=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const o={i:0,$hostElement$:t,o:e,l:new Map,N:new Map};o.V=new Promise((t=>o._=t)),t["s-p"]=[],t["s-rc"]=[];const l=o;t.__stencil__getHostRef=()=>l,512&e.i&&n(t,o)})(this,l)},connectedCallback(){if(!this.__hasHostListenerAttached){const t=o(this);if(!t)return;yt(this,t,l.W),this.__hasHostListenerAttached=!0}(t=>{if(!(1&f.i)){const e=o(t);if(!e)return;const n=e.o,l=()=>{};if(1&e.i)yt(t,e,n.W),(null==e?void 0:e.P)||(null==e?void 0:e.V)&&e.V.then((()=>{}));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){lt(e,e.A=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n)=>{let o;try{if(!(32&e.i)&&(e.i|=32,o=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),o&&o.style)){let t;"string"==typeof o.style&&(t=o.style);const e=E(n);if(!r.has(e)){const o=()=>{};((t,e,n)=>{let o=r.get(t);h&&n?(o=o||new CSSStyleSheet,"string"==typeof o?o=e:o.replaceSync(e)):o=e,r.set(t,o)})(e,t,!!(1&n.i)),o()}}const l=e.A,s=()=>st(e,!0);l&&l["s-rc"]?l["s-rc"].push(s):s()}catch(n){s(n,t),e.C&&(e.C(),e.C=void 0),e._&&e._(t)}})(t,e,n)}l()}})(this),i&&i.call(this)},disconnectedCallback(){(async t=>{if(!(1&f.i)){const e=o(t);(null==e?void 0:e.q)&&(e.q.map((t=>t())),e.q=void 0)}M.has(t)&&M.delete(t),t.shadowRoot&&M.has(t.shadowRoot)&&M.delete(t.shadowRoot)})(this),c&&c.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${l.h}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else S.call(this,l)}}),Object.defineProperty(t,"is",{value:l.h,configurable:!0}),vt(t,l)}catch(e){return s(e),t}},yt=(t,e,n)=>{n&&c.document&&n.map((([n,o,l])=>{const s=wt(c.document,t,n),r=$t(e,l),i=gt(n);f.ael(s,o,r,i),(e.q=e.q||[]).push((()=>f.rel(s,o,r,i)))}))},$t=(t,e)=>n=>{try{t.$hostElement$[e](n)}catch(e){s(e,t.$hostElement$)}},wt=(t,e,n)=>8&n?c:e,gt=t=>a?{passive:!!(1&t),capture:!!(2&t)}:!!(2&t),jt=t=>f.L=t,Ot=t=>Object.assign(f,t),St=new WeakMap;function kt(t,e){let n=St.get(e);n||(n={i:0,o:{i:0,h:e.tagName},$hostElement$:e},St.set(e,n)),ot(n,t)}function Mt(t){return t}export{u as H,jt as a,Ot as b,U as c,j as g,C as h,bt as p,kt as r,O as s,Mt as t}
|