@poadio/app-vue 0.1.0 → 0.2.1

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.
Files changed (224) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/app-vue.css +102 -23
  3. package/dist/browser.d.ts +3 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/browser.js +18 -1
  6. package/dist/browser.js.map +1 -1
  7. package/dist/draft-toolbar.d.ts +65 -0
  8. package/dist/draft-toolbar.d.ts.map +1 -0
  9. package/dist/draft-toolbar.js +62 -0
  10. package/dist/draft-toolbar.js.map +1 -0
  11. package/dist/front-view.d.ts +5 -1
  12. package/dist/front-view.d.ts.map +1 -1
  13. package/dist/front-view.js +103 -44
  14. package/dist/front-view.js.map +1 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/items.d.ts +33 -0
  20. package/dist/items.d.ts.map +1 -0
  21. package/dist/items.js +369 -0
  22. package/dist/items.js.map +1 -0
  23. package/dist/lazy.d.ts +16 -0
  24. package/dist/lazy.d.ts.map +1 -1
  25. package/dist/lazy.js +34 -1
  26. package/dist/lazy.js.map +1 -1
  27. package/dist/messages.d.ts +19 -2
  28. package/dist/messages.d.ts.map +1 -1
  29. package/dist/messages.js +38 -4
  30. package/dist/messages.js.map +1 -1
  31. package/dist/sections/grid.d.ts +25 -1
  32. package/dist/sections/grid.d.ts.map +1 -1
  33. package/dist/sections/grid.js +31 -3
  34. package/dist/sections/grid.js.map +1 -1
  35. package/package.json +4 -3
  36. package/runtime-dist/app.css +102 -23
  37. package/runtime-dist/app.js +2 -2
  38. package/runtime-dist/c-031pq7qf.js +2 -0
  39. package/runtime-dist/c-0vbs937h.js +18 -0
  40. package/runtime-dist/c-1h49vkah.js +2 -0
  41. package/runtime-dist/c-1hzd2pqr.js +2 -0
  42. package/runtime-dist/c-1q9r6ndn.js +1 -0
  43. package/runtime-dist/c-1re10yb3.js +1 -0
  44. package/runtime-dist/c-1v1v69qs.js +1 -0
  45. package/runtime-dist/c-1yjbg3yb.js +1 -0
  46. package/runtime-dist/c-2ag31260.js +2 -0
  47. package/runtime-dist/c-2c88ebgp.js +1 -0
  48. package/runtime-dist/c-30chvm5x.js +1 -0
  49. package/runtime-dist/c-37zx0wkd.js +1 -0
  50. package/runtime-dist/c-4agg4qbw.js +1 -0
  51. package/runtime-dist/c-4g3757ck.js +2 -0
  52. package/runtime-dist/c-4vjd8na5.js +1 -0
  53. package/runtime-dist/c-523qwqen.js +2 -0
  54. package/runtime-dist/c-56tgqzdn.js +2 -0
  55. package/runtime-dist/c-57mnqma1.js +1 -0
  56. package/runtime-dist/c-5gfe19fa.js +1 -0
  57. package/runtime-dist/c-5ma45m2j.js +1 -0
  58. package/runtime-dist/c-74emmp4y.js +1 -0
  59. package/runtime-dist/c-7dryrrsk.js +2 -0
  60. package/runtime-dist/c-82sqd7as.js +1 -0
  61. package/runtime-dist/c-8ahb2ywd.js +1 -0
  62. package/runtime-dist/c-8cc3yqpn.js +1 -0
  63. package/runtime-dist/c-8h2rwbd8.js +1 -0
  64. package/runtime-dist/c-8nyvd0h0.js +1 -0
  65. package/runtime-dist/c-8r1pgc8w.js +1 -0
  66. package/runtime-dist/c-8x8fdn2b.js +1 -0
  67. package/runtime-dist/c-8xxzrkpg.js +2 -0
  68. package/runtime-dist/c-98tbntdq.js +2 -0
  69. package/runtime-dist/c-9rx4pqjs.js +2 -0
  70. package/runtime-dist/c-b5wfx90n.js +1 -0
  71. package/runtime-dist/c-bhgqqt5x.js +2 -0
  72. package/runtime-dist/c-c60s3ncm.js +2 -0
  73. package/runtime-dist/c-cfrv87cv.js +1 -0
  74. package/runtime-dist/c-d3hafdna.js +1 -0
  75. package/runtime-dist/c-d8hfdner.js +2 -0
  76. package/runtime-dist/c-d9rzqgda.js +1 -0
  77. package/runtime-dist/c-dx8zkcbf.js +1 -0
  78. package/runtime-dist/c-dzx0rg0g.js +2 -0
  79. package/runtime-dist/c-e3rddwjq.js +1 -0
  80. package/runtime-dist/c-e45fhawr.js +1 -0
  81. package/runtime-dist/c-eh9ryhw7.js +2 -0
  82. package/runtime-dist/{c-fg782zf4.js → c-er7e0yqs.js} +1 -1
  83. package/runtime-dist/c-fbtxac36.js +1 -0
  84. package/runtime-dist/c-g4dt7z6r.js +2 -0
  85. package/runtime-dist/c-g6vc4fyb.js +1 -0
  86. package/runtime-dist/c-g9jhyx8j.js +1 -0
  87. package/runtime-dist/c-gf4wzfng.js +1 -0
  88. package/runtime-dist/c-gfzghvh2.js +1 -0
  89. package/runtime-dist/c-grqtxpm9.js +1 -0
  90. package/runtime-dist/c-h8ny4vpa.js +1 -0
  91. package/runtime-dist/c-hgdk0vqh.js +1 -0
  92. package/runtime-dist/c-hrbpqm8q.js +2 -0
  93. package/runtime-dist/c-j63hz554.js +2 -0
  94. package/runtime-dist/c-jxqht9an.js +2 -0
  95. package/runtime-dist/c-jy6yg5r5.js +3 -0
  96. package/runtime-dist/c-k3yb5e72.js +2 -0
  97. package/runtime-dist/c-k624qrhh.js +2 -0
  98. package/runtime-dist/c-kaqzctfm.js +15 -0
  99. package/runtime-dist/c-kbg0cafy.js +2 -0
  100. package/runtime-dist/c-kmx0mv0c.js +2 -0
  101. package/runtime-dist/c-kqsnm92z.js +1 -0
  102. package/runtime-dist/c-mcy4rvac.js +2 -0
  103. package/runtime-dist/c-mdj990nz.js +2 -0
  104. package/runtime-dist/c-mhzk96e8.js +1 -0
  105. package/runtime-dist/c-mv93h1f5.js +1 -0
  106. package/runtime-dist/c-mvdn43tv.js +2 -0
  107. package/runtime-dist/c-n27dcy6d.js +2 -0
  108. package/runtime-dist/c-n8sg12jt.js +1 -0
  109. package/runtime-dist/c-n9cyhrcb.js +2 -0
  110. package/runtime-dist/c-ny0mdx7k.js +2 -0
  111. package/runtime-dist/c-p3z8t4n5.js +1 -0
  112. package/runtime-dist/c-p8wyhrwm.js +2 -0
  113. package/runtime-dist/c-pfc9b97d.js +1 -0
  114. package/runtime-dist/c-pj08sk6j.js +2 -0
  115. package/runtime-dist/{c-pgxy0etb.js → c-pk2cv8zh.js} +1 -1
  116. package/runtime-dist/c-py0rvzyv.js +1 -0
  117. package/runtime-dist/c-pyj696ce.js +1 -0
  118. package/runtime-dist/c-qzar8xvm.js +2 -0
  119. package/runtime-dist/c-rf1xevya.js +1 -0
  120. package/runtime-dist/{c-ns42txax.js → c-rj7c7mwf.js} +2 -2
  121. package/runtime-dist/c-rktc0ksd.js +2 -0
  122. package/runtime-dist/c-rm0av36n.js +1 -0
  123. package/runtime-dist/c-rv7cxh2k.js +2 -0
  124. package/runtime-dist/c-s3vrabx6.js +1 -0
  125. package/runtime-dist/c-sd570jk7.js +2 -0
  126. package/runtime-dist/c-sjajadt4.js +2 -0
  127. package/runtime-dist/c-t83mbx7z.js +1 -0
  128. package/runtime-dist/c-tsyjqc1h.js +2 -0
  129. package/runtime-dist/c-vmp3ee81.js +1 -0
  130. package/runtime-dist/c-vztkfwfq.js +1 -0
  131. package/runtime-dist/c-xw7vce7r.js +2 -0
  132. package/runtime-dist/c-y7abh583.js +1 -0
  133. package/runtime-dist/c-ynwn0vws.js +1 -0
  134. package/runtime-dist/c-za724ed4.js +1 -0
  135. package/runtime-dist/c-zt8jhyxz.js +1 -0
  136. package/runtime-dist/c-zv49taf7.js +1 -0
  137. package/runtime-dist/ui-accordion.css +29 -0
  138. package/runtime-dist/ui-app-shell.css +36 -0
  139. package/runtime-dist/ui-avatar.css +28 -0
  140. package/runtime-dist/ui-badge.css +14 -0
  141. package/runtime-dist/ui-block-editor.css +85 -0
  142. package/runtime-dist/ui-block-view.css +50 -0
  143. package/runtime-dist/ui-block.css +20 -0
  144. package/runtime-dist/ui-bottom-nav.css +54 -0
  145. package/runtime-dist/ui-breadcrumb.css +25 -0
  146. package/runtime-dist/ui-button-group.css +39 -0
  147. package/runtime-dist/ui-calendar.css +168 -0
  148. package/runtime-dist/ui-card.css +26 -0
  149. package/runtime-dist/ui-carousel.css +35 -0
  150. package/runtime-dist/ui-chart.css +26 -0
  151. package/runtime-dist/ui-checkbox.css +25 -0
  152. package/runtime-dist/ui-chip.css +30 -0
  153. package/runtime-dist/ui-code-editor.css +25 -0
  154. package/runtime-dist/ui-colorpicker.css +46 -0
  155. package/runtime-dist/ui-combo.css +43 -0
  156. package/runtime-dist/ui-dataview.css +50 -0
  157. package/runtime-dist/ui-datepicker.css +80 -0
  158. package/runtime-dist/ui-dialog.css +119 -0
  159. package/runtime-dist/ui-divider.css +18 -0
  160. package/runtime-dist/ui-fieldset.css +25 -0
  161. package/runtime-dist/ui-filter-chip.css +24 -0
  162. package/runtime-dist/ui-floating.css +9 -0
  163. package/runtime-dist/ui-gantt.css +105 -0
  164. package/runtime-dist/ui-image.css +34 -0
  165. package/runtime-dist/ui-inplace.css +19 -0
  166. package/runtime-dist/ui-json-editor.css +40 -0
  167. package/runtime-dist/ui-layout.css +39 -0
  168. package/runtime-dist/ui-listbox.css +52 -0
  169. package/runtime-dist/ui-map.css +469 -0
  170. package/runtime-dist/ui-menu.css +38 -0
  171. package/runtime-dist/ui-menubar.css +55 -0
  172. package/runtime-dist/ui-meter.css +26 -0
  173. package/runtime-dist/ui-multiselect.css +62 -0
  174. package/runtime-dist/ui-nav-drawer.css +118 -0
  175. package/runtime-dist/ui-number.css +26 -0
  176. package/runtime-dist/ui-option-list.css +28 -0
  177. package/runtime-dist/ui-orderlist.css +54 -0
  178. package/runtime-dist/ui-orgchart.css +71 -0
  179. package/runtime-dist/ui-paginator.css +25 -0
  180. package/runtime-dist/ui-panel.css +28 -0
  181. package/runtime-dist/ui-password.css +26 -0
  182. package/runtime-dist/ui-picklist.css +58 -0
  183. package/runtime-dist/ui-popover.css +20 -0
  184. package/runtime-dist/ui-progress.css +31 -0
  185. package/runtime-dist/ui-radio.css +29 -0
  186. package/runtime-dist/ui-rating.css +19 -0
  187. package/runtime-dist/ui-richtext.css +48 -0
  188. package/runtime-dist/ui-scheduler.css +132 -0
  189. package/runtime-dist/ui-scroll-top.css +17 -0
  190. package/runtime-dist/ui-segmented.css +25 -0
  191. package/runtime-dist/ui-select.css +47 -0
  192. package/runtime-dist/ui-sheet.css +56 -0
  193. package/runtime-dist/ui-skeleton.css +18 -0
  194. package/runtime-dist/ui-slider.css +59 -0
  195. package/runtime-dist/ui-speed-dial.css +26 -0
  196. package/runtime-dist/ui-splitter.css +23 -0
  197. package/runtime-dist/ui-stepper.css +47 -0
  198. package/runtime-dist/ui-switch.css +31 -0
  199. package/runtime-dist/ui-table-panel.css +114 -0
  200. package/runtime-dist/ui-table.css +430 -0
  201. package/runtime-dist/ui-tabs.css +45 -0
  202. package/runtime-dist/ui-taskboard.css +104 -0
  203. package/runtime-dist/ui-timeline.css +44 -0
  204. package/runtime-dist/ui-toast.css +43 -0
  205. package/runtime-dist/ui-toggle-button.css +6 -0
  206. package/runtime-dist/ui-tooltip.css +21 -0
  207. package/runtime-dist/ui-tree.css +44 -0
  208. package/runtime-dist/ui-upload.css +46 -0
  209. package/runtime-dist/version.json +1 -1
  210. package/src/browser.ts +21 -2
  211. package/src/draft-toolbar.ts +67 -0
  212. package/src/front-view.ts +105 -51
  213. package/src/index.ts +2 -1
  214. package/src/items.ts +436 -0
  215. package/src/lazy.ts +38 -1
  216. package/src/messages.ts +38 -4
  217. package/src/sections/grid.ts +40 -4
  218. package/runtime-dist/c-7dddcgt2.js +0 -2
  219. package/runtime-dist/c-9a0nzf53.js +0 -2
  220. package/runtime-dist/c-c1e1x3y1.js +0 -1
  221. package/runtime-dist/c-fnkq09db.js +0 -1
  222. package/runtime-dist/c-j29w8z15.js +0 -1
  223. package/runtime-dist/c-mmxqs2mz.js +0 -1
  224. package/runtime-dist/c-xsq12y6b.js +0 -1
