@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
@@ -0,0 +1,538 @@
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
+ /** Les catégories, dans l'ordre de la boîte à outils */
15
+ export const CATEGORIES = [
16
+ { id: 'layout', label: { fr: 'Mise en page', en: 'Layout' }, icon: 'layers' },
17
+ { id: 'forms', label: { fr: 'Formulaires', en: 'Forms' }, icon: 'text-cursor-input' },
18
+ { id: 'editors', label: { fr: 'Éditeurs', en: 'Editors' }, icon: 'file-code' },
19
+ { id: 'data', label: { fr: 'Données', en: 'Data' }, icon: 'table' },
20
+ { id: 'geo', label: { fr: 'Carte', en: 'Map' }, icon: 'map' },
21
+ { id: 'planning', label: { fr: 'Planification', en: 'Planning' }, icon: 'calendar-days' },
22
+ { id: 'navigation', label: { fr: 'Navigation', en: 'Navigation' }, icon: 'compass' },
23
+ { id: 'display', label: { fr: 'Affichage', en: 'Display' }, icon: 'image' },
24
+ { id: 'nonvisual', label: { fr: 'Non visuels', en: 'Non-visual' }, icon: 'zap' },
25
+ ];
26
+ // ------------------------------------------------------------------ aides de déclaration
27
+ const L = (fr, en) => ({ fr, en });
28
+ const opt = (value, fr, en) => ({ value, label: L(fr, en) });
29
+ const SEVERITY = [
30
+ opt('primary', 'Principale', 'Primary'),
31
+ opt('secondary', 'Secondaire', 'Secondary'),
32
+ opt('success', 'Succès', 'Success'),
33
+ opt('warning', 'Attention', 'Warning'),
34
+ opt('danger', 'Danger', 'Danger'),
35
+ opt('info', 'Information', 'Info'),
36
+ ];
37
+ const TONE = [
38
+ opt('primary', 'Principale', 'Primary'),
39
+ opt('success', 'Succès', 'Success'),
40
+ opt('warning', 'Attention', 'Warning'),
41
+ opt('danger', 'Danger', 'Danger'),
42
+ opt('info', 'Information', 'Info'),
43
+ opt('neutral', 'Neutre', 'Neutral'),
44
+ ];
45
+ const ALIGN = [opt('left', 'À gauche', 'Left'), opt('center', 'Centré', 'Center'), opt('right', 'À droite', 'Right')];
46
+ const SIZES = [opt('sm', 'Petite', 'Small'), opt('md', 'Moyenne', 'Medium'), opt('lg', 'Grande', 'Large')];
47
+ const ORIENTATION = [opt('horizontal', 'Horizontale', 'Horizontal'), opt('vertical', 'Verticale', 'Vertical')];
48
+ const text = (key, label, def = '', maxLength) => ({ key, kind: 'text', label, default: def, ...(maxLength ? { maxLength } : {}) });
49
+ const longtext = (key, label, def = '') => ({ key, kind: 'longtext', label, default: def });
50
+ const lines = (key, label, fr, en) => ({ key, kind: 'lines', label, default: { fr, en } });
51
+ const num = (key, label, def, min, max) => ({ key, kind: 'number', label, default: def, min, max });
52
+ const bool = (key, label, def = false) => ({ key, kind: 'boolean', label, default: def });
53
+ const choice = (key, label, def, options) => ({ key, kind: 'choice', label, default: def, options });
54
+ // Libellés de propriétés employés plusieurs fois
55
+ const P = {
56
+ label: L('Libellé', 'Label'),
57
+ title: L('Titre', 'Title'),
58
+ subtitle: L('Sous-titre', 'Subtitle'),
59
+ content: L('Contenu', 'Content'),
60
+ placeholder: L('Texte indicatif', 'Placeholder'),
61
+ hint: L('Aide', 'Hint'),
62
+ required: L('Obligatoire', 'Required'),
63
+ options: L('Options (une par ligne)', 'Options (one per line)'),
64
+ items: L('Éléments (un par ligne)', 'Items (one per line)'),
65
+ severity: L('Couleur', 'Color'),
66
+ variant: L('Aspect', 'Style'),
67
+ size: L('Taille', 'Size'),
68
+ align: L('Alignement', 'Alignment'),
69
+ orientation: L('Orientation', 'Orientation'),
70
+ collapsible: L('Repliable', 'Collapsible'),
71
+ multiple: L('Choix multiple', 'Multiple choice'),
72
+ min: L('Minimum', 'Minimum'),
73
+ max: L('Maximum', 'Maximum'),
74
+ value: L('Valeur', 'Value'),
75
+ checked: L('Cochée au départ', 'Checked at start'),
76
+ on: L('Activé au départ', 'On at start'),
77
+ };
78
+ const OPTIONS_FR = ['Option 1', 'Option 2', 'Option 3'];
79
+ const OPTIONS_EN = ['Option 1', 'Option 2', 'Option 3'];
80
+ // ------------------------------------------------------------------ le catalogue
81
+ export const CATALOG = [
82
+ // ---------------------------------------------------------------- Mise en page
83
+ {
84
+ type: 'card', category: 'layout', label: L('Carte', 'Card'), icon: 'square', size: { w: 8, h: 5 }, min: { w: 3, h: 2 }, keywords: ['card', 'bloc', 'encart'],
85
+ 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.'))],
86
+ },
87
+ {
88
+ type: 'panel', category: 'layout', label: L('Panneau', 'Panel'), icon: 'panel-top', size: { w: 12, h: 5 }, min: { w: 4, h: 2 },
89
+ props: [text('header', P.title, L('Panneau', 'Panel')), bool('toggleable', P.collapsible), longtext('body', P.content, L('Le contenu du panneau.', 'The panel content.'))],
90
+ },
91
+ {
92
+ 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'],
93
+ 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.'))],
94
+ },
95
+ {
96
+ 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'],
97
+ props: [text('label', P.label), choice('align', P.align, 'center', ALIGN), bool('dashed', L('Tirets', 'Dashed'))],
98
+ },
99
+ {
100
+ type: 'tabs', category: 'layout', label: L('Onglets', 'Tabs'), icon: 'panel-top', size: { w: 24, h: 5 }, min: { w: 6, h: 2 },
101
+ props: [
102
+ lines('tabs', L('Onglets (un par ligne)', 'Tabs (one per line)'), ['Onglet 1', 'Onglet 2', 'Onglet 3'], ['Tab 1', 'Tab 2', 'Tab 3']),
103
+ choice('variant', P.variant, 'line', [opt('line', 'Trait', 'Line'), opt('pill', 'Pastille', 'Pill'), opt('enclosed', 'Encadré', 'Enclosed')]),
104
+ ],
105
+ },
106
+ {
107
+ type: 'accordion', category: 'layout', label: L('Accordéon', 'Accordion'), icon: 'list', size: { w: 12, h: 5 }, min: { w: 4, h: 3 },
108
+ 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'))],
109
+ },
110
+ {
111
+ type: 'stepper', category: 'layout', label: L('Étapes', 'Stepper'), icon: 'milestone', size: { w: 24, h: 3 }, min: { w: 8, h: 2 }, keywords: ['wizard', 'assistant'],
112
+ 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)],
113
+ },
114
+ {
115
+ type: 'splitter', category: 'layout', label: L('Panneaux redimensionnables', 'Splitter'), icon: 'columns', size: { w: 24, h: 6 }, min: { w: 6, h: 3 },
116
+ props: [choice('layout', P.orientation, 'horizontal', ORIENTATION), lines('panels', L('Panneaux (un par ligne)', 'Panels (one per line)'), ['Gauche', 'Droite'], ['Left', 'Right'])],
117
+ },
118
+ // ---------------------------------------------------------------- Formulaires
119
+ {
120
+ 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'],
121
+ props: [
122
+ text('label', P.label, L('Libellé', 'Label')), text('placeholder', P.placeholder), text('hint', P.hint), bool('required', P.required),
123
+ 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')]),
124
+ ],
125
+ },
126
+ {
127
+ 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'],
128
+ props: [text('label', P.label, L('Commentaire', 'Comment')), text('placeholder', P.placeholder), bool('required', P.required)],
129
+ },
130
+ {
131
+ type: 'button', category: 'forms', label: L('Bouton', 'Button'), icon: 'square', size: { w: 4, h: 1 }, min: { w: 2, h: 1 }, keywords: ['action', 'bouton'],
132
+ props: [
133
+ text('label', P.label, L('Valider', 'Submit'), 80),
134
+ choice('severity', P.severity, 'primary', SEVERITY),
135
+ choice('variant', P.variant, 'solid', [opt('solid', 'Plein', 'Solid'), opt('outline', 'Contour', 'Outline'), opt('text', 'Texte seul', 'Text')]),
136
+ bool('block', L('Toute la largeur', 'Full width')),
137
+ ],
138
+ },
139
+ {
140
+ type: 'button-group', category: 'forms', label: L('Groupe de boutons', 'Button group'), icon: 'columns', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
141
+ props: [lines('buttons', L('Boutons (un par ligne)', 'Buttons (one per line)'), ['Jour', 'Semaine', 'Mois'], ['Day', 'Week', 'Month']), choice('size', P.size, 'md', SIZES)],
142
+ },
143
+ {
144
+ type: 'checkbox', category: 'forms', label: L('Case à cocher', 'Checkbox'), icon: 'check-square', size: { w: 6, h: 1 }, min: { w: 2, h: 1 },
145
+ props: [text('label', P.label, L('J’accepte les conditions', 'I accept the terms')), bool('checked', P.checked)],
146
+ },
147
+ {
148
+ type: 'radio', category: 'forms', label: L('Boutons radio', 'Radio buttons'), icon: 'circle-dot', size: { w: 6, h: 3 }, min: { w: 3, h: 1 },
149
+ props: [text('label', P.label, L('Choix', 'Choice')), lines('options', P.options, OPTIONS_FR, OPTIONS_EN), choice('orientation', P.orientation, 'vertical', ORIENTATION)],
150
+ },
151
+ {
152
+ type: 'switch', category: 'forms', label: L('Interrupteur', 'Switch'), icon: 'toggle-left', size: { w: 6, h: 1 }, min: { w: 2, h: 1 }, keywords: ['toggle', 'bascule'],
153
+ props: [text('label', P.label, L('Notifications', 'Notifications')), bool('checked', P.on)],
154
+ },
155
+ {
156
+ type: 'toggle-button', category: 'forms', label: L('Bouton bascule', 'Toggle button'), icon: 'toggle-right', size: { w: 4, h: 1 }, min: { w: 2, h: 1 },
157
+ props: [text('onLabel', L('Libellé activé', 'On label'), L('Activé', 'On')), text('offLabel', L('Libellé désactivé', 'Off label'), L('Désactivé', 'Off'))],
158
+ },
159
+ {
160
+ type: 'segmented', category: 'forms', label: L('Choix segmenté', 'Segmented control'), icon: 'columns', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
161
+ props: [lines('options', P.options, ['Liste', 'Grille', 'Carte'], ['List', 'Grid', 'Map']), bool('block', L('Toute la largeur', 'Full width'))],
162
+ },
163
+ {
164
+ 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'],
165
+ 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)],
166
+ },
167
+ {
168
+ 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'],
169
+ 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'])],
170
+ },
171
+ {
172
+ type: 'listbox', category: 'forms', label: L('Liste de choix', 'List box'), icon: 'list-checks', size: { w: 6, h: 5 }, min: { w: 3, h: 2 },
173
+ props: [lines('options', P.options, OPTIONS_FR, OPTIONS_EN), bool('multiple', P.multiple), bool('filter', L('Recherche', 'Search box'))],
174
+ },
175
+ {
176
+ type: 'number', category: 'forms', label: L('Nombre', 'Number'), icon: 'hash', size: { w: 6, h: 2 }, min: { w: 2, h: 2 }, keywords: ['numerique', 'numeric', 'quantite'],
177
+ 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)],
178
+ },
179
+ {
180
+ type: 'password', category: 'forms', label: L('Mot de passe', 'Password'), icon: 'key', size: { w: 8, h: 2 }, min: { w: 3, h: 2 },
181
+ props: [text('label', P.label, L('Mot de passe', 'Password')), text('placeholder', P.placeholder), bool('feedback', L('Indicateur de robustesse', 'Strength meter'))],
182
+ },
183
+ {
184
+ 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'],
185
+ props: [
186
+ text('label', P.label, L('Téléphone', 'Phone')),
187
+ 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')]),
188
+ ],
189
+ },
190
+ {
191
+ type: 'datepicker', category: 'forms', label: L('Date', 'Date'), icon: 'calendar', size: { w: 6, h: 2 }, min: { w: 3, h: 2 }, keywords: ['date', 'calendrier', 'heure'],
192
+ props: [
193
+ text('label', P.label, L('Date', 'Date')),
194
+ 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')]),
195
+ bool('range', L('Intervalle', 'Range')),
196
+ ],
197
+ },
198
+ {
199
+ type: 'color', category: 'forms', label: L('Couleur', 'Color'), icon: 'palette', size: { w: 6, h: 2 }, min: { w: 3, h: 2 }, keywords: ['colorpicker', 'teinte'],
200
+ props: [text('label', P.label, L('Couleur', 'Color')), bool('alpha', L('Opacité', 'Opacity'))],
201
+ },
202
+ {
203
+ type: 'slider', category: 'forms', label: L('Curseur', 'Slider'), icon: 'sliders-horizontal', size: { w: 8, h: 2 }, min: { w: 3, h: 1 }, keywords: ['range', 'glissiere'],
204
+ 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)],
205
+ },
206
+ {
207
+ type: 'rating', category: 'forms', label: L('Note', 'Rating'), icon: 'star', size: { w: 4, h: 1 }, min: { w: 2, h: 1 }, keywords: ['etoiles', 'stars'],
208
+ props: [num('max', L('Nombre d’étoiles', 'Number of stars'), 5, 1, 10), bool('readonly', L('Lecture seule', 'Read-only'))],
209
+ },
210
+ {
211
+ 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'],
212
+ props: [
213
+ 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')]),
214
+ bool('multiple', L('Plusieurs fichiers', 'Several files')),
215
+ text('accept', L('Types acceptés', 'Accepted types'), '', 120),
216
+ ],
217
+ },
218
+ {
219
+ 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'],
220
+ props: [text('label', P.label, L('Étiquettes', 'Tags')), text('placeholder', P.placeholder, L('Choisir…', 'Choose…')), lines('options', P.options, OPTIONS_FR, OPTIONS_EN)],
221
+ },
222
+ {
223
+ 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'],
224
+ 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'))],
225
+ },
226
+ {
227
+ 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'],
228
+ props: [lines('items', P.items, ['Étude', 'Chantier', 'Réception'], ['Study', 'Works', 'Handover']), text('header', P.title, L('Étapes', 'Steps'))],
229
+ },
230
+ {
231
+ 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'],
232
+ props: [text('display', L('Texte affiché', 'Displayed text'), L('Cliquez pour modifier', 'Click to edit'))],
233
+ },
234
+ {
235
+ 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'],
236
+ 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)],
237
+ },
238
+ {
239
+ 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'],
240
+ props: [text('label', P.label, L('Statut', 'Status'), 60), text('value', P.value, L('En cours', 'Ongoing'), 60), bool('active', L('Actif', 'Active'), true)],
241
+ },
242
+ {
243
+ 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'],
244
+ props: [text('placeholder', P.placeholder, L('Écrivez ici…', 'Write here…'))],
245
+ },
246
+ {
247
+ 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'],
248
+ props: [
249
+ 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')]),
250
+ longtext('value', L('Contenu', 'Content'), 'const total = chantiers.length;\nconsole.log(total);'),
251
+ bool('readonly', L('Lecture seule', 'Read-only')),
252
+ ],
253
+ },
254
+ {
255
+ 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'],
256
+ 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'))],
257
+ },
258
+ {
259
+ 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'],
260
+ props: [text('placeholder', P.placeholder, L('Écrivez, ou tapez / pour un bloc…', 'Write, or type / for a block…'))],
261
+ },
262
+ {
263
+ 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'],
264
+ 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.'))],
265
+ },
266
+ // ---------------------------------------------------------------- Données
267
+ {
268
+ type: 'table', category: 'data', label: L('Tableau', 'Table'), icon: 'table', size: { w: 24, h: 8 }, min: { w: 8, h: 3 }, keywords: ['grille', 'datatable', 'lignes'],
269
+ props: [
270
+ lines('columns', L('Colonnes (une par ligne)', 'Columns (one per line)'), ['Nom', 'Statut', 'Date'], ['Name', 'Status', 'Date']),
271
+ 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.')),
272
+ bool('paginator', L('Pagination', 'Pagination')),
273
+ bool('striped', L('Lignes alternées', 'Striped rows')),
274
+ ],
275
+ },
276
+ {
277
+ type: 'dataview', category: 'data', label: L('Liste de fiches', 'Data view'), icon: 'grid', size: { w: 24, h: 8 }, min: { w: 6, h: 3 },
278
+ 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.'))],
279
+ },
280
+ {
281
+ type: 'tree', category: 'data', label: L('Arbre', 'Tree'), icon: 'folder-tree', size: { w: 8, h: 8 }, min: { w: 4, h: 3 }, keywords: ['arborescence', 'hierarchie'],
282
+ props: [lines('nodes', L('Nœuds racines (un par ligne)', 'Root nodes (one per line)'), ['Documents', 'Images', 'Archives'], ['Documents', 'Pictures', 'Archive'])],
283
+ },
284
+ {
285
+ type: 'paginator', category: 'data', label: L('Pagination', 'Paginator'), icon: 'ellipsis', size: { w: 12, h: 1 }, min: { w: 6, h: 1 },
286
+ props: [num('totalRecords', L('Nombre de lignes', 'Total rows'), 120, 0, 1e9), num('rows', L('Lignes par page', 'Rows per page'), 10, 1, 1000)],
287
+ },
288
+ {
289
+ 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'],
290
+ props: [
291
+ choice('chartType', L('Type', 'Type'), 'bar', [opt('bar', 'Barres', 'Bars'), opt('line', 'Courbe', 'Line'), opt('pie', 'Secteurs', 'Pie'), opt('doughnut', 'Anneau', 'Doughnut')]),
292
+ text('series', L('Nom de la série', 'Series name'), L('Ventes', 'Sales')),
293
+ lines('labels', L('Étiquettes (une par ligne)', 'Labels (one per line)'), ['Jan', 'Fév', 'Mar', 'Avr', 'Mai'], ['Jan', 'Feb', 'Mar', 'Apr', 'May']),
294
+ lines('values', L('Valeurs (une par ligne)', 'Values (one per line)'), ['12', '19', '7', '15', '22'], ['12', '19', '7', '15', '22']),
295
+ ],
296
+ },
297
+ {
298
+ type: 'meter', category: 'data', label: L('Jauge', 'Meter'), icon: 'gauge', size: { w: 12, h: 2 }, min: { w: 4, h: 1 },
299
+ 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)],
300
+ },
301
+ {
302
+ type: 'progress', category: 'data', label: L('Barre de progression', 'Progress bar'), icon: 'loader', size: { w: 8, h: 1 }, min: { w: 3, h: 1 },
303
+ 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'))],
304
+ },
305
+ {
306
+ type: 'timeline', category: 'data', label: L('Frise chronologique', 'Timeline'), icon: 'activity', size: { w: 8, h: 6 }, min: { w: 4, h: 3 },
307
+ 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)],
308
+ },
309
+ {
310
+ type: 'orgchart', category: 'data', label: L('Organigramme', 'Org chart'), icon: 'git-fork', size: { w: 16, h: 8 }, min: { w: 6, h: 4 },
311
+ 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'])],
312
+ },
313
+ // ---------------------------------------------------------------- Carte
314
+ {
315
+ 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'],
316
+ props: [
317
+ 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')]),
318
+ num('zoom', L('Zoom', 'Zoom'), 5, 0, 20),
319
+ ],
320
+ },
321
+ // ---------------------------------------------------------------- Planification
322
+ {
323
+ type: 'calendar', category: 'planning', label: L('Calendrier', 'Calendar'), icon: 'calendar-days', size: { w: 24, h: 12 }, min: { w: 8, h: 6 }, keywords: ['agenda', 'evenements'],
324
+ props: [choice('view', L('Vue', 'View'), 'month', [opt('month', 'Mois', 'Month'), opt('week', 'Semaine', 'Week'), opt('day', 'Jour', 'Day'), opt('agenda', 'Agenda', 'Agenda')])],
325
+ },
326
+ {
327
+ 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'],
328
+ props: [choice('scale', L('Échelle', 'Scale'), 'week', [opt('day', 'Jour', 'Day'), opt('week', 'Semaine', 'Week'), opt('month', 'Mois', 'Month')])],
329
+ },
330
+ {
331
+ 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'],
332
+ props: [choice('scale', L('Échelle', 'Scale'), 'week', [opt('day', 'Jour', 'Day'), opt('week', 'Semaine', 'Week'), opt('month', 'Mois', 'Month')])],
333
+ },
334
+ {
335
+ 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'],
336
+ props: [choice('mode', L('Présentation', 'Presentation'), 'board', [opt('board', 'Cartes', 'Board'), opt('list', 'Liste', 'List')])],
337
+ },
338
+ // ---------------------------------------------------------------- Navigation
339
+ {
340
+ type: 'menubar', category: 'navigation', label: L('Barre de menu', 'Menu bar'), icon: 'menu', size: { w: 24, h: 2 }, min: { w: 6, h: 2 },
341
+ 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'])],
342
+ },
343
+ {
344
+ type: 'breadcrumb', category: 'navigation', label: L('Fil d’Ariane', 'Breadcrumb'), icon: 'chevrons-right', size: { w: 12, h: 1 }, min: { w: 4, h: 1 },
345
+ props: [lines('items', P.items, ['Accueil', 'Catalogue', 'Fiche'], ['Home', 'Catalog', 'Item'])],
346
+ },
347
+ {
348
+ 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'],
349
+ 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'])],
350
+ },
351
+ {
352
+ 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'],
353
+ 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')])],
354
+ },
355
+ {
356
+ 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'],
357
+ props: [lines('items', P.items, ['Tableau de bord', 'Chantiers', 'Équipes', 'Réglages'], ['Dashboard', 'Sites', 'Teams', 'Settings'])],
358
+ },
359
+ {
360
+ 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'],
361
+ props: [num('threshold', L('Apparaît après (px défilés)', 'Shows after (px scrolled)'), 400, 0, 10000)],
362
+ },
363
+ // ---------------------------------------------------------------- Affichage
364
+ {
365
+ type: 'heading', category: 'display', label: L('Titre', 'Heading'), icon: 'heading', size: { w: 12, h: 1 }, min: { w: 2, h: 1 }, keywords: ['titre', 'h1', 'h2'],
366
+ 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)],
367
+ },
368
+ {
369
+ type: 'text', category: 'display', label: L('Texte', 'Text'), icon: 'type', size: { w: 12, h: 2 }, min: { w: 2, h: 1 }, keywords: ['paragraphe', 'paragraph'],
370
+ 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)],
371
+ },
372
+ {
373
+ type: 'image', category: 'display', label: L('Image', 'Image'), icon: 'image', size: { w: 8, h: 5 }, min: { w: 2, h: 2 }, keywords: ['photo', 'illustration'],
374
+ 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'))],
375
+ },
376
+ {
377
+ type: 'avatar', category: 'display', label: L('Avatar', 'Avatar'), icon: 'user', size: { w: 2, h: 2 }, min: { w: 1, h: 1 },
378
+ 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')])],
379
+ },
380
+ {
381
+ 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'],
382
+ 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)],
383
+ },
384
+ {
385
+ type: 'badge', category: 'display', label: L('Pastille', 'Badge'), icon: 'circle', size: { w: 2, h: 1 }, min: { w: 1, h: 1 }, keywords: ['compteur', 'counter'],
386
+ props: [text('value', P.value, '3', 12), choice('severity', P.severity, 'danger', TONE)],
387
+ },
388
+ {
389
+ type: 'tag', category: 'display', label: L('Étiquette', 'Tag'), icon: 'tag', size: { w: 3, h: 1 }, min: { w: 1, h: 1 },
390
+ props: [text('value', P.label, L('Nouveau', 'New'), 60), choice('severity', P.severity, 'primary', TONE), bool('rounded', L('Arrondie', 'Rounded'))],
391
+ },
392
+ {
393
+ type: 'chip', category: 'display', label: L('Puce', 'Chip'), icon: 'tags', size: { w: 4, h: 1 }, min: { w: 2, h: 1 },
394
+ props: [text('label', P.label, L('Filtre', 'Filter'), 60), bool('removable', L('Bouton de retrait', 'Remove button'))],
395
+ },
396
+ {
397
+ type: 'carousel', category: 'display', label: L('Carrousel', 'Carousel'), icon: 'images', size: { w: 24, h: 6 }, min: { w: 6, h: 3 }, keywords: ['diaporama', 'slider'],
398
+ 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)],
399
+ },
400
+ {
401
+ type: 'icon', category: 'display', label: L('Icône', 'Icon'), icon: 'smile', size: { w: 1, h: 1 }, min: { w: 1, h: 1 },
402
+ props: [text('name', L('Nom de l’icône', 'Icon name'), 'star', 40), num('size', P.size, 24, 8, 128)],
403
+ },
404
+ {
405
+ type: 'message', category: 'display', label: L('Message', 'Message'), icon: 'info', size: { w: 12, h: 2 }, min: { w: 3, h: 1 }, keywords: ['alerte', 'alert', 'notice'],
406
+ 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')])],
407
+ },
408
+ {
409
+ type: 'skeleton', category: 'display', label: L('Squelette', 'Skeleton'), icon: 'square-dashed', size: { w: 8, h: 2 }, min: { w: 1, h: 1 }, keywords: ['chargement', 'loading'],
410
+ 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)],
411
+ },
412
+ {
413
+ 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'],
414
+ props: [num('size', P.size, 32, 12, 128)],
415
+ },
416
+ // ---------------------------------------------------------------- Non visuels (bac de la page, jamais sur la grille)
417
+ {
418
+ 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'],
419
+ props: [text('table', L('Table', 'Table'), '', 120)],
420
+ },
421
+ {
422
+ 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'],
423
+ props: [num('interval', L('Intervalle (ms)', 'Interval (ms)'), 1000, 100, 86400000), bool('enabled', L('Actif', 'Enabled'), true)],
424
+ },
425
+ {
426
+ 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'],
427
+ props: [text('title', P.title, L('Détails', 'Details'))],
428
+ },
429
+ {
430
+ 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'],
431
+ 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')])],
432
+ },
433
+ {
434
+ 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'],
435
+ props: [longtext('message', L('Message', 'Message'), L('Voulez-vous vraiment continuer ?', 'Do you really want to continue?'))],
436
+ },
437
+ {
438
+ 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'],
439
+ 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)],
440
+ },
441
+ {
442
+ 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'],
443
+ props: [text('initial', L('Valeur initiale', 'Initial value'), '', 500)],
444
+ },
445
+ ];
446
+ // ------------------------------------------------------------------ accès
447
+ const BY_TYPE = new Map(CATALOG.map((e) => [e.type, e]));
448
+ /** Les clés de type du catalogue, dans l'ordre */
449
+ export const CATALOG_TYPES = CATALOG.map((e) => e.type);
450
+ /** Types posés sur la grille */
451
+ export const VISUAL_TYPES = CATALOG.filter((e) => !e.nonVisual).map((e) => e.type);
452
+ /** Types non visuels (bac de la page) */
453
+ export const NONVISUAL_TYPES = CATALOG.filter((e) => e.nonVisual).map((e) => e.type);
454
+ export const isNonVisual = (type) => !!BY_TYPE.get(type)?.nonVisual;
455
+ export const catalogEntry = (type) => BY_TYPE.get(type);
456
+ export const localize = (v, lang) => v[lang] ?? v.fr;
457
+ /** Langue du catalogue d'après une langue d'interface (en, en-GB → en ; le reste → fr) */
458
+ export const catalogLang = (lang) => (lang && lang.toLowerCase().startsWith('en') ? 'en' : 'fr');
459
+ const isLocalized = (v) => typeof v === 'object' && v !== null && !Array.isArray(v) && 'fr' in v;
460
+ /** Valeur par défaut d'une propriété dans une langue */
461
+ export const defaultValue = (spec, lang) => {
462
+ const d = spec.default;
463
+ if (isLocalized(d)) {
464
+ const v = d[lang] ?? d.fr;
465
+ return Array.isArray(v) ? [...v] : v;
466
+ }
467
+ return Array.isArray(d) ? [...d] : d;
468
+ };
469
+ /** Les props d'un composant neuf : toutes ses propriétés à leur valeur par défaut, dans la langue de la console */
470
+ export const defaultProps = (type, lang = 'fr') => {
471
+ const e = catalogEntry(type);
472
+ if (!e)
473
+ return {};
474
+ return Object.fromEntries(e.props.map((p) => [p.key, defaultValue(p, lang)]));
475
+ };
476
+ export const MAX_TEXT = 200;
477
+ export const MAX_LONGTEXT = 2000;
478
+ export const MAX_LINES = 50;
479
+ export const MAX_LINE = 200;
480
+ /** Écart d'une valeur de propriété à sa déclaration ; null si elle convient */
481
+ export const checkPropValue = (spec, v) => {
482
+ switch (spec.kind) {
483
+ case 'text':
484
+ case 'longtext': {
485
+ if (typeof v !== 'string')
486
+ return 'must be a string';
487
+ const max = spec.maxLength ?? (spec.kind === 'text' ? MAX_TEXT : MAX_LONGTEXT);
488
+ return [...v].length > max ? `must be at most ${max} characters` : null;
489
+ }
490
+ case 'lines':
491
+ if (!Array.isArray(v) || v.some((x) => typeof x !== 'string'))
492
+ return 'must be an array of strings';
493
+ if (v.length > MAX_LINES)
494
+ return `must have at most ${MAX_LINES} lines`;
495
+ return v.some((x) => [...x].length > MAX_LINE) ? `each line must be at most ${MAX_LINE} characters` : null;
496
+ case 'number':
497
+ if (typeof v !== 'number' || !Number.isFinite(v))
498
+ return 'must be a number';
499
+ if (spec.min !== undefined && v < spec.min)
500
+ return `must be ≥ ${spec.min}`;
501
+ if (spec.max !== undefined && v > spec.max)
502
+ return `must be ≤ ${spec.max}`;
503
+ return null;
504
+ case 'boolean':
505
+ return typeof v === 'boolean' ? null : 'must be a boolean';
506
+ case 'choice':
507
+ 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(', ')}`;
508
+ }
509
+ };
510
+ /**
511
+ * 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
512
+ * prend sa valeur par défaut, en français) ; une valeur qui ne convient pas est remplacée par la valeur par défaut.
513
+ * Le moteur affiche toujours ce résultat, jamais la définition brute.
514
+ */
515
+ export const resolveProps = (type, props, lang = 'fr') => {
516
+ const e = catalogEntry(type);
517
+ if (!e)
518
+ return {};
519
+ const out = {};
520
+ for (const spec of e.props) {
521
+ const v = props?.[spec.key];
522
+ out[spec.key] = v !== undefined && checkPropValue(spec, v) === null ? v : defaultValue(spec, lang);
523
+ }
524
+ return out;
525
+ };
526
+ /** Catalogue par catégorie, filtré par une recherche (libellé fr ou en, clé du type, mots-clés ; sans accent) */
527
+ export const searchCatalog = (query, lang = 'fr') => {
528
+ const fold = (s) => s.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
529
+ const words = fold(query).split(/\s+/).filter(Boolean);
530
+ const match = (e) => {
531
+ if (!words.length)
532
+ return true;
533
+ const hay = fold([e.label.fr, e.label.en, e.type, ...(e.keywords ?? []), localize(CATEGORIES.find((c) => c.id === e.category).label, lang)].join(' '));
534
+ return words.every((w) => hay.includes(w));
535
+ };
536
+ return CATEGORIES.map((category) => ({ category, entries: CATALOG.filter((e) => e.category === category.id && match(e)) })).filter((g) => g.entries.length > 0);
537
+ };
538
+ //# sourceMappingURL=catalog.js.map