@canonical/react-ds-global-form 0.47.0 → 0.49.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 (439) hide show
  1. package/README.md +5 -6
  2. package/dist/esm/density.css +40 -79
  3. package/dist/esm/index.css +39 -22
  4. package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/ColorField.js +2 -2
  5. package/dist/esm/lib/_work_in_progress/component/ColorField/ColorField.js.map +1 -0
  6. package/dist/esm/lib/_work_in_progress/component/ColorField/index.js.map +1 -0
  7. package/dist/esm/lib/_work_in_progress/component/ColorField/types.js.map +1 -0
  8. package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/ComboboxField.js +2 -2
  9. package/dist/esm/lib/_work_in_progress/component/ComboboxField/ComboboxField.js.map +1 -0
  10. package/dist/esm/lib/_work_in_progress/component/ComboboxField/index.js.map +1 -0
  11. package/dist/esm/lib/_work_in_progress/component/ComboboxField/types.js.map +1 -0
  12. package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/RatingField.js +2 -2
  13. package/dist/esm/lib/_work_in_progress/component/RatingField/RatingField.js.map +1 -0
  14. package/dist/esm/lib/_work_in_progress/component/RatingField/index.js.map +1 -0
  15. package/dist/esm/lib/_work_in_progress/component/RatingField/types.js.map +1 -0
  16. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.js.map +1 -0
  17. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/index.js.map +1 -0
  18. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/types.js.map +1 -0
  19. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.js.map +1 -0
  20. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js +199 -0
  21. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js.map +1 -0
  22. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js +120 -0
  23. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -0
  24. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.js +16 -4
  25. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.js.map +1 -0
  26. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.js.map +1 -0
  27. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.js.map +1 -0
  28. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.js +3 -3
  29. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +1 -0
  30. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.js.map +1 -0
  31. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/styles.css +3 -0
  32. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.js.map +1 -0
  33. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.js.map +1 -0
  34. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/constants.js.map +1 -0
  35. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/index.js.map +1 -0
  36. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.js +1 -0
  37. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/messages.js.map +1 -0
  38. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/styles.css +1 -2
  39. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/types.js.map +1 -0
  40. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.js.map +1 -0
  41. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +1 -0
  42. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.js.map +1 -0
  43. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js +7 -0
  44. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js.map +1 -0
  45. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js +6 -0
  46. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js.map +1 -0
  47. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js +10 -0
  48. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js.map +1 -0
  49. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js +25 -0
  50. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js.map +1 -0
  51. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.js.map +1 -0
  52. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/index.js.map +1 -0
  53. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/styles.css +7 -7
  54. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/types.js.map +1 -0
  55. package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js +3 -1
  56. package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js.map +1 -1
  57. package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +0 -6
  58. package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +2 -1
  59. package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -1
  60. package/dist/esm/lib/common/Wrapper/Wrapper.js +10 -6
  61. package/dist/esm/lib/common/Wrapper/Wrapper.js.map +1 -1
  62. package/dist/esm/lib/common/Wrapper/createMiddleware.js +70 -0
  63. package/dist/esm/lib/common/Wrapper/createMiddleware.js.map +1 -0
  64. package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js +2 -2
  65. package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js.map +1 -1
  66. package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js +17 -12
  67. package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js.map +1 -1
  68. package/dist/esm/lib/common/Wrapper/withWrapper.js +16 -10
  69. package/dist/esm/lib/common/Wrapper/withWrapper.js.map +1 -1
  70. package/dist/esm/lib/component/ChoicesField/Choices.js +2 -2
  71. package/dist/esm/lib/component/ChoicesField/Choices.js.map +1 -1
  72. package/dist/esm/lib/component/ChoicesField/ChoicesField.js +3 -2
  73. package/dist/esm/lib/component/ChoicesField/ChoicesField.js.map +1 -1
  74. package/dist/esm/lib/component/ChoicesField/styles.css +3 -65
  75. package/dist/esm/lib/component/DateTimeField/DateTimeField.js +2 -1
  76. package/dist/esm/lib/component/DateTimeField/DateTimeField.js.map +1 -1
  77. package/dist/esm/lib/component/FileUploadField/FileUploadField.js +45 -41
  78. package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
  79. package/dist/esm/lib/component/FileUploadField/fileUploadRules.js +39 -0
  80. package/dist/esm/lib/component/FileUploadField/fileUploadRules.js.map +1 -0
  81. package/dist/esm/lib/component/FileUploadField/styles.css +30 -0
  82. package/dist/esm/lib/component/RichChoicesField/RichChoices.js +2 -2
  83. package/dist/esm/lib/component/RichChoicesField/RichChoices.js.map +1 -1
  84. package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js +2 -2
  85. package/dist/esm/lib/component/index.js +5 -4
  86. package/dist/esm/lib/component/index.js.map +1 -1
  87. package/dist/esm/lib/index.js.map +1 -1
  88. package/dist/esm/lib/pattern/Field/Field.js +3 -3
  89. package/dist/esm/lib/pattern/Field/Field.js.map +1 -1
  90. package/dist/esm/lib/subcomponent/DateInput/styles.css +16 -0
  91. package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -7
  92. package/dist/esm/lib/subcomponent/Field/Description/Description.js +1 -3
  93. package/dist/esm/lib/subcomponent/Field/Description/Description.js.map +1 -1
  94. package/dist/esm/lib/subcomponent/Field/Description/styles.css +4 -0
  95. package/dist/esm/lib/subcomponent/Field/Error/Error.js +4 -4
  96. package/dist/esm/lib/subcomponent/Field/Error/Error.js.map +1 -1
  97. package/dist/esm/lib/subcomponent/Field/Error/styles.css +8 -0
  98. package/dist/esm/lib/subcomponent/Field/Label/styles.css +1 -0
  99. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +119 -64
  100. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
  101. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js +52 -0
  102. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js.map +1 -0
  103. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js +2 -0
  104. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js.map +1 -0
  105. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js +2 -0
  106. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js.map +1 -0
  107. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js +40 -0
  108. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js.map +1 -0
  109. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js +2 -0
  110. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js.map +1 -0
  111. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js +2 -0
  112. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js.map +1 -0
  113. package/dist/esm/lib/subcomponent/FileUploadInput/constants.js +3 -0
  114. package/dist/esm/lib/subcomponent/FileUploadInput/constants.js.map +1 -0
  115. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js +3 -0
  116. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js.map +1 -0
  117. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js +148 -0
  118. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js.map +1 -0
  119. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js +22 -0
  120. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js.map +1 -0
  121. package/dist/esm/lib/subcomponent/FileUploadInput/messages.js +25 -0
  122. package/dist/esm/lib/subcomponent/FileUploadInput/messages.js.map +1 -0
  123. package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +255 -94
  124. package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js +21 -0
  125. package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js.map +1 -0
  126. package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js +20 -0
  127. package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js.map +1 -0
  128. package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js +4 -0
  129. package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js.map +1 -0
  130. package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js +26 -0
  131. package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js.map +1 -0
  132. package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js +1 -1
  133. package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js.map +1 -1
  134. package/dist/esm/lib/subcomponent/NumberInput/styles.css +17 -0
  135. package/dist/esm/lib/subcomponent/PasswordInput/styles.css +7 -1
  136. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +8 -2
  137. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
  138. package/dist/esm/lib/subcomponent/RadioInput/styles.css +15 -13
  139. package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js +3 -2
  140. package/dist/esm/lib/subcomponent/SelectInput/SelectInput.js.map +1 -1
  141. package/dist/esm/lib/subcomponent/SelectInput/styles.css +39 -48
  142. package/dist/esm/lib/subcomponent/TextInput/TextInput.js +3 -1
  143. package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
  144. package/dist/esm/lib/subcomponent/index.js +5 -5
  145. package/dist/esm/lib/subcomponent/index.js.map +1 -1
  146. package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js +6 -4
  147. package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js.map +1 -1
  148. package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js +3 -3
  149. package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js.map +1 -1
  150. package/dist/esm/lib/utils/middleware/addRESTOptions.js +99 -39
  151. package/dist/esm/lib/utils/middleware/addRESTOptions.js.map +1 -1
  152. package/dist/esm/lib/utils/middleware/addRESTValidation.js +246 -32
  153. package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
  154. package/dist/esm/lib/utils/middleware/index.js +1 -0
  155. package/dist/esm/lib/utils/middleware/index.js.map +1 -1
  156. package/dist/esm/testing/expectNoAxeViolations.js +30 -0
  157. package/dist/esm/testing/expectNoAxeViolations.js.map +1 -0
  158. package/dist/types/lib/{component → _work_in_progress/component}/ColorField/ColorField.d.ts +7 -12
  159. package/dist/types/lib/_work_in_progress/component/ColorField/ColorField.d.ts.map +1 -0
  160. package/dist/types/lib/_work_in_progress/component/ColorField/index.d.ts.map +1 -0
  161. package/dist/types/lib/{component → _work_in_progress/component}/ColorField/types.d.ts +1 -1
  162. package/dist/types/lib/_work_in_progress/component/ColorField/types.d.ts.map +1 -0
  163. package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts +53 -0
  164. package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts.map +1 -0
  165. package/dist/types/lib/_work_in_progress/component/ComboboxField/index.d.ts.map +1 -0
  166. package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/types.d.ts +1 -1
  167. package/dist/types/lib/_work_in_progress/component/ComboboxField/types.d.ts.map +1 -0
  168. package/dist/types/lib/{component → _work_in_progress/component}/RatingField/RatingField.d.ts +7 -12
  169. package/dist/types/lib/_work_in_progress/component/RatingField/RatingField.d.ts.map +1 -0
  170. package/dist/types/lib/_work_in_progress/component/RatingField/index.d.ts.map +1 -0
  171. package/dist/types/lib/{component → _work_in_progress/component}/RatingField/types.d.ts +1 -1
  172. package/dist/types/lib/_work_in_progress/component/RatingField/types.d.ts.map +1 -0
  173. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.d.ts.map +1 -0
  174. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/index.d.ts.map +1 -0
  175. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.d.ts +1 -1
  176. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/types.d.ts.map +1 -0
  177. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.d.ts +13 -5
  178. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +1 -0
  179. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts +24 -0
  180. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +1 -0
  181. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/SingleCombobox.d.ts +19 -4
  182. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -0
  183. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.d.ts +1 -1
  184. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.d.ts.map +1 -0
  185. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.d.ts.map +1 -0
  186. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.d.ts +2 -1
  187. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.d.ts.map +1 -0
  188. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.d.ts +1 -1
  189. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +1 -0
  190. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +1 -0
  191. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.d.ts +1 -0
  192. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +1 -0
  193. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.d.ts.map +1 -0
  194. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/constants.d.ts.map +1 -0
  195. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/index.d.ts.map +1 -0
  196. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.d.ts +1 -0
  197. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/messages.d.ts.map +1 -0
  198. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts +52 -0
  199. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts.map +1 -0
  200. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +4 -0
  201. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +1 -0
  202. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.d.ts +1 -1
  203. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +1 -0
  204. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts +4 -0
  205. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +1 -0
  206. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts +7 -0
  207. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -0
  208. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts +4 -0
  209. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts.map +1 -0
  210. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts +8 -0
  211. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts.map +1 -0
  212. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts +13 -0
  213. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts.map +1 -0
  214. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.d.ts.map +1 -0
  215. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/index.d.ts.map +1 -0
  216. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/types.d.ts.map +1 -0
  217. package/dist/types/lib/common/Wrapper/InvisibleWrapper.d.ts.map +1 -1
  218. package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -1
  219. package/dist/types/lib/common/Wrapper/Wrapper.d.ts +1 -1
  220. package/dist/types/lib/common/Wrapper/Wrapper.d.ts.map +1 -1
  221. package/dist/types/lib/common/Wrapper/createMiddleware.d.ts +43 -0
  222. package/dist/types/lib/common/Wrapper/createMiddleware.d.ts.map +1 -0
  223. package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts +2 -0
  224. package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts.map +1 -1
  225. package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts +9 -3
  226. package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts.map +1 -1
  227. package/dist/types/lib/common/Wrapper/withWrapper.d.ts +3 -5
  228. package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
  229. package/dist/types/lib/common/types.d.ts +19 -7
  230. package/dist/types/lib/common/types.d.ts.map +1 -1
  231. package/dist/types/lib/component/ChoicesField/Choices.d.ts +1 -1
  232. package/dist/types/lib/component/ChoicesField/Choices.d.ts.map +1 -1
  233. package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +9 -13
  234. package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
  235. package/dist/types/lib/component/ChoicesField/types.d.ts +2 -2
  236. package/dist/types/lib/component/ChoicesField/types.d.ts.map +1 -1
  237. package/dist/types/lib/component/DateField/DateField.d.ts +6 -11
  238. package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +7 -11
  239. package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
  240. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +299 -19
  241. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
  242. package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts +24 -0
  243. package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts.map +1 -0
  244. package/dist/types/lib/component/HiddenField/HiddenField.d.ts +6 -11
  245. package/dist/types/lib/component/NumberField/NumberField.d.ts +6 -11
  246. package/dist/types/lib/component/PasswordField/PasswordField.d.ts +6 -11
  247. package/dist/types/lib/component/PhoneField/PhoneField.d.ts +7 -11
  248. package/dist/types/lib/component/RangeField/RangeField.d.ts +6 -11
  249. package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts +1 -1
  250. package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts.map +1 -1
  251. package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +8 -13
  252. package/dist/types/lib/component/RichChoicesField/types.d.ts +2 -2
  253. package/dist/types/lib/component/RichChoicesField/types.d.ts.map +1 -1
  254. package/dist/types/lib/component/SelectField/SelectField.d.ts +6 -11
  255. package/dist/types/lib/component/TextField/TextField.d.ts +6 -11
  256. package/dist/types/lib/component/TextareaField/TextareaField.d.ts +6 -11
  257. package/dist/types/lib/component/TimeField/TimeField.d.ts +6 -11
  258. package/dist/types/lib/component/index.d.ts +3 -3
  259. package/dist/types/lib/component/index.d.ts.map +1 -1
  260. package/dist/types/lib/index.d.ts +1 -1
  261. package/dist/types/lib/index.d.ts.map +1 -1
  262. package/dist/types/lib/pattern/Field/types.d.ts +4 -4
  263. package/dist/types/lib/pattern/Field/types.d.ts.map +1 -1
  264. package/dist/types/lib/subcomponent/Field/Description/Description.d.ts.map +1 -1
  265. package/dist/types/lib/subcomponent/Field/Error/Error.d.ts.map +1 -1
  266. package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts +25 -4
  267. package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
  268. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts +15 -0
  269. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts.map +1 -0
  270. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts +3 -0
  271. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts.map +1 -0
  272. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts +28 -0
  273. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts.map +1 -0
  274. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts +14 -0
  275. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts.map +1 -0
  276. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts +3 -0
  277. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts.map +1 -0
  278. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts +9 -0
  279. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts.map +1 -0
  280. package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts +3 -0
  281. package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts.map +1 -0
  282. package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts +3 -0
  283. package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts.map +1 -0
  284. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts +33 -0
  285. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts.map +1 -0
  286. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts +8 -0
  287. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts.map +1 -0
  288. package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts +1 -1
  289. package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts.map +1 -1
  290. package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts +4 -0
  291. package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts.map +1 -0
  292. package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts +165 -8
  293. package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts.map +1 -1
  294. package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts +7 -0
  295. package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts.map +1 -0
  296. package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts +14 -0
  297. package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts.map +1 -0
  298. package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts +5 -0
  299. package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts.map +1 -0
  300. package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts +10 -0
  301. package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts.map +1 -0
  302. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +12 -0
  303. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
  304. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +11 -2
  305. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
  306. package/dist/types/lib/subcomponent/SelectInput/SelectInput.d.ts.map +1 -1
  307. package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts +2 -0
  308. package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts.map +1 -1
  309. package/dist/types/lib/subcomponent/index.d.ts +7 -7
  310. package/dist/types/lib/subcomponent/index.d.ts.map +1 -1
  311. package/dist/types/lib/subcomponent/types.d.ts +6 -0
  312. package/dist/types/lib/subcomponent/types.d.ts.map +1 -1
  313. package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts +2 -1
  314. package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts.map +1 -1
  315. package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts +3 -2
  316. package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts.map +1 -1
  317. package/dist/types/lib/utils/middleware/addRESTOptions.d.ts +37 -4
  318. package/dist/types/lib/utils/middleware/addRESTOptions.d.ts.map +1 -1
  319. package/dist/types/lib/utils/middleware/addRESTValidation.d.ts +38 -3
  320. package/dist/types/lib/utils/middleware/addRESTValidation.d.ts.map +1 -1
  321. package/dist/types/lib/utils/middleware/index.d.ts +2 -0
  322. package/dist/types/lib/utils/middleware/index.d.ts.map +1 -1
  323. package/dist/types/testing/expectNoAxeViolations.d.ts +10 -0
  324. package/dist/types/testing/expectNoAxeViolations.d.ts.map +1 -0
  325. package/package.json +21 -18
  326. package/dist/esm/lib/component/ColorField/ColorField.js.map +0 -1
  327. package/dist/esm/lib/component/ColorField/index.js.map +0 -1
  328. package/dist/esm/lib/component/ColorField/types.js.map +0 -1
  329. package/dist/esm/lib/component/ComboboxField/ComboboxField.js.map +0 -1
  330. package/dist/esm/lib/component/ComboboxField/index.js.map +0 -1
  331. package/dist/esm/lib/component/ComboboxField/types.js.map +0 -1
  332. package/dist/esm/lib/component/RatingField/RatingField.js.map +0 -1
  333. package/dist/esm/lib/component/RatingField/index.js.map +0 -1
  334. package/dist/esm/lib/component/RatingField/types.js.map +0 -1
  335. package/dist/esm/lib/subcomponent/ColorInput/ColorInput.js.map +0 -1
  336. package/dist/esm/lib/subcomponent/ColorInput/index.js.map +0 -1
  337. package/dist/esm/lib/subcomponent/ColorInput/types.js.map +0 -1
  338. package/dist/esm/lib/subcomponent/ComboboxInput/ComboboxInput.js.map +0 -1
  339. package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js +0 -84
  340. package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js.map +0 -1
  341. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +0 -67
  342. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +0 -1
  343. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +0 -1
  344. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/index.js.map +0 -1
  345. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/types.js.map +0 -1
  346. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +0 -1
  347. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/index.js.map +0 -1
  348. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/types.js.map +0 -1
  349. package/dist/esm/lib/subcomponent/ComboboxInput/common/index.js.map +0 -1
  350. package/dist/esm/lib/subcomponent/ComboboxInput/constants.js.map +0 -1
  351. package/dist/esm/lib/subcomponent/ComboboxInput/index.js.map +0 -1
  352. package/dist/esm/lib/subcomponent/ComboboxInput/messages.js.map +0 -1
  353. package/dist/esm/lib/subcomponent/ComboboxInput/types.js.map +0 -1
  354. package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertItemToString.js.map +0 -1
  355. package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +0 -1
  356. package/dist/esm/lib/subcomponent/ComboboxInput/utils/filterItems.js.map +0 -1
  357. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -4
  358. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +0 -1
  359. package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js.map +0 -1
  360. package/dist/esm/lib/subcomponent/RatingInput/index.js.map +0 -1
  361. package/dist/esm/lib/subcomponent/RatingInput/types.js.map +0 -1
  362. package/dist/types/lib/component/ColorField/ColorField.d.ts.map +0 -1
  363. package/dist/types/lib/component/ColorField/index.d.ts.map +0 -1
  364. package/dist/types/lib/component/ColorField/types.d.ts.map +0 -1
  365. package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +0 -56
  366. package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +0 -1
  367. package/dist/types/lib/component/ComboboxField/index.d.ts.map +0 -1
  368. package/dist/types/lib/component/ComboboxField/types.d.ts.map +0 -1
  369. package/dist/types/lib/component/RatingField/RatingField.d.ts.map +0 -1
  370. package/dist/types/lib/component/RatingField/index.d.ts.map +0 -1
  371. package/dist/types/lib/component/RatingField/types.d.ts.map +0 -1
  372. package/dist/types/lib/subcomponent/ColorInput/ColorInput.d.ts.map +0 -1
  373. package/dist/types/lib/subcomponent/ColorInput/index.d.ts.map +0 -1
  374. package/dist/types/lib/subcomponent/ColorInput/types.d.ts.map +0 -1
  375. package/dist/types/lib/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +0 -1
  376. package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts +0 -16
  377. package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +0 -1
  378. package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +0 -1
  379. package/dist/types/lib/subcomponent/ComboboxInput/common/List/List.d.ts.map +0 -1
  380. package/dist/types/lib/subcomponent/ComboboxInput/common/List/index.d.ts.map +0 -1
  381. package/dist/types/lib/subcomponent/ComboboxInput/common/List/types.d.ts.map +0 -1
  382. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +0 -1
  383. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +0 -1
  384. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +0 -1
  385. package/dist/types/lib/subcomponent/ComboboxInput/common/index.d.ts.map +0 -1
  386. package/dist/types/lib/subcomponent/ComboboxInput/constants.d.ts.map +0 -1
  387. package/dist/types/lib/subcomponent/ComboboxInput/index.d.ts.map +0 -1
  388. package/dist/types/lib/subcomponent/ComboboxInput/messages.d.ts.map +0 -1
  389. package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts +0 -27
  390. package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts.map +0 -1
  391. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +0 -4
  392. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +0 -1
  393. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +0 -1
  394. package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts +0 -4
  395. package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +0 -1
  396. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -4
  397. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +0 -1
  398. package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts.map +0 -1
  399. package/dist/types/lib/subcomponent/RatingInput/index.d.ts.map +0 -1
  400. package/dist/types/lib/subcomponent/RatingInput/types.d.ts.map +0 -1
  401. /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/index.js +0 -0
  402. /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/types.js +0 -0
  403. /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/index.js +0 -0
  404. /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/types.js +0 -0
  405. /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/index.js +0 -0
  406. /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/types.js +0 -0
  407. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.js +0 -0
  408. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.js +0 -0
  409. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/styles.css +0 -0
  410. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.js +0 -0
  411. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.js +0 -0
  412. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.js +0 -0
  413. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/styles.css +0 -0
  414. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.js +0 -0
  415. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.js +0 -0
  416. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.js +0 -0
  417. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.js +0 -0
  418. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.js +0 -0
  419. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.js +0 -0
  420. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/types.js +0 -0
  421. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertItemToString.js +0 -0
  422. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.js +0 -0
  423. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/filterItems.js +0 -0
  424. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.js +0 -0
  425. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.js +0 -0
  426. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.js +0 -0
  427. /package/dist/types/lib/{component → _work_in_progress/component}/ColorField/index.d.ts +0 -0
  428. /package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/index.d.ts +0 -0
  429. /package/dist/types/lib/{component → _work_in_progress/component}/RatingField/index.d.ts +0 -0
  430. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.d.ts +0 -0
  431. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.d.ts +0 -0
  432. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.d.ts +0 -0
  433. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.d.ts +0 -0
  434. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.d.ts +0 -0
  435. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.d.ts +0 -0
  436. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.d.ts +0 -0
  437. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.d.ts +0 -0
  438. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.d.ts +0 -0
  439. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/FileUploadInput/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,148 @@
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { RESULT_DISPLAY_DURATION } from "../constants.js";
3
+ const clamp = (fraction) => Math.min(1, Math.max(0, Number.isFinite(fraction) ? fraction : 0));
4
+ const summarise = (states) => {
5
+ let uploading = 0;
6
+ let failed = 0;
7
+ for (const state of states.values()) {
8
+ if (state.status === "uploading")
9
+ uploading += 1;
10
+ if (state.status === "failed")
11
+ failed += 1;
12
+ }
13
+ return { uploading, failed };
14
+ };
15
+ /**
16
+ * Runs the live uploads of the chosen files. Each new file that may be
17
+ * uploaded is sent once with its own abort signal; a file that leaves the
18
+ * selection has its upload aborted and its state dropped. Upload state lives
19
+ * here, keyed by the `File` object, and never in the form value.
20
+ *
21
+ * Cancelling an upload is removing its file: the consumer drops it from the
22
+ * value, and the upload is aborted with it. Once an upload ends, success or
23
+ * failure, its result shows for `RESULT_DISPLAY_DURATION`; a failed upload
24
+ * then stays failed until it is retried or removed.
25
+ *
26
+ * Every upload promise is settled here, so neither a rejection nor an abort
27
+ * escapes as an unhandled rejection. A result from an upload that has since
28
+ * been retried or removed is ignored.
29
+ */
30
+ export default function useFileUploads(files, { upload, canUpload, onSummaryChange }) {
31
+ const [states, setStates] = useState(() => new Map());
32
+ const controllers = useRef(new Map());
33
+ const timers = useRef(new Map());
34
+ const tracked = useRef(new Set());
35
+ const latest = useRef({ upload, canUpload, onSummaryChange });
36
+ latest.current = { upload, canUpload, onSummaryChange };
37
+ const reported = useRef({ uploading: 0, failed: 0 });
38
+ const update = useCallback((file, next) => {
39
+ setStates((previous) => {
40
+ const current = previous.get(file);
41
+ const state = next(current);
42
+ if (state === current)
43
+ return previous;
44
+ const map = new Map(previous);
45
+ if (state)
46
+ map.set(file, state);
47
+ else
48
+ map.delete(file);
49
+ return map;
50
+ });
51
+ }, []);
52
+ const stop = useCallback((file) => {
53
+ controllers.current.get(file)?.abort();
54
+ controllers.current.delete(file);
55
+ clearTimeout(timers.current.get(file));
56
+ timers.current.delete(file);
57
+ }, []);
58
+ /**
59
+ * Records how an upload ended and shows its result, then hides the result
60
+ * after `RESULT_DISPLAY_DURATION`, keeping the outcome.
61
+ */
62
+ const end = useCallback((file, outcome) => {
63
+ controllers.current.delete(file);
64
+ update(file, outcome);
65
+ timers.current.set(file, setTimeout(() => {
66
+ timers.current.delete(file);
67
+ update(file, (current) => current && current.status !== "uploading"
68
+ ? { ...current, showResult: false }
69
+ : current);
70
+ }, RESULT_DISPLAY_DURATION));
71
+ }, [update]);
72
+ const start = useCallback((file, send) => {
73
+ stop(file);
74
+ const controller = new AbortController();
75
+ controllers.current.set(file, controller);
76
+ const isCurrent = () => controllers.current.get(file) === controller;
77
+ update(file, () => ({ status: "uploading", progress: 0 }));
78
+ const onProgress = (fraction) => {
79
+ if (!isCurrent())
80
+ return;
81
+ const progress = clamp(fraction);
82
+ update(file, (current) => current?.status === "uploading" &&
83
+ Math.round(current.progress * 100) === Math.round(progress * 100)
84
+ ? current
85
+ : { status: "uploading", progress });
86
+ };
87
+ new Promise((resolve) => {
88
+ resolve(send(file, { signal: controller.signal, onProgress }));
89
+ }).then(() => {
90
+ if (!isCurrent())
91
+ return;
92
+ end(file, () => ({ status: "uploaded", showResult: true }));
93
+ }, (reason) => {
94
+ if (!isCurrent())
95
+ return;
96
+ end(file, (current) => ({
97
+ status: "failed",
98
+ reason,
99
+ progress: current?.status === "uploading" ? current.progress : 0,
100
+ showResult: true,
101
+ }));
102
+ });
103
+ }, [end, stop, update]);
104
+ const live = Boolean(upload);
105
+ useEffect(() => {
106
+ const present = new Set(files);
107
+ for (const file of tracked.current) {
108
+ if (present.has(file) && live)
109
+ continue;
110
+ stop(file);
111
+ tracked.current.delete(file);
112
+ update(file, () => undefined);
113
+ }
114
+ const send = latest.current.upload;
115
+ if (!send)
116
+ return;
117
+ for (const file of files) {
118
+ if (tracked.current.has(file) || !latest.current.canUpload(file)) {
119
+ continue;
120
+ }
121
+ tracked.current.add(file);
122
+ start(file, send);
123
+ }
124
+ }, [files, live, start, stop, update]);
125
+ useEffect(() => () => {
126
+ for (const file of tracked.current)
127
+ stop(file);
128
+ tracked.current.clear();
129
+ }, [stop]);
130
+ useEffect(() => {
131
+ const summary = summarise(states);
132
+ const previous = reported.current;
133
+ if (summary.uploading === previous.uploading &&
134
+ summary.failed === previous.failed) {
135
+ return;
136
+ }
137
+ reported.current = summary;
138
+ latest.current.onSummaryChange?.(summary);
139
+ }, [states]);
140
+ const retry = useCallback((file) => {
141
+ const send = latest.current.upload;
142
+ if (!send || !tracked.current.has(file))
143
+ return;
144
+ start(file, send);
145
+ }, [start]);
146
+ return { states, retry };
147
+ }
148
+ //# sourceMappingURL=useFileUploads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFileUploads.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/FileUploadInput/hooks/useFileUploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAmB1D,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAU,EAAE,CACzC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE,MAAM,SAAS,GAAG,CAAC,MAAsC,EAAiB,EAAE;IAC1E,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,MAAM,GAA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AAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QAChD,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { useEffect, useState } from "react";
2
+ /**
3
+ * An object URL for a file, created after mount and revoked when the file
4
+ * changes or the component unmounts. `undefined` without a file, during server
5
+ * rendering, on the first client render, and where object URLs are not
6
+ * supported.
7
+ */
8
+ export default function useObjectUrl(file) {
9
+ const [url, setUrl] = useState();
10
+ useEffect(() => {
11
+ if (!file || typeof URL.createObjectURL !== "function")
12
+ return;
13
+ const objectUrl = URL.createObjectURL(file);
14
+ setUrl(objectUrl);
15
+ return () => {
16
+ URL.revokeObjectURL(objectUrl);
17
+ setUrl(undefined);
18
+ };
19
+ }, [file]);
20
+ return url;
21
+ }
22
+ //# sourceMappingURL=useObjectUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useObjectUrl.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAsB;IAEtB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAU,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,eAAe,KAAK,UAAU;YAAE,OAAO;QAC/D,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,SAAS,CAAC,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,CAAC,SAAS,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { formatFileSize } from "./utils/index.js";
2
+ const percent = new Intl.NumberFormat("en", { style: "percent" });
3
+ const messages = {
4
+ dropAreaText: () => "Drag and drop or",
5
+ chooseFile: (multiple) => (multiple ? "Choose files" : "Choose file"),
6
+ fileSize: (bytes) => formatFileSize(bytes),
7
+ progress: (fraction) => percent.format(fraction),
8
+ statusUploading: (fileName) => `Uploading ${fileName}`,
9
+ statusUploaded: (fileName) => `${fileName} uploaded`,
10
+ statusUploadedWithWarning: (fileName) => `${fileName} uploaded with a warning`,
11
+ statusFailed: (fileName) => `${fileName} failed to upload`,
12
+ remove: (fileName) => `Remove ${fileName}`,
13
+ cancelUpload: (fileName) => `Cancel upload of ${fileName}`,
14
+ retryUpload: (fileName) => `Retry upload of ${fileName}`,
15
+ messageLevel: (level) => (level === "error" ? "Error:" : "Warning:"),
16
+ uploadFailed: () => "File failed to upload.",
17
+ fileTooLarge: (maxSize) => `File size exceeds ${maxSize}.`,
18
+ fileTypeNotAccepted: () => "File type is not accepted.",
19
+ tooManyFiles: (maxFiles) => `You can upload at most ${maxFiles} file${maxFiles === 1 ? "" : "s"}.`,
20
+ filesHaveErrors: () => "Remove the files that have errors.",
21
+ uploadsPending: () => "Wait for the uploads to finish.",
22
+ uploadsFailed: () => "Retry or remove the files that failed to upload.",
23
+ };
24
+ export default messages;
25
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../../src/lib/subcomponent/FileUploadInput/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IA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ACzB,0BAA0B,QAAQ,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;IACxE,eAAe,EAAE,GAAG,EAAE,CAAC,oCAAoC;IAC3D,cAAc,EAAE,GAAG,EAAE,CAAC,iCAAiC;IACvD,aAAa,EAAE,GAAG,EAAE,CAAC,kDAAkD;CACxE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,144 +1,305 @@
1
1
  /* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */
