@synertech/ui 0.45.1 → 0.46.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 (138) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +115 -17
  2. package/README.md +47 -5
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/avatar/Avatar.cjs +1 -1
  6. package/dist/components/avatar/Avatar.js +1 -1
  7. package/dist/components/banner/Banner.cjs +1 -1
  8. package/dist/components/banner/Banner.js +1 -1
  9. package/dist/components/bar-chart/BarChart.cjs +1 -1
  10. package/dist/components/bar-chart/BarChart.js +1 -1
  11. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  12. package/dist/components/box-plot/BoxPlot.js +1 -1
  13. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  14. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  15. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  16. package/dist/components/bullet-chart/BulletChart.js +1 -1
  17. package/dist/components/calendar/Calendar.cjs +1 -1
  18. package/dist/components/calendar/Calendar.js +1 -1
  19. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  20. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  21. package/dist/components/chart/ChartBrush.cjs +1 -1
  22. package/dist/components/chart/ChartBrush.js +1 -1
  23. package/dist/components/chart/ChartExportButton.cjs +1 -1
  24. package/dist/components/chart/ChartExportButton.js +1 -1
  25. package/dist/components/chart/utils/export.cjs +1 -2
  26. package/dist/components/chart/utils/export.js +1 -2
  27. package/dist/components/chart/utils/keyboard.cjs +1 -0
  28. package/dist/components/chart/utils/keyboard.js +1 -0
  29. package/dist/components/chip/Chip.cjs +1 -1
  30. package/dist/components/chip/Chip.js +1 -1
  31. package/dist/components/datagrid/DataGrid.cjs +1 -2
  32. package/dist/components/datagrid/DataGrid.js +1 -2
  33. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  34. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  35. package/dist/components/dropdown/Dropdown.cjs +1 -1
  36. package/dist/components/dropdown/Dropdown.js +1 -1
  37. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  38. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  39. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  40. package/dist/components/dropdown/DropdownContent.js +1 -1
  41. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  42. package/dist/components/dropdown/DropdownItem.js +1 -1
  43. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  44. package/dist/components/dropdown/DropdownRadio.js +1 -1
  45. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  46. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  47. package/dist/components/dropdown/hooks/index.cjs +1 -1
  48. package/dist/components/dropdown/hooks/index.js +1 -1
  49. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  50. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  51. package/dist/components/dropdown/index.cjs +1 -1
  52. package/dist/components/dropdown/index.js +1 -1
  53. package/dist/components/dropdown/menu-navigation.cjs +1 -0
  54. package/dist/components/dropdown/menu-navigation.js +1 -0
  55. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  56. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  57. package/dist/components/file-selector/FileSelector.cjs +1 -1
  58. package/dist/components/file-selector/FileSelector.js +1 -1
  59. package/dist/components/form/input/Input.cjs +1 -1
  60. package/dist/components/form/input/Input.js +1 -1
  61. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  62. package/dist/components/form/mention-input/MentionInput.js +1 -1
  63. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  64. package/dist/components/form/number-input/NumberInput.js +1 -1
  65. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  66. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  67. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  68. package/dist/components/gantt-chart/GanttChart.js +1 -1
  69. package/dist/components/header/Header.cjs +1 -1
  70. package/dist/components/header/Header.js +1 -1
  71. package/dist/components/heat-map/Heatmap.cjs +1 -1
  72. package/dist/components/heat-map/Heatmap.js +1 -1
  73. package/dist/components/help-button/HelpButton.cjs +7 -7
  74. package/dist/components/help-button/HelpButton.js +7 -7
  75. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  76. package/dist/components/help-button/MarkdownEditor.js +1 -1
  77. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  78. package/dist/components/image-uploader/ImageUploader.js +1 -1
  79. package/dist/components/label/Label.cjs +1 -1
  80. package/dist/components/label/Label.js +1 -1
  81. package/dist/components/line-chart/LineChart.cjs +1 -1
  82. package/dist/components/line-chart/LineChart.js +1 -1
  83. package/dist/components/modal/Modal.cjs +1 -1
  84. package/dist/components/modal/Modal.js +1 -1
  85. package/dist/components/pagination/Pagination.cjs +1 -1
  86. package/dist/components/pagination/Pagination.js +1 -1
  87. package/dist/components/pie-chart/PieChart.cjs +1 -1
  88. package/dist/components/pie-chart/PieChart.js +1 -1
  89. package/dist/components/radio-button/RadioButton.cjs +1 -1
  90. package/dist/components/radio-button/RadioButton.js +1 -1
  91. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  92. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  93. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  94. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  95. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  96. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  97. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  98. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  99. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  100. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  101. package/dist/components/select/Select.cjs +1 -1
  102. package/dist/components/select/Select.js +1 -1
  103. package/dist/components/tabs/Tabs.cjs +1 -1
  104. package/dist/components/tabs/Tabs.js +1 -1
  105. package/dist/components/tabs/TabsContent.cjs +1 -1
  106. package/dist/components/tabs/TabsContent.js +1 -1
  107. package/dist/components/tabs/TabsContext.cjs +1 -1
  108. package/dist/components/tabs/TabsContext.js +1 -1
  109. package/dist/components/tabs/TabsList.cjs +1 -1
  110. package/dist/components/tabs/TabsList.js +1 -1
  111. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  112. package/dist/components/tabs/TabsTrigger.js +1 -1
  113. package/dist/components/toast/Toast.cjs +1 -1
  114. package/dist/components/toast/Toast.js +1 -1
  115. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  116. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  117. package/dist/components/wizard/Wizard.cjs +1 -1
  118. package/dist/components/wizard/Wizard.js +1 -1
  119. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  120. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  121. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  122. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  123. package/dist/index.cjs +1 -1
  124. package/dist/index.d.cts +814 -172
  125. package/dist/index.d.ts +814 -172
  126. package/dist/index.js +1 -1
  127. package/dist/lib/aria-hide.cjs +1 -1
  128. package/dist/lib/aria-hide.js +1 -1
  129. package/dist/lib/csv.cjs +2 -0
  130. package/dist/lib/csv.js +2 -0
  131. package/dist/lib/i18n.cjs +1 -1
  132. package/dist/lib/i18n.js +1 -1
  133. package/dist/lib/server-labels.cjs +1 -0
  134. package/dist/lib/server-labels.js +1 -0
  135. package/dist/lib/ui-labels.cjs +1 -0
  136. package/dist/lib/ui-labels.js +1 -0
  137. package/dist/styles.css +3049 -270
  138. package/package.json +2 -2
@@ -99,6 +99,29 @@ réglage, 90 Ko avec.
99
99
  **Anti-pattern** : dans une application Next.js sous webpack, importer `@synertech/ui`
100
100
  depuis un Server Component sans avoir ajouté ce réglage.
101
101
 
102
+ ### 5. Mode sombre : déclarer le thème sur `<html>`
103
+
104
+ Par défaut les composants suivent le système du lecteur. Une application qui a son propre
105
+ bouton clair/sombre déclare le thème sur `<html>`, **dans les deux états** :
106
+
107
+ ```html
108
+ <html class="dark"> <!-- ou data-theme="dark" -->
109
+ <html class="light"> <!-- ou data-theme="light" -->
110
+ ```
111
+
112
+ | Sur la page | Résultat |
113
+ |-------------|----------|
114
+ | classe `dark` ou `data-theme="dark"` sur un ancêtre | Sombre. Pas forcément `<html>` : une section sombre dans une page claire fonctionne |
115
+ | classe `light` ou `data-theme="light"` sur `<html>` | Clair, même si le système est en sombre |
116
+ | Rien | Le système décide (`prefers-color-scheme`) |
117
+
118
+ `next-themes` pose les deux (`attribute="class"` ou `attribute="data-theme"`). La palette
119
+ des graphiques suit les mêmes règles : un graphique et le panneau qui le contient sont
120
+ toujours d'accord.
121
+
122
+ **Anti-pattern** : un bouton qui ne fait qu'ajouter et retirer `dark`. L'état clair n'est
123
+ alors pas déclaré, et les composants redeviennent sombres dès que le système l'est.
124
+
102
125
  ---
103
126
 
104
127
  ## Imports
@@ -415,6 +438,11 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@synertech/ui";
415
438
  </Tabs>
416
439
  ```
417
440
 
441
+ **Notes :**
442
+ - Clavier : un seul onglet est dans l'ordre de tabulation ; les flèches, Début et Fin passent d'un onglet à l'autre (onglets `disabled` sautés) et sélectionnent celui qu'elles atteignent. Haut/Bas en `orientation="vertical"`, sens inversé en lecture droite-à-gauche
443
+ - Renseignez `defaultValue` (ou `value`) : sans lui aucun panneau n'est affiché au départ ; le premier onglet reste atteignable au clavier
444
+ - Chaque `TabsContent` est nommé par son onglet (`aria-labelledby`) : pas besoin d'`aria-label`
445
+
418
446
  ### Input (Form)
419
447
 
420
448
  ```tsx
@@ -504,8 +532,17 @@ import { RadioButton } from "@synertech/ui";
504
532
  variant="default" // "default" | "filled" | "outlined"
505
533
  />
506
534
  ))}
535
+
536
+ // Non contrôlé : aucun état. Le navigateur tient le groupe (même `name`),
537
+ // la valeur cochée part avec le formulaire, un reset revient au choix initial.
538
+ <RadioButton name="plan" value="monthly" label="Mensuel" defaultChecked />
539
+ <RadioButton name="plan" value="yearly" label="Annuel" />
507
540
  ```
508
541
 
542
+ **Notes :**
543
+ - `onCheckedChange` ne prévient que le bouton qui vient d'être coché, jamais celui qui est décoché par un autre
544
+ - `id` est respecté : le libellé pointe vers l'identifiant fourni
545
+
509
546
  ### Slider
510
547
 
511
548
  ```tsx
@@ -940,9 +977,13 @@ const data = [
940
977
  tient que si l'application peut dessiner ce qu'elle n'obtiendra jamais du kit.
941
978
  - **Un `ScatterChart` ne se brosse pas.** Ses deux axes sont des mesures, et une
942
979
  fenêtre sur l'une d'elles n'est pas le geste qu'un nuage appelle.
943
- - **Une plage se pose aussi au clavier.** Maj + flèches l'étend, Échap la retire :
944
- un filtre qui ne s'atteint qu'à la souris est inaccessible à la moitié des
945
- lecteurs.
980
+ - **Une plage se pose aussi au clavier.** Maj + flèches l'étend depuis la
981
+ position où se trouve le clavier, Échap la retire : un filtre qui ne s'atteint
982
+ qu'à la souris est inaccessible à la moitié des lecteurs.
983
+ - **Ce qu'un pointeur clique, le clavier le clique aussi.** La première flèche
984
+ se pose sur la première marque ; Entrée et Espace appellent le `on…Click` du
985
+ graphique avec les arguments d'un clic sur cette marque. Ne doublez pas un
986
+ graphique d'une liste de boutons pour le rendre atteignable : il l'est déjà.
946
987
  - **Une fenêtre qui a déjà recadré le tableau de bord n'a plus à être teintée.**
947
988
  Les panneaux SONT la fenêtre ; la bande lave alors chaque tracé de bord à bord
948
989
  et n'énonce rien. Repassez `brush={null}` après l'avoir appliquée.
@@ -992,7 +1033,7 @@ tout le kit sur une charte :
992
1033
  }
