@poadio/app-core 0.1.0 → 0.3.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/app.d.ts +2 -0
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +5 -1
  5. package/dist/app.js.map +1 -1
  6. package/dist/catalog.d.ts +100 -0
  7. package/dist/catalog.d.ts.map +1 -0
  8. package/dist/catalog.js +538 -0
  9. package/dist/catalog.js.map +1 -0
  10. package/dist/designer.d.ts +4 -0
  11. package/dist/designer.d.ts.map +1 -0
  12. package/dist/designer.js +6 -0
  13. package/dist/designer.js.map +1 -0
  14. package/dist/draft-toolbar.d.ts +59 -0
  15. package/dist/draft-toolbar.d.ts.map +1 -0
  16. package/dist/draft-toolbar.js +74 -0
  17. package/dist/draft-toolbar.js.map +1 -0
  18. package/dist/grid.d.ts +83 -0
  19. package/dist/grid.d.ts.map +1 -0
  20. package/dist/grid.js +188 -0
  21. package/dist/grid.js.map +1 -0
  22. package/dist/index.d.ts +9 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/model.d.ts +7 -2
  27. package/dist/model.d.ts.map +1 -1
  28. package/dist/model.js +7 -1
  29. package/dist/model.js.map +1 -1
  30. package/dist/nonvisual.d.ts +42 -0
  31. package/dist/nonvisual.d.ts.map +1 -0
  32. package/dist/nonvisual.js +89 -0
  33. package/dist/nonvisual.js.map +1 -0
  34. package/dist/preview.d.ts +13 -1
  35. package/dist/preview.d.ts.map +1 -1
  36. package/dist/preview.js +10 -2
  37. package/dist/preview.js.map +1 -1
  38. package/package.json +6 -1
  39. package/schema/front.v1.json +35 -2
  40. package/src/app.ts +5 -1
  41. package/src/catalog.ts +611 -0
  42. package/src/designer.ts +5 -0
  43. package/src/draft-toolbar.ts +104 -0
  44. package/src/grid.ts +189 -0
  45. package/src/index.ts +19 -1
  46. package/src/model.ts +9 -3
  47. package/src/nonvisual.ts +90 -0
  48. package/src/preview.ts +15 -3