2
2
 
3
3
  @layer ds.components.global {
4
+ /* The whole image in the thumbnail's tooltip, uncropped. It fills the
5
+ tooltip's own maximum width, since the tooltip sizes to its content and an
6
+ image without an intrinsic size (an SVG with only a viewBox) would
7
+ otherwise collapse. A tall image is held to half the viewport and
8
+ letterboxed. */
9
+ .ds.tooltip.file-upload-preview img {
10
+ --file-upload-preview-inset: calc(2 * var(--tooltip-padding-horizontal));
11
+
12
+ display: block;
13
+ inline-size: calc(
14
+ var(--tooltip-max-width) -
15
+ var(--file-upload-preview-inset)
16
+ );
17
+ block-size: auto;
18
+ max-block-size: 50vh;
19
+ object-fit: contain;
20
+ }
21
+
4
22
  .ds.input.file-upload {
23
+ position: relative;
5
24
  display: flex;
6
25
  flex-direction: column;
7
- gap: var(--form-group-gap);
26
+ /* 16px between the drop area and message group and the file list. */
27
+ gap: var(--dimension-200);
28
+
29
+ /* ── Drop area and its field-level message ─────────────────────── */
30
+ & > .drop-area-group {
31
+ display: flex;
32
+ flex-direction: column;
33
+ gap: var(--dimension-100);
34
+ }
8
35
 
9
- & > .drop-zone {
36
+ /* The border and fill read the Criticality channels; the drop area takes
37
+ the `error` class while the field is invalid. Their hover, active and
38
+ disabled values have no channel, so those states name the neutral
39
+ tokens. */
40
+ & > .drop-area-group > .drop-area {
10
41
  display: flex;
42
+ flex-direction: column;
11
43
  align-items: center;
12
44
  justify-content: center;
13
45
  box-sizing: border-box;
14
- min-height: calc(var(--dimension-400) * 4); /* 128px */
15
- /* Compensate padding for border so total stays on baseline grid */
16
- padding: calc(
17
- var(--form-input-padding-block) -
18
- var(--form-input-border-width)
19
- )
20
- var(--form-input-padding-inline);
21
- border: var(--form-input-border-width) dashed
22
- var(--form-input-border-color);
23
- border-radius: var(--form-input-border-radius);
24
- background-color: var(--form-input-background);
25
- color: var(--color-text-muted);
26
- cursor: pointer;
27
- transition:
28
- border-color var(--motion-duration-fast) ease,
29
- background-color var(--motion-duration-fast) ease;
30
-
31
- & > input[type="file"] {
32
- position: absolute;
33
- width: 1px;
34
- height: 1px;
35
- overflow: hidden;
36
- clip: rect(0, 0, 0, 0);
37
- white-space: nowrap;
38
- border: 0;
39
- }
46
+ /* 112px; no dimension token declares it. */
47
+ min-block-size: calc(var(--dimension-200) * 7);
48
+ padding: var(--dimension-200);
49
+ gap: var(--dimension-100);
50
+ border: var(--dimension-stroke-thickness-medium) dashed
51
+ var(--modifier-color-border, var(--color-border));
52
+ background-color: var(
53
+ --modifier-color-foreground-input,
54
+ var(--color-foreground-input)
55
+ );
56
+ transition: background-color var(--motion-duration-fast) ease;
40
57
 
41
- &:hover:not(:disabled) {
42
- background-color: var(
43
- --hover--color-foreground-input,
44
- var(--color-foreground-input-hover)
45
- );
58
+ /* A file dragged over the area takes the hover fill. */
59
+ &:hover:not(:has(> .ds.button:disabled)),
60
+ &.drag-over {
61
+ background-color: var(--color-foreground-input-hover);
46
62
  }
47
63
 
48
- &:focus-visible {
49
- outline: none;
50
- border-color: var(--form-input-border-color-focus);
51
- box-shadow: 0 0 0 1px var(--form-focus-ring-color);
64
+ /* Pressing the Choose file button makes the whole area active. */
65
+ &:has(> .ds.button:active:not(:disabled)) {
66
+ background-color: var(--color-foreground-input-active);
52
67
  }
53
68
 
54
- &.drag-over {
55
- border-color: var(--form-input-border-color-focus);
56
- background-color: var(
57
- --hover--color-foreground-input,
58
- var(--color-foreground-input-hover)
59
- );
69
+ &:has(> .ds.button:disabled) {
70
+ border-color: var(--color-border-disabled);
71
+ background-color: var(--color-foreground-input-disabled);
60
72
  }
61
73
 
62
- &:disabled {
63
- background-color: var(--form-input-background-disabled);
64
- color: var(--form-input-color-disabled);
65
- cursor: not-allowed;
74
+ /* The Choose file button stays neutral in the error state. The
75
+ Criticality class on the drop area sets these channels for the area's
76
+ own border and fill, but they inherit, and the button would read them
77
+ for its border, icon and focus ring. `initial` unsets each one, so the
78
+ button falls back to its own colours. */
79
+ & > .ds.button {
80
+ --modifier-color-border: initial;
81
+ --modifier-color-icon: initial;
82
+ --modifier-color-focus-ring: initial;
66
83
  }
67
84
  }
68
85
 
86
+ & > .drop-area-group > .drop-area > .drop-area-text {
87
+ font-family: var(--typography-text-primary-font-family);
88
+ font-size: var(--typography-text-primary-font-size);
89
+ font-weight: var(--typography-text-primary-font-weight);
90
+ color: var(--color-text);
91
+ }
92
+
93
+ &.disabled > .drop-area-group > .drop-area > .drop-area-text {
94
+ color: var(--color-text-disabled);
95
+ }
96
+
97
+ /* The native file input stays in the document (it carries the name and
98
+ `required`, and the button opens it) but is visually hidden. */
99
+ & > input[type="file"] {
100
+ position: absolute;
101
+ inline-size: 1px;
102
+ block-size: 1px;
103
+ overflow: hidden;
104
+ clip-path: inset(50%);
105
+ white-space: nowrap;
106
+ border: 0;
107
+ padding: 0;
108
+ }
109
+
110
+ /* ── File list ─────────────────────────────────────────────────── */
69
111
  & > .file-list {
70
112
  list-style: none;
71
113
  margin: 0;
72
114
  padding: 0;
73
115
  display: flex;
74
116
  flex-direction: column;
75
- gap: var(--form-group-gap);
117
+ gap: var(--dimension-200);
118
+ }
119
+ }
120
+
121
+ .ds.input.file-upload > .file-list > .file-item {
122
+ /* Hover and active fills of the tile's actions. The Criticality family has
123
+ no hover or active channel yet, so each criticality is named here. */
124
+ --file-upload-tile-hover: var(--color-foreground-input-hover);
125
+ --file-upload-tile-active: var(--color-foreground-input-active);
126
+
127
+ display: flex;
128
+ flex-direction: column;
129
+ gap: var(--dimension-100);
130
+ margin: 0;
131
+
132
+ &.warning {
133
+ --file-upload-tile-hover: var(--color-foreground-input-warning-hover);
134
+ --file-upload-tile-active: var(--color-foreground-input-warning-active);
135
+ }
136
+
137
+ &.error {
138
+ --file-upload-tile-hover: var(--color-foreground-input-error-hover);
139
+ --file-upload-tile-active: var(--color-foreground-input-error-active);
76
140
  }
77
141
 
78
- & > .file-list > .file-item {
142
+ /* The warning or error message under the tile. */
143
+ & > .file-message {
79
144
  display: flex;
80
- align-items: baseline;
81
- gap: var(--form-field-inline-gap);
82
- box-sizing: border-box;
83
- height: var(--form-input-height);
84
- padding-block: 0;
85
- padding-inline: var(--form-input-padding-inline);
86
- border: var(--form-input-border-width) solid
87
- var(--form-input-border-color);
88
- border-radius: var(--form-input-border-radius);
89
- background-color: var(--form-input-background);
90
- }
91
-
92
- & > .file-list > .file-item > .file-preview {
93
- width: var(--dimension-400); /* 32px */
94
- height: var(--dimension-400); /* 32px */
95
- object-fit: cover;
96
- border-radius: var(--form-input-border-radius);
145
+ flex-direction: row;
146
+ align-items: flex-start;
147
+ gap: var(--dimension-050);
148
+ margin: 0;
149
+
150
+ & > .ds.icon {
151
+ flex-shrink: 0;
152
+ margin-block: var(--dimension-025);
153
+ color: var(--modifier-color-icon, var(--color-icon));
154
+ }
155
+
156
+ & > .message-text {
157
+ flex-grow: 1;
158
+ font-family: var(--typography-text-secondary-font-family);
159
+ font-size: var(--typography-text-secondary-font-size);
160
+ font-weight: var(--typography-text-secondary-font-weight);
161
+ line-height: var(--typography-text-secondary-line-height);
162
+ color: var(--modifier-color-text, var(--color-text-destructive));
163
+ }
164
+ }
165
+
166
+ & > .tile {
167
+ display: flex;
168
+ flex-direction: row;
169
+ }
170
+
171
+ /* With a preview, the tooltip's wrapper is the tile's flex item and the
172
+ thumbnail sits inside it. */
173
+ & > .tile > .thumbnail-preview {
174
+ display: flex;
175
+ flex-shrink: 0;
176
+
177
+ & > .target {
178
+ display: block;
179
+ }
180
+ }
181
+
182
+ /* 60×36 (5:3). The image fills the box edge to edge; the height matches
183
+ the tile's. */
184
+ & > .tile > .thumbnail,
185
+ & > .tile > .thumbnail-preview > .target > .thumbnail {
186
+ display: block;
97
187
  flex-shrink: 0;
188
+ inline-size: 60px;
189
+ block-size: 36px;
190
+ overflow: hidden;
191
+
192
+ & > img {
193
+ display: block;
194
+ inline-size: 100%;
195
+ block-size: 100%;
196
+ object-fit: cover;
197
+ }
198
+ }
199
+
200
+ /* No border: the fill alone draws the tile. */
201
+ & > .tile > .tile-details {
202
+ display: flex;
203
+ flex-direction: row;
204
+ align-items: center;
205
+ flex-grow: 1;
206
+ min-inline-size: 0;
207
+ gap: var(--dimension-100);
208
+ padding-block: var(--dimension-050);
209
+ padding-inline: var(--dimension-150) var(--dimension-050);
210
+ background-color: var(
211
+ --modifier-color-foreground-input,
212
+ var(--color-foreground-input)
213
+ );
214
+ }
215
+
216
+ & > .tile > .tile-details > .file-info {
217
+ display: flex;
218
+ flex-direction: row;
219
+ align-items: center;
220
+ flex-grow: 1;
221
+ min-inline-size: 0;
222
+ gap: var(--dimension-100);
98
223
  }
99
224
 
100
- & > .file-list > .file-item > .file-name {
101
- flex: 1;
102
- min-width: 0;
225
+ & > .tile > .tile-details > .file-info > .file-name {
226
+ flex-shrink: 1;
227
+ min-inline-size: 0;
103
228
  overflow: hidden;
104
229
  text-overflow: ellipsis;
105
230
  white-space: nowrap;
231
+ font-family: var(--typography-text-primary-font-family);
232
+ font-size: var(--typography-text-primary-font-size);
233
+ font-weight: var(--typography-text-primary-font-weight);
234
+ color: var(
235
+ --modifier-color-text-onForegroundSecondary,
236
+ var(--color-text-onForegroundSecondary)
237
+ );
106
238
  }
107
239
 
108
- & > .file-list > .file-item > .file-size {
109
- color: var(--color-text-muted);
240
+ & > .tile > .tile-details > .file-info > .file-size,
241
+ & > .tile > .tile-details > .status-and-actions .upload-progress {
110
242
  white-space: nowrap;
243
+ font-family: var(--typography-text-secondary-font-family);
244
+ font-size: var(--typography-text-secondary-font-size);
245
+ font-weight: var(--typography-text-secondary-font-weight);
111
246
  }
112
247
 
113
- & > .file-list > .file-item > .file-remove {
114
- appearance: none;
115
- border: none;
116
- background: none;
117
- color: var(--color-text-muted);
118
- cursor: pointer;
119
- padding: 0 0.25rem;
248
+ & > .tile > .tile-details > .file-info > .file-size {
249
+ color: var(--modifier-color-text, var(--color-text-muted));
250
+ }
251
+
252
+ & > .tile > .tile-details > .status-and-actions {
253
+ display: flex;
254
+ flex-direction: row;
255
+ align-items: center;
256
+ /* 6px; no dimension token declares this step. */
257
+ gap: 6px;
258
+ }
120
259
 
121
- &:hover {
122
- color: var(--color-text);
260
+ & > .tile > .tile-details > .status-and-actions > .file-status {
261
+ display: flex;
262
+ flex-direction: row;
263
+ align-items: center;
264
+ gap: var(--dimension-100);
265
+
266
+ &:empty {
267
+ display: none;
123
268
  }
124
269
 
125
- /* biome-ignore lint/style/noDescendingSpecificity: :disabled follows :hover by
126
- interaction-state order; both target the same element and reordering would
127
- change the cascade for no visual gain. */
128
- &:disabled {
129
- cursor: not-allowed;
130
- opacity: 0.5;
270
+ & > .upload-progress {
271
+ color: var(--color-text-muted);
131
272
  }
132
273
  }
133
- }
134
274
 
135
- /* Danger state */
136
- .danger > .payload .ds.input.file-upload > .drop-zone {
137
- border-color: var(--form-input-border-color-error);
138
- }
275
+ & > .tile > .tile-details > .status-and-actions > .file-actions {
276
+ display: flex;
277
+ flex-direction: row;
278
+ align-items: center;
279
+ }
139
280
 
140
- .danger > .payload .ds.input.file-upload > .drop-zone:focus-visible {
141
- border-color: var(--form-focus-ring-color-error);
142
- box-shadow: 0 0 0 1px var(--form-focus-ring-color-error);
281
+ /* Icon buttons, 28×28. Their colours come from the tile: the icon reads
282
+ the tile's Criticality icon channel, and the hover and active fills are
283
+ the tile's own. */
284
+ &
285
+ > .tile
286
+ > .tile-details
287
+ > .status-and-actions
288
+ > .file-actions
289
+ > .ds.button.file-action {
290
+ --modifier-surface: transparent;
291
+ --modifier-surface-hover: var(--file-upload-tile-hover);
292
+ --modifier-surface-active: var(--file-upload-tile-active);
293
+ --modifier-outline: 0;
294
+ --modifier-color-text: var(--modifier-color-icon, var(--color-icon));
295
+
296
+ box-sizing: border-box;
297
+ inline-size: calc(var(--dimension-050) * 7);
298
+ block-size: calc(var(--dimension-050) * 7);
299
+ padding: 0;
300
+ align-items: center;
301
+ justify-content: center;
302
+ line-height: 1;
303
+ }
143
304
  }
144
305
  }
@@ -0,0 +1,21 @@
1
+ const UNITS = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"];
2
+ /**
3
+ * Formats a byte count as a short, human-readable size in the given locale,
4
+ * for example `1.5 MB` in English or `1,5 MB` in German. Sizes step by 1024.
5
+ * @note Pure.
6
+ */
7
+ export default function formatFileSize(bytes, locale = "en") {
8
+ let value = bytes;
9
+ let unit = 0;
10
+ while (value >= 1024 && unit < UNITS.length - 1) {
11
+ value /= 1024;
12
+ unit += 1;
13
+ }
14
+ return new Intl.NumberFormat(locale, {
15
+ style: "unit",
16
+ unit: UNITS[unit],
17
+ unitDisplay: "short",
18
+ maximumFractionDigits: 1,
19
+ }).format(value);
20
+ }
21
+ //# sourceMappingURL=formatFileSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatFileSize.js","sourceRoot":"","sources":["../../../../../../src/lib/subcomponent/FileUploadInput/utils/formatFileSize.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAa,EAAE,MAAM,GAAG,IAAI;IACjE,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,OAAO,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACnC,KAAK,EAAE,MAAM;QACb,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;QACjB,WAAW,EAAE,OAAO;QACpB,qBAAqB,EAAE,CAAC;KACzB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC"}