@pega/cosmos-react-core 4.0.0-dev.23.0 → 4.0.0-dev.24.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 (406) hide show
  1. package/lib/components/Actions/Actions.d.ts.map +1 -1
  2. package/lib/components/Actions/Actions.js +1 -1
  3. package/lib/components/Actions/Actions.js.map +1 -1
  4. package/lib/components/AdditionalInfo/AdditionalInfo.d.ts.map +1 -1
  5. package/lib/components/AdditionalInfo/AdditionalInfo.js +3 -2
  6. package/lib/components/AdditionalInfo/AdditionalInfo.js.map +1 -1
  7. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  8. package/lib/components/AppShell/AppHeader.js +1 -1
  9. package/lib/components/AppShell/AppHeader.js.map +1 -1
  10. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  11. package/lib/components/AppShell/AppShell.js +1 -1
  12. package/lib/components/AppShell/AppShell.js.map +1 -1
  13. package/lib/components/AppShell/Operator.d.ts.map +1 -1
  14. package/lib/components/AppShell/Operator.js +1 -1
  15. package/lib/components/AppShell/Operator.js.map +1 -1
  16. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  17. package/lib/components/Avatar/Avatar.js +1 -1
  18. package/lib/components/Avatar/Avatar.js.map +1 -1
  19. package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
  20. package/lib/components/Backdrop/Backdrop.js +1 -1
  21. package/lib/components/Backdrop/Backdrop.js.map +1 -1
  22. package/lib/components/Badges/Alert.d.ts.map +1 -1
  23. package/lib/components/Badges/Alert.js +1 -1
  24. package/lib/components/Badges/Alert.js.map +1 -1
  25. package/lib/components/Badges/Count.d.ts.map +1 -1
  26. package/lib/components/Badges/Count.js +1 -1
  27. package/lib/components/Badges/Count.js.map +1 -1
  28. package/lib/components/Badges/Selection.d.ts.map +1 -1
  29. package/lib/components/Badges/Selection.js +1 -1
  30. package/lib/components/Badges/Selection.js.map +1 -1
  31. package/lib/components/Badges/Status.d.ts.map +1 -1
  32. package/lib/components/Badges/Status.js +1 -1
  33. package/lib/components/Badges/Status.js.map +1 -1
  34. package/lib/components/Badges/Tag.d.ts.map +1 -1
  35. package/lib/components/Badges/Tag.js +1 -1
  36. package/lib/components/Badges/Tag.js.map +1 -1
  37. package/lib/components/Banner/Banner.d.ts.map +1 -1
  38. package/lib/components/Banner/Banner.js +2 -3
  39. package/lib/components/Banner/Banner.js.map +1 -1
  40. package/lib/components/Boolean/BooleanDisplay.js +1 -1
  41. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  42. package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
  43. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  44. package/lib/components/Button/BareButton.js +1 -1
  45. package/lib/components/Button/BareButton.js.map +1 -1
  46. package/lib/components/Button/BareRoleButton.js +1 -1
  47. package/lib/components/Button/BareRoleButton.js.map +1 -1
  48. package/lib/components/Button/Button.d.ts.map +1 -1
  49. package/lib/components/Button/Button.js +1 -1
  50. package/lib/components/Button/Button.js.map +1 -1
  51. package/lib/components/Card/Card.d.ts.map +1 -1
  52. package/lib/components/Card/Card.js +1 -1
  53. package/lib/components/Card/Card.js.map +1 -1
  54. package/lib/components/Card/CardHeader.js +1 -1
  55. package/lib/components/Card/CardHeader.js.map +1 -1
  56. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  57. package/lib/components/Checkbox/Checkbox.js +3 -1
  58. package/lib/components/Checkbox/Checkbox.js.map +1 -1
  59. package/lib/components/ColorPicker/ColorPicker.d.ts.map +1 -1
  60. package/lib/components/ColorPicker/ColorPicker.js +1 -1
  61. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  62. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  63. package/lib/components/ComboBox/ComboBox.js +1 -1
  64. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  65. package/lib/components/ComboBox/ComboBoxInput.js +1 -1
  66. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  67. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  68. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +1 -1
  69. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  70. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  71. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +1 -1
  72. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  73. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  74. package/lib/components/CompositeInput/CompositeInput.js +2 -6
  75. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  76. package/lib/components/CreditCard/CreditCardDisplay.js +1 -1
  77. package/lib/components/CreditCard/CreditCardDisplay.js.map +1 -1
  78. package/lib/components/CreditCard/CreditCardInput.js +1 -1
  79. package/lib/components/CreditCard/CreditCardInput.js.map +1 -1
  80. package/lib/components/Currency/CurrencyDisplay.js +1 -1
  81. package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
  82. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  83. package/lib/components/Currency/CurrencyInput.js +1 -1
  84. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  85. package/lib/components/DateTime/DateTimeDisplay.js +1 -1
  86. package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
  87. package/lib/components/DateTime/DurationDisplay.js +1 -1
  88. package/lib/components/DateTime/DurationDisplay.js.map +1 -1
  89. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  90. package/lib/components/DateTime/Input/DateInput.js +1 -1
  91. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  92. package/lib/components/DateTime/Input/DateRangeInput.js +1 -1
  93. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  94. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  95. package/lib/components/DateTime/Input/DateTimeInput.js +1 -1
  96. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  97. package/lib/components/DateTime/Input/DayOfWeekInput.d.ts.map +1 -1
  98. package/lib/components/DateTime/Input/DayOfWeekInput.js +1 -12
  99. package/lib/components/DateTime/Input/DayOfWeekInput.js.map +1 -1
  100. package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
  101. package/lib/components/DateTime/Input/Duration/DurationInput.js +1 -1
  102. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  103. package/lib/components/DateTime/Input/MonthInput.js +1 -1
  104. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  105. package/lib/components/DateTime/Input/PartInput.d.ts.map +1 -1
  106. package/lib/components/DateTime/Input/PartInput.js +1 -1
  107. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  108. package/lib/components/DateTime/Input/QuarterInput.js +1 -1
  109. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  110. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  111. package/lib/components/DateTime/Input/TimeInput.js +2 -5
  112. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  113. package/lib/components/DateTime/Input/TimeRangeInput.js +1 -1
  114. package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
  115. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  116. package/lib/components/DateTime/Input/WeekInput.js +2 -3
  117. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  118. package/lib/components/DateTime/Input/utils.d.ts +3 -0
  119. package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
  120. package/lib/components/DateTime/Input/utils.js +11 -0
  121. package/lib/components/DateTime/Input/utils.js.map +1 -1
  122. package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
  123. package/lib/components/DateTime/Picker/Calendar.js +1 -1
  124. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  125. package/lib/components/DateTime/Picker/Weeks.d.ts.map +1 -1
  126. package/lib/components/DateTime/Picker/Weeks.js +1 -1
  127. package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
  128. package/lib/components/Dialog/Dialog.d.ts.map +1 -1
  129. package/lib/components/Dialog/Dialog.js +1 -1
  130. package/lib/components/Dialog/Dialog.js.map +1 -1
  131. package/lib/components/Dialog/FormDialog.d.ts.map +1 -1
  132. package/lib/components/Dialog/FormDialog.js +5 -9
  133. package/lib/components/Dialog/FormDialog.js.map +1 -1
  134. package/lib/components/Dialog/InfoDialog.d.ts.map +1 -1
  135. package/lib/components/Dialog/InfoDialog.js +4 -3
  136. package/lib/components/Dialog/InfoDialog.js.map +1 -1
  137. package/lib/components/Drawer/Drawer.d.ts.map +1 -1
  138. package/lib/components/Drawer/Drawer.js +1 -1
  139. package/lib/components/Drawer/Drawer.js.map +1 -1
  140. package/lib/components/Email/EmailDisplay.js +1 -1
  141. package/lib/components/Email/EmailDisplay.js.map +1 -1
  142. package/lib/components/EmojiPicker/EmojiPicker.d.ts.map +1 -1
  143. package/lib/components/EmojiPicker/EmojiPicker.js +1 -1
  144. package/lib/components/EmojiPicker/EmojiPicker.js.map +1 -1
  145. package/lib/components/EmptyState/EmptyState.js +1 -1
  146. package/lib/components/EmptyState/EmptyState.js.map +1 -1
  147. package/lib/components/ErrorState/ErrorState.js +1 -1
  148. package/lib/components/ErrorState/ErrorState.js.map +1 -1
  149. package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
  150. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  151. package/lib/components/FieldGroup/FieldGroup.js +1 -1
  152. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  153. package/lib/components/FieldGroup/FieldGroupList.js +1 -1
  154. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  155. package/lib/components/FieldValueList/FieldValueList.js +1 -1
  156. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  157. package/lib/components/File/FileDisplay.js +1 -1
  158. package/lib/components/File/FileDisplay.js.map +1 -1
  159. package/lib/components/File/FileInput.d.ts.map +1 -1
  160. package/lib/components/File/FileInput.js +1 -1
  161. package/lib/components/File/FileInput.js.map +1 -1
  162. package/lib/components/File/FileItem.d.ts.map +1 -1
  163. package/lib/components/File/FileItem.js +1 -1
  164. package/lib/components/File/FileItem.js.map +1 -1
  165. package/lib/components/File/FileUploadItem.d.ts.map +1 -1
  166. package/lib/components/File/FileUploadItem.js +1 -1
  167. package/lib/components/File/FileUploadItem.js.map +1 -1
  168. package/lib/components/File/FileVisual.d.ts.map +1 -1
  169. package/lib/components/File/FileVisual.js +1 -1
  170. package/lib/components/File/FileVisual.js.map +1 -1
  171. package/lib/components/Flex/Flex.d.ts.map +1 -1
  172. package/lib/components/Flex/Flex.js +1 -1
  173. package/lib/components/Flex/Flex.js.map +1 -1
  174. package/lib/components/Form/Form.d.ts.map +1 -1
  175. package/lib/components/Form/Form.js +1 -1
  176. package/lib/components/Form/Form.js.map +1 -1
  177. package/lib/components/FormControl/FormControl.js +1 -1
  178. package/lib/components/FormControl/FormControl.js.map +1 -1
  179. package/lib/components/FormField/FormField.d.ts.map +1 -1
  180. package/lib/components/FormField/FormField.js +1 -1
  181. package/lib/components/FormField/FormField.js.map +1 -1
  182. package/lib/components/FormField/index.d.ts +1 -1
  183. package/lib/components/FormField/index.d.ts.map +1 -1
  184. package/lib/components/FormField/index.js +1 -1
  185. package/lib/components/FormField/index.js.map +1 -1
  186. package/lib/components/Grid/Grid.d.ts.map +1 -1
  187. package/lib/components/Grid/Grid.js +1 -1
  188. package/lib/components/Grid/Grid.js.map +1 -1
  189. package/lib/components/HTML/HTML.d.ts.map +1 -1
  190. package/lib/components/HTML/HTML.js +1 -1
  191. package/lib/components/HTML/HTML.js.map +1 -1
  192. package/lib/components/Icon/Icon.d.ts.map +1 -1
  193. package/lib/components/Icon/Icon.js +1 -1
  194. package/lib/components/Icon/Icon.js.map +1 -1
  195. package/lib/components/Icon/iconNames.d.ts +1 -1
  196. package/lib/components/Icon/iconNames.d.ts.map +1 -1
  197. package/lib/components/Icon/iconNames.js +1 -0
  198. package/lib/components/Icon/iconNames.js.map +1 -1
  199. package/lib/components/Icon/icons/live-transcript.icon.d.ts +5 -0
  200. package/lib/components/Icon/icons/live-transcript.icon.d.ts.map +1 -0
  201. package/lib/components/Icon/icons/live-transcript.icon.js +7 -0
  202. package/lib/components/Icon/icons/live-transcript.icon.js.map +1 -0
  203. package/lib/components/Icon/streamline-icons/code-search.icon.d.ts.map +1 -1
  204. package/lib/components/Icon/streamline-icons/code-search.icon.js +1 -1
  205. package/lib/components/Icon/streamline-icons/code-search.icon.js.map +1 -1
  206. package/lib/components/Icon/streamline-icons/copy.icon.d.ts +5 -0
  207. package/lib/components/Icon/streamline-icons/copy.icon.d.ts.map +1 -0
  208. package/lib/components/Icon/streamline-icons/copy.icon.js +7 -0
  209. package/lib/components/Icon/streamline-icons/copy.icon.js.map +1 -0
  210. package/lib/components/Icon/streamline-icons/search.icon.d.ts.map +1 -1
  211. package/lib/components/Icon/streamline-icons/search.icon.js +1 -1
  212. package/lib/components/Icon/streamline-icons/search.icon.js.map +1 -1
  213. package/lib/components/Icon/streamlineIconNames.d.ts +1 -1
  214. package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
  215. package/lib/components/Icon/streamlineIconNames.js +1 -0
  216. package/lib/components/Icon/streamlineIconNames.js.map +1 -1
  217. package/lib/components/IconPicker/IconPicker.js +1 -1
  218. package/lib/components/IconPicker/IconPicker.js.map +1 -1
  219. package/lib/components/Image/Image.d.ts.map +1 -1
  220. package/lib/components/Image/Image.js +1 -1
  221. package/lib/components/Image/Image.js.map +1 -1
  222. package/lib/components/Input/Input.d.ts.map +1 -1
  223. package/lib/components/Input/Input.js +1 -1
  224. package/lib/components/Input/Input.js.map +1 -1
  225. package/lib/components/Label/Label.d.ts.map +1 -1
  226. package/lib/components/Label/Label.js +1 -1
  227. package/lib/components/Label/Label.js.map +1 -1
  228. package/lib/components/Lightbox/Lightbox.d.ts.map +1 -1
  229. package/lib/components/Lightbox/Lightbox.js +1 -1
  230. package/lib/components/Lightbox/Lightbox.js.map +1 -1
  231. package/lib/components/Link/Link.d.ts.map +1 -1
  232. package/lib/components/Link/Link.js +3 -4
  233. package/lib/components/Link/Link.js.map +1 -1
  234. package/lib/components/List/CommaSeparatedList.js +1 -1
  235. package/lib/components/List/CommaSeparatedList.js.map +1 -1
  236. package/lib/components/List/List.d.ts.map +1 -1
  237. package/lib/components/List/List.js +1 -1
  238. package/lib/components/List/List.js.map +1 -1
  239. package/lib/components/List/OrderedList.d.ts.map +1 -1
  240. package/lib/components/List/OrderedList.js +3 -1
  241. package/lib/components/List/OrderedList.js.map +1 -1
  242. package/lib/components/List/UnorderedList.d.ts.map +1 -1
  243. package/lib/components/List/UnorderedList.js +3 -1
  244. package/lib/components/List/UnorderedList.js.map +1 -1
  245. package/lib/components/ListToolbar/ListToolbar.js +1 -1
  246. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  247. package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -1
  248. package/lib/components/ListToolbar/PresetMenuPopover.js +10 -4
  249. package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -1
  250. package/lib/components/Location/LocationDisplay.js +1 -1
  251. package/lib/components/Location/LocationDisplay.js.map +1 -1
  252. package/lib/components/Location/LocationInput.d.ts.map +1 -1
  253. package/lib/components/Location/LocationInput.js +1 -1
  254. package/lib/components/Location/LocationInput.js.map +1 -1
  255. package/lib/components/Menu/FlyoutMenuList.d.ts.map +1 -1
  256. package/lib/components/Menu/FlyoutMenuList.js +1 -1
  257. package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
  258. package/lib/components/Menu/Menu.d.ts.map +1 -1
  259. package/lib/components/Menu/Menu.js +1 -1
  260. package/lib/components/Menu/Menu.js.map +1 -1
  261. package/lib/components/Menu/MenuList.js +1 -1
  262. package/lib/components/Menu/MenuList.js.map +1 -1
  263. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  264. package/lib/components/MenuButton/MenuButton.js +8 -6
  265. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  266. package/lib/components/MetaList/MetaList.d.ts.map +1 -1
  267. package/lib/components/MetaList/MetaList.js +1 -1
  268. package/lib/components/MetaList/MetaList.js.map +1 -1
  269. package/lib/components/Modal/DockedModals.d.ts.map +1 -1
  270. package/lib/components/Modal/DockedModals.js +1 -1
  271. package/lib/components/Modal/DockedModals.js.map +1 -1
  272. package/lib/components/Modal/Modal.d.ts.map +1 -1
  273. package/lib/components/Modal/Modal.js +2 -5
  274. package/lib/components/Modal/Modal.js.map +1 -1
  275. package/lib/components/MultiStepForm/MultiStepForm.js +1 -1
  276. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
  277. package/lib/components/Number/NumberDisplay.js +1 -1
  278. package/lib/components/Number/NumberDisplay.js.map +1 -1
  279. package/lib/components/Number/NumberInput.js +1 -1
  280. package/lib/components/Number/NumberInput.js.map +1 -1
  281. package/lib/components/Number/NumberRangeInput.js +1 -1
  282. package/lib/components/Number/NumberRangeInput.js.map +1 -1
  283. package/lib/components/PageTemplates/CategorySubPage.js +1 -1
  284. package/lib/components/PageTemplates/CategorySubPage.js.map +1 -1
  285. package/lib/components/PageTemplates/DashboardPage.js +2 -2
  286. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  287. package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
  288. package/lib/components/PageTemplates/PageTemplates.js +11 -11
  289. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  290. package/lib/components/Paragraph/ParagraphDisplay.js +1 -1
  291. package/lib/components/Paragraph/ParagraphDisplay.js.map +1 -1
  292. package/lib/components/Phone/PhoneDisplay.js +1 -1
  293. package/lib/components/Phone/PhoneDisplay.js.map +1 -1
  294. package/lib/components/Phone/PhoneInput.js +1 -1
  295. package/lib/components/Phone/PhoneInput.js.map +1 -1
  296. package/lib/components/Popover/Popover.d.ts.map +1 -1
  297. package/lib/components/Popover/Popover.js +1 -1
  298. package/lib/components/Popover/Popover.js.map +1 -1
  299. package/lib/components/Progress/Bar.d.ts.map +1 -1
  300. package/lib/components/Progress/Bar.js +1 -1
  301. package/lib/components/Progress/Bar.js.map +1 -1
  302. package/lib/components/Progress/Ellipsis.d.ts.map +1 -1
  303. package/lib/components/Progress/Ellipsis.js +1 -1
  304. package/lib/components/Progress/Ellipsis.js.map +1 -1
  305. package/lib/components/Progress/Progress.d.ts.map +1 -1
  306. package/lib/components/Progress/Progress.js +1 -1
  307. package/lib/components/Progress/Progress.js.map +1 -1
  308. package/lib/components/Progress/Ring.d.ts.map +1 -1
  309. package/lib/components/Progress/Ring.js +1 -1
  310. package/lib/components/Progress/Ring.js.map +1 -1
  311. package/lib/components/QRCode/QRCode.d.ts.map +1 -1
  312. package/lib/components/QRCode/QRCode.js +1 -1
  313. package/lib/components/QRCode/QRCode.js.map +1 -1
  314. package/lib/components/RadioButton/RadioButton.d.ts.map +1 -1
  315. package/lib/components/RadioButton/RadioButton.js +3 -1
  316. package/lib/components/RadioButton/RadioButton.js.map +1 -1
  317. package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
  318. package/lib/components/RadioCheck/RadioCheck.js +15 -5
  319. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  320. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  321. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -1
  322. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  323. package/lib/components/Rating/Rating.d.ts.map +1 -1
  324. package/lib/components/Rating/Rating.js +3 -6
  325. package/lib/components/Rating/Rating.js.map +1 -1
  326. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  327. package/lib/components/SearchInput/SearchInput.js +4 -12
  328. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  329. package/lib/components/Select/Select.d.ts.map +1 -1
  330. package/lib/components/Select/Select.js +1 -1
  331. package/lib/components/Select/Select.js.map +1 -1
  332. package/lib/components/Sentiment/Sentiment.d.ts.map +1 -1
  333. package/lib/components/Sentiment/Sentiment.js +1 -1
  334. package/lib/components/Sentiment/Sentiment.js.map +1 -1
  335. package/lib/components/Slider/Slider.d.ts.map +1 -1
  336. package/lib/components/Slider/Slider.js +1 -1
  337. package/lib/components/Slider/Slider.js.map +1 -1
  338. package/lib/components/Slider/Slider.styles.d.ts.map +1 -1
  339. package/lib/components/Slider/Slider.styles.js +3 -3
  340. package/lib/components/Slider/Slider.styles.js.map +1 -1
  341. package/lib/components/SummaryItem/SummaryItem.js +1 -1
  342. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  343. package/lib/components/SummaryList/SummaryList.d.ts.map +1 -1
  344. package/lib/components/SummaryList/SummaryList.js +1 -1
  345. package/lib/components/SummaryList/SummaryList.js.map +1 -1
  346. package/lib/components/SummaryList/ViewAll.d.ts.map +1 -1
  347. package/lib/components/SummaryList/ViewAll.js +1 -1
  348. package/lib/components/SummaryList/ViewAll.js.map +1 -1
  349. package/lib/components/Switch/Switch.d.ts.map +1 -1
  350. package/lib/components/Switch/Switch.js +1 -1
  351. package/lib/components/Switch/Switch.js.map +1 -1
  352. package/lib/components/Table/Table.d.ts.map +1 -1
  353. package/lib/components/Table/Table.js +1 -1
  354. package/lib/components/Table/Table.js.map +1 -1
  355. package/lib/components/Tabs/Tab.d.ts +2 -0
  356. package/lib/components/Tabs/Tab.d.ts.map +1 -1
  357. package/lib/components/Tabs/Tab.js +19 -3
  358. package/lib/components/Tabs/Tab.js.map +1 -1
  359. package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
  360. package/lib/components/Tabs/TabPanel.js +1 -1
  361. package/lib/components/Tabs/TabPanel.js.map +1 -1
  362. package/lib/components/Tabs/Tabs.d.ts.map +1 -1
  363. package/lib/components/Tabs/Tabs.js +3 -3
  364. package/lib/components/Tabs/Tabs.js.map +1 -1
  365. package/lib/components/Tabs/Tabs.types.d.ts +2 -0
  366. package/lib/components/Tabs/Tabs.types.d.ts.map +1 -1
  367. package/lib/components/Tabs/Tabs.types.js.map +1 -1
  368. package/lib/components/Text/Text.d.ts.map +1 -1
  369. package/lib/components/Text/Text.js +1 -1
  370. package/lib/components/Text/Text.js.map +1 -1
  371. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  372. package/lib/components/TextArea/TextArea.js +1 -1
  373. package/lib/components/TextArea/TextArea.js.map +1 -1
  374. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  375. package/lib/components/Toaster/Toaster.js +1 -1
  376. package/lib/components/Toaster/Toaster.js.map +1 -1
  377. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  378. package/lib/components/Tooltip/Tooltip.js +1 -1
  379. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  380. package/lib/components/Tree/StandardTree.js +2 -2
  381. package/lib/components/Tree/StandardTree.js.map +1 -1
  382. package/lib/components/Tree/Tree.d.ts.map +1 -1
  383. package/lib/components/Tree/Tree.js +2 -2
  384. package/lib/components/Tree/Tree.js.map +1 -1
  385. package/lib/components/URL/URLDisplay.js +1 -1
  386. package/lib/components/URL/URLDisplay.js.map +1 -1
  387. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.d.ts.map +1 -1
  388. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.js +3 -1
  389. package/lib/components/VisuallyHiddenText/VisuallyHiddenText.js.map +1 -1
  390. package/lib/hooks/useEscape.d.ts +3 -0
  391. package/lib/hooks/useEscape.d.ts.map +1 -1
  392. package/lib/hooks/useEscape.js +5 -2
  393. package/lib/hooks/useEscape.js.map +1 -1
  394. package/lib/hooks/useI18n.d.ts +25 -14
  395. package/lib/hooks/useI18n.d.ts.map +1 -1
  396. package/lib/i18n/default.d.ts +25 -14
  397. package/lib/i18n/default.d.ts.map +1 -1
  398. package/lib/i18n/default.js +28 -16
  399. package/lib/i18n/default.js.map +1 -1
  400. package/lib/i18n/i18n.d.ts +25 -14
  401. package/lib/i18n/i18n.d.ts.map +1 -1
  402. package/lib/styles/GlobalStyle.d.ts +2 -2
  403. package/lib/styles/GlobalStyle.d.ts.map +1 -1
  404. package/lib/styles/GlobalStyle.js +2 -2
  405. package/lib/styles/GlobalStyle.js.map +1 -1
  406. package/package.json +1 -1