993
1034
  ```
994
1035
 
995
- Redéfinissez-les aussi sous `:root.dark` / `[data-theme="dark"]` : les rampes
1036
+ Redéfinissez-les aussi sous `.dark` / `[data-theme="dark"]` : les rampes
996
1037
  sombres du kit ne sont pas les claires éclaircies, elles courent en sens inverse
997
1038
  (sur fond sombre, « plus » doit s'éloigner du fond).
998
1039
 
@@ -1480,6 +1521,7 @@ import { FileSelector } from "@synertech/ui";
1480
1521
  **Notes :**
1481
1522
  - En mode `"both"` dropzone, deux boutons "Browse files" et "Browse folder" sont affichés
1482
1523
  - En mode `"both"` button variant, deux boutons côte à côte
1524
+ - En mode `"directory"` et `"both"`, la sélection est toujours une liste : `onChange` reçoit tous les fichiers du dossier, avec ou sans `multiple` (qui ne distingue un fichier de plusieurs qu'en mode `"file"`). `maxFiles` s'y applique aussi
1483
1525
  - Le drag & drop de dossiers traverse l'arborescence récursivement
1484
1526
  - `webkitRelativePath` est affiché dans la liste de fichiers quand disponible
1485
1527
  - `accept` n'est pas appliqué au dialogue natif en mode directory (navigateur l'ignore) mais la validation JS reste active
@@ -1519,7 +1561,7 @@ const columns: ColumnDef<User>[] = [
1519
1561
  ref={ref}
1520
1562
  columns={columns}
1521
1563
  data={users}
1522
- rowKey="id"
1564
+ rowKey="id" // toujours : sélection, expansion et édition sont tenues par cette clé
1523
1565
  mode="client" // "client" | "server"
1524
1566
 
1525
1567
  // Tri
@@ -1551,8 +1593,8 @@ const columns: ColumnDef<User>[] = [
1551
1593
  onCellEdit={(rowKey, colKey, value) => console.log(rowKey, colKey, value)}
1552
1594
 
1553
1595
  // Réordonnement
1554
- reorderable
1555
- onReorder={(from, to) => console.log(from, to)}
1596
+ reorderable // inactif tant que la grille trie elle-même les lignes
1597
+ onReorder={(from, to) => console.log(from, to)} // positions dans `data`, pas à l'écran
1556
1598
 
1557
1599
  // Visibilité des colonnes
1558
1600
  columnToggle
@@ -1564,6 +1606,8 @@ const columns: ColumnDef<User>[] = [
1564
1606
  exportable
1565
1607
  exportFormats={["csv", "json"]}
1566
1608
  exportFilename="users-export"
1609
+ // CSV : RFC 4180, et un texte qui commence par = + - @ est écrit précédé
1610
+ // d'une apostrophe (exportNeutralizeFormulas={false} pour l'écrire tel quel)
1567
1611
 
1568
1612
  // Footer agrégats
1569
1613
  showFooter
@@ -1590,8 +1634,8 @@ const columns: ColumnDef<User>[] = [
1590
1634
  // API impérative
1591
1635
  ref.current?.resetFilters();
1592
1636
  ref.current?.resetSort();
1593
- ref.current?.selectAll();
1594
- ref.current?.deselectAll();
1637
+ ref.current?.selectAll(); // ajoute les lignes visibles à la sélection
1638
+ ref.current?.deselectAll(); // vide la sélection, toutes pages confondues
1595
1639
  ref.current?.exportData("csv");
1596
1640
  ref.current?.scrollToRow(50);
1597
1641
  ref.current?.getVisibleData();
@@ -1973,16 +2017,23 @@ Cas particuliers :
1973
2017
  dialogue : le declarer avec `registerFloatingLayer(element, () => trigger)`,
1974
2018
  sinon il sera rendu inerte avec le fond. Les composants de la librairie
1975
2019
  (`Dropdown`, `Select`) le font deja : Echap y ferme d'abord le menu, un second
1976
- Echap ferme le dialogue.
2020
+ Echap ferme le dialogue. La propriete se suit de calque en calque : un
2021
+ sous-menu appartient au dialogue par le menu qui l'ouvre.
2022
+ - **Modale ouverte depuis un `Drawer` ou une `Sidebar` mobile** : rien a faire.
2023
+ `Modal` est rendue sous `<body>`, pas la ou elle est declaree, et reste donc
2024
+ utilisable ; le tiroir passe derriere elle, et Echap les ferme une a une.
1977
2025
  - **Dialogue maison** : le hook `useDialogA11y` est exporte et fournit le meme
1978
2026
  comportement (`const { dialogRef, dialogProps } = useDialogA11y({ open, onClose })`).
1979
2027
 
1980
2028
  ### 7. Traduction des libelles integres (FR / EN)
1981
2029
 
1982
- Les libelles rendus par la librairie (« Close modal », « Close drawer »,
1983
- « Confirm », « Cancel », plein ecran) sont traduisibles globalement via
1984
- `UILabelsProvider`, ou au cas par cas via les props du composant (la prop gagne
1985
- toujours).
2030
+ **Toutes** les chaines que la librairie ecrit d'elle-meme passent par
2031
+ `UILabels` : texte visible, `aria-label`, `title`, `placeholder`, `alt`, texte
2032
+ pour lecteur d'ecran, messages de validation (y compris le motif transmis a
2033
+ `onReject`). L'anglais est la langue par defaut partout ; `frenchUILabels` est
2034
+ le jeu francais. Elles se traduisent globalement via `UILabelsProvider`, ou au
2035
+ cas par cas via les props du composant (la prop gagne toujours, puis le
2036
+ provider, puis l'anglais).
1986
2037
 
1987
2038
  ```tsx
1988
2039
  // app/layout.tsx (ou n'importe quel niveau de l'arbre)
@@ -2001,11 +2052,58 @@ import { UILabelsProvider, frenchUILabels, defaultUILabels } from "@synertech/ui
2001
2052
  <Modal closeLabel="Fermer le detail" ... />
2002
2053
  <Drawer closeLabel="Fermer le menu" ... />
2003
2054
  <Sidebar closeLabel="Fermer la navigation" aria-label="Navigation principale" ... />
2055
+ <Select placeholder="Choisir un pays" searchPlaceholder="Rechercher un pays" ... />
2056
+
2057
+ // Plus de trois chaines : une seule prop `labels`, avec les cles du provider
2058
+ <DataGrid labels={{ dataGridNoData: "Aucun client", dataGridRowsPerPage: "Par page :" }} ... />
2059
+ <FileSelector labels={{ fileSelectorNoFile: "Aucun devis joint" }} ... />
2060
+ ```
2061
+
2062
+ **Les cles portent le prefixe de leur composant** : `dataGrid…`, `pagination…`,
2063
+ `select…`, `fileSelector…`, `imageUploader…`, `helpButton…`, `calendar…`,
2064
+ `wizard…`, `schemaEditor…`, `workflowEditor…` (et `editor…`, commun aux barres
2065
+ d'outils des deux editeurs), `chart…`, plus `bannerClose`, `toastClose`,
2066
+ `chipRemove`, `headerToggleMenu`, `mentionInputLoading`, `modalDefaultTitle`,
2067
+ et les cles des dialogues (`closeModal`, `closeDrawer`, `closeSidebar`,
2068
+ `openSidebar`, `expandSidebar`, `collapseSidebar`, `sidebar`,
2069
+ `enterFullScreen`, `exitFullScreen`, `confirm`, `cancel`). Le type `UILabels`
2070
+ les liste toutes, chacune avec sa description.
2071
+
2072
+ **Surcharge par instance** : jusqu'a trois chaines, des props individuelles
2073
+ (`closeLabel`, `removeLabel`, `menuLabel`, `loadingLabel`, `optionalLabel`,
2074
+ `clearLabel`, `searchLabel`, `searchPlaceholder`…) ; au-dela, une prop `labels`
2075
+ typee `UILabelsOf<"dataGrid">` (`DataGrid`, `FileSelector`, `ImageUploader`,
2076
+ `HelpButton`, `SchemaEditor`, `WorkflowEditor`). `Calendar` et `Pagination`
2077
+ gardent leur prop `labels` a cles courtes (`previousMonth`, `first`…).
2078
+
2079
+ **Les libelles sont de simples chaines** (un jeu peut venir d'un fichier JSON).
2080
+ Ce qui varie est un emplacement `{nom}` : `"Page {page} of {total}"`. Pour une
2081
+ autre langue, garder les memes emplacements. `formatUILabel(modele, valeurs)`
2082
+ les remplit si vous affichez un libelle vous-meme ; `useUILabels()` lit le jeu
2083
+ courant.
2084
+
2085
+ ```tsx
2086
+ <UILabelsProvider labels={{ dataGridPageOf: "Page {page} / {total}" }}>
2087
+ ```
2088
+
2089
+ **Composants rendus cote serveur** : `Label`, `Breadcrumb` et `Avatar` n'ont
2090
+ aucun hook, le provider ne les atteint donc pas. Leur libelle est une prop,
2091
+ anglaise par defaut :
2092
+
2093
+ ```tsx
2094
+ import { Label, Breadcrumb, frenchUILabels } from "@synertech/ui";
2095
+
2096
+ <Label required requiredLabel={frenchUILabels.labelRequired}>Courriel</Label>
2097
+ <Label optional optionalText={frenchUILabels.labelOptional}>Telephone</Label>
2098
+ <Breadcrumb items={items} aria-label={frenchUILabels.breadcrumbLabel} />
2099
+ <Avatar src={user.photo} alt={user.name} />
2004
2100
  ```
2005
2101
 
2006
- Cles disponibles : `closeModal`, `closeDrawer`, `closeSidebar`, `openSidebar`,
2007
- `expandSidebar`, `collapseSidebar`, `sidebar`, `enterFullScreen`,
2008
- `exitFullScreen`, `confirm`, `cancel`.
2102
+ **Changement depuis 0.45.1** : `HelpButton` et `ImageUploader` ecrivaient leurs
2103
+ chaines en francais quelle que soit la langue de l'application. Ils sont
2104
+ maintenant en anglais par defaut comme le reste, et en francais sous
2105
+ `<UILabelsProvider labels={frenchUILabels}>`. Une application francaise sans
2106
+ provider doit donc en monter un.
2009
2107
 
2010
2108
  ## Anti-patterns a eviter
2011
2109
 
package/README.md CHANGED
@@ -45,7 +45,32 @@ module.exports = {
45
45
 
46
46
  </details>
47
47
 
48
- ### 3. Next.js with webpack: optimize the package imports
48
+ ### 3. Dark mode
49
+
50
+ Out of the box the components follow the reader's system. An application that has its
51
+ own light/dark switch says which one is on, on `<html>`, **in both states**:
52
+
53
+ ```html
54
+ <html class="dark"> <!-- or data-theme="dark" -->
55
+ <html class="light"> <!-- or data-theme="light" -->
56
+ ```
57
+
58
+ | On the page | Result |
59
+ | --- | --- |
60
+ | `dark` class or `data-theme="dark"` on an ancestor | Dark. It need not be `<html>`: a dark section of a light page works. |
61
+ | `light` class or `data-theme="light"` on `<html>` | Light, even when the system is in dark. |
62
+ | Neither | The system decides (`prefers-color-scheme`). |
63
+
64
+ A switch that only ever adds `dark` leaves the light state undeclared, and undeclared
65
+ means "ask the system": set `light` as well. `next-themes` does both, with
66
+ `attribute="class"` or `attribute="data-theme"`. The chart palette follows the same
67
+ rules, so a chart and the panel around it always agree.
68
+
69
+ This is how the stylesheet the package ships is compiled. If you compile the classes
70
+ with your own Tailwind configuration instead, the `dark` variant is the one you
71
+ configured.
72
+
73
+ ### 4. Next.js with webpack: optimize the package imports
49
74
 
50
75
  Next.js 16 builds with Turbopack by default and needs nothing more. With webpack — what
51
76
  `next build` uses before Next.js 16, or `next build --webpack` since — add the package to
@@ -65,7 +90,7 @@ Without it, a Server Component that imports anything from `@synertech/ui` — a
65
90
  component of the library to the browser, on every page. Measured on a minimal server page
66
91
  with Next.js 14.2: 275 kB of first-load JavaScript without the setting, 90 kB with it.
67
92
 
68
- ### 4. Optional: Markdown editing
93
+ ### 5. Optional: Markdown editing
69
94
 
70
95
  `<HelpButton markdown editable>` uses [MDXEditor](https://mdxeditor.dev/), which is an
71
96
  **optional** peer dependency — it pulls in a large dependency tree, so it is not
@@ -164,6 +189,11 @@ through the exported `useDialogA11y` hook.
164
189
 
165
190
  ### Translating built-in labels
166
191
 
192
+ Every string the library writes on its own — visible text, accessible names,
193
+ placeholders, validation messages — is a key of `UILabels`. English is the
194
+ default; `frenchUILabels` is the French set, and any other language is an
195
+ object with the same keys.
196
+
167
197
  ```tsx
