@vantageos/mosaic 0.2.2 → 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 (120) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +193 -0
  3. package/dist/Alert.schema-LPJE5gFP.d.cts +71 -0
  4. package/dist/Alert.schema-LPJE5gFP.d.ts +71 -0
  5. package/dist/ConfirmDialog-B3CQQGmJ.d.cts +34 -0
  6. package/dist/ConfirmDialog-B3CQQGmJ.d.ts +34 -0
  7. package/dist/MarkdownRenderer.schema-Rx7kIeVA.d.cts +22 -0
  8. package/dist/MarkdownRenderer.schema-Rx7kIeVA.d.ts +22 -0
  9. package/dist/ProgressBar.schema-CdVYx0Wq.d.cts +22 -0
  10. package/dist/ProgressBar.schema-CdVYx0Wq.d.ts +22 -0
  11. package/dist/StatusBadge.schema-1tOjB4Ir.d.cts +22 -0
  12. package/dist/StatusBadge.schema-1tOjB4Ir.d.ts +22 -0
  13. package/dist/Tabs.schema-BzcEyeq8.d.cts +79 -0
  14. package/dist/Tabs.schema-BzcEyeq8.d.ts +79 -0
  15. package/dist/artifacts.cjs +144 -2
  16. package/dist/artifacts.cjs.map +1 -1
  17. package/dist/artifacts.d.cts +3 -21
  18. package/dist/artifacts.d.ts +3 -21
  19. package/dist/artifacts.js +144 -2
  20. package/dist/artifacts.js.map +1 -1
  21. package/dist/confirmation.cjs +168 -2
  22. package/dist/confirmation.cjs.map +1 -1
  23. package/dist/confirmation.d.cts +24 -20
  24. package/dist/confirmation.d.ts +24 -20
  25. package/dist/confirmation.js +165 -3
  26. package/dist/confirmation.js.map +1 -1
  27. package/dist/display.cjs +272 -2
  28. package/dist/display.cjs.map +1 -1
  29. package/dist/display.d.cts +132 -1
  30. package/dist/display.d.ts +132 -1
  31. package/dist/display.js +267 -3
  32. package/dist/display.js.map +1 -1
  33. package/dist/forms.cjs +1415 -0
  34. package/dist/forms.cjs.map +1 -0
  35. package/dist/forms.d.cts +159 -0
  36. package/dist/forms.d.ts +159 -0
  37. package/dist/forms.js +1334 -0
  38. package/dist/forms.js.map +1 -0
  39. package/dist/index-CwXVgtGb.d.cts +917 -0
  40. package/dist/index-CwXVgtGb.d.ts +917 -0
  41. package/dist/index.cjs +315 -2
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +11 -6
  44. package/dist/index.d.ts +11 -6
  45. package/dist/index.js +304 -3
  46. package/dist/index.js.map +1 -1
  47. package/dist/input.cjs +19 -0
  48. package/dist/input.cjs.map +1 -1
  49. package/dist/input.d.cts +4 -34
  50. package/dist/input.d.ts +4 -34
  51. package/dist/input.js +18 -1
  52. package/dist/input.js.map +1 -1
  53. package/dist/media.cjs +144 -2
  54. package/dist/media.cjs.map +1 -1
  55. package/dist/media.d.cts +3 -21
  56. package/dist/media.d.ts +3 -21
  57. package/dist/media.js +144 -2
  58. package/dist/media.js.map +1 -1
  59. package/dist/preact/artifacts.d.ts +39 -1
  60. package/dist/preact/artifacts.js +234 -0
  61. package/dist/preact/artifacts.js.map +1 -1
  62. package/dist/preact/confirmation.d.ts +115 -1
  63. package/dist/preact/confirmation.js +503 -0
  64. package/dist/preact/confirmation.js.map +1 -1
  65. package/dist/preact/display.d.ts +366 -1
  66. package/dist/preact/display.js +774 -0
  67. package/dist/preact/display.js.map +1 -1
  68. package/dist/preact/forms.d.ts +875 -0
  69. package/dist/preact/forms.js +1326 -0
  70. package/dist/preact/forms.js.map +1 -0
  71. package/dist/preact/input.d.ts +88 -1
  72. package/dist/preact/input.js +194 -0
  73. package/dist/preact/input.js.map +1 -1
  74. package/dist/preact/progress.d.ts +35 -1
  75. package/dist/preact/progress.js +263 -0
  76. package/dist/preact/progress.js.map +1 -1
  77. package/dist/progress.cjs +144 -2
  78. package/dist/progress.cjs.map +1 -1
  79. package/dist/progress.d.cts +3 -21
  80. package/dist/progress.d.ts +3 -21
  81. package/dist/progress.js +144 -2
  82. package/dist/progress.js.map +1 -1
  83. package/dist/react/artifacts.cjs +241 -0
  84. package/dist/react/artifacts.cjs.map +1 -1
  85. package/dist/react/artifacts.d.cts +20 -1
  86. package/dist/react/artifacts.d.ts +20 -1
  87. package/dist/react/artifacts.js +234 -0
  88. package/dist/react/artifacts.js.map +1 -1
  89. package/dist/react/confirmation.cjs +513 -0
  90. package/dist/react/confirmation.cjs.map +1 -1
  91. package/dist/react/confirmation.d.cts +21 -1
  92. package/dist/react/confirmation.d.ts +21 -1
  93. package/dist/react/confirmation.js +503 -0
  94. package/dist/react/confirmation.js.map +1 -1
  95. package/dist/react/display.cjs +788 -0
  96. package/dist/react/display.cjs.map +1 -1
  97. package/dist/react/display.d.cts +129 -1
  98. package/dist/react/display.d.ts +129 -1
  99. package/dist/react/display.js +771 -0
  100. package/dist/react/display.js.map +1 -1
  101. package/dist/react/forms.cjs +1387 -0
  102. package/dist/react/forms.cjs.map +1 -0
  103. package/dist/react/forms.d.cts +5 -0
  104. package/dist/react/forms.d.ts +5 -0
  105. package/dist/react/forms.js +1326 -0
  106. package/dist/react/forms.js.map +1 -0
  107. package/dist/react/input.cjs +197 -0
  108. package/dist/react/input.cjs.map +1 -1
  109. package/dist/react/input.d.cts +13 -1
  110. package/dist/react/input.d.ts +13 -1
  111. package/dist/react/input.js +194 -0
  112. package/dist/react/input.js.map +1 -1
  113. package/dist/react/progress.cjs +266 -0
  114. package/dist/react/progress.cjs.map +1 -1
  115. package/dist/react/progress.d.cts +17 -1
  116. package/dist/react/progress.d.ts +17 -1
  117. package/dist/react/progress.js +263 -0
  118. package/dist/react/progress.js.map +1 -1
  119. package/package.json +87 -61
  120. package/registry.yaml +167 -1
