@spark-ui/components 10.0.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 (296) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +19 -0
  4. package/dist/DialogTrigger-5SI4dvpK.d.mts +142 -0
  5. package/dist/DialogTrigger-5SI4dvpK.d.ts +142 -0
  6. package/dist/Input-g0LpWuv0.d.mts +17 -0
  7. package/dist/Input-g0LpWuv0.d.ts +17 -0
  8. package/dist/InputGroup-aoaZxCLk.d.mts +28 -0
  9. package/dist/InputGroup-aoaZxCLk.d.ts +28 -0
  10. package/dist/InputTrailingIcon-BBp7sE6D.d.mts +20 -0
  11. package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +20 -0
  12. package/dist/LabelRequiredIndicator-DRnCzHMU.d.mts +19 -0
  13. package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +19 -0
  14. package/dist/accordion/index.d.mts +85 -0
  15. package/dist/accordion/index.d.ts +85 -0
  16. package/dist/accordion/index.js +461 -0
  17. package/dist/accordion/index.js.map +1 -0
  18. package/dist/accordion/index.mjs +249 -0
  19. package/dist/accordion/index.mjs.map +1 -0
  20. package/dist/alert-dialog/index.d.mts +119 -0
  21. package/dist/alert-dialog/index.d.ts +119 -0
  22. package/dist/alert-dialog/index.js +1451 -0
  23. package/dist/alert-dialog/index.js.map +1 -0
  24. package/dist/alert-dialog/index.mjs +177 -0
  25. package/dist/alert-dialog/index.mjs.map +1 -0
  26. package/dist/badge/index.d.mts +47 -0
  27. package/dist/badge/index.d.ts +47 -0
  28. package/dist/badge/index.js +122 -0
  29. package/dist/badge/index.js.map +1 -0
  30. package/dist/badge/index.mjs +95 -0
  31. package/dist/badge/index.mjs.map +1 -0
  32. package/dist/breadcrumb/index.d.mts +64 -0
  33. package/dist/breadcrumb/index.d.ts +64 -0
  34. package/dist/breadcrumb/index.js +326 -0
  35. package/dist/breadcrumb/index.js.map +1 -0
  36. package/dist/breadcrumb/index.mjs +149 -0
  37. package/dist/breadcrumb/index.mjs.map +1 -0
  38. package/dist/button/index.d.mts +40 -0
  39. package/dist/button/index.d.ts +40 -0
  40. package/dist/button/index.js +877 -0
  41. package/dist/button/index.js.map +1 -0
  42. package/dist/button/index.mjs +10 -0
  43. package/dist/button/index.mjs.map +1 -0
  44. package/dist/carousel/index.d.mts +253 -0
  45. package/dist/carousel/index.d.ts +253 -0
  46. package/dist/carousel/index.js +1678 -0
  47. package/dist/carousel/index.js.map +1 -0
  48. package/dist/carousel/index.mjs +716 -0
  49. package/dist/carousel/index.mjs.map +1 -0
  50. package/dist/checkbox/index.d.mts +120 -0
  51. package/dist/checkbox/index.d.ts +120 -0
  52. package/dist/checkbox/index.js +873 -0
  53. package/dist/checkbox/index.js.map +1 -0
  54. package/dist/checkbox/index.mjs +349 -0
  55. package/dist/checkbox/index.mjs.map +1 -0
  56. package/dist/chip/index.d.mts +97 -0
  57. package/dist/chip/index.d.ts +97 -0
  58. package/dist/chip/index.js +905 -0
  59. package/dist/chip/index.js.map +1 -0
  60. package/dist/chip/index.mjs +793 -0
  61. package/dist/chip/index.mjs.map +1 -0
  62. package/dist/chunk-2KPFQEAA.mjs +52 -0
  63. package/dist/chunk-2KPFQEAA.mjs.map +1 -0
  64. package/dist/chunk-4F5DOL57.mjs +26 -0
  65. package/dist/chunk-4F5DOL57.mjs.map +1 -0
  66. package/dist/chunk-6JOA37TZ.mjs +742 -0
  67. package/dist/chunk-6JOA37TZ.mjs.map +1 -0
  68. package/dist/chunk-7PMPYEHJ.mjs +379 -0
  69. package/dist/chunk-7PMPYEHJ.mjs.map +1 -0
  70. package/dist/chunk-AESXFMCC.mjs +68 -0
  71. package/dist/chunk-AESXFMCC.mjs.map +1 -0
  72. package/dist/chunk-B42LOFIZ.mjs +308 -0
  73. package/dist/chunk-B42LOFIZ.mjs.map +1 -0
  74. package/dist/chunk-FGOZHKBT.mjs +97 -0
  75. package/dist/chunk-FGOZHKBT.mjs.map +1 -0
  76. package/dist/chunk-HLXYG643.mjs +52 -0
  77. package/dist/chunk-HLXYG643.mjs.map +1 -0
  78. package/dist/chunk-JKNBJHD5.mjs +601 -0
  79. package/dist/chunk-JKNBJHD5.mjs.map +1 -0
  80. package/dist/chunk-K7VP7DH3.mjs +66 -0
  81. package/dist/chunk-K7VP7DH3.mjs.map +1 -0
  82. package/dist/chunk-MUNDKRAE.mjs +80 -0
  83. package/dist/chunk-MUNDKRAE.mjs.map +1 -0
  84. package/dist/chunk-NBZKMCHF.mjs +36 -0
  85. package/dist/chunk-NBZKMCHF.mjs.map +1 -0
  86. package/dist/chunk-PZWESKAR.mjs +314 -0
  87. package/dist/chunk-PZWESKAR.mjs.map +1 -0
  88. package/dist/collapsible/index.d.mts +60 -0
  89. package/dist/collapsible/index.d.ts +60 -0
  90. package/dist/collapsible/index.js +140 -0
  91. package/dist/collapsible/index.js.map +1 -0
  92. package/dist/collapsible/index.mjs +8 -0
  93. package/dist/collapsible/index.mjs.map +1 -0
  94. package/dist/combobox/index.d.mts +285 -0
  95. package/dist/combobox/index.d.ts +285 -0
  96. package/dist/combobox/index.js +2920 -0
  97. package/dist/combobox/index.js.map +1 -0
  98. package/dist/combobox/index.mjs +1267 -0
  99. package/dist/combobox/index.mjs.map +1 -0
  100. package/dist/dialog/index.d.mts +33 -0
  101. package/dist/dialog/index.d.ts +33 -0
  102. package/dist/dialog/index.js +1286 -0
  103. package/dist/dialog/index.js.map +1 -0
  104. package/dist/dialog/index.mjs +13 -0
  105. package/dist/dialog/index.mjs.map +1 -0
  106. package/dist/divider/index.d.mts +61 -0
  107. package/dist/divider/index.d.ts +61 -0
  108. package/dist/divider/index.js +223 -0
  109. package/dist/divider/index.js.map +1 -0
  110. package/dist/divider/index.mjs +196 -0
  111. package/dist/divider/index.mjs.map +1 -0
  112. package/dist/drawer/index.d.mts +148 -0
  113. package/dist/drawer/index.d.ts +148 -0
  114. package/dist/drawer/index.js +1266 -0
  115. package/dist/drawer/index.js.map +1 -0
  116. package/dist/drawer/index.mjs +299 -0
  117. package/dist/drawer/index.mjs.map +1 -0
  118. package/dist/dropdown/index.d.mts +233 -0
  119. package/dist/dropdown/index.d.ts +233 -0
  120. package/dist/dropdown/index.js +2402 -0
  121. package/dist/dropdown/index.js.map +1 -0
  122. package/dist/dropdown/index.mjs +741 -0
  123. package/dist/dropdown/index.mjs.map +1 -0
  124. package/dist/form-field/index.d.mts +176 -0
  125. package/dist/form-field/index.d.ts +176 -0
  126. package/dist/form-field/index.js +540 -0
  127. package/dist/form-field/index.js.map +1 -0
  128. package/dist/form-field/index.mjs +13 -0
  129. package/dist/form-field/index.mjs.map +1 -0
  130. package/dist/icon/index.d.mts +28 -0
  131. package/dist/icon/index.d.ts +28 -0
  132. package/dist/icon/index.js +127 -0
  133. package/dist/icon/index.js.map +1 -0
  134. package/dist/icon/index.mjs +9 -0
  135. package/dist/icon/index.mjs.map +1 -0
  136. package/dist/icon-button/index.d.mts +16 -0
  137. package/dist/icon-button/index.d.ts +16 -0
  138. package/dist/icon-button/index.js +921 -0
  139. package/dist/icon-button/index.js.map +1 -0
  140. package/dist/icon-button/index.mjs +11 -0
  141. package/dist/icon-button/index.mjs.map +1 -0
  142. package/dist/input/index.d.mts +78 -0
  143. package/dist/input/index.d.ts +78 -0
  144. package/dist/input/index.js +1119 -0
  145. package/dist/input/index.js.map +1 -0
  146. package/dist/input/index.mjs +16 -0
  147. package/dist/input/index.mjs.map +1 -0
  148. package/dist/kbd/index.d.mts +9 -0
  149. package/dist/kbd/index.d.ts +9 -0
  150. package/dist/kbd/index.js +46 -0
  151. package/dist/kbd/index.js.map +1 -0
  152. package/dist/kbd/index.mjs +19 -0
  153. package/dist/kbd/index.mjs.map +1 -0
  154. package/dist/label/index.d.mts +11 -0
  155. package/dist/label/index.d.ts +11 -0
  156. package/dist/label/index.js +78 -0
  157. package/dist/label/index.js.map +1 -0
  158. package/dist/label/index.mjs +7 -0
  159. package/dist/label/index.mjs.map +1 -0
  160. package/dist/link-box/index.d.mts +34 -0
  161. package/dist/link-box/index.d.ts +34 -0
  162. package/dist/link-box/index.js +92 -0
  163. package/dist/link-box/index.js.map +1 -0
  164. package/dist/link-box/index.mjs +58 -0
  165. package/dist/link-box/index.mjs.map +1 -0
  166. package/dist/pagination/index.d.mts +143 -0
  167. package/dist/pagination/index.d.ts +143 -0
  168. package/dist/pagination/index.js +1303 -0
  169. package/dist/pagination/index.js.map +1 -0
  170. package/dist/pagination/index.mjs +326 -0
  171. package/dist/pagination/index.mjs.map +1 -0
  172. package/dist/popover/index.d.mts +93 -0
  173. package/dist/popover/index.d.ts +93 -0
  174. package/dist/popover/index.js +1280 -0
  175. package/dist/popover/index.js.map +1 -0
  176. package/dist/popover/index.mjs +13 -0
  177. package/dist/popover/index.mjs.map +1 -0
  178. package/dist/portal/index.d.mts +13 -0
  179. package/dist/portal/index.d.ts +13 -0
  180. package/dist/portal/index.js +37 -0
  181. package/dist/portal/index.js.map +1 -0
  182. package/dist/portal/index.mjs +10 -0
  183. package/dist/portal/index.mjs.map +1 -0
  184. package/dist/progress/index.d.mts +48 -0
  185. package/dist/progress/index.d.ts +48 -0
  186. package/dist/progress/index.js +201 -0
  187. package/dist/progress/index.js.map +1 -0
  188. package/dist/progress/index.mjs +174 -0
  189. package/dist/progress/index.mjs.map +1 -0
  190. package/dist/progress-tracker/index.d.mts +81 -0
  191. package/dist/progress-tracker/index.d.ts +81 -0
  192. package/dist/progress-tracker/index.js +834 -0
  193. package/dist/progress-tracker/index.js.map +1 -0
  194. package/dist/progress-tracker/index.mjs +716 -0
  195. package/dist/progress-tracker/index.mjs.map +1 -0
  196. package/dist/radio-group/index.d.mts +100 -0
  197. package/dist/radio-group/index.d.ts +100 -0
  198. package/dist/radio-group/index.js +824 -0
  199. package/dist/radio-group/index.js.map +1 -0
  200. package/dist/radio-group/index.mjs +297 -0
  201. package/dist/radio-group/index.mjs.map +1 -0
  202. package/dist/rating/index.d.mts +78 -0
  203. package/dist/rating/index.d.ts +78 -0
  204. package/dist/rating/index.js +362 -0
  205. package/dist/rating/index.js.map +1 -0
  206. package/dist/rating/index.mjs +247 -0
  207. package/dist/rating/index.mjs.map +1 -0
  208. package/dist/scrolling-list/index.d.mts +105 -0
  209. package/dist/scrolling-list/index.d.ts +105 -0
  210. package/dist/scrolling-list/index.js +1367 -0
  211. package/dist/scrolling-list/index.js.map +1 -0
  212. package/dist/scrolling-list/index.mjs +407 -0
  213. package/dist/scrolling-list/index.mjs.map +1 -0
  214. package/dist/select/index.d.mts +167 -0
  215. package/dist/select/index.d.ts +167 -0
  216. package/dist/select/index.js +991 -0
  217. package/dist/select/index.js.map +1 -0
  218. package/dist/select/index.mjs +470 -0
  219. package/dist/select/index.mjs.map +1 -0
  220. package/dist/skeleton/index.d.mts +67 -0
  221. package/dist/skeleton/index.d.ts +67 -0
  222. package/dist/skeleton/index.js +206 -0
  223. package/dist/skeleton/index.js.map +1 -0
  224. package/dist/skeleton/index.mjs +147 -0
  225. package/dist/skeleton/index.mjs.map +1 -0
  226. package/dist/slider/index.d.mts +97 -0
  227. package/dist/slider/index.d.ts +97 -0
  228. package/dist/slider/index.js +209 -0
  229. package/dist/slider/index.js.map +1 -0
  230. package/dist/slider/index.mjs +182 -0
  231. package/dist/slider/index.mjs.map +1 -0
  232. package/dist/slot/index.d.mts +17 -0
  233. package/dist/slot/index.d.ts +17 -0
  234. package/dist/slot/index.js +51 -0
  235. package/dist/slot/index.js.map +1 -0
  236. package/dist/slot/index.mjs +11 -0
  237. package/dist/slot/index.mjs.map +1 -0
  238. package/dist/snackbar/index.d.mts +158 -0
  239. package/dist/snackbar/index.d.ts +158 -0
  240. package/dist/snackbar/index.js +1693 -0
  241. package/dist/snackbar/index.js.map +1 -0
  242. package/dist/snackbar/index.mjs +733 -0
  243. package/dist/snackbar/index.mjs.map +1 -0
  244. package/dist/spinner/index.d.mts +21 -0
  245. package/dist/spinner/index.d.ts +21 -0
  246. package/dist/spinner/index.js +139 -0
  247. package/dist/spinner/index.js.map +1 -0
  248. package/dist/spinner/index.mjs +9 -0
  249. package/dist/spinner/index.mjs.map +1 -0
  250. package/dist/stepper/index.d.mts +82 -0
  251. package/dist/stepper/index.d.ts +82 -0
  252. package/dist/stepper/index.js +2178 -0
  253. package/dist/stepper/index.js.map +1 -0
  254. package/dist/stepper/index.mjs +229 -0
  255. package/dist/stepper/index.mjs.map +1 -0
  256. package/dist/switch/index.d.mts +64 -0
  257. package/dist/switch/index.d.ts +64 -0
  258. package/dist/switch/index.js +768 -0
  259. package/dist/switch/index.js.map +1 -0
  260. package/dist/switch/index.mjs +245 -0
  261. package/dist/switch/index.mjs.map +1 -0
  262. package/dist/tabs/index.d.mts +103 -0
  263. package/dist/tabs/index.d.ts +103 -0
  264. package/dist/tabs/index.js +1315 -0
  265. package/dist/tabs/index.js.map +1 -0
  266. package/dist/tabs/index.mjs +391 -0
  267. package/dist/tabs/index.mjs.map +1 -0
  268. package/dist/tag/index.d.mts +27 -0
  269. package/dist/tag/index.d.ts +27 -0
  270. package/dist/tag/index.js +269 -0
  271. package/dist/tag/index.js.map +1 -0
  272. package/dist/tag/index.mjs +237 -0
  273. package/dist/tag/index.mjs.map +1 -0
  274. package/dist/text-link/index.d.mts +20 -0
  275. package/dist/text-link/index.d.ts +20 -0
  276. package/dist/text-link/index.js +99 -0
  277. package/dist/text-link/index.js.map +1 -0
  278. package/dist/text-link/index.mjs +8 -0
  279. package/dist/text-link/index.mjs.map +1 -0
  280. package/dist/textarea/index.d.mts +47 -0
  281. package/dist/textarea/index.d.ts +47 -0
  282. package/dist/textarea/index.js +1180 -0
  283. package/dist/textarea/index.js.map +1 -0
  284. package/dist/textarea/index.mjs +77 -0
  285. package/dist/textarea/index.mjs.map +1 -0
  286. package/dist/visually-hidden/index.d.mts +16 -0
  287. package/dist/visually-hidden/index.d.ts +16 -0
  288. package/dist/visually-hidden/index.js +67 -0
  289. package/dist/visually-hidden/index.js.map +1 -0
  290. package/dist/visually-hidden/index.mjs +8 -0
  291. package/dist/visually-hidden/index.mjs.map +1 -0
  292. package/global.d.ts +12 -0
  293. package/package.json +75 -0
  294. package/tsconfig.build.json +9 -0
  295. package/tsconfig.json +9 -0
  296. package/tsup.config.ts +11 -0