168
198
  import { UILabelsProvider, frenchUILabels } from "@synertech/ui";
169
199
 
@@ -171,12 +201,24 @@ import { UILabelsProvider, frenchUILabels } from "@synertech/ui";
171
201
  <App />
172
202
  </UILabelsProvider>;
173
203
 
174
- // or per instance
204
+ // or per instance: a prop always wins over the provider
175
205
  <Modal closeLabel="Fermer la fenêtre" ... />
176
- <Drawer closeLabel="Fermer le panneau" ... />
177
- <Sidebar closeLabel="Fermer le menu" ... />
206
+ <Select placeholder="Choisir un pays" searchPlaceholder="Rechercher un pays" ... />
207
+
208
+ // a component with more than three strings takes them in one `labels` prop,
209
+ // with the very keys the provider takes
210
+ <DataGrid labels={{ dataGridNoData: "Aucun client", dataGridRowsPerPage: "Par page :" }} ... />
178
211
  ```
179
212
 
213
+ - What varies in a label is a `{name}` placeholder (`"Page {page} of {total}"`).
214
+ `formatUILabel(template, values)` fills it, should you render one yourself.
215
+ - `Label`, `Breadcrumb` and `Avatar` render on the server, where the provider
216
+ does not reach: pass them the label as a prop —
217
+ `<Label required requiredLabel={frenchUILabels.labelRequired}>`.
218
+ - `HelpButton` and `ImageUploader` used to speak French whatever the
219
+ application spoke. They are English by default like the rest, and French
220
+ under `frenchUILabels`.
221
+
180
222
  ### Table
181
223
 
182
224
  ```tsx