@@ -1,3 +1,777 @@
1
+ import { z } from 'zod';
2
+ import { jsx, jsxs } from 'preact/jsx-runtime';
3
+ import { h } from 'preact';
4
+ import { useVirtualizer } from '@tanstack/react-virtual';
5
+ import { useRef, useCallback, useState, useEffect } from 'preact/compat';
1
6
 
7
+ // src/components/display/EmptyState.logic.ts
8
+ var ACTION_VARIANT_CLASSES = {
9
+ primary: "inline-flex items-center justify-center rounded-md bg-slate-900 px-4 py-2 text-sm font-medium text-white shadow-sm transition-colors hover:bg-slate-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-900 disabled:pointer-events-none disabled:opacity-50",
10
+ secondary: "inline-flex items-center justify-center rounded-md border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 shadow-sm transition-colors hover:bg-slate-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-slate-400 disabled:pointer-events-none disabled:opacity-50"
11
+ };
12
+ var EmptyStatePropsSchema = z.object({
13
+ title: z.string().min(1),
14
+ description: z.string().optional(),
15
+ action: z.object({
16
+ label: z.string().min(1),
17
+ variant: z.enum(["primary", "secondary"]).default("primary")
18
+ }).optional(),
19
+ locale: z.enum(["en", "fr"]).default("en")
20
+ });
21
+ function validateEmptyStateProps(raw) {
22
+ return EmptyStatePropsSchema.parse(raw);
23
+ }
24
+
25
+ // src/i18n/strings.ts
26
+ var EN = {
27
+ // ─── Non-forms components ──────────────────────────────────────────────────
28
+ "ProgressBar.aria.label": "Progress",
29
+ "ProgressBar.error.invalidProps": "ProgressBar: invalid props",
30
+ "ConfirmDialog.button.confirm": "Confirm",
31
+ "ConfirmDialog.button.cancel": "Cancel",
32
+ "ConfirmDialog.aria.dialog": "Confirmation dialog",
33
+ "TableView.aria.table": "Data table",
34
+ "TableView.pagination.next": "Next page",
35
+ "TableView.pagination.prev": "Previous page",
36
+ "TableView.empty.message": "No data to display",
37
+ "TableView.error.invalidProps": "TableView: invalid props",
38
+ "MarkdownRenderer.aria.content": "Rendered Markdown content",
39
+ "MarkdownRenderer.error.invalidProps": "MarkdownRenderer: invalid props",
40
+ "MarkdownRenderer.error.tooLong": "Content exceeds maximum length",
41
+ "TokenDisplayOnceModal.button.copy": "Copy token",
42
+ "TokenDisplayOnceModal.button.close": "Close",
43
+ "TokenDisplayOnceModal.warning.once": "This token will only be shown once. Copy it now.",
44
+ "TokenDisplayOnceModal.copied": "Copied",
45
+ "StatusBadge.aria.status": "Status",
46
+ "StatusBadge.error.invalidProps": "StatusBadge: invalid props",
47
+ "EmptyState.error.invalidProps": "EmptyState: invalid props",
48
+ "Toast.aria.close": "Close notification",
49
+ "Toast.error.invalidProps": "Toast: invalid props",
50
+ "Alert.aria.dismiss": "Dismiss alert",
51
+ "Alert.error.invalidProps": "Alert: invalid props",
52
+ "VirtualList.empty.message": "No items to display",
53
+ "VirtualList.error.invalidProps": "VirtualList: invalid props",
54
+ "Skeleton.aria.label": "Loading",
55
+ "Skeleton.error.invalidProps": "Skeleton: invalid props",
56
+ // ─── Forms — useMosaicForm ─────────────────────────────────────────────────
57
+ "useMosaicForm.error.invalidProps": "useMosaicForm: invalid options",
58
+ // ─── Forms — FormProvider ──────────────────────────────────────────────────
59
+ "FormProvider.error.invalidProps": "FormProvider: invalid props",
60
+ // ─── Forms — FormField ────────────────────────────────────────────────────
61
+ "FormField.error.invalidProps": "FormField: invalid props",
62
+ // ─── Forms — ErrorDisplay ─────────────────────────────────────────────────
63
+ "ErrorDisplay.error.required": "This field is required",
64
+ "ErrorDisplay.error.min": "Value is below the minimum",
65
+ "ErrorDisplay.error.max": "Value exceeds the maximum",
66
+ "ErrorDisplay.error.minLength": "Input is too short",
67
+ "ErrorDisplay.error.maxLength": "Input is too long",
68
+ "ErrorDisplay.error.pattern": "Invalid format",
69
+ "ErrorDisplay.error.email": "Enter a valid email address",
70
+ "ErrorDisplay.error.url": "Enter a valid URL",
71
+ "ErrorDisplay.error.generic": "Invalid value",
72
+ // ─── Forms — SubmitButton ─────────────────────────────────────────────────
73
+ "SubmitButton.aria.submit": "Submit form",
74
+ "SubmitButton.state.loading": "Submitting\u2026",
75
+ "SubmitButton.error.invalidProps": "SubmitButton: invalid props",
76
+ // ─── Forms — Input ────────────────────────────────────────────────────────
77
+ "Input.aria.label": "Input field",
78
+ "Input.error.required": "This field is required",
79
+ "Input.error.invalid": "Invalid value",
80
+ "Input.error.tooLong": "Input is too long",
81
+ "Input.error.tooShort": "Input is too short",
82
+ "Input.error.invalidProps": "Input: invalid props",
83
+ // ─── Forms — Textarea ─────────────────────────────────────────────────────
84
+ "Textarea.aria.label": "Text area",
85
+ "Textarea.error.required": "This field is required",
86
+ "Textarea.error.tooLong": "Text is too long",
87
+ "Textarea.counter.remaining": "characters remaining",
88
+ "Textarea.error.invalidProps": "Textarea: invalid props",
89
+ // ─── Forms — FieldArray ───────────────────────────────────────────────────
90
+ "FieldArray.aria.list": "List of items",
91
+ "FieldArray.aria.addItem": "Add item",
92
+ "FieldArray.aria.removeItem": "Remove item",
93
+ "FieldArray.error.invalidProps": "FieldArray: invalid props",
94
+ // ─── Forms — Checkbox ─────────────────────────────────────────────────────
95
+ "Checkbox.aria.label": "Checkbox",
96
+ "Checkbox.error.required": "This field must be checked",
97
+ "Checkbox.error.invalidProps": "Checkbox: invalid props",
98
+ // ─── Forms — MultiSelect ──────────────────────────────────────────────────
99
+ "MultiSelect.aria.label": "Multi-select field",
100
+ "MultiSelect.aria.removeChip": "Remove",
101
+ "MultiSelect.error.required": "Select at least one option",
102
+ "MultiSelect.error.maxItems": "Maximum number of selections reached",
103
+ "MultiSelect.placeholder": "Select options\u2026",
104
+ "MultiSelect.search.placeholder": "Search\u2026",
105
+ "MultiSelect.empty": "No options available",
106
+ "MultiSelect.error.invalidProps": "MultiSelect: invalid props",
107
+ // ─── Forms — RadioGroup ───────────────────────────────────────────────────
108
+ "RadioGroup.aria.label": "Radio group",
109
+ "RadioGroup.error.required": "Select one option",
110
+ "RadioGroup.error.invalidProps": "RadioGroup: invalid props",
111
+ // ─── Forms — Select ───────────────────────────────────────────────────────
112
+ "Select.placeholder": "Select an option\u2026",
113
+ "Select.search.placeholder": "Search\u2026",
114
+ "Select.empty": "No options available",
115
+ "Select.error.required": "Select an option",
116
+ "Select.error.invalidProps": "Select: invalid props"
117
+ };
118
+ var FR = {
119
+ // ─── Non-forms components ──────────────────────────────────────────────────
120
+ "ProgressBar.aria.label": "Progression",
121
+ "ProgressBar.error.invalidProps": "ProgressBar : propri\xE9t\xE9s invalides",
122
+ "ConfirmDialog.button.confirm": "Confirmer",
123
+ "ConfirmDialog.button.cancel": "Annuler",
124
+ "ConfirmDialog.aria.dialog": "Bo\xEEte de dialogue de confirmation",
125
+ "TableView.aria.table": "Tableau de donn\xE9es",
126
+ "TableView.pagination.next": "Page suivante",
127
+ "TableView.pagination.prev": "Page pr\xE9c\xE9dente",
128
+ "TableView.empty.message": "Aucune donn\xE9e \xE0 afficher",
129
+ "TableView.error.invalidProps": "TableView : propri\xE9t\xE9s invalides",
130
+ "MarkdownRenderer.aria.content": "Contenu Markdown rendu",
131
+ "MarkdownRenderer.error.invalidProps": "MarkdownRenderer : propri\xE9t\xE9s invalides",
132
+ "MarkdownRenderer.error.tooLong": "Le contenu d\xE9passe la longueur maximale",
133
+ "TokenDisplayOnceModal.button.copy": "Copier le jeton",
134
+ "TokenDisplayOnceModal.button.close": "Fermer",
135
+ "TokenDisplayOnceModal.warning.once": "Ce jeton ne sera affich\xE9 qu'une seule fois. Copiez-le maintenant.",
136
+ "TokenDisplayOnceModal.copied": "Copi\xE9",
137
+ "StatusBadge.aria.status": "Statut",
138
+ "StatusBadge.error.invalidProps": "StatusBadge : propri\xE9t\xE9s invalides",
139
+ "EmptyState.error.invalidProps": "EmptyState : propri\xE9t\xE9s invalides",
140
+ "Toast.aria.close": "Fermer la notification",
141
+ "Toast.error.invalidProps": "Toast : propri\xE9t\xE9s invalides",
142
+ "Alert.aria.dismiss": "Fermer l'alerte",
143
+ "Alert.error.invalidProps": "Alert : propri\xE9t\xE9s invalides",
144
+ "VirtualList.empty.message": "Aucun \xE9l\xE9ment \xE0 afficher",
145
+ "VirtualList.error.invalidProps": "VirtualList : propri\xE9t\xE9s invalides",
146
+ "Skeleton.aria.label": "Chargement",
147
+ "Skeleton.error.invalidProps": "Skeleton : propri\xE9t\xE9s invalides",
148
+ // ─── Forms — useMosaicForm ─────────────────────────────────────────────────
149
+ "useMosaicForm.error.invalidProps": "useMosaicForm : options invalides",
150
+ // ─── Forms — FormProvider ──────────────────────────────────────────────────
151
+ "FormProvider.error.invalidProps": "FormProvider : propri\xE9t\xE9s invalides",
152
+ // ─── Forms — FormField ────────────────────────────────────────────────────
153
+ "FormField.error.invalidProps": "FormField : propri\xE9t\xE9s invalides",
154
+ // ─── Forms — ErrorDisplay ─────────────────────────────────────────────────
155
+ "ErrorDisplay.error.required": "Ce champ est obligatoire",
156
+ "ErrorDisplay.error.min": "La valeur est inf\xE9rieure au minimum",
157
+ "ErrorDisplay.error.max": "La valeur d\xE9passe le maximum",
158
+ "ErrorDisplay.error.minLength": "La saisie est trop courte",
159
+ "ErrorDisplay.error.maxLength": "La saisie est trop longue",
160
+ "ErrorDisplay.error.pattern": "Format invalide",
161
+ "ErrorDisplay.error.email": "Saisissez une adresse e-mail valide",
162
+ "ErrorDisplay.error.url": "Saisissez une URL valide",
163
+ "ErrorDisplay.error.generic": "Valeur invalide",
164
+ // ─── Forms — SubmitButton ─────────────────────────────────────────────────
165
+ "SubmitButton.aria.submit": "Soumettre le formulaire",
166
+ "SubmitButton.state.loading": "Envoi en cours\u2026",
167
+ "SubmitButton.error.invalidProps": "SubmitButton : propri\xE9t\xE9s invalides",
168
+ // ─── Forms — Input ────────────────────────────────────────────────────────
169
+ "Input.aria.label": "Champ de saisie",
170
+ "Input.error.required": "Ce champ est obligatoire",
171
+ "Input.error.invalid": "Valeur invalide",
172
+ "Input.error.tooLong": "La saisie est trop longue",
173
+ "Input.error.tooShort": "La saisie est trop courte",
174
+ "Input.error.invalidProps": "Input : propri\xE9t\xE9s invalides",
175
+ // ─── Forms — Textarea ─────────────────────────────────────────────────────
176
+ "Textarea.aria.label": "Zone de texte",
177
+ "Textarea.error.required": "Ce champ est obligatoire",
178
+ "Textarea.error.tooLong": "Le texte est trop long",
179
+ "Textarea.counter.remaining": "caract\xE8res restants",
180
+ "Textarea.error.invalidProps": "Textarea : propri\xE9t\xE9s invalides",
181
+ // ─── Forms — FieldArray ───────────────────────────────────────────────────
182
+ "FieldArray.aria.list": "Liste d'\xE9l\xE9ments",
183
+ "FieldArray.aria.addItem": "Ajouter un \xE9l\xE9ment",
184
+ "FieldArray.aria.removeItem": "Supprimer l'\xE9l\xE9ment",
185
+ "FieldArray.error.invalidProps": "FieldArray : propri\xE9t\xE9s invalides",
186
+ // ─── Forms — Checkbox ─────────────────────────────────────────────────────
187
+ "Checkbox.aria.label": "Case \xE0 cocher",
188
+ "Checkbox.error.required": "Ce champ doit \xEAtre coch\xE9",
189
+ "Checkbox.error.invalidProps": "Checkbox : propri\xE9t\xE9s invalides",
190
+ // ─── Forms — MultiSelect ──────────────────────────────────────────────────
191
+ "MultiSelect.aria.label": "Champ de s\xE9lection multiple",
192
+ "MultiSelect.aria.removeChip": "Retirer",
193
+ "MultiSelect.error.required": "S\xE9lectionnez au moins une option",
194
+ "MultiSelect.error.maxItems": "Nombre maximum de s\xE9lections atteint",
195
+ "MultiSelect.placeholder": "S\xE9lectionner des options\u2026",
196
+ "MultiSelect.search.placeholder": "Rechercher\u2026",
197
+ "MultiSelect.empty": "Aucune option disponible",
198
+ "MultiSelect.error.invalidProps": "MultiSelect : propri\xE9t\xE9s invalides",
199
+ // ─── Forms — RadioGroup ───────────────────────────────────────────────────
200
+ "RadioGroup.aria.label": "Groupe de boutons radio",
201
+ "RadioGroup.error.required": "S\xE9lectionnez une option",
202
+ "RadioGroup.error.invalidProps": "RadioGroup : propri\xE9t\xE9s invalides",
203
+ // ─── Forms — Select ───────────────────────────────────────────────────────
204
+ "Select.placeholder": "S\xE9lectionner une option\u2026",
205
+ "Select.search.placeholder": "Rechercher\u2026",
206
+ "Select.empty": "Aucune option disponible",
207
+ "Select.error.required": "S\xE9lectionnez une option",
208
+ "Select.error.invalidProps": "Select : propri\xE9t\xE9s invalides"
209
+ };
210
+ var TABLE = {
211
+ en: EN,
212
+ fr: FR
213
+ };
214
+ function t(key, locale = "en") {
215
+ return TABLE[locale]?.[key] ?? TABLE.en[key];
216
+ }
217
+ function EmptyStateInner({
218
+ icon,
219
+ title,
220
+ description,
221
+ action,
222
+ locale: _locale
223
+ }) {
224
+ const variant = action?.variant ?? "primary";
225
+ return /* @__PURE__ */ jsxs(
226
+ "section",
227
+ {
228
+ "aria-label": title,
229
+ class: "flex flex-col items-center justify-center gap-4 px-6 py-12 text-center",
230
+ children: [
231
+ icon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", class: "text-slate-400", children: icon }),
232
+ /* @__PURE__ */ jsx("h2", { class: "text-base font-semibold text-slate-900", children: title }),
233
+ description && /* @__PURE__ */ jsx("p", { class: "max-w-sm text-sm leading-relaxed text-slate-500", children: description }),
234
+ action && /* @__PURE__ */ jsx("button", { type: "button", onClick: action.onClick, class: ACTION_VARIANT_CLASSES[variant], children: action.label })
235
+ ]
236
+ }
237
+ );
238
+ }
239
+ function EmptyState(raw) {
240
+ try {
241
+ const parsed = validateEmptyStateProps(raw);
242
+ return /* @__PURE__ */ jsx(
243
+ EmptyStateInner,
244
+ {
245
+ ...parsed,
246
+ icon: raw.icon,
247
+ action: parsed.action && raw.action?.onClick ? { ...parsed.action, onClick: raw.action.onClick } : void 0
248
+ }
249
+ );
250
+ } catch (err) {
251
+ console.error("[EmptyState] Invalid props \u2014 component will not render.", err);
252
+ const locale = raw.locale === "fr" ? "fr" : "en";
253
+ return /* @__PURE__ */ jsx("span", { role: "alert", children: t("EmptyState.error.invalidProps", locale) });
254
+ }
255
+ }
256
+
257
+ // src/components/display/Skeleton.logic.ts
258
+ function getAnimationClass(animation) {
259
+ switch (animation) {
260
+ case "pulse":
261
+ return "animate-pulse";
262
+ case "wave":
263
+ return "skeleton-wave";
264
+ case "none":
265
+ return "";
266
+ }
267
+ }
268
+ function getVariantClass(variant) {
269
+ switch (variant) {
270
+ case "rect":
271
+ return "rounded-md";
272
+ case "circle":
273
+ return "rounded-full";
274
+ case "text":
275
+ return "rounded";
276
+ }
277
+ }
278
+ var SKELETON_BG_CLASS = "bg-gray-200 dark:bg-gray-700";
279
+ function textLineKey(index) {
280
+ return `skeleton-line-${index}`;
281
+ }
282
+ function lastLineWidth(index, total, baseWidth) {
283
+ if (total > 1 && index === total - 1) {
284
+ return "75%";
285
+ }
286
+ return baseWidth;
287
+ }
288
+ var SkeletonPropsSchema = z.object({
289
+ variant: z.enum(["rect", "circle", "text"]).default("rect"),
290
+ width: z.union([z.string().min(1), z.number().positive()]).optional(),
291
+ height: z.union([z.string().min(1), z.number().positive()]).optional(),
292
+ count: z.number().int().min(1).max(20).default(1),
293
+ animation: z.enum(["pulse", "wave", "none"]).default("pulse"),
294
+ locale: z.enum(["en", "fr"]).default("en")
295
+ });
296
+ function validateSkeletonProps(raw) {
297
+ return SkeletonPropsSchema.parse(raw);
298
+ }
299
+ function resolveSkeletonDimensions(variant, width, height) {
300
+ const toCss = (v, fallback) => {
301
+ if (v === void 0) return fallback;
302
+ if (typeof v === "number") return `${v}px`;
303
+ return v;
304
+ };
305
+ if (variant === "circle") {
306
+ const size = width !== void 0 ? toCss(width, "40px") : height !== void 0 ? toCss(height, "40px") : "40px";
307
+ return { widthCss: size, heightCss: size };
308
+ }
309
+ if (variant === "text") {
310
+ return {
311
+ widthCss: toCss(width, "100%"),
312
+ heightCss: toCss(height, "16px")
313
+ };
314
+ }
315
+ return {
316
+ widthCss: toCss(width, "100%"),
317
+ heightCss: toCss(height, "100px")
318
+ };
319
+ }
320
+
321
+ // src/runtimes/preact/components/display/Skeleton.tsx
322
+ function SkeletonInner({ variant, width, height, count, animation, locale }) {
323
+ const { widthCss, heightCss } = resolveSkeletonDimensions(variant, width, height);
324
+ const animClass = getAnimationClass(animation);
325
+ const variantClass = getVariantClass(variant);
326
+ const ariaLabel = t("Skeleton.aria.label", locale);
327
+ const baseClass = `${SKELETON_BG_CLASS} ${variantClass} ${animClass}`.trim();
328
+ if (variant === "text") {
329
+ return (
330
+ // biome-ignore lint/a11y/useSemanticElements: role="status" is the correct ARIA pattern for loading indicators; <output> conveys form output semantics which is incorrect here
331
+ /* @__PURE__ */ h("div", { role: "status", "aria-label": ariaLabel, "aria-busy": "true", class: "flex flex-col gap-2" }, Array.from({ length: count }, (_, i) => /* @__PURE__ */ h(
332
+ "span",
333
+ {
334
+ key: textLineKey(i),
335
+ class: `block ${baseClass}`,
336
+ style: {
337
+ width: lastLineWidth(i, count, widthCss),
338
+ height: heightCss
339
+ },
340
+ "aria-hidden": "true"
341
+ }
342
+ )))
343
+ );
344
+ }
345
+ return /* @__PURE__ */ h(
346
+ "div",
347
+ {
348
+ role: "status",
349
+ "aria-label": ariaLabel,
350
+ "aria-busy": "true",
351
+ class: `block ${baseClass}`,
352
+ style: { width: widthCss, height: heightCss }
353
+ }
354
+ );
355
+ }
356
+ function Skeleton(raw) {
357
+ try {
358
+ const props = validateSkeletonProps(raw);
359
+ return /* @__PURE__ */ h(SkeletonInner, { ...props });
360
+ } catch {
361
+ const locale = raw.locale === "fr" ? "fr" : "en";
362
+ return /* @__PURE__ */ h("span", { role: "alert", class: "text-red-600 text-sm" }, t("Skeleton.error.invalidProps", locale));
363
+ }
364
+ }
365
+ var VirtualListPropsSchema = z.object({
366
+ /** Array of items to render — required, can be empty */
367
+ items: z.array(z.unknown()),
368
+ /** Fixed row height in px — mutually exclusive with estimateSize */
369
+ itemHeight: z.number().positive().optional(),
370
+ /** Variable row height estimator — mutually exclusive with itemHeight */
371
+ estimateSize: z.function().args(z.number()).returns(z.number()).optional(),
372
+ /** Row renderer — required (runtime function, excluded from strict Zod parse but validated for presence) */
373
+ renderItem: z.function().args(z.unknown(), z.number()).returns(z.unknown()).optional(),
374
+ /** Rows to render outside visible area (default: 5) */
375
+ overscan: z.number().int().min(0).optional(),
376
+ /** CSS class applied to the scroll container */
377
+ className: z.string().optional(),
378
+ /** Locale for built-in empty state + error messages */
379
+ locale: z.enum(["en", "fr"]).optional(),
380
+ /** a11y: when provided, rows become keyboard-activable (role=button + tabIndex=0 + Enter/Space) */
381
+ onRowClick: z.function().args(z.unknown(), z.number()).returns(z.void()).optional()
382
+ });
383
+ function validateVirtualListProps(raw) {
384
+ return VirtualListPropsSchema.parse(raw);
385
+ }
386
+ var DEFAULT_OVERSCAN = 5;
387
+ var DEFAULT_ITEM_HEIGHT = 40;
388
+ function VirtualList(props) {
389
+ try {
390
+ validateVirtualListProps({
391
+ items: props.items,
392
+ itemHeight: props.itemHeight,
393
+ overscan: props.overscan,
394
+ className: props.className,
395
+ locale: props.locale
396
+ });
397
+ } catch {
398
+ const locale2 = props.locale === "fr" ? "fr" : "en";
399
+ return /* @__PURE__ */ jsx("div", { role: "alert", children: t("VirtualList.error.invalidProps", locale2) });
400
+ }
401
+ const locale = props.locale === "fr" ? "fr" : "en";
402
+ if (props.items.length === 0) {
403
+ return /* @__PURE__ */ jsx("output", { "aria-live": "polite", children: t("VirtualList.empty.message", locale) });
404
+ }
405
+ return /* @__PURE__ */ jsx(
406
+ VirtualListInner,
407
+ {
408
+ items: props.items,
409
+ itemHeight: props.itemHeight,
410
+ estimateSize: props.estimateSize,
411
+ renderItem: props.renderItem,
412
+ onRowClick: props.onRowClick,
413
+ overscan: props.overscan ?? DEFAULT_OVERSCAN,
414
+ className: props.className,
415
+ locale
416
+ }
417
+ );
418
+ }
419
+ function VirtualListInner({
420
+ items,
421
+ itemHeight,
422
+ estimateSize,
423
+ renderItem,
424
+ onRowClick,
425
+ overscan,
426
+ className
427
+ }) {
428
+ const scrollRef = useRef(null);
429
+ const resolvedEstimateSize = useCallback(
430
+ (index) => {
431
+ if (estimateSize) return estimateSize(index);
432
+ return itemHeight ?? DEFAULT_ITEM_HEIGHT;
433
+ },
434
+ [estimateSize, itemHeight]
435
+ );
436
+ const rowVirtualizer = useVirtualizer({
437
+ count: items.length,
438
+ /* v8 ignore next 1 */
439
+ getScrollElement: () => scrollRef.current,
440
+ estimateSize: resolvedEstimateSize,
441
+ overscan
442
+ });
443
+ const virtualItems = rowVirtualizer.getVirtualItems();
444
+ const totalSize = rowVirtualizer.getTotalSize();
445
+ return /* @__PURE__ */ jsx(
446
+ "div",
447
+ {
448
+ "data-virtual": "true",
449
+ ref: scrollRef,
450
+ className,
451
+ style: { height: 400, overflow: "auto", position: "relative" },
452
+ children: /* @__PURE__ */ jsx("div", { style: { height: `${totalSize}px`, position: "relative" }, children: virtualItems.map((virtualRow) => {
453
+ const item = items[virtualRow.index];
454
+ const index = virtualRow.index;
455
+ const rowProps = onRowClick ? {
456
+ role: "button",
457
+ tabIndex: 0,
458
+ "data-list-row": true,
459
+ style: {
460
+ position: "absolute",
461
+ top: 0,
462
+ left: 0,
463
+ width: "100%",
464
+ transform: `translateY(${virtualRow.start}px)`,
465
+ cursor: "pointer"
466
+ },
467
+ onClick: () => onRowClick(item, index),
468
+ onKeyDown: (e) => {
469
+ if (e.key === "Enter" || e.key === " ") {
470
+ e.preventDefault();
471
+ onRowClick(item, index);
472
+ }
473
+ }
474
+ } : {
475
+ "data-list-row": true,
476
+ style: {
477
+ position: "absolute",
478
+ top: 0,
479
+ left: 0,
480
+ width: "100%",
481
+ transform: `translateY(${virtualRow.start}px)`
482
+ }
483
+ };
484
+ return /* @__PURE__ */ jsx("div", { ...rowProps, children: renderItem(item, index) }, virtualRow.key);
485
+ }) })
486
+ }
487
+ );
488
+ }
489
+ var StatusBadgePropsSchema = z.object({
490
+ status: z.string(),
491
+ variant: z.enum(["success", "warning", "danger", "info", "neutral"]).default("neutral"),
492
+ label: z.string().optional(),
493
+ locale: z.enum(["en", "fr"])
494
+ });
495
+ function validateProps(raw) {
496
+ return StatusBadgePropsSchema.parse(raw);
497
+ }
498
+ var variantClasses = {
499
+ success: "bg-green-100 text-green-800 ring-1 ring-green-300",
500
+ warning: "bg-amber-100 text-amber-800 ring-1 ring-amber-300",
501
+ danger: "bg-red-100 text-red-800 ring-1 ring-red-300",
502
+ info: "bg-blue-100 text-blue-800 ring-1 ring-blue-300",
503
+ neutral: "bg-slate-100 text-slate-800 ring-1 ring-slate-300"
504
+ };
505
+ function StatusBadgeInner({ status, variant, label, locale }) {
506
+ const ariaLabel = label ?? status;
507
+ return /* @__PURE__ */ jsx(
508
+ "output",
509
+ {
510
+ "aria-label": ariaLabel,
511
+ lang: locale,
512
+ class: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${variantClasses[variant]}`,
513
+ children: label ?? status
514
+ }
515
+ );
516
+ }
517
+ function StatusBadge(raw) {
518
+ try {
519
+ const props = validateProps(raw);
520
+ return /* @__PURE__ */ jsx(StatusBadgeInner, { ...props });
521
+ } catch {
522
+ const locale = raw.locale === "fr" ? "fr" : "en";
523
+ return /* @__PURE__ */ jsx("span", { role: "alert", children: t("StatusBadge.error.invalidProps", locale) });
524
+ }
525
+ }
526
+ var ColumnDefSchema = z.object({
527
+ key: z.string().min(1),
528
+ header: z.string().min(1)
529
+ // render is a runtime function — excluded from Zod, typed separately
530
+ });
531
+ var TableViewPropsSchema = z.object({
532
+ columns: z.array(ColumnDefSchema).min(1, "TableView requires at least one column"),
533
+ virtualizeThreshold: z.number().int().positive().default(100),
534
+ ariaLabel: z.string().min(1),
535
+ locale: z.enum(["en", "fr"]).default("en")
536
+ });
537
+ function validateTableViewProps(raw) {
538
+ return TableViewPropsSchema.parse(raw);
539
+ }
540
+ var OVERSCAN = 5;
541
+ function TableView(props) {
542
+ let validatedThreshold = 100;
543
+ try {
544
+ const validated = validateTableViewProps({
545
+ columns: props.columns.map(({ key, header }) => ({ key, header })),
546
+ virtualizeThreshold: props.virtualizeThreshold,
547
+ ariaLabel: props.ariaLabel,
548
+ locale: props.locale
549
+ });
550
+ validatedThreshold = validated.virtualizeThreshold;
551
+ } catch {
552
+ const locale = props.locale === "fr" ? "fr" : "en";
553
+ return /* @__PURE__ */ jsx("div", { role: "alert", children: t("TableView.error.invalidProps", locale) });
554
+ }
555
+ const isVirtual = props.rows.length > validatedThreshold;
556
+ const resolvedLocale = props.locale === "fr" ? "fr" : "en";
557
+ if (isVirtual) {
558
+ return /* @__PURE__ */ jsx(
559
+ VirtualTable,
560
+ {
561
+ rows: props.rows,
562
+ columns: props.columns,
563
+ ariaLabel: props.ariaLabel,
564
+ locale: resolvedLocale,
565
+ onRowClick: props.onRowClick
566
+ }
567
+ );
568
+ }
569
+ return /* @__PURE__ */ jsx(
570
+ StaticTable,
571
+ {
572
+ rows: props.rows,
573
+ columns: props.columns,
574
+ ariaLabel: props.ariaLabel,
575
+ locale: resolvedLocale,
576
+ onRowClick: props.onRowClick
577
+ }
578
+ );
579
+ }
580
+ function StreamingTableView(props) {
581
+ let validatedThreshold = 100;
582
+ try {
583
+ const validated = validateTableViewProps({
584
+ columns: props.columns.map(({ key, header }) => ({ key, header })),
585
+ virtualizeThreshold: props.virtualizeThreshold,
586
+ ariaLabel: props.ariaLabel,
587
+ locale: props.locale
588
+ });
589
+ validatedThreshold = validated.virtualizeThreshold;
590
+ } catch {
591
+ const locale = props.locale === "fr" ? "fr" : "en";
592
+ return /* @__PURE__ */ jsx("div", { role: "alert", children: t("TableView.error.invalidProps", locale) });
593
+ }
594
+ return /* @__PURE__ */ jsx(
595
+ StreamingTableViewInner,
596
+ {
597
+ ...props,
598
+ virtualizeThreshold: validatedThreshold,
599
+ onRowClick: props.onRowClick
600
+ }
601
+ );
602
+ }
603
+ function StreamingTableViewInner({
604
+ columns,
605
+ rows$,
606
+ virtualizeThreshold = 100,
607
+ ariaLabel,
608
+ locale,
609
+ onRowClick
610
+ }) {
611
+ const resolvedLocale = locale === "fr" ? "fr" : "en";
612
+ const [rows, setRows] = useState([]);
613
+ useEffect(() => {
614
+ setRows([]);
615
+ const sub = rows$.subscribe((chunk) => {
616
+ setRows((prev) => [...prev, ...chunk]);
617
+ });
618
+ return () => {
619
+ sub.unsubscribe();
620
+ };
621
+ }, [rows$]);
622
+ const isVirtual = rows.length > virtualizeThreshold;
623
+ if (isVirtual) {
624
+ return /* @__PURE__ */ jsx(
625
+ VirtualTable,
626
+ {
627
+ rows,
628
+ columns,
629
+ ariaLabel,
630
+ locale: resolvedLocale,
631
+ onRowClick
632
+ }
633
+ );
634
+ }
635
+ return /* @__PURE__ */ jsx(
636
+ StaticTable,
637
+ {
638
+ rows,
639
+ columns,
640
+ ariaLabel,
641
+ locale: resolvedLocale,
642
+ onRowClick
643
+ }
644
+ );
645
+ }
646
+ function renderCell(col, row) {
647
+ if (col.render) {
648
+ return col.render(row);
649
+ }
650
+ return String(row[col.key] ?? "");
651
+ }
652
+ function StaticTable({
653
+ rows,
654
+ columns,
655
+ ariaLabel,
656
+ locale,
657
+ onRowClick
658
+ }) {
659
+ const emptyMsg = t("TableView.empty.message", locale);
660
+ return /* @__PURE__ */ jsxs(
661
+ "table",
662
+ {
663
+ "aria-label": ariaLabel,
664
+ "aria-rowcount": rows.length,
665
+ style: { width: "100%", borderCollapse: "collapse" },
666
+ children: [
667
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx("th", { scope: "col", children: col.header }, col.key)) }) }),
668
+ /* @__PURE__ */ jsx("tbody", { children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, "aria-label": emptyMsg, children: emptyMsg }) }) : rows.map((row, rowIndex) => /* @__PURE__ */ jsx(
669
+ "tr",
670
+ {
671
+ "aria-rowindex": rowIndex + 2,
672
+ ...onRowClick ? {
673
+ role: "button",
674
+ tabIndex: 0,
675
+ style: { cursor: "pointer" },
676
+ onClick: () => onRowClick(row, rowIndex),
677
+ onKeyDown: (e) => {
678
+ if (e.key === "Enter" || e.key === " ") {
679
+ e.preventDefault();
680
+ onRowClick(row, rowIndex);
681
+ }
682
+ }
683
+ } : {},
684
+ children: columns.map((col) => /* @__PURE__ */ jsx("td", { children: renderCell(col, row) }, col.key))
685
+ },
686
+ row.id != null ? String(row.id) : `row-${rowIndex}`
687
+ )) })
688
+ ]
689
+ }
690
+ );
691
+ }
692
+ function VirtualTable({
693
+ rows,
694
+ columns,
695
+ ariaLabel,
696
+ // locale reserved for future virtual-mode empty/pagination strings
697
+ locale: _locale,
698
+ onRowClick
699
+ }) {
700
+ const scrollRef = useRef(null);
701
+ const rowVirtualizer = useVirtualizer({
702
+ count: rows.length,
703
+ /* v8 ignore next 1 */
704
+ getScrollElement: () => scrollRef.current,
705
+ estimateSize: useCallback(() => 40, []),
706
+ overscan: OVERSCAN
707
+ });
708
+ const virtualItems = rowVirtualizer.getVirtualItems();
709
+ const totalSize = rowVirtualizer.getTotalSize();
710
+ return /* @__PURE__ */ jsx(
711
+ "div",
712
+ {
713
+ "data-virtual": "true",
714
+ ref: scrollRef,
715
+ tabIndex: 0,
716
+ role: "region",
717
+ "aria-label": ariaLabel,
718
+ style: { height: 400, overflow: "auto", position: "relative" },
719
+ children: /* @__PURE__ */ jsxs(
720
+ "table",
721
+ {
722
+ "aria-label": ariaLabel,
723
+ "aria-rowcount": rows.length,
724
+ style: { width: "100%", borderCollapse: "collapse" },
725
+ children: [
726
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx("th", { scope: "col", children: col.header }, col.key)) }) }),
727
+ /* @__PURE__ */ jsx(
728
+ "tbody",
729
+ {
730
+ style: {
731
+ height: `${totalSize}px`,
732
+ position: "relative",
733
+ display: "block"
734
+ },
735
+ children: virtualItems.map((virtualRow) => {
736
+ const row = rows[virtualRow.index] ?? {};
737
+ return /* @__PURE__ */ jsx(
738
+ "tr",
739
+ {
740
+ "aria-rowindex": virtualRow.index + 2,
741
+ style: {
742
+ position: "absolute",
743
+ top: 0,
744
+ left: 0,
745
+ width: "100%",
746
+ transform: `translateY(${virtualRow.start}px)`,
747
+ display: "flex",
748
+ ...onRowClick ? { cursor: "pointer" } : {}
749
+ },
750
+ ...onRowClick ? {
751
+ role: "button",
752
+ tabIndex: 0,
753
+ onClick: () => onRowClick(row, virtualRow.index),
754
+ onKeyDown: (e) => {
755
+ if (e.key === "Enter" || e.key === " ") {
756
+ e.preventDefault();
757
+ onRowClick(row, virtualRow.index);
758
+ }
759
+ }
760
+ } : {},
761
+ children: columns.map((col) => /* @__PURE__ */ jsx("td", { style: { flex: 1 }, children: renderCell(col, row) }, col.key))
762
+ },
763
+ row.id != null ? String(row.id) : `vrow-${virtualRow.index}`
764
+ );
765
+ })
766
+ }
767
+ )
768
+ ]
769
+ }
770
+ )
771
+ }
772
+ );
773
+ }
774
+
775
+ export { EmptyState, EmptyStatePropsSchema, Skeleton, SkeletonPropsSchema, StatusBadge, StatusBadgePropsSchema, StreamingTableView, TableView, TableViewPropsSchema, VirtualList, VirtualListPropsSchema, resolveSkeletonDimensions, validateEmptyStateProps, validateSkeletonProps, validateProps as validateStatusBadgeProps, validateTableViewProps, validateVirtualListProps };
2
776
  //# sourceMappingURL=display.js.map
3
777
  //# sourceMappingURL=display.js.map