@synertech/ui 0.55.0 → 0.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +66 -3
  2. package/README.md +55 -187
  3. package/dist/components/accordion/Accordion.cjs +1 -1
  4. package/dist/components/accordion/Accordion.js +1 -1
  5. package/dist/components/area-chart/AreaChart.cjs +1 -1
  6. package/dist/components/area-chart/AreaChart.js +1 -1
  7. package/dist/components/chart/ChartExportButton.cjs +1 -1
  8. package/dist/components/chart/ChartExportButton.js +1 -1
  9. package/dist/components/datagrid/ActiveFilters.cjs +1 -0
  10. package/dist/components/datagrid/ActiveFilters.js +1 -0
  11. package/dist/components/datagrid/BulkActionsBar.cjs +1 -0
  12. package/dist/components/datagrid/BulkActionsBar.js +1 -0
  13. package/dist/components/datagrid/ColumnToggle.cjs +1 -0
  14. package/dist/components/datagrid/ColumnToggle.js +1 -0
  15. package/dist/components/datagrid/DataGrid.cjs +1 -1
  16. package/dist/components/datagrid/DataGrid.js +1 -1
  17. package/dist/components/datagrid/DataGridPagination.cjs +1 -0
  18. package/dist/components/datagrid/DataGridPagination.js +1 -0
  19. package/dist/components/datagrid/EditableCell.cjs +1 -0
  20. package/dist/components/datagrid/EditableCell.js +1 -0
  21. package/dist/components/datagrid/FilterPopover.cjs +1 -0
  22. package/dist/components/datagrid/FilterPopover.js +1 -0
  23. package/dist/components/datagrid/export.cjs +1 -0
  24. package/dist/components/datagrid/export.js +1 -0
  25. package/dist/components/datagrid/icons.cjs +1 -0
  26. package/dist/components/datagrid/icons.js +1 -0
  27. package/dist/components/datagrid/index.cjs +1 -1
  28. package/dist/components/datagrid/types.cjs +1 -0
  29. package/dist/components/datagrid/types.js +0 -0
  30. package/dist/components/datagrid/utils.cjs +1 -0
  31. package/dist/components/datagrid/utils.js +1 -0
  32. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  33. package/dist/components/dropdown/DropdownContent.js +1 -1
  34. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  35. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  36. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  37. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  38. package/dist/components/form/mention-input/MentionInput.cjs +5 -5
  39. package/dist/components/form/mention-input/MentionInput.js +5 -5
  40. package/dist/components/help-button/HelpButton.cjs +2 -2
  41. package/dist/components/help-button/HelpButton.js +2 -2
  42. package/dist/components/indicator/Indicator.cjs +1 -1
  43. package/dist/components/indicator/Indicator.js +1 -1
  44. package/dist/components/line-chart/LineChart.cjs +1 -1
  45. package/dist/components/line-chart/LineChart.js +1 -1
  46. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  47. package/dist/components/progress-bar/ProgressBar.js +1 -1
  48. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  49. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  50. package/dist/components/select/Select.cjs +1 -1
  51. package/dist/components/select/Select.js +1 -1
  52. package/dist/components/skeleton/Skeleton.cjs +1 -1
  53. package/dist/components/skeleton/Skeleton.js +1 -1
  54. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  55. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  56. package/dist/index.d.cts +158 -8
  57. package/dist/index.d.ts +158 -8
  58. package/dist/lib/ui-labels.cjs +1 -1
  59. package/dist/lib/ui-labels.js +1 -1
  60. package/dist/styles-no-preflight.css +935 -891
  61. package/dist/styles.css +935 -891
  62. package/package.json +26 -6
@@ -261,6 +261,11 @@ import { cn } from "@synertech/ui";
261
261
 
262
262
  ## Catalogue des composants
263
263
 
264
+ Chaque composant exporté figure ci-dessous. Pour un composant qui n'a pas de section
265
+ dans « API Reference par composant », ses types publiés font foi :
266
+ `node_modules/@synertech/ui/dist/index.d.ts` (props et JSDoc), et sa page de la
267
+ référence : `https://ui.synertechweb.com/docs/<nom-en-kebab-case>/`.
268
+
264
269
  ### Display & Media
265
270
 
266
271
  | Composant | Description | Server-compatible |
@@ -269,6 +274,9 @@ import { cn } from "@synertech/ui";
269
274
  | `Skeleton` | Placeholder de chargement (pulse/wave) | Oui |
270
275
  | `EmptyState` | Ce qu'une liste, un tableau, un graphique ou une page montre quand il n'y a rien : icône, titre, description, actions | Oui |
271
276
  | `Indicator` | Badge de notification (dot/count/status/legend) | Oui |
277
+ | `Badge` | Étiquette courte en pastille : statut, compte, catégorie (`color` × `variant`) | Oui |
278
+ | `ProgressBar` | Barre de progression (`role="progressbar"`), avec valeur ou indéterminée | Oui |
279
+ | `Accordion` | Sections qui s'ouvrent et se ferment, une à la fois ou plusieurs (`AccordionItem`, `AccordionTrigger`, `AccordionContent`) | Non |
272
280
 
273
281
  ### Navigation & Actions
274
282
 
@@ -281,18 +289,23 @@ import { cn } from "@synertech/ui";
281
289
  | `Dropdown` | Menu déroulant composable | Non |
282
290
  | `CommandPalette` | Palette de commandes (⌘K) : chercher une action et la lancer au clavier | Non |
283
291
  | `Tabs` | Interface à onglets composable | Non |
292
+ | `Wizard` | Parcours en plusieurs étapes (stepper), linéaire ou non, avec `useWizard()` | Non |
284
293
 
285
294
  ### Forms & Input
286
295
 
287
296
  | Composant | Description | Server-compatible |
288
297
  |-----------|-------------|:-:|
289
298
  | `Input` | Champ texte/textarea avec label | Non |
299
+ | `NumberInput` | Champ numérique : nombre, monnaie, pourcentage, dans la `locale` ; émet un `number` ou `null` | Non |
300
+ | `MentionInput` | Champ de texte où un déclencheur (`@` par défaut) propose des suggestions, insérées en pastilles | Non |
290
301
  | `FormField` | Libellé, aide et erreur d'un champ sur mesure (le contrôle est le vôtre) | Oui |
291
302
  | `Select` | Combobox searchable avec portal ; plusieurs valeurs en étiquettes avec `multiple` | Non |
292
303
  | `Checkbox` | Case à cocher | Non |
304
+ | `CheckboxGroup` / `CheckboxGroupItem` | Cases d'un même `name`, avec libellé, description et erreur du groupe | Non |
293
305
  | `RadioButton` | Bouton radio | Non |
294
306
  | `Switch` | Interrupteur : un réglage qui prend effet dès qu'on le bascule | Non |
295
307
  | `Slider` | Curseur (range) accessible avec marques et tooltip | Non |
308
+ | `Calendar` | Grille d'un mois : un jour, plusieurs jours ou une période | Non |
296
309
  | `DatePicker` | Champ de date : saisie au clavier ou calendrier en popover | Non |
297
310
  | `DateRangePicker` | Période de deux dates, avec préréglages facultatifs | Non |
298
311
  | `ImageUploader` | Upload d'image (bouton et URL, sans glisser-déposer : c'est `FileSelector`) | Non |
@@ -306,6 +319,7 @@ import { cn } from "@synertech/ui";
306
319
  | `Header` | En-tête de page avec navigation | Non |
307
320
  | `Footer` | Pied de page | Oui |
308
321
  | `Drawer` | Panneau latéral coulissant | Non |
322
+ | `Sidebar` | Barre latérale repliable (groupes, sous-menus) ; tiroir modal sous `mobileBreakpoint` | Non |
309
323
  | `Divider` | Séparateur horizontal/vertical | Oui |
310
324
 
311
325
  ### Data Display
@@ -313,7 +327,7 @@ import { cn } from "@synertech/ui";
313
327
  | Composant | Description | Server-compatible |
314
328
  |-----------|-------------|:-:|
315
329
  | `Table` | Tableau composable (Header, Body, Row, Cell) | Oui |
316
- | `DataGrid` | Tableau avancé data-driven (tri, pagination, filtres, sélection, export) | Non |
330
+ | `DataGrid` | Tableau avancé data-driven (tri, pagination, filtres, sélection, actions groupées, vues enregistrées, export) | Non |
317
331
  | `TreeView` | Arborescence : dossiers et fichiers, catégories ; sélection simple ou multiple, cases à trois états, enfants chargés à la demande | Non |
318
332
  | `Chip` | Tag/badge | Oui |
319
333
  | `Timeline` / `TimelineItem` | Frise de ce qui s'est passé : historique d'un dossier, journal d'audit, suivi d'une commande | Oui |
@@ -333,6 +347,8 @@ import { cn } from "@synertech/ui";
333
347
  - `BulletChart` - Réalisé, objectif et plages qualitatives sur une seule ligne
334
348
  - `ChartFacets` - Petits multiples : un même graphique répété, à échelle partagée
335
349
  - `ChartScaleLegend` - La légende d'une rampe de couleur
350
+ - `ChartContainer` - Le cadre d'un graphique : titre, description, légende, actions,
351
+ états chargement / vide / erreur — celui de chaque graphique du kit, pour un graphique à vous
336
352
  - `ChartFilterBar` - Les filtres en une rangée au-dessus des graphiques qu'ils cadrent
337
353
  - `ChartPeriodPicker` - La fenêtre d'un tableau de bord : préréglages nommés + calendrier
338
354
  - `WaterfallChart` - Comment on passe de A à B : chaque contribution, positive ou négative
@@ -350,11 +366,13 @@ import { cn } from "@synertech/ui";
350
366
  | Composant | Description | Server-compatible |
351
367
  |-----------|-------------|:-:|
352
368
  | `Modal` | Dialog/overlay | Non |
369
+ | `Popover` | Panneau interactif ancré à son déclencheur : petit formulaire, filtres | Non |
353
370
  | `Tooltip` | Info-bulle au survol/clic | Non |