@@ -0,0 +1,733 @@
1
+ import {
2
+ IconButton
3
+ } from "../chunk-2KPFQEAA.mjs";
4
+ import {
5
+ Button
6
+ } from "../chunk-6JOA37TZ.mjs";
7
+ import "../chunk-MUNDKRAE.mjs";
8
+ import {
9
+ Icon
10
+ } from "../chunk-AESXFMCC.mjs";
11
+ import "../chunk-NBZKMCHF.mjs";
12
+ import "../chunk-4F5DOL57.mjs";
13
+
14
+ // src/snackbar/Snackbar.tsx
15
+ import {
16
+ ToastQueue,
17
+ useToastQueue
18
+ } from "@react-stately/toast";
19
+ import { useEffect as useEffect2, useRef as useRef4 } from "react";
20
+ import { createPortal } from "react-dom";
21
+
22
+ // src/snackbar/SnackbarRegion.tsx
23
+ import { useToastRegion } from "@react-aria/toast";
24
+ import { cloneElement as cloneElement2, useRef as useRef3 } from "react";
25
+
26
+ // src/snackbar/SnackbarItem.tsx
27
+ import { useToast } from "@react-aria/toast";
28
+ import {
29
+ Children,
30
+ cloneElement,
31
+ isValidElement,
32
+ useCallback,
33
+ useRef as useRef2
34
+ } from "react";
35
+
36
+ // src/snackbar/SnackbarItem.styles.ts
37
+ import { cva } from "class-variance-authority";
38
+
39
+ // src/snackbar/snackbarVariants.ts
40
+ var filledVariants = [
41
+ {
42
+ design: "filled",
43
+ intent: "success",
44
+ class: ["bg-success text-on-success"]
45
+ },
46
+ {
47
+ design: "filled",
48
+ intent: "alert",
49
+ class: ["bg-alert text-on-alert"]
50
+ },
51
+ {
52
+ design: "filled",
53
+ intent: "error",
54
+ class: ["bg-error text-on-error"]
55
+ },
56
+ {
57
+ design: "filled",
58
+ intent: "info",
59
+ class: ["bg-info text-on-info"]
60
+ },
61
+ {
62
+ design: "filled",
63
+ intent: "neutral",
64
+ class: ["bg-neutral text-on-neutral"]
65
+ },
66
+ {
67
+ design: "filled",
68
+ intent: "main",
69
+ class: ["bg-main text-on-main"]
70
+ },
71
+ {
72
+ design: "filled",
73
+ intent: "basic",
74
+ class: ["bg-basic text-on-basic"]
75
+ },
76
+ {
77
+ design: "filled",
78
+ intent: "support",
79
+ class: ["bg-support text-on-support"]
80
+ },
81
+ {
82
+ design: "filled",
83
+ intent: "accent",
84
+ class: ["bg-accent text-on-accent"]
85
+ },
86
+ {
87
+ design: "filled",
88
+ intent: "inverse",
89
+ class: ["bg-surface-inverse text-on-surface-inverse"]
90
+ }
91
+ ];
92
+ var tintedVariants = [
93
+ {
94
+ design: "tinted",
95
+ intent: "success",
96
+ class: ["bg-success-container text-on-success-container"]
97
+ },
98
+ {
99
+ design: "tinted",
100
+ intent: "alert",
101
+ class: ["bg-alert-container text-on-alert-container"]
102
+ },
103
+ {
104
+ design: "tinted",
105
+ intent: "error",
106
+ class: ["bg-error-container text-on-error-container"]
107
+ },
108
+ {
109
+ design: "tinted",
110
+ intent: "info",
111
+ class: ["bg-info-container text-on-info-container"]
112
+ },
113
+ {
114
+ design: "tinted",
115
+ intent: "neutral",
116
+ class: ["bg-neutral-container text-on-neutral-container"]
117
+ },
118
+ {
119
+ design: "tinted",
120
+ intent: "main",
121
+ class: ["bg-main-container text-on-main-container"]
122
+ },
123
+ {
124
+ design: "tinted",
125
+ intent: "basic",
126
+ class: ["bg-basic-container text-on-basic-container"]
127
+ },
128
+ {
129
+ design: "tinted",
130
+ intent: "support",
131
+ class: ["bg-support-container text-on-support-container"]
132
+ },
133
+ {
134
+ design: "tinted",
135
+ intent: "accent",
136
+ class: ["bg-accent-container text-on-accent-container"]
137
+ },
138
+ {
139
+ design: "tinted",
140
+ intent: "inverse",
141
+ class: ["bg-surface-inverse text-on-surface-inverse"]
142
+ }
143
+ ];
144
+
145
+ // src/snackbar/SnackbarItem.styles.ts
146
+ var snackbarItemVariant = cva(
147
+ [
148
+ "rounded-md shadow-sm",
149
+ "max-w-[600px]",
150
+ "cursor-default pointer-events-auto touch-none select-none",
151
+ "absolute",
152
+ /**
153
+ * Focus
154
+ */
155
+ "group-focus-visible:outline-hidden group-focus-visible:u-outline group-not-focus-visible:ring-inset",
156
+ /**
157
+ * Positionning
158
+ */
159
+ "group-data-[position=bottom]:bottom-0 group-data-[position=bottom-left]:bottom-0 group-data-[position=bottom-right]:bottom-0",
160
+ "group-data-[position=top]:top-0 group-data-[position=top-left]:top-0 group-data-[position=top-right]:top-0",
161
+ /**
162
+ * Animation and opacity
163
+ */
164
+ "[animation-fill-mode: forwards]!",
165
+ "data-[animation=queued]:animate-fade-in",
166
+ "data-[animation=entering]:easing-decelerate-back",
167
+ "data-[animation=exiting]:easing-standard",
168
+ // Parent position bottom|bottom-left|bottom-right
169
+ "data-[animation=entering]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-in-bottom",
170
+ "data-[animation=exiting]:opacity-0 data-[animation=exiting]:transition-opacity",
171
+ "data-[animation=exiting]:group-data-[position=bottom]:[&:not([data-swipe])]:animate-slide-out-bottom",
172
+ "data-[animation=entering]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-in-bottom",
173
+ "data-[animation=exiting]:group-data-[position=bottom-left]:[&:not([data-swipe])]:animate-slide-out-bottom",
174
+ "data-[animation=entering]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-in-bottom",
175
+ "data-[animation=exiting]:group-data-[position=bottom-right]:[&:not([data-swipe])]:animate-slide-out-bottom",
176
+ // Parent position top|top-left|top-right
177
+ "data-[animation=entering]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-in-top",
178
+ "data-[animation=exiting]:group-data-[position=top]:[&:not([data-swipe])]:animate-slide-out-top",
179
+ "data-[animation=entering]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-in-top",
180
+ "data-[animation=exiting]:group-data-[position=top-left]:[&:not([data-swipe])]:animate-slide-out-top",
181
+ "data-[animation=entering]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-in-top",
182
+ "data-[animation=exiting]:group-data-[position=top-right]:[&:not([data-swipe])]:animate-slide-out-top",
183
+ /**
184
+ * Swipe
185
+ */
186
+ "data-[swipe=move]:data-[swipe-direction=right]:translate-x-(--swipe-position-x)",
187
+ "data-[swipe=move]:data-[swipe-direction=left]:translate-x-(--swipe-position-x)",
188
+ "data-[swipe=cancel]:translate-x-0",
189
+ "data-[swipe=end]:data-[swipe-direction=right]:animate-standalone-swipe-out-right",
190
+ "data-[swipe=end]:data-[swipe-direction=left]:animate-standalone-swipe-out-left"
191
+ ],
192
+ {
193
+ variants: {
194
+ /**
195
+ * Set different look and feel
196
+ * @default 'filled'
197
+ */
198
+ design: {
199
+ filled: "",
200
+ tinted: ""
201
+ },
202
+ /**
203
+ * Set color intent
204
+ * @default 'neutral'
205
+ */
206
+ intent: {
207
+ success: "",
208
+ alert: "",
209
+ error: "",
210
+ info: "",
211
+ neutral: "",
212
+ main: "",
213
+ basic: "",
214
+ support: "",
215
+ accent: "",
216
+ inverse: ""
217
+ }
218
+ },
219
+ compoundVariants: [...filledVariants, ...tintedVariants],
220
+ defaultVariants: {
221
+ design: "filled",
222
+ intent: "neutral"
223
+ }
224
+ }
225
+ );
226
+ var snackbarItemVariantContent = cva(
227
+ [
228
+ "inline-grid items-center",
229
+ "col-start-1 row-start-1",
230
+ "px-md"
231
+ // applying padding on the parent prevents VoiceOver on Safari from reading snackbar content 🤷
232
+ ],
233
+ {
234
+ variants: {
235
+ /**
236
+ * Force action button displaying on a new line
237
+ * @default false
238
+ */
239
+ actionOnNewline: {
240
+ true: [
241
+ "grid-rows-[52px_1fr_52px]",
242
+ "grid-cols-[min-content_1fr_min-content]",
243
+ "[grid-template-areas:'icon_message_close'_'._message_.'_'action_action_action']"
244
+ ],
245
+ false: [
246
+ "grid-cols-[min-content_1fr_min-content_min-content]",
247
+ "[grid-template-areas:'icon_message_action_close']"
248
+ ]
249
+ }
250
+ },
251
+ defaultVariants: {
252
+ actionOnNewline: false
253
+ }
254
+ }
255
+ );
256
+
257
+ // src/snackbar/SnackbarItemAction.tsx
258
+ import { cx } from "class-variance-authority";
259
+
260
+ // src/snackbar/SnackbarItemContext.tsx
261
+ import { createContext, useContext } from "react";
262
+ var SnackbarItemContext = createContext({});
263
+ var useSnackbarItemContext = () => useContext(SnackbarItemContext);
264
+
265
+ // src/snackbar/SnackbarItemAction.tsx
266
+ import { jsx } from "react/jsx-runtime";
267
+ var SnackbarItemAction = ({
268
+ design: designProp = "filled",
269
+ intent: intentProp = "neutral",
270
+ onClick,
271
+ children,
272
+ className,
273
+ ref,
274
+ ...rest
275
+ }) => {
276
+ const { toast, state } = useSnackbarItemContext();
277
+ const intent = intentProp ?? toast.content.intent;
278
+ const design = designProp ?? toast.content.design;
279
+ return /* @__PURE__ */ jsx(
280
+ Button,
281
+ {
282
+ ref,
283
+ size: "md",
284
+ shape: "rounded",
285
+ ...intent === "inverse" ? {
286
+ design: "ghost",
287
+ intent: "surface"
288
+ } : {
289
+ design,
290
+ intent: intent === "error" ? "danger" : intent
291
+ },
292
+ onClick: (e) => {
293
+ onClick?.(e);
294
+ state.close(toast.key);
295
+ },
296
+ style: { gridArea: "action", ...rest.style },
297
+ className: cx("ml-md justify-self-end", className),
298
+ ...rest,
299
+ children
300
+ }
301
+ );
302
+ };
303
+ SnackbarItemAction.displayName = "Snackbar.ItemAction";
304
+
305
+ // src/snackbar/SnackbarItemClose.tsx
306
+ import { Close } from "@spark-ui/icons/Close";
307
+ import { cx as cx2 } from "class-variance-authority";
308
+ import { jsx as jsx2 } from "react/jsx-runtime";
309
+ var SnackbarItemClose = ({
310
+ design: designProp = "filled",
311
+ intent: intentProp = "neutral",
312
+ "aria-label": ariaLabel,
313
+ onClick,
314
+ className,
315
+ ref,
316
+ ...rest
317
+ }) => {
318
+ const { toast, state } = useSnackbarItemContext();
319
+ const intent = intentProp ?? toast.content.intent;
320
+ const design = designProp ?? toast.content.design;
321
+ return /* @__PURE__ */ jsx2(
322
+ IconButton,
323
+ {
324
+ ref,
325
+ size: "md",
326
+ shape: "rounded",
327
+ ...intent === "inverse" ? {
328
+ design: "ghost",
329
+ intent: "surface"
330
+ } : {
331
+ design,
332
+ intent: intent === "error" ? "danger" : intent
333
+ },
334
+ "aria-label": ariaLabel,
335
+ onClick: (e) => {
336
+ onClick?.(e);
337
+ state.close(toast.key);
338
+ },
339
+ style: { gridArea: "close", ...rest.style },
340
+ className: cx2("ml-md justify-self-end", className),
341
+ ...rest,
342
+ children: /* @__PURE__ */ jsx2(Icon, { size: "sm", children: /* @__PURE__ */ jsx2(Close, {}) })
343
+ }
344
+ );
345
+ };
346
+ SnackbarItemClose.displayName = "Snackbar.ItemClose";
347
+
348
+ // src/snackbar/SnackbarItemIcon.tsx
349
+ import { cx as cx3 } from "class-variance-authority";
350
+ import { jsx as jsx3 } from "react/jsx-runtime";
351
+ var SnackbarItemIcon = ({
352
+ children,
353
+ className,
354
+ ...rest
355
+ }) => /* @__PURE__ */ jsx3(
356
+ Icon,
357
+ {
358
+ size: "md",
359
+ className: cx3("mx-md", className),
360
+ style: { gridArea: "icon", ...rest.style },
361
+ ...rest,
362
+ children
363
+ }
364
+ );
365
+ SnackbarItemIcon.displayName = "Snackbar.ItemIcon";
366
+
367
+ // src/snackbar/useSwipe.ts
368
+ import { useEffect, useRef, useState } from "react";
369
+ var SWIPE_THRESHOLD = 75;
370
+ var useSwipe = ({
371
+ swipeRef,
372
+ onSwipeStart,
373
+ onSwipeMove,
374
+ onSwipeCancel,
375
+ onSwipeEnd,
376
+ threshold = 10
377
+ }) => {
378
+ const [state, setState] = useState();
379
+ const direction = useRef(null);
380
+ const origin = useRef(null);
381
+ const delta = useRef(null);
382
+ const handleSwipeStart = (evt) => {
383
+ origin.current = { x: evt.clientX, y: evt.clientY };
384
+ document.addEventListener("selectstart", (e) => e.preventDefault());
385
+ };
386
+ const handleSwipeMove = (evt) => {
387
+ if (!origin.current) return;
388
+ const deltaX = Math.abs(evt.clientX - origin.current.x);
389
+ const deltaY = Math.abs(evt.clientY - origin.current.y);
390
+ let moveState;
391
+ if (deltaX > deltaY && deltaX > threshold) {
392
+ direction.current = evt.clientX > origin.current.x ? "right" : "left";
393
+ } else if (deltaY > threshold) {
394
+ direction.current = evt.clientY > origin.current.y ? "down" : "up";
395
+ }
396
+ if (!direction.current) return;
397
+ if (!delta.current) {
398
+ moveState = "start";
399
+ delta.current = { x: deltaX, y: deltaY };
400
+ onSwipeStart?.({ state: moveState, direction: direction.current });
401
+ } else {
402
+ moveState = "move";
403
+ delta.current = { x: deltaX, y: deltaY };
404
+ swipeRef.current.style.setProperty(
405
+ "--swipe-position-x",
406
+ `${deltaX > deltaY ? evt.clientX - origin.current.x : 0}px`
407
+ );
408
+ swipeRef.current.style.setProperty(
409
+ "--swipe-position-y",
410
+ `${!(deltaX > deltaY) ? evt.clientY - origin.current.y : 0}px`
411
+ );
412
+ onSwipeMove?.({ state: moveState, direction: direction.current });
413
+ }
414
+ setState(moveState);
415
+ };
416
+ const handleSwipeEnd = () => {
417
+ const proxyDelta = delta.current;
418
+ origin.current = null;
419
+ delta.current = null;
420
+ if (proxyDelta) {
421
+ const { x: deltaX, y: deltaY } = proxyDelta;
422
+ let endState;
423
+ if (deltaX > deltaY) {
424
+ if (deltaX > SWIPE_THRESHOLD) {
425
+ endState = "end";
426
+ onSwipeEnd?.({ state: endState, direction: direction.current });
427
+ } else {
428
+ endState = "cancel";
429
+ onSwipeCancel?.({ state: endState, direction: direction.current });
430
+ }
431
+ } else {
432
+ if (deltaY > SWIPE_THRESHOLD) {
433
+ endState = "end";
434
+ onSwipeEnd?.({ state: endState, direction: direction.current });
435
+ } else {
436
+ endState = "cancel";
437
+ onSwipeCancel?.({ state: endState, direction: direction.current });
438
+ }
439
+ }
440
+ setState(endState);
441
+ document.removeEventListener("selectstart", (e) => e.preventDefault());
442
+ }
443
+ };
444
+ useEffect(() => {
445
+ if (!swipeRef.current) return;
446
+ const swipeElement = swipeRef.current;
447
+ swipeElement.addEventListener("pointerdown", handleSwipeStart);
448
+ document.addEventListener("pointermove", handleSwipeMove);
449
+ document.addEventListener("pointerup", handleSwipeEnd);
450
+ return () => {
451
+ swipeElement.removeEventListener("pointerdown", handleSwipeStart);
452
+ document.removeEventListener("pointermove", handleSwipeMove);
453
+ document.removeEventListener("pointerup", handleSwipeEnd);
454
+ };
455
+ }, []);
456
+ return {
457
+ state,
458
+ direction: direction.current
459
+ };
460
+ };
461
+
462
+ // src/snackbar/SnackbarItem.tsx
463
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
464
+ var SnackbarItem = ({
465
+ "aria-label": ariaLabel,
466
+ "aria-labelledby": ariaLabelledby,
467
+ "aria-describedby": ariaDescribedby,
468
+ "aria-details": ariaDetails,
469
+ design: designProp,
470
+ intent: intentProp,
471
+ actionOnNewline: actionOnNewlineProp,
472
+ className,
473
+ children,
474
+ ref: forwardedRef,
475
+ ...rest
476
+ }) => {
477
+ const innerRef = useRef2(null);
478
+ const ref = typeof forwardedRef !== "function" ? forwardedRef || innerRef : innerRef;
479
+ const { toast, state } = useSnackbarItemContext();
480
+ const { state: swipeState, direction: swipeDirection } = useSwipe({
481
+ swipeRef: ref,
482
+ onSwipeStart: state.pauseAll,
483
+ onSwipeCancel: state.resumeAll,
484
+ onSwipeEnd: ({ direction }) => {
485
+ ;
486
+ ["left", "right"].includes(`${direction}`) && state.close(toast.key);
487
+ }
488
+ });
489
+ const { message, icon, isClosable, onAction, actionLabel } = toast.content;
490
+ const intent = intentProp ?? toast.content.intent;
491
+ const design = designProp ?? toast.content.design;
492
+ const actionOnNewline = actionOnNewlineProp ?? toast.content.actionOnNewline;
493
+ const ariaProps = {
494
+ ariaLabel,
495
+ ariaLabelledby,
496
+ ariaDescribedby,
497
+ ariaDetails
498
+ };
499
+ const { toastProps, titleProps, closeButtonProps, contentProps } = useToast(
500
+ { toast, ...ariaProps },
501
+ state,
502
+ ref
503
+ );
504
+ const findElement = useCallback(
505
+ (elementDisplayName) => {
506
+ const childrenArray = Children.toArray(children);
507
+ const match = childrenArray.filter(isValidElement).find(
508
+ (child) => !!child.type.displayName?.includes(
509
+ elementDisplayName
510
+ )
511
+ );
512
+ return match;
513
+ },
514
+ [children]
515
+ );
516
+ const iconFromChildren = findElement("Snackbar.ItemIcon");
517
+ const actionBtnFromChildren = findElement("Snackbar.ItemAction");
518
+ const closeBtnFromChildren = findElement("Snackbar.ItemClose");
519
+ return /* @__PURE__ */ jsx4(
520
+ "div",
521
+ {
522
+ className: snackbarItemVariant({ design, intent, className }),
523
+ "data-animation": toast.animation,
524
+ ...!(swipeState === "cancel" && toast.animation === "exiting") && {
525
+ "data-swipe": swipeState,
526
+ "data-swipe-direction": swipeDirection
527
+ },
528
+ ...toast.animation === "exiting" && {
529
+ // Remove snackbar when the exiting animation completes
530
+ onAnimationEnd: () => state.remove(toast.key)
531
+ },
532
+ ref,
533
+ ...toastProps,
534
+ ...rest,
535
+ children: /* @__PURE__ */ jsxs("div", { className: snackbarItemVariantContent({ actionOnNewline }), ...contentProps, children: [
536
+ renderSubComponent(iconFromChildren, icon ? SnackbarItemIcon : null, {
537
+ children: icon
538
+ }),
539
+ /* @__PURE__ */ jsx4(
540
+ "p",
541
+ {
542
+ className: "px-md py-lg text-body-2 row-span-3",
543
+ style: { gridArea: "message" },
544
+ ...titleProps,
545
+ children: message
546
+ }
547
+ ),
548
+ renderSubComponent(
549
+ actionBtnFromChildren,
550
+ actionLabel && onAction ? SnackbarItemAction : null,
551
+ { intent, design, onClick: onAction, children: actionLabel }
552
+ ),
553
+ renderSubComponent(closeBtnFromChildren, isClosable ? SnackbarItemClose : null, {
554
+ intent,
555
+ design,
556
+ /**
557
+ * React Spectrum typing of aria-label is inaccurate, and aria-label value should never be undefined.
558
+ * See https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/i18n/src/useLocalizedStringFormatter.ts#L40
559
+ */
560
+ "aria-label": closeButtonProps["aria-label"]
561
+ })
562
+ ] })
563
+ }
564
+ );
565
+ };
566
+ SnackbarItem.displayName = "Snackbar.Item";
567
+ var renderSubComponent = (childItem, defaultItem, props) => {
568
+ if (childItem) {
569
+ return cloneElement(childItem, { ...props, ...childItem.props });
570
+ } else if (defaultItem) {
571
+ const Item = defaultItem;
572
+ return /* @__PURE__ */ jsx4(Item, { ...props });
573
+ } else {
574
+ return null;
575
+ }
576
+ };
577
+
578
+ // src/snackbar/SnackbarRegion.styles.ts
579
+ import { cva as cva2 } from "class-variance-authority";
580
+ var snackbarRegionVariant = cva2(
581
+ [
582
+ "fixed inset-x-lg z-toast group",
583
+ "outline-hidden pointer-events-none",
584
+ "grid grid-rows-1 grid-cols-1 gap-lg"
585
+ ],
586
+ {
587
+ variants: {
588
+ /**
589
+ * Set snackbar item position
590
+ * @default 'bottom'
591
+ */
592
+ position: {
593
+ top: "top-lg justify-items-center",
594
+ "top-right": "top-lg justify-items-end",
595
+ "top-left": "top-lg justify-items-start",
596
+ bottom: "bottom-lg justify-items-center",
597
+ "bottom-right": "bottom-lg justify-items-end",
598
+ "bottom-left": "bottom-lg justify-items-start"
599
+ }
600
+ },
601
+ defaultVariants: {
602
+ position: "bottom"
603
+ }
604
+ }
605
+ );
606
+
607
+ // src/snackbar/SnackbarRegion.tsx
608
+ import { jsx as jsx5 } from "react/jsx-runtime";
609
+ var SnackbarRegion = ({
610
+ children = /* @__PURE__ */ jsx5(SnackbarItem, {}),
611
+ state,
612
+ position = "bottom",
613
+ className,
614
+ ref: forwardedRef,
615
+ ...rest
616
+ }) => {
617
+ const innerRef = useRef3(null);
618
+ const ref = forwardedRef && typeof forwardedRef !== "function" ? forwardedRef : innerRef;
619
+ const { regionProps } = useToastRegion(rest, state, ref);
620
+ return /* @__PURE__ */ jsx5(
621
+ "div",
622
+ {
623
+ ...regionProps,
624
+ ref,
625
+ "data-position": position,
626
+ className: snackbarRegionVariant({ position, className }),
627
+ children: state.visibleToasts.map((toast) => /* @__PURE__ */ jsx5(SnackbarItemContext.Provider, { value: { toast, state }, children: cloneElement2(children, { key: toast.key }) }, toast.key))
628
+ }
629
+ );
630
+ };
631
+
632
+ // src/snackbar/useSnackbarGlobalStore.ts
633
+ import { useCallback as useCallback2, useSyncExternalStore } from "react";
634
+ var useSnackbarGlobalStore = ({
635
+ providers,
636
+ subscriptions
637
+ }) => {
638
+ const subscribe = useCallback2(
639
+ (listener) => {
640
+ subscriptions.add(listener);
641
+ return () => subscriptions.delete(listener);
642
+ },
643
+ [subscriptions]
644
+ );
645
+ const getLastSnackbarProvider = useCallback2(() => [...providers].reverse()[0], [providers]);
646
+ const addProvider = useCallback2(
647
+ (provider2) => {
648
+ providers.add(provider2);
649
+ for (const subscribeFn of subscriptions) {
650
+ subscribeFn();
651
+ }
652
+ },
653
+ [providers, subscriptions]
654
+ );
655
+ const deleteProvider = useCallback2(
656
+ (provider2) => {
657
+ providers.delete(provider2);
658
+ for (const subscribeFn of subscriptions) {
659
+ subscribeFn();
660
+ }
661
+ },
662
+ [providers, subscriptions]
663
+ );
664
+ const provider = useSyncExternalStore(subscribe, getLastSnackbarProvider, getLastSnackbarProvider);
665
+ return {
666
+ provider,
667
+ addProvider,
668
+ deleteProvider
669
+ };
670
+ };
671
+
672
+ // src/snackbar/Snackbar.tsx
673
+ import { jsx as jsx6 } from "react/jsx-runtime";
674
+ var GLOBAL_SNACKBAR_QUEUE = null;
675
+ var getGlobalSnackBarQueue = () => {
676
+ if (!GLOBAL_SNACKBAR_QUEUE) {
677
+ GLOBAL_SNACKBAR_QUEUE = new ToastQueue({
678
+ maxVisibleToasts: 1,
679
+ hasExitAnimation: true
680
+ });
681
+ }
682
+ return GLOBAL_SNACKBAR_QUEUE;
683
+ };
684
+ var clearSnackbarQueue = () => {
685
+ GLOBAL_SNACKBAR_QUEUE = null;
686
+ };
687
+ var GLOBAL_SNACKBAR_STORE = {
688
+ providers: /* @__PURE__ */ new Set(),
689
+ subscriptions: /* @__PURE__ */ new Set()
690
+ };
691
+ var Snackbar = ({ ref: forwardedRef, ...props }) => {
692
+ const ref = useRef4(null);
693
+ const state = useToastQueue(getGlobalSnackBarQueue());
694
+ const { provider, addProvider, deleteProvider } = useSnackbarGlobalStore(GLOBAL_SNACKBAR_STORE);
695
+ useEffect2(() => {
696
+ addProvider(ref);
697
+ return () => {
698
+ for (const toast of getGlobalSnackBarQueue().visibleToasts) {
699
+ toast.animation = void 0;
700
+ }
701
+ deleteProvider(ref);
702
+ };
703
+ }, []);
704
+ return ref === provider && state.visibleToasts.length > 0 ? createPortal(/* @__PURE__ */ jsx6(SnackbarRegion, { ref: forwardedRef, state, ...props }), document.body) : null;
705
+ };
706
+ Snackbar.displayName = "Snackbar";
707
+ var addSnackbar = ({ onClose, timeout = 5e3, priority, ...content }) => {
708
+ const queue = getGlobalSnackBarQueue();
709
+ queue.add(content, {
710
+ onClose,
711
+ timeout: timeout && !content.onAction ? Math.max(timeout, 5e3) : void 0,
712
+ priority
713
+ });
714
+ };
715
+
716
+ // src/snackbar/index.ts
717
+ var Snackbar2 = Object.assign(Snackbar, {
718
+ Item: SnackbarItem,
719
+ ItemAction: SnackbarItemAction,
720
+ ItemClose: SnackbarItemClose,
721
+ ItemIcon: SnackbarItemIcon
722
+ });
723
+ Snackbar2.displayName = "Snackbar";
724
+ SnackbarItem.displayName = "Snackbar.Item";
725
+ SnackbarItemAction.displayName = "Snackbar.ItemAction";
726
+ SnackbarItemClose.displayName = "Snackbar.ItemClose";
727
+ SnackbarItemIcon.displayName = "Snackbar.ItemIcon";
728
+ export {
729
+ Snackbar2 as Snackbar,
730
+ addSnackbar,
731
+ clearSnackbarQueue
732
+ };
733
+ //# sourceMappingURL=index.mjs.map