package/src/catalog.ts ADDED
@@ -0,0 +1,611 @@
1
+ // Catalogue des composants qu'on pose sur la grille d'une page (boîte à outils du designer de la console).
2
+ //
3
+ // Un élément du catalogue dit tout ce que la console et le moteur ont besoin de savoir d'un type, sans framework :
4
+ // sa catégorie, son libellé (fr, en), son icône (jeu d'icônes de @poadio/ui-core), sa taille par défaut et sa
5
+ // taille minimale en unités de la grille (24 colonnes × lignes de `rowHeight` px), et ses propriétés principales
6
+ // avec leurs valeurs par défaut. Le rendu (quel composant de @poadio/ui-vue, avec quelles props) est l'affaire du
7
+ // moteur (@poadio/app-vue) ; l'édition (panneau de propriétés) celle de la console.
8
+ //
9
+ // Ajouter un type : une entrée ici, son rendu dans app-vue (items/), et la liste `type` de schema/front.v1.json
10
+ // (le test catalog.test.ts vérifie que les deux disent la même chose).
11
+ //
12
+ // Pas encore : liaison aux données (store @poadio/data), événements et actions, composants imbriqués
13
+ // (un conteneur garde un texte, pas d'éléments enfants), disposition propre à chaque taille d'écran.
14
+
15
+ export type Localized = { fr: string; en: string };
16
+ export type CatalogLang = 'fr' | 'en';
17
+
18
+ export type CategoryId = 'layout' | 'forms' | 'editors' | 'data' | 'geo' | 'planning' | 'navigation' | 'display' | 'nonvisual';
19
+
20
+ export type Category = { id: CategoryId; label: Localized; icon: string };
21
+
22
+ /** Les catégories, dans l'ordre de la boîte à outils */
23
+ export const CATEGORIES: readonly Category[] = [
24
+ { id: 'layout', label: { fr: 'Mise en page', en: 'Layout' }, icon: 'layers' },
25
+ { id: 'forms', label: { fr: 'Formulaires', en: 'Forms' }, icon: 'text-cursor-input' },
26
+ { id: 'editors', label: { fr: 'Éditeurs', en: 'Editors' }, icon: 'file-code' },
27
+ { id: 'data', label: { fr: 'Données', en: 'Data' }, icon: 'table' },
28
+ { id: 'geo', label: { fr: 'Carte', en: 'Map' }, icon: 'map' },
29
+ { id: 'planning', label: { fr: 'Planification', en: 'Planning' }, icon: 'calendar-days' },
30
+ { id: 'navigation', label: { fr: 'Navigation', en: 'Navigation' }, icon: 'compass' },
31
+ { id: 'display', label: { fr: 'Affichage', en: 'Display' }, icon: 'image' },
32
+ { id: 'nonvisual', label: { fr: 'Non visuels', en: 'Non-visual' }, icon: 'zap' },
33
+ ];
34
+
35
+ /**
36
+ * Une propriété éditable :
37
+ * text une ligne de texte (maxLength : 200 par défaut)
38
+ * longtext plusieurs lignes (maxLength : 2000 par défaut)
39
+ * lines une liste de textes, un par ligne (stockée en tableau ; 50 au plus)
40
+ * number un nombre, borné par min / max
41
+ * boolean oui / non
42
+ * choice une valeur parmi `options`
43
+ */
44
+ export type PropKind = 'text' | 'longtext' | 'lines' | 'number' | 'boolean' | 'choice';
45
+ export type PropValue = string | number | boolean | string[];
46
+ export type PropOption = { value: string; label: Localized };
47
+ export type PropSpec = {
48
+ key: string;
49
+ kind: PropKind;
50
+ label: Localized;
51
+ /** Valeur par défaut ; un texte peut dépendre de la langue de la console qui pose le composant */
52
+ default: PropValue | Localized | { fr: string[]; en: string[] };
53
+ options?: readonly PropOption[];
54
+ min?: number;
55
+ max?: number;
56
+ maxLength?: number;
57
+ };
58
+
59
+ export type GridSize = { w: number; h: number };
60
+
61
+ export type CatalogEntry = {
62
+ /** Clé du type, écrite dans la définition (`type` d'un élément de grille) */
63
+ type: string;
64
+ category: CategoryId;
65
+ label: Localized;
66
+ /** Nom d'une icône du jeu de @poadio/ui-core */
67
+ icon: string;
68
+ /** Taille posée par défaut (colonnes, lignes) */
69
+ size: GridSize;
70
+ /** Taille minimale (colonnes, lignes) */
71
+ min: GridSize;
72
+ /** Mots de recherche en plus du libellé (sans accent, minuscules) */
73
+ keywords?: readonly string[];
74
+ /**
75
+ * Composant non visuel (store, minuterie, boîte de dialogue…) : posé dans le bac « Composants non visuels » de la
76
+ * page (`nonVisual`), jamais sur la grille ; `size` et `min` n'ont pas de sens pour lui.
77
+ */
78
+ nonVisual?: true;
79
+ props: readonly PropSpec[];
80
+ };
81
+
82
+ // ------------------------------------------------------------------ aides de déclaration
83
+
84
+ const L = (fr: string, en: string): Localized => ({ fr, en });
85
+ const opt = (value: string, fr: string, en: string): PropOption => ({ value, label: L(fr, en) });
86
+
87
+ const SEVERITY = [
88
+ opt('primary', 'Principale', 'Primary'),
89
+ opt('secondary', 'Secondaire', 'Secondary'),
90
+ opt('success', 'Succès', 'Success'),
91
+ opt('warning', 'Attention', 'Warning'),
92
+ opt('danger', 'Danger', 'Danger'),
93
+ opt('info', 'Information', 'Info'),
94
+ ] as const;
95
+ const TONE = [
96
+ opt('primary', 'Principale', 'Primary'),
97
+ opt('success', 'Succès', 'Success'),
98
+ opt('warning', 'Attention', 'Warning'),
99
+ opt('danger', 'Danger', 'Danger'),
100
+ opt('info', 'Information', 'Info'),
101
+ opt('neutral', 'Neutre', 'Neutral'),
102
+ ] as const;
103
+ const ALIGN = [opt('left', 'À gauche', 'Left'), opt('center', 'Centré', 'Center'), opt('right', 'À droite', 'Right')] as const;
104
+ const SIZES = [opt('sm', 'Petite', 'Small'), opt('md', 'Moyenne', 'Medium'), opt('lg', 'Grande', 'Large')] as const;
105
+ const ORIENTATION = [opt('horizontal', 'Horizontale', 'Horizontal'), opt('vertical', 'Verticale', 'Vertical')] as const;
106
+
107
+ const text = (key: string, label: Localized, def: Localized | string = '', maxLength?: number): PropSpec => ({ key, kind: 'text', label, default: def, ...(maxLength ? { maxLength } : {}) });
108
+ const longtext = (key: string, label: Localized, def: Localized | string = ''): PropSpec => ({ key, kind: 'longtext', label, default: def });
109
+ const lines = (key: string, label: Localized, fr: string[], en: string[]): PropSpec => ({ key, kind: 'lines', label, default: { fr, en } });
110
+ const num = (key: string, label: Localized, def: number, min: number, max: number): PropSpec => ({ key, kind: 'number', label, default: def, min, max });
111
+ const bool = (key: string, label: Localized, def = false): PropSpec => ({ key, kind: 'boolean', label, default: def });
112
+ const choice = (key: string, label: Localized, def: string, options: readonly PropOption[]): PropSpec => ({ key, kind: 'choice', label, default: def, options });
113
+
114
+ // Libellés de propriétés employés plusieurs fois
115
+ const P = {
116
+ label: L('Libellé', 'Label'),
117
+ title: L('Titre', 'Title'),
118
+ subtitle: L('Sous-titre', 'Subtitle'),
119
+ content: L('Contenu', 'Content'),
120
+ placeholder: L('Texte indicatif', 'Placeholder'),
121
+ hint: L('Aide', 'Hint'),
122
+ required: L('Obligatoire', 'Required'),
123
+ options: L('Options (une par ligne)', 'Options (one per line)'),
124
+ items: L('Éléments (un par ligne)', 'Items (one per line)'),
125
+ severity: L('Couleur', 'Color'),
126
+ variant: L('Aspect', 'Style'),
127
+ size: L('Taille', 'Size'),
128
+ align: L('Alignement', 'Alignment'),
129
+ orientation: L('Orientation', 'Orientation'),
130
+ collapsible: L('Repliable', 'Collapsible'),
131
+ multiple: L('Choix multiple', 'Multiple choice'),
132
+ min: L('Minimum', 'Minimum'),
133
+ max: L('Maximum', 'Maximum'),
134
+ value: L('Valeur', 'Value'),
135
+ checked: L('Cochée au départ', 'Checked at start'),
136
+ on: L('Activé au départ', 'On at start'),
137
+ };
138
+
139
+ const OPTIONS_FR = ['Option 1', 'Option 2', 'Option 3'];
140
+ const OPTIONS_EN = ['Option 1', 'Option 2', 'Option 3'];
141
+
142
+ // ------------------------------------------------------------------ le catalogue
143
+
144
+ export const CATALOG: readonly CatalogEntry[] = [
145
+ // ---------------------------------------------------------------- Mise en page
146
+ {
147
+ type: 'card', category: 'layout', label: L('Carte', 'Card'), icon: 'square', size: { w: 8, h: 5 }, min: { w: 3, h: 2 }, keywords: ['card', 'bloc', 'encart'],
148
+ props: [text('header', P.title, L('Titre de la carte', 'Card title')), text('subheader', P.subtitle), longtext('body', P.content, L('Le contenu de la carte.', 'The card content.'))],
149
+ },
150
+ {
151
+ type: 'panel', category: 'layout', label: L('Panneau', 'Panel'), icon: 'panel-top', size: { w: 12, h: 5 }, min: { w: 4, h: 2 },
152
+ props: [text('header', P.title, L('Panneau', 'Panel')), bool('toggleable', P.collapsible), longtext('body', P.content, L('Le contenu du panneau.', 'The panel content.'))],
153
+ },
154
+ {
155
+ type: 'fieldset', category: 'layout', label: L('Groupe de champs', 'Fieldset'), icon: 'rows', size: { w: 12, h: 4 }, min: { w: 4, h: 2 }, keywords: ['legende', 'legend'],
156
+ props: [text('legend', L('Légende', 'Legend'), L('Informations', 'Details')), bool('toggleable', P.collapsible), longtext('body', P.content, L('Les champs du groupe se poseront ici.', 'The group fields will go here.'))],
157
+ },
158
+ {
159
+ type: 'divider', category: 'layout', label: L('Séparateur', 'Divider'), icon: 'minus', size: { w: 24, h: 1 }, min: { w: 2, h: 1 }, keywords: ['ligne', 'trait', 'separator', 'hr'],
160
+ props: [text('label', P.label), choice('align', P.align, 'center', ALIGN), bool('dashed', L('Tirets', 'Dashed'))],
161
+ },
162
+ {
163
+ type: 'tabs', category: 'layout', label: L('Onglets', 'Tabs'), icon: 'panel-top', size: { w: 24, h: 5 }, min: { w: 6, h: 2 },
164
+ props: [
165
+ lines('tabs', L('Onglets (un par ligne)', 'Tabs (one per line)'), ['Onglet 1', 'Onglet 2', 'Onglet 3'], ['Tab 1', 'Tab 2', 'Tab 3']),
166
+ choice('variant', P.variant, 'line', [opt('line', 'Trait', 'Line'), opt('pill', 'Pastille', 'Pill'), opt('enclosed', 'Encadré', 'Enclosed')]),
167
+ ],
168
+ },
169
+ {
170
+ type: 'accordion', category: 'layout', label: L('Accordéon', 'Accordion'), icon: 'list', size: { w: 12, h: 5 }, min: { w: 4, h: 3 },
171
+ props: [lines('panels', L('Sections (une par ligne)', 'Sections (one per line)'), ['Section 1', 'Section 2', 'Section 3'], ['Section 1', 'Section 2', 'Section 3']), bool('multiple', L('Plusieurs ouvertes', 'Several open'))],
172
+ },
173
+ {
174
+ type: 'stepper', category: 'layout', label: L('Étapes', 'Stepper'), icon: 'milestone', size: { w: 24, h: 3 }, min: { w: 8, h: 2 }, keywords: ['wizard', 'assistant'],
175
+ props: [lines('steps', L('Étapes (une par ligne)', 'Steps (one per line)'), ['Informations', 'Validation', 'Terminé'], ['Details', 'Review', 'Done']), num('current', L('Étape en cours (rang)', 'Current step (index)'), 0, 0, 49)],
176
+ },
177
+ {
178
+ type: 'splitter', category: 'layout', label: L('Panneaux redimensionnables', 'Splitter'), icon: 'columns', size: { w: 24, h: 6 }, min: { w: 6, h: 3 },
179
+ props: [choice('layout', P.orientation, 'horizontal', ORIENTATION), lines('panels', L('Panneaux (un par ligne)', 'Panels (one per line)'), ['Gauche', 'Droite'], ['Left', 'Right'])],
180
+ },
181
+
182
+ // ---------------------------------------------------------------- Formulaires
183
+ {
184
+ type: 'field', category: 'forms', label: L('Champ texte', 'Text field'), icon: 'text-cursor-input', size: { w: 8, h: 2 }, min: { w: 3, h: 2 }, keywords: ['input', 'saisie', 'texte'],
185
+ props: [
186
+ text('label', P.label, L('Libellé', 'Label')), text('placeholder', P.placeholder), text('hint', P.hint), bool('required', P.required),
187
+ choice('inputType', L('Type de saisie', 'Input type'), 'text', [opt('text', 'Texte', 'Text'), opt('email', 'Adresse e-mail', 'Email'), opt('tel', 'Téléphone', 'Phone'), opt('url', 'Adresse web', 'URL')]),
188
+ ],
189
+ },
190
+ {
191
+ type: 'textarea', category: 'forms', label: L('Zone de texte', 'Text area'), icon: 'file-text', size: { w: 12, h: 3 }, min: { w: 4, h: 2 }, keywords: ['multiligne', 'multiline'],
192
+ props: [text('label', P.label, L('Commentaire', 'Comment')), text('placeholder', P.placeholder), bool('required', P.required)],
193
+ },
194
+ {
195
+ type: 'button', category: 'forms', label: L('Bouton', 'Button'), icon: 'square', size: { w: 4, h: 1 }, min: { w: 2, h: 1 }, keywords: ['action', 'bouton'],
196
+ props: [
197
+ text('label', P.label, L('Valider', 'Submit'), 80),
198
+ choice('severity', P.severity, 'primary', SEVERITY),
199
+ choice('variant', P.variant, 'solid', [opt('solid', 'Plein', 'Solid'), opt('outline', 'Contour', 'Outline'), opt('text', 'Texte seul', 'Text')]),
200
+ bool('block', L('Toute la largeur', 'Full width')),
201
+ ],
202
+ },
203
+ {
204
+ type: 'button-group', category: 'forms', label: L('Groupe de boutons', 'Button group'), icon: 'columns', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
205
+ props: [lines('buttons', L('Boutons (un par ligne)', 'Buttons (one per line)'), ['Jour', 'Semaine', 'Mois'], ['Day', 'Week', 'Month']), choice('size', P.size, 'md', SIZES)],
206
+ },
207
+ {
208
+ type: 'checkbox', category: 'forms', label: L('Case à cocher', 'Checkbox'), icon: 'check-square', size: { w: 6, h: 1 }, min: { w: 2, h: 1 },
209
+ props: [text('label', P.label, L('J’accepte les conditions', 'I accept the terms')), bool('checked', P.checked)],
210
+ },
211
+ {
212
+ type: 'radio', category: 'forms', label: L('Boutons radio', 'Radio buttons'), icon: 'circle-dot', size: { w: 6, h: 3 }, min: { w: 3, h: 1 },
213
+ props: [text('label', P.label, L('Choix', 'Choice')), lines('options', P.options, OPTIONS_FR, OPTIONS_EN), choice('orientation', P.orientation, 'vertical', ORIENTATION)],
214
+ },
215
+ {
216
+ type: 'switch', category: 'forms', label: L('Interrupteur', 'Switch'), icon: 'toggle-left', size: { w: 6, h: 1 }, min: { w: 2, h: 1 }, keywords: ['toggle', 'bascule'],
217
+ props: [text('label', P.label, L('Notifications', 'Notifications')), bool('checked', P.on)],
218
+ },
219
+ {
220
+ type: 'toggle-button', category: 'forms', label: L('Bouton bascule', 'Toggle button'), icon: 'toggle-right', size: { w: 4, h: 1 }, min: { w: 2, h: 1 },
221
+ props: [text('onLabel', L('Libellé activé', 'On label'), L('Activé', 'On')), text('offLabel', L('Libellé désactivé', 'Off label'), L('Désactivé', 'Off'))],
222
+ },
223
+ {
224
+ type: 'segmented', category: 'forms', label: L('Choix segmenté', 'Segmented control'), icon: 'columns', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
225
+ props: [lines('options', P.options, ['Liste', 'Grille', 'Carte'], ['List', 'Grid', 'Map']), bool('block', L('Toute la largeur', 'Full width'))],
226
+ },
227
+ {
228
+ type: 'select', category: 'forms', label: L('Liste déroulante', 'Select'), icon: 'chevron-down', size: { w: 8, h: 2 }, min: { w: 3, h: 2 }, keywords: ['dropdown', 'liste'],
229
+ props: [text('label', P.label, L('Choix', 'Choice')), text('placeholder', P.placeholder, L('Choisir…', 'Choose…')), lines('options', P.options, OPTIONS_FR, OPTIONS_EN), bool('required', P.required)],
230
+ },
231
+ {
232
+ type: 'combo', category: 'forms', label: L('Saisie avec suggestions', 'Combo box'), icon: 'search', size: { w: 8, h: 2 }, min: { w: 3, h: 2 }, keywords: ['autocomplete', 'autocompletion'],
233
+ props: [text('label', P.label, L('Recherche', 'Search')), text('placeholder', P.placeholder, L('Tapez pour chercher', 'Type to search')), lines('options', L('Suggestions (une par ligne)', 'Suggestions (one per line)'), ['Paris', 'Lyon', 'Marseille', 'Nantes'], ['London', 'Paris', 'Berlin', 'Madrid'])],
234
+ },
235
+ {
236
+ type: 'listbox', category: 'forms', label: L('Liste de choix', 'List box'), icon: 'list-checks', size: { w: 6, h: 5 }, min: { w: 3, h: 2 },
237
+ props: [lines('options', P.options, OPTIONS_FR, OPTIONS_EN), bool('multiple', P.multiple), bool('filter', L('Recherche', 'Search box'))],
238
+ },
239
+ {
240
+ type: 'number', category: 'forms', label: L('Nombre', 'Number'), icon: 'hash', size: { w: 6, h: 2 }, min: { w: 2, h: 2 }, keywords: ['numerique', 'numeric', 'quantite'],
241
+ props: [text('label', P.label, L('Quantité', 'Quantity')), num('min', P.min, 0, -1e9, 1e9), num('max', P.max, 100, -1e9, 1e9), text('suffix', L('Unité', 'Unit'), '', 20)],
242
+ },
243
+ {
244
+ type: 'password', category: 'forms', label: L('Mot de passe', 'Password'), icon: 'key', size: { w: 8, h: 2 }, min: { w: 3, h: 2 },
245
+ props: [text('label', P.label, L('Mot de passe', 'Password')), text('placeholder', P.placeholder), bool('feedback', L('Indicateur de robustesse', 'Strength meter'))],
246
+ },
247
+ {
248
+ type: 'mask', category: 'forms', label: L('Saisie masquée', 'Masked input'), icon: 'text-cursor-input', size: { w: 8, h: 2 }, min: { w: 3, h: 2 }, keywords: ['telephone', 'phone', 'siret', 'masque'],
249
+ props: [
250
+ text('label', P.label, L('Téléphone', 'Phone')),
251
+ choice('preset', L('Format', 'Format'), 'phone', [opt('phone', 'Téléphone', 'Phone'), opt('postal', 'Code postal', 'Postal code'), opt('siret', 'SIRET', 'SIRET'), opt('date', 'Date', 'Date'), opt('time', 'Heure', 'Time'), opt('iban', 'IBAN', 'IBAN')]),
252
+ ],
253
+ },
254
+ {
255
+ type: 'datepicker', category: 'forms', label: L('Date', 'Date'), icon: 'calendar', size: { w: 6, h: 2 }, min: { w: 3, h: 2 }, keywords: ['date', 'calendrier', 'heure'],
256
+ props: [
257
+ text('label', P.label, L('Date', 'Date')),
258
+ choice('mode', L('Ce qu’on choisit', 'Picks'), 'date', [opt('date', 'Une date', 'A date'), opt('datetime', 'Date et heure', 'Date and time'), opt('time', 'Une heure', 'A time'), opt('month', 'Un mois', 'A month')]),
259
+ bool('range', L('Intervalle', 'Range')),
260
+ ],
261
+ },
262
+ {
263
+ type: 'color', category: 'forms', label: L('Couleur', 'Color'), icon: 'palette', size: { w: 6, h: 2 }, min: { w: 3, h: 2 }, keywords: ['colorpicker', 'teinte'],
264
+ props: [text('label', P.label, L('Couleur', 'Color')), bool('alpha', L('Opacité', 'Opacity'))],
265
+ },
266
+ {
267
+ type: 'slider', category: 'forms', label: L('Curseur', 'Slider'), icon: 'sliders-horizontal', size: { w: 8, h: 2 }, min: { w: 3, h: 1 }, keywords: ['range', 'glissiere'],
268
+ props: [text('label', P.label, L('Volume', 'Volume')), num('min', P.min, 0, -1e9, 1e9), num('max', P.max, 100, -1e9, 1e9), num('step', L('Pas', 'Step'), 1, 0.001, 1e9)],
269
+ },
270
+ {
271
+ type: 'rating', category: 'forms', label: L('Note', 'Rating'), icon: 'star', size: { w: 4, h: 1 }, min: { w: 2, h: 1 }, keywords: ['etoiles', 'stars'],
272
+ props: [num('max', L('Nombre d’étoiles', 'Number of stars'), 5, 1, 10), bool('readonly', L('Lecture seule', 'Read-only'))],
273
+ },
274
+ {
275
+ type: 'upload', category: 'forms', label: L('Envoi de fichiers', 'File upload'), icon: 'upload', size: { w: 12, h: 4 }, min: { w: 4, h: 1 }, keywords: ['fichier', 'file', 'televerser'],
276
+ props: [
277
+ choice('mode', L('Présentation', 'Presentation'), 'dropzone', [opt('advanced', 'Complète', 'Full'), opt('dropzone', 'Zone de dépôt', 'Drop zone'), opt('basic', 'Un bouton', 'A button')]),
278
+ bool('multiple', L('Plusieurs fichiers', 'Several files')),
279
+ text('accept', L('Types acceptés', 'Accepted types'), '', 120),
280
+ ],
281
+ },
282
+ {
283
+ type: 'multiselect', category: 'forms', label: L('Sélection multiple', 'Multi-select'), icon: 'list-checks', size: { w: 8, h: 2 }, min: { w: 3, h: 2 }, keywords: ['plusieurs', 'tags'],
284
+ props: [text('label', P.label, L('Étiquettes', 'Tags')), text('placeholder', P.placeholder, L('Choisir…', 'Choose…')), lines('options', P.options, OPTIONS_FR, OPTIONS_EN)],
285
+ },
286
+ {
287
+ type: 'picklist', category: 'forms', label: L('Listes de transfert', 'Pick list'), icon: 'arrow-left-right', size: { w: 16, h: 6 }, min: { w: 8, h: 4 }, keywords: ['transfert', 'deux listes'],
288
+ props: [lines('options', L('Éléments disponibles (un par ligne)', 'Available items (one per line)'), ['Lyon', 'Paris', 'Nantes', 'Lille'], ['London', 'Paris', 'Berlin', 'Madrid']), text('sourceHeader', L('Titre de la liste de gauche', 'Left list title'), L('Disponibles', 'Available')), text('targetHeader', L('Titre de la liste de droite', 'Right list title'), L('Choisis', 'Chosen'))],
289
+ },
290
+ {
291
+ type: 'orderlist', category: 'forms', label: L('Liste à ordonner', 'Order list'), icon: 'arrow-up-down', size: { w: 8, h: 6 }, min: { w: 4, h: 3 }, keywords: ['tri', 'ordre', 'reorder'],
292
+ props: [lines('items', P.items, ['Étude', 'Chantier', 'Réception'], ['Study', 'Works', 'Handover']), text('header', P.title, L('Étapes', 'Steps'))],
293
+ },
294
+ {
295
+ type: 'inplace', category: 'forms', label: L('Édition sur place', 'Inplace'), icon: 'pencil', size: { w: 8, h: 1 }, min: { w: 3, h: 1 }, keywords: ['modifier', 'inline'],
296
+ props: [text('display', L('Texte affiché', 'Displayed text'), L('Cliquez pour modifier', 'Click to edit'))],
297
+ },
298
+ {
299
+ type: 'split-button', category: 'forms', label: L('Bouton à options', 'Split button'), icon: 'chevrons-down', size: { w: 5, h: 1 }, min: { w: 3, h: 1 }, keywords: ['menu', 'variantes'],
300
+ props: [text('label', P.label, L('Enregistrer', 'Save'), 80), lines('items', L('Variantes (une par ligne)', 'Variants (one per line)'), ['Enregistrer et fermer', 'Enregistrer comme modèle'], ['Save and close', 'Save as template']), choice('severity', P.severity, 'primary', SEVERITY)],
301
+ },
302
+ {
303
+ type: 'filter-chip', category: 'forms', label: L('Puce de filtre', 'Filter chip'), icon: 'filter', size: { w: 4, h: 1 }, min: { w: 2, h: 1 }, keywords: ['filtre'],
304
+ props: [text('label', P.label, L('Statut', 'Status'), 60), text('value', P.value, L('En cours', 'Ongoing'), 60), bool('active', L('Actif', 'Active'), true)],
305
+ },
306
+ {
307
+ type: 'richtext', category: 'editors', label: L('Texte riche', 'Rich text'), icon: 'type', size: { w: 12, h: 5 }, min: { w: 6, h: 3 }, keywords: ['editeur', 'editor', 'wysiwyg'],
308
+ props: [text('placeholder', P.placeholder, L('Écrivez ici…', 'Write here…'))],
309
+ },
310
+ {
311
+ type: 'code', category: 'editors', label: L('Éditeur de code', 'Code editor'), icon: 'code', size: { w: 12, h: 7 }, min: { w: 6, h: 4 }, keywords: ['monaco', 'sql', 'javascript'],
312
+ props: [
313
+ choice('language', L('Langage', 'Language'), 'javascript', [opt('javascript', 'JavaScript', 'JavaScript'), opt('typescript', 'TypeScript', 'TypeScript'), opt('sql', 'SQL', 'SQL'), opt('json', 'JSON', 'JSON'), opt('python', 'Python', 'Python'), opt('html', 'HTML', 'HTML'), opt('css', 'CSS', 'CSS'), opt('markdown', 'Markdown', 'Markdown'), opt('plaintext', 'Texte brut', 'Plain text')]),
314
+ longtext('value', L('Contenu', 'Content'), 'const total = chantiers.length;\nconsole.log(total);'),
315
+ bool('readonly', L('Lecture seule', 'Read-only')),
316
+ ],
317
+ },
318
+ {
319
+ type: 'json', category: 'editors', label: L('Éditeur JSON', 'JSON editor'), icon: 'braces', size: { w: 12, h: 7 }, min: { w: 6, h: 4 }, keywords: ['objet', 'object'],
320
+ props: [longtext('value', L('Contenu (JSON)', 'Content (JSON)'), '{\n "nom": "Pont de Saône",\n "avancement": 72,\n "actif": true\n}'), bool('readonly', L('Lecture seule', 'Read-only'))],
321
+ },
322
+ {
323
+ type: 'block-editor', category: 'editors', label: L('Éditeur de blocs', 'Block editor'), icon: 'notebook', size: { w: 12, h: 8 }, min: { w: 6, h: 4 }, keywords: ['editorjs', 'document', 'article'],
324
+ props: [text('placeholder', P.placeholder, L('Écrivez, ou tapez / pour un bloc…', 'Write, or type / for a block…'))],
325
+ },
326
+ {
327
+ type: 'block-view', category: 'editors', label: L('Document', 'Document'), icon: 'book-open', size: { w: 12, h: 6 }, min: { w: 4, h: 2 }, keywords: ['lecture', 'article', 'editorjs'],
328
+ props: [text('title', P.title, L('Compte rendu de chantier', 'Site report')), longtext('body', P.content, L('Le texte du document, affiché tel qu’il a été écrit dans l’éditeur de blocs.', 'The document text, shown as written in the block editor.'))],
329
+ },
330
+
331
+ // ---------------------------------------------------------------- Données
332
+ {
333
+ type: 'table', category: 'data', label: L('Tableau', 'Table'), icon: 'table', size: { w: 24, h: 8 }, min: { w: 8, h: 3 }, keywords: ['grille', 'datatable', 'lignes'],
334
+ props: [
335
+ lines('columns', L('Colonnes (une par ligne)', 'Columns (one per line)'), ['Nom', 'Statut', 'Date'], ['Name', 'Status', 'Date']),
336
+ text('emptyMessage', L('Message sans ligne', 'Empty message'), L('Aucune ligne : la source de données viendra à l’étape suivante.', 'No rows yet: the data source comes next.')),
337
+ bool('paginator', L('Pagination', 'Pagination')),
338
+ bool('striped', L('Lignes alternées', 'Striped rows')),
339
+ ],
340
+ },
341
+ {
342
+ type: 'dataview', category: 'data', label: L('Liste de fiches', 'Data view'), icon: 'grid', size: { w: 24, h: 8 }, min: { w: 6, h: 3 },
343
+ props: [choice('layout', L('Présentation', 'Layout'), 'grid', [opt('list', 'Liste', 'List'), opt('grid', 'Grille', 'Grid')]), text('emptyMessage', L('Message sans fiche', 'Empty message'), L('Aucune fiche pour l’instant.', 'Nothing to show yet.'))],
344
+ },
345
+ {
346
+ type: 'tree', category: 'data', label: L('Arbre', 'Tree'), icon: 'folder-tree', size: { w: 8, h: 8 }, min: { w: 4, h: 3 }, keywords: ['arborescence', 'hierarchie'],
347
+ props: [lines('nodes', L('Nœuds racines (un par ligne)', 'Root nodes (one per line)'), ['Documents', 'Images', 'Archives'], ['Documents', 'Pictures', 'Archive'])],
348
+ },
349
+ {
350
+ type: 'paginator', category: 'data', label: L('Pagination', 'Paginator'), icon: 'ellipsis', size: { w: 12, h: 1 }, min: { w: 6, h: 1 },
351
+ props: [num('totalRecords', L('Nombre de lignes', 'Total rows'), 120, 0, 1e9), num('rows', L('Lignes par page', 'Rows per page'), 10, 1, 1000)],
352
+ },
353
+ {
354
+ type: 'chart', category: 'data', label: L('Graphique', 'Chart'), icon: 'chart-bar', size: { w: 12, h: 7 }, min: { w: 4, h: 4 }, keywords: ['diagramme', 'courbe', 'histogramme', 'camembert'],
355
+ props: [
356
+ choice('chartType', L('Type', 'Type'), 'bar', [opt('bar', 'Barres', 'Bars'), opt('line', 'Courbe', 'Line'), opt('pie', 'Secteurs', 'Pie'), opt('doughnut', 'Anneau', 'Doughnut')]),
357
+ text('series', L('Nom de la série', 'Series name'), L('Ventes', 'Sales')),
358
+ lines('labels', L('Étiquettes (une par ligne)', 'Labels (one per line)'), ['Jan', 'Fév', 'Mar', 'Avr', 'Mai'], ['Jan', 'Feb', 'Mar', 'Apr', 'May']),
359
+ lines('values', L('Valeurs (une par ligne)', 'Values (one per line)'), ['12', '19', '7', '15', '22'], ['12', '19', '7', '15', '22']),
360
+ ],
361
+ },
362
+ {
363
+ type: 'meter', category: 'data', label: L('Jauge', 'Meter'), icon: 'gauge', size: { w: 12, h: 2 }, min: { w: 4, h: 1 },
364
+ props: [text('label', P.label, L('Espace utilisé', 'Space used')), num('value', P.value, 64, 0, 1e9), num('max', P.max, 100, 1, 1e9), text('unit', L('Unité', 'Unit'), '%', 20)],
365
+ },
366
+ {
367
+ type: 'progress', category: 'data', label: L('Barre de progression', 'Progress bar'), icon: 'loader', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
368
+ props: [text('label', P.label), num('value', P.value, 40, 0, 100), bool('showValue', L('Afficher la valeur', 'Show value'), true), choice('severity', P.severity, 'primary', TONE.filter((o) => o.value !== 'neutral'))],
369
+ },
370
+ {
371
+ type: 'timeline', category: 'data', label: L('Frise chronologique', 'Timeline'), icon: 'activity', size: { w: 8, h: 6 }, min: { w: 4, h: 3 },
372
+ props: [lines('events', L('Évènements (un par ligne)', 'Events (one per line)'), ['Commande', 'Préparation', 'Expédition', 'Livraison'], ['Ordered', 'Processing', 'Shipped', 'Delivered']), choice('layout', P.orientation, 'vertical', ORIENTATION)],
373
+ },
374
+ {
375
+ type: 'orgchart', category: 'data', label: L('Organigramme', 'Org chart'), icon: 'git-fork', size: { w: 16, h: 8 }, min: { w: 6, h: 4 },
376
+ props: [text('root', L('Racine', 'Root'), L('Direction', 'Management')), lines('children', L('Branches (une par ligne)', 'Branches (one per line)'), ['Études', 'Travaux', 'Support'], ['Research', 'Operations', 'Support'])],
377
+ },
378
+
379
+ // ---------------------------------------------------------------- Carte
380
+ {
381
+ type: 'map', category: 'geo', label: L('Carte', 'Map'), icon: 'map', size: { w: 24, h: 10 }, min: { w: 6, h: 5 }, keywords: ['maplibre', 'ign', 'geographie', 'plan'],
382
+ props: [
383
+ choice('basemap', L('Fond de carte', 'Basemap'), 'ign-plan', [opt('ign-plan', 'Plan IGN', 'IGN map'), opt('ign-ortho', 'Photos aériennes IGN', 'IGN aerial'), opt('osm', 'OpenStreetMap', 'OpenStreetMap'), opt('light', 'Clair', 'Light'), opt('dark', 'Sombre', 'Dark')]),
384
+ num('zoom', L('Zoom', 'Zoom'), 5, 0, 20),
385
+ ],
386
+ },
387
+
388
+ // ---------------------------------------------------------------- Planification
389
+ {
390
+ type: 'calendar', category: 'planning', label: L('Calendrier', 'Calendar'), icon: 'calendar-days', size: { w: 24, h: 12 }, min: { w: 8, h: 6 }, keywords: ['agenda', 'evenements'],
391
+ props: [choice('view', L('Vue', 'View'), 'month', [opt('month', 'Mois', 'Month'), opt('week', 'Semaine', 'Week'), opt('day', 'Jour', 'Day'), opt('agenda', 'Agenda', 'Agenda')])],
392
+ },
393
+ {
394
+ type: 'scheduler', category: 'planning', label: L('Planning de ressources', 'Resource scheduler'), icon: 'calendar-range', size: { w: 24, h: 10 }, min: { w: 10, h: 5 }, keywords: ['ressources', 'resources'],
395
+ props: [choice('scale', L('Échelle', 'Scale'), 'week', [opt('day', 'Jour', 'Day'), opt('week', 'Semaine', 'Week'), opt('month', 'Mois', 'Month')])],
396
+ },
397
+ {
398
+ type: 'gantt', category: 'planning', label: L('Diagramme de Gantt', 'Gantt chart'), icon: 'chart-no-axes-gantt', size: { w: 24, h: 10 }, min: { w: 10, h: 5 }, keywords: ['taches', 'projet'],
399
+ props: [choice('scale', L('Échelle', 'Scale'), 'week', [opt('day', 'Jour', 'Day'), opt('week', 'Semaine', 'Week'), opt('month', 'Mois', 'Month')])],
400
+ },
401
+ {
402
+ type: 'taskboard', category: 'planning', label: L('Tableau de tâches', 'Task board'), icon: 'kanban', size: { w: 24, h: 10 }, min: { w: 8, h: 5 }, keywords: ['kanban', 'colonnes'],
403
+ props: [choice('mode', L('Présentation', 'Presentation'), 'board', [opt('board', 'Cartes', 'Board'), opt('list', 'Liste', 'List')])],
404
+ },
405
+
406
+ // ---------------------------------------------------------------- Navigation
407
+ {
408
+ type: 'menubar', category: 'navigation', label: L('Barre de menu', 'Menu bar'), icon: 'menu', size: { w: 24, h: 2 }, min: { w: 6, h: 2 },
409
+ props: [choice('source', L('Éléments', 'Items'), 'pages', [opt('pages', 'Les pages du front', 'The front pages'), opt('custom', 'Liste libre', 'Custom list')]), lines('items', L('Liste libre (un par ligne)', 'Custom list (one per line)'), ['Accueil', 'Produits', 'Contact'], ['Home', 'Products', 'Contact'])],
410
+ },
411
+ {
412
+ type: 'breadcrumb', category: 'navigation', label: L('Fil d’Ariane', 'Breadcrumb'), icon: 'chevrons-right', size: { w: 12, h: 1 }, min: { w: 4, h: 1 },
413
+ props: [lines('items', P.items, ['Accueil', 'Catalogue', 'Fiche'], ['Home', 'Catalog', 'Item'])],
414
+ },
415
+ {
416
+ type: 'bottom-nav', category: 'navigation', label: L('Barre de navigation mobile', 'Bottom navigation'), icon: 'panel-bottom', size: { w: 24, h: 2 }, min: { w: 6, h: 2 }, keywords: ['onglets', 'mobile'],
417
+ props: [choice('source', L('Éléments', 'Items'), 'pages', [opt('pages', 'Les pages du front', 'The front pages'), opt('custom', 'Liste libre', 'Custom list')]), lines('items', L('Liste libre (un par ligne)', 'Custom list (one per line)'), ['Accueil', 'Recherche', 'Profil'], ['Home', 'Search', 'Profile'])],
418
+ },
419
+ {
420
+ type: 'speed-dial', category: 'navigation', label: L('Bouton d’actions', 'Speed dial'), icon: 'plus', size: { w: 2, h: 2 }, min: { w: 2, h: 2 }, keywords: ['fab', 'actions'],
421
+ props: [lines('items', L('Actions (une par ligne)', 'Actions (one per line)'), ['Modifier', 'Partager', 'Supprimer'], ['Edit', 'Share', 'Delete']), choice('direction', L('Direction', 'Direction'), 'up', [opt('up', 'Vers le haut', 'Up'), opt('down', 'Vers le bas', 'Down'), opt('left', 'Vers la gauche', 'Left'), opt('right', 'Vers la droite', 'Right')])],
422
+ },
423
+ {
424
+ type: 'nav-drawer', category: 'navigation', label: L('Menu latéral', 'Navigation drawer'), icon: 'panel-left', size: { w: 6, h: 8 }, min: { w: 4, h: 4 }, keywords: ['sidebar', 'tiroir', 'menu'],
425
+ props: [lines('items', P.items, ['Tableau de bord', 'Chantiers', 'Équipes', 'Réglages'], ['Dashboard', 'Sites', 'Teams', 'Settings'])],
426
+ },
427
+ {
428
+ type: 'scroll-top', category: 'navigation', label: L('Retour en haut', 'Scroll to top'), icon: 'arrow-up', size: { w: 2, h: 2 }, min: { w: 1, h: 1 }, keywords: ['remonter', 'haut de page'],
429
+ props: [num('threshold', L('Apparaît après (px défilés)', 'Shows after (px scrolled)'), 400, 0, 10000)],
430
+ },
431
+
432
+ // ---------------------------------------------------------------- Affichage
433
+ {
434
+ type: 'heading', category: 'display', label: L('Titre', 'Heading'), icon: 'heading', size: { w: 12, h: 1 }, min: { w: 2, h: 1 }, keywords: ['titre', 'h1', 'h2'],
435
+ props: [text('text', L('Texte', 'Text'), L('Titre de la section', 'Section title')), choice('level', L('Niveau', 'Level'), 'h2', [opt('h1', 'Titre 1', 'Heading 1'), opt('h2', 'Titre 2', 'Heading 2'), opt('h3', 'Titre 3', 'Heading 3')]), choice('align', P.align, 'left', ALIGN)],
436
+ },
437
+ {
438
+ type: 'text', category: 'display', label: L('Texte', 'Text'), icon: 'type', size: { w: 12, h: 2 }, min: { w: 2, h: 1 }, keywords: ['paragraphe', 'paragraph'],
439
+ props: [longtext('text', L('Texte', 'Text'), L('Un paragraphe de texte. Modifiez-le dans le panneau des propriétés.', 'A paragraph of text. Edit it in the properties panel.')), choice('align', P.align, 'left', ALIGN)],
440
+ },
441
+ {
442
+ type: 'image', category: 'display', label: L('Image', 'Image'), icon: 'image', size: { w: 8, h: 5 }, min: { w: 2, h: 2 }, keywords: ['photo', 'illustration'],
443
+ props: [text('src', L('Adresse de l’image', 'Image address'), '', 500), text('alt', L('Texte de remplacement', 'Alternative text')), choice('fit', L('Cadrage', 'Fit'), 'cover', [opt('cover', 'Remplir', 'Cover'), opt('contain', 'Contenir', 'Contain')]), bool('rounded', L('Coins arrondis', 'Rounded corners'))],
444
+ },
445
+ {
446
+ type: 'avatar', category: 'display', label: L('Avatar', 'Avatar'), icon: 'user', size: { w: 2, h: 2 }, min: { w: 1, h: 1 },
447
+ props: [text('text', L('Nom', 'Name'), 'Ada Lovelace', 80), choice('size', P.size, 'lg', SIZES), choice('shape', L('Forme', 'Shape'), 'circle', [opt('circle', 'Rond', 'Circle'), opt('square', 'Carré', 'Square')])],
448
+ },
449
+ {
450
+ type: 'avatar-group', category: 'display', label: L('Groupe d’avatars', 'Avatar group'), icon: 'users', size: { w: 4, h: 2 }, min: { w: 2, h: 1 }, keywords: ['equipe', 'team'],
451
+ props: [lines('names', L('Noms (un par ligne)', 'Names (one per line)'), ['Ada Lovelace', 'Alan Turing', 'Grace Hopper', 'Edsger Dijkstra'], ['Ada Lovelace', 'Alan Turing', 'Grace Hopper', 'Edsger Dijkstra']), num('max', L('Avatars visibles', 'Visible avatars'), 3, 1, 12)],
452
+ },
453
+ {
454
+ type: 'badge', category: 'display', label: L('Pastille', 'Badge'), icon: 'circle', size: { w: 2, h: 1 }, min: { w: 1, h: 1 }, keywords: ['compteur', 'counter'],
455
+ props: [text('value', P.value, '3', 12), choice('severity', P.severity, 'danger', TONE)],
456
+ },
457
+ {
458
+ type: 'tag', category: 'display', label: L('Étiquette', 'Tag'), icon: 'tag', size: { w: 3, h: 1 }, min: { w: 1, h: 1 },
459
+ props: [text('value', P.label, L('Nouveau', 'New'), 60), choice('severity', P.severity, 'primary', TONE), bool('rounded', L('Arrondie', 'Rounded'))],
460
+ },
461
+ {
462
+ type: 'chip', category: 'display', label: L('Puce', 'Chip'), icon: 'tags', size: { w: 4, h: 1 }, min: { w: 2, h: 1 },
463
+ props: [text('label', P.label, L('Filtre', 'Filter'), 60), bool('removable', L('Bouton de retrait', 'Remove button'))],
464
+ },
465
+ {
466
+ type: 'carousel', category: 'display', label: L('Carrousel', 'Carousel'), icon: 'images', size: { w: 24, h: 6 }, min: { w: 6, h: 3 }, keywords: ['diaporama', 'slider'],
467
+ props: [lines('slides', L('Diapositives (une par ligne)', 'Slides (one per line)'), ['Première', 'Deuxième', 'Troisième'], ['First', 'Second', 'Third']), num('numVisible', L('Visibles à la fois', 'Visible at once'), 1, 1, 6)],
468
+ },
469
+ {
470
+ type: 'icon', category: 'display', label: L('Icône', 'Icon'), icon: 'smile', size: { w: 1, h: 1 }, min: { w: 1, h: 1 },
471
+ props: [text('name', L('Nom de l’icône', 'Icon name'), 'star', 40), num('size', P.size, 24, 8, 128)],
472
+ },
473
+ {
474
+ type: 'message', category: 'display', label: L('Message', 'Message'), icon: 'info', size: { w: 12, h: 2 }, min: { w: 3, h: 1 }, keywords: ['alerte', 'alert', 'notice'],
475
+ props: [text('text', L('Texte', 'Text'), L('Un message à l’attention des visiteurs.', 'A message for visitors.'), 500), choice('severity', P.severity, 'info', [opt('info', 'Information', 'Info'), opt('success', 'Succès', 'Success'), opt('warning', 'Attention', 'Warning'), opt('danger', 'Danger', 'Danger')])],
476
+ },
477
+ {
478
+ type: 'skeleton', category: 'display', label: L('Squelette', 'Skeleton'), icon: 'square-dashed', size: { w: 8, h: 2 }, min: { w: 1, h: 1 }, keywords: ['chargement', 'loading'],
479
+ props: [choice('shape', L('Forme', 'Shape'), 'text', [opt('text', 'Lignes de texte', 'Text lines'), opt('rect', 'Bloc', 'Block'), opt('circle', 'Rond', 'Circle')]), num('lines', L('Lignes', 'Lines'), 3, 1, 12)],
480
+ },
481
+ {
482
+ type: 'spinner', category: 'display', label: L('Indicateur de chargement', 'Spinner'), icon: 'loader', size: { w: 2, h: 2 }, min: { w: 1, h: 1 }, keywords: ['chargement', 'loading', 'attente'],
483
+ props: [num('size', P.size, 32, 12, 128)],
484
+ },
485
+
486
+ // ---------------------------------------------------------------- Non visuels (bac de la page, jamais sur la grille)
487
+ {
488
+ type: 'store', category: 'nonvisual', nonVisual: true, label: L('Source de données', 'Data store'), icon: 'database', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['store', 'table', 'donnees'],
489
+ props: [text('table', L('Table', 'Table'), '', 120)],
490
+ },
491
+ {
492
+ type: 'timer', category: 'nonvisual', nonVisual: true, label: L('Minuterie', 'Timer'), icon: 'clock', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['intervalle', 'interval'],
493
+ props: [num('interval', L('Intervalle (ms)', 'Interval (ms)'), 1000, 100, 86400000), bool('enabled', L('Actif', 'Enabled'), true)],
494
+ },
495
+ {
496
+ type: 'dialog', category: 'nonvisual', nonVisual: true, label: L('Boîte de dialogue', 'Dialog'), icon: 'message-square', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['modale', 'modal', 'fenetre'],
497
+ props: [text('title', P.title, L('Détails', 'Details'))],
498
+ },
499
+ {
500
+ type: 'toast', category: 'nonvisual', nonVisual: true, label: L('Notification', 'Toast'), icon: 'bell', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['toast', 'message'],
501
+ props: [choice('severity', L('Couleur par défaut', 'Default color'), 'info', [opt('info', 'Information', 'Info'), opt('success', 'Succès', 'Success'), opt('warning', 'Attention', 'Warning'), opt('danger', 'Danger', 'Danger')])],
502
+ },
503
+ {
504
+ type: 'confirm', category: 'nonvisual', nonVisual: true, label: L('Confirmation', 'Confirm'), icon: 'help-circle', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['confirmer', 'question'],
505
+ props: [longtext('message', L('Message', 'Message'), L('Voulez-vous vraiment continuer ?', 'Do you really want to continue?'))],
506
+ },
507
+ {
508
+ type: 'action', category: 'nonvisual', nonVisual: true, label: L('Action', 'Action'), icon: 'zap', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['fonction', 'flow', 'appel'],
509
+ props: [choice('kind', L('Appelle', 'Calls'), 'function', [opt('function', 'Une fonction', 'A function'), opt('flow', 'Un flow', 'A flow')]), text('target', L('Nom de la fonction ou du flow', 'Function or flow name'), '', 120)],
510
+ },
511
+ {
512
+ type: 'variable', category: 'nonvisual', nonVisual: true, label: L('Variable', 'Variable'), icon: 'braces', size: { w: 1, h: 1 }, min: { w: 1, h: 1 }, keywords: ['etat', 'state', 'valeur'],
513
+ props: [text('initial', L('Valeur initiale', 'Initial value'), '', 500)],
514
+ },
515
+ ];
516
+
517
+ // ------------------------------------------------------------------ accès
518
+
519
+ const BY_TYPE = new Map(CATALOG.map((e) => [e.type, e]));
520
+
521
+ /** Les clés de type du catalogue, dans l'ordre */
522
+ export const CATALOG_TYPES: readonly string[] = CATALOG.map((e) => e.type);
523
+ /** Types posés sur la grille */
524
+ export const VISUAL_TYPES: readonly string[] = CATALOG.filter((e) => !e.nonVisual).map((e) => e.type);
525
+ /** Types non visuels (bac de la page) */
526
+ export const NONVISUAL_TYPES: readonly string[] = CATALOG.filter((e) => e.nonVisual).map((e) => e.type);
527
+ export const isNonVisual = (type: string): boolean => !!BY_TYPE.get(type)?.nonVisual;
528
+
529
+ export const catalogEntry = (type: string): CatalogEntry | undefined => BY_TYPE.get(type);
530
+
531
+ export const localize = (v: Localized, lang: CatalogLang): string => v[lang] ?? v.fr;
532
+
533
+ /** Langue du catalogue d'après une langue d'interface (en, en-GB → en ; le reste → fr) */
534
+ export const catalogLang = (lang: string | null | undefined): CatalogLang => (lang && lang.toLowerCase().startsWith('en') ? 'en' : 'fr');
535
+
536
+ const isLocalized = (v: unknown): v is Localized | { fr: string[]; en: string[] } => typeof v === 'object' && v !== null && !Array.isArray(v) && 'fr' in v;
537
+
538
+ /** Valeur par défaut d'une propriété dans une langue */
539
+ export const defaultValue = (spec: PropSpec, lang: CatalogLang): PropValue => {
540
+ const d = spec.default;
541
+ if (isLocalized(d)) {
542
+ const v = (d as Record<CatalogLang, string | string[]>)[lang] ?? (d as Record<CatalogLang, string | string[]>).fr;
543
+ return Array.isArray(v) ? [...v] : v;
544
+ }
545
+ return Array.isArray(d) ? [...d] : (d as PropValue);
546
+ };
547
+
548
+ /** Les props d'un composant neuf : toutes ses propriétés à leur valeur par défaut, dans la langue de la console */
549
+ export const defaultProps = (type: string, lang: CatalogLang = 'fr'): Record<string, PropValue> => {
550
+ const e = catalogEntry(type);
551
+ if (!e) return {};
552
+ return Object.fromEntries(e.props.map((p) => [p.key, defaultValue(p, lang)]));
553
+ };
554
+
555
+ export const MAX_TEXT = 200;
556
+ export const MAX_LONGTEXT = 2000;
557
+ export const MAX_LINES = 50;
558
+ export const MAX_LINE = 200;
559
+
560
+ /** Écart d'une valeur de propriété à sa déclaration ; null si elle convient */
561
+ export const checkPropValue = (spec: PropSpec, v: unknown): string | null => {
562
+ switch (spec.kind) {
563
+ case 'text':
564
+ case 'longtext': {
565
+ if (typeof v !== 'string') return 'must be a string';
566
+ const max = spec.maxLength ?? (spec.kind === 'text' ? MAX_TEXT : MAX_LONGTEXT);
567
+ return [...v].length > max ? `must be at most ${max} characters` : null;
568
+ }
569
+ case 'lines':
570
+ if (!Array.isArray(v) || v.some((x) => typeof x !== 'string')) return 'must be an array of strings';
571
+ if (v.length > MAX_LINES) return `must have at most ${MAX_LINES} lines`;
572
+ return v.some((x: string) => [...x].length > MAX_LINE) ? `each line must be at most ${MAX_LINE} characters` : null;
573
+ case 'number':
574
+ if (typeof v !== 'number' || !Number.isFinite(v)) return 'must be a number';
575
+ if (spec.min !== undefined && v < spec.min) return `must be ≥ ${spec.min}`;
576
+ if (spec.max !== undefined && v > spec.max) return `must be ≤ ${spec.max}`;
577
+ return null;
578
+ case 'boolean':
579
+ return typeof v === 'boolean' ? null : 'must be a boolean';
580
+ case 'choice':
581
+ return typeof v === 'string' && (spec.options ?? []).some((o) => o.value === v) ? null : `must be one of ${(spec.options ?? []).map((o) => JSON.stringify(o.value)).join(', ')}`;
582
+ }
583
+ };
584
+
585
+ /**
586
+ * Les props d'un élément, complétées par les valeurs par défaut (une propriété ajoutée au catalogue après coup
587
+ * prend sa valeur par défaut, en français) ; une valeur qui ne convient pas est remplacée par la valeur par défaut.
588
+ * Le moteur affiche toujours ce résultat, jamais la définition brute.
589
+ */
590
+ export const resolveProps = (type: string, props: Record<string, unknown> | undefined, lang: CatalogLang = 'fr'): Record<string, PropValue> => {
591
+ const e = catalogEntry(type);
592
+ if (!e) return {};
593
+ const out: Record<string, PropValue> = {};
594
+ for (const spec of e.props) {
595
+ const v = props?.[spec.key];
596
+ out[spec.key] = v !== undefined && checkPropValue(spec, v) === null ? (v as PropValue) : defaultValue(spec, lang);
597
+ }
598
+ return out;
599
+ };
600
+
601
+ /** Catalogue par catégorie, filtré par une recherche (libellé fr ou en, clé du type, mots-clés ; sans accent) */
602
+ export const searchCatalog = (query: string, lang: CatalogLang = 'fr'): { category: Category; entries: CatalogEntry[] }[] => {
603
+ const fold = (s: string) => s.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
604
+ const words = fold(query).split(/\s+/).filter(Boolean);
605
+ const match = (e: CatalogEntry) => {
606
+ if (!words.length) return true;
607
+ const hay = fold([e.label.fr, e.label.en, e.type, ...(e.keywords ?? []), localize(CATEGORIES.find((c) => c.id === e.category)!.label, lang)].join(' '));
608
+ return words.every((w) => hay.includes(w));
609
+ };
610
+ return CATEGORIES.map((category) => ({ category, entries: CATALOG.filter((e) => e.category === category.id && match(e)) })).filter((g) => g.entries.length > 0);
611
+ };