@@ -22,7 +22,7 @@ export const StyledErrorState = styled.div(({ theme }) => {
22
22
  `;
23
23
  });
24
24
  StyledErrorState.defaultProps = defaultThemeProp;
25
- const ErrorState = forwardRef((props, ref) => {
25
+ const ErrorState = forwardRef(function ErrorState(props, ref) {
26
26
  const t = useI18n();
27
27
  const { message = t('unknown_error'), onRetry, ...restProps } = props;
28
28
  return (_jsxs(Flex, { ...restProps, as: StyledErrorState, ref: ref, container: { direction: 'column', alignItems: 'center', justify: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'warn' }), _jsx(Text, { variant: 'secondary', children: message }), onRetry && (_jsx(Button, { variant: 'secondary', onClick: onRetry, children: t('try_again') }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorState.js","sourceRoot":"","sources":["../../../src/components/ErrorState/ErrorState.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,CAAC,QAAQ,CAAC,CAAC;AAavB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;;;MAGN,UAAU;;;;eAID,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;;GAErC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,CAAC,KAAuC,EAAE,GAA2B,EAAE,EAAE;IACvE,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEtE,OAAO,CACL,MAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,gBAAgB,EACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAEnF,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACpB,KAAC,IAAI,IAAC,OAAO,EAAC,WAAW,YAAE,OAAO,GAAQ,EACzC,OAAO,IAAI,CACV,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,OAAO,EAAE,OAAO,YACzC,CAAC,CAAC,WAAW,CAAC,GACR,CACV,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Flex from '../Flex';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as warnIcon from '../Icon/icons/warn.icon';\nimport Text from '../Text';\nimport { useI18n } from '../../hooks';\nimport { BaseProps, NoChildrenProp, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\n\nregisterIcon(warnIcon);\n\nexport interface ErrorStateProps extends BaseProps, NoChildrenProp {\n /**\n * Message to display below the icon.\n * @default 'Unknown error'\n */\n message?: string;\n /** Callback function that if provided renders a localized Retry button. */\n onRetry?: () => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledErrorState = styled.div(({ theme }) => {\n return css`\n height: 100%;\n\n ${StyledIcon} {\n font-size: 1.5rem;\n height: 1.5rem;\n width: 1.5rem;\n color: ${theme.base.palette.urgent};\n }\n `;\n});\n\nStyledErrorState.defaultProps = defaultThemeProp;\n\nconst ErrorState: FunctionComponent<ErrorStateProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ErrorStateProps>, ref: ErrorStateProps['ref']) => {\n const t = useI18n();\n const { message = t('unknown_error'), onRetry, ...restProps } = props;\n\n return (\n <Flex\n {...restProps}\n as={StyledErrorState}\n ref={ref}\n container={{ direction: 'column', alignItems: 'center', justify: 'center', gap: 1 }}\n >\n <Icon name='warn' />\n <Text variant='secondary'>{message}</Text>\n {onRetry && (\n <Button variant='secondary' onClick={onRetry}>\n {t('try_again')}\n </Button>\n )}\n </Flex>\n );\n }\n);\n\nexport default ErrorState;\n"]}
1
+ {"version":3,"file":"ErrorState.js","sourceRoot":"","sources":["../../../src/components/ErrorState/ErrorState.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,CAAC,QAAQ,CAAC,CAAC;AAavB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;;;MAGN,UAAU;;;;eAID,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;;GAErC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,SAAS,UAAU,CAAC,KAAuC,EAAE,GAA2B;IACtF,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEtE,OAAO,CACL,MAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,gBAAgB,EACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAEnF,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACpB,KAAC,IAAI,IAAC,OAAO,EAAC,WAAW,YAAE,OAAO,GAAQ,EACzC,OAAO,IAAI,CACV,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,OAAO,EAAE,OAAO,YACzC,CAAC,CAAC,WAAW,CAAC,GACR,CACV,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Flex from '../Flex';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as warnIcon from '../Icon/icons/warn.icon';\nimport Text from '../Text';\nimport { useI18n } from '../../hooks';\nimport { BaseProps, NoChildrenProp, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\n\nregisterIcon(warnIcon);\n\nexport interface ErrorStateProps extends BaseProps, NoChildrenProp {\n /**\n * Message to display below the icon.\n * @default 'Unknown error'\n */\n message?: string;\n /** Callback function that if provided renders a localized Retry button. */\n onRetry?: () => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledErrorState = styled.div(({ theme }) => {\n return css`\n height: 100%;\n\n ${StyledIcon} {\n font-size: 1.5rem;\n height: 1.5rem;\n width: 1.5rem;\n color: ${theme.base.palette.urgent};\n }\n `;\n});\n\nStyledErrorState.defaultProps = defaultThemeProp;\n\nconst ErrorState: FunctionComponent<ErrorStateProps & ForwardProps> = forwardRef(\n function ErrorState(props: PropsWithoutRef<ErrorStateProps>, ref: ErrorStateProps['ref']) {\n const t = useI18n();\n const { message = t('unknown_error'), onRetry, ...restProps } = props;\n\n return (\n <Flex\n {...restProps}\n as={StyledErrorState}\n ref={ref}\n container={{ direction: 'column', alignItems: 'center', justify: 'center', gap: 1 }}\n >\n <Icon name='warn' />\n <Text variant='secondary'>{message}</Text>\n {onRetry && (\n <Button variant='secondary' onClick={onRetry}>\n {t('try_again')}\n </Button>\n )}\n </Flex>\n );\n }\n);\n\nexport default ErrorState;\n"]}
@@ -31,7 +31,7 @@ const getStyle = (props) => {
31
31
  }
32
32
  return style;
33
33
  };
34
- const ExpandCollapse = forwardRef((props, refArg) => {
34
+ const ExpandCollapse = forwardRef(function ExpandCollapse(props, refArg) {
35
35
  const { base: { animation: themeAnimation } } = useTheme();
36
36
  const { children, dimension = 'height', collapsed = false, onBeforeExpand, onAfterExpand, onBeforeCollapse, onAfterCollapse, transitionSpeed = themeAnimation.speed, min, max, nullWhenCollapsed = false, as: Tag = 'div', ...restProps } = props;
37
37
  const [status, setStatus] = useState(collapsed ? 'collapsed' : 'expanded');
@@ -1 +1 @@
1
- {"version":3,"file":"ExpandCollapse.js","sourceRoot":"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B;YACjB,MAAM;YACN,EAAE,EAAE,GAAG,CAAC,OAAO;YACf,wBAAwB,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI;SACrD,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAElC,IAAI,MAAM,KAAK,cAAc,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,cAAe,CAAC,EAAE;QACpF,KAAK,GAAG,QAAQ,CAAC;YACf,SAAS;YACT,GAAG;YACH,GAAG;YACH,eAAe;YACf,iBAAiB;YACjB,MAAM,EAAE,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW;YAC3D,EAAE,EAAE,GAAG,CAAC,OAAO;YACf,wBAAwB,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI;SACrD,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,KAAK,WAAW,IAAI,iBAAiB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAClE,KAAC,GAAG,IAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,eAAe,KAAM,SAAS,EAAE,KAAK,EAAE,KAAK,YACzE,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ReactNode,\n PropsWithoutRef,\n useState,\n useLayoutEffect,\n useCallback,\n CSSProperties\n} from 'react';\n\nimport { ForwardProps, BaseProps, AsProp, PropsWithDefaults } from '../../types';\nimport { useConsolidatedRef, usePrevious, useTheme } from '../../hooks';\n\nexport interface ExpandCollapseProps extends AsProp, BaseProps {\n /** Content to expand/collapse. */\n children?: ReactNode;\n /**\n * If true,the content will be hidden.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Used to determine the transition property.\n * @default 'height'\n */\n dimension?: 'height' | 'width';\n /** Minimum height/width to collapse to. This will set the starting collapsed size as well. */\n min?: string;\n /** Maximum height/width to expand to. Expanded state will expanded up until, but not beyond, the natural height/width of the element. */\n max?: string;\n /** Callback fired after content collapsed. */\n onAfterCollapse?: () => void;\n /** Callback fired after content expanded. */\n onAfterExpand?: () => void;\n /** Callback fired before content collapsed. */\n onBeforeCollapse?: () => void;\n /** Callback fired before content expanded. */\n onBeforeExpand?: () => void;\n /**\n * Determine the speed of animation. This value comes from `theme.base.animation.speed`.\n * @default '0.25s'\n */\n transitionSpeed?: string;\n /**\n * If true, removes the component from the real DOM when collapsed. For full virtual DOM unmount(if necessary), perform at a parent level.\n * @default false\n */\n nullWhenCollapsed?: boolean;\n}\n\ntype ExpandCollapsePropsWithDefaults = PropsWithDefaults<\n ExpandCollapseProps,\n 'collapsed' | 'dimension' | 'transitionSpeed' | 'nullWhenCollapsed'\n>;\n\ntype Statuses = 'collapsed' | 'collapsing' | 'expanded' | 'expanding';\n\ninterface GetStyleProps\n extends Pick<\n ExpandCollapsePropsWithDefaults,\n 'dimension' | 'transitionSpeed' | 'min' | 'max' | 'nullWhenCollapsed'\n > {\n status: Statuses;\n el?: HTMLElement | null;\n transitionTimingFunction?: string;\n}\n\nconst getScrollSize = (\n el: HTMLElement,\n dimension: ExpandCollapsePropsWithDefaults['dimension']\n): string => {\n if (!el) return '';\n return dimension === 'height' ? `${el.scrollHeight}px` : `${el.scrollWidth}px`;\n};\n\nconst getStyle = (props: GetStyleProps): CSSProperties => {\n const {\n status,\n dimension,\n transitionSpeed,\n transitionTimingFunction,\n min,\n max,\n nullWhenCollapsed,\n el\n } = props;\n const style: CSSProperties = {};\n let maxSize = max;\n\n if (el && !max) {\n maxSize = getScrollSize(el, dimension!);\n }\n\n if (status === 'expanded' || status === 'collapsed') {\n if (max || min) {\n style[dimension as 'height' | 'width'] = status === 'expanded' ? maxSize : min || 0;\n style[`overflow${dimension === 'width' ? 'X' : 'Y'}`] = 'hidden';\n }\n\n if (status === 'collapsed' && !nullWhenCollapsed && !min) {\n style.display = 'none';\n }\n }\n\n if (status === 'expanding' || status === 'collapsing') {\n style[dimension as 'height' | 'width'] = status === 'expanding' ? maxSize : min || 0;\n style.overflow = 'hidden';\n style.transitionProperty = dimension;\n style.transitionDuration = `max(${transitionSpeed}, 0.01ms)`;\n style.transitionTimingFunction = transitionTimingFunction;\n }\n\n return style;\n};\n\nconst ExpandCollapse: FunctionComponent<ExpandCollapseProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ExpandCollapseProps>, refArg: Ref<HTMLElement>) => {\n const {\n base: { animation: themeAnimation }\n } = useTheme();\n\n const {\n children,\n dimension = 'height',\n collapsed = false,\n onBeforeExpand,\n onAfterExpand,\n onBeforeCollapse,\n onAfterCollapse,\n transitionSpeed = themeAnimation.speed,\n min,\n max,\n nullWhenCollapsed = false,\n as: Tag = 'div',\n ...restProps\n } = props;\n\n const [status, setStatus] = useState<Statuses>(collapsed ? 'collapsed' : 'expanded');\n const styleStateHook = useState<CSSProperties>();\n const setStyle = styleStateHook[1];\n let style = styleStateHook[0];\n const previousStatus = usePrevious(status);\n const ref = useConsolidatedRef(refArg);\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.target !== ref.current || e.propertyName !== dimension) return;\n setStatus(status === 'expanding' ? 'expanded' : 'collapsed');\n },\n [ref.current, status]\n );\n\n useLayoutEffect(() => {\n const wantsToCollapse = collapsed;\n const wantsToExpand = !collapsed;\n const canCollapse = ['expanded', 'expanding'].includes(status);\n const canExpand = ['collapsed', 'collapsing'].includes(status);\n\n if (wantsToExpand && canExpand) {\n onBeforeExpand?.();\n setStatus('expanding');\n } else if (wantsToCollapse && canCollapse) {\n onBeforeCollapse?.();\n setStatus('collapsing');\n }\n\n if (status === 'expanded' && previousStatus !== 'expanded') {\n onAfterExpand?.();\n } else if (status === 'collapsed' && previousStatus !== 'collapsed') {\n onAfterCollapse?.();\n }\n\n setStyle(\n getStyle({\n dimension,\n min,\n max,\n transitionSpeed,\n nullWhenCollapsed,\n status,\n el: ref.current,\n transitionTimingFunction: themeAnimation.timing.ease\n })\n );\n }, [collapsed, status, min, max]);\n\n if (status !== previousStatus && ['expanded', 'collapsed'].includes(previousStatus!)) {\n style = getStyle({\n dimension,\n min,\n max,\n transitionSpeed,\n nullWhenCollapsed,\n status: status === 'expanding' ? 'collapsing' : 'expanding',\n el: ref.current,\n transitionTimingFunction: themeAnimation.timing.ease\n });\n }\n\n return status === 'collapsed' && nullWhenCollapsed && !min ? null : (\n <Tag ref={ref} onTransitionEnd={onTransitionEnd} {...restProps} style={style}>\n {children}\n </Tag>\n );\n }\n);\n\nexport default ExpandCollapse;\n"]}
1
+ {"version":3,"file":"ExpandCollapse.js","sourceRoot":"","sources":["../../../src/components/ExpandCollapse/ExpandCollapse.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,QAAQ,EACR,eAAe,EACf,WAAW,EAEZ,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAwDxE,MAAM,aAAa,GAAG,CACpB,EAAe,EACf,SAAuD,EAC/C,EAAE;IACV,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IACnB,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,IAAI,CAAC;AACjF,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAiB,EAAE;IACvD,MAAM,EACJ,MAAM,EACN,SAAS,EACT,eAAe,EACf,wBAAwB,EACxB,GAAG,EACH,GAAG,EACH,iBAAiB,EACjB,EAAE,EACH,GAAG,KAAK,CAAC;IACV,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,IAAI,EAAE,IAAI,CAAC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e,KAAM,SAAS,EAAE,KAAK,EAAE,KAAK,YACzE,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ReactNode,\n PropsWithoutRef,\n useState,\n useLayoutEffect,\n useCallback,\n CSSProperties\n} from 'react';\n\nimport { ForwardProps, BaseProps, AsProp, PropsWithDefaults } from '../../types';\nimport { useConsolidatedRef, usePrevious, useTheme } from '../../hooks';\n\nexport interface ExpandCollapseProps extends AsProp, BaseProps {\n /** Content to expand/collapse. */\n children?: ReactNode;\n /**\n * If true,the content will be hidden.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Used to determine the transition property.\n * @default 'height'\n */\n dimension?: 'height' | 'width';\n /** Minimum height/width to collapse to. This will set the starting collapsed size as well. */\n min?: string;\n /** Maximum height/width to expand to. Expanded state will expanded up until, but not beyond, the natural height/width of the element. */\n max?: string;\n /** Callback fired after content collapsed. */\n onAfterCollapse?: () => void;\n /** Callback fired after content expanded. */\n onAfterExpand?: () => void;\n /** Callback fired before content collapsed. */\n onBeforeCollapse?: () => void;\n /** Callback fired before content expanded. */\n onBeforeExpand?: () => void;\n /**\n * Determine the speed of animation. This value comes from `theme.base.animation.speed`.\n * @default '0.25s'\n */\n transitionSpeed?: string;\n /**\n * If true, removes the component from the real DOM when collapsed. For full virtual DOM unmount(if necessary), perform at a parent level.\n * @default false\n */\n nullWhenCollapsed?: boolean;\n}\n\ntype ExpandCollapsePropsWithDefaults = PropsWithDefaults<\n ExpandCollapseProps,\n 'collapsed' | 'dimension' | 'transitionSpeed' | 'nullWhenCollapsed'\n>;\n\ntype Statuses = 'collapsed' | 'collapsing' | 'expanded' | 'expanding';\n\ninterface GetStyleProps\n extends Pick<\n ExpandCollapsePropsWithDefaults,\n 'dimension' | 'transitionSpeed' | 'min' | 'max' | 'nullWhenCollapsed'\n > {\n status: Statuses;\n el?: HTMLElement | null;\n transitionTimingFunction?: string;\n}\n\nconst getScrollSize = (\n el: HTMLElement,\n dimension: ExpandCollapsePropsWithDefaults['dimension']\n): string => {\n if (!el) return '';\n return dimension === 'height' ? `${el.scrollHeight}px` : `${el.scrollWidth}px`;\n};\n\nconst getStyle = (props: GetStyleProps): CSSProperties => {\n const {\n status,\n dimension,\n transitionSpeed,\n transitionTimingFunction,\n min,\n max,\n nullWhenCollapsed,\n el\n } = props;\n const style: CSSProperties = {};\n let maxSize = max;\n\n if (el && !max) {\n maxSize = getScrollSize(el, dimension!);\n }\n\n if (status === 'expanded' || status === 'collapsed') {\n if (max || min) {\n style[dimension as 'height' | 'width'] = status === 'expanded' ? maxSize : min || 0;\n style[`overflow${dimension === 'width' ? 'X' : 'Y'}`] = 'hidden';\n }\n\n if (status === 'collapsed' && !nullWhenCollapsed && !min) {\n style.display = 'none';\n }\n }\n\n if (status === 'expanding' || status === 'collapsing') {\n style[dimension as 'height' | 'width'] = status === 'expanding' ? maxSize : min || 0;\n style.overflow = 'hidden';\n style.transitionProperty = dimension;\n style.transitionDuration = `max(${transitionSpeed}, 0.01ms)`;\n style.transitionTimingFunction = transitionTimingFunction;\n }\n\n return style;\n};\n\nconst ExpandCollapse: FunctionComponent<ExpandCollapseProps & ForwardProps> = forwardRef(\n function ExpandCollapse(props: PropsWithoutRef<ExpandCollapseProps>, refArg: Ref<HTMLElement>) {\n const {\n base: { animation: themeAnimation }\n } = useTheme();\n\n const {\n children,\n dimension = 'height',\n collapsed = false,\n onBeforeExpand,\n onAfterExpand,\n onBeforeCollapse,\n onAfterCollapse,\n transitionSpeed = themeAnimation.speed,\n min,\n max,\n nullWhenCollapsed = false,\n as: Tag = 'div',\n ...restProps\n } = props;\n\n const [status, setStatus] = useState<Statuses>(collapsed ? 'collapsed' : 'expanded');\n const styleStateHook = useState<CSSProperties>();\n const setStyle = styleStateHook[1];\n let style = styleStateHook[0];\n const previousStatus = usePrevious(status);\n const ref = useConsolidatedRef(refArg);\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent) => {\n if (e.target !== ref.current || e.propertyName !== dimension) return;\n setStatus(status === 'expanding' ? 'expanded' : 'collapsed');\n },\n [ref.current, status]\n );\n\n useLayoutEffect(() => {\n const wantsToCollapse = collapsed;\n const wantsToExpand = !collapsed;\n const canCollapse = ['expanded', 'expanding'].includes(status);\n const canExpand = ['collapsed', 'collapsing'].includes(status);\n\n if (wantsToExpand && canExpand) {\n onBeforeExpand?.();\n setStatus('expanding');\n } else if (wantsToCollapse && canCollapse) {\n onBeforeCollapse?.();\n setStatus('collapsing');\n }\n\n if (status === 'expanded' && previousStatus !== 'expanded') {\n onAfterExpand?.();\n } else if (status === 'collapsed' && previousStatus !== 'collapsed') {\n onAfterCollapse?.();\n }\n\n setStyle(\n getStyle({\n dimension,\n min,\n max,\n transitionSpeed,\n nullWhenCollapsed,\n status,\n el: ref.current,\n transitionTimingFunction: themeAnimation.timing.ease\n })\n );\n }, [collapsed, status, min, max]);\n\n if (status !== previousStatus && ['expanded', 'collapsed'].includes(previousStatus!)) {\n style = getStyle({\n dimension,\n min,\n max,\n transitionSpeed,\n nullWhenCollapsed,\n status: status === 'expanding' ? 'collapsing' : 'expanding',\n el: ref.current,\n transitionTimingFunction: themeAnimation.timing.ease\n });\n }\n\n return status === 'collapsed' && nullWhenCollapsed && !min ? null : (\n <Tag ref={ref} onTransitionEnd={onTransitionEnd} {...restProps} style={style}>\n {children}\n </Tag>\n );\n }\n);\n\nexport default ExpandCollapse;\n"]}
@@ -81,7 +81,7 @@ StyledFieldGroup.defaultProps = defaultThemeProp;
81
81
  const FieldGroupLegend = ({ children, collapsed, actions, additionalInfo, ...restProps }) => {
82
82
  return (_jsx(StyledFieldGroupLegend, { collapsed: collapsed, ...restProps, children: _jsxs(Flex, { container: { alignItems: 'center', justify: 'between', gap: 0.5 }, children: [_jsxs(Flex, { container: { alignItems: 'center', gap: 0.5 }, children: [children, additionalInfo && (_jsx(AdditionalInfo, { heading: additionalInfo.heading, children: additionalInfo.content }))] }), actions && _jsx(Actions, { items: actions })] }) }));
83
83
  };
84
- const FieldGroup = forwardRef(({ children, description, name, additionalInfo, actions, collapsed, headingTag, onToggleCollapsed, ...restProps }, ref) => {
84
+ const FieldGroup = forwardRef(function FieldGroup({ children, description, name, additionalInfo, actions, collapsed, headingTag, onToggleCollapsed, ...restProps }, ref) {
85
85
  const t = useI18n();
86
86
  const uid = useUID();
87
87
  const descAndChildren = (_jsxs(Grid, { container: { cols: 'minmax(0, 1fr)', gap: 3 }, children: [description && _jsx(HTML, { id: `${uid}-description`, as: 'p', content: description }), _jsx("div", { children: children })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,OAAyB,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAY,SAAS,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,cAAuC,MAAM,mBAAmB,CAAC;AAExE,YAAY,CAAC,cAAc,CAAC,CAAC;AAs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AC,aAAa,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,YAElE,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,EAC/D,WAAW,EAAC,MAAM,aAElB,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,EAC1B,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,YAAG,IAAI,GAAQ,CACzC,CAAC,CAAC,CAAC,CACF,KAAC,oBAAoB,cAAE,IAAI,GAAwB,CACpD,IACI,GACY,CACtB,CAAC,CAAC,CAAC,CACF,4BACG,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,IAAI,IAAC,OAAO,EAAE,UAAU,YAAG,IAAI,GAAQ,CACzC,CAAC,CAAC,CAAC,CACF,KAAC,oBAAoB,cAAE,IAAI,GAAwB,CACpD,GACA,CACJ,GACgB,CACpB,EACA,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAChC,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,YAAG,eAAe,GAAkB,CACzE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Text from '../Text';\nimport Button from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex from '../Flex';\nimport Grid from '../Grid';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, HeadingTag } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize, omitProps } from '../../styles';\nimport AdditionalInfo, { AdditionalInfoProps } from '../AdditionalInfo';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends BaseProps {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /**\n * Controls the collapsed state of the field group.\n * Passing undefined will render the field group as non-collapsible.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Called when user clicks the toggle button.\n */\n onToggleCollapsed?: () => void;\n /** Select the heading tag for header */\n headingTag?: HeadingTag;\n /** The name associated with the Field Group. */\n name?: string;\n /** Provides additional info relevant to the field group. */\n additionalInfo?: {\n heading: AdditionalInfoProps['heading'];\n content: AdditionalInfoProps['children'];\n };\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps extends Pick<FieldGroupProps, 'collapsed'> {\n actions?: ActionsProps['items'];\n children?: ReactNode;\n additionalInfo?: FieldGroupProps['additionalInfo'];\n}\n\nconst StyledExpandButton = styled(Button)(\n ({\n theme: {\n base: { animation }\n }\n }) => {\n const { rtl } = useDirection();\n return css`\n ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n &[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n }\n);\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupName = styled.span``;\n\nexport const StyledFieldGroupLegend = styled.legend.withConfig<Pick<FieldGroupProps, 'collapsed'>>(\n omitProps('collapsed')\n)(\n ({\n collapsed,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => {\n return css`\n width: 100%;\n margin-bottom: 0;\n ${!collapsed &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n > ${StyledExpandButton} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `;\n }\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n\n & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n collapsed,\n actions,\n additionalInfo,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend collapsed={collapsed} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between', gap: 0.5 }}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {children}\n {additionalInfo && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </Flex>\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n (\n {\n children,\n description,\n name,\n additionalInfo,\n actions,\n collapsed,\n headingTag,\n onToggleCollapsed,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) => {\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Grid container={{ cols: 'minmax(0, 1fr)', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Grid>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend collapsed={collapsed} actions={actions} additionalInfo={additionalInfo}>\n {typeof collapsed === 'boolean' ? (\n <StyledExpandButton\n type='button'\n variant='text'\n onClick={() => {\n onToggleCollapsed?.();\n }}\n aria-expanded={collapsed ? 'false' : 'true'}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </Flex>\n </StyledExpandButton>\n ) : (\n <>\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </>\n )}\n </FieldGroupLegend>\n )}\n {typeof collapsed === 'boolean' ? (\n <ExpandCollapse collapsed={collapsed}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
1
+ {"version":3,"file":"FieldGroup.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,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B,CACpB,EACA,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,CAChC,KAAC,cAAc,IAAC,SAAS,EAAE,SAAS,YAAG,eAAe,GAAkB,CACzE,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,IACgB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Text from '../Text';\nimport Button from '../Button';\nimport ExpandCollapse from '../ExpandCollapse';\nimport Flex from '../Flex';\nimport Grid from '../Grid';\nimport HTML from '../HTML';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as caretRightIcon from '../Icon/icons/caret-right.icon';\nimport Actions, { ActionsProps } from '../Actions';\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps, HeadingTag } from '../../types';\nimport { useDirection, useI18n, useUID } from '../../hooks';\nimport { calculateFontSize, FontSize, omitProps } from '../../styles';\nimport AdditionalInfo, { AdditionalInfoProps } from '../AdditionalInfo';\n\nregisterIcon(caretRightIcon);\n\nexport interface FieldGroupProps extends BaseProps {\n /** The content of the Field Group. */\n children: ReactNode;\n /** A description of the field group to be displayed above the controls. */\n description?: string;\n /**\n * Controls the collapsed state of the field group.\n * Passing undefined will render the field group as non-collapsible.\n * @default false\n */\n collapsed?: boolean;\n /**\n * Called when user clicks the toggle button.\n */\n onToggleCollapsed?: () => void;\n /** Select the heading tag for header */\n headingTag?: HeadingTag;\n /** The name associated with the Field Group. */\n name?: string;\n /** Provides additional info relevant to the field group. */\n additionalInfo?: {\n heading: AdditionalInfoProps['heading'];\n content: AdditionalInfoProps['children'];\n };\n /** An array of actions to add to the header. */\n actions?: ActionsProps['items'];\n /** A reference to the wrapping element. */\n ref?: Ref<HTMLFieldSetElement>;\n}\n\ninterface FieldGroupLegendProps extends Pick<FieldGroupProps, 'collapsed'> {\n actions?: ActionsProps['items'];\n children?: ReactNode;\n additionalInfo?: FieldGroupProps['additionalInfo'];\n}\n\nconst StyledExpandButton = styled(Button)(\n ({\n theme: {\n base: { animation }\n }\n }) => {\n const { rtl } = useDirection();\n return css`\n ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n &[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n `;\n }\n);\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroupName = styled.span``;\n\nexport const StyledFieldGroupLegend = styled.legend.withConfig<Pick<FieldGroupProps, 'collapsed'>>(\n omitProps('collapsed')\n)(\n ({\n collapsed,\n theme: {\n base: {\n spacing,\n animation,\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n }\n }\n }) => {\n return css`\n width: 100%;\n margin-bottom: 0;\n ${!collapsed &&\n css`\n margin-block-end: calc(1.5 * ${spacing});\n `}\n transition: margin-block-end ${animation.speed} ${animation.timing.ease};\n\n > ${StyledExpandButton} {\n min-height: ${hitAreaMouse};\n\n @media (pointer: 'coarse') {\n min-height: ${hitAreaFinger};\n }\n }\n `;\n }\n);\n\nStyledFieldGroupLegend.defaultProps = defaultThemeProp;\n\nexport const StyledFieldGroup = styled.fieldset(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale },\n components: { text }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n border: none;\n\n & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n }\n\n & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n }\n\n & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n }\n\n & & & & ${StyledFieldGroupName} {\n font-size: ${fontSizes[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n }\n `;\n }\n);\n\nStyledFieldGroup.defaultProps = defaultThemeProp;\n\nconst FieldGroupLegend: FunctionComponent<FieldGroupLegendProps> = ({\n children,\n collapsed,\n actions,\n additionalInfo,\n ...restProps\n}) => {\n return (\n <StyledFieldGroupLegend collapsed={collapsed} {...restProps}>\n <Flex container={{ alignItems: 'center', justify: 'between', gap: 0.5 }}>\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {children}\n {additionalInfo && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </Flex>\n {actions && <Actions items={actions} />}\n </Flex>\n </StyledFieldGroupLegend>\n );\n};\n\nconst FieldGroup: FunctionComponent<FieldGroupProps & ForwardProps> = forwardRef(\n function FieldGroup(\n {\n children,\n description,\n name,\n additionalInfo,\n actions,\n collapsed,\n headingTag,\n onToggleCollapsed,\n ...restProps\n }: PropsWithoutRef<FieldGroupProps>,\n ref: FieldGroupProps['ref']\n ) {\n const t = useI18n();\n const uid = useUID();\n\n const descAndChildren = (\n <Grid container={{ cols: 'minmax(0, 1fr)', gap: 3 }}>\n {description && <HTML id={`${uid}-description`} as='p' content={description} />}\n <div>{children}</div>\n </Grid>\n );\n\n return (\n <StyledFieldGroup\n aria-label={name}\n aria-describedby={description ? `${uid}-description` : undefined}\n {...restProps}\n ref={ref}\n >\n {name && (\n <FieldGroupLegend collapsed={collapsed} actions={actions} additionalInfo={additionalInfo}>\n {typeof collapsed === 'boolean' ? (\n <StyledExpandButton\n type='button'\n variant='text'\n onClick={() => {\n onToggleCollapsed?.();\n }}\n aria-expanded={collapsed ? 'false' : 'true'}\n aria-label={t(collapsed ? 'expand_noun' : 'collapse_noun', [name])}\n >\n <Flex\n container={{ direction: 'row', alignItems: 'center', gap: 0.5 }}\n forwardedAs='span'\n >\n <Icon name='caret-right' />\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </Flex>\n </StyledExpandButton>\n ) : (\n <>\n {headingTag ? (\n <Text variant={headingTag}>{name}</Text>\n ) : (\n <StyledFieldGroupName>{name}</StyledFieldGroupName>\n )}\n </>\n )}\n </FieldGroupLegend>\n )}\n {typeof collapsed === 'boolean' ? (\n <ExpandCollapse collapsed={collapsed}>{descAndChildren}</ExpandCollapse>\n ) : (\n descAndChildren\n )}\n </StyledFieldGroup>\n );\n }\n);\n\nexport default FieldGroup;\n"]}
@@ -30,7 +30,7 @@ const StyledAddButton = styled(Button)(({ theme }) => css `
30
30
  margin-top: ${theme.base.spacing};
31
31
  `);
32
32
  StyledAddButton.defaultProps = defaultThemeProp;
33
- const FieldGroupList = forwardRef(({ items, onAdd, onDelete, ...restProps }, ref) => {
33
+ const FieldGroupList = forwardRef(function FieldGroupList({ items, onAdd, onDelete, ...restProps }, ref) {
34
34
  const t = useI18n();
35
35
  return (_jsxs(StyledFieldGroupList, { ref: ref, ...restProps, children: [items.map(({ id, children, name, headingTag, onDelete: itemOnDelete, ...restItemProps }) => {
36
36
  return (_jsx(StyledListItem, { name: name, headingTag: headingTag, ...restItemProps, actions: onDelete || itemOnDelete
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAwB,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,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I,EACJ,UAAU,EACV,QAAQ,EAAE,YAAY,EACtB,GAAG,aAAa,EACQ,EAAE,EAAE;gBAC5B,OAAO,CACL,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,KAClB,aAAa,EACjB,OAAO,EACL,QAAQ,IAAI,YAAY;wBACtB,CAAC,CAAC;4BACE;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC;gCACjB,IAAI,EAAE,OAAO;gCACb,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE,GAAG,EAAE;oCACZ,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;oCACnB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;gCACjB,CAAC;6BACF;yBACF;wBACH,CAAC,CAAC,SAAS,YAGd,QAAQ,IArBJ,EAAE,CAsBQ,CAClB,CAAC;YACJ,CAAC,CACF,EACA,KAAK,IAAI,CACR,MAAC,eAAe,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,KAAK,aAC5C,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,OAAE,CAAC,CAAC,KAAK,CAAC,IACd,CACnB,IACoB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nimport FieldGroup, { FieldGroupProps, StyledFieldGroup } from './FieldGroup';\n\nregisterIcon(plusIcon);\n\nexport interface FieldGroupListItemProps extends FieldGroupProps {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n}\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledFieldGroupList = styled.div(\n ({ theme }) =>\n css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledFieldGroup} {\n margin-block-start: 0;\n }\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled(FieldGroup)(\n ({ theme }) =>\n css`\n padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n margin-block-end: calc(2 * ${theme.base.spacing});\n\n legend {\n margin-block-end: 0;\n }\n `\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({ theme }) =>\n css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst FieldGroupList: FunctionComponent<FieldGroupListProps & ForwardProps> = forwardRef(\n (\n { items, onAdd, onDelete, ...restProps }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) => {\n const t = useI18n();\n\n return (\n <StyledFieldGroupList ref={ref} {...restProps}>\n {items.map(\n ({\n id,\n children,\n name,\n headingTag,\n onDelete: itemOnDelete,\n ...restItemProps\n }: FieldGroupListItemProps) => {\n return (\n <StyledListItem\n key={id}\n name={name}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n onDelete || itemOnDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n itemOnDelete?.(id);\n onDelete?.(id);\n }\n }\n ]\n : undefined\n }\n >\n {children}\n </StyledListItem>\n );\n }\n )}\n {onAdd && (\n <StyledAddButton variant='link' onClick={onAdd}>\n <Icon name='plus' /> {t('add')}\n </StyledAddButton>\n )}\n </StyledFieldGroupList>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
1
+ {"version":3,"file":"FieldGroupList.js","s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, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\n\nimport FieldGroup, { FieldGroupProps, StyledFieldGroup } from './FieldGroup';\n\nregisterIcon(plusIcon);\n\nexport interface FieldGroupListItemProps extends FieldGroupProps {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n}\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledFieldGroupList = styled.div(\n ({ theme }) =>\n css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledFieldGroup} {\n margin-block-start: 0;\n }\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled(FieldGroup)(\n ({ theme }) =>\n css`\n padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n margin-block-end: calc(2 * ${theme.base.spacing});\n\n legend {\n margin-block-end: 0;\n }\n `\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({ theme }) =>\n css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst FieldGroupList: FunctionComponent<FieldGroupListProps & ForwardProps> = forwardRef(\n function FieldGroupList(\n { items, onAdd, onDelete, ...restProps }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) {\n const t = useI18n();\n\n return (\n <StyledFieldGroupList ref={ref} {...restProps}>\n {items.map(\n ({\n id,\n children,\n name,\n headingTag,\n onDelete: itemOnDelete,\n ...restItemProps\n }: FieldGroupListItemProps) => {\n return (\n <StyledListItem\n key={id}\n name={name}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n onDelete || itemOnDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n itemOnDelete?.(id);\n onDelete?.(id);\n }\n }\n ]\n : undefined\n }\n >\n {children}\n </StyledListItem>\n );\n }\n )}\n {onAdd && (\n <StyledAddButton variant='link' onClick={onAdd}>\n <Icon name='plus' /> {t('add')}\n </StyledAddButton>\n )}\n </StyledFieldGroupList>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
@@ -47,7 +47,7 @@ export const FieldValueItem = withTestIds(({ testId, name, value, variant = 'inl
47
47
  const labelAndValue = (_jsxs(_Fragment, { children: [_jsx(StyledLabel, { "data-testid": testIds.name, as: StyledFieldName, children: name }), _jsx(StyledFieldValue, { "data-testid": testIds.value, children: value ? displayValue : _jsx(NoValue, {}) })] }));
48
48
  return variant === 'stacked' ? (_jsx(StyledStackedFieldValue, { "data-testid": testIds.root, children: labelAndValue })) : (_jsx(_Fragment, { children: labelAndValue }));
49
49
  }, getFieldValueItemTestIds);
50
- const FieldValueList = forwardRef(({ testId, fields, variant = 'inline', ...restProps }, ref) => {
50
+ const FieldValueList = forwardRef(function FieldValueList({ testId, fields, variant = 'inline', ...restProps }, ref) {
51
51
  const testIds = useTestIds(testId, getFieldValueListTestIds);
52
52
  const fieldValueListRef = useConsolidatedRef(ref);
53
53
  const isXSContentWidthOrAbove = useBreakpoint('xs', {
@@ -1 +1 @@
1
- {"version":3,"file":"FieldValueList.js","sourceRoot":"","sources":["../../../src/components/FieldValueList/FieldValueList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqC,UAAU,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,UA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gB;YACtB,MAAM,EAAE,OAAO,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,EAAE,OAAO,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;SACjD,EACD,EAAE,EAAE,oBAAoB,EACxB,OAAO,EAAE,OAAO,YAEf,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YACzD,OAAO,CACL,KAAC,cAAc,IACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,EACL,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,uBAAuB;oBACjE,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,QAAQ,IAET,EAAE,IAAI,IAAI,CACf,CACH,CAAC;QACJ,CAAC,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { ReactNode, FunctionComponent, Ref, forwardRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport Grid from '../Grid';\nimport { StyledLabel } from '../Label';\nimport { useBreakpoint, useConsolidatedRef, useTestIds } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport ShowMoreLess from '../ShowMoreLess';\nimport { withTestIds } from '../../utils';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFieldValueListTestIds, getFieldValueItemTestIds } from './FieldValueList.test-ids';\n\nexport type FieldValueVariant = 'inline' | 'stacked';\n\nexport interface FieldValueListItemProps extends TestIdProp {\n name: string;\n value?: ReactNode;\n variant?: FieldValueVariant;\n}\n\nexport interface FieldValueListItem extends FieldValueListItemProps {\n id?: string;\n}\n\nexport interface FieldValueListProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The set of field values to render in the list. */\n fields: FieldValueListItem[];\n /**\n * Determines if the field and values should be displayed on the same line, or stacked with the field above the value.\n * @default 'inline'\n */\n variant?: FieldValueVariant | 'value-comparison';\n}\n\nexport const StyledFieldName = styled.dt`\n word-break: break-word;\n`;\n\nexport const StyledFieldValue = styled.dd`\n word-break: break-word;\n`;\n\nexport type StyledFieldValueListProps = Pick<FieldValueListProps, 'variant'>;\n\nexport const StyledFieldValueList = styled.dl<StyledFieldValueListProps>(({ variant, theme }) => {\n return css`\n width: 100%;\n\n ${variant === 'value-comparison' &&\n css`\n dt {\n width: 100%;\n }\n dd {\n text-align: end;\n padding-inline-start: calc(2 * ${theme.base.spacing});\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n `;\n});\n\nStyledFieldValueList.defaultProps = defaultThemeProp;\n\nexport const StyledStackedFieldValue = styled.div``;\n\nexport const FieldValueItem = withTestIds(\n ({ testId, name, value, variant = 'inline' }: FieldValueListItemProps) => {\n const testIds = useTestIds(testId, getFieldValueItemTestIds);\n\n const displayValue =\n typeof value === 'string' ? <ShowMoreLess lines={3}>{value}</ShowMoreLess> : value;\n\n const labelAndValue = (\n <>\n <StyledLabel data-testid={testIds.name} as={StyledFieldName}>\n {name}\n </StyledLabel>\n <StyledFieldValue data-testid={testIds.value}>\n {value ? displayValue : <NoValue />}\n </StyledFieldValue>\n </>\n );\n\n return variant === 'stacked' ? (\n <StyledStackedFieldValue data-testid={testIds.root}>{labelAndValue}</StyledStackedFieldValue>\n ) : (\n <>{labelAndValue}</>\n );\n },\n getFieldValueItemTestIds\n);\n\nconst FieldValueList: FunctionComponent<FieldValueListProps & ForwardProps> = forwardRef(\n (\n { testId, fields, variant = 'inline', ...restProps }: FieldValueListProps,\n ref: Ref<HTMLDivElement>\n ) => {\n const testIds = useTestIds(testId, getFieldValueListTestIds);\n\n const fieldValueListRef = useConsolidatedRef<HTMLDivElement>(ref);\n\n const isXSContentWidthOrAbove = useBreakpoint('xs', {\n breakpointRef: fieldValueListRef,\n themeProp: 'content-width'\n });\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n ref={fieldValueListRef}\n container={{\n cols:\n ['inline', 'value-comparison'].includes(variant) && isXSContentWidthOrAbove\n ? '16ch minmax(0, 1fr)'\n : 'minmax(0, 1fr)',\n colGap: variant !== 'value-comparison' ? 2 : 0,\n rowGap: variant !== 'value-comparison' ? 1 : 0.5\n }}\n as={StyledFieldValueList}\n variant={variant}\n >\n {fields.map(({ id, name, value, variant: fieldVariant }) => {\n return (\n <FieldValueItem\n name={name}\n value={value}\n variant={\n (fieldVariant ?? variant) === 'stacked' || !isXSContentWidthOrAbove\n ? 'stacked'\n : 'inline'\n }\n key={id ?? name}\n />\n );\n })}\n </Grid>\n );\n }\n);\n\nexport default withTestIds(FieldValueList, getFieldValueListTestIds);\n"]}
1
+ {"version":3,"file":"FieldValueList.js","sourceRoot":"","sources":["../../../src/components/FieldValueList/FieldValueList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqC,UAAU,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,wBAAw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IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YACzD,OAAO,CACL,KAAC,cAAc,IACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,EACL,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,uBAAuB;oBACjE,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,QAAQ,IAET,EAAE,IAAI,IAAI,CACf,CACH,CAAC;QACJ,CAAC,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { ReactNode, FunctionComponent, Ref, forwardRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport Grid from '../Grid';\nimport { StyledLabel } from '../Label';\nimport { useBreakpoint, useConsolidatedRef, useTestIds } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport ShowMoreLess from '../ShowMoreLess';\nimport { withTestIds } from '../../utils';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFieldValueListTestIds, getFieldValueItemTestIds } from './FieldValueList.test-ids';\n\nexport type FieldValueVariant = 'inline' | 'stacked';\n\nexport interface FieldValueListItemProps extends TestIdProp {\n name: string;\n value?: ReactNode;\n variant?: FieldValueVariant;\n}\n\nexport interface FieldValueListItem extends FieldValueListItemProps {\n id?: string;\n}\n\nexport interface FieldValueListProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The set of field values to render in the list. */\n fields: FieldValueListItem[];\n /**\n * Determines if the field and values should be displayed on the same line, or stacked with the field above the value.\n * @default 'inline'\n */\n variant?: FieldValueVariant | 'value-comparison';\n}\n\nexport const StyledFieldName = styled.dt`\n word-break: break-word;\n`;\n\nexport const StyledFieldValue = styled.dd`\n word-break: break-word;\n`;\n\nexport type StyledFieldValueListProps = Pick<FieldValueListProps, 'variant'>;\n\nexport const StyledFieldValueList = styled.dl<StyledFieldValueListProps>(({ variant, theme }) => {\n return css`\n width: 100%;\n\n ${variant === 'value-comparison' &&\n css`\n dt {\n width: 100%;\n }\n dd {\n text-align: end;\n padding-inline-start: calc(2 * ${theme.base.spacing});\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n `;\n});\n\nStyledFieldValueList.defaultProps = defaultThemeProp;\n\nexport const StyledStackedFieldValue = styled.div``;\n\nexport const FieldValueItem = withTestIds(\n ({ testId, name, value, variant = 'inline' }: FieldValueListItemProps) => {\n const testIds = useTestIds(testId, getFieldValueItemTestIds);\n\n const displayValue =\n typeof value === 'string' ? <ShowMoreLess lines={3}>{value}</ShowMoreLess> : value;\n\n const labelAndValue = (\n <>\n <StyledLabel data-testid={testIds.name} as={StyledFieldName}>\n {name}\n </StyledLabel>\n <StyledFieldValue data-testid={testIds.value}>\n {value ? displayValue : <NoValue />}\n </StyledFieldValue>\n </>\n );\n\n return variant === 'stacked' ? (\n <StyledStackedFieldValue data-testid={testIds.root}>{labelAndValue}</StyledStackedFieldValue>\n ) : (\n <>{labelAndValue}</>\n );\n },\n getFieldValueItemTestIds\n);\n\nconst FieldValueList: FunctionComponent<FieldValueListProps & ForwardProps> = forwardRef(\n function FieldValueList(\n { testId, fields, variant = 'inline', ...restProps }: FieldValueListProps,\n ref: Ref<HTMLDivElement>\n ) {\n const testIds = useTestIds(testId, getFieldValueListTestIds);\n\n const fieldValueListRef = useConsolidatedRef<HTMLDivElement>(ref);\n\n const isXSContentWidthOrAbove = useBreakpoint('xs', {\n breakpointRef: fieldValueListRef,\n themeProp: 'content-width'\n });\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n ref={fieldValueListRef}\n container={{\n cols:\n ['inline', 'value-comparison'].includes(variant) && isXSContentWidthOrAbove\n ? '16ch minmax(0, 1fr)'\n : 'minmax(0, 1fr)',\n colGap: variant !== 'value-comparison' ? 2 : 0,\n rowGap: variant !== 'value-comparison' ? 1 : 0.5\n }}\n as={StyledFieldValueList}\n variant={variant}\n >\n {fields.map(({ id, name, value, variant: fieldVariant }) => {\n return (\n <FieldValueItem\n name={name}\n value={value}\n variant={\n (fieldVariant ?? variant) === 'stacked' || !isXSContentWidthOrAbove\n ? 'stacked'\n : 'inline'\n }\n key={id ?? name}\n />\n );\n })}\n </Grid>\n );\n }\n);\n\nexport default withTestIds(FieldValueList, getFieldValueListTestIds);\n"]}
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
3
3
  import Link from '../Link';
4
4
  import NoValue from '../NoValue/NoValue';
5
5
  import FileItem from './FileItem';
6
- const FileDisplay = forwardRef(({ displayText, value, variant, thumbnail, onPreview, onDownload, ...restProps }, ref) => {
6
+ const FileDisplay = forwardRef(function FileDisplay({ displayText, value, variant, thumbnail, onPreview, onDownload, ...restProps }, ref) {
7
7
  if (variant === 'text' || !value) {
8
8
  return (_jsx("span", { ref: ref, ...restProps, children: value ? displayText || value : _jsx(NoValue, {}) }));
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FileDisplay.js","sourceRoot":"","sources":["../../../src/components/File/FileDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAG5E,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,QAA2B,MAAM,YAAY,CAAC;AAqBrD,MAAM,WAAW,GAAuD,UAAU,CAChF,CACE,EACE,WAAW,EACX,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,GAAG,SAAS,EACsB,EACpC,GAA4B,EAC5B,EAAE;IACF,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,KAAK,EAAE;QAChC,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,CAAC,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,KAAC,OAAO,KAAG,GACtC,CACR,CAAC;KACH;IAED,IAAI,OAAO,KAAK,MAAM;QACpB,OAAO,CACL,KAAC,IAAI,IAAC,GAAG,EAAE,GAA6B,KAAM,SAAS,EAAE,IAAI,EAAE,KAAK,YACjE,WAAW,IAAI,KAAK,GAChB,CACR,CAAC;IAEJ,OAAO,CACL,KAAC,QAAQ,OACH,SAAS,EACb,GAAG,EAAE,GAA6B,EAClC,IAAI,EAAE,WAAW,IAAI,KAAK,EAC1B,GAAG,EAAE,KAAK,KACN;YACF,SAAS;YACT,UAAU;YACV,SAAS;SACV,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport Link from '../Link';\nimport NoValue from '../NoValue/NoValue';\n\nimport FileItem, { FileItemProps } from './FileItem';\n\nexport interface FileDisplayProps\n extends Pick<FileItemProps, 'onPreview' | 'onDownload'>,\n BaseProps,\n NoChildrenProp {\n /** URL address */\n value?: string;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Display value either as file, link only or textual representation.\n * @default 'file'\n */\n variant?: 'file' | 'link' | 'text';\n /** Thumbnail image. */\n thumbnail?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement | HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst FileDisplay: FunctionComponent<FileDisplayProps & ForwardProps> = forwardRef(\n (\n {\n displayText,\n value,\n variant,\n thumbnail,\n onPreview,\n onDownload,\n ...restProps\n }: PropsWithoutRef<FileDisplayProps>,\n ref: FileDisplayProps['ref']\n ) => {\n if (variant === 'text' || !value) {\n return (\n <span ref={ref} {...restProps}>\n {value ? displayText || value : <NoValue />}\n </span>\n );\n }\n\n if (variant === 'link')\n return (\n <Link ref={ref as Ref<HTMLAnchorElement>} {...restProps} href={value}>\n {displayText || value}\n </Link>\n );\n\n return (\n <FileItem\n {...restProps}\n ref={ref as Ref<HTMLButtonElement>}\n name={displayText || value}\n url={value}\n {...{\n thumbnail,\n onDownload,\n onPreview\n }}\n />\n );\n }\n);\n\nexport default FileDisplay;\n"]}
1
+ {"version":3,"file":"FileDisplay.js","sourceRoot":"","sources":["../../../src/components/File/FileDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAG5E,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,QAA2B,MAAM,YAAY,CAAC;AAqBrD,MAAM,WAAW,GAAuD,UAAU,CAChF,SAAS,WAAW,CAClB,EACE,WAAW,EACX,KAAK,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,GAAG,SAAS,EACsB,EACpC,GAA4B;IAE5B,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,KAAK,EAAE;QAChC,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,CAAC,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,KAAC,OAAO,KAAG,GACtC,CACR,CAAC;KACH;IAED,IAAI,OAAO,KAAK,MAAM;QACpB,OAAO,CACL,KAAC,IAAI,IAAC,GAAG,EAAE,GAA6B,KAAM,SAAS,EAAE,IAAI,EAAE,KAAK,YACjE,WAAW,IAAI,KAAK,GAChB,CACR,CAAC;IAEJ,OAAO,CACL,KAAC,QAAQ,OACH,SAAS,EACb,GAAG,EAAE,GAA6B,EAClC,IAAI,EAAE,WAAW,IAAI,KAAK,EAC1B,GAAG,EAAE,KAAK,KACN;YACF,SAAS;YACT,UAAU;YACV,SAAS;SACV,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport Link from '../Link';\nimport NoValue from '../NoValue/NoValue';\n\nimport FileItem, { FileItemProps } from './FileItem';\n\nexport interface FileDisplayProps\n extends Pick<FileItemProps, 'onPreview' | 'onDownload'>,\n BaseProps,\n NoChildrenProp {\n /** URL address */\n value?: string;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Display value either as file, link only or textual representation.\n * @default 'file'\n */\n variant?: 'file' | 'link' | 'text';\n /** Thumbnail image. */\n thumbnail?: string;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement | HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst FileDisplay: FunctionComponent<FileDisplayProps & ForwardProps> = forwardRef(\n function FileDisplay(\n {\n displayText,\n value,\n variant,\n thumbnail,\n onPreview,\n onDownload,\n ...restProps\n }: PropsWithoutRef<FileDisplayProps>,\n ref: FileDisplayProps['ref']\n ) {\n if (variant === 'text' || !value) {\n return (\n <span ref={ref} {...restProps}>\n {value ? displayText || value : <NoValue />}\n </span>\n );\n }\n\n if (variant === 'link')\n return (\n <Link ref={ref as Ref<HTMLAnchorElement>} {...restProps} href={value}>\n {displayText || value}\n </Link>\n );\n\n return (\n <FileItem\n {...restProps}\n ref={ref as Ref<HTMLButtonElement>}\n name={displayText || value}\n url={value}\n {...{\n thumbnail,\n onDownload,\n onPreview\n }}\n />\n );\n }\n);\n\nexport default FileDisplay;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,GAAG,EAOJ,MAAM,OAAO,CAAC;AAIf,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EAEd,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAoB,EAAE,gBAAgB,EAAE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2D"}
@@ -52,7 +52,7 @@ const StyledInteractiveText = styled.span(({ theme }) => {
52
52
  `;
53
53
  });
54
54
  StyledInteractiveText.defaultProps = defaultThemeProp;
55
- const FileInput = forwardRef((props, ref) => {
55
+ const FileInput = forwardRef(function FileInput(props, ref) {
56
56
  const uid = useUID();
57
57
  const { testId, id = uid, label, labelHidden, info, required = false, disabled = false, files, onFilesAdded, multiple = false, status, ...restProps } = props;
58
58
  const testIds = useTestIds(testId, getFileInputTestIds);
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,WAAW,EAGX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,WAAiC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,cAAuC,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,YAAY,CAAC,aAAa,CAAC,CAAC;AAuC5B,MAAM,CAAC,MAAM,cAAc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AAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oBACzB,MAAM,GAAG,GACP,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBAEjF,4IAA4I;oBAC5I,OAAO,KAAC,cAAc,OAAe,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAA9B,GAAG,CAA+B,CAAC;gBACjE,CAAC,CAAC,GACG,CACR,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ChangeEvent,\n useCallback,\n PropsWithoutRef,\n DragEvent,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport { useConsolidatedRef, useI18n, useUID, useDirection, useTestIds } from '../../hooks';\nimport FormControl, { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport FormField from '../FormField';\nimport Grid from '../Grid';\nimport { withTestIds } from '../../utils';\n\nimport FileUploadItem, { FileUploadItemProps } from './FileUploadItem';\nimport { getFileInputTestIds } from './File.test-ids';\n\nregisterIcon(paperClipIcon);\n\ntype FileInputPropsWithDefaults = PropsWithDefaults<FileInputProps>;\n\nexport interface FileInputProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /** An array of files that have been uploaded. */\n files?: FileUploadItemProps[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledDropZone = styled(FormControl)<{ dragOver: boolean }>(({ dragOver, theme }) => {\n return css`\n padding: calc(2 * ${theme.base.spacing});\n min-height: 4rem;\n border-style: dashed;\n cursor: pointer;\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n `;\n});\n\nexport const StyledFileInput = styled.div<FileInputPropsWithDefaults & ForwardProps>(\n ({ theme }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n }\n\n input[hidden] + ${StyledDropZone} {\n display: none;\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nconst StyledInteractiveText = styled.span(({ theme }) => {\n return css`\n color: ${theme.base.palette.interactive};\n `;\n});\n\nStyledInteractiveText.defaultProps = defaultThemeProp;\n\nconst FileInput: FunctionComponent<FileInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FileInputProps>, ref: FileInputProps['ref']) => {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n files,\n onFilesAdded,\n multiple = false,\n status,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n\n const icon = <Icon name='paper-clip' />;\n const inputRef = useConsolidatedRef(ref);\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const { ltr, rtl } = useDirection();\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n id={id}\n disabled={disabled}\n onChange={onChange}\n multiple={multiple}\n />\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n item={{ grow: 1 }}\n as={StyledDropZone}\n dragOver={dragOver}\n onClick={() => {\n inputRef.current?.focus();\n inputRef.current?.click();\n }}\n onDragOver={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n }}\n onDragEnter={() => setDragOver(true)}\n onDragLeave={() => setDragOver(false)}\n onDrop={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n }}\n >\n {ltr && icon}\n <Text variant='primary'>\n &nbsp;\n {t('file_upload_text_main', [\n <StyledInteractiveText>\n {t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')}\n </StyledInteractiveText>\n ])}\n &nbsp;\n </Text>\n {rtl && icon}\n </Flex>\n </StyledFileInput>\n );\n\n return (\n <Grid container={{ rowGap: 1 }}>\n {label ? (\n <FormField\n {...{\n testId: testIds,\n label,\n labelHidden,\n id,\n info,\n required,\n disabled,\n status\n }}\n >\n {fileInput}\n </FormField>\n ) : (\n fileInput\n )}\n {!!files?.length && (\n <Grid\n data-testid={testIds.files}\n container={{\n gap: 1,\n cols: 'repeat(2, minmax(0, 1fr))'\n }}\n as='ul'\n >\n {files.map((file, index) => {\n const key =\n file.id ?? (file.File ? `${file.File.name}_${file.File.lastModified}` : index);\n\n // When files is an array of native File objects, all properties (including name) are on the prototype, so spreading will not set any props.\n return <FileUploadItem key={key} {...file} name={file.name} />;\n })}\n </Grid>\n )}\n </Grid>\n );\n }\n);\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
1
+ {"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../../src/components/File/FileInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,WAAW,EAGX,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AASxC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,WAAiC,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B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,CACF,SAAS,CACV,EACA,CAAC,CAAC,KAAK,EAAE,MAAM,IAAI,CAClB,KAAC,IAAI,mBACU,OAAO,CAAC,KAAK,EAC1B,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,IAAI,EAAE,2BAA2B;iBAClC,EACD,EAAE,EAAC,IAAI,YAEN,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oBACzB,MAAM,GAAG,GACP,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBAEjF,4IAA4I;oBAC5I,OAAO,KAAC,cAAc,OAAe,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAA9B,GAAG,CAA+B,CAAC;gBACjE,CAAC,CAAC,GACG,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import {\n FunctionComponent,\n Ref,\n forwardRef,\n ChangeEvent,\n useCallback,\n PropsWithoutRef,\n DragEvent,\n useState\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport {\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n PropsWithDefaults,\n TestIdProp\n} from '../../types';\nimport { useConsolidatedRef, useI18n, useUID, useDirection, useTestIds } from '../../hooks';\nimport FormControl, { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Icon, { registerIcon } from '../Icon';\nimport * as paperClipIcon from '../Icon/icons/paper-clip.icon';\nimport FormField from '../FormField';\nimport Grid from '../Grid';\nimport { withTestIds } from '../../utils';\n\nimport FileUploadItem, { FileUploadItemProps } from './FileUploadItem';\nimport { getFileInputTestIds } from './File.test-ids';\n\nregisterIcon(paperClipIcon);\n\ntype FileInputPropsWithDefaults = PropsWithDefaults<FileInputProps>;\n\nexport interface FileInputProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** Called when files are added either via the input or drop zone. */\n onFilesAdded?: (files: File[]) => void;\n /**\n * Allow multiple files to be selected from the OS specific file browser.\n * NOTE: This does not restrict multiple files from being added via drag and drop.\n * Restrict multi file drag and drop via onFilesAdded and custom info message.\n * @default false\n */\n multiple?: boolean;\n /** An array of files that have been uploaded. */\n files?: FileUploadItemProps[];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Ref for the input element within the component's dom structure. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledDropZone = styled(FormControl)<{ dragOver: boolean }>(({ dragOver, theme }) => {\n return css`\n padding: calc(2 * ${theme.base.spacing});\n min-height: 4rem;\n border-style: dashed;\n cursor: pointer;\n\n ${dragOver &&\n css`\n border-style: solid;\n `}\n `;\n});\n\nexport const StyledFileInput = styled.div<FileInputPropsWithDefaults & ForwardProps>(\n ({ theme }) => {\n return css`\n position: relative;\n\n input {\n ${hideVisually}\n }\n\n input:enabled:focus + ${StyledDropZone} {\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n }\n\n input[hidden] + ${StyledDropZone} {\n display: none;\n }\n `;\n }\n);\n\nStyledFileInput.defaultProps = defaultThemeProp;\n\nconst StyledInteractiveText = styled.span(({ theme }) => {\n return css`\n color: ${theme.base.palette.interactive};\n `;\n});\n\nStyledInteractiveText.defaultProps = defaultThemeProp;\n\nconst FileInput: FunctionComponent<FileInputProps & ForwardProps> = forwardRef(function FileInput(\n props: PropsWithoutRef<FileInputProps>,\n ref: FileInputProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n label,\n labelHidden,\n info,\n required = false,\n disabled = false,\n files,\n onFilesAdded,\n multiple = false,\n status,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFileInputTestIds);\n\n const icon = <Icon name='paper-clip' />;\n const inputRef = useConsolidatedRef(ref);\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n onFilesAdded?.(Array.from(e.target.files));\n }\n /**\n * WHY are we doing this?\n * We are not working with the \"value\" prop of the input but rather the File instances that are created.\n * The consumer of this component should manage an array or File(s) and allow for a user to remove a selected file.\n * Since we can not modify the input value of files for browser security reasons,\n * and since setting the files property is less than ideal, we reset/toggle the input to a fresh state after a render.\n * This enables onChange to fire even if the user had just previously selected a file, removed it, and selected it again.\n */\n if (inputRef.current) inputRef.current.value = '';\n },\n [onFilesAdded]\n );\n\n const t = useI18n();\n const [dragOver, setDragOver] = useState(false);\n const { ltr, rtl } = useDirection();\n\n const fileInput = (\n <StyledFileInput>\n <input\n data-testid={testIds.control}\n {...restProps}\n ref={inputRef}\n type='file'\n id={id}\n disabled={disabled}\n onChange={onChange}\n multiple={multiple}\n />\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n item={{ grow: 1 }}\n as={StyledDropZone}\n dragOver={dragOver}\n onClick={() => {\n inputRef.current?.focus();\n inputRef.current?.click();\n }}\n onDragOver={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n }}\n onDragEnter={() => setDragOver(true)}\n onDragLeave={() => setDragOver(false)}\n onDrop={(e: DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n onFilesAdded?.(Array.from(e.dataTransfer.files));\n }}\n >\n {ltr && icon}\n <Text variant='primary'>\n &nbsp;\n {t('file_upload_text_main', [\n <StyledInteractiveText>\n {t(multiple ? 'file_upload_text_multiple' : 'file_upload_text_one')}\n </StyledInteractiveText>\n ])}\n &nbsp;\n </Text>\n {rtl && icon}\n </Flex>\n </StyledFileInput>\n );\n\n return (\n <Grid container={{ rowGap: 1 }}>\n {label ? (\n <FormField\n {...{\n testId: testIds,\n label,\n labelHidden,\n id,\n info,\n required,\n disabled,\n status\n }}\n >\n {fileInput}\n </FormField>\n ) : (\n fileInput\n )}\n {!!files?.length && (\n <Grid\n data-testid={testIds.files}\n container={{\n gap: 1,\n cols: 'repeat(2, minmax(0, 1fr))'\n }}\n as='ul'\n >\n {files.map((file, index) => {\n const key =\n file.id ?? (file.File ? `${file.File.name}_${file.File.lastModified}` : index);\n\n // When files is an array of native File objects, all properties (including name) are on the prototype, so spreading will not set any props.\n return <FileUploadItem key={key} {...file} name={file.name} />;\n })}\n </Grid>\n )}\n </Grid>\n );\n});\n\nexport default withTestIds(FileInput, getFileInputTestIds);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAyB,MAAM,OAAO,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOtD,OAAmB,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAE7E,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,oIAAoI;IACpI,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACzC,wGAAwG;IACxG,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAChD,8FAA8F;IAC9F,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IACjD,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B;AAmCD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CAsC9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAyB,MAAM,OAAO,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOtD,OAAmB,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAE7E,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,oIAAoI;IACpI,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACzC,wGAAwG;IACxG,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAChD,8FAA8F;IAC9F,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IACjD,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC9B;AAmCD,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CAuC7C,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -38,7 +38,7 @@ const StyledFileItem = styled.div(({ theme: { base, components } }) => {
38
38
  `;
39
39
  });
40
40
  StyledFileItem.defaultProps = defaultThemeProp;
41
- const FileItem = forwardRef((props, ref) => {
41
+ const FileItem = forwardRef(function FileItem(props, ref) {
42
42
  const { name, url, thumbnail, onPreview, onDownload, ...restProps } = props;
43
43
  const [thumbnailError, setThumbnailError] = useState(false);
44
44
  const t = useI18n();
@@ -1 +1 @@
1
- {"version":3,"file":"FileItem.js","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA4B,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,UAAU,EAAE,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAiB7E,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE;IACpE,OAAO,GAAG,CAAA;gCACoB,IAAI,CAAC,eAAe,CAAC;;QAE7C,gBAAgB;;;;;gBAKR,UAAU,CAAC,KAAK,CAAC,MAAM;eACxB,UAAU,CAAC,KAAK,CAAC,MAAM;;;QAG9B,gBAAgB,MAAM,gBAAgB;;gCAEd,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;0BACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;;mBAEzC,IAAI,CAAC,OAAO;;;;;;;;;;GAU5B,CAAC;AACJ,CA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U,EACrB,OAAO,EAAE,eAAe,gBACZ,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,YAEtC,IAAI,GACE,IACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, useCallback, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps, BaseProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Button, { StyledButtonLink } from '../Button';\nimport Grid from '../Grid';\nimport { useI18n } from '../../hooks';\n\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\nimport FileVisual, { FileVisualProps, StyledFileVisual } from './FileVisual';\n\nexport interface FileItemProps extends BaseProps {\n /** Name of the file. */\n name: string;\n /** Url of the file. */\n url: string;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: FileVisualProps['thumbnail'];\n /** When passed, it will make the icon/thumbnail region actionable. Passes file url as the parameter. */\n onPreview?: (url: FileItemProps['url']) => void;\n /** When passed, it will make the name region actionable. Passes file url as the parameter. */\n onDownload?: (url: FileItemProps['url']) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\nconst StyledFileItem = styled.div(({ theme: { base, components } }) => {\n return css`\n border-radius: calc(0.5 * ${base['border-radius']});\n\n > ${StyledFileVisual} {\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n height: ${components.input.height};\n width: ${components.input.height};\n }\n\n > ${StyledFileVisual} + ${StyledButtonLink} {\n margin-inline-start: 0;\n border: 0.0625rem solid ${base.palette['border-line']};\n background-color: ${base.palette['primary-background']};\n opacity: 1;\n padding: 0 ${base.spacing};\n border-inline-start: 0;\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n border-start-end-radius: inherit;\n border-end-end-radius: inherit;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n `;\n});\n\nStyledFileItem.defaultProps = defaultThemeProp;\n\nconst FileItem: FC<FileItemProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FileItemProps>, ref: FileItemProps['ref']) => {\n const { name, url, thumbnail, onPreview, onDownload, ...restProps } = props;\n\n const [thumbnailError, setThumbnailError] = useState(false);\n const t = useI18n();\n\n const onDownloadClick = useCallback(() => {\n onDownload?.(url);\n }, [url, onDownload]);\n\n const type = getMimeTypeFromFile(url);\n const text = name || url;\n\n return (\n <Grid as={StyledFileItem} container={{ cols: 'auto 1fr' }} ref={ref}>\n <FileVisual\n type={getKindFromMimeType(type ?? '')}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n disabled={!onPreview}\n onClick={() => onPreview?.(url)}\n aria-label={`${t('preview')}: ${text}`}\n />\n <Button\n {...restProps}\n variant='text'\n disabled={!onDownload}\n onClick={onDownloadClick}\n aria-label={`${t('download')}: ${text}`}\n >\n {text}\n </Button>\n </Grid>\n );\n }\n);\n\nexport default FileItem;\n"]}
1
+ {"version":3,"file":"FileItem.js","sourceRoot":"","sources":["../../../src/components/File/FileItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA4B,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,UAAU,EAAE,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAiB7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U,IACT,IAAI,EAAE,mBAAmB,CAAC,IAAI,IAAI,EAAE,CAAC,EACrC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EACjD,gBAAgB,EAAE,GAAG,EAAE;oBACrB,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAC1B,CAAC,EACD,QAAQ,EAAE,CAAC,SAAS,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,gBACnB,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,GACtC,EACF,KAAC,MAAM,OACD,SAAS,EACb,OAAO,EAAC,MAAM,EACd,QAAQ,EAAE,CAAC,UAAU,EACrB,OAAO,EAAE,eAAe,gBACZ,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,YAEtC,IAAI,GACE,IACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, useCallback, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { ForwardProps, BaseProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Button, { StyledButtonLink } from '../Button';\nimport Grid from '../Grid';\nimport { useI18n } from '../../hooks';\n\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\nimport FileVisual, { FileVisualProps, StyledFileVisual } from './FileVisual';\n\nexport interface FileItemProps extends BaseProps {\n /** Name of the file. */\n name: string;\n /** Url of the file. */\n url: string;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: FileVisualProps['thumbnail'];\n /** When passed, it will make the icon/thumbnail region actionable. Passes file url as the parameter. */\n onPreview?: (url: FileItemProps['url']) => void;\n /** When passed, it will make the name region actionable. Passes file url as the parameter. */\n onDownload?: (url: FileItemProps['url']) => void;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\nconst StyledFileItem = styled.div(({ theme: { base, components } }) => {\n return css`\n border-radius: calc(0.5 * ${base['border-radius']});\n\n > ${StyledFileVisual} {\n border-start-start-radius: inherit;\n border-end-start-radius: inherit;\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n height: ${components.input.height};\n width: ${components.input.height};\n }\n\n > ${StyledFileVisual} + ${StyledButtonLink} {\n margin-inline-start: 0;\n border: 0.0625rem solid ${base.palette['border-line']};\n background-color: ${base.palette['primary-background']};\n opacity: 1;\n padding: 0 ${base.spacing};\n border-inline-start: 0;\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n border-start-end-radius: inherit;\n border-end-end-radius: inherit;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n `;\n});\n\nStyledFileItem.defaultProps = defaultThemeProp;\n\nconst FileItem: FC<FileItemProps & ForwardProps> = forwardRef(function FileItem(\n props: PropsWithoutRef<FileItemProps>,\n ref: FileItemProps['ref']\n) {\n const { name, url, thumbnail, onPreview, onDownload, ...restProps } = props;\n\n const [thumbnailError, setThumbnailError] = useState(false);\n const t = useI18n();\n\n const onDownloadClick = useCallback(() => {\n onDownload?.(url);\n }, [url, onDownload]);\n\n const type = getMimeTypeFromFile(url);\n const text = name || url;\n\n return (\n <Grid as={StyledFileItem} container={{ cols: 'auto 1fr' }} ref={ref}>\n <FileVisual\n type={getKindFromMimeType(type ?? '')}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n disabled={!onPreview}\n onClick={() => onPreview?.(url)}\n aria-label={`${t('preview')}: ${text}`}\n />\n <Button\n {...restProps}\n variant='text'\n disabled={!onDownload}\n onClick={onDownloadClick}\n aria-label={`${t('download')}: ${text}`}\n >\n {text}\n </Button>\n </Grid>\n );\n});\n\nexport default FileItem;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploadItem.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileUploadItem.tsx"],"names":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AChB,oIAAoI;IACpI,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gIAAgI;IAChI,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B;AAuDD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,GAAG,YAAY,CA4HzD,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -55,7 +55,7 @@ const StyledFileUploadItem = styled(SummaryItem)(({ hasThumbnail, theme }) => {
55
55
  `;
56
56
  });
57
57
  StyledFileUploadItem.defaultProps = defaultThemeProp;
58
- const FileUploadItem = forwardRef(({ name, meta, error = false, progress, thumbnail, onCancel, onEdit, onPreview, onDownload, onDelete, size, ...restProps }, ref) => {
58
+ const FileUploadItem = forwardRef(function FileUploadItem({ name, meta, error = false, progress, thumbnail, onCancel, onEdit, onPreview, onDownload, onDelete, size, ...restProps }, ref) {
59
59
  const t = useI18n();
60
60
  const [thumbnailError, setThumbnailError] = useState(false);
61
61
  const definedActions = useMemo(() => [
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploadItem.js","sourceRoot":"","sources":["../../../src/components/File/FileUploadItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,OAAO,EACP,QAAQ,EAET,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,WAAW,EAAE,EAClB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,QAAQ,EAAE,E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from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport MenuButton from '../MenuButton';\nimport MetaList from '../MetaList';\nimport SummaryItem, {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport Text from '../Text';\nimport { ForwardProps, BaseProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\n\nimport FileVisual from './FileVisual';\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\n\nexport interface FileUploadItemProps extends BaseProps, NoChildrenProp {\n /** Name of the file. */\n name: string;\n /** Id applied to upload item */\n id?: string;\n /** File blob */\n File?: File;\n /** A FileUploadVisual element to represent the file. */\n visual?: ReactElement;\n /** Additional information about the file. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string | string[];\n /** When passed, will render a single icon button for yet to be or in progress uploads. Use this action to trigger xhr request termination. */\n onCancel?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onPreview?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDownload?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (name: FileUploadItemProps['name']) => void;\n /**\n * Set if there is an error uploading or processing the file. Applies error styling to the meta string passed.\n * @default false\n */\n error?: boolean;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** If the attachment is in an upload state, pass progress as a number between 0-100 representing the percentage of progress. */\n progress?: number;\n /** The size of the file. */\n size?: number;\n /** A ref to the file item's HTMLLIElement. */\n ref?: Ref<HTMLLIElement>;\n}\n\ninterface FileAction {\n fn: (name: FileUploadItemProps['name']) => void;\n text: string;\n icon: string;\n}\n\nconst StyledFileUploadItem = styled(SummaryItem)<{ hasThumbnail: boolean }>(\n ({ hasThumbnail, theme }) => {\n return css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n min-height: 3rem;\n\n ${StyledProgressRing} {\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n }\n\n ${hasThumbnail &&\n css`\n height: calc(6rem + ${theme.base.spacing});\n grid-row: span 2;\n grid-template-columns: auto minmax(0, 1fr) auto;\n\n ${StyledVisual} {\n align-self: auto;\n width: calc(6rem - 0.125rem);\n height: calc(6rem - 0.125rem);\n }\n\n ${StyledPrimary} {\n align-self: start;\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSecondary} {\n grid-area: primary;\n align-self: center;\n margin-block-start: calc(3 * ${theme.base.spacing});\n }\n\n ${StyledSummaryItemActions} {\n align-self: start;\n }\n `}\n `;\n }\n);\n\nStyledFileUploadItem.defaultProps = defaultThemeProp;\n\nconst FileUploadItem: FC<FileUploadItemProps & ForwardProps> = forwardRef(\n (\n {\n name,\n meta,\n error = false,\n progress,\n thumbnail,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n size,\n ...restProps\n }: PropsWithoutRef<FileUploadItemProps>,\n ref: FileUploadItemProps['ref']\n ) => {\n const t = useI18n();\n const [thumbnailError, setThumbnailError] = useState(false);\n\n const definedActions: FileAction[] = useMemo(\n () =>\n [\n { fn: onCancel, text: t('cancel'), icon: 'times' },\n { fn: onEdit, text: t('edit'), icon: 'pencil' },\n { fn: onPreview, text: t('preview'), icon: 'eye' },\n { fn: onDownload, text: t('download'), icon: 'download' },\n { fn: onDelete, text: t('delete'), icon: 'trash' }\n ].filter<FileAction>((action): action is FileAction => !!action.fn),\n [onCancel, onEdit, onPreview, onDownload, onDelete]\n );\n\n let metaContent: ReactNode = meta;\n let actions: ReactElement | undefined;\n\n const type = getKindFromMimeType(getMimeTypeFromFile(name) ?? '');\n\n if (typeof progress === 'number' && progress < 100) {\n metaContent = `${t('uploading')}…${Math.floor(progress)}%`;\n }\n\n if (Array.isArray(metaContent)) {\n metaContent = (\n <MetaList\n items={metaContent.map((item, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Text key={i} variant='secondary' status={error ? 'error' : undefined}>\n {item}\n </Text>\n ))}\n />\n );\n } else if (typeof metaContent === 'string') {\n metaContent = (\n <Text variant='secondary' status={error ? 'error' : undefined}>\n {metaContent}\n </Text>\n );\n }\n\n if (definedActions.length === 1) {\n const action = definedActions[0];\n\n actions = (\n <Button\n icon\n variant='simple'\n onClick={() => action.fn?.(name)}\n aria-label={`${action.text} ${name}`}\n >\n <Icon name={action.icon} />\n </Button>\n );\n } else if (definedActions.length > 1) {\n actions = (\n <MenuButton\n text={t('actions')}\n iconOnly\n icon='more'\n variant='simple'\n menu={{\n items: definedActions.map(action => ({\n id: action.text,\n primary: action.text,\n onClick: () => {\n action.fn(name);\n }\n }))\n }}\n />\n );\n }\n\n const visual = useMemo(() => {\n if (typeof progress === 'number' && progress !== 100) {\n return <Progress value={progress} placement='inline' variant='ring' />;\n }\n\n return (\n <FileVisual\n type={type}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n }, [progress, thumbnail, thumbnailError]);\n\n return (\n <StyledFileUploadItem\n {...restProps}\n forwardedAs='li'\n hasThumbnail={\n thumbnail && !thumbnailError && (progress === 100 || progress === undefined) && !error\n }\n ref={ref}\n visual={visual}\n primary={name}\n secondary={metaContent}\n actions={actions}\n overflowStrategy='ellipsis'\n />\n );\n }\n);\n\nexport default FileUploadItem;\n"]}
1
+ {"version":3,"file":"FileUploadItem.js","sourceRoot":"","sources":["../../../src/components/File/FileUploadItem.tsx"],"names":[],"mappings":";AAAA,OA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,SAAS,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ,KAAK,GAAG,IAAI,QAAQ,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,EAExF,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,EACb,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAC,UAAU,GAC3B,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n PropsWithoutRef,\n FC,\n Ref,\n ReactElement,\n useMemo,\n useState,\n ReactNode\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport Icon from '../Icon';\nimport MenuButton from '../MenuButton';\nimport MetaList from '../MetaList';\nimport SummaryItem, {\n StyledPrimary,\n StyledSecondary,\n StyledSummaryItemActions,\n StyledVisual\n} from '../SummaryItem';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport Text from '../Text';\nimport { ForwardProps, BaseProps, NoChildrenProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { useI18n } from '../../hooks';\n\nimport FileVisual from './FileVisual';\nimport { getKindFromMimeType, getMimeTypeFromFile } from './utils';\n\nexport interface FileUploadItemProps extends BaseProps, NoChildrenProp {\n /** Name of the file. */\n name: string;\n /** Id applied to upload item */\n id?: string;\n /** File blob */\n File?: File;\n /** A FileUploadVisual element to represent the file. */\n visual?: ReactElement;\n /** Additional information about the file. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string | string[];\n /** When passed, will render a single icon button for yet to be or in progress uploads. Use this action to trigger xhr request termination. */\n onCancel?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onEdit?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onPreview?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDownload?: (name: FileUploadItemProps['name']) => void;\n /** When passed, will render a single icon button or within a MenuButton if other actions are defined. */\n onDelete?: (name: FileUploadItemProps['name']) => void;\n /**\n * Set if there is an error uploading or processing the file. Applies error styling to the meta string passed.\n * @default false\n */\n error?: boolean;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** If the attachment is in an upload state, pass progress as a number between 0-100 representing the percentage of progress. */\n progress?: number;\n /** The size of the file. */\n size?: number;\n /** A ref to the file item's HTMLLIElement. */\n ref?: Ref<HTMLLIElement>;\n}\n\ninterface FileAction {\n fn: (name: FileUploadItemProps['name']) => void;\n text: string;\n icon: string;\n}\n\nconst StyledFileUploadItem = styled(SummaryItem)<{ hasThumbnail: boolean }>(\n ({ hasThumbnail, theme }) => {\n return css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n min-height: 3rem;\n\n ${StyledProgressRing} {\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n }\n\n ${hasThumbnail &&\n css`\n height: calc(6rem + ${theme.base.spacing});\n grid-row: span 2;\n grid-template-columns: auto minmax(0, 1fr) auto;\n\n ${StyledVisual} {\n align-self: auto;\n width: calc(6rem - 0.125rem);\n height: calc(6rem - 0.125rem);\n }\n\n ${StyledPrimary} {\n align-self: start;\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSecondary} {\n grid-area: primary;\n align-self: center;\n margin-block-start: calc(3 * ${theme.base.spacing});\n }\n\n ${StyledSummaryItemActions} {\n align-self: start;\n }\n `}\n `;\n }\n);\n\nStyledFileUploadItem.defaultProps = defaultThemeProp;\n\nconst FileUploadItem: FC<FileUploadItemProps & ForwardProps> = forwardRef(function FileUploadItem(\n {\n name,\n meta,\n error = false,\n progress,\n thumbnail,\n onCancel,\n onEdit,\n onPreview,\n onDownload,\n onDelete,\n size,\n ...restProps\n }: PropsWithoutRef<FileUploadItemProps>,\n ref: FileUploadItemProps['ref']\n) {\n const t = useI18n();\n const [thumbnailError, setThumbnailError] = useState(false);\n\n const definedActions: FileAction[] = useMemo(\n () =>\n [\n { fn: onCancel, text: t('cancel'), icon: 'times' },\n { fn: onEdit, text: t('edit'), icon: 'pencil' },\n { fn: onPreview, text: t('preview'), icon: 'eye' },\n { fn: onDownload, text: t('download'), icon: 'download' },\n { fn: onDelete, text: t('delete'), icon: 'trash' }\n ].filter<FileAction>((action): action is FileAction => !!action.fn),\n [onCancel, onEdit, onPreview, onDownload, onDelete]\n );\n\n let metaContent: ReactNode = meta;\n let actions: ReactElement | undefined;\n\n const type = getKindFromMimeType(getMimeTypeFromFile(name) ?? '');\n\n if (typeof progress === 'number' && progress < 100) {\n metaContent = `${t('uploading')}…${Math.floor(progress)}%`;\n }\n\n if (Array.isArray(metaContent)) {\n metaContent = (\n <MetaList\n items={metaContent.map((item, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Text key={i} variant='secondary' status={error ? 'error' : undefined}>\n {item}\n </Text>\n ))}\n />\n );\n } else if (typeof metaContent === 'string') {\n metaContent = (\n <Text variant='secondary' status={error ? 'error' : undefined}>\n {metaContent}\n </Text>\n );\n }\n\n if (definedActions.length === 1) {\n const action = definedActions[0];\n\n actions = (\n <Button\n icon\n variant='simple'\n onClick={() => action.fn?.(name)}\n aria-label={`${action.text} ${name}`}\n >\n <Icon name={action.icon} />\n </Button>\n );\n } else if (definedActions.length > 1) {\n actions = (\n <MenuButton\n text={t('actions')}\n iconOnly\n icon='more'\n variant='simple'\n menu={{\n items: definedActions.map(action => ({\n id: action.text,\n primary: action.text,\n onClick: () => {\n action.fn(name);\n }\n }))\n }}\n />\n );\n }\n\n const visual = useMemo(() => {\n if (typeof progress === 'number' && progress !== 100) {\n return <Progress value={progress} placement='inline' variant='ring' />;\n }\n\n return (\n <FileVisual\n type={type}\n thumbnail={thumbnailError ? undefined : thumbnail}\n onThumbnailError={() => {\n setThumbnailError(true);\n }}\n />\n );\n }, [progress, thumbnail, thumbnailError]);\n\n return (\n <StyledFileUploadItem\n {...restProps}\n forwardedAs='li'\n hasThumbnail={\n thumbnail && !thumbnailError && (progress === 100 || progress === undefined) && !error\n }\n ref={ref}\n visual={visual}\n primary={name}\n secondary={metaContent}\n actions={actions}\n overflowStrategy='ellipsis'\n />\n );\n});\n\nexport default FileUploadItem;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileVisual.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAMlE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,oFAAoF;IACpF,IAAI,EAAE,cAAc,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACjE,qCAAqC;IACrC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAmED,eAAO,MAAM,gBAAgB,6EAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,6EAY1B,CAAC;AAsBH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAoClD,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FileVisual.d.ts","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,EAAE,EAAE,GAAG,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAe,EAAO,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAMlE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,oFAAoF;IACpF,IAAI,EAAE,cAAc,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACjE,qCAAqC;IACrC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAmED,eAAO,MAAM,gBAAgB,6EAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,6EAY1B,CAAC;AAsBH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,GAAG,YAAY,CAkCjD,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -91,7 +91,7 @@ const StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {
91
91
  `;
92
92
  });
93
93
  StyledThumbnailFrame.defaultProps = defaultThemeProp;
94
- const FileVisual = forwardRef(({ type, thumbnail, onThumbnailError, ...restProps }, ref) => {
94
+ const FileVisual = forwardRef(function FileVisual({ type, thumbnail, onThumbnailError, ...restProps }, ref) {
95
95
  const visualConfig = mapping[type];
96
96
  const [color, lightness] = visualConfig.backgroundColor.split('.', 2);
97
97
  const { base: { colors: { [color]: { [lightness]: backgroundColor } } } } = useTheme();
@@ -1 +1 @@
1
- {"version":3,"file":"FileVisual.js","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2D,MAAM,OAAO,CAAC;AAC5F,OAAO,M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AAI,EAAE,EACJ,MAAM,EAAE,EACN,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,EAC1C,EACF,EACF,GAAG,QAAQ,EAAE,CAAC;IAEf,OAAO,SAAS,CAAC,CAAC,CAAC,CACjB,KAAC,IAAI,OAAK,SAAS,EAAE,EAAE,EAAE,oBAAoB,EAAE,SAAS,kBACtD,KAAC,KAAK,IAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,GAAG,GACtD,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EACtD,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAmB,YAElD,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,YAAY,CAAC,QAAQ,GAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,GAC7E,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, CSSProperties, SyntheticEvent } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\n\nimport Icon from '../Icon';\nimport { ForwardProps, BaseProps, OmitStrict } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Image, { StyledImage } from '../Image';\nimport { useTheme } from '../../hooks';\n\nimport { AttachmentType } from './utils';\n\nexport interface FileVisualProps extends BaseProps {\n /** Attachment/File type, it has an impact on background color and icon rendered. */\n type: AttachmentType;\n /** A string to be used as an image src for a attachment thumbnail. */\n thumbnail?: string;\n /** Called when a thumbnail encounters an error while loading. */\n onThumbnailError?: (e: SyntheticEvent<HTMLImageElement>) => void;\n /** Reference to a button element. */\n ref?: Ref<HTMLDivElement>;\n}\ntype ThemeColor = keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>;\ntype ThemeColorVariant = 'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark';\n\ntype BackgroundColor = `${ThemeColor}.${ThemeColorVariant}`;\n\nconst mapping: Record<\n AttachmentType,\n { backgroundColor: BackgroundColor } & (\n | { iconName: string; text?: never }\n | { iconName?: never; text: string }\n )\n> = {\n generic: {\n iconName: 'paper-clip',\n backgroundColor: 'slate.dark'\n },\n video: {\n iconName: 'play-solid',\n backgroundColor: 'slate.dark'\n },\n audio: {\n iconName: 'speaker-on-solid',\n backgroundColor: 'slate.dark'\n },\n document: {\n iconName: 'filetype-text',\n backgroundColor: 'blue.medium'\n },\n message: {\n iconName: 'mail-solid',\n backgroundColor: 'blue.dark'\n },\n pdf: {\n text: 'PDF',\n backgroundColor: 'red.medium'\n },\n spreadsheet: {\n iconName: 'grid-solid',\n backgroundColor: 'green.medium'\n },\n presentation: {\n iconName: 'slideshow-solid',\n backgroundColor: 'orange.medium'\n },\n link: {\n iconName: 'chain',\n backgroundColor: 'purple.dark'\n },\n archive: {\n iconName: 'archive-solid',\n backgroundColor: 'slate.dark'\n },\n database: {\n iconName: 'disc-stack-solid',\n backgroundColor: 'slate.dark'\n },\n image: {\n iconName: 'picture-solid',\n backgroundColor: 'slate.dark'\n },\n text: {\n iconName: 'filetype-text',\n backgroundColor: 'slate.dark'\n }\n} as const;\n\nexport const StyledFileVisual = styled.div``;\n\nexport const StyledIconFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: var(--bg);\n color: ${theme.base.palette.light};\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: calc(0.7 * ${theme.base['font-size']});\n font-weight: ${theme.base['font-weight']['semi-bold']};\n user-select: none;\n -webkit-user-select: none;\n `;\n});\n\nStyledIconFrame.defaultProps = defaultThemeProp;\n\nconst StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: 100%;\n width: 100%;\n\n ${StyledImage} {\n margin: auto;\n height: unset;\n width: unset;\n max-height: 100%;\n max-width: 100%;\n }\n `;\n});\n\nStyledThumbnailFrame.defaultProps = defaultThemeProp;\n\nconst FileVisual: FC<FileVisualProps & ForwardProps> = forwardRef(\n (\n { type, thumbnail, onThumbnailError, ...restProps }: PropsWithoutRef<FileVisualProps>,\n ref: FileVisualProps['ref']\n ) => {\n const visualConfig = mapping[type];\n\n const [color, lightness] = visualConfig.backgroundColor.split('.', 2) as [\n ThemeColor,\n ThemeColorVariant\n ];\n\n const {\n base: {\n colors: {\n [color]: { [lightness]: backgroundColor }\n }\n }\n } = useTheme();\n\n return thumbnail ? (\n <Flex {...restProps} as={StyledThumbnailFrame} container>\n <Image src={thumbnail} onError={onThumbnailError} alt='' />\n </Flex>\n ) : (\n <Flex\n {...restProps}\n as={StyledIconFrame}\n ref={ref}\n container={{ justify: 'center', alignItems: 'center' }}\n style={{ '--bg': backgroundColor } as CSSProperties}\n >\n {visualConfig.iconName ? <Icon name={visualConfig.iconName} /> : visualConfig.text}\n </Flex>\n );\n }\n);\n\nexport default FileVisual;\n"]}
1
+ {"version":3,"file":"FileVisual.js","sourceRoot":"","sources":["../../../src/components/File/FileVisual.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2D,MAAM,OAAO,CAAC;AAC5F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAE9D,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAmBvC,MA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AO,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,GAAG,GACtD,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OACC,SAAS,EACb,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EACtD,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAmB,YAElD,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,YAAY,CAAC,QAAQ,GAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,GAC7E,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, PropsWithoutRef, FC, Ref, CSSProperties, SyntheticEvent } from 'react';\nimport styled, { css, DefaultTheme } from 'styled-components';\n\nimport Icon from '../Icon';\nimport { ForwardProps, BaseProps, OmitStrict } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport Image, { StyledImage } from '../Image';\nimport { useTheme } from '../../hooks';\n\nimport { AttachmentType } from './utils';\n\nexport interface FileVisualProps extends BaseProps {\n /** Attachment/File type, it has an impact on background color and icon rendered. */\n type: AttachmentType;\n /** A string to be used as an image src for a attachment thumbnail. */\n thumbnail?: string;\n /** Called when a thumbnail encounters an error while loading. */\n onThumbnailError?: (e: SyntheticEvent<HTMLImageElement>) => void;\n /** Reference to a button element. */\n ref?: Ref<HTMLDivElement>;\n}\ntype ThemeColor = keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>;\ntype ThemeColorVariant = 'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark';\n\ntype BackgroundColor = `${ThemeColor}.${ThemeColorVariant}`;\n\nconst mapping: Record<\n AttachmentType,\n { backgroundColor: BackgroundColor } & (\n | { iconName: string; text?: never }\n | { iconName?: never; text: string }\n )\n> = {\n generic: {\n iconName: 'paper-clip',\n backgroundColor: 'slate.dark'\n },\n video: {\n iconName: 'play-solid',\n backgroundColor: 'slate.dark'\n },\n audio: {\n iconName: 'speaker-on-solid',\n backgroundColor: 'slate.dark'\n },\n document: {\n iconName: 'filetype-text',\n backgroundColor: 'blue.medium'\n },\n message: {\n iconName: 'mail-solid',\n backgroundColor: 'blue.dark'\n },\n pdf: {\n text: 'PDF',\n backgroundColor: 'red.medium'\n },\n spreadsheet: {\n iconName: 'grid-solid',\n backgroundColor: 'green.medium'\n },\n presentation: {\n iconName: 'slideshow-solid',\n backgroundColor: 'orange.medium'\n },\n link: {\n iconName: 'chain',\n backgroundColor: 'purple.dark'\n },\n archive: {\n iconName: 'archive-solid',\n backgroundColor: 'slate.dark'\n },\n database: {\n iconName: 'disc-stack-solid',\n backgroundColor: 'slate.dark'\n },\n image: {\n iconName: 'picture-solid',\n backgroundColor: 'slate.dark'\n },\n text: {\n iconName: 'filetype-text',\n backgroundColor: 'slate.dark'\n }\n} as const;\n\nexport const StyledFileVisual = styled.div``;\n\nexport const StyledIconFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: var(--bg);\n color: ${theme.base.palette.light};\n height: ${theme.components.input.height};\n width: ${theme.components.input.height};\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: calc(0.7 * ${theme.base['font-size']});\n font-weight: ${theme.base['font-weight']['semi-bold']};\n user-select: none;\n -webkit-user-select: none;\n `;\n});\n\nStyledIconFrame.defaultProps = defaultThemeProp;\n\nconst StyledThumbnailFrame = styled(StyledFileVisual)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: 100%;\n width: 100%;\n\n ${StyledImage} {\n margin: auto;\n height: unset;\n width: unset;\n max-height: 100%;\n max-width: 100%;\n }\n `;\n});\n\nStyledThumbnailFrame.defaultProps = defaultThemeProp;\n\nconst FileVisual: FC<FileVisualProps & ForwardProps> = forwardRef(function FileVisual(\n { type, thumbnail, onThumbnailError, ...restProps }: PropsWithoutRef<FileVisualProps>,\n ref: FileVisualProps['ref']\n) {\n const visualConfig = mapping[type];\n\n const [color, lightness] = visualConfig.backgroundColor.split('.', 2) as [\n ThemeColor,\n ThemeColorVariant\n ];\n\n const {\n base: {\n colors: {\n [color]: { [lightness]: backgroundColor }\n }\n }\n } = useTheme();\n\n return thumbnail ? (\n <Flex {...restProps} as={StyledThumbnailFrame} container>\n <Image src={thumbnail} onError={onThumbnailError} alt='' />\n </Flex>\n ) : (\n <Flex\n {...restProps}\n as={StyledIconFrame}\n ref={ref}\n container={{ justify: 'center', alignItems: 'center' }}\n style={{ '--bg': backgroundColor } as CSSProperties}\n >\n {visualConfig.iconName ? <Icon name={visualConfig.iconName} /> : visualConfig.text}\n </Flex>\n );\n});\n\nexport default FileVisual;\n"]}