354
371
  | `Toast` | Un message de notification, là où on le rend | Non |
355
372
  | `Toaster` + `toast()` | La pile des notifications, poussées de n'importe où | Non (`toast()` s'appelle partout) |
356
373
  | `CircularProgress` | Indicateur de chargement | Oui |
357
374
  | `HelpButton` | Bouton d'aide contextuel avec Markdown | Non |
375
+ | `MarkdownEditor` | L'éditeur du mode édition de `HelpButton`, importé de `@synertech/ui/markdown-editor` (dépendance facultative `@mdxeditor/editor`) | Non |
358
376
 
359
377
  ### Advanced
360
378
 
@@ -2192,7 +2210,7 @@ import { FileSelector } from "@synertech/ui";
2192
2210
 
2193
2211
  ```tsx
2194
2212
  import { DataGrid } from "@synertech/ui";
2195
- import type { ColumnDef, SortState, DataGridRef } from "@synertech/ui";
2213
+ import type { ColumnDef, SortState, DataGridRef, DataGridView } from "@synertech/ui";
2196
2214
  import { useRef } from "react";
2197
2215
 
2198
2216
  const ref = useRef<DataGridRef>(null);
@@ -2241,10 +2259,29 @@ const columns: ColumnDef<User>[] = [
2241
2259
  selectionMode="multiple" // "single" | "multiple"
2242
2260
  onSelectionChange={(keys) => console.log(keys)}
2243
2261
 
2262
+ // Actions groupées : une barre au-dessus de la grille tant que des lignes sont
2263
+ // cochées (leur nombre, vos actions, « Effacer la sélection »). En fonction, elle
2264
+ // reçoit les clés et les lignes de `data` de toutes les pages, et clear()
2265
+ bulkActions={({ keys, rows, clear }) => (
2266
+ <Button size="sm" onClick={async () => { await archive(keys); clear(); }}>
2267
+ Archiver {rows.length}
2268
+ </Button>
2269
+ )}
2270
+
2244
2271
  // Recherche & Filtres
2245
2272
  searchable
2246
2273
  searchPlaceholder="Rechercher..."
2247
2274
  onSearch={(q) => console.log(q)}
2275
+ // Les filtres en vigueur sont écrits au-dessus de la grille, un chip retirable
2276
+ // chacun (« Rôle : Admin », « Âge : ≥ 30 »), dans la `locale` de la grille
2277
+ showActiveFilters // par défaut ; false pour les taire
2278
+
2279
+ // Vue : chaque partie contrôlée par sa prop, ou tenue par la grille
2280
+ defaultView={savedView} // lue au montage seulement, entière ou en partie
2281
+ onViewChange={(view) => save(view)} // la vue entière, à chaque changement
2282
+ pageSize={pageSize} // + onPageSizeChange
2283
+ columnOrder={order} // + onColumnOrderChange (toutes les clés, masquées comprises)
2284
+ columnWidths={widths} // + onColumnWidthsChange, appelée une fois au relâcher
2248
2285
 
2249
2286
  // Lignes expandables
2250
2287
  expandable
@@ -2301,6 +2338,32 @@ ref.current?.deselectAll(); // vide la sélection, toutes pages confondues
2301
2338
  ref.current?.exportData("csv");
2302
2339
  ref.current?.scrollToRow(50);
2303
2340
  ref.current?.getVisibleData();
2341
+ const view = ref.current?.getView(); // tri, filtres, recherche, colonnes, taille de page
2342
+ ref.current?.setView(view); // revient à la page 1 ; ignore les champs inconnus
2343
+ ```
2344
+
2345
+ **Vues enregistrées :** une `DataGridView` est un objet JSON (tri, filtres,
2346
+ recherche, colonnes masquées, ordre et largeurs des colonnes, taille de page).
2347
+ Enregistrez-la dans `onViewChange` ; remettez-la par `defaultView` si elle est
2348
+ connue avant le rendu, sinon par `setView` dans un effet. Ne lisez jamais
2349
+ `localStorage` pendant le rendu : le serveur ne l'a pas, et le HTML ne correspond
2350
+ plus à l'hydratation.
2351
+
2352
+ ```tsx
2353
+ "use client";
2354
+ const ref = useRef<DataGridRef>(null);
2355
+ useEffect(() => {
2356
+ const saved = localStorage.getItem("clients:view");
2357
+ if (saved) ref.current?.setView(JSON.parse(saved) as Partial<DataGridView>);
2358
+ }, []);
2359
+
2360
+ <DataGrid
2361
+ ref={ref}
2362
+ columns={columns}
2363
+ data={clients}
2364
+ rowKey="id"
2365
+ onViewChange={(view) => localStorage.setItem("clients:view", JSON.stringify(view))}
2366
+ />
2304
2367
  ```
2305
2368
 
2306
2369
  **Quand utiliser DataGrid vs Table :**
@@ -2756,7 +2819,7 @@ d'écrire les nombres et les dates. Le provider prend les deux :
2756
2819
  ```
2757
2820
 
2758
2821
  - La lisent : les treize graphiques, `Calendar`, `ChartPeriodPicker`,
2759
- `NumberInput` et les agrégats du pied de `DataGrid`. La prop `locale` d'une
2822
+ `NumberInput`, les agrégats du pied et les filtres actifs de `DataGrid`. La prop `locale` d'une
2760
2823
  instance gagne ; un provider imbriqué sans `locale` garde celle du parent ;
2761
2824
  `useUILocale()` la lit pour vos propres composants (à passer à `Intl`).
2762
2825
  - Sans prop ni provider, ces composants suivent la langue de l'environnement :
package/README.md CHANGED
@@ -1,8 +1,50 @@
1
1
  # @synertech/ui
2
2
 
3
- A TypeScript/React UI component library using Tailwind CSS classes. Published on the public npm registry.
3
+ **React dashboards, from a single package.** Charts, a data grid, forms and
4
+ accessible dialogs for React and Next.js, drawn by one compiled stylesheet — no
5
+ Tailwind setup to write — with every label the components write in English and
6
+ in French. Free to use, in commercial applications too.
4
7
 
5
- 📖 **[View Storybook](https://ui.synertechweb.com/storybook/)** — Interactive component documentation
8
+ **[Documentation](https://ui.synertechweb.com/en/docs/)** ·
9
+ **[Demos](https://ui.synertechweb.com/en/#galerie)** ·
10
+ **[Storybook](https://ui.synertechweb.com/storybook/)**
11
+
12
+ [![A dashboard built with @synertech/ui: three KPI cards, two of them with a sparkline, an area chart of the revenue per day, and a progress bar](https://ui.synertechweb.com/images/readme-dashboard.png)](https://ui.synertechweb.com/en/#galerie)
13
+
14
+ ```bash
15
+ pnpm add @synertech/ui
16
+ ```
17
+
18
+ ```tsx
19
+ import "@synertech/ui/styles.css"; // once, at the root of the application
20
+ import { DataGrid, LineChart, StatCard } from "@synertech/ui";
21
+ ```
22
+
23
+ The components are typed, and they can be imported from a Server Component: each
24
+ module that needs `"use client"` carries it, and the display components (`Card`,
25
+ `Table`, `StatCard`, `Timeline`…) render on the server.
26
+
27
+ ## Components
28
+
29
+ The [reference](https://ui.synertechweb.com/en/docs/) has a page for each, with
30
+ live examples, what it is for and every prop:
31
+
32
+ <!-- reference:start -->
33
+
34
+ | Category | Pages |
35
+ | --- | --- |
36
+ | Display & media | [Avatar](https://ui.synertechweb.com/en/docs/avatar/) · [Badge](https://ui.synertechweb.com/en/docs/badge/) · [Indicator](https://ui.synertechweb.com/en/docs/indicator/) · [Skeleton](https://ui.synertechweb.com/en/docs/skeleton/) · [EmptyState](https://ui.synertechweb.com/en/docs/empty-state/) · [ProgressBar](https://ui.synertechweb.com/en/docs/progress-bar/) · [Accordion](https://ui.synertechweb.com/en/docs/accordion/) |
37
+ | Navigation & actions | [Button](https://ui.synertechweb.com/en/docs/button/) · [ButtonGroup](https://ui.synertechweb.com/en/docs/button-group/) · [Dropdown](https://ui.synertechweb.com/en/docs/dropdown/) · [CommandPalette](https://ui.synertechweb.com/en/docs/command-palette/) · [Tabs](https://ui.synertechweb.com/en/docs/tabs/) · [Breadcrumb](https://ui.synertechweb.com/en/docs/breadcrumb/) · [Pagination](https://ui.synertechweb.com/en/docs/pagination/) · [Wizard](https://ui.synertechweb.com/en/docs/wizard/) |
38
+ | Forms | [Input](https://ui.synertechweb.com/en/docs/input/) · [NumberInput](https://ui.synertechweb.com/en/docs/number-input/) · [MentionInput](https://ui.synertechweb.com/en/docs/mention-input/) · [Select](https://ui.synertechweb.com/en/docs/select/) · [Checkbox](https://ui.synertechweb.com/en/docs/checkbox/) · [RadioButton](https://ui.synertechweb.com/en/docs/radio-button/) · [Switch](https://ui.synertechweb.com/en/docs/switch/) · [Slider](https://ui.synertechweb.com/en/docs/slider/) · [Calendar](https://ui.synertechweb.com/en/docs/calendar/) · [DatePicker](https://ui.synertechweb.com/en/docs/date-picker/) · [Label](https://ui.synertechweb.com/en/docs/label/) · [FormField](https://ui.synertechweb.com/en/docs/form-field/) · [ImageUploader](https://ui.synertechweb.com/en/docs/image-uploader/) · [FileSelector](https://ui.synertechweb.com/en/docs/file-selector/) |
39
+ | Layout | [Card](https://ui.synertechweb.com/en/docs/card/) · [Header](https://ui.synertechweb.com/en/docs/header/) · [Footer](https://ui.synertechweb.com/en/docs/footer/) · [Drawer](https://ui.synertechweb.com/en/docs/drawer/) · [Sidebar](https://ui.synertechweb.com/en/docs/sidebar/) · [Divider](https://ui.synertechweb.com/en/docs/divider/) |
40
+ | Data | [Table](https://ui.synertechweb.com/en/docs/table/) · [DataGrid](https://ui.synertechweb.com/en/docs/datagrid/) · [TreeView](https://ui.synertechweb.com/en/docs/tree-view/) · [Chip](https://ui.synertechweb.com/en/docs/chip/) · [Timeline](https://ui.synertechweb.com/en/docs/timeline/) |
41
+ | Charts | [LineChart](https://ui.synertechweb.com/en/docs/line-chart/) · [AreaChart](https://ui.synertechweb.com/en/docs/area-chart/) · [BarChart](https://ui.synertechweb.com/en/docs/bar-chart/) · [PieChart](https://ui.synertechweb.com/en/docs/pie-chart/) · [ScatterChart](https://ui.synertechweb.com/en/docs/scatter-chart/) · [StatCard](https://ui.synertechweb.com/en/docs/stat-card/) · [Sparkline](https://ui.synertechweb.com/en/docs/sparkline/) · [Heatmap](https://ui.synertechweb.com/en/docs/heat-map/) · [BulletChart](https://ui.synertechweb.com/en/docs/bullet-chart/) · [WaterfallChart](https://ui.synertechweb.com/en/docs/waterfall-chart/) · [FunnelChart](https://ui.synertechweb.com/en/docs/funnel-chart/) · [DumbbellChart](https://ui.synertechweb.com/en/docs/dumbbell-chart/) · [BoxPlot](https://ui.synertechweb.com/en/docs/box-plot/) · [CandlestickChart](https://ui.synertechweb.com/en/docs/candlestick-chart/) · [GanttChart](https://ui.synertechweb.com/en/docs/gantt-chart/) |
42
+ | Dashboards | [ChartContainer](https://ui.synertechweb.com/en/docs/chart-container/) · [ChartFacets](https://ui.synertechweb.com/en/docs/chart-facets/) · [ChartFilterBar](https://ui.synertechweb.com/en/docs/chart-filter-bar/) · [ChartPeriodPicker](https://ui.synertechweb.com/en/docs/chart-period-picker/) · [ChartSyncProvider](https://ui.synertechweb.com/en/docs/chart-sync/) · [ChartExportButton](https://ui.synertechweb.com/en/docs/chart-export-button/) · [ChartScaleLegend](https://ui.synertechweb.com/en/docs/chart-scale-legend/) · [Chart foundation](https://ui.synertechweb.com/en/docs/chart-foundation/) |
43
+ | Feedback & overlays | [Modal](https://ui.synertechweb.com/en/docs/modal/) · [Popover](https://ui.synertechweb.com/en/docs/popover/) · [Tooltip](https://ui.synertechweb.com/en/docs/tooltip/) · [Toast](https://ui.synertechweb.com/en/docs/toast/) · [Toaster](https://ui.synertechweb.com/en/docs/toaster/) · [Banner](https://ui.synertechweb.com/en/docs/banner/) · [CircularProgress](https://ui.synertechweb.com/en/docs/circular-progress/) · [HelpButton](https://ui.synertechweb.com/en/docs/help-button/) · [MarkdownEditor](https://ui.synertechweb.com/en/docs/markdown-editor/) · [Detachable](https://ui.synertechweb.com/en/docs/detachable/) · [AdvanceDetachable](https://ui.synertechweb.com/en/docs/advance-detachable/) |
44
+ | Advanced | [WorkflowEditor](https://ui.synertechweb.com/en/docs/workflow-editor/) · [SchemaEditor](https://ui.synertechweb.com/en/docs/schema-editor/) · [DeviceMockup](https://ui.synertechweb.com/en/docs/device-mockup/) |
45
+ | Hooks & utilities | [useDialogA11y](https://ui.synertechweb.com/en/docs/use-dialog-a11y/) · [Translatable labels](https://ui.synertechweb.com/en/docs/i18n/) · [Utilities](https://ui.synertechweb.com/en/docs/utilities/) |
46
+
47
+ <!-- reference:end -->
6
48
 
7
49
  ## Installation
8
50
 
@@ -119,7 +161,6 @@ import { MarkdownEditor } from "@synertech/ui/markdown-editor";
119
161
  stylesheet is included. Without the prop, the edit mode renders an explanatory
120
162
  message instead of the editor.
121
163
 
122
-
123
164
  ### 6. Optional: the colour of your application
124
165
 
125
166
  A primary button, a checked box, a selected row, an active tab, a focus ring, a link:
@@ -172,13 +213,13 @@ one component at a time.
172
213
  ```tsx