package/src/front-view.ts CHANGED
@@ -5,10 +5,19 @@
5
5
  * gestes (navigation, connexion, déconnexion). Aucune logique ici : ce qui décide (page, connexion exigée, page
6
6
  * introuvable, front pas encore publié) est dans le cœur, testé sans navigateur. Composants de @poadio/ui-vue,
7
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.
8
12
  */
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';
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';
12
21
  import { translator, type Lang, type MessageKey } from './messages.js';
13
22
 
14
23
  type T = (k: MessageKey) => string;
@@ -19,9 +28,9 @@ const panel = (t: T, title: MessageKey, text: MessageKey, extra: VNode[] = []) =
19
28
  ]);
20
29
 
21
30
  /** Une section : son module, chargé à la demande (lazy.ts) ; un type inconnu n'affiche rien */
22
- const section = (t: T, s: Section, canvas: boolean) => {
31
+ const section = (t: T, s: Section, canvas: boolean, log: FrontLogger, nav: FrontNav | null) => {
23
32
  const c = sectionComponent(s.type);
24
- return c ? h(c, { key: s.id, section: s, t, canvas }) : null;
33
+ return c ? h(c, { key: s.id, section: s, t, canvas, ...(s.type === 'grid' ? { log, nav } : {}) }) : null;
25
34
  };
26
35
 
27
36
  export const PoadFrontView = defineComponent({
@@ -36,15 +45,74 @@ export const PoadFrontView = defineComponent({
36
45
  onBeforeUnmount(off);
37
46
  const t = computed(() => translator(props.lang));
38
47
  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
+ // ---- 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
+ })
48
116
  : null;
49
117
  const password = ref('');
50
118
 
@@ -80,39 +148,18 @@ export const PoadFrontView = defineComponent({
80
148
  ]);
81
149
  };
82
150
 
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
- };
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
+ });
116
163
 
117
164
  return () => {
118
165
  const s = state.value;
@@ -123,10 +170,17 @@ export const PoadFrontView = defineComponent({
123
170
  else if (s.status === 'unpublished') body = panel(tt, 'unpublished.title', 'unpublished.text');
124
171
  else if (s.status === 'error') body = panel(tt, 'error.title', 'error.text');
125
172
  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])]);
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
+ );
130
184
  };
131
185
  },
132
186
  });
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // @poadio/app-vue : le rendu Vue des fronts dessinés dans poad, sur @poadio/app-core et @poadio/ui-vue.
2
2
  export { PoadFrontView } from './front-view.js';
3
- export { browserHistory, logSender, applyTheme, bootFront, type BootOptions } from './browser.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';
4
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] ?? []);