@poadio/app-vue 0.0.0-stage → 0.1.0
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/CHANGELOG.md +19 -0
- package/LICENSE +22 -0
- package/README.md +16 -2
- package/app-vue.css +107 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +95 -0
- package/dist/browser.js.map +1 -0
- package/dist/front-view.d.ts +35 -0
- package/dist/front-view.d.ts.map +1 -0
- package/dist/front-view.js +115 -0
- package/dist/front-view.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lazy.d.ts +40 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/lazy.js +35 -0
- package/dist/lazy.js.map +1 -0
- package/dist/messages.d.ts +38 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +66 -0
- package/dist/messages.js.map +1 -0
- package/dist/sections/grid.d.ts +29 -0
- package/dist/sections/grid.d.ts.map +1 -0
- package/dist/sections/grid.js +19 -0
- package/dist/sections/grid.js.map +1 -0
- package/dist/sections/under-construction.d.ts +25 -0
- package/dist/sections/under-construction.d.ts.map +1 -0
- package/dist/sections/under-construction.js +32 -0
- package/dist/sections/under-construction.js.map +1 -0
- package/package.json +71 -4
- package/runtime-dist/app.css +461 -0
- package/runtime-dist/app.js +2 -0
- package/runtime-dist/c-7dddcgt2.js +2 -0
- package/runtime-dist/c-9a0nzf53.js +2 -0
- package/runtime-dist/c-c1e1x3y1.js +1 -0
- package/runtime-dist/c-fg782zf4.js +1 -0
- package/runtime-dist/c-fnkq09db.js +1 -0
- package/runtime-dist/c-j29w8z15.js +1 -0
- package/runtime-dist/c-mmxqs2mz.js +1 -0
- package/runtime-dist/c-ns42txax.js +2 -0
- package/runtime-dist/c-pgxy0etb.js +1 -0
- package/runtime-dist/c-xsq12y6b.js +1 -0
- package/runtime-dist/index.html +14 -0
- package/runtime-dist/version.json +1 -0
- package/src/browser.ts +107 -0
- package/src/front-view.ts +132 -0
- package/src/index.ts +4 -0
- package/src/lazy.ts +39 -0
- package/src/messages.ts +74 -0
- package/src/sections/grid.ts +21 -0
- package/src/sections/under-construction.ts +34 -0
package/src/browser.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Ce qui touche au navigateur : historique, envoi des journaux, thème, démarrage complet d'un front servi par
|
|
2
|
+
// l'engine (bootFront). Rien ici ne s'exécute à l'import : les fonctions lisent `window` quand on les appelle.
|
|
3
|
+
import { createApp, type App } from 'vue';
|
|
4
|
+
import {
|
|
5
|
+
createFrontApp, createFrontLogger, createPreviewBridge, isFrontConfig, poadAuth, previewModeOf,
|
|
6
|
+
type AuthPort, type BrowserLogLine, type FrontApp, type FrontConfig, type HistoryPort, type PoadAuthLike, type Theme,
|
|
7
|
+
} from '@poadio/app-core';
|
|
8
|
+
import { PoadFrontView } from './front-view.js';
|
|
9
|
+
import { langOf } from './messages.js';
|
|
10
|
+
import { preloadPage } from './lazy.js';
|
|
11
|
+
|
|
12
|
+
export const browserHistory = (): HistoryPort => ({
|
|
13
|
+
location: () => ({ pathname: window.location.pathname, search: window.location.search }),
|
|
14
|
+
push: (p) => window.history.pushState(null, '', p),
|
|
15
|
+
// En aperçu, ?poad_preview=… reste dans l'adresse (un rechargement de l'iframe garde son mode)
|
|
16
|
+
replace: (p) => window.history.replaceState(null, '', p + (previewModeOf(window.location.search) ? window.location.search : '')),
|
|
17
|
+
listen: (cb) => {
|
|
18
|
+
window.addEventListener('popstate', cb);
|
|
19
|
+
return () => window.removeEventListener('popstate', cb);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/** Envoi des lignes à l'origine du front (POST /_poad/log) ; à la fermeture de la page, sendBeacon */
|
|
24
|
+
export const logSender = (endpoint = '/_poad/log') => (lines: BrowserLogLine[], { final }: { final: boolean }) => {
|
|
25
|
+
const body = JSON.stringify({ lines });
|
|
26
|
+
try {
|
|
27
|
+
if (final && navigator.sendBeacon) {
|
|
28
|
+
navigator.sendBeacon(endpoint, new Blob([body], { type: 'application/json' }));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
void fetch(endpoint, { method: 'POST', headers: { 'content-type': 'application/json' }, body, keepalive: true, credentials: 'omit' }).catch(() => {});
|
|
32
|
+
} catch {
|
|
33
|
+
/* jamais d'erreur à cause du journal */
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const applyTheme = (theme: Theme | null) => {
|
|
38
|
+
const t = theme ?? (window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
|
39
|
+
const root = document.documentElement;
|
|
40
|
+
root.classList.remove('theme-dark', 'theme-light');
|
|
41
|
+
root.classList.add(`theme-${t}`);
|
|
42
|
+
root.style.colorScheme = t;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type BootOptions = {
|
|
46
|
+
el: Element;
|
|
47
|
+
/** Fabrique du client poad (createClient de @poadio/client-js) : url et clé anon viennent de front.json */
|
|
48
|
+
createClient: (url: string, anonKey: string) => PoadAuthLike;
|
|
49
|
+
configUrl?: string;
|
|
50
|
+
fetchConfig?: () => Promise<unknown>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Démarre un front servi par l'engine : config, client poad, journaux, aperçu de la console, rendu */
|
|
54
|
+
export const bootFront = async (opts: BootOptions): Promise<{ app: FrontApp; vue: App } | null> => {
|
|
55
|
+
const logger = createFrontLogger(logSender());
|
|
56
|
+
window.addEventListener('pagehide', () => logger.flush(true));
|
|
57
|
+
window.addEventListener('error', (e) => logger.error(`erreur JavaScript : ${e.message}`, { event: 'app_js_error', attrs: { source: String(e.filename ?? '').split('?')[0], line: e.lineno } }));
|
|
58
|
+
window.addEventListener('unhandledrejection', (e) => logger.error(`promesse rejetée : ${String((e.reason as Error)?.message ?? e.reason)}`, { event: 'app_js_error' }));
|
|
59
|
+
setInterval(() => logger.flush(), 2000);
|
|
60
|
+
|
|
61
|
+
let config: FrontConfig;
|
|
62
|
+
try {
|
|
63
|
+
const raw = opts.fetchConfig ? await opts.fetchConfig() : await (await fetch(opts.configUrl ?? '/_poad/front.json', { credentials: 'same-origin', cache: 'no-store' })).json();
|
|
64
|
+
if (!isFrontConfig(raw)) throw new Error('front.json illisible');
|
|
65
|
+
config = raw;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
logger.error(`configuration du front illisible : ${(e as Error).message}`, { event: 'app_config_error' });
|
|
68
|
+
logger.flush();
|
|
69
|
+
opts.el.textContent = 'poad : configuration du front illisible.';
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const mode = previewModeOf(window.location.search) ?? 'live';
|
|
74
|
+
const auth: AuthPort = poadAuth(opts.createClient(config.api.url, config.api.anonKey));
|
|
75
|
+
let bridge: ReturnType<typeof createPreviewBridge> | null = null;
|
|
76
|
+
const app = createFrontApp({ config, auth, history: browserHistory(), logger, mode, onNavigate: (page) => bridge?.navigate(page) });
|
|
77
|
+
applyTheme(null);
|
|
78
|
+
app.subscribe((s) => {
|
|
79
|
+
// Les modules de la page (sections, formulaire de connexion) partent avant le rendu
|
|
80
|
+
void preloadPage(s.page, s.needsLogin);
|
|
81
|
+
if (s.theme) applyTheme(s.theme);
|
|
82
|
+
if (s.front) document.title = s.page ? `${s.page.title} · ${s.front.name}` : s.front.name;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (mode !== 'live') {
|
|
86
|
+
bridge = createPreviewBridge(window as never, config.console.origins, {
|
|
87
|
+
load: (front, page, m, theme, options) => app.loadPreview(front, page, m, theme, options),
|
|
88
|
+
page: (page) => app.showPage(page),
|
|
89
|
+
theme: (theme) => app.setTheme(theme),
|
|
90
|
+
});
|
|
91
|
+
// Taille rendue de la page, pour que le canevas cadre l'aperçu
|
|
92
|
+
const report = () => {
|
|
93
|
+
const s = app.state();
|
|
94
|
+
if (s.page) bridge!.rendered(s.page.id, document.documentElement.scrollWidth, document.documentElement.scrollHeight);
|
|
95
|
+
};
|
|
96
|
+
new ResizeObserver(report).observe(document.body);
|
|
97
|
+
app.subscribe(() => requestAnimationFrame(report));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await app.start();
|
|
101
|
+
const vue = createApp(PoadFrontView, { app, lang: langOf(navigator.languages) });
|
|
102
|
+
vue.config.errorHandler = (err) => logger.error(`erreur de rendu : ${(err as Error)?.message ?? String(err)}`, { event: 'app_render_error' });
|
|
103
|
+
vue.mount(opts.el);
|
|
104
|
+
bridge?.ready();
|
|
105
|
+
logger.info(mode === 'live' ? 'front démarré' : `aperçu démarré (${mode})`, { event: 'app_boot', attrs: { mode, version: config.published?.version ?? null } });
|
|
106
|
+
return { app, vue };
|
|
107
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <PoadFrontView :app="app" lang="fr" />
|
|
3
|
+
*
|
|
4
|
+
* Le rendu Vue d'un front : il dessine l'état du cœur (@poadio/app-core, `createFrontApp`) et lui renvoie les
|
|
5
|
+
* gestes (navigation, connexion, déconnexion). Aucune logique ici : ce qui décide (page, connexion exigée, page
|
|
6
|
+
* introuvable, front pas encore publié) est dans le cœur, testé sans navigateur. Composants de @poadio/ui-vue,
|
|
7
|
+
* styles de @poadio/ui-core (+ `app-vue.css`), clair et sombre par `.theme-dark` / `.theme-light` sur la racine.
|
|
8
|
+
*/
|
|
9
|
+
import { computed, defineComponent, h, onBeforeUnmount, ref, shallowRef, type PropType, type VNode } from 'vue';
|
|
10
|
+
import type { AppState, FrontApp, Page, Section } from '@poadio/app-core';
|
|
11
|
+
import { PoadButton, PoadField, PoadInput, PoadMessage, PoadTag, sectionComponent } from './lazy.js';
|
|
12
|
+
import { translator, type Lang, type MessageKey } from './messages.js';
|
|
13
|
+
|
|
14
|
+
type T = (k: MessageKey) => string;
|
|
15
|
+
|
|
16
|
+
const panel = (t: T, title: MessageKey, text: MessageKey, extra: VNode[] = []) =>
|
|
17
|
+
h('div', { class: 'poad-front__center' }, [
|
|
18
|
+
h('div', { class: 'poad-front__panel' }, [h('h1', { class: 'poad-front__panel-title' }, t(title)), h('p', { class: 'poad-front__panel-text' }, t(text)), ...extra]),
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/** Une section : son module, chargé à la demande (lazy.ts) ; un type inconnu n'affiche rien */
|
|
22
|
+
const section = (t: T, s: Section, canvas: boolean) => {
|
|
23
|
+
const c = sectionComponent(s.type);
|
|
24
|
+
return c ? h(c, { key: s.id, section: s, t, canvas }) : null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const PoadFrontView = defineComponent({
|
|
28
|
+
name: 'PoadFrontView',
|
|
29
|
+
props: {
|
|
30
|
+
app: { type: Object as PropType<FrontApp>, required: true },
|
|
31
|
+
lang: { type: String as PropType<Lang>, default: 'fr' },
|
|
32
|
+
},
|
|
33
|
+
setup(props) {
|
|
34
|
+
const state = shallowRef<AppState>(props.app.state());
|
|
35
|
+
const off = props.app.subscribe((s) => (state.value = s));
|
|
36
|
+
onBeforeUnmount(off);
|
|
37
|
+
const t = computed(() => translator(props.lang));
|
|
38
|
+
const email = ref('');
|
|
39
|
+
const draftHidden = ref(false);
|
|
40
|
+
/** Lecture du brouillon : un petit bandeau discret, fermable, absent de la version publiée */
|
|
41
|
+
const draftBanner = () =>
|
|
42
|
+
state.value.draft && !draftHidden.value
|
|
43
|
+
? h('div', { class: 'poad-front__draft', role: 'status' }, [
|
|
44
|
+
h('span', { class: 'poad-front__draft-badge' }, t.value('draft.badge')),
|
|
45
|
+
h('span', { class: 'poad-front__draft-text' }, t.value('draft.text')),
|
|
46
|
+
h('button', { type: 'button', class: 'poad-front__draft-close', 'aria-label': t.value('draft.close'), onClick: () => (draftHidden.value = true) }, '×'),
|
|
47
|
+
])
|
|
48
|
+
: null;
|
|
49
|
+
const password = ref('');
|
|
50
|
+
|
|
51
|
+
const signInForm = () => {
|
|
52
|
+
const s = state.value;
|
|
53
|
+
const code = s.signIn.error;
|
|
54
|
+
return h('div', { class: 'poad-front__center' }, [
|
|
55
|
+
h(
|
|
56
|
+
'form',
|
|
57
|
+
{
|
|
58
|
+
class: 'poad-front__panel poad-front__signin',
|
|
59
|
+
novalidate: true,
|
|
60
|
+
onSubmit: (e: Event) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
void props.app.signIn(email.value, password.value).then(() => {
|
|
63
|
+
if (!props.app.state().signIn.error) password.value = '';
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
[
|
|
68
|
+
h('h1', { class: 'poad-front__panel-title' }, t.value('signin.title')),
|
|
69
|
+
h('p', { class: 'poad-front__panel-text' }, t.value('signin.text')),
|
|
70
|
+
code ? h(PoadMessage, { severity: 'danger', class: 'poad-front__signin-error', text: t.value(code === 'invalid_credentials' ? 'signin.invalid_credentials' : 'signin.error') }) : null,
|
|
71
|
+
h(PoadField, { label: t.value('signin.email') }, () =>
|
|
72
|
+
h(PoadInput, { type: 'email', autocomplete: 'username', modelValue: email.value, 'onUpdate:modelValue': (v: string | number) => (email.value = String(v)) }),
|
|
73
|
+
),
|
|
74
|
+
h(PoadField, { label: t.value('signin.password') }, () =>
|
|
75
|
+
h(PoadInput, { type: 'password', autocomplete: 'current-password', modelValue: password.value, 'onUpdate:modelValue': (v: string | number) => (password.value = String(v)) }),
|
|
76
|
+
),
|
|
77
|
+
h(PoadButton, { type: 'submit', severity: 'primary', block: true, loading: s.signIn.busy }, () => t.value('signin.submit')),
|
|
78
|
+
],
|
|
79
|
+
),
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const link = (p: Page, current: Page | null) =>
|
|
84
|
+
h(
|
|
85
|
+
'a',
|
|
86
|
+
{
|
|
87
|
+
class: ['poad-front__nav-link', current?.id === p.id && 'is-current'],
|
|
88
|
+
href: props.app.pathOf(p.id),
|
|
89
|
+
'aria-current': current?.id === p.id ? 'page' : undefined,
|
|
90
|
+
onClick: (e: MouseEvent) => {
|
|
91
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
props.app.navigate(p.id);
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
p.title,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const header = () => {
|
|
100
|
+
const s = state.value;
|
|
101
|
+
const front = s.front!;
|
|
102
|
+
return h('header', { class: 'poad-front__bar' }, [
|
|
103
|
+
h('a', { class: 'poad-front__brand', href: props.app.pathOf(front.home), onClick: (e: MouseEvent) => (e.preventDefault(), props.app.navigate(front.home)) }, front.name),
|
|
104
|
+
front.pages.length > 1 && !s.single ? h('nav', { class: 'poad-front__nav', 'aria-label': t.value('nav') }, front.pages.map((p) => link(p, s.page))) : h('span', { class: 'poad-front__spacer' }),
|
|
105
|
+
s.mode !== 'live'
|
|
106
|
+
// Aperçu de la console : un rappel discret de la règle d'accès de la page
|
|
107
|
+
? h(PoadTag, { size: 'sm', severity: s.authRequired ? 'warning' : 'success', value: t.value(s.authRequired ? (s.needsLogin ? 'badge.visitor' : 'badge.auth') : 'badge.public') })
|
|
108
|
+
: s.user
|
|
109
|
+
? h('div', { class: 'poad-front__user' }, [
|
|
110
|
+
s.user.email ? h('span', { class: 'poad-front__user-email' }, s.user.email) : null,
|
|
111
|
+
h(PoadButton, { size: 'sm', variant: 'outline', onClick: () => void props.app.signOut() }, () => t.value('signout')),
|
|
112
|
+
])
|
|
113
|
+
: null,
|
|
114
|
+
]);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return () => {
|
|
118
|
+
const s = state.value;
|
|
119
|
+
const tt = t.value;
|
|
120
|
+
const themeClass = s.theme ? `theme-${s.theme}` : null;
|
|
121
|
+
let body: VNode | VNode[];
|
|
122
|
+
if (s.status === 'loading' || s.status === 'waiting-preview') body = h('div', { class: 'poad-front__center poad-front__loading', role: 'status' }, tt('loading'));
|
|
123
|
+
else if (s.status === 'unpublished') body = panel(tt, 'unpublished.title', 'unpublished.text');
|
|
124
|
+
else if (s.status === 'error') body = panel(tt, 'error.title', 'error.text');
|
|
125
|
+
else if (s.status === 'not-found')
|
|
126
|
+
body = [header(), panel(tt, 'notfound.title', 'notfound.text', [h(PoadButton, { variant: 'outline', onClick: () => props.app.navigate(s.front!.home) }, () => tt('notfound.home'))])];
|
|
127
|
+
else if (s.needsLogin) body = [header(), signInForm()];
|
|
128
|
+
else body = [header(), h('main', { class: 'poad-front__page', 'data-page': s.page!.id }, s.page!.sections.map((sec) => section(tt, sec, s.mode === 'canvas')))];
|
|
129
|
+
return h('div', { class: ['poad-front', themeClass, `is-${s.mode}`], 'data-status': s.status }, [draftBanner(), ...(Array.isArray(body) ? body : [body])]);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @poadio/app-vue : le rendu Vue des fronts dessinés dans poad, sur @poadio/app-core et @poadio/ui-vue.
|
|
2
|
+
export { PoadFrontView } from './front-view.js';
|
|
3
|
+
export { browserHistory, logSender, applyTheme, bootFront, type BootOptions } from './browser.js';
|
|
4
|
+
export { MESSAGES, langOf, translator, type Lang, type MessageKey } from './messages.js';
|
package/src/lazy.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Chargement à la demande : le moteur ne télécharge que ce que la page affichée emploie.
|
|
2
|
+
// - composants de @poadio/ui-vue : un module par composant (exports profonds @poadio/ui-vue/<composant>,
|
|
3
|
+
// ui-vue 0.10.0), chargé au premier rendu qui en a besoin (formulaire de connexion, badge du canevas…) ;
|
|
4
|
+
// - sections d'une page : un module par type de section présent dans la définition (SECTIONS).
|
|
5
|
+
// Le bundle du moteur (runtime/build.mjs, découpage en morceaux) en fait des fichiers à part : la page
|
|
6
|
+
// « En construction » ne charge ni le formulaire de connexion, ni les champs, ni les composants qu'elle n'a pas.
|
|
7
|
+
import { defineAsyncComponent, type Component } from 'vue';
|
|
8
|
+
import type { Page } from '@poadio/app-core';
|
|
9
|
+
|
|
10
|
+
const lazy = (load: () => Promise<Component>) => defineAsyncComponent({ loader: load, delay: 0 });
|
|
11
|
+
|
|
12
|
+
export const PoadButton = lazy(() => import('@poadio/ui-vue/button').then((m) => m.PoadButton));
|
|
13
|
+
export const PoadField = lazy(() => import('@poadio/ui-vue/field').then((m) => m.PoadField));
|
|
14
|
+
export const PoadInput = lazy(() => import('@poadio/ui-vue/field').then((m) => m.PoadInput));
|
|
15
|
+
export const PoadMessage = lazy(() => import('@poadio/ui-vue/message').then((m) => m.PoadMessage));
|
|
16
|
+
export const PoadTag = lazy(() => import('@poadio/ui-vue/tag').then((m) => m.PoadTag));
|
|
17
|
+
|
|
18
|
+
/** Un module par type de section : ajouter un type, c'est ajouter une ligne ici et son module dans sections/ */
|
|
19
|
+
export const SECTION_LOADERS: Record<string, () => Promise<Component>> = {
|
|
20
|
+
'under-construction': () => import('./sections/under-construction.js').then((m) => m.UnderConstructionSection),
|
|
21
|
+
grid: () => import('./sections/grid.js').then((m) => m.GridSection),
|
|
22
|
+
};
|
|
23
|
+
const sectionComponents = new Map<string, Component>();
|
|
24
|
+
export const sectionComponent = (type: string): Component | null => {
|
|
25
|
+
const load = SECTION_LOADERS[type];
|
|
26
|
+
if (!load) return null;
|
|
27
|
+
if (!sectionComponents.has(type)) sectionComponents.set(type, lazy(load));
|
|
28
|
+
return sectionComponents.get(type)!;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Types de section d'une page (sans doublon) : ce qu'il faut charger pour l'afficher */
|
|
32
|
+
export const sectionTypes = (page: Page | null | undefined): string[] => [...new Set((page?.sections ?? []).map((s) => s.type))];
|
|
33
|
+
|
|
34
|
+
/** Charge d'avance les modules d'une page (navigation, connexion demandée) ; les erreurs restent au rendu */
|
|
35
|
+
export const preloadPage = (page: Page | null | undefined, needsLogin = false): Promise<unknown> =>
|
|
36
|
+
Promise.allSettled([
|
|
37
|
+
...sectionTypes(page).map((t) => SECTION_LOADERS[t]?.()),
|
|
38
|
+
...(needsLogin ? [import('@poadio/ui-vue/field'), import('@poadio/ui-vue/button'), import('@poadio/ui-vue/message')] : []),
|
|
39
|
+
]);
|
package/src/messages.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Textes du moteur (français et anglais). La langue suit celle du navigateur ; le français par défaut.
|
|
2
|
+
export type Lang = 'fr' | 'en';
|
|
3
|
+
|
|
4
|
+
const FR = {
|
|
5
|
+
'loading': 'Chargement…',
|
|
6
|
+
'under.title': 'En construction',
|
|
7
|
+
'under.text': 'Ce front se prépare. Revenez bientôt.',
|
|
8
|
+
'under.project': 'Projet',
|
|
9
|
+
'unpublished.title': 'Pas encore publié',
|
|
10
|
+
'unpublished.text': 'Ce front existe mais n’a pas encore été publié depuis la console du projet.',
|
|
11
|
+
'notfound.title': 'Page introuvable',
|
|
12
|
+
'notfound.text': 'Cette adresse ne correspond à aucune page de ce front.',
|
|
13
|
+
'notfound.home': 'Revenir à l’accueil',
|
|
14
|
+
'error.title': 'Ce front ne peut pas s’afficher',
|
|
15
|
+
'error.text': 'Sa configuration est illisible. L’erreur a été enregistrée dans les journaux du projet.',
|
|
16
|
+
'signin.title': 'Connexion',
|
|
17
|
+
'signin.text': 'Cette page est réservée aux utilisateurs du projet.',
|
|
18
|
+
'signin.email': 'Adresse e-mail',
|
|
19
|
+
'signin.password': 'Mot de passe',
|
|
20
|
+
'signin.submit': 'Se connecter',
|
|
21
|
+
'signin.invalid_credentials': 'Adresse e-mail ou mot de passe incorrect.',
|
|
22
|
+
'signin.error': 'La connexion a échoué. Réessayez.',
|
|
23
|
+
'signout': 'Se déconnecter',
|
|
24
|
+
'signin.link': 'Se connecter',
|
|
25
|
+
'badge.auth': 'Membres',
|
|
26
|
+
'badge.public': 'Public',
|
|
27
|
+
'badge.visitor': 'Vu comme visiteur',
|
|
28
|
+
'grid.empty': 'Grille vide : les composants se poseront ici.',
|
|
29
|
+
'grid.empty.live': 'Cette page est encore vide.',
|
|
30
|
+
'nav': 'Pages du front',
|
|
31
|
+
'draft.badge': 'Brouillon',
|
|
32
|
+
'draft.text': 'Vous voyez le brouillon, pas la version en ligne.',
|
|
33
|
+
'draft.close': 'Masquer',
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export type MessageKey = keyof typeof FR;
|
|
37
|
+
|
|
38
|
+
const EN: Record<MessageKey, string> = {
|
|
39
|
+
'loading': 'Loading…',
|
|
40
|
+
'under.title': 'Under construction',
|
|
41
|
+
'under.text': 'This front is being prepared. Come back soon.',
|
|
42
|
+
'under.project': 'Project',
|
|
43
|
+
'unpublished.title': 'Not published yet',
|
|
44
|
+
'unpublished.text': 'This front exists but has not been published from the project console yet.',
|
|
45
|
+
'notfound.title': 'Page not found',
|
|
46
|
+
'notfound.text': 'This address matches no page of this front.',
|
|
47
|
+
'notfound.home': 'Back to the home page',
|
|
48
|
+
'error.title': 'This front cannot be shown',
|
|
49
|
+
'error.text': 'Its configuration cannot be read. The error was recorded in the project logs.',
|
|
50
|
+
'signin.title': 'Sign in',
|
|
51
|
+
'signin.text': 'This page is reserved for the project users.',
|
|
52
|
+
'signin.email': 'Email address',
|
|
53
|
+
'signin.password': 'Password',
|
|
54
|
+
'signin.submit': 'Sign in',
|
|
55
|
+
'signin.invalid_credentials': 'Wrong email address or password.',
|
|
56
|
+
'signin.error': 'Sign-in failed. Try again.',
|
|
57
|
+
'signout': 'Sign out',
|
|
58
|
+
'signin.link': 'Sign in',
|
|
59
|
+
'badge.auth': 'Members',
|
|
60
|
+
'badge.public': 'Public',
|
|
61
|
+
'badge.visitor': 'Seen as a visitor',
|
|
62
|
+
'grid.empty': 'Empty grid: components will be placed here.',
|
|
63
|
+
'grid.empty.live': 'This page is still empty.',
|
|
64
|
+
'nav': 'Front pages',
|
|
65
|
+
'draft.badge': 'Draft',
|
|
66
|
+
'draft.text': 'You are seeing the draft, not the online version.',
|
|
67
|
+
'draft.close': 'Hide',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const MESSAGES: Record<Lang, Record<MessageKey, string>> = { fr: FR, en: EN };
|
|
71
|
+
|
|
72
|
+
export const langOf = (languages: readonly string[] | undefined): Lang => (languages?.[0]?.toLowerCase().startsWith('en') ? 'en' : 'fr');
|
|
73
|
+
|
|
74
|
+
export const translator = (lang: Lang) => (key: MessageKey) => MESSAGES[lang][key];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Section grille (24 colonnes) : vide à cette étape ; le canevas montre où les composants se poseront.
|
|
2
|
+
import { defineComponent, h, type PropType } from 'vue';
|
|
3
|
+
import type { GridSection as Section } from '@poadio/app-core';
|
|
4
|
+
import type { MessageKey } from '../messages.js';
|
|
5
|
+
|
|
6
|
+
export const GridSection = defineComponent({
|
|
7
|
+
name: 'PoadFrontGrid',
|
|
8
|
+
props: {
|
|
9
|
+
section: { type: Object as PropType<Section>, required: true },
|
|
10
|
+
t: { type: Function as PropType<(k: MessageKey) => string>, required: true },
|
|
11
|
+
canvas: Boolean,
|
|
12
|
+
},
|
|
13
|
+
setup(props) {
|
|
14
|
+
return () => {
|
|
15
|
+
const s = props.section;
|
|
16
|
+
return h('section', { class: ['poad-front__grid', props.canvas && 'is-canvas'], 'data-section': s.id, style: { '--poad-front-row': `${s.rowHeight}px` } }, [
|
|
17
|
+
s.items.length === 0 ? h('p', { class: 'poad-front__grid-empty' }, props.t(props.canvas ? 'grid.empty' : 'grid.empty.live')) : null,
|
|
18
|
+
]);
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Section « En construction » : nom du front, message, nom du projet. Aucun composant de @poadio/ui-vue.
|
|
2
|
+
import { defineComponent, h, type PropType } from 'vue';
|
|
3
|
+
import type { UnderConstructionSection as Section } from '@poadio/app-core';
|
|
4
|
+
import type { MessageKey } from '../messages.js';
|
|
5
|
+
|
|
6
|
+
export const UnderConstructionSection = defineComponent({
|
|
7
|
+
name: 'PoadFrontUnderConstruction',
|
|
8
|
+
props: {
|
|
9
|
+
section: { type: Object as PropType<Section>, required: true },
|
|
10
|
+
t: { type: Function as PropType<(k: MessageKey) => string>, required: true },
|
|
11
|
+
},
|
|
12
|
+
setup(props) {
|
|
13
|
+
return () => {
|
|
14
|
+
const s = props.section;
|
|
15
|
+
const t = props.t;
|
|
16
|
+
return h('section', { class: 'poad-front__under', 'data-section': s.id }, [
|
|
17
|
+
h('div', { class: 'poad-front__under-mark', 'aria-hidden': 'true' }, [
|
|
18
|
+
// Une grue stylisée : trait seul, couleur du thème
|
|
19
|
+
h('svg', { viewBox: '0 0 64 64', width: 64, height: 64, fill: 'none', stroke: 'currentColor', 'stroke-width': 2.5, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' }, [
|
|
20
|
+
h('path', { d: 'M14 58V10l-6 8h44' }),
|
|
21
|
+
h('path', { d: 'M14 10l38 8' }),
|
|
22
|
+
h('path', { d: 'M44 18v14' }),
|
|
23
|
+
h('rect', { x: 38, y: 32, width: 12, height: 9, rx: 1.5 }),
|
|
24
|
+
h('path', { d: 'M6 58h20' }),
|
|
25
|
+
]),
|
|
26
|
+
]),
|
|
27
|
+
h('h1', { class: 'poad-front__under-title' }, t('under.title')),
|
|
28
|
+
s.props.front ? h('p', { class: 'poad-front__under-front' }, s.props.front) : null,
|
|
29
|
+
h('p', { class: 'poad-front__under-text' }, s.props.message || t('under.text')),
|
|
30
|
+
s.props.project ? h('p', { class: 'poad-front__under-project' }, [h('span', { class: 'poad-front__under-label' }, `${t('under.project')} `), h('strong', null, s.props.project)]) : null,
|
|
31
|
+
]);
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|