173
214
  import { Button } from "@synertech/ui";
174
215
 
175
- <Button variant="primary" onClick={() => console.log("clicked")}>
176
- Click me
177
- </Button>
216
+ <Button onClick={() => console.log("saved")}>Save</Button>
178
217
 
179
- <Button variant="outline" disabled>
180
- Disabled
218
+ <Button size="sm" loading>
219
+ Saving
181
220
  </Button>
221
+
222
+ <Button disabled>Unavailable</Button>
182
223
  ```
183
224
 
184
225
  ### Input
@@ -222,11 +263,11 @@ import { Header, Footer, FooterBottom } from "@synertech/ui";
222
263
  import { Modal } from "@synertech/ui";
223
264
 
224
265
  <Modal
225
- isOpen={isOpen}
266
+ open={isOpen}
226
267
  onClose={() => setIsOpen(false)}
227
- title="Confirm Action"
228
- buttonLabel="Confirm"
229
- onButtonClick={handleConfirm}
268
+ title="Confirm action"
269
+ submitLabel="Confirm"
270
+ onSubmitClick={handleConfirm}
230
271
  >
231
272
  <p>Are you sure you want to proceed?</p>
232
273
  </Modal>
@@ -287,7 +328,7 @@ written, and the provider takes both:
287
328
  ```
288
329
 
289
330
  - The charts, `Calendar`, `ChartPeriodPicker`, `NumberInput` and the footer
290
- aggregates of `DataGrid` read it. A `locale` prop on one instance wins, and
331
+ aggregates and active filters of `DataGrid` read it. A `locale` prop on one instance wins, and
291
332
  `useUILocale()` reads it for your own components.
292
333
  - Without either, they follow the language of the runtime — the server's on the
293
334
  server, the reader's in the browser. **An application that renders on the
