@teamofsilicons/silicon-ui 0.0.0-stage → 0.2.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 (354) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +81 -2
  3. package/check.mjs +236 -0
  4. package/components/accordion/accordion.d.ts +13 -0
  5. package/components/accordion/accordion.js +35 -0
  6. package/components/accordion/accordion.module.css +15 -0
  7. package/components/action-button/action-button.d.ts +11 -0
  8. package/components/action-button/action-button.js +57 -0
  9. package/components/action-button/action-button.module.css +15 -0
  10. package/components/activity-heatmap/activity-heatmap.d.ts +37 -0
  11. package/components/activity-heatmap/activity-heatmap.js +303 -0
  12. package/components/activity-heatmap/activity-heatmap.module.css +83 -0
  13. package/components/alert/alert.d.ts +13 -0
  14. package/components/alert/alert.js +79 -0
  15. package/components/alert/alert.module.css +15 -0
  16. package/components/animated-counter/animated-counter.d.ts +13 -0
  17. package/components/animated-counter/animated-counter.js +73 -0
  18. package/components/animated-counter/animated-counter.module.css +12 -0
  19. package/components/announcement-bar/announcement-bar.d.ts +53 -0
  20. package/components/announcement-bar/announcement-bar.js +187 -0
  21. package/components/announcement-bar/announcement-bar.module.css +60 -0
  22. package/components/avatar/avatar.d.ts +8 -0
  23. package/components/avatar/avatar.js +18 -0
  24. package/components/avatar/avatar.module.css +60 -0
  25. package/components/avatar-group/avatar-group.d.ts +13 -0
  26. package/components/avatar-group/avatar-group.js +24 -0
  27. package/components/avatar-group/avatar-group.module.css +27 -0
  28. package/components/badge/badge.d.ts +10 -0
  29. package/components/badge/badge.js +66 -0
  30. package/components/badge/badge.module.css +52 -0
  31. package/components/bar-chart/bar-chart.d.ts +32 -0
  32. package/components/bar-chart/bar-chart.js +327 -0
  33. package/components/bar-chart/bar-chart.module.css +49 -0
  34. package/components/billing-toggle/billing-toggle.d.ts +35 -0
  35. package/components/billing-toggle/billing-toggle.js +83 -0
  36. package/components/billing-toggle/billing-toggle.module.css +139 -0
  37. package/components/bottom-sheet/bottom-sheet.d.ts +27 -0
  38. package/components/bottom-sheet/bottom-sheet.js +386 -0
  39. package/components/bottom-sheet/bottom-sheet.module.css +69 -0
  40. package/components/breadcrumb/breadcrumb.d.ts +13 -0
  41. package/components/breadcrumb/breadcrumb.js +19 -0
  42. package/components/breadcrumb/breadcrumb.module.css +12 -0
  43. package/components/brush-chart/brush-chart.d.ts +45 -0
  44. package/components/brush-chart/brush-chart.js +426 -0
  45. package/components/brush-chart/brush-chart.module.css +69 -0
  46. package/components/button/button.d.ts +10 -0
  47. package/components/button/button.js +97 -0
  48. package/components/button/button.module.css +39 -0
  49. package/components/button-group/button-group.d.ts +59 -0
  50. package/components/button-group/button-group.js +280 -0
  51. package/components/button-group/button-group.module.css +87 -0
  52. package/components/button-link/button-link.d.ts +24 -0
  53. package/components/button-link/button-link.js +11 -0
  54. package/components/button-link/button-link.module.css +7 -0
  55. package/components/calendar/calendar.d.ts +22 -0
  56. package/components/calendar/calendar.js +253 -0
  57. package/components/calendar/calendar.module.css +51 -0
  58. package/components/card/card.d.ts +19 -0
  59. package/components/card/card.js +108 -0
  60. package/components/card/card.module.css +51 -0
  61. package/components/card-stack/card-stack.d.ts +34 -0
  62. package/components/card-stack/card-stack.js +291 -0
  63. package/components/card-stack/card-stack.module.css +63 -0
  64. package/components/carousel/carousel.d.ts +28 -0
  65. package/components/carousel/carousel.js +332 -0
  66. package/components/carousel/carousel.module.css +42 -0
  67. package/components/chat-thread/chat-thread.d.ts +135 -0
  68. package/components/chat-thread/chat-thread.js +406 -0
  69. package/components/chat-thread/chat-thread.module.css +242 -0
  70. package/components/checkbox/checkbox.d.ts +7 -0
  71. package/components/checkbox/checkbox.js +23 -0
  72. package/components/checkbox/checkbox.module.css +15 -0
  73. package/components/chip-group/chip-group.d.ts +24 -0
  74. package/components/chip-group/chip-group.js +196 -0
  75. package/components/chip-group/chip-group.module.css +38 -0
  76. package/components/code-block/code-block.d.ts +11 -0
  77. package/components/code-block/code-block.js +133 -0
  78. package/components/code-block/code-block.module.css +43 -0
  79. package/components/color-picker/color-picker.d.ts +40 -0
  80. package/components/color-picker/color-picker.js +449 -0
  81. package/components/color-picker/color-picker.module.css +111 -0
  82. package/components/combobox/combobox.d.ts +19 -0
  83. package/components/combobox/combobox.js +167 -0
  84. package/components/combobox/combobox.module.css +28 -0
  85. package/components/command-palette/command-palette.d.ts +20 -0
  86. package/components/command-palette/command-palette.js +151 -0
  87. package/components/command-palette/command-palette.module.css +94 -0
  88. package/components/comment-thread/comment-thread.d.ts +120 -0
  89. package/components/comment-thread/comment-thread.js +343 -0
  90. package/components/comment-thread/comment-thread.module.css +195 -0
  91. package/components/confirm-morph/confirm-morph.d.ts +65 -0
  92. package/components/confirm-morph/confirm-morph.js +355 -0
  93. package/components/confirm-morph/confirm-morph.module.css +146 -0
  94. package/components/context-menu/context-menu.d.ts +18 -0
  95. package/components/context-menu/context-menu.js +148 -0
  96. package/components/context-menu/context-menu.module.css +17 -0
  97. package/components/copy-button/copy-button.d.ts +10 -0
  98. package/components/copy-button/copy-button.js +69 -0
  99. package/components/copy-button/copy-button.module.css +21 -0
  100. package/components/countdown/countdown.d.ts +31 -0
  101. package/components/countdown/countdown.js +177 -0
  102. package/components/countdown/countdown.module.css +49 -0
  103. package/components/date-picker/date-picker.d.ts +17 -0
  104. package/components/date-picker/date-picker.js +100 -0
  105. package/components/date-picker/date-picker.module.css +34 -0
  106. package/components/date-range-picker/date-range-picker.d.ts +44 -0
  107. package/components/date-range-picker/date-range-picker.js +534 -0
  108. package/components/date-range-picker/date-range-picker.module.css +214 -0
  109. package/components/dialog/dialog.d.ts +11 -0
  110. package/components/dialog/dialog.js +52 -0
  111. package/components/dialog/dialog.module.css +36 -0
  112. package/components/donut-chart/donut-chart.d.ts +46 -0
  113. package/components/donut-chart/donut-chart.js +382 -0
  114. package/components/donut-chart/donut-chart.module.css +48 -0
  115. package/components/drawer/drawer.d.ts +20 -0
  116. package/components/drawer/drawer.js +111 -0
  117. package/components/drawer/drawer.module.css +97 -0
  118. package/components/dropdown-menu/dropdown-menu.d.ts +16 -0
  119. package/components/dropdown-menu/dropdown-menu.js +39 -0
  120. package/components/dropdown-menu/dropdown-menu.module.css +38 -0
  121. package/components/elastic-slider/elastic-slider.d.ts +39 -0
  122. package/components/elastic-slider/elastic-slider.js +261 -0
  123. package/components/elastic-slider/elastic-slider.module.css +40 -0
  124. package/components/empty-state/empty-state.d.ts +12 -0
  125. package/components/empty-state/empty-state.js +69 -0
  126. package/components/empty-state/empty-state.module.css +13 -0
  127. package/components/expandable-card/expandable-card.d.ts +13 -0
  128. package/components/expandable-card/expandable-card.js +89 -0
  129. package/components/expandable-card/expandable-card.module.css +22 -0
  130. package/components/expanding-button-group/expanding-button-group.d.ts +41 -0
  131. package/components/expanding-button-group/expanding-button-group.js +258 -0
  132. package/components/expanding-button-group/expanding-button-group.module.css +44 -0
  133. package/components/expanding-search/expanding-search.d.ts +38 -0
  134. package/components/expanding-search/expanding-search.js +242 -0
  135. package/components/expanding-search/expanding-search.module.css +52 -0
  136. package/components/file-dropzone/file-dropzone.d.ts +44 -0
  137. package/components/file-dropzone/file-dropzone.js +379 -0
  138. package/components/file-dropzone/file-dropzone.module.css +115 -0
  139. package/components/file-upload/file-upload.d.ts +22 -0
  140. package/components/file-upload/file-upload.js +192 -0
  141. package/components/file-upload/file-upload.module.css +49 -0
  142. package/components/filter-toolbar/filter-toolbar.d.ts +48 -0
  143. package/components/filter-toolbar/filter-toolbar.js +446 -0
  144. package/components/filter-toolbar/filter-toolbar.module.css +70 -0
  145. package/components/floating-button-group/floating-button-group.d.ts +51 -0
  146. package/components/floating-button-group/floating-button-group.js +215 -0
  147. package/components/floating-button-group/floating-button-group.module.css +74 -0
  148. package/components/gauge/gauge.d.ts +18 -0
  149. package/components/gauge/gauge.js +101 -0
  150. package/components/gauge/gauge.module.css +22 -0
  151. package/components/hold-to-confirm/hold-to-confirm.d.ts +25 -0
  152. package/components/hold-to-confirm/hold-to-confirm.js +165 -0
  153. package/components/hold-to-confirm/hold-to-confirm.module.css +20 -0
  154. package/components/hover-card/hover-card.d.ts +38 -0
  155. package/components/hover-card/hover-card.js +145 -0
  156. package/components/hover-card/hover-card.module.css +20 -0
  157. package/components/image-compare/image-compare.d.ts +27 -0
  158. package/components/image-compare/image-compare.js +267 -0
  159. package/components/image-compare/image-compare.module.css +25 -0
  160. package/components/in-view-title/in-view-title.d.ts +17 -0
  161. package/components/in-view-title/in-view-title.js +70 -0
  162. package/components/in-view-title/in-view-title.module.css +13 -0
  163. package/components/inline-edit/inline-edit.d.ts +27 -0
  164. package/components/inline-edit/inline-edit.js +315 -0
  165. package/components/inline-edit/inline-edit.module.css +73 -0
  166. package/components/input/input.d.ts +7 -0
  167. package/components/input/input.js +60 -0
  168. package/components/input/input.module.css +22 -0
  169. package/components/json-viewer/json-viewer.d.ts +48 -0
  170. package/components/json-viewer/json-viewer.js +463 -0
  171. package/components/json-viewer/json-viewer.module.css +92 -0
  172. package/components/line-chart/line-chart.d.ts +58 -0
  173. package/components/line-chart/line-chart.js +383 -0
  174. package/components/line-chart/line-chart.module.css +60 -0
  175. package/components/mention-input/mention-input.d.ts +72 -0
  176. package/components/mention-input/mention-input.js +417 -0
  177. package/components/mention-input/mention-input.module.css +134 -0
  178. package/components/metric-card/metric-card.d.ts +8 -0
  179. package/components/metric-card/metric-card.js +44 -0
  180. package/components/metric-card/metric-card.module.css +18 -0
  181. package/components/money-input/money-input.d.ts +48 -0
  182. package/components/money-input/money-input.js +503 -0
  183. package/components/money-input/money-input.module.css +77 -0
  184. package/components/morph-select/morph-select.d.ts +50 -0
  185. package/components/morph-select/morph-select.js +395 -0
  186. package/components/morph-select/morph-select.module.css +88 -0
  187. package/components/multi-select/multi-select.d.ts +18 -0
  188. package/components/multi-select/multi-select.js +105 -0
  189. package/components/multi-select/multi-select.module.css +37 -0
  190. package/components/notification-center/notification-center.d.ts +24 -0
  191. package/components/notification-center/notification-center.js +146 -0
  192. package/components/notification-center/notification-center.module.css +79 -0
  193. package/components/number-field/number-field.d.ts +41 -0
  194. package/components/number-field/number-field.js +455 -0
  195. package/components/number-field/number-field.module.css +71 -0
  196. package/components/otp-input/otp-input.d.ts +13 -0
  197. package/components/otp-input/otp-input.js +129 -0
  198. package/components/otp-input/otp-input.module.css +28 -0
  199. package/components/pagination/pagination.d.ts +7 -0
  200. package/components/pagination/pagination.js +60 -0
  201. package/components/pagination/pagination.module.css +16 -0
  202. package/components/password-field/password-field.d.ts +14 -0
  203. package/components/password-field/password-field.js +51 -0
  204. package/components/password-field/password-field.module.css +27 -0
  205. package/components/password-strength/password-strength.d.ts +107 -0
  206. package/components/password-strength/password-strength.js +161 -0
  207. package/components/password-strength/password-strength.module.css +57 -0
  208. package/components/phone-input/phone-input.d.ts +73 -0
  209. package/components/phone-input/phone-input.js +612 -0
  210. package/components/phone-input/phone-input.module.css +98 -0
  211. package/components/popover/popover.d.ts +6 -0
  212. package/components/popover/popover.js +19 -0
  213. package/components/popover/popover.module.css +32 -0
  214. package/components/progress/progress.d.ts +8 -0
  215. package/components/progress/progress.js +42 -0
  216. package/components/progress/progress.module.css +1 -0
  217. package/components/radio-cards/radio-cards.d.ts +35 -0
  218. package/components/radio-cards/radio-cards.js +110 -0
  219. package/components/radio-cards/radio-cards.module.css +84 -0
  220. package/components/radio-group/radio-group.d.ts +13 -0
  221. package/components/radio-group/radio-group.js +55 -0
  222. package/components/radio-group/radio-group.module.css +30 -0
  223. package/components/resizable-panels/resizable-panels.d.ts +37 -0
  224. package/components/resizable-panels/resizable-panels.js +338 -0
  225. package/components/resizable-panels/resizable-panels.module.css +40 -0
  226. package/components/rich-text-editor/rich-text-editor.d.ts +55 -0
  227. package/components/rich-text-editor/rich-text-editor.js +1733 -0
  228. package/components/rich-text-editor/rich-text-editor.module.css +201 -0
  229. package/components/ridgeline/ridgeline.d.ts +37 -0
  230. package/components/ridgeline/ridgeline.js +346 -0
  231. package/components/ridgeline/ridgeline.module.css +58 -0
  232. package/components/scroll-area/scroll-area.d.ts +40 -0
  233. package/components/scroll-area/scroll-area.js +153 -0
  234. package/components/scroll-area/scroll-area.module.css +79 -0
  235. package/components/search-field/search-field.d.ts +7 -0
  236. package/components/search-field/search-field.js +20 -0
  237. package/components/search-field/search-field.module.css +17 -0
  238. package/components/segmented-control/segmented-control.d.ts +16 -0
  239. package/components/segmented-control/segmented-control.js +56 -0
  240. package/components/segmented-control/segmented-control.module.css +15 -0
  241. package/components/select/select.d.ts +15 -0
  242. package/components/select/select.js +36 -0
  243. package/components/select/select.module.css +35 -0
  244. package/components/shortcut-recorder/shortcut-recorder.d.ts +108 -0
  245. package/components/shortcut-recorder/shortcut-recorder.js +380 -0
  246. package/components/shortcut-recorder/shortcut-recorder.module.css +85 -0
  247. package/components/signature-pad/signature-pad.d.ts +72 -0
  248. package/components/signature-pad/signature-pad.js +450 -0
  249. package/components/signature-pad/signature-pad.module.css +84 -0
  250. package/components/skeleton/skeleton.d.ts +13 -0
  251. package/components/skeleton/skeleton.js +53 -0
  252. package/components/skeleton/skeleton.module.css +11 -0
  253. package/components/slider/slider.d.ts +45 -0
  254. package/components/slider/slider.js +347 -0
  255. package/components/slider/slider.module.css +45 -0
  256. package/components/slope-chart/slope-chart.d.ts +38 -0
  257. package/components/slope-chart/slope-chart.js +183 -0
  258. package/components/slope-chart/slope-chart.module.css +51 -0
  259. package/components/slot-text/slot-text.d.ts +26 -0
  260. package/components/slot-text/slot-text.js +119 -0
  261. package/components/slot-text/slot-text.module.css +19 -0
  262. package/components/sortable-data-table/sortable-data-table.d.ts +38 -0
  263. package/components/sortable-data-table/sortable-data-table.js +240 -0
  264. package/components/sortable-data-table/sortable-data-table.module.css +116 -0
  265. package/components/sparkline/sparkline.d.ts +19 -0
  266. package/components/sparkline/sparkline.js +239 -0
  267. package/components/sparkline/sparkline.module.css +26 -0
  268. package/components/split-button/split-button.d.ts +19 -0
  269. package/components/split-button/split-button.js +33 -0
  270. package/components/split-button/split-button.module.css +51 -0
  271. package/components/stepper/stepper.d.ts +36 -0
  272. package/components/stepper/stepper.js +108 -0
  273. package/components/stepper/stepper.module.css +74 -0
  274. package/components/streamgraph/streamgraph.d.ts +51 -0
  275. package/components/streamgraph/streamgraph.js +376 -0
  276. package/components/streamgraph/streamgraph.module.css +55 -0
  277. package/components/swipe-actions/swipe-actions.d.ts +35 -0
  278. package/components/swipe-actions/swipe-actions.js +330 -0
  279. package/components/swipe-actions/swipe-actions.module.css +64 -0
  280. package/components/switch/switch.d.ts +7 -0
  281. package/components/switch/switch.js +45 -0
  282. package/components/switch/switch.module.css +12 -0
  283. package/components/tabs/tabs.d.ts +8 -0
  284. package/components/tabs/tabs.js +138 -0
  285. package/components/tabs/tabs.module.css +27 -0
  286. package/components/tag-input/tag-input.d.ts +15 -0
  287. package/components/tag-input/tag-input.js +150 -0
  288. package/components/tag-input/tag-input.module.css +34 -0
  289. package/components/text-morph/text-morph.d.ts +13 -0
  290. package/components/text-morph/text-morph.js +69 -0
  291. package/components/text-morph/text-morph.module.css +8 -0
  292. package/components/text-reveal/text-reveal.d.ts +14 -0
  293. package/components/text-reveal/text-reveal.js +20 -0
  294. package/components/text-reveal/text-reveal.module.css +13 -0
  295. package/components/text-shimmer/text-shimmer.d.ts +18 -0
  296. package/components/text-shimmer/text-shimmer.js +90 -0
  297. package/components/text-shimmer/text-shimmer.module.css +9 -0
  298. package/components/textarea/textarea.d.ts +7 -0
  299. package/components/textarea/textarea.js +56 -0
  300. package/components/textarea/textarea.module.css +22 -0
  301. package/components/theme-switch/theme-switch.d.ts +11 -0
  302. package/components/theme-switch/theme-switch.js +37 -0
  303. package/components/theme-switch/theme-switch.module.css +31 -0
  304. package/components/time-picker/time-picker.d.ts +13 -0
  305. package/components/time-picker/time-picker.js +95 -0
  306. package/components/time-picker/time-picker.module.css +23 -0
  307. package/components/timeline/timeline.d.ts +47 -0
  308. package/components/timeline/timeline.js +171 -0
  309. package/components/timeline/timeline.module.css +51 -0
  310. package/components/toast/toast.d.ts +8 -0
  311. package/components/toast/toast.js +118 -0
  312. package/components/toast/toast.module.css +100 -0
  313. package/components/toast-stack/toast-stack.d.ts +57 -0
  314. package/components/toast-stack/toast-stack.js +399 -0
  315. package/components/toast-stack/toast-stack.module.css +61 -0
  316. package/components/tooltip/tooltip.d.ts +8 -0
  317. package/components/tooltip/tooltip.js +62 -0
  318. package/components/tooltip/tooltip.module.css +18 -0
  319. package/components/tree-view/tree-view.d.ts +17 -0
  320. package/components/tree-view/tree-view.js +147 -0
  321. package/components/tree-view/tree-view.module.css +22 -0
  322. package/components/treemap/treemap.d.ts +35 -0
  323. package/components/treemap/treemap.js +375 -0
  324. package/components/treemap/treemap.module.css +59 -0
  325. package/components/usage-meter/usage-meter.d.ts +24 -0
  326. package/components/usage-meter/usage-meter.js +296 -0
  327. package/components/usage-meter/usage-meter.module.css +61 -0
  328. package/components/user-menu/user-menu.d.ts +62 -0
  329. package/components/user-menu/user-menu.js +316 -0
  330. package/components/user-menu/user-menu.module.css +97 -0
  331. package/components/waffle-chart/waffle-chart.d.ts +39 -0
  332. package/components/waffle-chart/waffle-chart.js +244 -0
  333. package/components/waffle-chart/waffle-chart.module.css +52 -0
  334. package/components.json +1330 -0
  335. package/eslint.js +53 -0
  336. package/lib/escape.d.ts +19 -0
  337. package/lib/escape.js +50 -0
  338. package/lib/media.d.ts +353 -0
  339. package/lib/media.js +65 -0
  340. package/lib/menu-highlight.d.ts +28 -0
  341. package/lib/menu-highlight.js +43 -0
  342. package/lib/motion-tokens.d.ts +60 -0
  343. package/lib/motion-tokens.js +25 -0
  344. package/lib/return-focus.d.ts +9 -0
  345. package/lib/return-focus.js +53 -0
  346. package/lib/silicon-provider.d.ts +60 -0
  347. package/lib/silicon-provider.js +47 -0
  348. package/lib/use-copy-feedback.d.ts +8 -0
  349. package/lib/use-copy-feedback.js +36 -0
  350. package/lib/use-today.d.ts +2 -0
  351. package/lib/use-today.js +29 -0
  352. package/package.json +76 -4
  353. package/styles.css +218 -0
  354. package/styles.css.d.ts +1 -0
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { AnimatePresence, animate, motion, useIsPresent, useMotionValue, useMotionValueEvent, useReducedMotion, useTransform } from "motion/react";
5
+ import { File, FileArchive, FileImage, FileText, RotateCw, UploadCloud, X } from "lucide-react";
6
+ import { motionTokens } from "../../lib/motion-tokens.js";
7
+ import styles from "./file-upload.module.css";
8
+ const enter = { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter] };
9
+ const exitFast = { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.standard] };
10
+ const instant = { duration: 0 };
11
+ const textIn = { opacity: 0, y: "0.3em", filter: `blur(${motionTokens.blur.soft}px)` };
12
+ const textOut = { opacity: 0, y: "-0.3em", filter: `blur(${motionTokens.blur.subtle}px)`, transition: exitFast };
13
+ const iconIn = { opacity: 0, scale: .6, filter: `blur(${motionTokens.blur.subtle}px)` };
14
+ const shown = { opacity: 1, y: "0em", scale: 1, filter: "blur(0px)" };
15
+ const fadeOut = { opacity: 0, transition: { duration: motionTokens.duration.instant } };
16
+ function FileTypeIcon({ file }) {
17
+ const props = { size: 16, strokeWidth: 1.8, "aria-hidden": true };
18
+ if (file.type.startsWith("image/"))
19
+ return _jsx(FileImage, { ...props });
20
+ if (file.type.startsWith("text/"))
21
+ return _jsx(FileText, { ...props });
22
+ if (file.type.includes("zip") || file.name.endsWith(".gz"))
23
+ return _jsx(FileArchive, { ...props });
24
+ return _jsx(File, { ...props });
25
+ }
26
+ function formatSize(bytes) {
27
+ if (bytes < 1024)
28
+ return `${bytes} B`;
29
+ if (bytes < 1024 * 1024)
30
+ return `${Math.round(bytes / 1024)} KB`;
31
+ const mb = bytes / (1024 * 1024);
32
+ return `${mb >= 10 ? Math.round(mb) : Number(mb.toFixed(1))} MB`;
33
+ }
34
+ /** Outgoing copies are hidden from assistive tech while they fade, so live text reads only the current message. */
35
+ function Swap(props) {
36
+ const present = useIsPresent();
37
+ return _jsx(motion.span, { ...props, "aria-hidden": present ? props["aria-hidden"] : true });
38
+ }
39
+ function FileRow({ item, upload, reduce, onRemove, onRetry, removeRef }) {
40
+ const status = upload?.status;
41
+ // A finished upload keeps its bar until the spring reaches the end, so 100% is seen before the label turns to Uploaded.
42
+ const [filled, setFilled] = useState(status !== "uploading");
43
+ const [seen, setSeen] = useState(status);
44
+ if (seen !== status) {
45
+ setSeen(status);
46
+ if (status === "uploading")
47
+ setFilled(false);
48
+ }
49
+ const shownStatus = status === "done" && !filled && !reduce ? "uploading" : status;
50
+ const phase = item.error ? "invalid" : shownStatus ?? "ready";
51
+ // One spring drives the bar and the counted percentage, so both always agree.
52
+ const progress = useMotionValue(upload?.progress ?? 0);
53
+ // The fill slides in from the left instead of scaling, so its rounded end keeps its shape at every value.
54
+ const x = useTransform(progress, latest => `${Math.min(Math.max(latest, 0), 100) - 100}%`);
55
+ const percent = useTransform(progress, latest => `${Math.round(Math.min(Math.max(latest, 0), 100))}%`);
56
+ const target = status === "done" ? 100 : upload?.progress ?? 0;
57
+ useEffect(() => {
58
+ // Every upload starts from an empty bar, even a retry that failed halfway.
59
+ if (reduce || (status === "uploading" && target === 0)) {
60
+ progress.jump(target);
61
+ return;
62
+ }
63
+ const controls = animate(progress, target, { ...motionTokens.spring.smooth, onComplete: status === "done" ? () => setFilled(true) : undefined });
64
+ return () => controls.stop();
65
+ }, [status, target, progress, reduce]);
66
+ // The label turns as soon as the count reads 100%, without waiting out the spring's last fraction of a pixel.
67
+ useMotionValueEvent(progress, "change", latest => { if (status === "done" && latest >= 99.5)
68
+ setFilled(true); });
69
+ const swap = { initial: reduce ? { opacity: 0 } : textIn, animate: shown, exit: reduce ? fadeOut : textOut, transition: reduce ? instant : enter };
70
+ return _jsxs("div", { className: styles.fileItem, children: [_jsx("span", { className: styles.fileIcon, children: _jsx(FileTypeIcon, { file: item.file }) }), _jsxs("span", { className: styles.fileCopy, children: [_jsx("strong", { title: item.file.name, children: item.file.name }), _jsxs("span", { className: styles.meta, children: [formatSize(item.file.size), shownStatus ? _jsxs(_Fragment, { children: [_jsx("span", { className: styles.dot, "aria-hidden": "true", children: "\u00B7" }), _jsx("span", { className: styles.phase, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(Swap, { className: shownStatus === "failed" ? `${styles.phaseText} ${styles.error}` : styles.phaseText, ...swap, children: shownStatus === "uploading" ? _jsxs(_Fragment, { children: ["Uploading ", _jsx(motion.span, { className: styles.percent, children: percent })] }) : shownStatus === "done" ? "Uploaded" : "Upload failed" }, shownStatus) }) })] }) : null] }), item.error && _jsx("span", { className: styles.error, children: item.error }), _jsx(AnimatePresence, { initial: false, children: shownStatus === "uploading" && _jsx(motion.span, { className: styles.barFrame, initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: { ...motionTokens.spring.smooth, delay: .24 }, opacity: { ...exitFast, delay: .24 } } }, transition: reduce ? instant : { height: motionTokens.spring.smooth, opacity: enter }, children: _jsx("span", { className: styles.bar, children: _jsx(motion.span, { className: styles.barFill, style: { x } }) }) }, "bar") })] }), _jsx("span", { className: styles.statusSlot, children: _jsxs(AnimatePresence, { mode: "popLayout", initial: false, children: [(phase === "ready" || phase === "done") && _jsxs(motion.span, { className: styles.ready, initial: reduce ? { opacity: 0 } : { opacity: 0, scale: .8 }, animate: { opacity: 1, scale: 1 }, exit: fadeOut, transition: reduce ? instant : motionTokens.spring.snappy, children: [_jsx("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx(motion.path, { d: "M4 12.5l5 5L20 6.5", initial: reduce ? false : { pathLength: 0 }, animate: { pathLength: 1 }, transition: { ...enter, delay: .08 } }) }), _jsx("span", { className: styles.srOnly, children: phase === "done" ? "Uploaded" : "Ready" })] }, "ready"), phase === "failed" && _jsx(motion.span, { className: styles.retrySlot, initial: reduce ? { opacity: 0 } : iconIn, animate: shown, exit: reduce ? fadeOut : { ...iconIn, transition: exitFast }, transition: reduce ? instant : motionTokens.spring.snappy, children: _jsx("button", { type: "button", className: styles.retry, "aria-label": `Retry ${item.file.name}`, onClick: onRetry, children: _jsx(RotateCw, { size: 14, strokeWidth: 1.8, "aria-hidden": "true" }) }) }, "retry")] }) }), _jsx("button", { ref: removeRef, type: "button", className: styles.remove, "aria-label": `Remove ${item.file.name}`, onClick: onRemove, children: _jsx(X, { size: 15, "aria-hidden": "true" }) })] });
71
+ }
72
+ export function FileUpload({ accept, disabled = false, label = "Upload files", description = "Drop files here or browse from your device.", multiple = true, maxSize, value, onChange, onUpload, }) {
73
+ const inputId = useId();
74
+ const reduce = useReducedMotion();
75
+ const inputRef = useRef(null);
76
+ const dropzoneRef = useRef(null);
77
+ const [internalFiles, setInternalFiles] = useState([]);
78
+ const [dragging, setDragging] = useState(false);
79
+ const [status, setStatus] = useState("");
80
+ const [uploads, setUploads] = useState({});
81
+ const dragDepth = useRef(0);
82
+ const nextId = useRef(0);
83
+ const controllers = useRef(new Map());
84
+ const removeRefs = useRef(new Map());
85
+ const files = value ?? internalFiles;
86
+ useEffect(() => {
87
+ const active = controllers.current;
88
+ return () => active.forEach(controller => controller.abort());
89
+ }, []);
90
+ function update(next) {
91
+ if (value === undefined)
92
+ setInternalFiles(next);
93
+ onChange?.(next);
94
+ }
95
+ function startUpload(item) {
96
+ if (!onUpload)
97
+ return;
98
+ controllers.current.get(item.id)?.abort();
99
+ const controller = new AbortController();
100
+ controllers.current.set(item.id, controller);
101
+ const set = (next) => setUploads(current => ({ ...current, [item.id]: next(current[item.id]) }));
102
+ set(() => ({ status: "uploading", progress: 0 }));
103
+ onUpload(item.file, {
104
+ signal: controller.signal,
105
+ onProgress: percent => { if (!controller.signal.aborted)
106
+ set(current => ({ status: "uploading", progress: Math.min(Math.max(percent, current?.progress ?? 0), 100) })); },
107
+ }).then(() => {
108
+ if (controller.signal.aborted)
109
+ return;
110
+ set(() => ({ status: "done", progress: 100 }));
111
+ setStatus(`${item.file.name} uploaded.`);
112
+ }, () => {
113
+ if (controller.signal.aborted)
114
+ return;
115
+ set(current => ({ status: "failed", progress: current?.progress ?? 0 }));
116
+ setStatus(`${item.file.name} could not be uploaded.`);
117
+ }).finally(() => { if (controllers.current.get(item.id) === controller)
118
+ controllers.current.delete(item.id); });
119
+ }
120
+ function addFiles(fileList) {
121
+ const incoming = Array.from(fileList).slice(0, multiple ? undefined : 1);
122
+ const acceptedTypes = accept?.split(",").map(type => type.trim().toLowerCase()).filter(Boolean) ?? [];
123
+ const matchesAccept = (file) => acceptedTypes.length === 0 || acceptedTypes.some(type => type.startsWith(".")
124
+ ? file.name.toLowerCase().endsWith(type)
125
+ : type.endsWith("/*") ? file.type.startsWith(type.slice(0, -1)) : file.type === type);
126
+ const accepted = incoming.map(file => ({
127
+ id: `${file.name}-${file.lastModified}-${nextId.current++}`,
128
+ file,
129
+ error: !matchesAccept(file)
130
+ ? "This file type is not accepted."
131
+ : maxSize && file.size > maxSize ? `File is larger than ${formatSize(maxSize)}.` : undefined,
132
+ }));
133
+ if (!multiple)
134
+ controllers.current.forEach(controller => controller.abort());
135
+ update(multiple ? [...files, ...accepted] : accepted);
136
+ const invalidCount = accepted.filter(item => item.error).length;
137
+ const validCount = accepted.length - invalidCount;
138
+ const added = `${validCount} file${validCount === 1 ? "" : "s"} added.`;
139
+ const attention = `${invalidCount} file${invalidCount === 1 ? " needs" : "s need"} attention.`;
140
+ setStatus(!invalidCount ? added : validCount ? `${added} ${attention}` : attention);
141
+ accepted.filter(item => !item.error).forEach(startUpload);
142
+ }
143
+ function removeFile(item) {
144
+ controllers.current.get(item.id)?.abort();
145
+ controllers.current.delete(item.id);
146
+ // Keep keyboard focus in the list: the next row's remove button, else the previous one, else the dropzone.
147
+ const index = files.findIndex(file => file.id === item.id);
148
+ const neighbor = files[index + 1] ?? files[index - 1];
149
+ update(files.filter(file => file.id !== item.id));
150
+ setStatus(`${item.file.name} removed.`);
151
+ requestAnimationFrame(() => (neighbor ? removeRefs.current.get(neighbor.id) : dropzoneRef.current)?.focus());
152
+ }
153
+ function handleInput(event) {
154
+ if (event.target.files)
155
+ addFiles(event.target.files);
156
+ event.target.value = "";
157
+ }
158
+ function handleDrop(event) {
159
+ event.preventDefault();
160
+ dragDepth.current = 0;
161
+ setDragging(false);
162
+ if (!disabled && event.dataTransfer.files.length)
163
+ addFiles(event.dataTransfer.files);
164
+ }
165
+ function handleDragEnter(event) {
166
+ event.preventDefault();
167
+ if (!disabled) {
168
+ dragDepth.current += 1;
169
+ setDragging(true);
170
+ }
171
+ }
172
+ function handleDragLeave(event) {
173
+ event.preventDefault();
174
+ dragDepth.current = Math.max(0, dragDepth.current - 1);
175
+ if (dragDepth.current === 0)
176
+ setDragging(false);
177
+ }
178
+ function handleKeyDown(event) {
179
+ if (disabled)
180
+ return;
181
+ if (event.key === "Enter" || event.key === " ") {
182
+ event.preventDefault();
183
+ inputRef.current?.click();
184
+ }
185
+ }
186
+ const height = reduce ? instant : { height: motionTokens.spring.smooth, opacity: enter };
187
+ return _jsxs("div", { className: styles.root, children: [_jsx("input", { ref: inputRef, id: inputId, className: styles.input, type: "file", accept: accept, multiple: multiple, disabled: disabled, onChange: handleInput }), _jsxs("div", { ref: dropzoneRef, className: [styles.dropzone, dragging ? styles.dragging : "", disabled ? styles.disabled : ""].filter(Boolean).join(" "), role: "button", tabIndex: disabled ? -1 : 0, "aria-disabled": disabled, "aria-describedby": `${inputId}-description`, onClick: () => !disabled && inputRef.current?.click(), onKeyDown: handleKeyDown, onDragEnter: handleDragEnter, onDragOver: event => event.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, children: [_jsx("span", { className: styles.uploadIcon, children: _jsx(UploadCloud, { size: 20, strokeWidth: 1.8, "aria-hidden": "true" }) }), _jsxs("span", { className: styles.copy, children: [_jsx("strong", { className: styles.label, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(Swap, { className: styles.labelText, initial: reduce ? { opacity: 0 } : textIn, animate: shown, exit: reduce ? fadeOut : textOut, transition: reduce ? instant : enter, children: dragging ? `Drop to add ${multiple ? "files" : "a file"}` : label }, dragging ? "drop" : "idle") }) }), _jsx("span", { id: `${inputId}-description`, children: description })] }), _jsx("span", { className: styles.browse, children: "Browse" })] }), _jsx(motion.div, { className: styles.statusFrame, initial: false, animate: { height: status ? "auto" : 0 }, transition: height, children: _jsx("p", { className: styles.status, "aria-live": "polite", "aria-atomic": "true", children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: status ? _jsx(Swap, { className: styles.statusText, initial: reduce ? { opacity: 0 } : textIn, animate: shown, exit: reduce ? fadeOut : textOut, transition: reduce ? instant : enter, children: status }, status) : null }) }) }), _jsx(motion.ul, { className: styles.fileList, "aria-label": "Selected files", "aria-hidden": files.length === 0 ? true : undefined, initial: false, animate: { paddingTop: files.length ? 6 : 0 }, transition: reduce ? instant : motionTokens.spring.smooth, children: _jsx(AnimatePresence, { initial: false, children: files.map(item => _jsx(motion.li, { className: styles.fileRow, initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: motionTokens.spring.smooth, opacity: exitFast } }, transition: height, children: _jsx(FileRow, { item: item, upload: uploads[item.id], reduce: reduce, onRemove: () => removeFile(item), onRetry: () => startUpload(item), removeRef: node => { if (node)
188
+ removeRefs.current.set(item.id, node);
189
+ else
190
+ removeRefs.current.delete(item.id); } }) }, item.id)) }) })] });
191
+ }
192
+ export default FileUpload;
@@ -0,0 +1,49 @@
1
+ .root { display: grid; width: 100%; min-width: 0; color: var(--foreground); }
2
+ .input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
3
+ /* A full-width drop target: press feedback is color only, never a scale. */
4
+ .dropzone { display: flex; min-height: 92px; align-items: center; gap: 12px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--surface); cursor: pointer; transition: border-color var(--duration-standard) var(--ease-standard), background-color var(--duration-standard) var(--ease-standard); }
5
+ .dropzone.dragging, .dropzone:not(.disabled):active { border-color: var(--accent); background: var(--accent-subtle); }
6
+ .dropzone.disabled { cursor: not-allowed; opacity: .52; }
7
+ .uploadIcon, .fileIcon { display: grid; flex: 0 0 auto; place-items: center; color: var(--accent-strong); }
8
+ /* The cloud lifts toward the file while it hovers over the drop target. */
9
+ .uploadIcon { width: 24px; height: 24px; transition: transform var(--duration-spring) var(--ease-spring); }
10
+ .dragging .uploadIcon { transform: translateY(-3px); }
11
+ .copy { display: grid; min-width: 0; gap: 3px; flex: 1; }
12
+ .copy strong { font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); }
13
+ .label { position: relative; display: block; min-width: 0; }
14
+ .labelText { display: block; }
15
+ .copy > span { color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-body); overflow-wrap: anywhere; }
16
+ .browse { flex: 0 0 auto; color: var(--accent-strong); font-size: var(--text-xs); font-weight: 500; }
17
+ .statusFrame { overflow: hidden; }
18
+ .status { position: relative; min-height: 16px; margin: 0; padding-top: 8px; color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-body); }
19
+ .statusText { display: block; }
20
+ .fileList { display: grid; margin: 0; padding: 0; list-style: none; }
21
+ /* The gap lives inside the clipped row, so a collapsing row reaches zero height instead of stopping at its padding. */
22
+ .fileRow { overflow: hidden; }
23
+ .fileItem { display: flex; margin-top: 6px; min-width: 0; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--surface-muted); }
24
+ .fileIcon { width: 24px; height: 24px; color: var(--text-secondary); }
25
+ .fileCopy { display: grid; min-width: 0; flex: 1; gap: 2px; }
26
+ .fileCopy strong { overflow: hidden; font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); text-overflow: ellipsis; white-space: nowrap; }
27
+ .fileCopy > span { color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-body); }
28
+ .meta { display: flex; min-width: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
29
+ .dot { padding-inline: 5px; }
30
+ .phase { position: relative; display: inline-block; }
31
+ .phaseText { display: block; }
32
+ .percent { display: inline-block; min-width: 4ch; }
33
+ .fileCopy .error { color: var(--danger); }
34
+ .barFrame { display: block; }
35
+ .bar { display: block; height: 3px; margin: 5px 0 1px; overflow: hidden; border-radius: var(--radius-full); corner-shape: round; background: var(--border); }
36
+ .barFill { display: block; width: 100%; height: 100%; border-radius: inherit; corner-shape: inherit; background: var(--accent); }
37
+ .statusSlot { position: relative; display: grid; width: 26px; height: 26px; flex: 0 0 auto; place-items: center; }
38
+ .retrySlot { display: grid; place-items: center; }
39
+ .ready { display: grid; width: 22px; height: 22px; place-items: center; color: var(--success); }
40
+ .remove, .retry { display: grid; width: 26px; height: 26px; flex: 0 0 auto; place-items: center; border: 0; border-radius: var(--radius-full); corner-shape: round; background: transparent; color: var(--text-muted); cursor: pointer; transition: transform var(--duration-spring) var(--ease-spring), background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
41
+ .retry { color: var(--text-secondary); }
42
+ /* Quick press, spring release. */
43
+ .remove:active, .retry:active { transform: scale(.96); transition-duration: var(--duration-instant); transition-timing-function: var(--ease-standard); }
44
+ @media (hover: hover) and (pointer: fine) {
45
+ .dropzone:not(.disabled):hover { border-color: var(--accent); background: var(--accent-subtle); }
46
+ .remove:hover, .retry:hover { background: var(--surface); color: var(--foreground); }
47
+ }
48
+ .srOnly { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
49
+ @media (prefers-reduced-motion: reduce) { .dropzone, .uploadIcon, .remove, .retry { transition: none; } .dragging .uploadIcon, .remove:active, .retry:active { transform: none; } }
@@ -0,0 +1,48 @@
1
+ import type { ReactNode } from "react";
2
+ export interface FilterChip {
3
+ id: string;
4
+ label: string;
5
+ value?: string;
6
+ }
7
+ /** One value a field can take. `hint` sits at the end of the row, for example a count. */
8
+ export interface FilterOption {
9
+ value: string;
10
+ label?: string;
11
+ hint?: string | number;
12
+ icon?: ReactNode;
13
+ }
14
+ export interface FilterField {
15
+ id: string;
16
+ label: string;
17
+ icon?: ReactNode;
18
+ options: (string | FilterOption)[];
19
+ }
20
+ export interface FilterMenuProps {
21
+ fields: FilterField[];
22
+ /** Receives a chip whose id is the field id, so a second pick for a field replaces the first. */
23
+ onSelect: (filter: FilterChip, field: FilterField) => void;
24
+ /** Applied filters. Each field shows its current value and the value step marks it. */
25
+ active?: FilterChip[];
26
+ label?: string;
27
+ /** The trigger edge the panel lines up with. It flips or shifts when the viewport, or a clipping ancestor, has no room. */
28
+ align?: "start" | "end";
29
+ }
30
+ export interface FilterToolbarProps {
31
+ filters: FilterChip[];
32
+ onRemove: (id: string) => void;
33
+ onClearAll?: () => void;
34
+ children?: ReactNode;
35
+ label?: string;
36
+ /** Adds an Add filter trigger that morphs into a two step field and value menu. */
37
+ addFilter?: {
38
+ fields: FilterField[];
39
+ onAdd: (filter: FilterChip, field: FilterField) => void;
40
+ label?: string;
41
+ align?: "start" | "end";
42
+ };
43
+ }
44
+ /** An Add filter button that grows into its own menu: pick a field, then a value. The shape springs between the
45
+ * button and the panel, and the panel renders in place, so keep its ancestors free of overflow clipping. */
46
+ export declare function FilterMenu({ fields, onSelect, active, label, align }: FilterMenuProps): import("react").JSX.Element;
47
+ export declare function FilterToolbar({ filters, onRemove, onClearAll, children, label, addFilter }: FilterToolbarProps): import("react").JSX.Element;
48
+ export default FilterToolbar;