@poadio/app-vue 0.0.0-stage → 0.2.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 +44 -0
- package/LICENSE +22 -0
- package/README.md +16 -2
- package/app-vue.css +181 -0
- package/dist/browser.d.ts +23 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +112 -0
- package/dist/browser.js.map +1 -0
- package/dist/draft-toolbar.d.ts +65 -0
- package/dist/draft-toolbar.d.ts.map +1 -0
- package/dist/draft-toolbar.js +62 -0
- package/dist/draft-toolbar.js.map +1 -0
- package/dist/front-view.d.ts +39 -0
- package/dist/front-view.d.ts.map +1 -0
- package/dist/front-view.js +174 -0
- package/dist/front-view.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/items.d.ts +33 -0
- package/dist/items.d.ts.map +1 -0
- package/dist/items.js +369 -0
- package/dist/items.js.map +1 -0
- package/dist/lazy.d.ts +56 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/lazy.js +68 -0
- package/dist/lazy.js.map +1 -0
- package/dist/messages.d.ts +56 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +102 -0
- package/dist/messages.js.map +1 -0
- package/dist/sections/grid.d.ts +53 -0
- package/dist/sections/grid.d.ts.map +1 -0
- package/dist/sections/grid.js +46 -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 +72 -4
- package/runtime-dist/app.css +535 -0
- package/runtime-dist/app.js +2 -0
- package/runtime-dist/c-0rxdxcn3.js +2 -0
- package/runtime-dist/c-0vbs937h.js +18 -0
- package/runtime-dist/c-0zqjsnm5.js +2 -0
- package/runtime-dist/c-13nx24wa.js +1 -0
- package/runtime-dist/c-16cdkp27.js +1 -0
- package/runtime-dist/c-16cm3n82.js +1 -0
- package/runtime-dist/c-1h49vkah.js +2 -0
- package/runtime-dist/c-1xpa1fqz.js +1 -0
- package/runtime-dist/c-29v2e09p.js +1 -0
- package/runtime-dist/c-2ag31260.js +2 -0
- package/runtime-dist/c-2s6r37jb.js +1 -0
- package/runtime-dist/c-2v244yc0.js +1 -0
- package/runtime-dist/c-3be398px.js +1 -0
- package/runtime-dist/c-3jm96b1p.js +2 -0
- package/runtime-dist/c-3pe5hprv.js +2 -0
- package/runtime-dist/c-3zbf5g3p.js +1 -0
- package/runtime-dist/c-4h51m4qq.js +1 -0
- package/runtime-dist/c-523qwqen.js +2 -0
- package/runtime-dist/c-572jz6y4.js +1 -0
- package/runtime-dist/c-64j9mv7a.js +1 -0
- package/runtime-dist/c-6f446pxt.js +1 -0
- package/runtime-dist/c-6pd33f4a.js +1 -0
- package/runtime-dist/c-6qa26wds.js +1 -0
- package/runtime-dist/c-6w0f1kqm.js +1 -0
- package/runtime-dist/c-72hj12cs.js +2 -0
- package/runtime-dist/c-7cjj18ea.js +1 -0
- package/runtime-dist/c-823yyjat.js +1 -0
- package/runtime-dist/c-8gpbevx2.js +1 -0
- package/runtime-dist/c-98tbntdq.js +2 -0
- package/runtime-dist/c-9sm6aybf.js +2 -0
- package/runtime-dist/c-a63rkaa9.js +1 -0
- package/runtime-dist/c-ahcj5yr5.js +1 -0
- package/runtime-dist/c-azvw5879.js +2 -0
- package/runtime-dist/c-b6g9ey7e.js +2 -0
- package/runtime-dist/c-bssc8kwn.js +1 -0
- package/runtime-dist/c-bvp9zbmr.js +1 -0
- package/runtime-dist/c-cc3m3rs1.js +2 -0
- package/runtime-dist/c-cp1ehb23.js +1 -0
- package/runtime-dist/c-cvsx6n6e.js +2 -0
- package/runtime-dist/c-d5y90g8f.js +1 -0
- package/runtime-dist/c-d8hfdner.js +2 -0
- package/runtime-dist/c-dqtdk937.js +1 -0
- package/runtime-dist/c-dzx0rg0g.js +2 -0
- package/runtime-dist/c-eczfywaq.js +1 -0
- package/runtime-dist/c-epemgj1a.js +2 -0
- package/runtime-dist/c-et83hbhc.js +1 -0
- package/runtime-dist/c-ffkh15py.js +1 -0
- package/runtime-dist/c-fn3059s1.js +2 -0
- package/runtime-dist/c-fnzeden9.js +1 -0
- package/runtime-dist/c-gen0a4bn.js +1 -0
- package/runtime-dist/c-gesjk5ph.js +1 -0
- package/runtime-dist/c-gkyekesy.js +15 -0
- package/runtime-dist/c-gs1k0twe.js +2 -0
- package/runtime-dist/c-gznx0sj4.js +2 -0
- package/runtime-dist/c-h5m94fwp.js +1 -0
- package/runtime-dist/c-hdstjg33.js +2 -0
- package/runtime-dist/c-hsy77frc.js +3 -0
- package/runtime-dist/c-j02ymtyd.js +2 -0
- package/runtime-dist/c-j63hz554.js +2 -0
- package/runtime-dist/c-jvrr9zb8.js +1 -0
- package/runtime-dist/c-jymrpj5m.js +1 -0
- package/runtime-dist/c-k624qrhh.js +2 -0
- package/runtime-dist/c-kbg0cafy.js +2 -0
- package/runtime-dist/c-kmx0mv0c.js +2 -0
- package/runtime-dist/c-krt6rpg1.js +1 -0
- package/runtime-dist/c-kyajr8zz.js +2 -0
- package/runtime-dist/c-m30q0jrb.js +1 -0
- package/runtime-dist/c-m49q9r7s.js +1 -0
- package/runtime-dist/c-m6yf7zaj.js +2 -0
- package/runtime-dist/c-m70tbfc5.js +2 -0
- package/runtime-dist/c-mdj990nz.js +2 -0
- package/runtime-dist/c-mvdn43tv.js +2 -0
- package/runtime-dist/c-mw3zx9yk.js +1 -0
- package/runtime-dist/c-n8mqnvjg.js +1 -0
- package/runtime-dist/c-nkrm4n9a.js +1 -0
- package/runtime-dist/c-nn49946s.js +1 -0
- package/runtime-dist/c-ny0mdx7k.js +2 -0
- package/runtime-dist/c-p8wyhrwm.js +2 -0
- package/runtime-dist/c-pbn2syef.js +1 -0
- package/runtime-dist/c-prt5qv2x.js +1 -0
- package/runtime-dist/c-qe1kevqk.js +1 -0
- package/runtime-dist/c-rasvf2z2.js +2 -0
- package/runtime-dist/c-rf1xevya.js +1 -0
- package/runtime-dist/c-rktc0ksd.js +2 -0
- package/runtime-dist/c-sd570jk7.js +2 -0
- package/runtime-dist/c-sdf15np5.js +1 -0
- package/runtime-dist/c-sjajadt4.js +2 -0
- package/runtime-dist/c-sv15z0aa.js +1 -0
- package/runtime-dist/c-tv3ksk7j.js +2 -0
- package/runtime-dist/c-vrmw0gka.js +1 -0
- package/runtime-dist/c-wjadf68q.js +1 -0
- package/runtime-dist/c-wnynh7zm.js +1 -0
- package/runtime-dist/c-xeqwqt9z.js +2 -0
- package/runtime-dist/c-xk9fqzsc.js +1 -0
- package/runtime-dist/c-xqf3j4w7.js +1 -0
- package/runtime-dist/c-xx4986kx.js +1 -0
- package/runtime-dist/c-y9120d6h.js +1 -0
- package/runtime-dist/c-ywzh0r63.js +1 -0
- package/runtime-dist/c-zyfkspym.js +2 -0
- package/runtime-dist/index.html +14 -0
- package/runtime-dist/ui-accordion.css +29 -0
- package/runtime-dist/ui-app-shell.css +36 -0
- package/runtime-dist/ui-avatar.css +28 -0
- package/runtime-dist/ui-badge.css +14 -0
- package/runtime-dist/ui-block-editor.css +85 -0
- package/runtime-dist/ui-block-view.css +50 -0
- package/runtime-dist/ui-block.css +20 -0
- package/runtime-dist/ui-bottom-nav.css +54 -0
- package/runtime-dist/ui-breadcrumb.css +25 -0
- package/runtime-dist/ui-button-group.css +39 -0
- package/runtime-dist/ui-calendar.css +168 -0
- package/runtime-dist/ui-card.css +26 -0
- package/runtime-dist/ui-carousel.css +35 -0
- package/runtime-dist/ui-chart.css +26 -0
- package/runtime-dist/ui-checkbox.css +25 -0
- package/runtime-dist/ui-chip.css +30 -0
- package/runtime-dist/ui-code-editor.css +25 -0
- package/runtime-dist/ui-colorpicker.css +46 -0
- package/runtime-dist/ui-combo.css +43 -0
- package/runtime-dist/ui-dataview.css +50 -0
- package/runtime-dist/ui-datepicker.css +80 -0
- package/runtime-dist/ui-dialog.css +119 -0
- package/runtime-dist/ui-divider.css +18 -0
- package/runtime-dist/ui-fieldset.css +25 -0
- package/runtime-dist/ui-filter-chip.css +24 -0
- package/runtime-dist/ui-floating.css +9 -0
- package/runtime-dist/ui-gantt.css +105 -0
- package/runtime-dist/ui-image.css +34 -0
- package/runtime-dist/ui-inplace.css +19 -0
- package/runtime-dist/ui-json-editor.css +40 -0
- package/runtime-dist/ui-layout.css +39 -0
- package/runtime-dist/ui-listbox.css +52 -0
- package/runtime-dist/ui-map.css +469 -0
- package/runtime-dist/ui-menu.css +38 -0
- package/runtime-dist/ui-menubar.css +55 -0
- package/runtime-dist/ui-meter.css +26 -0
- package/runtime-dist/ui-multiselect.css +62 -0
- package/runtime-dist/ui-nav-drawer.css +118 -0
- package/runtime-dist/ui-number.css +26 -0
- package/runtime-dist/ui-option-list.css +28 -0
- package/runtime-dist/ui-orderlist.css +54 -0
- package/runtime-dist/ui-orgchart.css +71 -0
- package/runtime-dist/ui-paginator.css +25 -0
- package/runtime-dist/ui-panel.css +28 -0
- package/runtime-dist/ui-password.css +26 -0
- package/runtime-dist/ui-picklist.css +58 -0
- package/runtime-dist/ui-popover.css +20 -0
- package/runtime-dist/ui-progress.css +31 -0
- package/runtime-dist/ui-radio.css +29 -0
- package/runtime-dist/ui-rating.css +19 -0
- package/runtime-dist/ui-richtext.css +48 -0
- package/runtime-dist/ui-scheduler.css +132 -0
- package/runtime-dist/ui-scroll-top.css +17 -0
- package/runtime-dist/ui-segmented.css +25 -0
- package/runtime-dist/ui-select.css +47 -0
- package/runtime-dist/ui-sheet.css +56 -0
- package/runtime-dist/ui-skeleton.css +18 -0
- package/runtime-dist/ui-slider.css +59 -0
- package/runtime-dist/ui-speed-dial.css +26 -0
- package/runtime-dist/ui-splitter.css +23 -0
- package/runtime-dist/ui-stepper.css +47 -0
- package/runtime-dist/ui-switch.css +31 -0
- package/runtime-dist/ui-table-panel.css +114 -0
- package/runtime-dist/ui-table.css +430 -0
- package/runtime-dist/ui-tabs.css +45 -0
- package/runtime-dist/ui-taskboard.css +104 -0
- package/runtime-dist/ui-timeline.css +44 -0
- package/runtime-dist/ui-toast.css +43 -0
- package/runtime-dist/ui-toggle-button.css +6 -0
- package/runtime-dist/ui-tooltip.css +21 -0
- package/runtime-dist/ui-tree.css +44 -0
- package/runtime-dist/ui-upload.css +46 -0
- package/runtime-dist/version.json +1 -0
- package/src/browser.ts +126 -0
- package/src/draft-toolbar.ts +67 -0
- package/src/front-view.ts +186 -0
- package/src/index.ts +5 -0
- package/src/items.ts +436 -0
- package/src/lazy.ts +76 -0
- package/src/messages.ts +110 -0
- package/src/sections/grid.ts +56 -0
- package/src/sections/under-construction.ts +34 -0
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
* Aucune barre automatique : une page ne montre que ce qui a été dessiné dessus. Naviguer entre les pages, c'est
|
|
10
|
+
* poser un composant de navigation (barre de menu, barre mobile : les pages du front par défaut) ; le nom du front
|
|
11
|
+
* et de la page restent dans le titre de l'onglet. Une page réservée sans session montre l'écran de connexion seul.
|
|
12
|
+
*/
|
|
13
|
+
import { computed, defineComponent, h, onBeforeUnmount, ref, shallowRef, watch, type PropType, type VNode } from 'vue';
|
|
14
|
+
import {
|
|
15
|
+
DRAFT_TOOLBAR_DEFAULT, draftFrameWidth, draftToolbarKey, draftToolbarLog, draftToolbarReduce, readDraftToolbar, writeDraftToolbar,
|
|
16
|
+
type AppState, type DraftToolbarAction, type DraftToolbarState, type FrontApp, type FrontLogger, type Section,
|
|
17
|
+
} from '@poadio/app-core';
|
|
18
|
+
import { DraftToolbar } from './draft-toolbar.js';
|
|
19
|
+
import { PoadButton, PoadField, PoadInput, PoadMessage, sectionComponent } from './lazy.js';
|
|
20
|
+
import type { FrontNav } from './items.js';
|
|
21
|
+
import { translator, type Lang, type MessageKey } from './messages.js';
|
|
22
|
+
|
|
23
|
+
type T = (k: MessageKey) => string;
|
|
24
|
+
|
|
25
|
+
const panel = (t: T, title: MessageKey, text: MessageKey, extra: VNode[] = []) =>
|
|
26
|
+
h('div', { class: 'poad-front__center' }, [
|
|
27
|
+
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]),
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
/** Une section : son module, chargé à la demande (lazy.ts) ; un type inconnu n'affiche rien */
|
|
31
|
+
const section = (t: T, s: Section, canvas: boolean, log: FrontLogger, nav: FrontNav | null) => {
|
|
32
|
+
const c = sectionComponent(s.type);
|
|
33
|
+
return c ? h(c, { key: s.id, section: s, t, canvas, ...(s.type === 'grid' ? { log, nav } : {}) }) : null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const PoadFrontView = defineComponent({
|
|
37
|
+
name: 'PoadFrontView',
|
|
38
|
+
props: {
|
|
39
|
+
app: { type: Object as PropType<FrontApp>, required: true },
|
|
40
|
+
lang: { type: String as PropType<Lang>, default: 'fr' },
|
|
41
|
+
},
|
|
42
|
+
setup(props) {
|
|
43
|
+
const state = shallowRef<AppState>(props.app.state());
|
|
44
|
+
const off = props.app.subscribe((s) => (state.value = s));
|
|
45
|
+
onBeforeUnmount(off);
|
|
46
|
+
const t = computed(() => translator(props.lang));
|
|
47
|
+
const email = ref('');
|
|
48
|
+
// ---- Lecture du brouillon : la barre du brouillon (état et règles dans app-core, draft-toolbar.ts)
|
|
49
|
+
const storage = (): Storage | null => {
|
|
50
|
+
try {
|
|
51
|
+
return typeof window !== 'undefined' ? window.sessionStorage : null;
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const draftUi = ref<DraftToolbarState>(DRAFT_TOOLBAR_DEFAULT);
|
|
57
|
+
let draftLoaded = '';
|
|
58
|
+
const width = ref(typeof window !== 'undefined' ? window.innerWidth : 1280);
|
|
59
|
+
const onResize = () => (width.value = window.innerWidth);
|
|
60
|
+
if (typeof window !== 'undefined') window.addEventListener('resize', onResize);
|
|
61
|
+
onBeforeUnmount(() => typeof window !== 'undefined' && window.removeEventListener('resize', onResize));
|
|
62
|
+
/** Thème affiché : celui du front (barre, aperçu), sinon celui du système */
|
|
63
|
+
const isDark = () => {
|
|
64
|
+
const th = state.value.theme;
|
|
65
|
+
if (th) return th === 'dark';
|
|
66
|
+
return typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-color-scheme: dark)').matches;
|
|
67
|
+
};
|
|
68
|
+
// L'état de l'onglet se relit quand le brouillon s'affiche ; son thème s'applique
|
|
69
|
+
watch(
|
|
70
|
+
() => (state.value.draft && state.value.front ? state.value.front.id : ''),
|
|
71
|
+
(id) => {
|
|
72
|
+
if (!id || draftLoaded === id) return;
|
|
73
|
+
draftLoaded = id;
|
|
74
|
+
let raw: string | null = null;
|
|
75
|
+
try {
|
|
76
|
+
raw = storage()?.getItem(draftToolbarKey(id)) ?? null;
|
|
77
|
+
} catch {
|
|
78
|
+
/* rien de gardé */
|
|
79
|
+
}
|
|
80
|
+
draftUi.value = readDraftToolbar(raw);
|
|
81
|
+
if (draftUi.value.theme) props.app.setTheme(draftUi.value.theme);
|
|
82
|
+
},
|
|
83
|
+
{ immediate: true },
|
|
84
|
+
);
|
|
85
|
+
const draftAct = (a: DraftToolbarAction) => {
|
|
86
|
+
const front = state.value.front;
|
|
87
|
+
if (!front) return;
|
|
88
|
+
draftUi.value = draftToolbarReduce(draftUi.value, a);
|
|
89
|
+
try {
|
|
90
|
+
storage()?.setItem(draftToolbarKey(front.id), writeDraftToolbar(draftUi.value));
|
|
91
|
+
} catch {
|
|
92
|
+
/* gardé pour cet affichage seulement */
|
|
93
|
+
}
|
|
94
|
+
const line = draftToolbarLog(a);
|
|
95
|
+
props.app.log.info(line.msg, { event: 'app_draft_toolbar', attrs: line.attrs });
|
|
96
|
+
if (a.type === 'theme') props.app.setTheme(a.theme);
|
|
97
|
+
else if (a.type === 'page') props.app.navigate(a.page);
|
|
98
|
+
else if (a.type === 'reload') {
|
|
99
|
+
// Le cookie de lecture reste : le rechargement montre le dernier brouillon enregistré
|
|
100
|
+
props.app.log.flush(true);
|
|
101
|
+
window.location.reload();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Largeur où contenir la page (taille d'écran choisie dans la barre) ; null : toute la fenêtre */
|
|
105
|
+
const frame = computed(() => (state.value.draft && !draftUi.value.closed ? draftFrameWidth(draftUi.value.device, width.value) : null));
|
|
106
|
+
const draftBar = () =>
|
|
107
|
+
state.value.draft && state.value.front
|
|
108
|
+
? h(DraftToolbar, {
|
|
109
|
+
state: draftUi.value,
|
|
110
|
+
t: t.value,
|
|
111
|
+
dark: isDark(),
|
|
112
|
+
pages: state.value.front.pages.map((p) => ({ id: p.id, title: p.title })),
|
|
113
|
+
current: state.value.page?.id ?? null,
|
|
114
|
+
onAct: draftAct,
|
|
115
|
+
})
|
|
116
|
+
: null;
|
|
117
|
+
const password = ref('');
|
|
118
|
+
|
|
119
|
+
const signInForm = () => {
|
|
120
|
+
const s = state.value;
|
|
121
|
+
const code = s.signIn.error;
|
|
122
|
+
return h('div', { class: 'poad-front__center' }, [
|
|
123
|
+
h(
|
|
124
|
+
'form',
|
|
125
|
+
{
|
|
126
|
+
class: 'poad-front__panel poad-front__signin',
|
|
127
|
+
novalidate: true,
|
|
128
|
+
onSubmit: (e: Event) => {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
void props.app.signIn(email.value, password.value).then(() => {
|
|
131
|
+
if (!props.app.state().signIn.error) password.value = '';
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
[
|
|
136
|
+
h('h1', { class: 'poad-front__panel-title' }, t.value('signin.title')),
|
|
137
|
+
h('p', { class: 'poad-front__panel-text' }, t.value('signin.text')),
|
|
138
|
+
code ? h(PoadMessage, { severity: 'danger', class: 'poad-front__signin-error', text: t.value(code === 'invalid_credentials' ? 'signin.invalid_credentials' : 'signin.error') }) : null,
|
|
139
|
+
h(PoadField, { label: t.value('signin.email') }, () =>
|
|
140
|
+
h(PoadInput, { type: 'email', autocomplete: 'username', modelValue: email.value, 'onUpdate:modelValue': (v: string | number) => (email.value = String(v)) }),
|
|
141
|
+
),
|
|
142
|
+
h(PoadField, { label: t.value('signin.password') }, () =>
|
|
143
|
+
h(PoadInput, { type: 'password', autocomplete: 'current-password', modelValue: password.value, 'onUpdate:modelValue': (v: string | number) => (password.value = String(v)) }),
|
|
144
|
+
),
|
|
145
|
+
h(PoadButton, { type: 'submit', severity: 'primary', block: true, loading: s.signIn.busy }, () => t.value('signin.submit')),
|
|
146
|
+
],
|
|
147
|
+
),
|
|
148
|
+
]);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** Navigation entre pages : ce que posent les composants de navigation (barre de menu…) ; aucune barre automatique */
|
|
152
|
+
const nav = computed<FrontNav | null>(() => {
|
|
153
|
+
const st = state.value;
|
|
154
|
+
if (!st.front) return null;
|
|
155
|
+
const front = st.front;
|
|
156
|
+
return {
|
|
157
|
+
pages: front.pages.map((p) => ({ id: p.id, title: p.title, path: p.path })),
|
|
158
|
+
current: st.page?.id ?? null,
|
|
159
|
+
href: (id: string) => props.app.pathOf(id),
|
|
160
|
+
go: (id: string) => props.app.navigate(id),
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return () => {
|
|
165
|
+
const s = state.value;
|
|
166
|
+
const tt = t.value;
|
|
167
|
+
const themeClass = s.theme ? `theme-${s.theme}` : null;
|
|
168
|
+
let body: VNode | VNode[];
|
|
169
|
+
if (s.status === 'loading' || s.status === 'waiting-preview') body = h('div', { class: 'poad-front__center poad-front__loading', role: 'status' }, tt('loading'));
|
|
170
|
+
else if (s.status === 'unpublished') body = panel(tt, 'unpublished.title', 'unpublished.text');
|
|
171
|
+
else if (s.status === 'error') body = panel(tt, 'error.title', 'error.text');
|
|
172
|
+
else if (s.status === 'not-found')
|
|
173
|
+
body = panel(tt, 'notfound.title', 'notfound.text', [h(PoadButton, { variant: 'outline', onClick: () => props.app.navigate(s.front!.home) }, () => tt('notfound.home'))]);
|
|
174
|
+
// Connexion demandée : l'écran de connexion seul (la page n'a pas de barre ; se déconnecter viendra comme action)
|
|
175
|
+
else if (s.needsLogin) body = signInForm();
|
|
176
|
+
// La page : seulement ce qui a été dessiné dessus
|
|
177
|
+
else body = h('main', { class: 'poad-front__page', 'data-page': s.page!.id }, s.page!.sections.map((sec) => section(tt, sec, s.mode === 'canvas', props.app.log, nav.value)));
|
|
178
|
+
const fw = frame.value;
|
|
179
|
+
return h(
|
|
180
|
+
'div',
|
|
181
|
+
{ class: ['poad-front', themeClass, `is-${s.mode}`, fw && 'is-framed'], 'data-status': s.status, style: fw ? { '--poad-front-frame': `${fw}px` } : undefined },
|
|
182
|
+
[h('div', { class: 'poad-front__screen' }, Array.isArray(body) ? body : [body]), draftBar()],
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
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, gridLayouts, type BootOptions } from './browser.js';
|
|
4
|
+
export { ITEM_LOADERS, ITEM_STYLES, setStyleLoader, loadItemStyles, type ItemProps, type ItemContext } from './items.js';
|
|
5
|
+
export { MESSAGES, langOf, translator, type Lang, type MessageKey } from './messages.js';
|
package/src/items.ts
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
// Rendu des composants posés sur une grille : un chargeur par type du catalogue (@poadio/app-core, catalog.ts).
|
|
2
|
+
//
|
|
3
|
+
// Chaque chargeur n'importe QUE le module de @poadio/ui-vue dont son type a besoin (exports profonds
|
|
4
|
+
// @poadio/ui-vue/<composant>) : le bundle du moteur en fait un morceau à part, téléchargé la première fois qu'une page
|
|
5
|
+
// pose ce type. Les styles suivent le même chemin (ITEM_STYLES, chargés par `setStyleLoader`).
|
|
6
|
+
//
|
|
7
|
+
// Le rendu ne décide rien : il reçoit les props déjà résolues par le cœur (`resolveProps` : valeurs par défaut,
|
|
8
|
+
// valeurs invalides remplacées) et dessine. Les contrôles gardent une valeur locale (saisie, case cochée…) : la
|
|
9
|
+
// liaison aux tables du projet viendra avec le store @poadio/data.
|
|
10
|
+
import { defineComponent, h, mergeProps, ref, watch, withDirectives, type Component, type PropType, type Ref, type VNode } from 'vue';
|
|
11
|
+
import type { PropValue } from '@poadio/app-core';
|
|
12
|
+
import type { MessageKey } from './messages.js';
|
|
13
|
+
|
|
14
|
+
export type ItemProps = Record<string, PropValue>;
|
|
15
|
+
/** Les pages du front et le routeur du moteur : ce que les composants de navigation posés emploient */
|
|
16
|
+
export type FrontNav = {
|
|
17
|
+
pages: { id: string; title: string; path: string }[];
|
|
18
|
+
current: string | null;
|
|
19
|
+
href(id: string): string;
|
|
20
|
+
go(id: string): void;
|
|
21
|
+
};
|
|
22
|
+
export type ItemContext = { t: (k: MessageKey) => string; canvas: boolean; nav?: FrontNav | null };
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lien vers une page du front : une vraie adresse (<a href>, nouvel onglet possible), suivie par le routeur du
|
|
26
|
+
* moteur sans recharger. Passé aux composants de navigation de @poadio/ui-vue (`linkAs`).
|
|
27
|
+
*/
|
|
28
|
+
const navLinks = new WeakMap<FrontNav, Component>();
|
|
29
|
+
const frontLink = (nav: FrontNav): Component => {
|
|
30
|
+
let c = navLinks.get(nav);
|
|
31
|
+
if (!c) {
|
|
32
|
+
c = defineComponent({
|
|
33
|
+
name: 'PoadFrontLink',
|
|
34
|
+
inheritAttrs: false,
|
|
35
|
+
props: { to: { type: String, required: true } },
|
|
36
|
+
setup(props, { slots, attrs }) {
|
|
37
|
+
return () =>
|
|
38
|
+
h('a', mergeProps(attrs, {
|
|
39
|
+
href: props.to,
|
|
40
|
+
onClick: (e: MouseEvent) => {
|
|
41
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;
|
|
42
|
+
const page = nav.pages.find((p) => nav.href(p.id) === props.to);
|
|
43
|
+
if (!page) return;
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
nav.go(page.id);
|
|
46
|
+
},
|
|
47
|
+
}), slots['default']?.());
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
navLinks.set(nav, c);
|
|
51
|
+
}
|
|
52
|
+
return c;
|
|
53
|
+
};
|
|
54
|
+
/** Pages listées par un composant de navigation : celles du front (source « pages »), ou sa liste libre */
|
|
55
|
+
const fromPages = (p: ItemProps, ctx: ItemContext) => (str(p, 'source') !== 'custom' && ctx.nav ? ctx.nav : null);
|
|
56
|
+
|
|
57
|
+
const str = (p: ItemProps, k: string): string => (typeof p[k] === 'string' ? (p[k] as string) : '');
|
|
58
|
+
const num = (p: ItemProps, k: string): number => (typeof p[k] === 'number' ? (p[k] as number) : 0);
|
|
59
|
+
const bool = (p: ItemProps, k: string): boolean => p[k] === true;
|
|
60
|
+
const list = (p: ItemProps, k: string): string[] => (Array.isArray(p[k]) ? (p[k] as string[]).filter((s) => s.trim() !== '') : []);
|
|
61
|
+
const options = (p: ItemProps, k = 'options') => list(p, k).map((l) => ({ label: l, value: l }));
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* h() sans le typage strict des props de chaque composant : les valeurs viennent du catalogue (choix déjà vérifiés
|
|
65
|
+
* par `resolveProps`), un texte y vaut une des valeurs permises.
|
|
66
|
+
*/
|
|
67
|
+
const el = h as unknown as (type: unknown, props?: Record<string, unknown> | null, children?: unknown) => VNode;
|
|
68
|
+
|
|
69
|
+
const itemProps = { p: { type: Object as PropType<ItemProps>, required: true }, ctx: { type: Object as PropType<ItemContext>, required: true } } as const;
|
|
70
|
+
|
|
71
|
+
/** Un composant sans état : (props, contexte) → rendu */
|
|
72
|
+
const view = (name: string, render: (p: ItemProps, ctx: ItemContext) => VNode | null) =>
|
|
73
|
+
defineComponent({ name, props: itemProps, setup: (props) => () => render(props.p, props.ctx) });
|
|
74
|
+
|
|
75
|
+
/** Un composant avec une valeur locale (v-model), remise à sa valeur de départ quand les props changent */
|
|
76
|
+
const model = <T>(name: string, initial: (p: ItemProps) => T, render: (p: ItemProps, ctx: ItemContext, v: Ref<T>) => VNode | null) =>
|
|
77
|
+
defineComponent({
|
|
78
|
+
name,
|
|
79
|
+
props: itemProps,
|
|
80
|
+
setup(props) {
|
|
81
|
+
const v = ref(initial(props.p)) as Ref<T>;
|
|
82
|
+
watch(() => JSON.stringify(initial(props.p)), () => (v.value = initial(props.p)));
|
|
83
|
+
return () => render(props.p, props.ctx, v);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const bind = <T>(v: Ref<T>) => ({ modelValue: v.value, 'onUpdate:modelValue': (x: T) => (v.value = x) });
|
|
88
|
+
|
|
89
|
+
/** Texte d'un contenu de démonstration : « Contenu de « Onglet 1 ». » */
|
|
90
|
+
const contentOf = (ctx: ItemContext, name: string) => ctx.t('item.content').replace('{name}', name);
|
|
91
|
+
|
|
92
|
+
const ui = {
|
|
93
|
+
button: () => import('@poadio/ui-vue/button'),
|
|
94
|
+
field: () => import('@poadio/ui-vue/field'),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Libellé et contrôle, à la façon d'un champ de formulaire */
|
|
98
|
+
const labelled = async <T>(name: string, load: () => Promise<Component>, initial: (p: ItemProps) => T, extra: (p: ItemProps) => Record<string, unknown> = () => ({})) => {
|
|
99
|
+
const [{ PoadField }, control] = await Promise.all([ui.field(), load()]);
|
|
100
|
+
return model(name, initial, (p, _ctx, v) =>
|
|
101
|
+
el(PoadField, { label: str(p, 'label') || undefined, required: bool(p, 'required'), hint: str(p, 'hint') || undefined, bare: true }, () => el(control, { ...extra(p), ...bind(v) })),
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Un chargeur par type : rend le composant Vue qui dessine ce type */
|
|
106
|
+
export const ITEM_LOADERS: Record<string, () => Promise<Component>> = {
|
|
107
|
+
// ---------------------------------------------------------------- Mise en page
|
|
108
|
+
card: async () => {
|
|
109
|
+
const { PoadCard } = await import('@poadio/ui-vue/card');
|
|
110
|
+
return view('PoadItemCard', (p) => el(PoadCard, { header: str(p, 'header') || undefined, subheader: str(p, 'subheader') || undefined, class: 'poad-front__fill' }, () => h('p', { class: 'poad-front__body' }, str(p, 'body'))));
|
|
111
|
+
},
|
|
112
|
+
panel: async () => {
|
|
113
|
+
const { PoadPanel } = await import('@poadio/ui-vue/panel');
|
|
114
|
+
return view('PoadItemPanel', (p) => el(PoadPanel, { header: str(p, 'header') || undefined, toggleable: bool(p, 'toggleable'), class: 'poad-front__fill' }, () => h('p', { class: 'poad-front__body' }, str(p, 'body'))));
|
|
115
|
+
},
|
|
116
|
+
fieldset: async () => {
|
|
117
|
+
const { PoadFieldset } = await import('@poadio/ui-vue/fieldset');
|
|
118
|
+
return view('PoadItemFieldset', (p) => el(PoadFieldset, { legend: str(p, 'legend') || undefined, toggleable: bool(p, 'toggleable'), class: 'poad-front__fill' }, () => h('p', { class: 'poad-front__body' }, str(p, 'body'))));
|
|
119
|
+
},
|
|
120
|
+
divider: async () => {
|
|
121
|
+
const { PoadDivider } = await import('@poadio/ui-vue/divider');
|
|
122
|
+
return view('PoadItemDivider', (p) => h('div', { class: 'poad-front__center-v' }, [el(PoadDivider, { align: str(p, 'align'), dashed: bool(p, 'dashed') }, str(p, 'label') ? () => str(p, 'label') : undefined)]));
|
|
123
|
+
},
|
|
124
|
+
tabs: async () => {
|
|
125
|
+
const { PoadTabs, PoadTab } = await import('@poadio/ui-vue/tabs');
|
|
126
|
+
return view('PoadItemTabs', (p, ctx) => el(PoadTabs, { variant: str(p, 'variant') }, () => list(p, 'tabs').map((l, i) => el(PoadTab, { key: i, value: i, label: l }, () => h('p', { class: 'poad-front__body' }, contentOf(ctx, l))))));
|
|
127
|
+
},
|
|
128
|
+
accordion: async () => {
|
|
129
|
+
const { PoadAccordion, PoadAccordionPanel } = await import('@poadio/ui-vue/accordion');
|
|
130
|
+
return view('PoadItemAccordion', (p, ctx) =>
|
|
131
|
+
el(PoadAccordion, { multiple: bool(p, 'multiple'), modelValue: bool(p, 'multiple') ? ['0'] : '0' }, () => list(p, 'panels').map((l, i) => el(PoadAccordionPanel, { key: i, value: String(i), header: l }, () => h('p', { class: 'poad-front__body' }, contentOf(ctx, l))))),
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
stepper: async () => {
|
|
135
|
+
const { PoadStepper, PoadStep } = await import('@poadio/ui-vue/stepper');
|
|
136
|
+
return model('PoadItemStepper', (p) => num(p, 'current'), (p, _ctx, v) => el(PoadStepper, bind(v), () => list(p, 'steps').map((l, i) => el(PoadStep, { key: i, label: l }))));
|
|
137
|
+
},
|
|
138
|
+
splitter: async () => {
|
|
139
|
+
const { PoadSplitter, PoadSplitterPanel } = await import('@poadio/ui-vue/splitter');
|
|
140
|
+
return view('PoadItemSplitter', (p) =>
|
|
141
|
+
el(PoadSplitter, { layout: str(p, 'layout'), class: 'poad-front__fill' }, () => list(p, 'panels').map((l, i) => el(PoadSplitterPanel, { key: i }, () => h('div', { class: 'poad-front__split' }, l)))),
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// ---------------------------------------------------------------- Formulaires
|
|
146
|
+
field: async () => {
|
|
147
|
+
const { PoadField, PoadInput } = await ui.field();
|
|
148
|
+
return model('PoadItemField', () => '', (p, _ctx, v) =>
|
|
149
|
+
el(PoadField, { label: str(p, 'label') || undefined, hint: str(p, 'hint') || undefined, required: bool(p, 'required') }, () =>
|
|
150
|
+
el(PoadInput, { type: str(p, 'inputType') || 'text', placeholder: str(p, 'placeholder') || undefined, required: bool(p, 'required'), ...bind(v) }),
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
textarea: async () => {
|
|
155
|
+
const { PoadField, PoadTextarea } = await ui.field();
|
|
156
|
+
return model('PoadItemTextarea', () => '', (p, _ctx, v) =>
|
|
157
|
+
el(PoadField, { label: str(p, 'label') || undefined, required: bool(p, 'required'), class: 'poad-front__fill-field' }, () => el(PoadTextarea, { placeholder: str(p, 'placeholder') || undefined, ...bind(v) })),
|
|
158
|
+
);
|
|
159
|
+
},
|
|
160
|
+
button: async () => {
|
|
161
|
+
const { PoadButton } = await ui.button();
|
|
162
|
+
return view('PoadItemButton', (p) => el(PoadButton, { severity: str(p, 'severity'), variant: str(p, 'variant'), block: bool(p, 'block') }, () => str(p, 'label')));
|
|
163
|
+
},
|
|
164
|
+
'button-group': async () => {
|
|
165
|
+
const [{ PoadButtonGroup }, { PoadButton }] = await Promise.all([import('@poadio/ui-vue/button-group'), ui.button()]);
|
|
166
|
+
return model('PoadItemButtonGroup', (p) => list(p, 'buttons')[0] ?? null, (p, _ctx, v) =>
|
|
167
|
+
el(PoadButtonGroup, { selectable: 'single', size: str(p, 'size'), ...bind(v) }, () => list(p, 'buttons').map((l) => el(PoadButton, { key: l, value: l }, () => l))),
|
|
168
|
+
);
|
|
169
|
+
},
|
|
170
|
+
checkbox: async () => {
|
|
171
|
+
const { PoadCheckbox } = await import('@poadio/ui-vue/checkbox');
|
|
172
|
+
return model('PoadItemCheckbox', (p) => bool(p, 'checked'), (p, _ctx, v) => h('div', { class: 'poad-front__center-v' }, [el(PoadCheckbox, { label: str(p, 'label'), ...bind(v) })]));
|
|
173
|
+
},
|
|
174
|
+
radio: async () => {
|
|
175
|
+
const { PoadRadioGroup, PoadRadio } = await import('@poadio/ui-vue/radio');
|
|
176
|
+
return model('PoadItemRadio', (p) => list(p, 'options')[0] ?? null, (p, _ctx, v) =>
|
|
177
|
+
h('div', { class: 'poad-front__group' }, [
|
|
178
|
+
str(p, 'label') ? h('span', { class: 'poad-front__label' }, str(p, 'label')) : null,
|
|
179
|
+
el(PoadRadioGroup, { orientation: str(p, 'orientation'), ariaLabel: str(p, 'label') || undefined, ...bind(v) }, () => list(p, 'options').map((o) => el(PoadRadio, { key: o, value: o, label: o }))),
|
|
180
|
+
]),
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
switch: async () => {
|
|
184
|
+
const { PoadSwitch } = await import('@poadio/ui-vue/switch');
|
|
185
|
+
return model('PoadItemSwitch', (p) => bool(p, 'checked'), (p, _ctx, v) => h('div', { class: 'poad-front__center-v' }, [el(PoadSwitch, { label: str(p, 'label'), ...bind(v) })]));
|
|
186
|
+
},
|
|
187
|
+
'toggle-button': async () => {
|
|
188
|
+
const { PoadToggleButton } = await import('@poadio/ui-vue/toggle-button');
|
|
189
|
+
return model('PoadItemToggle', () => false, (p, _ctx, v) => el(PoadToggleButton, { onLabel: str(p, 'onLabel'), offLabel: str(p, 'offLabel'), ...bind(v) }));
|
|
190
|
+
},
|
|
191
|
+
segmented: async () => {
|
|
192
|
+
const { PoadSegmented } = await import('@poadio/ui-vue/segmented');
|
|
193
|
+
return model('PoadItemSegmented', (p) => list(p, 'options')[0] ?? null, (p, _ctx, v) => el(PoadSegmented, { options: options(p), block: bool(p, 'block'), ...bind(v) }));
|
|
194
|
+
},
|
|
195
|
+
select: async () =>
|
|
196
|
+
labelled('PoadItemSelect', () => import('@poadio/ui-vue/select').then((m) => m.PoadSelect), () => null, (p) => ({ options: options(p), optionLabel: 'label', optionValue: 'value', placeholder: str(p, 'placeholder') || undefined })),
|
|
197
|
+
combo: async () =>
|
|
198
|
+
labelled('PoadItemCombo', () => import('@poadio/ui-vue/combo').then((m) => m.PoadCombo), () => '', (p) => ({ suggestions: list(p, 'options'), placeholder: str(p, 'placeholder') || undefined, dropdown: true })),
|
|
199
|
+
listbox: async () => {
|
|
200
|
+
const { PoadListbox } = await import('@poadio/ui-vue/listbox');
|
|
201
|
+
return model('PoadItemListbox', (p) => (bool(p, 'multiple') ? [] : null), (p, _ctx, v) =>
|
|
202
|
+
el(PoadListbox, { options: options(p), optionLabel: 'label', optionValue: 'value', multiple: bool(p, 'multiple'), filter: bool(p, 'filter'), class: 'poad-front__fill', ...bind(v) }),
|
|
203
|
+
);
|
|
204
|
+
},
|
|
205
|
+
number: async () =>
|
|
206
|
+
labelled('PoadItemNumber', () => import('@poadio/ui-vue/number').then((m) => m.PoadNumber), () => null as number | null, (p) => ({ min: num(p, 'min'), max: num(p, 'max'), suffix: str(p, 'suffix') ? ` ${str(p, 'suffix')}` : undefined })),
|
|
207
|
+
password: async () =>
|
|
208
|
+
labelled('PoadItemPassword', () => import('@poadio/ui-vue/password').then((m) => m.PoadPassword), () => '', (p) => ({ placeholder: str(p, 'placeholder') || undefined, feedback: bool(p, 'feedback'), autocomplete: 'new-password' })),
|
|
209
|
+
mask: async () => {
|
|
210
|
+
const [{ PoadField, PoadInput }, { vPoadMask }] = await Promise.all([ui.field(), import('@poadio/ui-vue/mask')]);
|
|
211
|
+
return view('PoadItemMask', (p) => el(PoadField, { label: str(p, 'label') || undefined }, () => withDirectives(el(PoadInput, { key: str(p, 'preset'), inputmode: 'text' }), [[vPoadMask, { preset: str(p, 'preset') }]])));
|
|
212
|
+
},
|
|
213
|
+
datepicker: async () =>
|
|
214
|
+
labelled('PoadItemDate', () => import('@poadio/ui-vue/datepicker').then((m) => m.PoadDatepicker), () => null, (p) => ({ mode: str(p, 'mode'), selectionMode: bool(p, 'range') ? 'range' : 'single' })),
|
|
215
|
+
color: async () => labelled('PoadItemColor', () => import('@poadio/ui-vue/colorpicker').then((m) => m.PoadColorpicker), () => null, (p) => ({ alpha: bool(p, 'alpha') })),
|
|
216
|
+
slider: async () =>
|
|
217
|
+
labelled('PoadItemSlider', () => import('@poadio/ui-vue/slider').then((m) => m.PoadSlider), (p) => num(p, 'min'), (p) => ({ min: num(p, 'min'), max: num(p, 'max'), step: num(p, 'step') || 1, showValue: 'drag' })),
|
|
218
|
+
rating: async () => {
|
|
219
|
+
const { PoadRating } = await import('@poadio/ui-vue/rating');
|
|
220
|
+
return model('PoadItemRating', () => null as number | null, (p, _ctx, v) => h('div', { class: 'poad-front__center-v is-fit' }, [el(PoadRating, { max: num(p, 'max') || 5, readonly: bool(p, 'readonly'), ...bind(v) })]));
|
|
221
|
+
},
|
|
222
|
+
upload: async () => {
|
|
223
|
+
const { PoadUpload } = await import('@poadio/ui-vue/upload');
|
|
224
|
+
// Choix seulement : l'envoi vers le stockage du projet viendra avec la liaison aux données
|
|
225
|
+
return view('PoadItemUpload', (p) => el(PoadUpload, { mode: str(p, 'mode'), multiple: bool(p, 'multiple'), accept: str(p, 'accept'), selectOnly: true }));
|
|
226
|
+
},
|
|
227
|
+
richtext: async () => {
|
|
228
|
+
const { PoadRichText } = await import('@poadio/ui-vue/richtext');
|
|
229
|
+
return model('PoadItemRichText', () => '', (p, _ctx, v) => el(PoadRichText, { placeholder: str(p, 'placeholder'), minHeight: '100%', maxHeight: '100%', class: 'poad-front__fill', ...bind(v) }));
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
// ---------------------------------------------------------------- Données
|
|
233
|
+
table: async () => {
|
|
234
|
+
const { PoadTable } = await import('@poadio/ui-vue/table');
|
|
235
|
+
return view('PoadItemTable', (p) =>
|
|
236
|
+
el(PoadTable, {
|
|
237
|
+
value: [],
|
|
238
|
+
columns: list(p, 'columns').map((c, i) => ({ field: `c${i}`, header: c })),
|
|
239
|
+
emptyMessage: str(p, 'emptyMessage') || undefined,
|
|
240
|
+
paginator: bool(p, 'paginator'),
|
|
241
|
+
striped: bool(p, 'striped'),
|
|
242
|
+
// Sans source de données, la barre n'aurait qu'un compteur à 0 : elle reviendra avec la liaison au store
|
|
243
|
+
showToolbar: false,
|
|
244
|
+
class: 'poad-front__fill',
|
|
245
|
+
}),
|
|
246
|
+
);
|
|
247
|
+
},
|
|
248
|
+
dataview: async () => {
|
|
249
|
+
const { PoadDataview } = await import('@poadio/ui-vue/dataview');
|
|
250
|
+
return view('PoadItemDataview', (p) => el(PoadDataview, { value: [], layout: str(p, 'layout'), emptyMessage: str(p, 'emptyMessage') || undefined, class: 'poad-front__fill' }));
|
|
251
|
+
},
|
|
252
|
+
tree: async () => {
|
|
253
|
+
const { PoadTree } = await import('@poadio/ui-vue/tree');
|
|
254
|
+
return view('PoadItemTree', (p) => el(PoadTree, { value: list(p, 'nodes').map((l, i) => ({ key: String(i), label: l })), dataKey: 'key' }));
|
|
255
|
+
},
|
|
256
|
+
paginator: async () => {
|
|
257
|
+
const { PoadPaginator } = await import('@poadio/ui-vue/paginator');
|
|
258
|
+
return model('PoadItemPaginator', () => 0, (p, _ctx, v) => el(PoadPaginator, { totalRecords: num(p, 'totalRecords'), rows: num(p, 'rows') || 10, rowsPerPageOptions: [], first: v.value, 'onUpdate:first': (x: number) => (v.value = x) }));
|
|
259
|
+
},
|
|
260
|
+
chart: async () => {
|
|
261
|
+
const { PoadChart } = await import('@poadio/ui-vue/chart');
|
|
262
|
+
return view('PoadItemChart', (p) =>
|
|
263
|
+
el(PoadChart, {
|
|
264
|
+
type: str(p, 'chartType'),
|
|
265
|
+
data: { labels: list(p, 'labels'), datasets: [{ label: str(p, 'series'), data: list(p, 'values').map((v) => Number(v.replace(',', '.')) || 0) }] },
|
|
266
|
+
height: '100%',
|
|
267
|
+
class: 'poad-front__fill',
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
270
|
+
},
|
|
271
|
+
meter: async () => {
|
|
272
|
+
const { PoadMeter } = await import('@poadio/ui-vue/meter');
|
|
273
|
+
return view('PoadItemMeter', (p) => h('div', { class: 'poad-front__center-v' }, [el(PoadMeter, { values: [{ label: str(p, 'label') || '—', value: num(p, 'value') }], max: num(p, 'max') || 100, unit: str(p, 'unit') })]));
|
|
274
|
+
},
|
|
275
|
+
progress: async () => {
|
|
276
|
+
const { PoadProgress } = await import('@poadio/ui-vue/progress');
|
|
277
|
+
return view('PoadItemProgress', (p) => h('div', { class: 'poad-front__center-v' }, [el(PoadProgress, { value: num(p, 'value'), label: str(p, 'label') || undefined, showValue: bool(p, 'showValue'), severity: str(p, 'severity') })]));
|
|
278
|
+
},
|
|
279
|
+
timeline: async () => {
|
|
280
|
+
const { PoadTimeline } = await import('@poadio/ui-vue/timeline');
|
|
281
|
+
return view('PoadItemTimeline', (p) => el(PoadTimeline, { events: list(p, 'events').map((l) => ({ label: l })), layout: str(p, 'layout'), activeIndex: 0 }));
|
|
282
|
+
},
|
|
283
|
+
orgchart: async () => {
|
|
284
|
+
const { PoadOrgchart } = await import('@poadio/ui-vue/orgchart');
|
|
285
|
+
return view('PoadItemOrgchart', (p) =>
|
|
286
|
+
el(PoadOrgchart, { value: [{ key: 'root', data: { label: str(p, 'root') }, children: list(p, 'children').map((l, i) => ({ key: `n${i}`, data: { label: l } })) }], class: 'poad-front__fill' }),
|
|
287
|
+
);
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
// ---------------------------------------------------------------- Planification (sans données : la liaison viendra avec le store)
|
|
291
|
+
calendar: async () => {
|
|
292
|
+
const { PoadCalendar } = await import('@poadio/ui-vue/calendar');
|
|
293
|
+
return view('PoadItemCalendar', (p) => el(PoadCalendar, { view: str(p, 'view'), class: 'poad-front__fill' }));
|
|
294
|
+
},
|
|
295
|
+
scheduler: async () => {
|
|
296
|
+
const { PoadScheduler } = await import('@poadio/ui-vue/scheduler');
|
|
297
|
+
return view('PoadItemScheduler', (p) => el(PoadScheduler, { scale: str(p, 'scale'), class: 'poad-front__fill' }));
|
|
298
|
+
},
|
|
299
|
+
gantt: async () => {
|
|
300
|
+
const { PoadGantt } = await import('@poadio/ui-vue/gantt');
|
|
301
|
+
return view('PoadItemGantt', (p) => el(PoadGantt, { scale: str(p, 'scale'), class: 'poad-front__fill' }));
|
|
302
|
+
},
|
|
303
|
+
taskboard: async () => {
|
|
304
|
+
const { PoadTaskboard } = await import('@poadio/ui-vue/taskboard');
|
|
305
|
+
return view('PoadItemTaskboard', (p) => el(PoadTaskboard, { mode: str(p, 'mode'), class: 'poad-front__fill' }));
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
// ---------------------------------------------------------------- Navigation
|
|
309
|
+
menubar: async () => {
|
|
310
|
+
const { PoadMenubar } = await import('@poadio/ui-vue/menubar');
|
|
311
|
+
return view('PoadItemMenubar', (p, ctx) => {
|
|
312
|
+
const nav = fromPages(p, ctx);
|
|
313
|
+
const bar = nav
|
|
314
|
+
? el(PoadMenubar, { items: nav.pages.map((pg) => ({ id: pg.id, label: pg.title, url: nav.href(pg.id) })), current: nav.current ? nav.href(nav.current) : null, linkAs: frontLink(nav), ariaLabel: ctx.t('item.menu') })
|
|
315
|
+
: el(PoadMenubar, { items: list(p, 'items').map((l) => ({ label: l })), ariaLabel: ctx.t('item.menu') });
|
|
316
|
+
return h('div', { class: 'poad-front__center-v' }, [bar]);
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
breadcrumb: async () => {
|
|
320
|
+
const { PoadBreadcrumb } = await import('@poadio/ui-vue/breadcrumb');
|
|
321
|
+
return view('PoadItemBreadcrumb', (p) => h('div', { class: 'poad-front__center-v' }, [el(PoadBreadcrumb, { items: list(p, 'items').map((l) => ({ label: l })) })]));
|
|
322
|
+
},
|
|
323
|
+
'bottom-nav': async () => {
|
|
324
|
+
const { PoadBottomNav } = await import('@poadio/ui-vue/bottom-nav');
|
|
325
|
+
const icons = ['home', 'search', 'user', 'settings', 'bell'];
|
|
326
|
+
return model('PoadItemBottomNav', () => '0', (p, ctx, v) => {
|
|
327
|
+
const nav = fromPages(p, ctx);
|
|
328
|
+
return nav
|
|
329
|
+
? el(PoadBottomNav, {
|
|
330
|
+
items: nav.pages.map((pg, i) => ({ value: pg.id, label: pg.title, icon: icons[i % icons.length]! })),
|
|
331
|
+
modelValue: nav.current,
|
|
332
|
+
'onUpdate:modelValue': (id: string) => nav.go(id),
|
|
333
|
+
alwaysShow: true, ariaLabel: ctx.t('item.menu'), class: 'poad-front__inline-nav',
|
|
334
|
+
})
|
|
335
|
+
: el(PoadBottomNav, { items: list(p, 'items').map((l, i) => ({ value: String(i), label: l, icon: icons[i % icons.length]! })), alwaysShow: true, ariaLabel: ctx.t('item.menu'), class: 'poad-front__inline-nav', ...bind(v) });
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
'speed-dial': async () => {
|
|
339
|
+
const { PoadSpeedDial } = await import('@poadio/ui-vue/speed-dial');
|
|
340
|
+
const icons = ['pencil', 'share', 'trash'];
|
|
341
|
+
return view('PoadItemSpeedDial', (p, ctx) => h('div', { class: 'poad-front__center' }, [el(PoadSpeedDial, { items: list(p, 'items').map((l, i) => ({ label: l, icon: icons[i % icons.length] })), direction: str(p, 'direction'), ariaLabel: ctx.t('item.actions') })]));
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
// ---------------------------------------------------------------- Affichage
|
|
345
|
+
heading: async () =>
|
|
346
|
+
view('PoadItemHeading', (p) => h(str(p, 'level') || 'h2', { class: ['poad-front__heading', `is-${str(p, 'level') || 'h2'}`], style: { textAlign: str(p, 'align') || 'left' } }, str(p, 'text'))),
|
|
347
|
+
text: async () => view('PoadItemText', (p) => h('p', { class: 'poad-front__text', style: { textAlign: str(p, 'align') || 'left' } }, str(p, 'text'))),
|
|
348
|
+
image: async () => {
|
|
349
|
+
const [{ PoadImage }, { PoadIcon }] = await Promise.all([import('@poadio/ui-vue/image'), import('@poadio/ui-vue/icon')]);
|
|
350
|
+
return view('PoadItemImage', (p, ctx) =>
|
|
351
|
+
str(p, 'src')
|
|
352
|
+
? el(PoadImage, { src: str(p, 'src'), alt: str(p, 'alt'), fit: str(p, 'fit'), rounded: bool(p, 'rounded'), width: '100%', height: '100%', class: 'poad-front__fill' })
|
|
353
|
+
: h('div', { class: 'poad-front__placeholder', role: 'img', 'aria-label': str(p, 'alt') || ctx.t('item.image.empty') }, [el(PoadIcon, { name: 'image', size: 28 }), h('span', ctx.t('item.image.empty'))]),
|
|
354
|
+
);
|
|
355
|
+
},
|
|
356
|
+
avatar: async () => {
|
|
357
|
+
const { PoadAvatar } = await import('@poadio/ui-vue/avatar');
|
|
358
|
+
return view('PoadItemAvatar', (p) => h('div', { class: 'poad-front__center' }, [el(PoadAvatar, { text: str(p, 'text'), size: str(p, 'size'), shape: str(p, 'shape') })]));
|
|
359
|
+
},
|
|
360
|
+
badge: async () => {
|
|
361
|
+
const { PoadBadge } = await import('@poadio/ui-vue/badge');
|
|
362
|
+
return view('PoadItemBadge', (p) => h('div', { class: 'poad-front__center-v is-fit' }, [el(PoadBadge, { value: str(p, 'value'), severity: str(p, 'severity') })]));
|
|
363
|
+
},
|
|
364
|
+
tag: async () => {
|
|
365
|
+
const { PoadTag } = await import('@poadio/ui-vue/tag');
|
|
366
|
+
return view('PoadItemTag', (p) => h('div', { class: 'poad-front__center-v is-fit' }, [el(PoadTag, { value: str(p, 'value'), severity: str(p, 'severity'), rounded: bool(p, 'rounded') })]));
|
|
367
|
+
},
|
|
368
|
+
chip: async () => {
|
|
369
|
+
const { PoadChip } = await import('@poadio/ui-vue/chip');
|
|
370
|
+
return view('PoadItemChip', (p) => h('div', { class: 'poad-front__center-v is-fit' }, [el(PoadChip, { label: str(p, 'label'), removable: bool(p, 'removable') })]));
|
|
371
|
+
},
|
|
372
|
+
carousel: async () => {
|
|
373
|
+
const { PoadCarousel } = await import('@poadio/ui-vue/carousel');
|
|
374
|
+
return view('PoadItemCarousel', (p) =>
|
|
375
|
+
el(PoadCarousel, { items: list(p, 'slides'), numVisible: num(p, 'numVisible') || 1, class: 'poad-front__fill' }, { item: ({ item }: { item: string }) => h('div', { class: 'poad-front__slide' }, item) }),
|
|
376
|
+
);
|
|
377
|
+
},
|
|
378
|
+
icon: async () => {
|
|
379
|
+
const { PoadIcon } = await import('@poadio/ui-vue/icon');
|
|
380
|
+
return view('PoadItemIcon', (p) => h('div', { class: 'poad-front__center' }, [el(PoadIcon, { name: str(p, 'name') || 'star', size: num(p, 'size') || 24 })]));
|
|
381
|
+
},
|
|
382
|
+
message: async () => {
|
|
383
|
+
const { PoadMessage } = await import('@poadio/ui-vue/message');
|
|
384
|
+
return view('PoadItemMessage', (p) => el(PoadMessage, { severity: str(p, 'severity'), text: str(p, 'text') }));
|
|
385
|
+
},
|
|
386
|
+
skeleton: async () => {
|
|
387
|
+
const { PoadSkeleton } = await import('@poadio/ui-vue/skeleton');
|
|
388
|
+
return view('PoadItemSkeleton', (p) => {
|
|
389
|
+
const shape = str(p, 'shape') || 'text';
|
|
390
|
+
return el(PoadSkeleton, shape === 'text' ? { shape, lines: num(p, 'lines') || 3 } : { shape, width: shape === 'circle' ? '48px' : '100%', height: shape === 'circle' ? '48px' : '100%' });
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Feuilles de style de @poadio/ui-core par type (noms de fichiers de ui-core, sans `.css`) ; tokens, base, bouton,
|
|
397
|
+
* champ, message, étiquette et icône sont déjà dans app.css.
|
|
398
|
+
*/
|
|
399
|
+
export const ITEM_STYLES: Record<string, readonly string[]> = {
|
|
400
|
+
card: ['card'], panel: ['panel'], fieldset: ['fieldset'], divider: ['divider'], tabs: ['tabs'], accordion: ['accordion'], stepper: ['stepper'], splitter: ['splitter'],
|
|
401
|
+
field: [], textarea: [], button: [], 'button-group': ['button-group'], checkbox: ['checkbox'], radio: ['radio'], switch: ['switch'], 'toggle-button': ['toggle-button'],
|
|
402
|
+
segmented: ['segmented'], select: ['select', 'option-list', 'popover'], combo: ['combo', 'option-list', 'popover', 'chip'], listbox: ['listbox', 'option-list'],
|
|
403
|
+
number: ['number'], password: ['password', 'popover'], mask: [], datepicker: ['datepicker', 'popover', 'select', 'option-list'], color: ['colorpicker', 'popover'],
|
|
404
|
+
slider: ['slider', 'tooltip'], rating: ['rating'], upload: ['upload', 'progress'], richtext: ['richtext', 'menu', 'dialog', 'tooltip', 'popover'],
|
|
405
|
+
table: ['table', 'table-panel', 'paginator', 'select', 'option-list', 'popover', 'menu', 'checkbox', 'skeleton'], dataview: ['dataview', 'paginator', 'select', 'option-list', 'popover', 'segmented', 'skeleton'],
|
|
406
|
+
tree: ['tree', 'checkbox'], paginator: ['paginator', 'select', 'option-list', 'popover'], chart: ['chart', 'progress'], meter: ['meter'], progress: ['progress'],
|
|
407
|
+
timeline: ['timeline'], orgchart: ['orgchart', 'avatar'],
|
|
408
|
+
calendar: ['calendar', 'popover', 'segmented', 'dialog', 'menu', 'select', 'option-list', 'datepicker', 'checkbox', 'skeleton'],
|
|
409
|
+
scheduler: ['scheduler', 'popover', 'segmented', 'dialog', 'menu', 'select', 'option-list', 'datepicker', 'skeleton'],
|
|
410
|
+
gantt: ['gantt', 'popover', 'segmented', 'dialog', 'menu', 'select', 'option-list', 'datepicker', 'skeleton'],
|
|
411
|
+
taskboard: ['taskboard', 'popover', 'segmented', 'dialog', 'menu', 'avatar', 'select', 'option-list', 'skeleton'],
|
|
412
|
+
menubar: ['menubar', 'menu', 'popover'], breadcrumb: ['breadcrumb', 'menu', 'popover'], 'bottom-nav': ['bottom-nav', 'badge'], 'speed-dial': ['speed-dial', 'tooltip'],
|
|
413
|
+
heading: [], text: [], image: ['image'], avatar: ['avatar'], badge: ['badge'], tag: [], chip: ['chip', 'avatar'], carousel: ['carousel'], icon: [], message: [], skeleton: ['skeleton'],
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// ------------------------------------------------------------------ styles à la demande
|
|
417
|
+
|
|
418
|
+
let styleLoader: ((name: string) => void) | null = null;
|
|
419
|
+
const loadedStyles = new Set<string>();
|
|
420
|
+
|
|
421
|
+
/** Le moteur servi par l'engine charge les feuilles de ui-core à la demande (runtime/main.ts) ; une appli les importe elle-même */
|
|
422
|
+
export const setStyleLoader = (load: ((name: string) => void) | null) => {
|
|
423
|
+
styleLoader = load;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/** Charge des feuilles de @poadio/ui-core (une fois chacune) */
|
|
427
|
+
export const loadStyles = (names: readonly string[]) => {
|
|
428
|
+
if (!styleLoader) return;
|
|
429
|
+
for (const name of names) {
|
|
430
|
+
if (loadedStyles.has(name)) continue;
|
|
431
|
+
loadedStyles.add(name);
|
|
432
|
+
styleLoader(name);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export const loadItemStyles = (type: string) => loadStyles(ITEM_STYLES[type] ?? []);
|