@@ -348,181 +389,8 @@ import {
348
389
  </Table>
349
390
  ```
350
391
 
351
- ## Available Components
352
-
353
- | Category | Components |
354
- | -------- | ------------------------------------------------------------------------------- |
355
- | Button | `Button` |
356
- | Form | `Input` |
357
- | Layout | `Header`, `Footer` |
358
- | Modal | `Modal` |
359
- | Table | `Table`, `TableHeader`, `TableHeaderCell`, `TableBody`, `TableRow`, `TableCell` |
360
-
361
- ## Contributing
362
-
363
- ### Adding a new component
364
-
365
- 1. Create the component in the appropriate category: `src/components/<category>/<Component>.tsx`
366
- 2. Add `"use client"` directive if the module needs it (see [Conventions](#use-client-directive))
367
- 3. Export the component and its props type
368
- 4. Add export in `src/components/<category>/index.ts`
369
- 5. Verify: `pnpm typecheck && pnpm build`
370
- 6. Create a changeset: `pnpm changeset` (see [Releasing](#releasing))
371
- 7. Commit and push to `main`
372
-
373
- ### Guidelines
374
-
375
- - **No MUI** – HTML + Tailwind only
376
- - **No compiled CSS** – Tailwind classes are applied, not compiled
377
- - **React as peer dependency** – Don't bundle React
378
- - **Next.js compatible** – Proper ESM/CJS exports
379
- - **Use `"use client"`** – Only for modules using client-only React APIs or their own event handlers
380
- - **Accept `className`** – All components should allow style overrides
381
- - **Export types** – Each component exports its props type
382
-
383
- ## Development
384
-
385
- ```bash
386
- pnpm build # Build to dist/
387
- pnpm dev # Build in watch mode
388
- pnpm typecheck # TypeScript check
389
- pnpm lint # ESLint check
390
- pnpm lint:fix # ESLint auto-fix
391
- pnpm format # Prettier format
392
- pnpm format:check # Prettier check
393
- pnpm storybook # Run Storybook locally (port 6006)
394
- pnpm build-storybook # Build static Storybook
395
- ```
396
-
397
- ## Storybook
398
-
399
- Interactive component documentation is available via Storybook.
400
-
401
- ### Run locally
402
-
403
- ```bash
404
- pnpm storybook
405
- ```
406
-
407
- Then open [http://localhost:6006](http://localhost:6006).
408
-
409
- ### Hosted version
410
-
411
- Storybook is automatically deployed to GitLab Pages on every push to `main`:
412
-
413
- 👉 **https://ui.synertechweb.com/storybook/**
414
-
415
- ## Releasing
416
-
417
- This project uses [Changesets](https://github.com/changesets/changesets) for version management and changelog generation.
418
-
419
- ### Workflow
420
-
421
- 1. **Create a changeset** after making changes:
422
- ```bash
423
- pnpm changeset
424
- ```
425
- This will prompt you to select the version bump type (patch/minor/major) and write a summary.
426
-
427
- 2. **Commit the changeset file** (`.changeset/*.md`) along with your changes.
428
-
429
- 3. **When ready to release**, apply the version bump:
430
- ```bash
431
- pnpm version-packages
432
- ```
433
- This consumes all changesets, bumps `package.json` version, and updates `CHANGELOG.md`.
434
-
435
- 4. **Commit and push** to `main`:
436
- ```bash
437
- git add -A && git commit -m "chore: release vX.Y.Z" && git push
438
- ```
439
-
440
- 5. **CI publishes automatically** to the public npm registry.
441
-
442
- > **Note**: npm versions are immutable. Once published, a version cannot be overwritten. Changesets prevents accidental duplicate publishes.
443
-
444
- ## Conventions
445
-
446
- ### `"use client"` directive
447
-
448
- An application never has to write `"use client"` just to import a component: the
449
- library's own modules carry the directive, and each one is published as its own file so
450
- the directive survives the build. A module gets it when it:
451
-
452
- - uses a client-only React API: state, effects, refs, context (`useId`, `useMemo`,
453
- `useCallback`, `forwardRef` and `memo` also exist on the server);
454
- - or attaches an event handler of its own to what it renders (`Chip` has no hook, but
455
- always wires `onClick`).
456
-
457
- Display components (`Card`, `Button`, `Avatar`, `Table`, `StatCard`, `Sparkline`…) have no
458
- directive and render as Server Components. `pnpm build` runs
459
- `scripts/check-bundle-boundary.mjs`, which fails when a directive is lost or when a module
460
- without one uses a client-only API.
461
-
462
- ### `className` prop
463
-
464
- All components accept a `className` prop for style customization. Classes are merged using the internal `cn()` utility.
465
-
466
- ### Styles CSS
467
-
468
- The library ships with pre-compiled CSS. Simply import it once:
469
-
470
- ```tsx
471
- import "@synertech/ui/styles.css";
472
- ```
473
-
474
- An application that compiles Tailwind CSS itself imports `@synertech/ui/styles-no-preflight.css`
475
- instead: the same sheet without Tailwind's reset, which its own stylesheet already has. See
476
- the [installation section](#2-import-the-styles).
477
-
478
-
479
- ## Table Suite
480
-
481
- The Table components are designed to be composed together for flexibility:
482
-
483
- ```
484
- Table
485
- ├── TableHeader
486
- │ └── TableHeaderCell (multiple)
487
- └── TableBody
488
- └── TableRow (multiple)
489
- └── TableCell (multiple)
490
- ```
491
-
492
- ### Component Props
493
-
494
- | Component | Key Props | HTML Element |
495
- | ----------------- | ----------------------------------- | ------------ |
496
- | `Table` | `className` | `<table>` |
497
- | `TableHeader` | `className` | `<thead>` |
498
- | `TableHeaderCell` | `sortable`, `onClick`, `className` | `<th>` |
499
- | `TableBody` | `className` | `<tbody>` |
500
- | `TableRow` | `clickable`, `onClick`, `className` | `<tr>` |
501
- | `TableCell` | `className` | `<td>` |
502
-
503
- ### Example with sortable headers
504
-
505
- ```tsx
506
- <Table>
507
- <TableHeader>
508
- <TableHeaderCell sortable onClick={() => sort("name")}>
509
- Name ↕
510
- </TableHeaderCell>
511
- <TableHeaderCell>Email</TableHeaderCell>
512
- </TableHeader>
513
- <TableBody>
514
- {users.map((user) => (
515
- <TableRow key={user.id} onClick={() => selectUser(user)}>
516
- <TableCell>{user.name}</TableCell>
517
- <TableCell>{user.email}</TableCell>
518
- </TableRow>
519
- ))}
520
- </TableBody>
521
- </Table>
522
- ```
523
-
524
392
  ## License
525
393
 
526
394
  Free to install and use in your applications, including commercial ones.
527
395
  Redistribution and derivative component libraries are not permitted.
528
- See [LICENSE](LICENSE).
396
+ See [LICENSE](LICENSE), or the licence [in plain words](https://ui.synertechweb.com/en/docs/licence/).
@@ -1 +1 @@
1
- "use strict";"use client";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var c in r)A(e,c,{get:r[c],enumerable:!0})},M=(e,r,c,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!D.call(e,t)&&t!==c&&A(e,t,{get:()=>r[t],enumerable:!(n=z(r,t))||n.enumerable});return e};var S=e=>M(A({},"__esModule",{value:!0}),e);var G={};H(G,{Accordion:()=>$,AccordionContent:()=>F,AccordionItem:()=>q,AccordionTrigger:()=>B});module.exports=S(G);var o=require("react"),b=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),I=(0,o.createContext)(null),C=(0,o.createContext)(null);function v(){let e=(0,o.useContext)(I);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function N(){let e=(0,o.useContext)(C);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var k={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:e})=>(0,d.jsx)("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function $({type:e="single",value:r,defaultValue:c,onValueChange:n,collapsible:t=!1,variant:s="default",size:l="md",disabled:u=!1,iconPosition:a="right",icon:g,hideIcon:i=!1,className:m,children:w}){let[R,P]=(0,o.useState)(()=>c?Array.isArray(c)?c:[c]:[]),y=r!==void 0,p=y?Array.isArray(r)?r:[r]:R,h=(0,o.useCallback)(f=>{let x;e==="single"?p.includes(f)?x=t?[]:[f]:x=[f]:x=p.includes(f)?p.filter(T=>T!==f):[...p,f],y||P(x),n?.(e==="single"?x[0]??"":x)},[e,p,t,y,n]),O=(0,o.useMemo)(()=>({openItems:p,toggle:h,variant:s,size:l,disabled:u,iconPosition:a,icon:g??null,hideIcon:i}),[p,h,s,l,u,a,g,i]);return(0,d.jsx)(I.Provider,{value:O,children:(0,d.jsx)("div",{className:(0,b.cn)(K[s],m),"data-testid":"accordion",children:w})})}function q({value:e,disabled:r,className:c,children:n}){let t=v(),s=t.openItems.includes(e),l=r??t.disabled,u=(0,o.useId)(),a=`accordion-trigger-${u}`,g=`accordion-content-${u}`,i=(0,o.useMemo)(()=>({value:e,isOpen:s,disabled:l,triggerId:a,contentId:g}),[e,s,l,a,g]);return(0,d.jsx)(C.Provider,{value:i,children:(0,d.jsx)("div",{className:(0,b.cn)(L[t.variant],c),"data-state":s?"open":"closed","data-testid":"accordion-item",children:n})})}function B({className:e,icon:r,children:c}){let n=v(),t=N(),s=k[n.size],l=()=>{t.disabled||n.toggle(t.value)},u=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l())},a=r??n.icon??(0,d.jsx)(V,{className:s.icon}),g=!n.hideIcon&&(0,d.jsx)("span",{className:(0,b.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",t.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:a});return(0,d.jsxs)("button",{type:"button",id:t.triggerId,"aria-expanded":t.isOpen,"aria-controls":t.contentId,disabled:t.disabled,onClick:l,onKeyDown:u,className:(0,b.cn)("flex items-center w-full text-left font-medium transition-colors cursor-pointer",s.trigger,s.text,"text-gray-900 dark:text-gray-100",!t.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",t.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&g,(0,d.jsx)("span",{className:"flex-1",children:c}),n.iconPosition==="right"&&g]})}function F({className:e,children:r}){let c=v(),n=N(),t=k[c.size],s=(0,o.useRef)(null),l=(0,o.useRef)(null),[u,a]=(0,o.useState)(n.isOpen?void 0:0),g=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{let i=l.current;i&&(n.isOpen?i.removeAttribute("inert"):i.setAttribute("inert",""))},[n.isOpen]),(0,o.useEffect)(()=>{if(g.current){g.current=!1,a(n.isOpen?void 0:0);return}if(n.isOpen){let i=s.current;if(i){a(i.scrollHeight);let m=setTimeout(()=>a(void 0),200);return()=>clearTimeout(m)}}else{let i=s.current;i&&(a(i.scrollHeight),requestAnimationFrame(()=>a(0)))}},[n.isOpen]),(0,d.jsx)("div",{ref:l,id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:(0,d.jsx)("div",{ref:s,className:(0,b.cn)(t.content,"text-gray-600 dark:text-gray-400",t.text==="text-lg"?"text-base":"text-sm",e),children:r})})}0&&(module.exports={Accordion,AccordionContent,AccordionItem,AccordionTrigger});
1
+ "use strict";"use client";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var c in r)A(e,c,{get:r[c],enumerable:!0})},M=(e,r,c,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!D.call(e,t)&&t!==c&&A(e,t,{get:()=>r[t],enumerable:!(n=z(r,t))||n.enumerable});return e};var S=e=>M(A({},"__esModule",{value:!0}),e);var G={};H(G,{Accordion:()=>$,AccordionContent:()=>F,AccordionItem:()=>q,AccordionTrigger:()=>B});module.exports=S(G);var o=require("react"),b=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),C=(0,o.createContext)(null),N=(0,o.createContext)(null);function v(){let e=(0,o.useContext)(C);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function k(){let e=(0,o.useContext)(N);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var w={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:e})=>(0,d.jsx)("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function $({type:e="single",value:r,defaultValue:c,onValueChange:n,collapsible:t=!1,variant:s="default",size:l="md",disabled:u=!1,iconPosition:a="right",icon:g,hideIcon:i=!1,className:y,children:R}){let[h,O]=(0,o.useState)(()=>c?Array.isArray(c)?c:[c]:[]),m=r!==void 0,p=(0,o.useMemo)(()=>m?Array.isArray(r)?r:[r]:h,[m,r,h]),I=(0,o.useCallback)(f=>{let x;e==="single"?p.includes(f)?x=t?[]:[f]:x=[f]:x=p.includes(f)?p.filter(T=>T!==f):[...p,f],m||O(x),n?.(e==="single"?x[0]??"":x)},[e,p,t,m,n]),P=(0,o.useMemo)(()=>({openItems:p,toggle:I,variant:s,size:l,disabled:u,iconPosition:a,icon:g??null,hideIcon:i}),[p,I,s,l,u,a,g,i]);return(0,d.jsx)(C.Provider,{value:P,children:(0,d.jsx)("div",{className:(0,b.cn)(K[s],y),"data-testid":"accordion",children:R})})}function q({value:e,disabled:r,className:c,children:n}){let t=v(),s=t.openItems.includes(e),l=r??t.disabled,u=(0,o.useId)(),a=`accordion-trigger-${u}`,g=`accordion-content-${u}`,i=(0,o.useMemo)(()=>({value:e,isOpen:s,disabled:l,triggerId:a,contentId:g}),[e,s,l,a,g]);return(0,d.jsx)(N.Provider,{value:i,children:(0,d.jsx)("div",{className:(0,b.cn)(L[t.variant],c),"data-state":s?"open":"closed","data-testid":"accordion-item",children:n})})}function B({className:e,icon:r,children:c}){let n=v(),t=k(),s=w[n.size],l=()=>{t.disabled||n.toggle(t.value)},u=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l())},a=r??n.icon??(0,d.jsx)(V,{className:s.icon}),g=!n.hideIcon&&(0,d.jsx)("span",{className:(0,b.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",t.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:a});return(0,d.jsxs)("button",{type:"button",id:t.triggerId,"aria-expanded":t.isOpen,"aria-controls":t.contentId,disabled:t.disabled,onClick:l,onKeyDown:u,className:(0,b.cn)("flex items-center w-full text-left font-medium transition-colors cursor-pointer",s.trigger,s.text,"text-gray-900 dark:text-gray-100",!t.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",t.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&g,(0,d.jsx)("span",{className:"flex-1",children:c}),n.iconPosition==="right"&&g]})}function F({className:e,children:r}){let c=v(),n=k(),t=w[c.size],s=(0,o.useRef)(null),l=(0,o.useRef)(null),[u,a]=(0,o.useState)(n.isOpen?void 0:0),g=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{let i=l.current;i&&(n.isOpen?i.removeAttribute("inert"):i.setAttribute("inert",""))},[n.isOpen]),(0,o.useEffect)(()=>{if(g.current){g.current=!1,a(n.isOpen?void 0:0);return}if(n.isOpen){let i=s.current;if(i){a(i.scrollHeight);let y=setTimeout(()=>a(void 0),200);return()=>clearTimeout(y)}}else{let i=s.current;i&&(a(i.scrollHeight),requestAnimationFrame(()=>a(0)))}},[n.isOpen]),(0,d.jsx)("div",{ref:l,id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:(0,d.jsx)("div",{ref:s,className:(0,b.cn)(t.content,"text-gray-600 dark:text-gray-400",t.text==="text-lg"?"text-base":"text-sm",e),children:r})})}0&&(module.exports={Accordion,AccordionContent,AccordionItem,AccordionTrigger});
@@ -1 +1 @@
1
- "use client";import{createContext as I,useContext as C,useState as N,useCallback as M,useMemo as k,useRef as y,useEffect as h,useId as S}from"react";import{cn as x}from"../../lib/cn.js";import{jsx as d,jsxs as $}from"react/jsx-runtime";var w=I(null),R=I(null);function A(){let t=C(w);if(!t)throw new Error("Accordion sub-components must be used within <Accordion>");return t}function P(){let t=C(R);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return t}var O={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:t})=>d("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:d("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function F({type:t="single",value:a,defaultValue:l,onValueChange:e,collapsible:n=!1,variant:r="default",size:c="md",disabled:g=!1,iconPosition:i="right",icon:s,hideIcon:o=!1,className:b,children:T}){let[z,E]=N(()=>l?Array.isArray(l)?l:[l]:[]),m=a!==void 0,u=m?Array.isArray(a)?a:[a]:z,v=M(p=>{let f;t==="single"?u.includes(p)?f=n?[]:[p]:f=[p]:f=u.includes(p)?u.filter(H=>H!==p):[...u,p],m||E(f),e?.(t==="single"?f[0]??"":f)},[t,u,n,m,e]),D=k(()=>({openItems:u,toggle:v,variant:r,size:c,disabled:g,iconPosition:i,icon:s??null,hideIcon:o}),[u,v,r,c,g,i,s,o]);return d(w.Provider,{value:D,children:d("div",{className:x(K[r],b),"data-testid":"accordion",children:T})})}function G({value:t,disabled:a,className:l,children:e}){let n=A(),r=n.openItems.includes(t),c=a??n.disabled,g=S(),i=`accordion-trigger-${g}`,s=`accordion-content-${g}`,o=k(()=>({value:t,isOpen:r,disabled:c,triggerId:i,contentId:s}),[t,r,c,i,s]);return d(R.Provider,{value:o,children:d("div",{className:x(L[n.variant],l),"data-state":r?"open":"closed","data-testid":"accordion-item",children:e})})}function J({className:t,icon:a,children:l}){let e=A(),n=P(),r=O[e.size],c=()=>{n.disabled||e.toggle(n.value)},g=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),c())},i=a??e.icon??d(V,{className:r.icon}),s=!e.hideIcon&&d("span",{className:x("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return $("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:c,onKeyDown:g,className:x("flex items-center w-full text-left font-medium transition-colors cursor-pointer",r.trigger,r.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",t),"data-testid":"accordion-trigger",children:[e.iconPosition==="left"&&s,d("span",{className:"flex-1",children:l}),e.iconPosition==="right"&&s]})}function Q({className:t,children:a}){let l=A(),e=P(),n=O[l.size],r=y(null),c=y(null),[g,i]=N(e.isOpen?void 0:0),s=y(!0);return h(()=>{let o=c.current;o&&(e.isOpen?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.isOpen]),h(()=>{if(s.current){s.current=!1,i(e.isOpen?void 0:0);return}if(e.isOpen){let o=r.current;if(o){i(o.scrollHeight);let b=setTimeout(()=>i(void 0),200);return()=>clearTimeout(b)}}else{let o=r.current;o&&(i(o.scrollHeight),requestAnimationFrame(()=>i(0)))}},[e.isOpen]),d("div",{ref:c,id:e.contentId,role:"region","aria-labelledby":e.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},"data-testid":"accordion-content","data-state":e.isOpen?"open":"closed",children:d("div",{ref:r,className:x(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",t),children:a})})}export{F as Accordion,Q as AccordionContent,G as AccordionItem,J as AccordionTrigger};
1
+ "use client";import{createContext as N,useContext as k,useState as w,useCallback as M,useMemo as A,useRef as y,useEffect as C,useId as S}from"react";import{cn as x}from"../../lib/cn.js";import{jsx as a,jsxs as $}from"react/jsx-runtime";var R=N(null),O=N(null);function v(){let t=k(R);if(!t)throw new Error("Accordion sub-components must be used within <Accordion>");return t}function P(){let t=k(O);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return t}var T={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:t})=>a("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:a("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function F({type:t="single",value:c,defaultValue:l,onValueChange:e,collapsible:n=!1,variant:r="default",size:s="md",disabled:g=!1,iconPosition:i="right",icon:d,hideIcon:o=!1,className:m,children:z}){let[h,E]=w(()=>l?Array.isArray(l)?l:[l]:[]),b=c!==void 0,u=A(()=>b?Array.isArray(c)?c:[c]:h,[b,c,h]),I=M(p=>{let f;t==="single"?u.includes(p)?f=n?[]:[p]:f=[p]:f=u.includes(p)?u.filter(H=>H!==p):[...u,p],b||E(f),e?.(t==="single"?f[0]??"":f)},[t,u,n,b,e]),D=A(()=>({openItems:u,toggle:I,variant:r,size:s,disabled:g,iconPosition:i,icon:d??null,hideIcon:o}),[u,I,r,s,g,i,d,o]);return a(R.Provider,{value:D,children:a("div",{className:x(K[r],m),"data-testid":"accordion",children:z})})}function G({value:t,disabled:c,className:l,children:e}){let n=v(),r=n.openItems.includes(t),s=c??n.disabled,g=S(),i=`accordion-trigger-${g}`,d=`accordion-content-${g}`,o=A(()=>({value:t,isOpen:r,disabled:s,triggerId:i,contentId:d}),[t,r,s,i,d]);return a(O.Provider,{value:o,children:a("div",{className:x(L[n.variant],l),"data-state":r?"open":"closed","data-testid":"accordion-item",children:e})})}function J({className:t,icon:c,children:l}){let e=v(),n=P(),r=T[e.size],s=()=>{n.disabled||e.toggle(n.value)},g=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),s())},i=c??e.icon??a(V,{className:r.icon}),d=!e.hideIcon&&a("span",{className:x("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return $("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:s,onKeyDown:g,className:x("flex items-center w-full text-left font-medium transition-colors cursor-pointer",r.trigger,r.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",t),"data-testid":"accordion-trigger",children:[e.iconPosition==="left"&&d,a("span",{className:"flex-1",children:l}),e.iconPosition==="right"&&d]})}function Q({className:t,children:c}){let l=v(),e=P(),n=T[l.size],r=y(null),s=y(null),[g,i]=w(e.isOpen?void 0:0),d=y(!0);return C(()=>{let o=s.current;o&&(e.isOpen?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.isOpen]),C(()=>{if(d.current){d.current=!1,i(e.isOpen?void 0:0);return}if(e.isOpen){let o=r.current;if(o){i(o.scrollHeight);let m=setTimeout(()=>i(void 0),200);return()=>clearTimeout(m)}}else{let o=r.current;o&&(i(o.scrollHeight),requestAnimationFrame(()=>i(0)))}},[e.isOpen]),a("div",{ref:s,id:e.contentId,role:"region","aria-labelledby":e.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},"data-testid":"accordion-content","data-state":e.isOpen?"open":"closed",children:a("div",{ref:r,className:x(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",t),children:c})})}export{F as Accordion,Q as AccordionContent,G as AccordionItem,J as AccordionTrigger};
@@ -1 +1 @@
1
- "use strict";"use client";var Ne=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var et=(c,u)=>{for(var n in u)Ne(c,n,{get:u[n],enumerable:!0})},tt=(c,u,n,d)=>{if(u&&typeof u=="object"||typeof u=="function")for(let p of Je(u))!Qe.call(c,p)&&p!==n&&Ne(c,p,{get:()=>u[p],enumerable:!(d=qe(u,p))||d.enumerable});return c};var nt=c=>tt(Ne({},"__esModule",{value:!0}),c);var ct={};et(ct,{AreaChart:()=>ut});module.exports=nt(ct);var l=require("react"),_e=require("../../lib/cn.cjs"),Ce=require("../../lib/i18n.cjs"),ae=require("../chart/ChartAnnotations.cjs"),De=require("../chart/ChartAxis.cjs"),q=require("../chart/ChartBrush.cjs"),Oe=require("../chart/ChartContainer.cjs"),Ge=require("../chart/ChartGrid.cjs"),Xe=require("../chart/ChartLegend.cjs"),ve=require("../chart/ChartPatterns.cjs"),$e=require("../chart/ChartSync.cjs"),Ue=require("../chart/ChartTableView.cjs"),ke=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),g=require("../chart/utils/cartesian.cjs"),xe=require("../chart/utils/data.cjs"),se=require("../chart/utils/decimate.cjs"),W=require("../chart/utils/format.cjs"),Se=require("../chart/utils/keyboard.cjs"),I=require("../chart/utils/path.cjs"),Z=require("../chart/utils/scales.cjs"),Pe=require("../chart/utils/stack.cjs"),ze=require("../chart/utils/ticks.cjs"),Ye=require("../chart/utils/timestamp.cjs"),Fe=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),ot=6,rt=.12,at=.9,st=10,lt=(0,l.memo)(function({bands:u,stacked:n,patterns:d,patternBaseId:p}){return(0,r.jsx)("g",{children:u.map(m=>(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:m.area,fill:(0,ve.patternFill)(d,p,m.slot,m.color),fillOpacity:n?at:rt,stroke:"none"}),m.gap?(0,r.jsx)("path",{d:m.gap,fill:"none",strokeWidth:2,stroke:A.CHART_SURFACE_COLOR}):null,(0,r.jsx)("path",{d:m.edge,fill:"none",stroke:m.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),m.isolated.map((P,$)=>(0,r.jsx)("circle",{cx:P.x,cy:P.y,r:3,fill:m.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},$))]},m.key))})});function it({width:c,height:u,data:n,resolvedSeries:d,x:p,y:m,grid:P,size:$,curve:L,stack:M,baseline:N,connectNulls:D,referenceLines:K,annotations:w,annotationsLabel:Ae,patterns:le,patternBaseId:ie,overlay:Le,maxPoints:B,brush:ue,onBrush:ce,brushLabel:Re,syncEnabled:J,margin:he,tooltip:_,onPointClick:V,plotLabel:we,formatValue:O,formatRaw:U,formatX:z,locale:me}){let[Q,ee]=(0,l.useState)(null),h=Q!==null&&Q<n.length?Q:null,[Be,Ve]=(0,l.useState)(null),Ee=(0,$e.useChartSync)(),b=J?Ee:null,e=(0,l.useMemo)(()=>{let t=d.filter(x=>!x.hidden),o=t.map(x=>x.key),s=M!=="none",i=(0,Pe.stackSeries)(n,o,M),G=(0,g.widenBounds)(s?(0,Pe.stackExtent)(i):(0,ze.extent)([...(0,xe.collectAllValues)(n,o),N]),(0,g.annotationValues)(n,p.key,K,w)),f=(0,g.buildCartesianGeometry)({locale:me,width:c,height:u,data:n,x:p,y:m,bounds:G,margin:he,placement:"point",formatValue:O,formatX:z,defaultIncludeZero:!0}),F=f.categoryCenters,y=f.valueScale,k=y(s?0:N),re=t.map((x,X)=>({top:n.map((j,H)=>{let S=i[H].segments[X];return{x:F[H],y:S.value===null?Number.NaN:y(S.end),defined:S.value!==null}}),bottom:n.map((j,H)=>{let S=i[H].segments[X];return{x:F[H],y:S.value===null?Number.NaN:y(s?S.start:N),defined:S.value!==null}})})),We=B!==void 0&&B>0&&n.length>B,je=We&&s?[...new Set(re.flatMap(({top:x})=>(0,se.decimateIndices)(x,B)))].sort((x,X)=>x-X):null,Ze=t.map((x,X)=>{let{top:j,bottom:H}=re[X],S={connectNulls:D},be=je??(We?(0,se.decimateIndices)(j,B):null),ye=be?be.map(Me=>j[Me]):j,Ke=be?be.map(Me=>H[Me]):H;return B||(0,se.warnPointBudget)("AreaChart",j.length),{key:x.key,color:x.color,slot:x.slot,area:s?(0,I.buildAreaPath)(ye,Ke,L,S):(0,I.buildAreaPath)(ye,k,L,S),edge:(0,I.buildLinePath)(ye,L,S),gap:s&&X>0?(0,I.buildLinePath)(Ke,L,S):"",isolated:(0,I.isolatedPoints)(ye,D)}});return{visible:t,locate:(0,g.createCategoryLocator)(f),span:(0,g.createSpanLocator)(f),plot:(0,g.createPlotContext)({geometry:f,width:c,height:u,data:n,series:t,formatValue:O,formatX:z}),rows:i,stacked:s,xValues:f.xValues,positions:F,xTicks:f.categoryTicks,yTicks:f.valueTicks,valueScale:y,innerWidth:f.innerWidth,innerHeight:f.innerHeight,margin:f.margin,bands:Ze}},[me,n,d,p,m,c,u,he,L,M,N,D,B,K,w,O,z]),te=(0,l.useCallback)(t=>e.visible.map((o,s)=>{let i=(0,xe.readNumber)(n[t],o.key),G=e.rows[t].segments[s],f=i===null?"\u2014":M==="percent"?`${U(i)} (${O(G.end-G.start)})`:U(i);return{seriesKey:o.key,seriesLabel:(0,A.getSeriesLabel)(o),color:o.color,value:i,formattedValue:f,datum:n[t]}}),[n,e.visible,e.rows,M,O,U]),v=b?b.brush:Be,de=(0,l.useCallback)(t=>{Ve(t),b?.setBrush(t),ce?.(t)},[b,ce]),C=(0,q.useChartBrush)({enabled:ue,active:v!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:de}),Te=(0,l.useCallback)(t=>{if(C.onPointerMove(t),_===!1||n.length===0)return;let o=t.currentTarget.getBoundingClientRect(),s=t.clientX-o.left-e.margin.left,i=(0,Z.nearestIndex)(e.positions,s);ee(i>=0?i:null),b?.setHovered(i>=0?e.xValues[i]:null)},[C,_,n.length,e.margin.left,e.positions,e.xValues,b]),pe=(0,l.useCallback)(()=>{ee(null),b?.setHovered(null)},[b]),R=(0,l.useCallback)((t,o)=>{if(!V)return;let s=te(t),i=e.rows[t]?.segments??[],G=s.map((y,k)=>({point:y,segment:i[k]})).filter(({point:y,segment:k})=>y.value!==null&&k!==void 0),f=({segment:y})=>{if(o===null)return 0;let k=e.valueScale(y.end),re=e.valueScale(e.stacked?y.start:y.end);return e.stacked&&o.y>=Math.min(k,re)&&o.y<=Math.max(k,re)?-1:Math.abs(k-o.y)},F=G.length>0?G.reduce((y,k)=>f(k)<f(y)?k:y).point:s[0];F&&V({...F,index:t,x:e.xValues[t]})},[V,te,e.rows,e.stacked,e.valueScale,e.xValues]),T=(0,l.useCallback)(t=>{if(n.length===0)return;let o=V&&h!==null&&e.visible.length>0;if((0,Se.pressChartMark)(t,o?()=>R(h,null):null))return;let s=C.onKeyDown(t,h),i=(0,Se.chartCursorTarget)(t.key,h,n.length,"x");if(i===void 0){s&&t.preventDefault();return}t.preventDefault(),ee(i),b?.setHovered(i===null?null:e.xValues[i])},[n.length,h,C,b,e.xValues,e.visible.length,V,R]),He=(0,l.useCallback)(t=>{if(C.consumedClick()||!V||n.length===0)return;let o=(0,g.plotPointer)(t,e),s=h??(o===null?-1:(0,Z.nearestIndex)(e.positions,o.x));s<0||R(s,o)},[C,V,n.length,e,h,R]),Ie=h!==null||b===null||b.hovered===null?null:(()=>{let t=(0,Z.toKey)(b.hovered),o=e.xValues.findIndex(s=>(0,Z.toKey)(s)===t);return o<0?null:o})(),E=h??Ie,ne=h===null?null:te(h),oe=E===null?[]:e.visible.map((t,o)=>{let s=e.rows[E].segments[o];return s.value===null?null:{key:t.key,color:t.color,y:e.valueScale(s.end)}}).filter(t=>t!==null),fe=C.dragging??v,Y=fe?(0,q.locateBrush)(fe,e.xValues,e.positions,e.locate):null,ge=(0,g.splitOverlay)(Le),a=h===null||ne===null?null:{x:e.xValues[h],xLabel:z(e.xValues[h],h),index:h,points:ne};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:c,height:u,role:"img","aria-label":we??[e.visible.map(t=>(0,A.getSeriesLabel)(t)).join(", "),(0,ae.describeAnnotations)(w,Ae)].filter(Boolean).join(". "),tabIndex:0,className:(0,_e.cn)(Fe.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",ue&&"select-none"),onPointerDown:C.onPointerDown,onPointerMove:Te,onPointerUp:C.onPointerUp,onPointerCancel:C.onPointerUp,onPointerLeave:pe,onKeyDown:T,onBlur:pe,onClick:He,children:[le?(0,r.jsx)(ve.ChartPatternDefs,{id:ie,entries:d.map(t=>({slot:t.slot,color:t.color}))}):null,(0,r.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,r.jsx)(Ge.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:P==="y"||P==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:P==="x"||P==="both"?e.xTicks.map(t=>t.offset):void 0}),w?(0,r.jsx)(ae.ChartAnnotationLayer,{layer:"under",annotations:w,xAt:e.locate,spanAt:e.span,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,Y?(0,r.jsx)(q.ChartBrushLayer,{from:Y.from,to:Y.to,width:e.innerWidth,height:e.innerHeight,live:C.dragging!==null,label:Re,minSpan:ot}):null,ge.under?.(e.plot),(0,r.jsx)(lt,{bands:e.bands,stacked:e.stacked,patterns:le&&e.stacked,patternBaseId:ie}),w?(0,r.jsx)(ae.ChartAnnotationLayer,{annotations:w,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,K?.map(t=>{let o=e.valueScale(t.value),s=o<st?o+12:o-4;return(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:0,y1:o,x2:e.innerWidth,y2:o,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,r.jsx)("text",{x:e.innerWidth,y:s,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),ge.over?.(e.plot),E!==null?(0,r.jsxs)("g",{"aria-hidden":"true",children:[(0,r.jsx)("line",{x1:e.positions[E],y1:0,x2:e.positions[E],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:h===null?"3 3":void 0}),oe.map(t=>(0,r.jsx)("circle",{cx:e.positions[E],cy:t.y,r:4,fill:t.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},t.key))]}):null]}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:$})}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:m?.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:m?.label,size:$})})]}),a&&_!==!1?(0,r.jsx)(ke.ChartTooltip,{x:e.margin.left+e.positions[a.index],y:e.margin.top+(oe.length>0?Math.min(...oe.map(t=>t.y)):e.innerHeight/2),containerWidth:c,children:typeof _=="function"?_(a):(0,r.jsx)(ke.ChartTooltipContent,{title:a.xLabel,points:a.points})}):null]})}function ut({data:c,series:u,x:n,y:d,height:p=240,width:m,size:P="md",grid:$="y",legend:L,tooltip:M=!0,tableView:N=!1,emphasis:D,title:K,description:w,loading:Ae=!1,emptyState:le,error:ie=!1,errorState:Le,onRetry:B,actions:ue,onPointClick:ce,curve:Re="monotone",stack:J="none",baseline:he=0,connectNulls:_=!1,referenceLines:V,annotations:we,overlay:O,patterns:U=!1,legendToggle:z=!0,maxPoints:me,brush:Q=!1,onBrush:ee,brushLabel:h,sync:Be=!0,margin:Ve,locale:Ee,plotLabel:b,className:e,...te}){let v=(0,Ce.useUILocale)(Ee),de=(0,Ce.useUILabels)(),[C,Te]=(0,l.useState)(()=>new Set),pe=(0,l.useId)(),R=(0,l.useMemo)(()=>u.map((a,t)=>({...a,slot:t,hidden:a.hidden||C.has(a.key),color:(0,A.resolveSeriesColor)(a,t,D)})),[u,C,D]),T=J==="percent",He=(0,l.useMemo)(()=>T?{domain:[0,100],...d}:d,[T,d]),Ie=(0,l.useMemo)(()=>d?.format??(T?a=>(0,W.formatPercent)(a,{locale:v,alreadyScaled:!0,maximumFractionDigits:0}):a=>(0,W.formatAuto)(a,v)),[d?.format,T,v]),E=(0,l.useMemo)(()=>!T&&d?.format||(a=>(0,W.formatExact)(a,v)),[T,d?.format,v]),ne=(0,l.useMemo)(()=>n.format??(a=>n.scale==="time"?(0,Ye.formatTimeValue)(a,v):(0,W.formatXValue)(a,v)),[n.format,n.scale,v]),oe=(0,l.useCallback)(a=>{Te(t=>{let o=new Set(t);return o.has(a)?o.delete(a):o.add(a),o})},[]),fe=L===void 0?u.length>=2:L!==!1,Y=typeof L=="string"?L:"bottom",ge=R.filter(a=>!a.hidden).length;return(0,r.jsx)(Oe.ChartContainer,{title:K,description:w,height:p,width:m,size:P,loading:Ae,empty:c.length===0||ge===0,emptyState:le,error:ie,errorState:Le,onRetry:B,actions:ue,exportSource:{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:N,legendPosition:Y,legend:fe?(0,r.jsx)(Xe.ChartLegend,{items:(0,A.toLegendItems)(R,D,U&&J!=="none"),position:Y,marker:"rect",size:P,onToggle:z?oe:void 0}):void 0,table:N?(0,r.jsx)(Ue.ChartTableView,{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:ne,formatValue:E,caption:typeof K=="string"?K:void 0}):void 0,className:e,...te,children:({width:a})=>(0,r.jsx)(it,{locale:v,width:a,height:p,data:c,resolvedSeries:R,x:n,y:He,grid:$,size:P,curve:Re,stack:J,baseline:he,connectNulls:_,referenceLines:V,annotations:we,annotationsLabel:de.chartAnnotations,patterns:U,patternBaseId:pe,overlay:O,maxPoints:me,brush:Q,onBrush:ee,brushLabel:h??de.chartBrush,syncEnabled:Be,margin:Ve,tooltip:M,onPointClick:ce,plotLabel:b,formatValue:Ie,formatRaw:E,formatX:ne})})}0&&(module.exports={AreaChart});
1
+ "use strict";"use client";var Ne=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var et=(c,u)=>{for(var n in u)Ne(c,n,{get:u[n],enumerable:!0})},tt=(c,u,n,d)=>{if(u&&typeof u=="object"||typeof u=="function")for(let p of Je(u))!Qe.call(c,p)&&p!==n&&Ne(c,p,{get:()=>u[p],enumerable:!(d=qe(u,p))||d.enumerable});return c};var nt=c=>tt(Ne({},"__esModule",{value:!0}),c);var ct={};et(ct,{AreaChart:()=>ut});module.exports=nt(ct);var l=require("react"),_e=require("../../lib/cn.cjs"),Ce=require("../../lib/i18n.cjs"),ae=require("../chart/ChartAnnotations.cjs"),De=require("../chart/ChartAxis.cjs"),q=require("../chart/ChartBrush.cjs"),Oe=require("../chart/ChartContainer.cjs"),Ge=require("../chart/ChartGrid.cjs"),Xe=require("../chart/ChartLegend.cjs"),ve=require("../chart/ChartPatterns.cjs"),$e=require("../chart/ChartSync.cjs"),Ue=require("../chart/ChartTableView.cjs"),ke=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),g=require("../chart/utils/cartesian.cjs"),xe=require("../chart/utils/data.cjs"),se=require("../chart/utils/decimate.cjs"),W=require("../chart/utils/format.cjs"),Pe=require("../chart/utils/keyboard.cjs"),I=require("../chart/utils/path.cjs"),Z=require("../chart/utils/scales.cjs"),Se=require("../chart/utils/stack.cjs"),ze=require("../chart/utils/ticks.cjs"),Ye=require("../chart/utils/timestamp.cjs"),Fe=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),ot=6,rt=.12,at=.9,st=10,lt=(0,l.memo)(function({bands:u,stacked:n,patterns:d,patternBaseId:p}){return(0,r.jsx)("g",{children:u.map(m=>(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:m.area,fill:(0,ve.patternFill)(d,p,m.slot,m.color),fillOpacity:n?at:rt,stroke:"none"}),m.gap?(0,r.jsx)("path",{d:m.gap,fill:"none",strokeWidth:2,stroke:A.CHART_SURFACE_COLOR}):null,(0,r.jsx)("path",{d:m.edge,fill:"none",stroke:m.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),m.isolated.map((S,$)=>(0,r.jsx)("circle",{cx:S.x,cy:S.y,r:3,fill:m.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},$))]},m.key))})});function it({width:c,height:u,data:n,resolvedSeries:d,x:p,y:m,grid:S,size:$,curve:L,stack:M,baseline:N,connectNulls:D,referenceLines:K,annotations:B,annotationsLabel:Ae,patterns:le,patternBaseId:ie,overlay:Le,maxPoints:w,brush:ue,onBrush:ce,brushLabel:Re,syncEnabled:J,margin:he,tooltip:_,onPointClick:V,plotLabel:Be,formatValue:O,formatRaw:U,formatX:z,locale:me}){let[Q,ee]=(0,l.useState)(null),h=Q!==null&&Q<n.length?Q:null,[we,Ve]=(0,l.useState)(null),Ee=(0,$e.useChartSync)(),b=J?Ee:null,e=(0,l.useMemo)(()=>{let t=d.filter(x=>!x.hidden),o=t.map(x=>x.key),s=M!=="none",i=(0,Se.stackSeries)(n,o,M),G=(0,g.widenBounds)(s?(0,Se.stackExtent)(i):(0,ze.extent)([...(0,xe.collectAllValues)(n,o),N]),(0,g.annotationValues)(n,p.key,K,B)),f=(0,g.buildCartesianGeometry)({locale:me,width:c,height:u,data:n,x:p,y:m,bounds:G,margin:he,placement:"point",formatValue:O,formatX:z,defaultIncludeZero:!0}),F=f.categoryCenters,y=f.valueScale,k=y(s?0:N),re=t.map((x,X)=>({top:n.map((j,H)=>{let P=i[H].segments[X];return{x:F[H],y:P.value===null?Number.NaN:y(P.end),defined:P.value!==null}}),bottom:n.map((j,H)=>{let P=i[H].segments[X];return{x:F[H],y:P.value===null?Number.NaN:y(s?P.start:N),defined:P.value!==null}})})),We=w!==void 0&&w>0&&n.length>w,je=We&&s?[...new Set(re.flatMap(({top:x})=>(0,se.decimateIndices)(x,w)))].sort((x,X)=>x-X):null,Ze=t.map((x,X)=>{let{top:j,bottom:H}=re[X],P={connectNulls:D},be=je??(We?(0,se.decimateIndices)(j,w):null),ye=be?be.map(Me=>j[Me]):j,Ke=be?be.map(Me=>H[Me]):H;return w||(0,se.warnPointBudget)("AreaChart",j.length),{key:x.key,color:x.color,slot:x.slot,area:s?(0,I.buildAreaPath)(ye,Ke,L,P):(0,I.buildAreaPath)(ye,k,L,P),edge:(0,I.buildLinePath)(ye,L,P),gap:s&&X>0?(0,I.buildLinePath)(Ke,L,P):"",isolated:(0,I.isolatedPoints)(ye,D)}});return{visible:t,locate:(0,g.createCategoryLocator)(f),span:(0,g.createSpanLocator)(f),plot:(0,g.createPlotContext)({geometry:f,width:c,height:u,data:n,series:t,formatValue:O,formatX:z}),rows:i,stacked:s,xValues:f.xValues,positions:F,xTicks:f.categoryTicks,yTicks:f.valueTicks,valueScale:y,innerWidth:f.innerWidth,innerHeight:f.innerHeight,margin:f.margin,bands:Ze}},[me,n,d,p,m,c,u,he,L,M,N,D,w,K,B,O,z]),te=(0,l.useCallback)(t=>e.visible.map((o,s)=>{let i=(0,xe.readNumber)(n[t],o.key),G=e.rows[t].segments[s],f=i===null?"\u2014":M==="percent"?`${U(i)} (${O(G.end-G.start)})`:U(i);return{seriesKey:o.key,seriesLabel:(0,A.getSeriesLabel)(o),color:o.color,value:i,formattedValue:f,datum:n[t]}}),[n,e.visible,e.rows,M,O,U]),v=b?b.brush:we,de=(0,l.useCallback)(t=>{Ve(t),b?.setBrush(t),ce?.(t)},[b,ce]),C=(0,q.useChartBrush)({enabled:ue,active:v!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:de}),Te=(0,l.useCallback)(t=>{if(C.onPointerMove(t),_===!1||n.length===0)return;let o=t.currentTarget.getBoundingClientRect(),s=t.clientX-o.left-e.margin.left,i=(0,Z.nearestIndex)(e.positions,s);ee(i>=0?i:null),b?.setHovered(i>=0?e.xValues[i]:null)},[C,_,n.length,e.margin.left,e.positions,e.xValues,b]),pe=(0,l.useCallback)(()=>{ee(null),b?.setHovered(null)},[b]),R=(0,l.useCallback)((t,o)=>{if(!V)return;let s=te(t),i=e.rows[t]?.segments??[],G=s.map((y,k)=>({point:y,segment:i[k]})).filter(({point:y,segment:k})=>y.value!==null&&k!==void 0),f=({segment:y})=>{if(o===null)return 0;let k=e.valueScale(y.end),re=e.valueScale(e.stacked?y.start:y.end);return e.stacked&&o.y>=Math.min(k,re)&&o.y<=Math.max(k,re)?-1:Math.abs(k-o.y)},F=G.length>0?G.reduce((y,k)=>f(k)<f(y)?k:y).point:s[0];F&&V({...F,index:t,x:e.xValues[t]})},[V,te,e]),T=(0,l.useCallback)(t=>{if(n.length===0)return;let o=V&&h!==null&&e.visible.length>0;if((0,Pe.pressChartMark)(t,o?()=>R(h,null):null))return;let s=C.onKeyDown(t,h),i=(0,Pe.chartCursorTarget)(t.key,h,n.length,"x");if(i===void 0){s&&t.preventDefault();return}t.preventDefault(),ee(i),b?.setHovered(i===null?null:e.xValues[i])},[n.length,h,C,b,e.xValues,e.visible.length,V,R]),He=(0,l.useCallback)(t=>{if(C.consumedClick()||!V||n.length===0)return;let o=(0,g.plotPointer)(t,e),s=h??(o===null?-1:(0,Z.nearestIndex)(e.positions,o.x));s<0||R(s,o)},[C,V,n.length,e,h,R]),Ie=h!==null||b===null||b.hovered===null?null:(()=>{let t=(0,Z.toKey)(b.hovered),o=e.xValues.findIndex(s=>(0,Z.toKey)(s)===t);return o<0?null:o})(),E=h??Ie,ne=h===null?null:te(h),oe=E===null?[]:e.visible.map((t,o)=>{let s=e.rows[E].segments[o];return s.value===null?null:{key:t.key,color:t.color,y:e.valueScale(s.end)}}).filter(t=>t!==null),fe=C.dragging??v,Y=fe?(0,q.locateBrush)(fe,e.xValues,e.positions,e.locate):null,ge=(0,g.splitOverlay)(Le),a=h===null||ne===null?null:{x:e.xValues[h],xLabel:z(e.xValues[h],h),index:h,points:ne};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:c,height:u,role:"img","aria-label":Be??[e.visible.map(t=>(0,A.getSeriesLabel)(t)).join(", "),(0,ae.describeAnnotations)(B,Ae)].filter(Boolean).join(". "),tabIndex:0,className:(0,_e.cn)(Fe.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",ue&&"select-none"),onPointerDown:C.onPointerDown,onPointerMove:Te,onPointerUp:C.onPointerUp,onPointerCancel:C.onPointerUp,onPointerLeave:pe,onKeyDown:T,onBlur:pe,onClick:He,children:[le?(0,r.jsx)(ve.ChartPatternDefs,{id:ie,entries:d.map(t=>({slot:t.slot,color:t.color}))}):null,(0,r.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,r.jsx)(Ge.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:S==="y"||S==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:S==="x"||S==="both"?e.xTicks.map(t=>t.offset):void 0}),B?(0,r.jsx)(ae.ChartAnnotationLayer,{layer:"under",annotations:B,xAt:e.locate,spanAt:e.span,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,Y?(0,r.jsx)(q.ChartBrushLayer,{from:Y.from,to:Y.to,width:e.innerWidth,height:e.innerHeight,live:C.dragging!==null,label:Re,minSpan:ot}):null,ge.under?.(e.plot),(0,r.jsx)(lt,{bands:e.bands,stacked:e.stacked,patterns:le&&e.stacked,patternBaseId:ie}),B?(0,r.jsx)(ae.ChartAnnotationLayer,{annotations:B,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,K?.map(t=>{let o=e.valueScale(t.value),s=o<st?o+12:o-4;return(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:0,y1:o,x2:e.innerWidth,y2:o,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,r.jsx)("text",{x:e.innerWidth,y:s,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),ge.over?.(e.plot),E!==null?(0,r.jsxs)("g",{"aria-hidden":"true",children:[(0,r.jsx)("line",{x1:e.positions[E],y1:0,x2:e.positions[E],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:h===null?"3 3":void 0}),oe.map(t=>(0,r.jsx)("circle",{cx:e.positions[E],cy:t.y,r:4,fill:t.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},t.key))]}):null]}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:$})}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:m?.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:m?.label,size:$})})]}),a&&_!==!1?(0,r.jsx)(ke.ChartTooltip,{x:e.margin.left+e.positions[a.index],y:e.margin.top+(oe.length>0?Math.min(...oe.map(t=>t.y)):e.innerHeight/2),containerWidth:c,children:typeof _=="function"?_(a):(0,r.jsx)(ke.ChartTooltipContent,{title:a.xLabel,points:a.points})}):null]})}function ut({data:c,series:u,x:n,y:d,height:p=240,width:m,size:S="md",grid:$="y",legend:L,tooltip:M=!0,tableView:N=!1,emphasis:D,title:K,description:B,loading:Ae=!1,emptyState:le,error:ie=!1,errorState:Le,onRetry:w,actions:ue,onPointClick:ce,curve:Re="monotone",stack:J="none",baseline:he=0,connectNulls:_=!1,referenceLines:V,annotations:Be,overlay:O,patterns:U=!1,legendToggle:z=!0,maxPoints:me,brush:Q=!1,onBrush:ee,brushLabel:h,sync:we=!0,margin:Ve,locale:Ee,plotLabel:b,className:e,...te}){let v=(0,Ce.useUILocale)(Ee),de=(0,Ce.useUILabels)(),[C,Te]=(0,l.useState)(()=>new Set),pe=(0,l.useId)(),R=(0,l.useMemo)(()=>u.map((a,t)=>({...a,slot:t,hidden:a.hidden||C.has(a.key),color:(0,A.resolveSeriesColor)(a,t,D)})),[u,C,D]),T=J==="percent",He=(0,l.useMemo)(()=>T?{domain:[0,100],...d}:d,[T,d]),Ie=(0,l.useMemo)(()=>d?.format??(T?a=>(0,W.formatPercent)(a,{locale:v,alreadyScaled:!0,maximumFractionDigits:0}):a=>(0,W.formatAuto)(a,v)),[d?.format,T,v]),E=(0,l.useMemo)(()=>!T&&d?.format||(a=>(0,W.formatExact)(a,v)),[T,d?.format,v]),ne=(0,l.useMemo)(()=>n.format??(a=>n.scale==="time"?(0,Ye.formatTimeValue)(a,v):(0,W.formatXValue)(a,v)),[n.format,n.scale,v]),oe=(0,l.useCallback)(a=>{Te(t=>{let o=new Set(t);return o.has(a)?o.delete(a):o.add(a),o})},[]),fe=L===void 0?u.length>=2:L!==!1,Y=typeof L=="string"?L:"bottom",ge=R.filter(a=>!a.hidden).length;return(0,r.jsx)(Oe.ChartContainer,{title:K,description:B,height:p,width:m,size:S,loading:Ae,empty:c.length===0||ge===0,emptyState:le,error:ie,errorState:Le,onRetry:w,actions:ue,exportSource:{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:N,legendPosition:Y,legend:fe?(0,r.jsx)(Xe.ChartLegend,{items:(0,A.toLegendItems)(R,D,U&&J!=="none"),position:Y,marker:"rect",size:S,onToggle:z?oe:void 0}):void 0,table:N?(0,r.jsx)(Ue.ChartTableView,{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:ne,formatValue:E,caption:typeof K=="string"?K:void 0}):void 0,className:e,...te,children:({width:a})=>(0,r.jsx)(it,{locale:v,width:a,height:p,data:c,resolvedSeries:R,x:n,y:He,grid:$,size:S,curve:Re,stack:J,baseline:he,connectNulls:_,referenceLines:V,annotations:Be,annotationsLabel:de.chartAnnotations,patterns:U,patternBaseId:pe,overlay:O,maxPoints:me,brush:Q,onBrush:ee,brushLabel:h??de.chartBrush,syncEnabled:we,margin:Ve,tooltip:M,onPointClick:ce,plotLabel:b,formatValue:Ie,formatRaw:E,formatX:ne})})}0&&(module.exports={AreaChart});