@@ -1 +1 @@
1
- "use strict";"use client";var Ve=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var je=Object.prototype.hasOwnProperty;var Ze=(h,i)=>{for(var r in i)Ve(h,r,{get:i[r],enumerable:!0})},qe=(h,i,r,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of Fe(i))!je.call(h,d)&&d!==r&&Ve(h,d,{get:()=>i[d],enumerable:!(g=Ue(i,d))||g.enumerable});return h};var Je=h=>qe(Ve({},"__esModule",{value:!0}),h);var at={};Ze(at,{AreaChart:()=>ot});module.exports=Je(at);var s=require("react"),Ne=require("../../lib/cn.cjs"),We=require("../../lib/i18n.cjs"),J=require("../chart/ChartAnnotations.cjs"),Ee=require("../chart/ChartAxis.cjs"),ge=require("../chart/ChartBrush.cjs"),De=require("../chart/ChartContainer.cjs"),Me=require("../chart/ChartGrid.cjs"),$e=require("../chart/ChartLegend.cjs"),fe=require("../chart/ChartPatterns.cjs"),Ke=require("../chart/ChartSync.cjs"),Oe=require("../chart/ChartTableView.cjs"),pe=require("../chart/ChartTooltip.cjs"),E=require("../chart/palette.cjs"),P=require("../chart/utils/cartesian.cjs"),ye=require("../chart/utils/data.cjs"),Ce=require("../chart/utils/decimate.cjs"),H=require("../chart/utils/format.cjs"),x=require("../chart/utils/path.cjs"),Q=require("../chart/utils/scales.cjs"),be=require("../chart/utils/stack.cjs"),Xe=require("../chart/utils/ticks.cjs"),Ge=require("../chart/utils/timestamp.cjs"),_e=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Qe=.12,et=.9,tt=10,nt=(0,s.memo)(function({bands:i,stacked:r,patterns:g,patternBaseId:d}){return(0,n.jsx)("g",{children:i.map(m=>(0,n.jsxs)("g",{children:[(0,n.jsx)("path",{d:m.area,fill:(0,fe.patternFill)(g,d,m.slot,m.color),fillOpacity:r?et:Qe,stroke:"none"}),m.gap?(0,n.jsx)("path",{d:m.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,(0,n.jsx)("path",{d:m.edge,fill:"none",stroke:m.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),m.isolated.map(p=>(0,n.jsx)("circle",{cx:p.x,cy:p.y,r:3,fill:m.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${p.x}-${p.y}`))]},m.key))})});function rt({width:h,height:i,data:r,resolvedSeries:g,x:d,y:m,grid:p,size:ee,curve:C,stack:A,baseline:L,connectNulls:S,referenceLines:M,annotations:B,annotationsLabel:ke,patterns:te,patternBaseId:ne,overlay:ve,maxPoints:b,brush:re,onBrush:oe,brushLabel:xe,syncEnabled:$,margin:ae,tooltip:R,onPointClick:K,plotLabel:Pe,formatValue:k,formatRaw:O,formatX:I}){let[X,G]=(0,s.useState)(null),u=X!==null&&X<r.length?X:null,[Ae,Le]=(0,s.useState)(null),Se=(0,Ke.useChartSync)(),l=$?Se:null,t=(0,s.useMemo)(()=>{let e=g.filter(T=>!T.hidden),o=e.map(T=>T.key),a=A!=="none",c=(0,be.stackSeries)(r,o,A),ue=a?(0,be.stackExtent)(c):(0,Xe.extent)([...(0,ye.collectAllValues)(r,o),L]),y=(0,P.buildCartesianGeometry)({width:h,height:i,data:r,x:d,y:m,bounds:ue,margin:ae,placement:"point",formatValue:k,formatX:I,defaultIncludeZero:!0}),we=y.categoryCenters,ce=y.valueScale,ze=ce(a?0:L),Ye=e.map((T,Te)=>{let j=r.map((Z,q)=>{let V=c[q].segments[Te];return{x:we[q],y:V.value===null?Number.NaN:ce(V.end),defined:V.value!==null}}),He=r.map((Z,q)=>{let V=c[q].segments[Te];return{x:we[q],y:V.value===null?Number.NaN:ce(a?V.start:L),defined:V.value!==null}}),he={connectNulls:S},me=b&&b>0&&j.length>b?(0,Ce.decimateIndices)(j,b):null,de=me?me.map(Z=>j[Z]):j,Ie=me?me.map(Z=>He[Z]):He;return b||(0,Ce.warnPointBudget)("AreaChart",j.length),{key:T.key,color:T.color,slot:T.slot,area:a?(0,x.buildAreaPath)(de,Ie,C,he):(0,x.buildAreaPath)(de,ze,C,he),edge:(0,x.buildLinePath)(de,C,he),gap:a&&Te>0?(0,x.buildLinePath)(Ie,C,he):"",isolated:(0,x.isolatedPoints)(de,S)}});return{visible:e,locate:(0,P.createCategoryLocator)(y),plot:(0,P.createPlotContext)({geometry:y,width:h,height:i,data:r,series:e,formatValue:k,formatX:I}),rows:c,stacked:a,xValues:y.xValues,positions:we,xTicks:y.categoryTicks,yTicks:y.valueTicks,valueScale:ce,innerWidth:y.innerWidth,innerHeight:y.innerHeight,margin:y.margin,bands:Ye}},[r,g,d,m,h,i,ae,C,A,L,S,b,k,I]),_=(0,s.useCallback)(e=>t.visible.map((o,a)=>{let c=(0,ye.readNumber)(r[e],o.key),ue=t.rows[e].segments[a],y=c===null?"\u2014":A==="percent"?`${O(c)} (${k(ue.end-ue.start)})`:k(c);return{seriesKey:o.key,seriesLabel:(0,E.getSeriesLabel)(o),color:o.color,value:c,formattedValue:y,datum:r[e]}}),[r,t.visible,t.rows,A,k,O]),se=l?l.brush:Ae,le=(0,s.useCallback)(e=>{Le(e),l?.setBrush(e),oe?.(e)},[l,oe]),f=(0,ge.useChartBrush)({enabled:re,active:se!==null,centers:t.positions,xValues:t.xValues,offset:t.margin.left,orientation:"vertical",onCommit:le}),Be=(0,s.useCallback)(e=>{if(f.onPointerMove(e),R===!1||r.length===0)return;let o=e.currentTarget.getBoundingClientRect(),a=e.clientX-o.left-t.margin.left,c=(0,Q.nearestIndex)(t.positions,a);G(c>=0?c:null),l?.setHovered(c>=0?t.xValues[c]:null)},[f,R,r.length,t.margin.left,t.positions,t.xValues,l]),ie=(0,s.useCallback)(()=>{G(null),l?.setHovered(null)},[l]),N=(0,s.useCallback)(e=>{if(r.length===0)return;f.onKeyDown(e,u);let o=r.length-1,a=u??0,c=e.key==="ArrowRight"?Math.min(o,a+1):e.key==="ArrowLeft"?Math.max(0,a-1):e.key==="Home"?0:e.key==="End"?o:e.key==="Escape"?null:void 0;c!==void 0&&(e.preventDefault(),G(c),l?.setHovered(c===null?null:t.xValues[c]))},[r.length,u,f,l,t.xValues]),W=(0,s.useCallback)(()=>{if(f.consumedClick()||!K||u===null)return;let[e]=_(u);e&&K({...e,index:u,x:t.xValues[u]})},[f,K,u,_,t.xValues]),Re=u!==null||!l?.hovered?null:(()=>{let e=(0,Q.toKey)(l.hovered),o=t.xValues.findIndex(a=>(0,Q.toKey)(a)===e);return o<0?null:o})(),v=u??Re,z=u===null?null:_(u),D=v===null?[]:t.visible.map((e,o)=>{let a=t.rows[v].segments[o];return a.value===null?null:{key:e.key,color:e.color,y:t.valueScale(a.end)}}).filter(e=>e!==null),Y=f.dragging??se,U=(()=>{if(!Y)return null;let e=t.locate(Y.from),o=t.locate(Y.to);return e===null||o===null?null:{from:e,to:o}})(),F=(0,P.splitOverlay)(ve),w=u===null||z===null?null:{x:t.xValues[u],xLabel:I(t.xValues[u],u),index:u,points:z};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:h,height:i,role:"img","aria-label":Pe??[t.visible.map(e=>(0,E.getSeriesLabel)(e)).join(", "),(0,J.describeAnnotations)(B,ke)].filter(Boolean).join(". "),tabIndex:0,className:(0,Ne.cn)(_e.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",re&&"select-none"),onPointerDown:f.onPointerDown,onPointerMove:Be,onPointerUp:f.onPointerUp,onPointerCancel:f.onPointerUp,onPointerLeave:ie,onKeyDown:N,onBlur:ie,onClick:W,children:[te?(0,n.jsx)(fe.ChartPatternDefs,{id:ne,entries:g.map(e=>({slot:e.slot,color:e.color}))}):null,(0,n.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,n.jsx)(Me.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:p==="y"||p==="both"?t.yTicks.map(e=>e.offset):void 0,vertical:p==="x"||p==="both"?t.xTicks.map(e=>e.offset):void 0}),B?(0,n.jsx)(J.ChartAnnotationLayer,{layer:"under",annotations:B,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,U?(0,n.jsx)(ge.ChartBrushLayer,{from:U.from,to:U.to,width:t.innerWidth,height:t.innerHeight,live:f.dragging!==null,label:xe}):null,F.under?.(t.plot),(0,n.jsx)(nt,{bands:t.bands,stacked:t.stacked,patterns:te&&t.stacked,patternBaseId:ne}),B?(0,n.jsx)(J.ChartAnnotationLayer,{annotations:B,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,M?.map(e=>{let o=t.valueScale(e.value),a=o<tt?o+12:o-4;return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:0,y1:o,x2:t.innerWidth,y2:o,stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?(0,n.jsx)("text",{x:t.innerWidth,y:a,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)}),F.over?.(t.plot),v!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:t.positions[v],y1:0,x2:t.positions[v],y2:t.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:u===null?"3 3":void 0}),D.map(e=>(0,n.jsx)("circle",{cx:t.positions[v],cy:e.y,r:4,fill:e.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},e.key))]}):null]}),(0,n.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:d.hidden?null:(0,n.jsx)(Ee.ChartAxis,{orientation:"bottom",ticks:t.xTicks,length:t.innerWidth,label:d.label,size:ee})}),(0,n.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:m?.hidden?null:(0,n.jsx)(Ee.ChartAxis,{orientation:"left",ticks:t.yTicks,length:t.innerHeight,showLine:!1,label:m?.label,size:ee})})]}),w&&R!==!1?(0,n.jsx)(pe.ChartTooltip,{x:t.margin.left+t.positions[w.index],y:t.margin.top+(D.length>0?Math.min(...D.map(e=>e.y)):t.innerHeight/2),containerWidth:h,children:typeof R=="function"?R(w):(0,n.jsx)(pe.ChartTooltipContent,{title:w.xLabel,points:w.points})}):null]})}function ot({data:h,series:i,x:r,y:g,height:d=240,width:m,size:p="md",grid:ee="y",legend:C,tooltip:A=!0,tableView:L=!1,emphasis:S,title:M,description:B,loading:ke=!1,emptyState:te,error:ne=!1,errorState:ve,onRetry:b,actions:re,onPointClick:oe,curve:xe="monotone",stack:$="none",baseline:ae=0,connectNulls:R=!1,referenceLines:K,annotations:Pe,overlay:k,patterns:O=!1,legendToggle:I=!0,maxPoints:X,brush:G=!1,onBrush:u,brushLabel:Ae,sync:Le=!0,margin:Se,locale:l,plotLabel:t,className:_,...se}){let le=(0,We.useUILabels)(),[f,Be]=(0,s.useState)(()=>new Set),ie=(0,s.useId)(),N=(0,s.useMemo)(()=>i.map((e,o)=>({...e,slot:o,hidden:e.hidden||f.has(e.key),color:(0,E.resolveSeriesColor)(e,o,S)})),[i,f,S]),W=$==="percent",Re=(0,s.useMemo)(()=>W?{domain:[0,100],...g}:g,[W,g]),v=(0,s.useMemo)(()=>g?.format??(W?e=>(0,H.formatPercent)(e,{locale:l,alreadyScaled:!0,maximumFractionDigits:0}):e=>(0,H.formatAuto)(e,l)),[g?.format,W,l]),z=(0,s.useMemo)(()=>e=>(0,H.formatAuto)(e,l),[l]),D=(0,s.useMemo)(()=>r.format??(e=>r.scale==="time"?(0,Ge.formatTimeValue)(e,l):(0,H.formatXValue)(e,l)),[r.format,r.scale,l]),Y=(0,s.useCallback)(e=>{Be(o=>{let a=new Set(o);return a.has(e)?a.delete(e):a.add(e),a})},[]),U=C===void 0?i.length>=2:C!==!1,F=typeof C=="string"?C:"bottom",w=N.filter(e=>!e.hidden).length;return(0,n.jsx)(De.ChartContainer,{title:M,description:B,height:d,width:m,size:p,loading:ke,empty:h.length===0||w===0,emptyState:te,error:ne,errorState:ve,onRetry:b,actions:re,tableView:L,legendPosition:F,legend:U?(0,n.jsx)($e.ChartLegend,{items:(0,E.toLegendItems)(N,S,O&&$!=="none"),position:F,marker:"rect",size:p,onToggle:I?Y:void 0}):void 0,table:L?(0,n.jsx)(Oe.ChartTableView,{data:h,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:D,formatValue:z,caption:typeof M=="string"?M:void 0}):void 0,className:_,...se,children:({width:e})=>(0,n.jsx)(rt,{width:e,height:d,data:h,resolvedSeries:N,x:r,y:Re,grid:ee,size:p,curve:xe,stack:$,baseline:ae,connectNulls:R,referenceLines:K,annotations:Pe,annotationsLabel:le.chartAnnotations,patterns:O,patternBaseId:ie,overlay:k,maxPoints:X,brush:G,onBrush:u,brushLabel:Ae??le.chartBrush,syncEnabled:Le,margin:Se,tooltip:A,onPointClick:oe,plotLabel:t,formatValue:v,formatRaw:z,formatX:D})})}0&&(module.exports={AreaChart});
1
+ "use strict";"use client";var He=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Je=(h,c)=>{for(var r in c)He(h,r,{get:c[r],enumerable:!0})},Qe=(h,c,r,g)=>{if(c&&typeof c=="object"||typeof c=="function")for(let d of Ze(c))!qe.call(h,d)&&d!==r&&He(h,d,{get:()=>c[d],enumerable:!(g=je(c,d))||g.enumerable});return h};var et=h=>Qe(He({},"__esModule",{value:!0}),h);var lt={};Je(lt,{AreaChart:()=>st});module.exports=et(lt);var s=require("react"),De=require("../../lib/cn.cjs"),$e=require("../../lib/i18n.cjs"),q=require("../chart/ChartAnnotations.cjs"),Ie=require("../chart/ChartAxis.cjs"),ge=require("../chart/ChartBrush.cjs"),Ke=require("../chart/ChartContainer.cjs"),Me=require("../chart/ChartGrid.cjs"),Oe=require("../chart/ChartLegend.cjs"),fe=require("../chart/ChartPatterns.cjs"),Xe=require("../chart/ChartSync.cjs"),Ge=require("../chart/ChartTableView.cjs"),pe=require("../chart/ChartTooltip.cjs"),I=require("../chart/palette.cjs"),S=require("../chart/utils/cartesian.cjs"),be=require("../chart/utils/data.cjs"),Ce=require("../chart/utils/decimate.cjs"),N=require("../chart/utils/format.cjs"),ye=require("../chart/utils/keyboard.cjs"),L=require("../chart/utils/path.cjs"),J=require("../chart/utils/scales.cjs"),ve=require("../chart/utils/stack.cjs"),_e=require("../chart/utils/ticks.cjs"),ze=require("../chart/utils/timestamp.cjs"),Ye=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),tt=.12,nt=.9,rt=10,ot=(0,s.memo)(function({bands:c,stacked:r,patterns:g,patternBaseId:d}){return(0,n.jsx)("g",{children:c.map(m=>(0,n.jsxs)("g",{children:[(0,n.jsx)("path",{d:m.area,fill:(0,fe.patternFill)(g,d,m.slot,m.color),fillOpacity:r?nt:tt,stroke:"none"}),m.gap?(0,n.jsx)("path",{d:m.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,(0,n.jsx)("path",{d:m.edge,fill:"none",stroke:m.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),m.isolated.map(b=>(0,n.jsx)("circle",{cx:b.x,cy:b.y,r:3,fill:m.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${b.x}-${b.y}`))]},m.key))})});function at({width:h,height:c,data:r,resolvedSeries:g,x:d,y:m,grid:b,size:Q,curve:y,stack:A,baseline:B,connectNulls:R,referenceLines:K,annotations:w,annotationsLabel:ke,patterns:ee,patternBaseId:te,overlay:xe,maxPoints:x,brush:ne,onBrush:re,brushLabel:Pe,syncEnabled:M,margin:oe,tooltip:T,onPointClick:V,plotLabel:Le,formatValue:P,formatRaw:O,formatX:W}){let[X,G]=(0,s.useState)(null),i=X!==null&&X<r.length?X:null,[Se,Ae]=(0,s.useState)(null),Be=(0,Xe.useChartSync)(),u=M?Be:null,e=(0,s.useMemo)(()=>{let t=g.filter(E=>!E.hidden),o=t.map(E=>E.key),l=A!=="none",p=(0,ve.stackSeries)(r,o,A),ue=l?(0,ve.stackExtent)(p):(0,_e.extent)([...(0,be.collectAllValues)(r,o),B]),C=(0,S.buildCartesianGeometry)({width:h,height:c,data:r,x:d,y:m,bounds:ue,margin:oe,placement:"point",formatValue:P,formatX:W,defaultIncludeZero:!0}),Ve=C.categoryCenters,ce=C.valueScale,Ue=ce(l?0:B),Fe=t.map((E,Ee)=>{let F=r.map((j,Z)=>{let H=p[Z].segments[Ee];return{x:Ve[Z],y:H.value===null?Number.NaN:ce(H.end),defined:H.value!==null}}),Ne=r.map((j,Z)=>{let H=p[Z].segments[Ee];return{x:Ve[Z],y:H.value===null?Number.NaN:ce(l?H.start:B),defined:H.value!==null}}),he={connectNulls:R},me=x&&x>0&&F.length>x?(0,Ce.decimateIndices)(F,x):null,de=me?me.map(j=>F[j]):F,We=me?me.map(j=>Ne[j]):Ne;return x||(0,Ce.warnPointBudget)("AreaChart",F.length),{key:E.key,color:E.color,slot:E.slot,area:l?(0,L.buildAreaPath)(de,We,y,he):(0,L.buildAreaPath)(de,Ue,y,he),edge:(0,L.buildLinePath)(de,y,he),gap:l&&Ee>0?(0,L.buildLinePath)(We,y,he):"",isolated:(0,L.isolatedPoints)(de,R)}});return{visible:t,locate:(0,S.createCategoryLocator)(C),plot:(0,S.createPlotContext)({geometry:C,width:h,height:c,data:r,series:t,formatValue:P,formatX:W}),rows:p,stacked:l,xValues:C.xValues,positions:Ve,xTicks:C.categoryTicks,yTicks:C.valueTicks,valueScale:ce,innerWidth:C.innerWidth,innerHeight:C.innerHeight,margin:C.margin,bands:Fe}},[r,g,d,m,h,c,oe,y,A,B,R,x,P,W]),_=(0,s.useCallback)(t=>e.visible.map((o,l)=>{let p=(0,be.readNumber)(r[t],o.key),ue=e.rows[t].segments[l],C=p===null?"\u2014":A==="percent"?`${O(p)} (${P(ue.end-ue.start)})`:P(p);return{seriesKey:o.key,seriesLabel:(0,I.getSeriesLabel)(o),color:o.color,value:p,formattedValue:C,datum:r[t]}}),[r,e.visible,e.rows,A,P,O]),ae=u?u.brush:Se,se=(0,s.useCallback)(t=>{Ae(t),u?.setBrush(t),re?.(t)},[u,re]),f=(0,ge.useChartBrush)({enabled:ne,active:ae!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:se}),Re=(0,s.useCallback)(t=>{if(f.onPointerMove(t),T===!1||r.length===0)return;let o=t.currentTarget.getBoundingClientRect(),l=t.clientX-o.left-e.margin.left,p=(0,J.nearestIndex)(e.positions,l);G(p>=0?p:null),u?.setHovered(p>=0?e.xValues[p]:null)},[f,T,r.length,e.margin.left,e.positions,e.xValues,u]),le=(0,s.useCallback)(()=>{G(null),u?.setHovered(null)},[u]),v=(0,s.useCallback)(()=>{if(!V||i===null)return;let[t]=_(i);t&&V({...t,index:i,x:e.xValues[i]})},[V,i,_,e.xValues]),D=(0,s.useCallback)(t=>{if(r.length===0)return;let o=V&&i!==null&&e.visible.length>0;if((0,ye.pressChartMark)(t,o?v:null))return;f.onKeyDown(t,i);let l=(0,ye.chartCursorTarget)(t.key,i,r.length,"x");l!==void 0&&(t.preventDefault(),G(l),u?.setHovered(l===null?null:e.xValues[l]))},[r.length,i,f,u,e.xValues,e.visible.length,V,v]),we=(0,s.useCallback)(()=>{f.consumedClick()||v()},[f,v]),Te=i!==null||!u?.hovered?null:(()=>{let t=(0,J.toKey)(u.hovered),o=e.xValues.findIndex(l=>(0,J.toKey)(l)===t);return o<0?null:o})(),k=i??Te,z=i===null?null:_(i),Y=k===null?[]:e.visible.map((t,o)=>{let l=e.rows[k].segments[o];return l.value===null?null:{key:t.key,color:t.color,y:e.valueScale(l.end)}}).filter(t=>t!==null),U=f.dragging??ae,$=(()=>{if(!U)return null;let t=e.locate(U.from),o=e.locate(U.to);return t===null||o===null?null:{from:t,to:o}})(),ie=(0,S.splitOverlay)(xe),a=i===null||z===null?null:{x:e.xValues[i],xLabel:W(e.xValues[i],i),index:i,points:z};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:h,height:c,role:"img","aria-label":Le??[e.visible.map(t=>(0,I.getSeriesLabel)(t)).join(", "),(0,q.describeAnnotations)(w,ke)].filter(Boolean).join(". "),tabIndex:0,className:(0,De.cn)(Ye.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",ne&&"select-none"),onPointerDown:f.onPointerDown,onPointerMove:Re,onPointerUp:f.onPointerUp,onPointerCancel:f.onPointerUp,onPointerLeave:le,onKeyDown:D,onBlur:le,onClick:we,children:[ee?(0,n.jsx)(fe.ChartPatternDefs,{id:te,entries:g.map(t=>({slot:t.slot,color:t.color}))}):null,(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(Me.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:b==="y"||b==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:b==="x"||b==="both"?e.xTicks.map(t=>t.offset):void 0}),w?(0,n.jsx)(q.ChartAnnotationLayer,{layer:"under",annotations:w,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,$?(0,n.jsx)(ge.ChartBrushLayer,{from:$.from,to:$.to,width:e.innerWidth,height:e.innerHeight,live:f.dragging!==null,label:Pe}):null,ie.under?.(e.plot),(0,n.jsx)(ot,{bands:e.bands,stacked:e.stacked,patterns:ee&&e.stacked,patternBaseId:te}),w?(0,n.jsx)(q.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),l=o<rt?o+12:o-4;return(0,n.jsxs)("g",{children:[(0,n.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,n.jsx)("text",{x:e.innerWidth,y:l,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),ie.over?.(e.plot),k!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:e.positions[k],y1:0,x2:e.positions[k],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:i===null?"3 3":void 0}),Y.map(t=>(0,n.jsx)("circle",{cx:e.positions[k],cy:t.y,r:4,fill:t.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},t.key))]}):null]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:d.hidden?null:(0,n.jsx)(Ie.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:d.label,size:Q})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:m?.hidden?null:(0,n.jsx)(Ie.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:m?.label,size:Q})})]}),a&&T!==!1?(0,n.jsx)(pe.ChartTooltip,{x:e.margin.left+e.positions[a.index],y:e.margin.top+(Y.length>0?Math.min(...Y.map(t=>t.y)):e.innerHeight/2),containerWidth:h,children:typeof T=="function"?T(a):(0,n.jsx)(pe.ChartTooltipContent,{title:a.xLabel,points:a.points})}):null]})}function st({data:h,series:c,x:r,y:g,height:d=240,width:m,size:b="md",grid:Q="y",legend:y,tooltip:A=!0,tableView:B=!1,emphasis:R,title:K,description:w,loading:ke=!1,emptyState:ee,error:te=!1,errorState:xe,onRetry:x,actions:ne,onPointClick:re,curve:Pe="monotone",stack:M="none",baseline:oe=0,connectNulls:T=!1,referenceLines:V,annotations:Le,overlay:P,patterns:O=!1,legendToggle:W=!0,maxPoints:X,brush:G=!1,onBrush:i,brushLabel:Se,sync:Ae=!0,margin:Be,locale:u,plotLabel:e,className:_,...ae}){let se=(0,$e.useUILabels)(),[f,Re]=(0,s.useState)(()=>new Set),le=(0,s.useId)(),v=(0,s.useMemo)(()=>c.map((a,t)=>({...a,slot:t,hidden:a.hidden||f.has(a.key),color:(0,I.resolveSeriesColor)(a,t,R)})),[c,f,R]),D=M==="percent",we=(0,s.useMemo)(()=>D?{domain:[0,100],...g}:g,[D,g]),Te=(0,s.useMemo)(()=>g?.format??(D?a=>(0,N.formatPercent)(a,{locale:u,alreadyScaled:!0,maximumFractionDigits:0}):a=>(0,N.formatAuto)(a,u)),[g?.format,D,u]),k=(0,s.useMemo)(()=>a=>(0,N.formatAuto)(a,u),[u]),z=(0,s.useMemo)(()=>r.format??(a=>r.scale==="time"?(0,ze.formatTimeValue)(a,u):(0,N.formatXValue)(a,u)),[r.format,r.scale,u]),Y=(0,s.useCallback)(a=>{Re(t=>{let o=new Set(t);return o.has(a)?o.delete(a):o.add(a),o})},[]),U=y===void 0?c.length>=2:y!==!1,$=typeof y=="string"?y:"bottom",ie=v.filter(a=>!a.hidden).length;return(0,n.jsx)(Ke.ChartContainer,{title:K,description:w,height:d,width:m,size:b,loading:ke,empty:h.length===0||ie===0,emptyState:ee,error:te,errorState:xe,onRetry:x,actions:ne,tableView:B,legendPosition:$,legend:U?(0,n.jsx)(Oe.ChartLegend,{items:(0,I.toLegendItems)(v,R,O&&M!=="none"),position:$,marker:"rect",size:b,onToggle:W?Y:void 0}):void 0,table:B?(0,n.jsx)(Ge.ChartTableView,{data:h,series:v,xKey:r.key,xLabel:r.label??r.key,formatX:z,formatValue:k,caption:typeof K=="string"?K:void 0}):void 0,className:_,...ae,children:({width:a})=>(0,n.jsx)(at,{width:a,height:d,data:h,resolvedSeries:v,x:r,y:we,grid:Q,size:b,curve:Pe,stack:M,baseline:oe,connectNulls:T,referenceLines:V,annotations:Le,annotationsLabel:se.chartAnnotations,patterns:O,patternBaseId:le,overlay:P,maxPoints:X,brush:G,onBrush:i,brushLabel:Se??se.chartBrush,syncEnabled:Ae,margin:Be,tooltip:A,onPointClick:re,plotLabel:e,formatValue:Te,formatRaw:k,formatX:z})})}0&&(module.exports={AreaChart});
@@ -1 +1 @@
1
- "use client";import{memo as He,useCallback as w,useId as Ie,useMemo as I,useState as ve}from"react";import{cn as Ne}from"../../lib/cn.js";import{useUILabels as We}from"../../lib/i18n.js";import{ChartAnnotationLayer as Ae,describeAnnotations as De}from"../chart/ChartAnnotations.js";import{ChartAxis as Le}from"../chart/ChartAxis.js";import{ChartBrushLayer as Me,useChartBrush as $e}from"../chart/ChartBrush.js";import{ChartContainer as Ke}from"../chart/ChartContainer.js";import{ChartGrid as Oe}from"../chart/ChartGrid.js";import{ChartLegend as Xe}from"../chart/ChartLegend.js";import{ChartPatternDefs as Ge,patternFill as _e}from"../chart/ChartPatterns.js";import{useChartSync as ze}from"../chart/ChartSync.js";import{ChartTableView as Ye}from"../chart/ChartTableView.js";import{ChartTooltip as Ue,ChartTooltipContent as Fe}from"../chart/ChartTooltip.js";import{getSeriesLabel as Se,resolveSeriesColor as je,toLegendItems as Ze}from"../chart/palette.js";import{buildCartesianGeometry as qe,createCategoryLocator as Je,createPlotContext as Qe,splitOverlay as et}from"../chart/utils/cartesian.js";import{collectAllValues as tt,readNumber as nt}from"../chart/utils/data.js";import{decimateIndices as rt,warnPointBudget as ot}from"../chart/utils/decimate.js";import{formatAuto as Be,formatPercent as at,formatXValue as st}from"../chart/utils/format.js";import{buildAreaPath as Re,buildLinePath as we,isolatedPoints as lt}from"../chart/utils/path.js";import{nearestIndex as it,toKey as Te}from"../chart/utils/scales.js";import{stackExtent as ut,stackSeries as ct}from"../chart/utils/stack.js";import{extent as ht}from"../chart/utils/ticks.js";import{formatTimeValue as mt}from"../chart/utils/timestamp.js";import{CHART_TOUCH as dt}from"../chart/utils/touch.js";import{Fragment as bt,jsx as a,jsxs as N}from"react/jsx-runtime";var gt=.12,ft=.9,pt=10,yt=He(function({bands:f,stacked:r,patterns:d,patternBaseId:y}){return a("g",{children:f.map(u=>N("g",{children:[a("path",{d:u.area,fill:_e(d,y,u.slot,u.color),fillOpacity:r?ft:gt,stroke:"none"}),u.gap?a("path",{d:u.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,a("path",{d:u.edge,fill:"none",stroke:u.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),u.isolated.map(h=>a("circle",{cx:h.x,cy:h.y,r:3,fill:u.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${h.x}-${h.y}`))]},u.key))})});function Ct({width:g,height:f,data:r,resolvedSeries:d,x:y,y:u,grid:h,size:Z,curve:p,stack:v,baseline:x,connectNulls:P,referenceLines:W,annotations:A,annotationsLabel:ce,patterns:q,patternBaseId:J,overlay:he,maxPoints:C,brush:Q,onBrush:ee,brushLabel:me,syncEnabled:D,margin:te,tooltip:L,onPointClick:M,plotLabel:de,formatValue:b,formatRaw:$,formatX:T}){let[K,O]=ve(null),l=K!==null&&K<r.length?K:null,[ge,fe]=ve(null),pe=ze(),s=D?pe:null,t=I(()=>{let e=d.filter(B=>!B.hidden),n=e.map(B=>B.key),o=v!=="none",i=ct(r,n,v),ae=o?ut(i):ht([...tt(r,n),x]),m=qe({width:g,height:f,data:r,x:y,y:u,bounds:ae,margin:te,placement:"point",formatValue:b,formatX:T,defaultIncludeZero:!0}),be=m.categoryCenters,se=m.valueScale,Ve=se(o?0:x),Ee=e.map((B,ke)=>{let U=r.map((F,j)=>{let R=i[j].segments[ke];return{x:be[j],y:R.value===null?Number.NaN:se(R.end),defined:R.value!==null}}),xe=r.map((F,j)=>{let R=i[j].segments[ke];return{x:be[j],y:R.value===null?Number.NaN:se(o?R.start:x),defined:R.value!==null}}),le={connectNulls:P},ie=C&&C>0&&U.length>C?rt(U,C):null,ue=ie?ie.map(F=>U[F]):U,Pe=ie?ie.map(F=>xe[F]):xe;return C||ot("AreaChart",U.length),{key:B.key,color:B.color,slot:B.slot,area:o?Re(ue,Pe,p,le):Re(ue,Ve,p,le),edge:we(ue,p,le),gap:o&&ke>0?we(Pe,p,le):"",isolated:lt(ue,P)}});return{visible:e,locate:Je(m),plot:Qe({geometry:m,width:g,height:f,data:r,series:e,formatValue:b,formatX:T}),rows:i,stacked:o,xValues:m.xValues,positions:be,xTicks:m.categoryTicks,yTicks:m.valueTicks,valueScale:se,innerWidth:m.innerWidth,innerHeight:m.innerHeight,margin:m.margin,bands:Ee}},[r,d,y,u,g,f,te,p,v,x,P,C,b,T]),X=w(e=>t.visible.map((n,o)=>{let i=nt(r[e],n.key),ae=t.rows[e].segments[o],m=i===null?"\u2014":v==="percent"?`${$(i)} (${b(ae.end-ae.start)})`:b(i);return{seriesKey:n.key,seriesLabel:Se(n),color:n.color,value:i,formattedValue:m,datum:r[e]}}),[r,t.visible,t.rows,v,b,$]),ne=s?s.brush:ge,re=w(e=>{fe(e),s?.setBrush(e),ee?.(e)},[s,ee]),c=$e({enabled:Q,active:ne!==null,centers:t.positions,xValues:t.xValues,offset:t.margin.left,orientation:"vertical",onCommit:re}),ye=w(e=>{if(c.onPointerMove(e),L===!1||r.length===0)return;let n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-t.margin.left,i=it(t.positions,o);O(i>=0?i:null),s?.setHovered(i>=0?t.xValues[i]:null)},[c,L,r.length,t.margin.left,t.positions,t.xValues,s]),oe=w(()=>{O(null),s?.setHovered(null)},[s]),V=w(e=>{if(r.length===0)return;c.onKeyDown(e,l);let n=r.length-1,o=l??0,i=e.key==="ArrowRight"?Math.min(n,o+1):e.key==="ArrowLeft"?Math.max(0,o-1):e.key==="Home"?0:e.key==="End"?n:e.key==="Escape"?null:void 0;i!==void 0&&(e.preventDefault(),O(i),s?.setHovered(i===null?null:t.xValues[i]))},[r.length,l,c,s,t.xValues]),E=w(()=>{if(c.consumedClick()||!M||l===null)return;let[e]=X(l);e&&M({...e,index:l,x:t.xValues[l]})},[c,M,l,X,t.xValues]),Ce=l!==null||!s?.hovered?null:(()=>{let e=Te(s.hovered),n=t.xValues.findIndex(o=>Te(o)===e);return n<0?null:n})(),k=l??Ce,G=l===null?null:X(l),H=k===null?[]:t.visible.map((e,n)=>{let o=t.rows[k].segments[n];return o.value===null?null:{key:e.key,color:e.color,y:t.valueScale(o.end)}}).filter(e=>e!==null),_=c.dragging??ne,z=(()=>{if(!_)return null;let e=t.locate(_.from),n=t.locate(_.to);return e===null||n===null?null:{from:e,to:n}})(),Y=et(he),S=l===null||G===null?null:{x:t.xValues[l],xLabel:T(t.xValues[l],l),index:l,points:G};return N(bt,{children:[N("svg",{width:g,height:f,role:"img","aria-label":de??[t.visible.map(e=>Se(e)).join(", "),De(A,ce)].filter(Boolean).join(". "),tabIndex:0,className:Ne(dt,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",Q&&"select-none"),onPointerDown:c.onPointerDown,onPointerMove:ye,onPointerUp:c.onPointerUp,onPointerCancel:c.onPointerUp,onPointerLeave:oe,onKeyDown:V,onBlur:oe,onClick:E,children:[q?a(Ge,{id:J,entries:d.map(e=>({slot:e.slot,color:e.color}))}):null,N("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[a(Oe,{width:t.innerWidth,height:t.innerHeight,horizontal:h==="y"||h==="both"?t.yTicks.map(e=>e.offset):void 0,vertical:h==="x"||h==="both"?t.xTicks.map(e=>e.offset):void 0}),A?a(Ae,{layer:"under",annotations:A,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,z?a(Me,{from:z.from,to:z.to,width:t.innerWidth,height:t.innerHeight,live:c.dragging!==null,label:me}):null,Y.under?.(t.plot),a(yt,{bands:t.bands,stacked:t.stacked,patterns:q&&t.stacked,patternBaseId:J}),A?a(Ae,{annotations:A,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,W?.map(e=>{let n=t.valueScale(e.value),o=n<pt?n+12:n-4;return N("g",{children:[a("line",{x1:0,y1:n,x2:t.innerWidth,y2:n,stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?a("text",{x:t.innerWidth,y:o,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)}),Y.over?.(t.plot),k!==null?N("g",{"aria-hidden":"true",children:[a("line",{x1:t.positions[k],y1:0,x2:t.positions[k],y2:t.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:l===null?"3 3":void 0}),H.map(e=>a("circle",{cx:t.positions[k],cy:e.y,r:4,fill:e.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},e.key))]}):null]}),a("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:y.hidden?null:a(Le,{orientation:"bottom",ticks:t.xTicks,length:t.innerWidth,label:y.label,size:Z})}),a("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:u?.hidden?null:a(Le,{orientation:"left",ticks:t.yTicks,length:t.innerHeight,showLine:!1,label:u?.label,size:Z})})]}),S&&L!==!1?a(Ue,{x:t.margin.left+t.positions[S.index],y:t.margin.top+(H.length>0?Math.min(...H.map(e=>e.y)):t.innerHeight/2),containerWidth:g,children:typeof L=="function"?L(S):a(Fe,{title:S.xLabel,points:S.points})}):null]})}function _t({data:g,series:f,x:r,y:d,height:y=240,width:u,size:h="md",grid:Z="y",legend:p,tooltip:v=!0,tableView:x=!1,emphasis:P,title:W,description:A,loading:ce=!1,emptyState:q,error:J=!1,errorState:he,onRetry:C,actions:Q,onPointClick:ee,curve:me="monotone",stack:D="none",baseline:te=0,connectNulls:L=!1,referenceLines:M,annotations:de,overlay:b,patterns:$=!1,legendToggle:T=!0,maxPoints:K,brush:O=!1,onBrush:l,brushLabel:ge,sync:fe=!0,margin:pe,locale:s,plotLabel:t,className:X,...ne}){let re=We(),[c,ye]=ve(()=>new Set),oe=Ie(),V=I(()=>f.map((e,n)=>({...e,slot:n,hidden:e.hidden||c.has(e.key),color:je(e,n,P)})),[f,c,P]),E=D==="percent",Ce=I(()=>E?{domain:[0,100],...d}:d,[E,d]),k=I(()=>d?.format??(E?e=>at(e,{locale:s,alreadyScaled:!0,maximumFractionDigits:0}):e=>Be(e,s)),[d?.format,E,s]),G=I(()=>e=>Be(e,s),[s]),H=I(()=>r.format??(e=>r.scale==="time"?mt(e,s):st(e,s)),[r.format,r.scale,s]),_=w(e=>{ye(n=>{let o=new Set(n);return o.has(e)?o.delete(e):o.add(e),o})},[]),z=p===void 0?f.length>=2:p!==!1,Y=typeof p=="string"?p:"bottom",S=V.filter(e=>!e.hidden).length;return a(Ke,{title:W,description:A,height:y,width:u,size:h,loading:ce,empty:g.length===0||S===0,emptyState:q,error:J,errorState:he,onRetry:C,actions:Q,tableView:x,legendPosition:Y,legend:z?a(Xe,{items:Ze(V,P,$&&D!=="none"),position:Y,marker:"rect",size:h,onToggle:T?_:void 0}):void 0,table:x?a(Ye,{data:g,series:V,xKey:r.key,xLabel:r.label??r.key,formatX:H,formatValue:G,caption:typeof W=="string"?W:void 0}):void 0,className:X,...ne,children:({width:e})=>a(Ct,{width:e,height:y,data:g,resolvedSeries:V,x:r,y:Ce,grid:Z,size:h,curve:me,stack:D,baseline:te,connectNulls:L,referenceLines:M,annotations:de,annotationsLabel:re.chartAnnotations,patterns:$,patternBaseId:oe,overlay:b,maxPoints:K,brush:O,onBrush:l,brushLabel:ge??re.chartBrush,syncEnabled:fe,margin:pe,tooltip:v,onPointClick:ee,plotLabel:t,formatValue:k,formatRaw:G,formatX:H})})}export{_t as AreaChart};
1
+ "use client";import{memo as Ie,useCallback as P,useId as Ne,useMemo as N,useState as xe}from"react";import{cn as We}from"../../lib/cn.js";import{useUILabels as De}from"../../lib/i18n.js";import{ChartAnnotationLayer as Se,describeAnnotations as $e}from"../chart/ChartAnnotations.js";import{ChartAxis as Ae}from"../chart/ChartAxis.js";import{ChartBrushLayer as Ke,useChartBrush as Me}from"../chart/ChartBrush.js";import{ChartContainer as Oe}from"../chart/ChartContainer.js";import{ChartGrid as Xe}from"../chart/ChartGrid.js";import{ChartLegend as Ge}from"../chart/ChartLegend.js";import{ChartPatternDefs as _e,patternFill as ze}from"../chart/ChartPatterns.js";import{useChartSync as Ye}from"../chart/ChartSync.js";import{ChartTableView as Ue}from"../chart/ChartTableView.js";import{ChartTooltip as Fe,ChartTooltipContent as je}from"../chart/ChartTooltip.js";import{getSeriesLabel as Be,resolveSeriesColor as Ze,toLegendItems as qe}from"../chart/palette.js";import{buildCartesianGeometry as Je,createCategoryLocator as Qe,createPlotContext as et,splitOverlay as tt}from"../chart/utils/cartesian.js";import{collectAllValues as nt,readNumber as rt}from"../chart/utils/data.js";import{decimateIndices as ot,warnPointBudget as at}from"../chart/utils/decimate.js";import{formatAuto as Re,formatPercent as st,formatXValue as lt}from"../chart/utils/format.js";import{chartCursorTarget as it,pressChartMark as ut}from"../chart/utils/keyboard.js";import{buildAreaPath as we,buildLinePath as Te,isolatedPoints as ct}from"../chart/utils/path.js";import{nearestIndex as ht,toKey as Ve}from"../chart/utils/scales.js";import{stackExtent as mt,stackSeries as dt}from"../chart/utils/stack.js";import{extent as gt}from"../chart/utils/ticks.js";import{formatTimeValue as ft}from"../chart/utils/timestamp.js";import{CHART_TOUCH as pt}from"../chart/utils/touch.js";import{Fragment as xt,jsx as a,jsxs as W}from"react/jsx-runtime";var bt=.12,Ct=.9,yt=10,vt=Ie(function({bands:p,stacked:r,patterns:g,patternBaseId:C}){return a("g",{children:p.map(u=>W("g",{children:[a("path",{d:u.area,fill:ze(g,C,u.slot,u.color),fillOpacity:r?Ct:bt,stroke:"none"}),u.gap?a("path",{d:u.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,a("path",{d:u.edge,fill:"none",stroke:u.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),u.isolated.map(m=>a("circle",{cx:m.x,cy:m.y,r:3,fill:u.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${m.x}-${m.y}`))]},u.key))})});function kt({width:f,height:p,data:r,resolvedSeries:g,x:C,y:u,grid:m,size:j,curve:b,stack:L,baseline:S,connectNulls:A,referenceLines:D,annotations:B,annotationsLabel:ce,patterns:Z,patternBaseId:q,overlay:he,maxPoints:k,brush:J,onBrush:Q,brushLabel:me,syncEnabled:$,margin:ee,tooltip:R,onPointClick:w,plotLabel:de,formatValue:x,formatRaw:K,formatX:E}){let[M,O]=xe(null),l=M!==null&&M<r.length?M:null,[ge,fe]=xe(null),pe=Ye(),i=$?pe:null,e=N(()=>{let t=g.filter(T=>!T.hidden),n=t.map(T=>T.key),s=L!=="none",h=dt(r,n,L),ae=s?mt(h):gt([...nt(r,n),S]),d=Je({width:f,height:p,data:r,x:C,y:u,bounds:ae,margin:ee,placement:"point",formatValue:x,formatX:E,defaultIncludeZero:!0}),ve=d.categoryCenters,se=d.valueScale,Ee=se(s?0:S),He=t.map((T,ke)=>{let Y=r.map((U,F)=>{let V=h[F].segments[ke];return{x:ve[F],y:V.value===null?Number.NaN:se(V.end),defined:V.value!==null}}),Pe=r.map((U,F)=>{let V=h[F].segments[ke];return{x:ve[F],y:V.value===null?Number.NaN:se(s?V.start:S),defined:V.value!==null}}),le={connectNulls:A},ie=k&&k>0&&Y.length>k?ot(Y,k):null,ue=ie?ie.map(U=>Y[U]):Y,Le=ie?ie.map(U=>Pe[U]):Pe;return k||at("AreaChart",Y.length),{key:T.key,color:T.color,slot:T.slot,area:s?we(ue,Le,b,le):we(ue,Ee,b,le),edge:Te(ue,b,le),gap:s&&ke>0?Te(Le,b,le):"",isolated:ct(ue,A)}});return{visible:t,locate:Qe(d),plot:et({geometry:d,width:f,height:p,data:r,series:t,formatValue:x,formatX:E}),rows:h,stacked:s,xValues:d.xValues,positions:ve,xTicks:d.categoryTicks,yTicks:d.valueTicks,valueScale:se,innerWidth:d.innerWidth,innerHeight:d.innerHeight,margin:d.margin,bands:He}},[r,g,C,u,f,p,ee,b,L,S,A,k,x,E]),X=P(t=>e.visible.map((n,s)=>{let h=rt(r[t],n.key),ae=e.rows[t].segments[s],d=h===null?"\u2014":L==="percent"?`${K(h)} (${x(ae.end-ae.start)})`:x(h);return{seriesKey:n.key,seriesLabel:Be(n),color:n.color,value:h,formattedValue:d,datum:r[t]}}),[r,e.visible,e.rows,L,x,K]),te=i?i.brush:ge,ne=P(t=>{fe(t),i?.setBrush(t),Q?.(t)},[i,Q]),c=Me({enabled:J,active:te!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:ne}),be=P(t=>{if(c.onPointerMove(t),R===!1||r.length===0)return;let n=t.currentTarget.getBoundingClientRect(),s=t.clientX-n.left-e.margin.left,h=ht(e.positions,s);O(h>=0?h:null),i?.setHovered(h>=0?e.xValues[h]:null)},[c,R,r.length,e.margin.left,e.positions,e.xValues,i]),re=P(()=>{O(null),i?.setHovered(null)},[i]),y=P(()=>{if(!w||l===null)return;let[t]=X(l);t&&w({...t,index:l,x:e.xValues[l]})},[w,l,X,e.xValues]),H=P(t=>{if(r.length===0)return;let n=w&&l!==null&&e.visible.length>0;if(ut(t,n?y:null))return;c.onKeyDown(t,l);let s=it(t.key,l,r.length,"x");s!==void 0&&(t.preventDefault(),O(s),i?.setHovered(s===null?null:e.xValues[s]))},[r.length,l,c,i,e.xValues,e.visible.length,w,y]),Ce=P(()=>{c.consumedClick()||y()},[c,y]),ye=l!==null||!i?.hovered?null:(()=>{let t=Ve(i.hovered),n=e.xValues.findIndex(s=>Ve(s)===t);return n<0?null:n})(),v=l??ye,G=l===null?null:X(l),_=v===null?[]:e.visible.map((t,n)=>{let s=e.rows[v].segments[n];return s.value===null?null:{key:t.key,color:t.color,y:e.valueScale(s.end)}}).filter(t=>t!==null),z=c.dragging??te,I=(()=>{if(!z)return null;let t=e.locate(z.from),n=e.locate(z.to);return t===null||n===null?null:{from:t,to:n}})(),oe=tt(he),o=l===null||G===null?null:{x:e.xValues[l],xLabel:E(e.xValues[l],l),index:l,points:G};return W(xt,{children:[W("svg",{width:f,height:p,role:"img","aria-label":de??[e.visible.map(t=>Be(t)).join(", "),$e(B,ce)].filter(Boolean).join(". "),tabIndex:0,className:We(pt,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",J&&"select-none"),onPointerDown:c.onPointerDown,onPointerMove:be,onPointerUp:c.onPointerUp,onPointerCancel:c.onPointerUp,onPointerLeave:re,onKeyDown:H,onBlur:re,onClick:Ce,children:[Z?a(_e,{id:q,entries:g.map(t=>({slot:t.slot,color:t.color}))}):null,W("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[a(Xe,{width:e.innerWidth,height:e.innerHeight,horizontal:m==="y"||m==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:m==="x"||m==="both"?e.xTicks.map(t=>t.offset):void 0}),B?a(Se,{layer:"under",annotations:B,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,I?a(Ke,{from:I.from,to:I.to,width:e.innerWidth,height:e.innerHeight,live:c.dragging!==null,label:me}):null,oe.under?.(e.plot),a(vt,{bands:e.bands,stacked:e.stacked,patterns:Z&&e.stacked,patternBaseId:q}),B?a(Se,{annotations:B,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,D?.map(t=>{let n=e.valueScale(t.value),s=n<yt?n+12:n-4;return W("g",{children:[a("line",{x1:0,y1:n,x2:e.innerWidth,y2:n,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?a("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??""}`)}),oe.over?.(e.plot),v!==null?W("g",{"aria-hidden":"true",children:[a("line",{x1:e.positions[v],y1:0,x2:e.positions[v],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:l===null?"3 3":void 0}),_.map(t=>a("circle",{cx:e.positions[v],cy:t.y,r:4,fill:t.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},t.key))]}):null]}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:C.hidden?null:a(Ae,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:C.label,size:j})}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:u?.hidden?null:a(Ae,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:u?.label,size:j})})]}),o&&R!==!1?a(Fe,{x:e.margin.left+e.positions[o.index],y:e.margin.top+(_.length>0?Math.min(..._.map(t=>t.y)):e.innerHeight/2),containerWidth:f,children:typeof R=="function"?R(o):a(je,{title:o.xLabel,points:o.points})}):null]})}function Ft({data:f,series:p,x:r,y:g,height:C=240,width:u,size:m="md",grid:j="y",legend:b,tooltip:L=!0,tableView:S=!1,emphasis:A,title:D,description:B,loading:ce=!1,emptyState:Z,error:q=!1,errorState:he,onRetry:k,actions:J,onPointClick:Q,curve:me="monotone",stack:$="none",baseline:ee=0,connectNulls:R=!1,referenceLines:w,annotations:de,overlay:x,patterns:K=!1,legendToggle:E=!0,maxPoints:M,brush:O=!1,onBrush:l,brushLabel:ge,sync:fe=!0,margin:pe,locale:i,plotLabel:e,className:X,...te}){let ne=De(),[c,be]=xe(()=>new Set),re=Ne(),y=N(()=>p.map((o,t)=>({...o,slot:t,hidden:o.hidden||c.has(o.key),color:Ze(o,t,A)})),[p,c,A]),H=$==="percent",Ce=N(()=>H?{domain:[0,100],...g}:g,[H,g]),ye=N(()=>g?.format??(H?o=>st(o,{locale:i,alreadyScaled:!0,maximumFractionDigits:0}):o=>Re(o,i)),[g?.format,H,i]),v=N(()=>o=>Re(o,i),[i]),G=N(()=>r.format??(o=>r.scale==="time"?ft(o,i):lt(o,i)),[r.format,r.scale,i]),_=P(o=>{be(t=>{let n=new Set(t);return n.has(o)?n.delete(o):n.add(o),n})},[]),z=b===void 0?p.length>=2:b!==!1,I=typeof b=="string"?b:"bottom",oe=y.filter(o=>!o.hidden).length;return a(Oe,{title:D,description:B,height:C,width:u,size:m,loading:ce,empty:f.length===0||oe===0,emptyState:Z,error:q,errorState:he,onRetry:k,actions:J,tableView:S,legendPosition:I,legend:z?a(Ge,{items:qe(y,A,K&&$!=="none"),position:I,marker:"rect",size:m,onToggle:E?_:void 0}):void 0,table:S?a(Ue,{data:f,series:y,xKey:r.key,xLabel:r.label??r.key,formatX:G,formatValue:v,caption:typeof D=="string"?D:void 0}):void 0,className:X,...te,children:({width:o})=>a(kt,{width:o,height:C,data:f,resolvedSeries:y,x:r,y:Ce,grid:j,size:m,curve:me,stack:$,baseline:ee,connectNulls:R,referenceLines:w,annotations:de,annotationsLabel:ne.chartAnnotations,patterns:K,patternBaseId:re,overlay:x,maxPoints:M,brush:O,onBrush:l,brushLabel:ge??ne.chartBrush,syncEnabled:fe,margin:pe,tooltip:L,onPointClick:Q,plotLabel:e,formatValue:ye,formatRaw:v,formatX:G})})}export{Ft as AreaChart};
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var a in e)o(r,a,{get:e[a],enumerable:!0})},p=(r,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!x.call(r,t)&&t!==a&&o(r,t,{get:()=>e[t],enumerable:!(s=m(e,t))||s.enumerable});return r};var u=r=>p(o({},"__esModule",{value:!0}),r);var b={};f(b,{Avatar:()=>w});module.exports=u(b);var i=require("../../lib/cn.cjs"),n=require("react/jsx-runtime"),h={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},v={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function w({src:r,alt:e="Avatar",fallback:a,size:s="md",variant:t="circle",border:l=!1,className:d,...c}){return(0,n.jsx)("div",{className:(0,i.cn)("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",h[s],v[t],l&&"ring-2 ring-white dark:ring-gray-900",d),...c,children:r?(0,n.jsx)("img",{src:r,alt:e,className:"h-full w-full object-cover"}):(0,n.jsx)("span",{children:a||e.charAt(0).toUpperCase()})})}0&&(module.exports={Avatar});
1
+ "use strict";var n=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var a in e)n(r,a,{get:e[a],enumerable:!0})},u=(r,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!p.call(r,t)&&t!==a&&n(r,t,{get:()=>e[t],enumerable:!(s=g(e,t))||s.enumerable});return r};var v=r=>u(n({},"__esModule",{value:!0}),r);var y={};x(y,{Avatar:()=>w});module.exports=v(y);var i=require("../../lib/cn.cjs"),l=require("../../lib/server-labels.cjs"),o=require("react/jsx-runtime"),h={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},b={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function w({src:r,alt:e=l.serverUILabels.avatarAlt,fallback:a,size:s="md",variant:t="circle",border:d=!1,className:c,...m}){return(0,o.jsx)("div",{className:(0,i.cn)("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",h[s],b[t],d&&"ring-2 ring-white dark:ring-gray-900",c),...m,children:r?(0,o.jsx)("img",{src:r,alt:e,className:"h-full w-full object-cover"}):(0,o.jsx)("span",{children:a||e.charAt(0).toUpperCase()})})}0&&(module.exports={Avatar});
@@ -1 +1 @@
1
- import{cn as d}from"../../lib/cn.js";import{jsx as e}from"react/jsx-runtime";var c={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},m={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function x({src:r,alt:t="Avatar",fallback:a,size:s="md",variant:n="circle",border:o=!1,className:i,...l}){return e("div",{className:d("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",c[s],m[n],o&&"ring-2 ring-white dark:ring-gray-900",i),...l,children:r?e("img",{src:r,alt:t,className:"h-full w-full object-cover"}):e("span",{children:a||t.charAt(0).toUpperCase()})})}export{x as Avatar};
1
+ import{cn as d}from"../../lib/cn.js";import{serverUILabels as c}from"../../lib/server-labels.js";import{jsx as e}from"react/jsx-runtime";var m={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},g={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function x({src:r,alt:t=c.avatarAlt,fallback:a,size:s="md",variant:o="circle",border:n=!1,className:i,...l}){return e("div",{className:d("inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",m[s],g[o],n&&"ring-2 ring-white dark:ring-gray-900",i),...l,children:r?e("img",{src:r,alt:t,className:"h-full w-full object-cover"}):e("span",{children:a||t.charAt(0).toUpperCase()})})}export{x as Avatar};
@@ -1 +1 @@
1
- "use strict";"use client";var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var L=(t,r)=>{for(var o in r)x(t,o,{get:r[o],enumerable:!0})},M=(t,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!B.call(t,n)&&n!==o&&x(t,n,{get:()=>r[n],enumerable:!(s=N(r,n))||s.enumerable});return t};var R=t=>M(x({},"__esModule",{value:!0}),t);var z={};L(z,{Banner:()=>C});module.exports=R(z);var v=require("react"),a=require("../../lib/cn.cjs"),e=require("react/jsx-runtime");function k({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function I({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function P({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function W({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var V={info:k,success:I,warning:P,error:W,default:k},H={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},T={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function j({type:t="default",title:r,description:o,children:s,icon:n,action:i,closable:d=!1,onClose:c,fullWidth:u=!1,className:g,...f}){let[m,b]=(0,v.useState)(!0);if(!m)return null;let l=()=>{b(!1),c?.()},p=V[t],w=s??o;return(0,e.jsxs)("div",{role:"alert",className:(0,a.cn)("flex items-start gap-3 border px-4 py-3",u?"w-full":"rounded-lg",H[t],g),...f,children:[(0,e.jsx)("div",{className:(0,a.cn)("shrink-0 mt-0.5",T[t]),children:n??(0,e.jsx)(p,{className:"w-5 h-5"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[r&&(0,e.jsx)("div",{className:"font-semibold text-sm",children:r}),w&&(0,e.jsx)("div",{className:(0,a.cn)("text-sm",r?"mt-1 opacity-90":!1),children:w}),i&&(0,e.jsx)("div",{className:"mt-3",children:i})]}),d&&(0,e.jsx)("button",{type:"button",onClick:l,className:(0,a.cn)("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":"Close banner",children:(0,e.jsx)(h,{className:"w-4 h-4"})})]})}function O({title:t,description:r,children:o,action:s,backgroundImage:n,closable:i=!1,onClose:d,fullWidth:c=!1,className:u,...g}){let[f,m]=(0,v.useState)(!0);if(!f)return null;let b=()=>{m(!1),d?.()},l=o??r;return(0,e.jsxs)("div",{className:(0,a.cn)("relative overflow-hidden bg-gray-900 text-white",c?"w-full":"rounded-xl","py-12 px-6 sm:px-12",u),style:n?{backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...g,children:[n&&(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&(0,e.jsx)("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),l&&(0,e.jsx)("div",{className:(0,a.cn)("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:l}),s&&(0,e.jsx)("div",{className:"mt-6",children:s})]}),i&&(0,e.jsx)("button",{type:"button",onClick:b,className:(0,a.cn)("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:(0,e.jsx)(h,{className:"w-5 h-5"})})]})}function Z({title:t,description:r,children:o,icon:s,action:n,badge:i,closable:d=!1,onClose:c,fullWidth:u=!1,className:g,...f}){let[m,b]=(0,v.useState)(!0);if(!m)return null;let l=()=>{b(!1),c?.()},p=o??r;return(0,e.jsxs)("div",{className:(0,a.cn)("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",u?"w-full":"rounded-lg",g),...f,children:[s&&(0,e.jsx)("div",{className:"shrink-0",children:s}),i&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:i}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&(0,e.jsx)("span",{className:"font-semibold text-sm",children:t}),p&&(0,e.jsx)("span",{className:"text-sm opacity-90",children:p})]}),n&&(0,e.jsx)("div",{className:"shrink-0",children:n}),d&&(0,e.jsx)("button",{type:"button",onClick:l,className:(0,a.cn)("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:(0,e.jsx)(h,{className:"w-4 h-4"})})]})}function C({variant:t="notification",...r}){switch(t){case"hero":return(0,e.jsx)(O,{...r});case"promotion":return(0,e.jsx)(Z,{...r});default:return(0,e.jsx)(j,{...r})}}C.displayName="Banner";0&&(module.exports={Banner});
1
+ "use strict";"use client";var k=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var R=(t,r)=>{for(var o in r)k(t,o,{get:r[o],enumerable:!0})},P=(t,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of M(r))!I.call(t,n)&&n!==o&&k(t,n,{get:()=>r[n],enumerable:!(s=L(r,n))||s.enumerable});return t};var W=t=>P(k({},"__esModule",{value:!0}),t);var U={};R(U,{Banner:()=>B});module.exports=W(U);var h=require("react"),a=require("../../lib/cn.cjs"),w=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function y({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function V({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function H({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function T({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function C({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var j={info:y,success:V,warning:H,error:T,default:y},O={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},Z={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function z({type:t="default",title:r,description:o,children:s,icon:n,action:i,closable:d=!1,closeLabel:c,onClose:u,fullWidth:g=!1,className:b,...m}){let[f,p]=(0,h.useState)(!0),v=(0,w.useUILabels)();if(!f)return null;let l=()=>{p(!1),u?.()},x=j[t],N=s??o;return(0,e.jsxs)("div",{role:"alert",className:(0,a.cn)("flex items-start gap-3 border px-4 py-3",g?"w-full":"rounded-lg",O[t],b),...m,children:[(0,e.jsx)("div",{className:(0,a.cn)("shrink-0 mt-0.5",Z[t]),children:n??(0,e.jsx)(x,{className:"w-5 h-5"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[r&&(0,e.jsx)("div",{className:"font-semibold text-sm",children:r}),N&&(0,e.jsx)("div",{className:(0,a.cn)("text-sm",r?"mt-1 opacity-90":!1),children:N}),i&&(0,e.jsx)("div",{className:"mt-3",children:i})]}),d&&(0,e.jsx)("button",{type:"button",onClick:l,className:(0,a.cn)("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":c??v.bannerClose,children:(0,e.jsx)(C,{className:"w-4 h-4"})})]})}function S({title:t,description:r,children:o,action:s,backgroundImage:n,closable:i=!1,closeLabel:d,onClose:c,fullWidth:u=!1,className:g,...b}){let[m,f]=(0,h.useState)(!0),p=(0,w.useUILabels)();if(!m)return null;let v=()=>{f(!1),c?.()},l=o??r;return(0,e.jsxs)("div",{className:(0,a.cn)("relative overflow-hidden bg-gray-900 text-white",u?"w-full":"rounded-xl","py-12 px-6 sm:px-12",g),style:n?{backgroundImage:`url(${n})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...b,children:[n&&(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&(0,e.jsx)("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),l&&(0,e.jsx)("div",{className:(0,a.cn)("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:l}),s&&(0,e.jsx)("div",{className:"mt-6",children:s})]}),i&&(0,e.jsx)("button",{type:"button",onClick:v,className:(0,a.cn)("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":d??p.bannerClose,children:(0,e.jsx)(C,{className:"w-5 h-5"})})]})}function E({title:t,description:r,children:o,icon:s,action:n,badge:i,closable:d=!1,closeLabel:c,onClose:u,fullWidth:g=!1,className:b,...m}){let[f,p]=(0,h.useState)(!0),v=(0,w.useUILabels)();if(!f)return null;let l=()=>{p(!1),u?.()},x=o??r;return(0,e.jsxs)("div",{className:(0,a.cn)("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",g?"w-full":"rounded-lg",b),...m,children:[s&&(0,e.jsx)("div",{className:"shrink-0",children:s}),i&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:i}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&(0,e.jsx)("span",{className:"font-semibold text-sm",children:t}),x&&(0,e.jsx)("span",{className:"text-sm opacity-90",children:x})]}),n&&(0,e.jsx)("div",{className:"shrink-0",children:n}),d&&(0,e.jsx)("button",{type:"button",onClick:l,className:(0,a.cn)("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":c??v.bannerClose,children:(0,e.jsx)(C,{className:"w-4 h-4"})})]})}function B({variant:t="notification",...r}){switch(t){case"hero":return(0,e.jsx)(S,{...r});case"promotion":return(0,e.jsx)(E,{...r});default:return(0,e.jsx)(z,{...r})}}B.displayName="Banner";0&&(module.exports={Banner});
@@ -1 +1 @@
1
- "use client";import{useState as x}from"react";import{cn as n}from"../../lib/cn.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";function k({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function C({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function N({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function y({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h({className:t}){return e("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var B={info:k,success:C,warning:N,error:y,default:k},L={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},M={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function R({type:t="default",title:r,description:d,children:s,icon:o,action:a,closable:c=!1,onClose:u,fullWidth:g=!1,className:f,...m}){let[b,p]=x(!0);if(!b)return null;let i=()=>{p(!1),u?.()},v=B[t],w=s??d;return l("div",{role:"alert",className:n("flex items-start gap-3 border px-4 py-3",g?"w-full":"rounded-lg",L[t],f),...m,children:[e("div",{className:n("shrink-0 mt-0.5",M[t]),children:o??e(v,{className:"w-5 h-5"})}),l("div",{className:"flex-1 min-w-0",children:[r&&e("div",{className:"font-semibold text-sm",children:r}),w&&e("div",{className:n("text-sm",r?"mt-1 opacity-90":!1),children:w}),a&&e("div",{className:"mt-3",children:a})]}),c&&e("button",{type:"button",onClick:i,className:n("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":"Close banner",children:e(h,{className:"w-4 h-4"})})]})}function I({title:t,description:r,children:d,action:s,backgroundImage:o,closable:a=!1,onClose:c,fullWidth:u=!1,className:g,...f}){let[m,b]=x(!0);if(!m)return null;let p=()=>{b(!1),c?.()},i=d??r;return l("div",{className:n("relative overflow-hidden bg-gray-900 text-white",u?"w-full":"rounded-xl","py-12 px-6 sm:px-12",g),style:o?{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...f,children:[o&&e("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),l("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&e("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),i&&e("div",{className:n("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:i}),s&&e("div",{className:"mt-6",children:s})]}),a&&e("button",{type:"button",onClick:p,className:n("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:e(h,{className:"w-5 h-5"})})]})}function P({title:t,description:r,children:d,icon:s,action:o,badge:a,closable:c=!1,onClose:u,fullWidth:g=!1,className:f,...m}){let[b,p]=x(!0);if(!b)return null;let i=()=>{p(!1),u?.()},v=d??r;return l("div",{className:n("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",g?"w-full":"rounded-lg",f),...m,children:[s&&e("div",{className:"shrink-0",children:s}),a&&e("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),l("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&e("span",{className:"font-semibold text-sm",children:t}),v&&e("span",{className:"text-sm opacity-90",children:v})]}),o&&e("div",{className:"shrink-0",children:o}),c&&e("button",{type:"button",onClick:i,className:n("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":"Close banner",children:e(h,{className:"w-4 h-4"})})]})}function W({variant:t="notification",...r}){switch(t){case"hero":return e(I,{...r});case"promotion":return e(P,{...r});default:return e(R,{...r})}}W.displayName="Banner";export{W as Banner};
1
+ "use client";import{useState as w}from"react";import{cn as n}from"../../lib/cn.js";import{useUILabels as k}from"../../lib/i18n.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";function y({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function B({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function L({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function M({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function C({className:t}){return e("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var I={info:y,success:B,warning:L,error:M,default:y},R={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},P={info:"text-blue-600 dark:text-blue-400",success:"text-green-600 dark:text-green-400",warning:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function W({type:t="default",title:r,description:d,children:s,icon:o,action:a,closable:c=!1,closeLabel:u,onClose:g,fullWidth:b=!1,className:m,...f}){let[p,v]=w(!0),x=k();if(!p)return null;let i=()=>{v(!1),g?.()},h=I[t],N=s??d;return l("div",{role:"alert",className:n("flex items-start gap-3 border px-4 py-3",b?"w-full":"rounded-lg",R[t],m),...f,children:[e("div",{className:n("shrink-0 mt-0.5",P[t]),children:o??e(h,{className:"w-5 h-5"})}),l("div",{className:"flex-1 min-w-0",children:[r&&e("div",{className:"font-semibold text-sm",children:r}),N&&e("div",{className:n("text-sm",r?"mt-1 opacity-90":!1),children:N}),a&&e("div",{className:"mt-3",children:a})]}),c&&e("button",{type:"button",onClick:i,className:n("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":u??x.bannerClose,children:e(C,{className:"w-4 h-4"})})]})}function V({title:t,description:r,children:d,action:s,backgroundImage:o,closable:a=!1,closeLabel:c,onClose:u,fullWidth:g=!1,className:b,...m}){let[f,p]=w(!0),v=k();if(!f)return null;let x=()=>{p(!1),u?.()},i=d??r;return l("div",{className:n("relative overflow-hidden bg-gray-900 text-white",g?"w-full":"rounded-xl","py-12 px-6 sm:px-12",b),style:o?{backgroundImage:`url(${o})`,backgroundSize:"cover",backgroundPosition:"center"}:void 0,...m,children:[o&&e("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),l("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&e("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),i&&e("div",{className:n("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:i}),s&&e("div",{className:"mt-6",children:s})]}),a&&e("button",{type:"button",onClick:x,className:n("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":c??v.bannerClose,children:e(C,{className:"w-5 h-5"})})]})}function H({title:t,description:r,children:d,icon:s,action:o,badge:a,closable:c=!1,closeLabel:u,onClose:g,fullWidth:b=!1,className:m,...f}){let[p,v]=w(!0),x=k();if(!p)return null;let i=()=>{v(!1),g?.()},h=d??r;return l("div",{className:n("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",b?"w-full":"rounded-lg",m),...f,children:[s&&e("div",{className:"shrink-0",children:s}),a&&e("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:a}),l("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&e("span",{className:"font-semibold text-sm",children:t}),h&&e("span",{className:"text-sm opacity-90",children:h})]}),o&&e("div",{className:"shrink-0",children:o}),c&&e("button",{type:"button",onClick:i,className:n("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":u??x.bannerClose,children:e(C,{className:"w-4 h-4"})})]})}function T({variant:t="notification",...r}){switch(t){case"hero":return e(V,{...r});case"promotion":return e(H,{...r});default:return e(W,{...r})}}T.displayName="Banner";export{T as Banner};