@senvenli/react 0.0.0-stage → 0.1.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 (636) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/action/button-group.d.ts +26 -0
  4. package/dist/action/button-group.js +12 -0
  5. package/dist/action/button-group.js.map +1 -0
  6. package/dist/action/button.d.ts +42 -0
  7. package/dist/action/button.js +58 -0
  8. package/dist/action/button.js.map +1 -0
  9. package/dist/action/close-button.d.ts +12 -0
  10. package/dist/action/close-button.js +13 -0
  11. package/dist/action/close-button.js.map +1 -0
  12. package/dist/action/copy-button.d.ts +21 -0
  13. package/dist/action/copy-button.js +38 -0
  14. package/dist/action/copy-button.js.map +1 -0
  15. package/dist/action/fab.d.ts +29 -0
  16. package/dist/action/fab.js +57 -0
  17. package/dist/action/fab.js.map +1 -0
  18. package/dist/action/files.d.ts +70 -0
  19. package/dist/action/files.js +156 -0
  20. package/dist/action/files.js.map +1 -0
  21. package/dist/action/index.d.ts +23 -0
  22. package/dist/action/index.js +16 -0
  23. package/dist/action/index.js.map +1 -0
  24. package/dist/action/language-names.d.ts +19 -0
  25. package/dist/action/language-names.js +79 -0
  26. package/dist/action/language-names.js.map +1 -0
  27. package/dist/action/language-switcher.d.ts +57 -0
  28. package/dist/action/language-switcher.js +53 -0
  29. package/dist/action/language-switcher.js.map +1 -0
  30. package/dist/action/link-button.d.ts +57 -0
  31. package/dist/action/link-button.js +48 -0
  32. package/dist/action/link-button.js.map +1 -0
  33. package/dist/action/link.d.ts +24 -0
  34. package/dist/action/link.js +18 -0
  35. package/dist/action/link.js.map +1 -0
  36. package/dist/action/pressable.d.ts +40 -0
  37. package/dist/action/pressable.js +65 -0
  38. package/dist/action/pressable.js.map +1 -0
  39. package/dist/action/styles.d.ts +60 -0
  40. package/dist/action/styles.js +109 -0
  41. package/dist/action/styles.js.map +1 -0
  42. package/dist/action/theme-script.d.ts +12 -0
  43. package/dist/action/theme-script.js +23 -0
  44. package/dist/action/theme-script.js.map +1 -0
  45. package/dist/action/theme-switcher.d.ts +43 -0
  46. package/dist/action/theme-switcher.js +260 -0
  47. package/dist/action/theme-switcher.js.map +1 -0
  48. package/dist/action/theme-toggle.d.ts +43 -0
  49. package/dist/action/theme-toggle.js +259 -0
  50. package/dist/action/theme-toggle.js.map +1 -0
  51. package/dist/action/toggle.d.ts +44 -0
  52. package/dist/action/toggle.js +28 -0
  53. package/dist/action/toggle.js.map +1 -0
  54. package/dist/action/touch-target.d.ts +9 -0
  55. package/dist/action/touch-target.js +14 -0
  56. package/dist/action/touch-target.js.map +1 -0
  57. package/dist/charts/axis-width.d.ts +186 -0
  58. package/dist/charts/axis-width.js +1262 -0
  59. package/dist/charts/axis-width.js.map +1 -0
  60. package/dist/charts/bar-public.d.ts +16 -0
  61. package/dist/charts/bar-public.js +16 -0
  62. package/dist/charts/bar-public.js.map +1 -0
  63. package/dist/charts/chart-parts.d.ts +136 -0
  64. package/dist/charts/chart-parts.js +160 -0
  65. package/dist/charts/chart-parts.js.map +1 -0
  66. package/dist/charts/core-charts.d.ts +157 -0
  67. package/dist/charts/core-charts.js +505 -0
  68. package/dist/charts/core-charts.js.map +1 -0
  69. package/dist/charts/index.d.ts +12 -0
  70. package/dist/charts/index.js +8 -0
  71. package/dist/charts/index.js.map +1 -0
  72. package/dist/charts/list-charts.d.ts +124 -0
  73. package/dist/charts/list-charts.js +308 -0
  74. package/dist/charts/list-charts.js.map +1 -0
  75. package/dist/charts/more-charts.d.ts +138 -0
  76. package/dist/charts/more-charts.js +284 -0
  77. package/dist/charts/more-charts.js.map +1 -0
  78. package/dist/charts/report-charts.d.ts +138 -0
  79. package/dist/charts/report-charts.js +370 -0
  80. package/dist/charts/report-charts.js.map +1 -0
  81. package/dist/charts/value-tick.d.ts +178 -0
  82. package/dist/charts/value-tick.js +240 -0
  83. package/dist/charts/value-tick.js.map +1 -0
  84. package/dist/collection/data-table-url-hook.d.ts +34 -0
  85. package/dist/collection/data-table-url-hook.js +70 -0
  86. package/dist/collection/data-table-url-hook.js.map +1 -0
  87. package/dist/collection/data-table-url.d.ts +30 -0
  88. package/dist/collection/data-table-url.js +48 -0
  89. package/dist/collection/data-table-url.js.map +1 -0
  90. package/dist/collection/data-table.d.ts +112 -0
  91. package/dist/collection/data-table.js +188 -0
  92. package/dist/collection/data-table.js.map +1 -0
  93. package/dist/collection/grid-list-public.d.ts +18 -0
  94. package/dist/collection/grid-list-public.js +19 -0
  95. package/dist/collection/grid-list-public.js.map +1 -0
  96. package/dist/collection/grid-list.d.ts +73 -0
  97. package/dist/collection/grid-list.js +46 -0
  98. package/dist/collection/grid-list.js.map +1 -0
  99. package/dist/collection/index.d.ts +14 -0
  100. package/dist/collection/index.js +8 -0
  101. package/dist/collection/index.js.map +1 -0
  102. package/dist/collection/list.d.ts +61 -0
  103. package/dist/collection/list.js +38 -0
  104. package/dist/collection/list.js.map +1 -0
  105. package/dist/collection/selection-checkbox.d.ts +5 -0
  106. package/dist/collection/selection-checkbox.js +13 -0
  107. package/dist/collection/selection-checkbox.js.map +1 -0
  108. package/dist/collection/table.d.ts +91 -0
  109. package/dist/collection/table.js +183 -0
  110. package/dist/collection/table.js.map +1 -0
  111. package/dist/collection/tree.d.ts +31 -0
  112. package/dist/collection/tree.js +22 -0
  113. package/dist/collection/tree.js.map +1 -0
  114. package/dist/color/color.d.ts +87 -0
  115. package/dist/color/color.js +200 -0
  116. package/dist/color/color.js.map +1 -0
  117. package/dist/color/contrast.d.ts +34 -0
  118. package/dist/color/contrast.js +44 -0
  119. package/dist/color/contrast.js.map +1 -0
  120. package/dist/color/index.d.ts +4 -0
  121. package/dist/color/index.js +5 -0
  122. package/dist/color/index.js.map +1 -0
  123. package/dist/date/calendar.d.ts +71 -0
  124. package/dist/date/calendar.js +291 -0
  125. package/dist/date/calendar.js.map +1 -0
  126. package/dist/date/fields.d.ts +174 -0
  127. package/dist/date/fields.js +250 -0
  128. package/dist/date/fields.js.map +1 -0
  129. package/dist/date/index.d.ts +7 -0
  130. package/dist/date/index.js +6 -0
  131. package/dist/date/index.js.map +1 -0
  132. package/dist/date/month-grid.d.ts +31 -0
  133. package/dist/date/month-grid.js +115 -0
  134. package/dist/date/month-grid.js.map +1 -0
  135. package/dist/date/pickers.d.ts +118 -0
  136. package/dist/date/pickers.js +176 -0
  137. package/dist/date/pickers.js.map +1 -0
  138. package/dist/date/public.d.ts +25 -0
  139. package/dist/date/public.js +24 -0
  140. package/dist/date/public.js.map +1 -0
  141. package/dist/date/segments.d.ts +153 -0
  142. package/dist/date/segments.js +433 -0
  143. package/dist/date/segments.js.map +1 -0
  144. package/dist/defaults.d.ts +74 -0
  145. package/dist/defaults.js +100 -0
  146. package/dist/defaults.js.map +1 -0
  147. package/dist/density.d.ts +2 -0
  148. package/dist/density.js +2 -0
  149. package/dist/density.js.map +1 -0
  150. package/dist/display/avatar.d.ts +29 -0
  151. package/dist/display/avatar.js +71 -0
  152. package/dist/display/avatar.js.map +1 -0
  153. package/dist/display/badge.d.ts +65 -0
  154. package/dist/display/badge.js +99 -0
  155. package/dist/display/badge.js.map +1 -0
  156. package/dist/display/card.d.ts +72 -0
  157. package/dist/display/card.js +91 -0
  158. package/dist/display/card.js.map +1 -0
  159. package/dist/display/carousel.d.ts +47 -0
  160. package/dist/display/carousel.js +214 -0
  161. package/dist/display/carousel.js.map +1 -0
  162. package/dist/display/description-list.d.ts +25 -0
  163. package/dist/display/description-list.js +36 -0
  164. package/dist/display/description-list.js.map +1 -0
  165. package/dist/display/icon-aliases.d.ts +1 -0
  166. package/dist/display/icon-aliases.js +259 -0
  167. package/dist/display/icon-aliases.js.map +1 -0
  168. package/dist/display/icon-names.d.ts +4 -0
  169. package/dist/display/icon-names.js +2 -0
  170. package/dist/display/icon-names.js.map +1 -0
  171. package/dist/display/icon.d.ts +51 -0
  172. package/dist/display/icon.js +96 -0
  173. package/dist/display/icon.js.map +1 -0
  174. package/dist/display/image-crop.d.ts +106 -0
  175. package/dist/display/image-crop.js +117 -0
  176. package/dist/display/image-crop.js.map +1 -0
  177. package/dist/display/image-cropper.d.ts +68 -0
  178. package/dist/display/image-cropper.js +284 -0
  179. package/dist/display/image-cropper.js.map +1 -0
  180. package/dist/display/image-viewer.d.ts +54 -0
  181. package/dist/display/image-viewer.js +84 -0
  182. package/dist/display/image-viewer.js.map +1 -0
  183. package/dist/display/image.d.ts +26 -0
  184. package/dist/display/image.js +17 -0
  185. package/dist/display/image.js.map +1 -0
  186. package/dist/display/index.d.ts +29 -0
  187. package/dist/display/index.js +16 -0
  188. package/dist/display/index.js.map +1 -0
  189. package/dist/display/iso-chip.d.ts +19 -0
  190. package/dist/display/iso-chip.js +21 -0
  191. package/dist/display/iso-chip.js.map +1 -0
  192. package/dist/display/kbd.d.ts +11 -0
  193. package/dist/display/kbd.js +33 -0
  194. package/dist/display/kbd.js.map +1 -0
  195. package/dist/display/lozenge.d.ts +30 -0
  196. package/dist/display/lozenge.js +55 -0
  197. package/dist/display/lozenge.js.map +1 -0
  198. package/dist/display/scroll-area.d.ts +29 -0
  199. package/dist/display/scroll-area.js +95 -0
  200. package/dist/display/scroll-area.js.map +1 -0
  201. package/dist/display/separator.d.ts +13 -0
  202. package/dist/display/separator.js +24 -0
  203. package/dist/display/separator.js.map +1 -0
  204. package/dist/display/stat.d.ts +35 -0
  205. package/dist/display/stat.js +41 -0
  206. package/dist/display/stat.js.map +1 -0
  207. package/dist/display/timeline.d.ts +44 -0
  208. package/dist/display/timeline.js +111 -0
  209. package/dist/display/timeline.js.map +1 -0
  210. package/dist/display/typography.d.ts +37 -0
  211. package/dist/display/typography.js +53 -0
  212. package/dist/display/typography.js.map +1 -0
  213. package/dist/display/visually-hidden.d.ts +14 -0
  214. package/dist/display/visually-hidden.js +10 -0
  215. package/dist/display/visually-hidden.js.map +1 -0
  216. package/dist/feedback/banner.d.ts +46 -0
  217. package/dist/feedback/banner.js +157 -0
  218. package/dist/feedback/banner.js.map +1 -0
  219. package/dist/feedback/cooldown.d.ts +17 -0
  220. package/dist/feedback/cooldown.js +59 -0
  221. package/dist/feedback/cooldown.js.map +1 -0
  222. package/dist/feedback/empty-state.d.ts +35 -0
  223. package/dist/feedback/empty-state.js +39 -0
  224. package/dist/feedback/empty-state.js.map +1 -0
  225. package/dist/feedback/index.d.ts +12 -0
  226. package/dist/feedback/index.js +11 -0
  227. package/dist/feedback/index.js.map +1 -0
  228. package/dist/feedback/meter.d.ts +33 -0
  229. package/dist/feedback/meter.js +42 -0
  230. package/dist/feedback/meter.js.map +1 -0
  231. package/dist/feedback/motion.d.ts +9 -0
  232. package/dist/feedback/motion.js +57 -0
  233. package/dist/feedback/motion.js.map +1 -0
  234. package/dist/feedback/progress.d.ts +39 -0
  235. package/dist/feedback/progress.js +68 -0
  236. package/dist/feedback/progress.js.map +1 -0
  237. package/dist/feedback/skeleton.d.ts +48 -0
  238. package/dist/feedback/skeleton.js +61 -0
  239. package/dist/feedback/skeleton.js.map +1 -0
  240. package/dist/feedback/spinner.d.ts +19 -0
  241. package/dist/feedback/spinner.js +29 -0
  242. package/dist/feedback/spinner.js.map +1 -0
  243. package/dist/feedback/status-dot.d.ts +23 -0
  244. package/dist/feedback/status-dot.js +37 -0
  245. package/dist/feedback/status-dot.js.map +1 -0
  246. package/dist/form/countries.d.ts +34 -0
  247. package/dist/form/countries.js +273 -0
  248. package/dist/form/countries.js.map +1 -0
  249. package/dist/form/data-attributes.d.ts +11 -0
  250. package/dist/form/data-attributes.js +22 -0
  251. package/dist/form/data-attributes.js.map +1 -0
  252. package/dist/form/field-parts.d.ts +113 -0
  253. package/dist/form/field-parts.js +178 -0
  254. package/dist/form/field-parts.js.map +1 -0
  255. package/dist/form/field.d.ts +36 -0
  256. package/dist/form/field.js +65 -0
  257. package/dist/form/field.js.map +1 -0
  258. package/dist/form/files.d.ts +70 -0
  259. package/dist/form/files.js +156 -0
  260. package/dist/form/files.js.map +1 -0
  261. package/dist/form/form.d.ts +40 -0
  262. package/dist/form/form.js +74 -0
  263. package/dist/form/form.js.map +1 -0
  264. package/dist/form/image-crop.d.ts +106 -0
  265. package/dist/form/image-crop.js +117 -0
  266. package/dist/form/image-crop.js.map +1 -0
  267. package/dist/form/image-cropper.d.ts +68 -0
  268. package/dist/form/image-cropper.js +284 -0
  269. package/dist/form/image-cropper.js.map +1 -0
  270. package/dist/form/index.d.ts +24 -0
  271. package/dist/form/index.js +15 -0
  272. package/dist/form/index.js.map +1 -0
  273. package/dist/form/input-group.d.ts +63 -0
  274. package/dist/form/input-group.js +63 -0
  275. package/dist/form/input-group.js.map +1 -0
  276. package/dist/form/input-otp.d.ts +35 -0
  277. package/dist/form/input-otp.js +83 -0
  278. package/dist/form/input-otp.js.map +1 -0
  279. package/dist/form/input.d.ts +36 -0
  280. package/dist/form/input.js +41 -0
  281. package/dist/form/input.js.map +1 -0
  282. package/dist/form/number-field.d.ts +84 -0
  283. package/dist/form/number-field.js +81 -0
  284. package/dist/form/number-field.js.map +1 -0
  285. package/dist/form/otp-field.d.ts +37 -0
  286. package/dist/form/otp-field.js +116 -0
  287. package/dist/form/otp-field.js.map +1 -0
  288. package/dist/form/password-field.d.ts +61 -0
  289. package/dist/form/password-field.js +61 -0
  290. package/dist/form/password-field.js.map +1 -0
  291. package/dist/form/phone-field.d.ts +104 -0
  292. package/dist/form/phone-field.js +275 -0
  293. package/dist/form/phone-field.js.map +1 -0
  294. package/dist/form/phone-paste.d.ts +24 -0
  295. package/dist/form/phone-paste.js +40 -0
  296. package/dist/form/phone-paste.js.map +1 -0
  297. package/dist/form/phone.d.ts +159 -0
  298. package/dist/form/phone.js +309 -0
  299. package/dist/form/phone.js.map +1 -0
  300. package/dist/form/search-field.d.ts +29 -0
  301. package/dist/form/search-field.js +23 -0
  302. package/dist/form/search-field.js.map +1 -0
  303. package/dist/form/styles.d.ts +31 -0
  304. package/dist/form/styles.js +43 -0
  305. package/dist/form/styles.js.map +1 -0
  306. package/dist/form/text-area.d.ts +70 -0
  307. package/dist/form/text-area.js +93 -0
  308. package/dist/form/text-area.js.map +1 -0
  309. package/dist/form/text-field.d.ts +131 -0
  310. package/dist/form/text-field.js +59 -0
  311. package/dist/form/text-field.js.map +1 -0
  312. package/dist/form/validation.d.ts +145 -0
  313. package/dist/form/validation.js +136 -0
  314. package/dist/form/validation.js.map +1 -0
  315. package/dist/i18n.d.ts +438 -0
  316. package/dist/i18n.js +948 -0
  317. package/dist/i18n.js.map +1 -0
  318. package/dist/index.d.ts +9 -0
  319. package/dist/index.js +7 -0
  320. package/dist/index.js.map +1 -0
  321. package/dist/intl-locale.d.ts +30 -0
  322. package/dist/intl-locale.js +83 -0
  323. package/dist/intl-locale.js.map +1 -0
  324. package/dist/layers.d.ts +32 -0
  325. package/dist/layers.js +33 -0
  326. package/dist/layers.js.map +1 -0
  327. package/dist/layout/auth-form-layout.d.ts +71 -0
  328. package/dist/layout/auth-form-layout.js +61 -0
  329. package/dist/layout/auth-form-layout.js.map +1 -0
  330. package/dist/layout/auth-layout.d.ts +59 -0
  331. package/dist/layout/auth-layout.js +26 -0
  332. package/dist/layout/auth-layout.js.map +1 -0
  333. package/dist/layout/box.d.ts +26 -0
  334. package/dist/layout/box.js +16 -0
  335. package/dist/layout/box.js.map +1 -0
  336. package/dist/layout/grid.d.ts +27 -0
  337. package/dist/layout/grid.js +26 -0
  338. package/dist/layout/grid.js.map +1 -0
  339. package/dist/layout/index.d.ts +16 -0
  340. package/dist/layout/index.js +12 -0
  341. package/dist/layout/index.js.map +1 -0
  342. package/dist/layout/pressable.d.ts +40 -0
  343. package/dist/layout/pressable.js +65 -0
  344. package/dist/layout/pressable.js.map +1 -0
  345. package/dist/layout/reset-sent-card.d.ts +39 -0
  346. package/dist/layout/reset-sent-card.js +22 -0
  347. package/dist/layout/reset-sent-card.js.map +1 -0
  348. package/dist/layout/scroll-area.d.ts +29 -0
  349. package/dist/layout/scroll-area.js +95 -0
  350. package/dist/layout/scroll-area.js.map +1 -0
  351. package/dist/layout/section.d.ts +41 -0
  352. package/dist/layout/section.js +22 -0
  353. package/dist/layout/section.js.map +1 -0
  354. package/dist/layout/split.d.ts +50 -0
  355. package/dist/layout/split.js +35 -0
  356. package/dist/layout/split.js.map +1 -0
  357. package/dist/layout/stack.d.ts +44 -0
  358. package/dist/layout/stack.js +36 -0
  359. package/dist/layout/stack.js.map +1 -0
  360. package/dist/layout/tokens.d.ts +33 -0
  361. package/dist/layout/tokens.js +85 -0
  362. package/dist/layout/tokens.js.map +1 -0
  363. package/dist/layout/toolbar.d.ts +37 -0
  364. package/dist/layout/toolbar.js +334 -0
  365. package/dist/layout/toolbar.js.map +1 -0
  366. package/dist/navigate-context.d.ts +12 -0
  367. package/dist/navigate-context.js +13 -0
  368. package/dist/navigate-context.js.map +1 -0
  369. package/dist/navigation/accordion.d.ts +40 -0
  370. package/dist/navigation/accordion.js +33 -0
  371. package/dist/navigation/accordion.js.map +1 -0
  372. package/dist/navigation/bottom-nav.d.ts +29 -0
  373. package/dist/navigation/bottom-nav.js +48 -0
  374. package/dist/navigation/bottom-nav.js.map +1 -0
  375. package/dist/navigation/brand-link-context.d.ts +8 -0
  376. package/dist/navigation/brand-link-context.js +9 -0
  377. package/dist/navigation/brand-link-context.js.map +1 -0
  378. package/dist/navigation/breadcrumbs.d.ts +36 -0
  379. package/dist/navigation/breadcrumbs.js +51 -0
  380. package/dist/navigation/breadcrumbs.js.map +1 -0
  381. package/dist/navigation/dock.d.ts +27 -0
  382. package/dist/navigation/dock.js +47 -0
  383. package/dist/navigation/dock.js.map +1 -0
  384. package/dist/navigation/footer.d.ts +43 -0
  385. package/dist/navigation/footer.js +43 -0
  386. package/dist/navigation/footer.js.map +1 -0
  387. package/dist/navigation/index.d.ts +22 -0
  388. package/dist/navigation/index.js +17 -0
  389. package/dist/navigation/index.js.map +1 -0
  390. package/dist/navigation/language-names.d.ts +19 -0
  391. package/dist/navigation/language-names.js +79 -0
  392. package/dist/navigation/language-names.js.map +1 -0
  393. package/dist/navigation/language-switcher.d.ts +55 -0
  394. package/dist/navigation/language-switcher.js +53 -0
  395. package/dist/navigation/language-switcher.js.map +1 -0
  396. package/dist/navigation/nav-panel.d.ts +18 -0
  397. package/dist/navigation/nav-panel.js +51 -0
  398. package/dist/navigation/nav-panel.js.map +1 -0
  399. package/dist/navigation/navbar.d.ts +73 -0
  400. package/dist/navigation/navbar.js +64 -0
  401. package/dist/navigation/navbar.js.map +1 -0
  402. package/dist/navigation/page-header.d.ts +37 -0
  403. package/dist/navigation/page-header.js +50 -0
  404. package/dist/navigation/page-header.js.map +1 -0
  405. package/dist/navigation/pagination.d.ts +25 -0
  406. package/dist/navigation/pagination.js +51 -0
  407. package/dist/navigation/pagination.js.map +1 -0
  408. package/dist/navigation/panel-header.d.ts +37 -0
  409. package/dist/navigation/panel-header.js +50 -0
  410. package/dist/navigation/panel-header.js.map +1 -0
  411. package/dist/navigation/sidebar-script.d.ts +12 -0
  412. package/dist/navigation/sidebar-script.js +20 -0
  413. package/dist/navigation/sidebar-script.js.map +1 -0
  414. package/dist/navigation/sidebar.d.ts +149 -0
  415. package/dist/navigation/sidebar.js +332 -0
  416. package/dist/navigation/sidebar.js.map +1 -0
  417. package/dist/navigation/skip-link.d.ts +12 -0
  418. package/dist/navigation/skip-link.js +30 -0
  419. package/dist/navigation/skip-link.js.map +1 -0
  420. package/dist/navigation/stepper.d.ts +50 -0
  421. package/dist/navigation/stepper.js +96 -0
  422. package/dist/navigation/stepper.js.map +1 -0
  423. package/dist/navigation/tabs.d.ts +84 -0
  424. package/dist/navigation/tabs.js +118 -0
  425. package/dist/navigation/tabs.js.map +1 -0
  426. package/dist/navigation/toolbar.d.ts +37 -0
  427. package/dist/navigation/toolbar.js +334 -0
  428. package/dist/navigation/toolbar.js.map +1 -0
  429. package/dist/overlay/alert-dialog.d.ts +63 -0
  430. package/dist/overlay/alert-dialog.js +76 -0
  431. package/dist/overlay/alert-dialog.js.map +1 -0
  432. package/dist/overlay/command-palette.d.ts +53 -0
  433. package/dist/overlay/command-palette.js +130 -0
  434. package/dist/overlay/command-palette.js.map +1 -0
  435. package/dist/overlay/command.d.ts +53 -0
  436. package/dist/overlay/command.js +129 -0
  437. package/dist/overlay/command.js.map +1 -0
  438. package/dist/overlay/context-menu.d.ts +29 -0
  439. package/dist/overlay/context-menu.js +58 -0
  440. package/dist/overlay/context-menu.js.map +1 -0
  441. package/dist/overlay/dialog.d.ts +162 -0
  442. package/dist/overlay/dialog.js +174 -0
  443. package/dist/overlay/dialog.js.map +1 -0
  444. package/dist/overlay/drawer.d.ts +41 -0
  445. package/dist/overlay/drawer.js +114 -0
  446. package/dist/overlay/drawer.js.map +1 -0
  447. package/dist/overlay/floating.d.ts +142 -0
  448. package/dist/overlay/floating.js +226 -0
  449. package/dist/overlay/floating.js.map +1 -0
  450. package/dist/overlay/hover-card.d.ts +19 -0
  451. package/dist/overlay/hover-card.js +31 -0
  452. package/dist/overlay/hover-card.js.map +1 -0
  453. package/dist/overlay/index.d.ts +18 -0
  454. package/dist/overlay/index.js +12 -0
  455. package/dist/overlay/index.js.map +1 -0
  456. package/dist/overlay/overlay-base.d.ts +105 -0
  457. package/dist/overlay/overlay-base.js +250 -0
  458. package/dist/overlay/overlay-base.js.map +1 -0
  459. package/dist/overlay/overlay.d.ts +299 -0
  460. package/dist/overlay/overlay.js +558 -0
  461. package/dist/overlay/overlay.js.map +1 -0
  462. package/dist/overlay/toast.d.ts +58 -0
  463. package/dist/overlay/toast.js +145 -0
  464. package/dist/overlay/toast.js.map +1 -0
  465. package/dist/provider.d.ts +26 -0
  466. package/dist/provider.js +30 -0
  467. package/dist/provider.js.map +1 -0
  468. package/dist/selection/autocomplete.d.ts +54 -0
  469. package/dist/selection/autocomplete.js +122 -0
  470. package/dist/selection/autocomplete.js.map +1 -0
  471. package/dist/selection/checkbox.d.ts +56 -0
  472. package/dist/selection/checkbox.js +49 -0
  473. package/dist/selection/checkbox.js.map +1 -0
  474. package/dist/selection/choice-size.d.ts +26 -0
  475. package/dist/selection/choice-size.js +50 -0
  476. package/dist/selection/choice-size.js.map +1 -0
  477. package/dist/selection/choice-text.d.ts +21 -0
  478. package/dist/selection/choice-text.js +33 -0
  479. package/dist/selection/choice-text.js.map +1 -0
  480. package/dist/selection/combobox.d.ts +173 -0
  481. package/dist/selection/combobox.js +410 -0
  482. package/dist/selection/combobox.js.map +1 -0
  483. package/dist/selection/index.d.ts +20 -0
  484. package/dist/selection/index.js +13 -0
  485. package/dist/selection/index.js.map +1 -0
  486. package/dist/selection/list-box.d.ts +30 -0
  487. package/dist/selection/list-box.js +16 -0
  488. package/dist/selection/list-box.js.map +1 -0
  489. package/dist/selection/listbox.d.ts +44 -0
  490. package/dist/selection/listbox.js +49 -0
  491. package/dist/selection/listbox.js.map +1 -0
  492. package/dist/selection/match.d.ts +20 -0
  493. package/dist/selection/match.js +57 -0
  494. package/dist/selection/match.js.map +1 -0
  495. package/dist/selection/multi-select.d.ts +72 -0
  496. package/dist/selection/multi-select.js +138 -0
  497. package/dist/selection/multi-select.js.map +1 -0
  498. package/dist/selection/radio-card.d.ts +31 -0
  499. package/dist/selection/radio-card.js +29 -0
  500. package/dist/selection/radio-card.js.map +1 -0
  501. package/dist/selection/radio.d.ts +72 -0
  502. package/dist/selection/radio.js +64 -0
  503. package/dist/selection/radio.js.map +1 -0
  504. package/dist/selection/select-public.d.ts +19 -0
  505. package/dist/selection/select-public.js +24 -0
  506. package/dist/selection/select-public.js.map +1 -0
  507. package/dist/selection/select.d.ts +72 -0
  508. package/dist/selection/select.js +69 -0
  509. package/dist/selection/select.js.map +1 -0
  510. package/dist/selection/slider.d.ts +16 -0
  511. package/dist/selection/slider.js +44 -0
  512. package/dist/selection/slider.js.map +1 -0
  513. package/dist/selection/styles.d.ts +26 -0
  514. package/dist/selection/styles.js +78 -0
  515. package/dist/selection/styles.js.map +1 -0
  516. package/dist/selection/switch.d.ts +24 -0
  517. package/dist/selection/switch.js +27 -0
  518. package/dist/selection/switch.js.map +1 -0
  519. package/dist/selection/tag-group.d.ts +38 -0
  520. package/dist/selection/tag-group.js +45 -0
  521. package/dist/selection/tag-group.js.map +1 -0
  522. package/dist/tone.d.ts +6 -0
  523. package/dist/tone.js +2 -0
  524. package/dist/tone.js.map +1 -0
  525. package/dist/utils.d.ts +9 -0
  526. package/dist/utils.js +42 -0
  527. package/dist/utils.js.map +1 -0
  528. package/manifest/component.full.schema.json +391 -0
  529. package/manifest/component.schema.json +279 -0
  530. package/manifests/accordion.json +299 -0
  531. package/manifests/alert-dialog.json +261 -0
  532. package/manifests/area-chart.json +338 -0
  533. package/manifests/autocomplete.json +299 -0
  534. package/manifests/avatar.json +253 -0
  535. package/manifests/badge.json +288 -0
  536. package/manifests/banner.json +185 -0
  537. package/manifests/bar-chart.json +454 -0
  538. package/manifests/bar-list.json +262 -0
  539. package/manifests/bottom-nav.json +139 -0
  540. package/manifests/box.json +3450 -0
  541. package/manifests/breadcrumbs.json +199 -0
  542. package/manifests/button-group.json +2294 -0
  543. package/manifests/button.json +1211 -0
  544. package/manifests/calendar-heatmap.json +218 -0
  545. package/manifests/calendar.json +299 -0
  546. package/manifests/card.json +308 -0
  547. package/manifests/carousel.json +263 -0
  548. package/manifests/chart-parts.json +309 -0
  549. package/manifests/checkbox.json +998 -0
  550. package/manifests/close-button.json +1000 -0
  551. package/manifests/color-field.json +276 -0
  552. package/manifests/color-picker.json +161 -0
  553. package/manifests/color-swatch-picker.json +220 -0
  554. package/manifests/color-swatch.json +140 -0
  555. package/manifests/combobox.json +581 -0
  556. package/manifests/command.json +275 -0
  557. package/manifests/composed-chart.json +287 -0
  558. package/manifests/context-menu.json +148 -0
  559. package/manifests/copy-button.json +192 -0
  560. package/manifests/data-table.json +334 -0
  561. package/manifests/date-field.json +302 -0
  562. package/manifests/date-picker.json +472 -0
  563. package/manifests/description-list.json +201 -0
  564. package/manifests/dialog.json +322 -0
  565. package/manifests/donut-chart.json +264 -0
  566. package/manifests/drawer.json +211 -0
  567. package/manifests/empty-state.json +185 -0
  568. package/manifests/fab.json +172 -0
  569. package/manifests/field.json +209 -0
  570. package/manifests/file-upload.json +791 -0
  571. package/manifests/form.json +829 -0
  572. package/manifests/funnel-chart.json +223 -0
  573. package/manifests/gauge-chart.json +252 -0
  574. package/manifests/grid-list.json +335 -0
  575. package/manifests/grid.json +3482 -0
  576. package/manifests/heading.json +183 -0
  577. package/manifests/heatmap.json +265 -0
  578. package/manifests/hover-card.json +172 -0
  579. package/manifests/icon.json +201 -0
  580. package/manifests/image-cropper.json +295 -0
  581. package/manifests/image-viewer.json +198 -0
  582. package/manifests/image.json +193 -0
  583. package/manifests/index.json +2035 -0
  584. package/manifests/input-group.json +3571 -0
  585. package/manifests/input.json +1557 -0
  586. package/manifests/kbd.json +98 -0
  587. package/manifests/language-switcher.json +274 -0
  588. package/manifests/line-chart.json +342 -0
  589. package/manifests/link.json +867 -0
  590. package/manifests/list-box.json +213 -0
  591. package/manifests/menu.json +453 -0
  592. package/manifests/meter.json +145 -0
  593. package/manifests/navbar.json +281 -0
  594. package/manifests/otp-field.json +1029 -0
  595. package/manifests/page-header.json +164 -0
  596. package/manifests/pagination.json +181 -0
  597. package/manifests/popover.json +205 -0
  598. package/manifests/pressable.json +367 -0
  599. package/manifests/progress.json +282 -0
  600. package/manifests/radar-chart.json +229 -0
  601. package/manifests/radial-chart.json +195 -0
  602. package/manifests/radio.json +975 -0
  603. package/manifests/scatter-chart.json +277 -0
  604. package/manifests/scroll-area.json +127 -0
  605. package/manifests/section.json +169 -0
  606. package/manifests/select.json +474 -0
  607. package/manifests/separator.json +119 -0
  608. package/manifests/sidebar.json +584 -0
  609. package/manifests/skeleton.json +235 -0
  610. package/manifests/skip-link.json +89 -0
  611. package/manifests/slider.json +706 -0
  612. package/manifests/sparkline.json +208 -0
  613. package/manifests/spinner.json +105 -0
  614. package/manifests/split.json +6618 -0
  615. package/manifests/stack.json +3541 -0
  616. package/manifests/stat.json +192 -0
  617. package/manifests/stepper.json +279 -0
  618. package/manifests/switch.json +205 -0
  619. package/manifests/table.json +375 -0
  620. package/manifests/tabs.json +438 -0
  621. package/manifests/tag-group.json +264 -0
  622. package/manifests/text-area.json +1136 -0
  623. package/manifests/text.json +244 -0
  624. package/manifests/theme-switcher.json +152 -0
  625. package/manifests/time-field.json +284 -0
  626. package/manifests/timeline.json +196 -0
  627. package/manifests/toast.json +87 -0
  628. package/manifests/toggle-button.json +1489 -0
  629. package/manifests/toolbar.json +145 -0
  630. package/manifests/tooltip.json +181 -0
  631. package/manifests/tracker.json +192 -0
  632. package/manifests/tree.json +245 -0
  633. package/manifests/visually-hidden.json +114 -0
  634. package/package.json +117 -3
  635. package/styles/base.css +56 -0
  636. package/styles/theme.css +154 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/form/files.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,QAAQ,IAAI,YAAY,EACxB,WAAW,IAAI,eAAe,EAC9B,SAAS,GAGV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAC5H,aAAa,EAAE,cAAc,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,MAAc;IAC1D,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;IACpE,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,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C,QAAQ,EAAC,IAAI,EAAC,OAAO,EAAC,QAAQ,QAAC,UAAU,EAAC,SAAS,gBAAa,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,GAAI,CAC/H,CAAC,CAAC,CAAC,IAAI,IACL,CACN,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAwD;IACxH,OAAO;IACL,mEAAmE;IACnE,aAAI,IAAI,EAAC,MAAM,gBAAa,SAAS,eAAY,WAAW,EAAC,SAAS,EAAC,4CAA4C,YAChH,QAAQ,GACN,CACN,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Button as AriaButton,\n DropZone as AriaDropZone,\n FileTrigger as AriaFileTrigger,\n useLocale,\n type DropItem,\n type FileTriggerProps as AriaFileTriggerProps,\n} from \"react-aria-components\";\nimport { IconGlyph } from \"../display/icon\";\n\nimport { cn } from \"../utils\";\nimport {\n cancelUploadLabel, chooseFilesLabel, onlyOneLabel, orChooseTemplate, removeFileLabel, replaceLabel, tooLargeLabel, upToLabel,\n uploadedLabel, wrongTypeLabel,\n} from \"../i18n\";\nimport { Button } from \"../action/button\";\nimport { LINK_FOCUS } from \"../action/styles\";\n\n/** Bytes as the locale writes them: \"2.4 MB\", \"980 kB\". */\nexport function formatFileSize(bytes: number, locale: string): string {\n const units = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\"] as const;\n let value = bytes;\n let unit = 0;\n // Round the way the unit will print before choosing it, so 999,600 bytes is \"1 MB\", not \"1.000 kB\".\n const rounded = () => (unit < 2 ? Math.round(value) : Math.round(value * 10) / 10);\n while (rounded() >= 1000 && unit < units.length - 1) {\n value /= 1000;\n unit += 1;\n }\n return new Intl.NumberFormat(locale, {\n style: \"unit\",\n unit: units[unit],\n unitDisplay: \"short\",\n maximumFractionDigits: unit < 2 ? 0 : 1,\n }).format(value);\n}\n\nexport type FileRules = {\n /** MIME types or extensions: \"image/jpeg\", \"image/*\", \".heic\", \"application/pdf\". */\n acceptedFileTypes?: readonly string[];\n /** Bytes. */\n maxSize?: number;\n};\n\nexport type RejectedFile = { file: File; reason: string };\n\nfunction accepts(file: File, types: readonly string[] | undefined) {\n if (!types || types.length === 0) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return types.some((rule) => {\n const pattern = rule.toLowerCase().trim();\n if (pattern.startsWith(\".\")) return name.endsWith(pattern);\n if (pattern.endsWith(\"/*\")) return type.startsWith(pattern.slice(0, -1));\n return type === pattern;\n });\n}\n\n/**\n * Checks each file on its own: a wrong type or a file over `maxSize` is\n * rejected with the reason, and the others are kept (design rule).\n */\nexport function validateFiles(files: readonly File[], rules: FileRules, locale: string) {\n const accepted: File[] = [];\n const rejected: RejectedFile[] = [];\n for (const file of files) {\n if (!accepts(file, rules.acceptedFileTypes)) rejected.push({ file, reason: wrongTypeLabel(locale) });\n else if (rules.maxSize !== undefined && file.size > rules.maxSize) {\n rejected.push({ file, reason: tooLargeLabel(locale, formatFileSize(rules.maxSize, locale)) });\n } else accepted.push(file);\n }\n return { accepted, rejected };\n}\n\nexport type FileTriggerProps = Omit<AriaFileTriggerProps, \"onSelect\" | \"acceptedFileTypes\"> &\n FileRules & {\n /** Files that passed the rules. */\n onSelect?: (files: File[]) => void;\n /** Files that did not, each with its reason. */\n onReject?: (rejected: RejectedFile[]) => void;\n /** The control that opens the picker: a DS Button or Link. */\n children: React.ReactElement;\n };\n\n/**\n * Hands the picked files on, then empties the picker's hidden input, so the same file picked again is\n * a change and reaches the app again, however the input was filled. The files are copied\n * out of the FileList before the callbacks run; clearing the input empties that list, not the copies.\n */\nfunction pickThenClear(input: React.RefObject<HTMLInputElement | null>, list: FileList | null, handle: (files: File[]) => void) {\n const files = Array.from(list ?? []);\n try {\n handle(files);\n } finally {\n if (input.current) input.current.value = \"\";\n }\n}\n\n/** Opens the system file picker from any button. */\nexport function FileTrigger({ onSelect, onReject, acceptedFileTypes, maxSize, children, ...rest }: FileTriggerProps) {\n const { locale } = useLocale();\n const inputRef = React.useRef<HTMLInputElement>(null);\n return (\n <AriaFileTrigger\n {...rest}\n ref={inputRef}\n acceptedFileTypes={acceptedFileTypes ? [...acceptedFileTypes] : undefined}\n onSelect={(list) =>\n pickThenClear(inputRef, list, (files) => {\n const { accepted, rejected } = validateFiles(files, { acceptedFileTypes, maxSize }, locale);\n if (accepted.length) onSelect?.(accepted);\n if (rejected.length) onReject?.(rejected);\n })\n }\n >\n {children}\n </AriaFileTrigger>\n );\n}\n\nexport type DropZoneProps = FileRules & {\n /** What to drop, as a call to action: \"Drag your photos here\". */\n label: string;\n /** The accepted types as people read them (\"JPG, PNG, HEIC\"); the size limit is added. */\n typesLabel?: string;\n allowsMultiple?: boolean;\n onSelect?: (files: File[]) => void;\n onReject?: (rejected: RejectedFile[]) => void;\n isDisabled?: boolean;\n};\n\n/** The files among dropped items; folders, text and files the browser cannot read are skipped. */\nexport async function filesFrom(items: readonly DropItem[]) {\n const reads = items.flatMap((item) => (item.kind === \"file\" ? [item.getFile()] : []));\n const results = await Promise.allSettled(reads);\n return results.flatMap((result) => (result.status === \"fulfilled\" ? [result.value] : []));\n}\n\n/**\n * A drop target with the picker inside: states the accepted types and the\n * size limit before the user picks; while a file is over it the zone takes\n * the selected fill and border.\n */\nexport function DropZone({ label, typesLabel, allowsMultiple, acceptedFileTypes, maxSize, onSelect, onReject, isDisabled }: DropZoneProps) {\n const { locale } = useLocale();\n const inputRef = React.useRef<HTMLInputElement>(null);\n const handle = (files: File[]) => {\n const list = allowsMultiple ? files : files.slice(0, 1);\n const { accepted, rejected } = validateFiles(list, { acceptedFileTypes, maxSize }, locale);\n // Extra files on a single-file zone are rejected with a reason, never dropped silently.\n if (!allowsMultiple) for (const file of files.slice(1)) rejected.push({ file, reason: onlyOneLabel(locale) });\n if (accepted.length) onSelect?.(accepted);\n if (rejected.length) onReject?.(rejected);\n };\n const [before, after] = orChooseTemplate(locale).split(\"{choose}\");\n const details = [typesLabel, maxSize !== undefined ? upToLabel(locale, formatFileSize(maxSize, locale)) : undefined]\n .filter(Boolean)\n .join(\" · \");\n\n return (\n <AriaDropZone\n // Names the zone's keyboard and paste target (React Aria's own fallback is the untranslated \"DropZone\").\n aria-label={label}\n isDisabled={isDisabled}\n onDrop={async (event) => handle(await filesFrom(event.items))}\n data-slot=\"drop-zone\"\n className={cn(\n \"flex flex-col items-center justify-center gap-ds-100 rounded-ds-large border-[1.5px] border-dashed border-ds-border-bold bg-ds-surface-sunken p-ds-400 text-center outline-hidden\",\n \"data-[drop-target]:border-ds-border-selected data-[drop-target]:bg-ds-background-selected\",\n // Keyboard focus: the 2px inner border every DS control uses.\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:border-ds-border data-[disabled]:bg-ds-background-disabled\",\n )}\n >\n <IconGlyph name=\"image-up\" size=\"large\" color=\"subtle\" data-slot=\"drop-zone-icon\" />\n <span data-slot=\"drop-zone-label\" className=\"text-body-strong text-ds-text\">{label}</span>\n <span data-slot=\"drop-zone-help\" className=\"text-body-small text-ds-text-subtlest\">\n {before}\n <AriaFileTrigger\n ref={inputRef}\n allowsMultiple={allowsMultiple}\n acceptedFileTypes={acceptedFileTypes ? [...acceptedFileTypes] : undefined}\n onSelect={(list) => pickThenClear(inputRef, list, handle)}\n >\n <AriaButton\n isDisabled={isDisabled}\n data-slot=\"drop-zone-choose\"\n className={cn(\n \"cursor-pointer text-ds-link underline-offset-3 data-[hovered]:underline\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:text-ds-text-disabled data-[disabled]:no-underline\",\n LINK_FOCUS,\n )}\n >\n {chooseFilesLabel(locale)}\n </AriaButton>\n </AriaFileTrigger>\n {after}\n {details && ` · ${details}`}\n </span>\n </AriaDropZone>\n );\n}\n\n/** A thumbnail URL for an image file, created in an effect and revoked on change or unmount. */\nfunction useObjectUrl(file: File | undefined) {\n const [url, setUrl] = React.useState<string>();\n React.useEffect(() => {\n if (!file || !file.type.startsWith(\"image/\") || typeof URL.createObjectURL !== \"function\") {\n setUrl(undefined);\n return;\n }\n const next = URL.createObjectURL(file);\n setUrl(next);\n return () => URL.revokeObjectURL(next);\n }, [file]);\n return url;\n}\n\nexport type FileRowProps = {\n /** The picked file; photos get a thumbnail at once, before upload ends. */\n file?: File;\n /** Shown name and size when there is no File object (a stored document). */\n name?: string;\n size?: number;\n /** 0–1 while uploading; omit when done. */\n progress?: number;\n error?: string;\n onCancel?: () => void;\n onRemove?: () => void;\n onReplace?: () => void;\n};\n\n/** One picked or stored file: thumbnail, name, progress or size, per-file error, one trailing action. */\nexport function FileRow({ file, name, size, progress, error, onCancel, onRemove, onReplace }: FileRowProps) {\n const { locale } = useLocale();\n const url = useObjectUrl(file);\n // A type the browser cannot draw (HEIC on most browsers) falls back to the file icon.\n const [broken, setBroken] = React.useState<string>();\n const thumbnail = url && url !== broken ? url : undefined;\n const total = size ?? file?.size;\n const uploading = progress !== undefined && progress < 1 && !error;\n\n return (\n <li\n data-slot=\"file-row\"\n data-state={error ? \"error\" : uploading ? \"uploading\" : \"done\"}\n className=\"flex items-center gap-ds-150 rounded-ds-large bg-ds-surface-raised p-ds-100 pe-ds-150 shadow-ds-raised\"\n >\n <span data-slot=\"file-thumbnail\" className=\"grid size-10 shrink-0 place-items-center overflow-hidden rounded-ds-medium bg-ds-surface-sunken\">\n {thumbnail ? <img src={thumbnail} alt=\"\" onError={() => setBroken(thumbnail)} className=\"size-full object-cover\" /> : <IconGlyph name={error ? \"file-exclamation-point\" : \"file\"} color=\"subtle\" data-slot=\"file-row-icon\" />}\n </span>\n <span className=\"flex min-w-0 flex-1 flex-col gap-ds-050\">\n <span data-slot=\"file-name\" className=\"truncate text-body text-ds-text\">{name ?? file?.name}</span>\n {uploading && (\n <span\n role=\"progressbar\"\n aria-label={name ?? file?.name}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round((progress ?? 0) * 100)}\n aria-valuetext={total !== undefined ? `${formatFileSize(total * (progress ?? 0), locale)} / ${formatFileSize(total, locale)}` : undefined}\n data-slot=\"file-progress\"\n className=\"h-1 overflow-hidden rounded-ds-full bg-ds-background-neutral\"\n >\n <span className=\"block h-full rounded-ds-full bg-ds-background-brand-bold\" style={{ width: `${Math.round((progress ?? 0) * 100)}%` }} />\n </span>\n )}\n {error ? (\n <span role=\"status\" data-slot=\"file-error\" className=\"text-body-small text-ds-text-danger\">{error}</span>\n ) : total !== undefined ? (\n <span data-slot=\"file-meta\" className=\"text-body-small tabular-nums text-ds-text-subtlest\">\n {uploading\n ? `${formatFileSize(total * (progress ?? 0), locale)} / ${formatFileSize(total, locale)}`\n : `${formatFileSize(total, locale)} · ${uploadedLabel(locale)}`}\n </span>\n ) : null}\n </span>\n {error && onReplace ? (\n <Button variant=\"link\" size=\"small\" onPress={onReplace}>{replaceLabel(locale)}</Button>\n ) : uploading && onCancel ? (\n <Button variant=\"subtle\" size=\"small\" iconOnly iconBefore=\"x\" aria-label={cancelUploadLabel(locale)} onPress={onCancel} />\n ) : onRemove ? (\n <Button variant=\"subtle\" size=\"small\" iconOnly iconBefore=\"trash-2\" aria-label={removeFileLabel(locale)} onPress={onRemove} />\n ) : null}\n </li>\n );\n}\n\n/** The list of picked or stored files. */\nexport function FileUploadList({ children, \"aria-label\": ariaLabel }: { children: React.ReactNode; \"aria-label\"?: string }) {\n return (\n // role=\"list\": Safari drops the list role from a `list-none` list.\n <ul role=\"list\" aria-label={ariaLabel} data-slot=\"file-list\" className=\"m-0 flex list-none flex-col gap-ds-100 p-0\">\n {children}\n </ul>\n );\n}\n\n"]}
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import { type FormProps as AriaFormProps } from "react-aria-components";
3
+ export type FormProps = Omit<AriaFormProps, "className" | "style"> & {
4
+ children: React.ReactNode;
5
+ /** `narrow` (default) caps single-column forms at 560px. */
6
+ width?: "narrow" | "full";
7
+ };
8
+ /**
9
+ * Arranges sections and one action footer. `validationBehavior` defaults to
10
+ * `aria`: errors show on blur and on submit without blocking native submit.
11
+ * On submit, if any field is invalid the first one gets focus and
12
+ * `onSubmit` is not called (a Select or MultiSelect too, at its trigger); entered values are always kept. A required
13
+ * field left empty is invalid from the first submit on, the selection fields included, unless it
14
+ * leaves that to the app (`requiredValidation="app"`). Server errors
15
+ * passed as `validationErrors` mark their fields invalid until the user
16
+ * edits them (React Aria), so the same data cannot be resubmitted unchanged.
17
+ * Native behaviour (`validationBehavior="native"`) leaves blocking to the browser.
18
+ *
19
+ * A reset (a reset button, or `form.reset()`) puts the values back and clears what the fields show. Under native
20
+ * behaviour React Aria clears a field's message only on a reset from a user event, and keeps it after a programmatic
21
+ * `form.reset()` outside one (to keep a form action's server errors); the date and time fields clear theirs on
22
+ * every reset, except a server error the form holds.
23
+ */
24
+ export declare function Form({ children, width, validationBehavior, onSubmit, onReset, ...rest }: FormProps): React.JSX.Element;
25
+ export type FormSectionProps = {
26
+ /** The section title (`heading-small`). */
27
+ legend: React.ReactNode;
28
+ children: React.ReactNode;
29
+ isDisabled?: boolean;
30
+ };
31
+ /** A titled group of related fields; a real `fieldset` with a `legend`. */
32
+ export declare function FormSection({ legend, children, isDisabled }: FormSectionProps): React.JSX.Element;
33
+ /** Two fields read together (first and last name); stacks when the row is narrower than 360px. */
34
+ export declare function FormRow({ children }: {
35
+ children: React.ReactNode;
36
+ }): React.JSX.Element;
37
+ /** The action footer on a `ds-border` rule: subtle cancel, then primary, aligned to the end. */
38
+ export declare function FormFooter({ children }: {
39
+ children: React.ReactNode;
40
+ }): React.JSX.Element;
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { flushSync } from "react-dom";
5
+ import { Form as AriaForm } from "react-aria-components";
6
+ import { FormSubmittedContext } from "./validation.js";
7
+ /**
8
+ * Arranges sections and one action footer. `validationBehavior` defaults to
9
+ * `aria`: errors show on blur and on submit without blocking native submit.
10
+ * On submit, if any field is invalid the first one gets focus and
11
+ * `onSubmit` is not called (a Select or MultiSelect too, at its trigger); entered values are always kept. A required
12
+ * field left empty is invalid from the first submit on, the selection fields included, unless it
13
+ * leaves that to the app (`requiredValidation="app"`). Server errors
14
+ * passed as `validationErrors` mark their fields invalid until the user
15
+ * edits them (React Aria), so the same data cannot be resubmitted unchanged.
16
+ * Native behaviour (`validationBehavior="native"`) leaves blocking to the browser.
17
+ *
18
+ * A reset (a reset button, or `form.reset()`) puts the values back and clears what the fields show. Under native
19
+ * behaviour React Aria clears a field's message only on a reset from a user event, and keeps it after a programmatic
20
+ * `form.reset()` outside one (to keep a form action's server errors); the date and time fields clear theirs on
21
+ * every reset, except a server error the form holds.
22
+ */
23
+ export function Form({ children, width = "narrow", validationBehavior = "aria", onSubmit, onReset, ...rest }) {
24
+ const [state, setState] = React.useState({ submitted: false, resetCount: 0, inForm: true });
25
+ return (_jsx(FormSubmittedContext.Provider, { value: state, children: _jsx(AriaForm, { ...rest, validationBehavior: validationBehavior, "data-slot": "form", onReset: (event) => {
26
+ setState((current) => ({ ...current, submitted: false, resetCount: current.resetCount + 1 }));
27
+ onReset?.(event);
28
+ }, className: width === "narrow" ? "flex w-full max-w-[560px] flex-col gap-ds-300" : "flex w-full flex-col gap-ds-300", onSubmit: (event) => {
29
+ // Every field shows its errors from the first submit on; render that before looking for them.
30
+ flushSync(() => setState((current) => ({ ...current, submitted: true })));
31
+ const invalid = event.currentTarget.querySelectorAll(INVALID);
32
+ if (invalid.length > 0) {
33
+ event.preventDefault();
34
+ focusTarget(invalid)?.focus();
35
+ return;
36
+ }
37
+ onSubmit?.(event);
38
+ }, children: children }) }));
39
+ }
40
+ /** An invalid field: its own mark (`aria-invalid` on the input) or its root's (`data-invalid`, React Aria's and the DS's). */
41
+ const INVALID = '[aria-invalid="true"], [data-invalid]';
42
+ const FOCUSABLE = "input:not([type='hidden']), textarea, select, button, [tabindex]";
43
+ /** Something the user can reach: enabled, in the tab order, not in a part hidden from assistive tech (React Aria's hidden select). */
44
+ function reachable(element) {
45
+ return element.matches(FOCUSABLE) && !element.matches(":disabled") && element.tabIndex >= 0 && !element.closest("[aria-hidden='true']");
46
+ }
47
+ /**
48
+ * Where focus goes for the first invalid field, in the form's order: the element marked `aria-invalid` (a text input,
49
+ * a ComboBox input, a date segment), else its typed input, else the button that opens its list (a Select's or
50
+ * MultiSelect's trigger, whose own button carries no `aria-invalid` and whose hidden native select is not focusable;
51
+ * a MultiSelect's tag buttons come before it), else the first control the user can reach in it.
52
+ */
53
+ function focusTarget(invalid) {
54
+ for (const root of invalid) {
55
+ const within = (selector) => [...(root.matches(selector) ? [root] : []), ...root.querySelectorAll(selector)].find(reachable);
56
+ const target = within('[aria-invalid="true"]') ?? within("input, textarea") ?? within("[aria-haspopup]") ?? within(FOCUSABLE);
57
+ if (target)
58
+ return target;
59
+ }
60
+ return null;
61
+ }
62
+ /** A titled group of related fields; a real `fieldset` with a `legend`. */
63
+ export function FormSection({ legend, children, isDisabled }) {
64
+ return (_jsxs("fieldset", { disabled: isDisabled, "data-slot": "form-section", className: "m-0 flex min-w-0 flex-col gap-ds-200 border-0 p-0", children: [_jsx("legend", { "data-slot": "form-section-legend", className: "heading-small mb-ds-200 p-0 text-ds-text", children: legend }), children] }));
65
+ }
66
+ /** Two fields read together (first and last name); stacks when the row is narrower than 360px. */
67
+ export function FormRow({ children }) {
68
+ return (_jsx("div", { "data-slot": "form-row", className: "@container", children: _jsx("div", { className: "grid grid-cols-1 gap-ds-200 @min-[360px]:grid-cols-2", children: children }) }));
69
+ }
70
+ /** The action footer on a `ds-border` rule: subtle cancel, then primary, aligned to the end. */
71
+ export function FormFooter({ children }) {
72
+ return (_jsx("div", { "data-slot": "form-footer", className: "flex flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border pt-ds-200", children: children }));
73
+ }
74
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@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B,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;QAC9H,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AASD,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAoB;IAC5E,OAAO,CACL,oBAAU,QAAQ,EAAE,UAAU,eAAY,cAAc,EAAC,SAAS,EAAC,mDAAmD,aACpH,8BAAkB,qBAAqB,EAAC,SAAS,EAAC,0CAA0C,YACzF,MAAM,GACA,EACR,QAAQ,IACA,CACZ,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAiC;IACjE,OAAO,CACL,2BAAe,UAAU,EAAC,SAAS,EAAC,YAAY,YAC9C,cAAK,SAAS,EAAC,sDAAsD,YAAE,QAAQ,GAAO,GAClF,CACP,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAiC;IACpE,OAAO,CACL,2BAAe,aAAa,EAAC,SAAS,EAAC,wFAAwF,YAC5H,QAAQ,GACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Form as AriaForm, type FormProps as AriaFormProps } from \"react-aria-components\";\n\nimport { FormSubmittedContext } from \"./validation\";\n\nexport type FormProps = Omit<AriaFormProps, \"className\" | \"style\"> & {\n children: React.ReactNode;\n /** `narrow` (default) caps single-column forms at 560px. */\n width?: \"narrow\" | \"full\";\n};\n\n/**\n * Arranges sections and one action footer. `validationBehavior` defaults to\n * `aria`: errors show on blur and on submit without blocking native submit.\n * On submit, if any field is invalid the first one gets focus and\n * `onSubmit` is not called (a Select or MultiSelect too, at its trigger); entered values are always kept. A required\n * field left empty is invalid from the first submit on, the selection fields included, unless it\n * leaves that to the app (`requiredValidation=\"app\"`). Server errors\n * passed as `validationErrors` mark their fields invalid until the user\n * edits them (React Aria), so the same data cannot be resubmitted unchanged.\n * Native behaviour (`validationBehavior=\"native\"`) leaves blocking to the browser.\n *\n * A reset (a reset button, or `form.reset()`) puts the values back and clears what the fields show. Under native\n * behaviour React Aria clears a field's message only on a reset from a user event, and keeps it after a programmatic\n * `form.reset()` outside one (to keep a form action's server errors); the date and time fields clear theirs on\n * every reset, except a server error the form holds.\n */\nexport function Form({ children, width = \"narrow\", validationBehavior = \"aria\", onSubmit, onReset, ...rest }: FormProps) {\n const [state, setState] = React.useState({ submitted: false, resetCount: 0, inForm: true });\n return (\n <FormSubmittedContext.Provider value={state}>\n <AriaForm\n {...rest}\n validationBehavior={validationBehavior}\n data-slot=\"form\"\n onReset={(event) => {\n setState((current) => ({ ...current, submitted: false, resetCount: current.resetCount + 1 }));\n onReset?.(event);\n }}\n className={width === \"narrow\" ? \"flex w-full max-w-[560px] flex-col gap-ds-300\" : \"flex w-full flex-col gap-ds-300\"}\n onSubmit={(event) => {\n // Every field shows its errors from the first submit on; render that before looking for them.\n flushSync(() => setState((current) => ({ ...current, submitted: true })));\n const invalid = event.currentTarget.querySelectorAll<HTMLElement>(INVALID);\n if (invalid.length > 0) {\n event.preventDefault();\n focusTarget(invalid)?.focus();\n return;\n }\n onSubmit?.(event);\n }}\n >\n {children}\n </AriaForm>\n </FormSubmittedContext.Provider>\n );\n}\n\n/** An invalid field: its own mark (`aria-invalid` on the input) or its root's (`data-invalid`, React Aria's and the DS's). */\nconst INVALID = '[aria-invalid=\"true\"], [data-invalid]';\nconst FOCUSABLE = \"input:not([type='hidden']), textarea, select, button, [tabindex]\";\n\n/** Something the user can reach: enabled, in the tab order, not in a part hidden from assistive tech (React Aria's hidden select). */\nfunction reachable(element: HTMLElement) {\n return element.matches(FOCUSABLE) && !element.matches(\":disabled\") && element.tabIndex >= 0 && !element.closest(\"[aria-hidden='true']\");\n}\n\n/**\n * Where focus goes for the first invalid field, in the form's order: the element marked `aria-invalid` (a text input,\n * a ComboBox input, a date segment), else its typed input, else the button that opens its list (a Select's or\n * MultiSelect's trigger, whose own button carries no `aria-invalid` and whose hidden native select is not focusable;\n * a MultiSelect's tag buttons come before it), else the first control the user can reach in it.\n */\nfunction focusTarget(invalid: NodeListOf<HTMLElement>): HTMLElement | null {\n for (const root of invalid) {\n const within = (selector: string) =>\n [...(root.matches(selector) ? [root] : []), ...root.querySelectorAll<HTMLElement>(selector)].find(reachable);\n const target = within('[aria-invalid=\"true\"]') ?? within(\"input, textarea\") ?? within(\"[aria-haspopup]\") ?? within(FOCUSABLE);\n if (target) return target;\n }\n return null;\n}\n\nexport type FormSectionProps = {\n /** The section title (`heading-small`). */\n legend: React.ReactNode;\n children: React.ReactNode;\n isDisabled?: boolean;\n};\n\n/** A titled group of related fields; a real `fieldset` with a `legend`. */\nexport function FormSection({ legend, children, isDisabled }: FormSectionProps) {\n return (\n <fieldset disabled={isDisabled} data-slot=\"form-section\" className=\"m-0 flex min-w-0 flex-col gap-ds-200 border-0 p-0\">\n <legend data-slot=\"form-section-legend\" className=\"heading-small mb-ds-200 p-0 text-ds-text\">\n {legend}\n </legend>\n {children}\n </fieldset>\n );\n}\n\n/** Two fields read together (first and last name); stacks when the row is narrower than 360px. */\nexport function FormRow({ children }: { children: React.ReactNode }) {\n return (\n <div data-slot=\"form-row\" className=\"@container\">\n <div className=\"grid grid-cols-1 gap-ds-200 @min-[360px]:grid-cols-2\">{children}</div>\n </div>\n );\n}\n\n/** The action footer on a `ds-border` rule: subtle cancel, then primary, aligned to the end. */\nexport function FormFooter({ children }: { children: React.ReactNode }) {\n return (\n <div data-slot=\"form-footer\" className=\"flex flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border pt-ds-200\">\n {children}\n </div>\n );\n}\n"]}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * ImageCropper's geometry and output, kept apart from the component so the rules the
3
+ * cropper exists for are tested on their own:
4
+ * - never upscale: the output is the crop region in source pixels, only ever scaled down;
5
+ * - contain never paints black: an output without alpha (JPEG) fills the empty area with the
6
+ * background, white by default; PNG and WebP keep it transparent.
7
+ *
8
+ * Coordinates are in the source's pixels after rotation ("rotated space"): a 90° turn of a 4000 × 3000
9
+ * photo is a 3000 × 4000 image to crop.
10
+ */
11
+ export type CropFit = "cover" | "contain";
12
+ export type CropOutputType = "image/jpeg" | "image/png" | "image/webp";
13
+ export type CropRotation = 0 | 90 | 180 | 270;
14
+ export type CropState = {
15
+ /** 1 shows the whole fit; up to 4. */
16
+ zoom: number;
17
+ /** The crop region's centre, in rotated-space pixels. */
18
+ centerX: number;
19
+ centerY: number;
20
+ rotation: CropRotation;
21
+ };
22
+ export type CropRegion = {
23
+ left: number;
24
+ top: number;
25
+ width: number;
26
+ height: number;
27
+ };
28
+ export declare const MIN_ZOOM = 1;
29
+ export declare const MAX_ZOOM = 4;
30
+ /** Outputs that keep transparency; the rest get the background under empty areas. */
31
+ export declare const hasAlpha: (type: CropOutputType) => type is "image/png" | "image/webp";
32
+ /** The source's size once turned. */
33
+ export declare function rotatedSize(width: number, height: number, rotation: CropRotation): {
34
+ width: number;
35
+ height: number;
36
+ };
37
+ /**
38
+ * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that
39
+ * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).
40
+ * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is
41
+ * smaller than, and stays centred along a side it is larger than (only contain's empty area).
42
+ */
43
+ export declare function cropRegion(image: {
44
+ width: number;
45
+ height: number;
46
+ }, aspect: number, fit: CropFit, state: Pick<CropState, "zoom" | "centerX" | "centerY">): CropRegion;
47
+ export declare const clampZoom: (zoom: number) => number;
48
+ /**
49
+ * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.
50
+ * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).
51
+ */
52
+ export declare function outputSize(region: CropRegion, { maxOutputSize, minOutputSize }: {
53
+ maxOutputSize?: number;
54
+ minOutputSize?: number;
55
+ }): {
56
+ width: number;
57
+ height: number;
58
+ scale: number;
59
+ small: boolean;
60
+ };
61
+ /** The 2D context calls the renderer makes; a canvas's context, or a recorder in tests. */
62
+ export type CropContext = Pick<CanvasRenderingContext2D, "fillStyle" | "fillRect" | "clearRect" | "save" | "restore" | "translate" | "rotate" | "scale" | "drawImage" | "imageSmoothingEnabled" | "imageSmoothingQuality">;
63
+ /**
64
+ * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty
65
+ * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills
66
+ * the canvas.
67
+ */
68
+ export declare function drawCrop(context: CropContext, image: CanvasImageSource, source: {
69
+ width: number;
70
+ height: number;
71
+ }, region: CropRegion, size: {
72
+ width: number;
73
+ height: number;
74
+ }, { rotation, outputType, background }: {
75
+ rotation: CropRotation;
76
+ outputType: CropOutputType;
77
+ background?: string;
78
+ }): void;
79
+ /** The output file's extension for its type. */
80
+ export declare const extensionOf: (type: CropOutputType) => "jpg" | "png" | "webp";
81
+ /**
82
+ * The qualities to try under a byte limit, as an image upload typically needs for a logo,
83
+ * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most
84
+ * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.
85
+ */
86
+ export declare function qualitySteps({ outputType, quality, minimumQuality, maxBytes }: {
87
+ outputType: CropOutputType;
88
+ quality: number;
89
+ minimumQuality?: number;
90
+ maxBytes?: number;
91
+ }): number[];
92
+ export type EncodeResult = {
93
+ blob: Blob;
94
+ quality: number;
95
+ fits: boolean;
96
+ };
97
+ /**
98
+ * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is
99
+ * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.
100
+ */
101
+ export declare function encodeWithin(encode: (quality: number | undefined) => Promise<Blob | null>, options: {
102
+ outputType: CropOutputType;
103
+ quality: number;
104
+ minimumQuality?: number;
105
+ maxBytes?: number;
106
+ }): Promise<EncodeResult>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * ImageCropper's geometry and output, kept apart from the component so the rules the
3
+ * cropper exists for are tested on their own:
4
+ * - never upscale: the output is the crop region in source pixels, only ever scaled down;
5
+ * - contain never paints black: an output without alpha (JPEG) fills the empty area with the
6
+ * background, white by default; PNG and WebP keep it transparent.
7
+ *
8
+ * Coordinates are in the source's pixels after rotation ("rotated space"): a 90° turn of a 4000 × 3000
9
+ * photo is a 3000 × 4000 image to crop.
10
+ */
11
+ export const MIN_ZOOM = 1;
12
+ export const MAX_ZOOM = 4;
13
+ /** Outputs that keep transparency; the rest get the background under empty areas. */
14
+ export const hasAlpha = (type) => type !== "image/jpeg";
15
+ /** The source's size once turned. */
16
+ export function rotatedSize(width, height, rotation) {
17
+ return rotation % 180 === 0 ? { width, height } : { width: height, height: width };
18
+ }
19
+ /**
20
+ * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that
21
+ * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).
22
+ * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is
23
+ * smaller than, and stays centred along a side it is larger than (only contain's empty area).
24
+ */
25
+ export function cropRegion(image, aspect, fit, state) {
26
+ const imageAspect = image.width / image.height;
27
+ const widerFrame = aspect > imageAspect;
28
+ // cover: limited by the image's short side for this shape; contain: by its long side.
29
+ const baseWidth = fit === "cover" ? (widerFrame ? image.width : image.height * aspect) : widerFrame ? image.height * aspect : image.width;
30
+ const zoom = clampZoom(state.zoom);
31
+ const width = baseWidth / zoom;
32
+ const height = width / aspect;
33
+ const centerX = clampCenter(state.centerX, width, image.width);
34
+ const centerY = clampCenter(state.centerY, height, image.height);
35
+ return { left: centerX - width / 2, top: centerY - height / 2, width, height };
36
+ }
37
+ export const clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Number.isFinite(zoom) ? zoom : MIN_ZOOM));
38
+ function clampCenter(center, size, extent) {
39
+ if (size >= extent)
40
+ return extent / 2;
41
+ return Math.min(extent - size / 2, Math.max(size / 2, center));
42
+ }
43
+ /**
44
+ * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.
45
+ * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).
46
+ */
47
+ export function outputSize(region, { maxOutputSize, minOutputSize }) {
48
+ const long = Math.max(region.width, region.height);
49
+ const scale = maxOutputSize && long > maxOutputSize ? maxOutputSize / long : 1;
50
+ const width = Math.max(1, Math.round(region.width * scale));
51
+ const height = Math.max(1, Math.round(region.height * scale));
52
+ return { width, height, scale, small: Boolean(minOutputSize && Math.max(width, height) < minOutputSize) };
53
+ }
54
+ /**
55
+ * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty
56
+ * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills
57
+ * the canvas.
58
+ */
59
+ export function drawCrop(context, image, source, region, size, { rotation, outputType, background = "#ffffff" }) {
60
+ context.clearRect(0, 0, size.width, size.height);
61
+ if (!hasAlpha(outputType)) {
62
+ context.fillStyle = background;
63
+ context.fillRect(0, 0, size.width, size.height);
64
+ }
65
+ const turned = rotatedSize(source.width, source.height, rotation);
66
+ // Each edge on its own: after rounding, width and height can differ by under a pixel, which would leave
67
+ // a faint row of background (or transparency) along the bottom.
68
+ context.save();
69
+ context.imageSmoothingEnabled = true;
70
+ context.imageSmoothingQuality = "high";
71
+ context.scale(size.width / region.width, size.height / region.height);
72
+ context.translate(-region.left, -region.top);
73
+ // Into rotated space: turn about the turned image's centre, then draw the source centred on it.
74
+ context.translate(turned.width / 2, turned.height / 2);
75
+ context.rotate((rotation * Math.PI) / 180);
76
+ context.drawImage(image, -source.width / 2, -source.height / 2, source.width, source.height);
77
+ context.restore();
78
+ }
79
+ /** The output file's extension for its type. */
80
+ export const extensionOf = (type) => (type === "image/jpeg" ? "jpg" : type === "image/png" ? "png" : "webp");
81
+ /**
82
+ * The qualities to try under a byte limit, as an image upload typically needs for a logo,
83
+ * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most
84
+ * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.
85
+ */
86
+ export function qualitySteps({ outputType, quality, minimumQuality, maxBytes }) {
87
+ if (!maxBytes || outputType === "image/png")
88
+ return [quality];
89
+ const floor = Math.min(quality, Math.max(0.1, minimumQuality ?? 0.1));
90
+ const steps = [];
91
+ for (let index = 0;; index++) {
92
+ const step = Math.round(Math.max(floor, quality - index * 0.1) * 100) / 100;
93
+ if (steps[steps.length - 1] !== step)
94
+ steps.push(step);
95
+ if (step <= floor)
96
+ break;
97
+ }
98
+ return steps;
99
+ }
100
+ /**
101
+ * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is
102
+ * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.
103
+ */
104
+ export async function encodeWithin(encode, options) {
105
+ let last;
106
+ for (const quality of qualitySteps(options)) {
107
+ // PNG is lossless: the browser ignores a quality for it, so none is passed.
108
+ const blob = await encode(options.outputType === "image/png" ? undefined : quality);
109
+ if (!blob)
110
+ throw new Error("export-failed");
111
+ last = { blob, quality };
112
+ if (!options.maxBytes || blob.size <= options.maxBytes)
113
+ return { ...last, fits: true };
114
+ }
115
+ return { ...last, fits: false };
116
+ }
117
+ //# sourceMappingURL=image-crop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-crop.js","sourceRoot":"","sources":["../../src/form/image-crop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAE1B,qFAAqF;AACrF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAoB,EAAE,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC;AAExE,qCAAqC;AACrC,M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AAI,IAAI,KAAK;YAAE,MAAM;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAID;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA6D,EAC7D,OAAoG;IAEpG,IAAI,IAAiD,CAAC;IACtD,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,4EAA4E;QAC5E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ;YAAE,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzF,CAAC;IACD,OAAO,EAAE,GAAG,IAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * ImageCropper's geometry and output, kept apart from the component so the rules the\n * cropper exists for are tested on their own:\n * - never upscale: the output is the crop region in source pixels, only ever scaled down;\n * - contain never paints black: an output without alpha (JPEG) fills the empty area with the\n * background, white by default; PNG and WebP keep it transparent.\n *\n * Coordinates are in the source's pixels after rotation (\"rotated space\"): a 90° turn of a 4000 × 3000\n * photo is a 3000 × 4000 image to crop.\n */\n\nexport type CropFit = \"cover\" | \"contain\";\nexport type CropOutputType = \"image/jpeg\" | \"image/png\" | \"image/webp\";\nexport type CropRotation = 0 | 90 | 180 | 270;\n\nexport type CropState = {\n /** 1 shows the whole fit; up to 4. */\n zoom: number;\n /** The crop region's centre, in rotated-space pixels. */\n centerX: number;\n centerY: number;\n rotation: CropRotation;\n};\n\nexport type CropRegion = { left: number; top: number; width: number; height: number };\n\nexport const MIN_ZOOM = 1;\nexport const MAX_ZOOM = 4;\n\n/** Outputs that keep transparency; the rest get the background under empty areas. */\nexport const hasAlpha = (type: CropOutputType) => type !== \"image/jpeg\";\n\n/** The source's size once turned. */\nexport function rotatedSize(width: number, height: number, rotation: CropRotation) {\n return rotation % 180 === 0 ? { width, height } : { width: height, height: width };\n}\n\n/**\n * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that\n * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).\n * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is\n * smaller than, and stays centred along a side it is larger than (only contain's empty area).\n */\nexport function cropRegion(image: { width: number; height: number }, aspect: number, fit: CropFit, state: Pick<CropState, \"zoom\" | \"centerX\" | \"centerY\">): CropRegion {\n const imageAspect = image.width / image.height;\n const widerFrame = aspect > imageAspect;\n // cover: limited by the image's short side for this shape; contain: by its long side.\n const baseWidth = fit === \"cover\" ? (widerFrame ? image.width : image.height * aspect) : widerFrame ? image.height * aspect : image.width;\n const zoom = clampZoom(state.zoom);\n const width = baseWidth / zoom;\n const height = width / aspect;\n const centerX = clampCenter(state.centerX, width, image.width);\n const centerY = clampCenter(state.centerY, height, image.height);\n return { left: centerX - width / 2, top: centerY - height / 2, width, height };\n}\n\nexport const clampZoom = (zoom: number) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Number.isFinite(zoom) ? zoom : MIN_ZOOM));\n\nfunction clampCenter(center: number, size: number, extent: number) {\n if (size >= extent) return extent / 2;\n return Math.min(extent - size / 2, Math.max(size / 2, center));\n}\n\n/**\n * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.\n * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).\n */\nexport function outputSize(region: CropRegion, { maxOutputSize, minOutputSize }: { maxOutputSize?: number; minOutputSize?: number }) {\n const long = Math.max(region.width, region.height);\n const scale = maxOutputSize && long > maxOutputSize ? maxOutputSize / long : 1;\n const width = Math.max(1, Math.round(region.width * scale));\n const height = Math.max(1, Math.round(region.height * scale));\n return { width, height, scale, small: Boolean(minOutputSize && Math.max(width, height) < minOutputSize) };\n}\n\n/** The 2D context calls the renderer makes; a canvas's context, or a recorder in tests. */\nexport type CropContext = Pick<\n CanvasRenderingContext2D,\n \"fillStyle\" | \"fillRect\" | \"clearRect\" | \"save\" | \"restore\" | \"translate\" | \"rotate\" | \"scale\" | \"drawImage\" | \"imageSmoothingEnabled\" | \"imageSmoothingQuality\"\n>;\n\n/**\n * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty\n * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills\n * the canvas.\n */\nexport function drawCrop(\n context: CropContext,\n image: CanvasImageSource,\n source: { width: number; height: number },\n region: CropRegion,\n size: { width: number; height: number },\n { rotation, outputType, background = \"#ffffff\" }: { rotation: CropRotation; outputType: CropOutputType; background?: string },\n) {\n context.clearRect(0, 0, size.width, size.height);\n if (!hasAlpha(outputType)) {\n context.fillStyle = background;\n context.fillRect(0, 0, size.width, size.height);\n }\n const turned = rotatedSize(source.width, source.height, rotation);\n // Each edge on its own: after rounding, width and height can differ by under a pixel, which would leave\n // a faint row of background (or transparency) along the bottom.\n context.save();\n context.imageSmoothingEnabled = true;\n context.imageSmoothingQuality = \"high\";\n context.scale(size.width / region.width, size.height / region.height);\n context.translate(-region.left, -region.top);\n // Into rotated space: turn about the turned image's centre, then draw the source centred on it.\n context.translate(turned.width / 2, turned.height / 2);\n context.rotate((rotation * Math.PI) / 180);\n context.drawImage(image, -source.width / 2, -source.height / 2, source.width, source.height);\n context.restore();\n}\n\n/** The output file's extension for its type. */\nexport const extensionOf = (type: CropOutputType) => (type === \"image/jpeg\" ? \"jpg\" : type === \"image/png\" ? \"png\" : \"webp\");\n\n/**\n * The qualities to try under a byte limit, as an image upload typically needs for a logo,\n * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most\n * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.\n */\nexport function qualitySteps({ outputType, quality, minimumQuality, maxBytes }: { outputType: CropOutputType; quality: number; minimumQuality?: number; maxBytes?: number }) {\n if (!maxBytes || outputType === \"image/png\") return [quality];\n const floor = Math.min(quality, Math.max(0.1, minimumQuality ?? 0.1));\n const steps: number[] = [];\n for (let index = 0; ; index++) {\n const step = Math.round(Math.max(floor, quality - index * 0.1) * 100) / 100;\n if (steps[steps.length - 1] !== step) steps.push(step);\n if (step <= floor) break;\n }\n return steps;\n}\n\nexport type EncodeResult = { blob: Blob; quality: number; fits: boolean };\n\n/**\n * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is\n * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.\n */\nexport async function encodeWithin(\n encode: (quality: number | undefined) => Promise<Blob | null>,\n options: { outputType: CropOutputType; quality: number; minimumQuality?: number; maxBytes?: number },\n): Promise<EncodeResult> {\n let last: { blob: Blob; quality: number } | undefined;\n for (const quality of qualitySteps(options)) {\n // PNG is lossless: the browser ignores a quality for it, so none is passed.\n const blob = await encode(options.outputType === \"image/png\" ? undefined : quality);\n if (!blob) throw new Error(\"export-failed\");\n last = { blob, quality };\n if (!options.maxBytes || blob.size <= options.maxBytes) return { ...last, fits: true };\n }\n return { ...last!, fits: false };\n}\n"]}
@@ -0,0 +1,68 @@
1
+ import * as React from "react";
2
+ import { type CropFit, type CropOutputType } from "./image-crop.js";
3
+ export type ImageCropperAspect = number | "free";
4
+ export type ImageCropperPreset = {
5
+ id: string;
6
+ /** "Cover 16:9". */
7
+ label: string;
8
+ aspectRatio: ImageCropperAspect;
9
+ /** The fit this surface uses; the cropper's `fit` otherwise. */
10
+ fit?: CropFit;
11
+ };
12
+ export type ImageCropperResult = {
13
+ width: number;
14
+ height: number;
15
+ type: CropOutputType;
16
+ };
17
+ export type ImageCropperProps = {
18
+ /**
19
+ * The picked file (from FileTrigger, already checked for size and type), or an image URL. A URL from
20
+ * another origin is loaded with CORS so the crop can be read back: its server must send
21
+ * `Access-Control-Allow-Origin`, or the image does not open (rather than failing later at save).
22
+ */
23
+ src: Blob | string;
24
+ /** What is being cropped ("Cover photo"); names the crop frame. */
25
+ label: string;
26
+ /** 16:9 by default; `"free"` keeps the image's own shape. Ignored when presets are given. */
27
+ aspectRatio?: ImageCropperAspect;
28
+ /** Two or more shapes to choose from (a segmented control); the first is selected. */
29
+ aspectPresets?: readonly ImageCropperPreset[];
30
+ /** `cover` (default) fills the frame; `contain` fits the whole image and leaves empty area. */
31
+ fit?: CropFit;
32
+ /** The empty area's colour in `contain` when the output has no alpha (JPEG). White by default. */
33
+ background?: string;
34
+ /** `image/jpeg` by default. PNG and WebP keep transparency. */
35
+ outputType?: CropOutputType;
36
+ /** 0–1, for JPEG and WebP. 0.9 by default. */
37
+ quality?: number;
38
+ /**
39
+ * The largest file the surface takes, in bytes. A JPEG or WebP
40
+ * over it is encoded again at a quality 0.1 lower each time, down to `minimumQuality`; when even that is over, or
41
+ * a PNG is, nothing is handed to `onCrop` and the cropper says the image is over the limit (a smaller crop, by
42
+ * zooming in, or another image fits).
43
+ */
44
+ maxBytes?: number;
45
+ /** The lowest quality `maxBytes` may step down to (0.9 keeps a hero or slide sharp). 0.1 by default; at most `quality`. */
46
+ minimumQuality?: number;
47
+ /**
48
+ * The output's long edge in px at most (a surface's size, 2560 for a full-width photo): larger crops scale down,
49
+ * never up. 4096 by default, so a 48 MP phone photo stays within every browser's canvas limit.
50
+ */
51
+ maxOutputSize?: number;
52
+ /** Under this long edge the warning shows; it never blocks. */
53
+ minOutputSize?: number;
54
+ /** The output file's name without extension; the source file's name by default. */
55
+ fileName?: string;
56
+ onCrop: (file: File, result: ImageCropperResult) => unknown;
57
+ onCancel?: () => void;
58
+ };
59
+ /**
60
+ * Frames one picked image to the shape a surface needs (a 16:9 cover photo, a square logo) and hands
61
+ * back the cropped file at the source's own pixel density: never upscaled, only scaled down to
62
+ * `maxOutputSize`. In `contain`, the empty area takes `background` when the output has no
63
+ * alpha, white by default, never black. A sunken stage dims what falls outside a white frame
64
+ * with thirds guides; the toolbar holds the shapes, zoom, rotation and fit. The frame is one focusable
65
+ * group: arrows move the image (Shift for 10%), + and − zoom, [ and ] rotate, and each change is announced.
66
+ * The toolbar mirrors in RTL; the image and the arrows never do.
67
+ */
68
+ export declare function ImageCropper({ src, label, aspectRatio, aspectPresets, fit: fitProp, background: backgroundProp, outputType, quality, maxBytes, minimumQuality, maxOutputSize, minOutputSize, fileName, onCrop, onCancel, }: ImageCropperProps): React.JSX.Element;