wirejs-components 0.1.32 → 0.1.34-async-api

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.
@@ -0,0 +1,60 @@
1
+ import type { AuthenticationState } from 'wirejs-resources';
2
+ export declare function Main(slots: {
3
+ /**
4
+ * Replaces the default prefix in the final page title.
5
+ */
6
+ siteTitle?: string | ((state: AuthenticationState) => string);
7
+ /**
8
+ * Appears on the page under the site title.
9
+ *
10
+ * Set to empty-string explicitly to omit the default.
11
+ */
12
+ siteSubTitle?: string | ((state: AuthenticationState) => string);
13
+ /**
14
+ * The page title. Appears below the site title and subtitle when given.
15
+ */
16
+ pageTitle?: string | ((state: AuthenticationState) => string);
17
+ /**
18
+ * Author for this page. Appears next to the title in lighter font and
19
+ * in the address bar.
20
+ */
21
+ pageAuthor?: string | ((state: AuthenticationState) => string);
22
+ /**
23
+ * The main content for the page.
24
+ */
25
+ content: HTMLElement | ((state: AuthenticationState) => HTMLElement);
26
+ /**
27
+ * Appears in the top of the footer.
28
+ */
29
+ disclaimer?: string | HTMLElement | ((state: AuthenticationState) => string | HTMLElement);
30
+ }): Promise<HTMLElement & {
31
+ data: {
32
+ account: HTMLElement & {
33
+ data: unknown;
34
+ } & import("wirejs-dom/v2").DomEvents<HTMLElement & {
35
+ data: unknown;
36
+ }> & import("wirejs-dom/v2").Extend<HTMLElement & {
37
+ data: unknown;
38
+ }>;
39
+ };
40
+ } & import("wirejs-dom/v2").DomEvents<HTMLElement & {
41
+ data: {
42
+ account: HTMLElement & {
43
+ data: unknown;
44
+ } & import("wirejs-dom/v2").DomEvents<HTMLElement & {
45
+ data: unknown;
46
+ }> & import("wirejs-dom/v2").Extend<HTMLElement & {
47
+ data: unknown;
48
+ }>;
49
+ };
50
+ }> & import("wirejs-dom/v2").Extend<HTMLElement & {
51
+ data: {
52
+ account: HTMLElement & {
53
+ data: unknown;
54
+ } & import("wirejs-dom/v2").DomEvents<HTMLElement & {
55
+ data: unknown;
56
+ }> & import("wirejs-dom/v2").Extend<HTMLElement & {
57
+ data: unknown;
58
+ }>;
59
+ };
60
+ }>>;
@@ -0,0 +1,100 @@
1
+ import { html, node, hydrate } from 'wirejs-dom/v2';
2
+ import { auth } from 'my-api';
3
+ import { AccountMenu } from '../components/index.js';
4
+ const TITLE = 'My New Site';
5
+ const SUBTITLE = 'Made with wirejs';
6
+ const MENU_ID = 'account-menu';
7
+ const DISCLAIMER = html `<div>
8
+ <p>Everything here is awesome.</p>
9
+ </div>`;
10
+ async function Account() {
11
+ return html `<div id='${MENU_ID}'>
12
+ ${AccountMenu({ api: auth })}
13
+ </div>`;
14
+ }
15
+ export async function Main(slots) {
16
+ const pageAuthorElement = slots.pageAuthor ? html `
17
+ <span style='color: var(--color-muted);'>
18
+ : according to <a href='/wiki/view/~${slots.pageAuthor}'>${slots.pageAuthor}</a>
19
+ </span>
20
+ ` : '';
21
+ const pageTitle = slots.pageTitle ? html `
22
+ <h2 style='font-variant: small-caps;'>
23
+ ${slots.pageTitle} ${pageAuthorElement}
24
+ </h2>
25
+ ` : '';
26
+ const browserBarTitle = [
27
+ slots.pageTitle,
28
+ slots.pageAuthor,
29
+ slots.siteTitle || TITLE,
30
+ slots.siteSubTitle || SUBTITLE,
31
+ ].filter(Boolean).slice(0, 3).join(' - ');
32
+ const page = html `
33
+ <!doctype html>
34
+ <html id='root'>
35
+ <head>
36
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
37
+ <title>${browserBarTitle}</title>
38
+ <link rel='icon' type='image/svg+xml' href='/images/logo.svg' />
39
+ <link rel='stylesheet' type='text/css' href='/default.css' />
40
+ </head>
41
+ <body>
42
+ <div style='
43
+ border-width: 0 1px;
44
+ border-color: silver;
45
+ border-style: solid;
46
+ max-width: 1200px;
47
+ min-height: 100vh;
48
+ padding: 0 1rem;
49
+ margin: 0 auto;
50
+ overflow: hidden;
51
+ '>
52
+ <div style='
53
+ display: flex;
54
+ width: 100%;
55
+ padding-bottom: 0.5rem;
56
+ border-bottom: 1px solid var(--border-color-muted, #777);
57
+ margin-bottom: 1rem;
58
+ '>
59
+ <!-- source: https://www.svgrepo.com/svg/322460/greek-temple -->
60
+ <svg
61
+ style='
62
+ margin-top: 1.4rem;
63
+ margin-right: 0.5rem;
64
+ '
65
+ height='4rem'
66
+ viewBox="0 0 512 512"
67
+ xmlns="http://www.w3.org/2000/svg"
68
+ ><path fill="#000000" d="M256 26.2L52 135h408L256 26.2zM73 153v14h366v-14H73zm16 32v206h30V185H89zm101.334 0v206h30V185h-30zm101.332 0v206h30V185h-30zM393 185v206h30V185h-30zM73 409v30h366v-30H73zm-32 48v30h430v-30H41z"/></svg>
69
+
70
+ <div style='flex-basis: 0; flex-grow: 5;'>
71
+ <h1 style='font-variant: small-caps; text-shadow: silver 2px 2px 2px;'>
72
+ <a href='/' style='color: var(--color-strong, #000);'>${slots.siteTitle || TITLE}</a>
73
+ </h1>
74
+
75
+ <div style='
76
+ margin-top: -1rem;
77
+ color: var(--color-muted, #888);
78
+ '>${slots.siteSubTitle ?? SUBTITLE}</div>
79
+ </div>
80
+
81
+ <div style='margin-top: 3.5rem; flex-grow: 0;'>
82
+ ${node('account', await Account())}
83
+ </div>
84
+ </div>
85
+
86
+ ${pageTitle}
87
+
88
+ <div id='content'>${slots.content}</div>
89
+
90
+ <footer>
91
+ ${slots.disclaimer ?? DISCLAIMER}
92
+ </footer>
93
+ </div>
94
+ </body>
95
+ </html>
96
+ `;
97
+ return page;
98
+ }
99
+ // TODO: fix wirejs requiring ... whatever it is here that it requires that breaks the type!
100
+ hydrate(MENU_ID, Account);
@@ -0,0 +1 @@
1
+ export { default as defaultLayout } from './default.js';
@@ -0,0 +1 @@
1
+ export { default as defaultLayout } from './default.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-components",
3
- "version": "0.1.32",
3
+ "version": "0.1.34-async-api",
4
4
  "description": "Client-side components for wirejs apps, including basic UI and resource-aware components.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://github.com/svidgen/create-wirejs-app#readme",
32
32
  "dependencies": {
33
33
  "wirejs-dom": "^1.0.41",
34
- "wirejs-resources": "^0.1.89"
34
+ "wirejs-resources": "^0.1.91-async-api"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^5.7.3"