@webiny/admin-ui 6.4.12-beta.5 → 6.5.0-beta.1

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 (316) hide show
  1. package/Accordion/Accordion.d.ts +7 -6
  2. package/Accordion/components/AccordionContent.js +4 -1
  3. package/Accordion/components/AccordionContent.js.map +1 -1
  4. package/Accordion/components/AccordionItem.d.ts +8 -6
  5. package/Accordion/components/AccordionItem.js.map +1 -1
  6. package/Accordion/components/AccordionItemAction.d.ts +7 -6
  7. package/Accordion/components/AccordionItemDragHandle.d.ts +2 -1
  8. package/Accordion/components/AccordionItemDragHandle.js +2 -1
  9. package/Accordion/components/AccordionItemDragHandle.js.map +1 -1
  10. package/Accordion/components/AccordionItemIcon.d.ts +7 -6
  11. package/Accordion/components/AccordionItemSeparator.d.ts +7 -6
  12. package/Accordion/components/AccordionTrigger.js +4 -2
  13. package/Accordion/components/AccordionTrigger.js.map +1 -1
  14. package/Alert/Alert.d.ts +21 -19
  15. package/AutoComplete/AutoComplete.d.ts +7 -6
  16. package/AutoComplete/primitives/AutoCompletePrimitive.d.ts +7 -6
  17. package/Avatar/Avatar.d.ts +9 -8
  18. package/Avatar/components/AvatarFallback.d.ts +7 -6
  19. package/Avatar/components/AvatarImage.d.ts +7 -6
  20. package/BetaBadge/BetaBadge.d.ts +6 -0
  21. package/BetaBadge/BetaBadge.js +7 -0
  22. package/BetaBadge/BetaBadge.js.map +1 -0
  23. package/Button/Button.d.ts +10 -9
  24. package/Button/CopyButton.d.ts +7 -6
  25. package/Button/IconButton.d.ts +10 -9
  26. package/Calendar/Calendar.d.ts +7 -6
  27. package/Calendar/calendarClassNames.js +1 -1
  28. package/Calendar/calendarClassNames.js.map +1 -1
  29. package/Card/Card.d.ts +8 -22
  30. package/Card/components/CancelAction.d.ts +8 -6
  31. package/Card/components/CardContent.d.ts +6 -6
  32. package/Card/components/CardTitle.d.ts +2 -2
  33. package/Card/components/ConfirmAction.d.ts +8 -6
  34. package/Card/components/Icon.d.ts +7 -6
  35. package/Checkbox/Checkbox.d.ts +7 -6
  36. package/Checkbox/primitives/CheckboxPrimitive.d.ts +17 -12
  37. package/CheckboxGroup/CheckboxGroup.d.ts +7 -6
  38. package/CheckboxGroup/primitives/CheckboxGroupPrimitive.d.ts +20 -12
  39. package/CodeEditor/CodeEditor.d.ts +7 -6
  40. package/CodeEditor/CodeEditorPrimitive.d.ts +7 -6
  41. package/CodeEditor/CodeEditorPrimitive.js +3 -1
  42. package/CodeEditor/CodeEditorPrimitive.js.map +1 -1
  43. package/ColorPicker/ColorPicker.d.ts +7 -6
  44. package/ColorPicker/primitives/ColorPickerPrimitive.d.ts +7 -6
  45. package/Command/Command.d.ts +10 -8
  46. package/Command/components/List.d.ts +1 -1
  47. package/Command/components/List.js +9 -5
  48. package/Command/components/List.js.map +1 -1
  49. package/DataList/DataListModal.d.ts +6 -3
  50. package/DataTable/DataTable.d.ts +13 -22
  51. package/DataTable/DataTable.js +6 -14
  52. package/DataTable/DataTable.js.map +1 -1
  53. package/DataTable/components/ColumnsVisibility.d.ts +4 -5
  54. package/DataTable/components/ColumnsVisibility.js +3 -6
  55. package/DataTable/components/ColumnsVisibility.js.map +1 -1
  56. package/DatePicker/DatePicker.d.ts +11 -7
  57. package/DatePicker/DatePicker.js +10 -2
  58. package/DatePicker/DatePicker.js.map +1 -1
  59. package/DatePicker/primitives/DatePickerPrimitive.d.ts +7 -6
  60. package/DatePicker/primitives/DateTimePicker.d.ts +1 -1
  61. package/DatePicker/primitives/DateTimePicker.js +23 -16
  62. package/DatePicker/primitives/DateTimePicker.js.map +1 -1
  63. package/DatePicker/primitives/components/DatePickerTrigger.js +1 -1
  64. package/DatePicker/primitives/components/DatePickerTrigger.js.map +1 -1
  65. package/DatePicker/utils/dateHelpers.d.ts +1 -1
  66. package/DatePicker/utils/dateHelpers.js +2 -1
  67. package/DatePicker/utils/dateHelpers.js.map +1 -1
  68. package/DatePicker/utils/timezoneHelpers.d.ts +3 -0
  69. package/DatePicker/utils/timezoneHelpers.js +32 -0
  70. package/DatePicker/utils/timezoneHelpers.js.map +1 -0
  71. package/DatePicker/utils/types.d.ts +2 -0
  72. package/Dialog/Dialog.d.ts +8 -22
  73. package/Dialog/components/CancelAction.d.ts +8 -6
  74. package/Dialog/components/ConfirmAction.d.ts +8 -6
  75. package/Dialog/components/DialogContent.d.ts +1 -1
  76. package/Dialog/components/DialogFooter.d.ts +1 -1
  77. package/Dialog/components/DialogTitle.d.ts +1 -1
  78. package/Dialog/components/Icon.d.ts +7 -6
  79. package/Drawer/Drawer.d.ts +8 -22
  80. package/Drawer/Drawer.stories.js +1 -0
  81. package/Drawer/Drawer.stories.js.map +1 -1
  82. package/Drawer/components/CancelButton.d.ts +8 -6
  83. package/Drawer/components/ConfirmButton.d.ts +8 -6
  84. package/Drawer/components/DrawerContent.d.ts +1 -1
  85. package/Drawer/components/Icon.d.ts +7 -6
  86. package/DropdownMenu/components/DropdownMenuItem.d.ts +3 -2
  87. package/DropdownMenu/components/DropdownMenuItem.js +9 -2
  88. package/DropdownMenu/components/DropdownMenuItem.js.map +1 -1
  89. package/DropdownMenu/components/DropdownMenuLink.d.ts +9 -8
  90. package/DropdownMenu/components/DropdownMenuSeparator.d.ts +7 -6
  91. package/EditableTitle/EditableTitle.d.ts +7 -6
  92. package/EmptyState/EmptyState.d.ts +43 -0
  93. package/EmptyState/EmptyState.js +93 -0
  94. package/EmptyState/EmptyState.js.map +1 -0
  95. package/EmptyState/EmptyState.stories.d.ts +13 -0
  96. package/EmptyState/EmptyState.stories.js +136 -0
  97. package/EmptyState/EmptyState.stories.js.map +1 -0
  98. package/EmptyState/illustrations/ContentIllustration.d.ts +2 -0
  99. package/EmptyState/illustrations/ContentIllustration.js +100 -0
  100. package/EmptyState/illustrations/ContentIllustration.js.map +1 -0
  101. package/EmptyState/illustrations/LayoutIllustration.d.ts +2 -0
  102. package/EmptyState/illustrations/LayoutIllustration.js +93 -0
  103. package/EmptyState/illustrations/LayoutIllustration.js.map +1 -0
  104. package/EmptyState/illustrations/ListingIllustration.d.ts +2 -0
  105. package/EmptyState/illustrations/ListingIllustration.js +92 -0
  106. package/EmptyState/illustrations/ListingIllustration.js.map +1 -0
  107. package/EmptyState/illustrations/SelectIllustration.d.ts +2 -0
  108. package/EmptyState/illustrations/SelectIllustration.js +100 -0
  109. package/EmptyState/illustrations/SelectIllustration.js.map +1 -0
  110. package/EmptyState/illustrations/TableIllustration.d.ts +2 -0
  111. package/EmptyState/illustrations/TableIllustration.js +233 -0
  112. package/EmptyState/illustrations/TableIllustration.js.map +1 -0
  113. package/EmptyState/illustrations/UploadIllustration.d.ts +2 -0
  114. package/EmptyState/illustrations/UploadIllustration.js +77 -0
  115. package/EmptyState/illustrations/UploadIllustration.js.map +1 -0
  116. package/EmptyState/illustrations/index.d.ts +6 -0
  117. package/EmptyState/illustrations/index.js +6 -0
  118. package/EmptyState/index.d.ts +1 -0
  119. package/EmptyState/index.js +1 -0
  120. package/FilePicker/FilePicker.d.ts +19 -18
  121. package/FilePicker/FilePicker.stories.d.ts +0 -6
  122. package/FilePicker/FilePicker.stories.js +1 -24
  123. package/FilePicker/FilePicker.stories.js.map +1 -1
  124. package/FilePicker/primitives/FilePickerPrimitive.d.ts +20 -19
  125. package/FilePicker/primitives/components/Trigger.d.ts +1 -1
  126. package/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.d.ts +19 -7
  127. package/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.js +15 -6
  128. package/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.js.map +1 -1
  129. package/FilePicker/primitives/components/previews/ItemActions.js.map +1 -1
  130. package/FilePicker/primitives/components/previews/ItemDescription.js +1 -1
  131. package/FilePicker/primitives/components/previews/ItemDescription.js.map +1 -1
  132. package/FilePicker/primitives/components/previews/RichItemPreview/FileType.d.ts +0 -4
  133. package/FilePicker/primitives/components/previews/RichItemPreview/FileType.js.map +1 -1
  134. package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.d.ts +0 -3
  135. package/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js.map +1 -1
  136. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.d.ts +12 -6
  137. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js +6 -4
  138. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js.map +1 -1
  139. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.d.ts +6 -1
  140. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js +3 -2
  141. package/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js.map +1 -1
  142. package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.d.ts +5 -5
  143. package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js +7 -3
  144. package/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js.map +1 -1
  145. package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.d.ts +0 -5
  146. package/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js.map +1 -1
  147. package/FilePicker/primitives/components/previews/TextOnlyPreview/TextOnlyPreview.d.ts +7 -6
  148. package/FilePicker/primitives/components/previews/TruncatedFileName.d.ts +0 -4
  149. package/FilePicker/primitives/components/previews/TruncatedFileName.js.map +1 -1
  150. package/FilePicker/primitives/components/previews/fileName.d.ts +0 -8
  151. package/FilePicker/primitives/components/previews/fileName.js.map +1 -1
  152. package/FilePicker/primitives/components/previews/variants.d.ts +1 -1
  153. package/FillViewport/FillViewport.d.ts +21 -18
  154. package/FormComponent/Description.d.ts +7 -6
  155. package/FormComponent/ErrorMessage.d.ts +7 -6
  156. package/FormComponent/Label.d.ts +7 -6
  157. package/FormComponent/Note.d.ts +7 -6
  158. package/Grid/Grid.d.ts +24 -22
  159. package/HeaderBar/HeaderBar.d.ts +7 -6
  160. package/Heading/Heading.d.ts +8 -7
  161. package/Icon/Icon.d.ts +9 -8
  162. package/IconPicker/IconPicker.d.ts +7 -6
  163. package/IconPicker/domains/IconPickerIcon.js +1 -1
  164. package/IconPicker/domains/IconPickerIcon.js.map +1 -1
  165. package/IconPicker/primitives/IconPickerPrimitive.d.ts +1 -1
  166. package/IconPicker/primitives/IconPickerPrimitive.js +1 -2
  167. package/IconPicker/primitives/IconPickerPrimitive.js.map +1 -1
  168. package/IconPicker/primitives/components/IconPickerTrigger.d.ts +1 -1
  169. package/ImageEditor/AspectRatioPreview.d.ts +16 -0
  170. package/ImageEditor/AspectRatioPreview.js +26 -0
  171. package/ImageEditor/AspectRatioPreview.js.map +1 -0
  172. package/ImageEditor/CropHotspotEditor.d.ts +22 -0
  173. package/ImageEditor/CropHotspotEditor.js +402 -0
  174. package/ImageEditor/CropHotspotEditor.js.map +1 -0
  175. package/ImageEditor/ImageEditor.d.ts +18 -0
  176. package/ImageEditor/ImageEditor.js +151 -0
  177. package/ImageEditor/ImageEditor.js.map +1 -0
  178. package/ImageEditor/ImageEditor.stories.d.ts +6 -0
  179. package/ImageEditor/ImageEditor.stories.js +42 -0
  180. package/ImageEditor/ImageEditor.stories.js.map +1 -0
  181. package/ImageEditor/MetaFields.d.ts +12 -0
  182. package/ImageEditor/MetaFields.js +20 -0
  183. package/ImageEditor/MetaFields.js.map +1 -0
  184. package/ImageEditor/SectionLabel.d.ts +8 -0
  185. package/ImageEditor/SectionLabel.js +7 -0
  186. package/ImageEditor/SectionLabel.js.map +1 -0
  187. package/ImageEditor/geometry.d.ts +46 -0
  188. package/ImageEditor/geometry.js +126 -0
  189. package/ImageEditor/geometry.js.map +1 -0
  190. package/ImageEditor/index.d.ts +3 -0
  191. package/ImageEditor/index.js +3 -0
  192. package/ImageEditor/types.d.ts +52 -0
  193. package/ImageEditor/types.js +35 -0
  194. package/ImageEditor/types.js.map +1 -0
  195. package/Input/Input.d.ts +7 -6
  196. package/Input/InputPrimitive.d.ts +9 -8
  197. package/Label/Label.d.ts +8 -7
  198. package/Label/components/LabelValue.d.ts +1 -1
  199. package/Link/Link.d.ts +2 -2
  200. package/List/List.d.ts +8 -7
  201. package/List/components/ListItem.d.ts +7 -6
  202. package/List/components/ListItemAction.d.ts +7 -6
  203. package/List/components/ListItemHandle.d.ts +7 -6
  204. package/List/components/ListItemIcon.d.ts +7 -6
  205. package/List/components/ListItemSeparator.d.ts +7 -6
  206. package/Loader/Loader.d.ts +9 -8
  207. package/Loader/OverlayLoader.d.ts +7 -6
  208. package/MultiAutoComplete/MultiAutoComplete.d.ts +7 -6
  209. package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.d.ts +7 -6
  210. package/MultiAutoComplete/primitives/presenters/MultiAutoCompletePresenter.test.js +1 -1
  211. package/MultiAutoComplete/primitives/presenters/MultiAutoCompletePresenter.test.js.map +1 -1
  212. package/MultiAutoComplete/primitives/presenters/MultiAutoCompletePresenterWithFreeInput.d.ts +3 -3
  213. package/MultiAutoComplete/primitives/useMultiAutoComplete.d.ts +3 -3
  214. package/MultiAutoComplete/primitives/useMultiAutoComplete.js +2 -3
  215. package/MultiAutoComplete/primitives/useMultiAutoComplete.js.map +1 -1
  216. package/MultiFilePicker/MultiFilePicker.d.ts +19 -18
  217. package/MultiFilePicker/primitives/MultiFilePickerPrimitive.d.ts +19 -18
  218. package/MultiSelect/MultiSelect.d.ts +7 -6
  219. package/MultiSelect/primitives/MultiSelectPrimitive.d.ts +10 -6
  220. package/MultiSelect/primitives/MultiSelectPrimitive.js +12 -5
  221. package/MultiSelect/primitives/MultiSelectPrimitive.js.map +1 -1
  222. package/Popover/Popover.d.ts +7 -6
  223. package/Popover/Popover.stories.d.ts +7 -0
  224. package/Popover/Popover.stories.js +24 -1
  225. package/Popover/Popover.stories.js.map +1 -1
  226. package/Popover/primitives/PopoverPrimitive.d.ts +7 -7
  227. package/Popover/primitives/components/PopoverContent.js +6 -1
  228. package/Popover/primitives/components/PopoverContent.js.map +1 -1
  229. package/ProgressBar/ProgressBar.d.ts +7 -6
  230. package/RadioGroup/RadioGroup.d.ts +7 -6
  231. package/RadioGroup/primitives/Radio.d.ts +7 -6
  232. package/RadioGroup/primitives/RadioGroupPrimitive.d.ts +5 -1
  233. package/RangeSlider/RangeSlider.d.ts +7 -6
  234. package/ScrollArea/ScrollArea.d.ts +12 -2
  235. package/ScrollArea/ScrollArea.js +11 -4
  236. package/ScrollArea/ScrollArea.js.map +1 -1
  237. package/SegmentedControl/SegmentedControl.d.ts +8 -7
  238. package/SegmentedControl/SegmentedControlTabs.d.ts +5 -2
  239. package/SegmentedControl/primitives/SegmentedControlPrimitive.d.ts +1 -1
  240. package/Select/Select.d.ts +7 -6
  241. package/Select/primitives/components/SelectContent.js +4 -6
  242. package/Select/primitives/components/SelectContent.js.map +1 -1
  243. package/Select/primitives/components/SelectTrigger.d.ts +2 -2
  244. package/Separator/Separator.d.ts +9 -8
  245. package/Sidebar/Sidebar.d.ts +7 -6
  246. package/Sidebar/components/SidebarIcon.d.ts +7 -6
  247. package/Sidebar/components/SidebarProvider.d.ts +4 -4
  248. package/Sidebar/components/items/SidebarMenuGroup.d.ts +9 -8
  249. package/Sidebar/components/items/SidebarMenuItem.d.ts +11 -10
  250. package/Sidebar/components/items/SidebarMenuItemIcon.d.ts +7 -6
  251. package/Sidebar/components/items/SidebarMenuLink.d.ts +11 -10
  252. package/Sidebar/components/items/SidebarMenuProvider.d.ts +4 -4
  253. package/Sidebar/components/items/SidebarMenuRootItem.d.ts +9 -7
  254. package/Skeleton/Skeleton.d.ts +9 -7
  255. package/Skeleton/Skeleton.js +10 -4
  256. package/Skeleton/Skeleton.js.map +1 -1
  257. package/Skeleton/Skeleton.stories.d.ts +2 -0
  258. package/Skeleton/Skeleton.stories.js +28 -2
  259. package/Skeleton/Skeleton.stories.js.map +1 -1
  260. package/Slider/Slider.d.ts +7 -6
  261. package/SteppedProgress/SteppedProgress.d.ts +7 -6
  262. package/SteppedProgress/SteppedProgressItem.d.ts +7 -6
  263. package/Switch/Switch.d.ts +7 -6
  264. package/Switch/primitives/SwitchPrimitive.d.ts +10 -6
  265. package/Table/Table.d.ts +12 -10
  266. package/Table/components/Direction.d.ts +1 -1
  267. package/Tabs/Tabs.d.ts +8 -6
  268. package/Tabs/Tabs.js +5 -2
  269. package/Tabs/Tabs.js.map +1 -1
  270. package/Tabs/components/Content.d.ts +1 -1
  271. package/Tabs/components/List.d.ts +2 -2
  272. package/Tabs/components/Tab.d.ts +7 -6
  273. package/Tabs/components/Trigger.d.ts +3 -2
  274. package/Tabs/components/Trigger.js +8 -3
  275. package/Tabs/components/Trigger.js.map +1 -1
  276. package/Tag/Tag.d.ts +8 -7
  277. package/Tags/Tags.d.ts +7 -6
  278. package/Tags/primitives/TagsPrimitive.d.ts +7 -6
  279. package/Text/Text.d.ts +8 -7
  280. package/Textarea/Textarea.d.ts +7 -6
  281. package/Textarea/TextareaPrimitive.d.ts +9 -8
  282. package/Toast/Toast.d.ts +7 -6
  283. package/Toast/components/ToastActions.d.ts +7 -6
  284. package/Toast/components/ToastDescription.d.ts +7 -6
  285. package/Toast/components/ToastTitle.d.ts +7 -6
  286. package/Toast/useToast.stories.js.map +1 -1
  287. package/Toggle/Toggle.d.ts +7 -6
  288. package/Toggle/primitives/TogglePrimitive.d.ts +13 -9
  289. package/ToggleGroup/ToggleGroup.d.ts +7 -6
  290. package/ToggleGroup/primitives/ToggleGroupPrimitive.d.ts +13 -9
  291. package/Tooltip/Tooltip.d.ts +7 -6
  292. package/Tree/Tree.d.ts +7 -6
  293. package/Tree/components/Item.d.ts +7 -6
  294. package/Tree/components/ItemCollapseTrigger.d.ts +7 -6
  295. package/Tree/components/ItemContent.d.ts +8 -6
  296. package/Tree/components/ItemDragHandle.d.ts +7 -6
  297. package/Tree/components/ItemIcon.d.ts +7 -6
  298. package/Tree/components/ItemPlaceholder.d.ts +7 -6
  299. package/Tree/components/ItemSubIndentation.d.ts +7 -6
  300. package/Widget/Widget.d.ts +8 -22
  301. package/Widget/components/Icon.d.ts +7 -6
  302. package/Widget/components/WidgetAction.d.ts +8 -6
  303. package/Widget/components/WidgetContent.d.ts +5 -5
  304. package/exports/admin/ui.d.ts +2 -0
  305. package/exports/admin/ui.js +2 -0
  306. package/hooks/index.d.ts +1 -0
  307. package/hooks/index.js +1 -0
  308. package/hooks/useEscapeScrollLock.d.ts +13 -0
  309. package/hooks/useEscapeScrollLock.js +21 -0
  310. package/hooks/useEscapeScrollLock.js.map +1 -0
  311. package/index.d.ts +3 -0
  312. package/index.js +3 -0
  313. package/package.json +25 -25
  314. package/theme.css +41 -1
  315. package/utils.js +52 -34
  316. package/utils.js.map +1 -1
@@ -6,7 +6,7 @@ import { FileItem, type FileItemDto, type FileItemFormatted } from "../domains/i
6
6
  import type { FilePreviewRendererProps, TriggerRendererProps } from "./components/types.js";
7
7
  declare const filePickerVariants: (props?: ({
8
8
  type?: "area" | "compact" | null | undefined;
9
- variant?: "primary" | "secondary" | "ghost" | null | undefined;
9
+ variant?: "ghost" | "primary" | "secondary" | null | undefined;
10
10
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
11
  interface FilePickerPrimitiveProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof filePickerVariants> {
12
12
  /**
@@ -63,60 +63,61 @@ interface FilePickerPrimitiveProps extends React.HTMLAttributes<HTMLDivElement>,
63
63
  */
64
64
  value?: FileItemDto | string | null;
65
65
  }
66
- declare const FilePickerPrimitive: (({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element) & {
67
- original: ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
66
+ declare const BaseFilePickerPrimitive: ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
67
+ declare const FilePickerPrimitive: typeof BaseFilePickerPrimitive & {
68
+ original: typeof BaseFilePickerPrimitive;
68
69
  originalName: string;
69
70
  displayName: string;
70
71
  } & {
71
- original: (({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element) & {
72
- original: ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
72
+ original: typeof BaseFilePickerPrimitive & {
73
+ original: typeof BaseFilePickerPrimitive;
73
74
  originalName: string;
74
75
  displayName: string;
75
76
  };
76
77
  originalName: string;
77
78
  displayName: string;
78
79
  } & {
79
- createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element) & {
80
- original: ({ className, containerStyle, description, disabled, invalid, label, onEditItem, onRemoveItem, onSelectItem, placeholder, renderFilePreview, renderTrigger, type, value, variant }: FilePickerPrimitiveProps) => React.JSX.Element;
80
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<typeof BaseFilePickerPrimitive & {
81
+ original: typeof BaseFilePickerPrimitive;
81
82
  originalName: string;
82
83
  displayName: string;
83
84
  }>) => (props: unknown) => React.JSX.Element;
84
85
  } & {
85
86
  Preview: {
86
- Image: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
87
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
87
+ Image: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
88
+ original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
88
89
  originalName: string;
89
90
  displayName: string;
90
91
  } & {
91
- original: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
92
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
92
+ original: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
93
+ original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
93
94
  originalName: string;
94
95
  displayName: string;
95
96
  };
96
97
  originalName: string;
97
98
  displayName: string;
98
99
  } & {
99
- createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
100
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
100
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element) & {
101
+ original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: import("./index.js").ImagePreviewProps) => React.JSX.Element;
101
102
  originalName: string;
102
103
  displayName: string;
103
104
  }>) => (props: unknown) => React.JSX.Element;
104
105
  };
105
- RichItem: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
106
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
106
+ RichItem: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
107
+ original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
107
108
  originalName: string;
108
109
  displayName: string;
109
110
  } & {
110
- original: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
111
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
111
+ original: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
112
+ original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
112
113
  originalName: string;
113
114
  displayName: string;
114
115
  };
115
116
  originalName: string;
116
117
  displayName: string;
117
118
  } & {
118
- createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
119
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
119
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element) & {
120
+ original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: import("./index.js").RichItemPreviewProps) => React.JSX.Element;
120
121
  originalName: string;
121
122
  displayName: string;
122
123
  }>) => (props: unknown) => React.JSX.Element;
@@ -3,7 +3,7 @@ import { type VariantProps } from "../../../utils.js";
3
3
  import type { TriggerDefaultProps } from "../../../FilePicker/primitives/components/types.js";
4
4
  declare const triggerVariants: (props?: ({
5
5
  type?: "area" | "compact" | null | undefined;
6
- variant?: "primary" | "secondary" | "ghost" | null | undefined;
6
+ variant?: "ghost" | "primary" | "secondary" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  interface TriggerProps extends TriggerDefaultProps, VariantProps<typeof triggerVariants> {
9
9
  renderTrigger?: (props: any) => React.ReactElement<any>;
@@ -1,21 +1,33 @@
1
1
  import React from "react";
2
2
  import type { FilePreviewDefaultProps } from "../../types.js";
3
- type ImagePreviewProps = FilePreviewDefaultProps;
4
- declare const ImagePreview: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element) & {
5
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element;
3
+ type ImagePreviewProps = FilePreviewDefaultProps & {
4
+ /**
5
+ * Optional custom image renderer. Lets a consumer render, e.g., a cropped /
6
+ * focal-point-aware thumbnail while keeping all of the preview chrome. When
7
+ * omitted (or it returns a falsy value) a plain `<img>` is rendered.
8
+ */
9
+ renderImage?: (args: {
10
+ url: string;
11
+ name: string;
12
+ className: string;
13
+ }) => React.ReactNode;
14
+ };
15
+ declare const DecoratableImagePreview: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage }: ImagePreviewProps) => React.JSX.Element;
16
+ declare const ImagePreview: typeof DecoratableImagePreview & {
17
+ original: typeof DecoratableImagePreview;
6
18
  originalName: string;
7
19
  displayName: string;
8
20
  } & {
9
- original: (({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element) & {
10
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element;
21
+ original: typeof DecoratableImagePreview & {
22
+ original: typeof DecoratableImagePreview;
11
23
  originalName: string;
12
24
  displayName: string;
13
25
  };
14
26
  originalName: string;
15
27
  displayName: string;
16
28
  } & {
17
- createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element) & {
18
- original: ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem }: ImagePreviewProps) => React.JSX.Element;
29
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<typeof DecoratableImagePreview & {
30
+ original: typeof DecoratableImagePreview;
19
31
  originalName: string;
20
32
  displayName: string;
21
33
  }>) => (props: unknown) => React.JSX.Element;
@@ -2,7 +2,19 @@ import react from "react";
2
2
  import { cn, makeDecoratable } from "../../../../../utils.js";
3
3
  import { previewVariants } from "../variants.js";
4
4
  import { ItemActions } from "../ItemActions.js";
5
- const DecoratableImagePreview = ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem })=>/*#__PURE__*/ react.createElement("div", {
5
+ const IMAGE_CLASS = "object-contain size-full";
6
+ const DecoratableImagePreview = ({ value, className, variant, disabled, onRemoveItem, onReplaceItem, onEditItem, renderImage })=>{
7
+ let image = /*#__PURE__*/ react.createElement("img", {
8
+ src: value.url,
9
+ alt: value.name,
10
+ className: IMAGE_CLASS
11
+ });
12
+ if ("function" == typeof renderImage) image = renderImage({
13
+ url: value.url,
14
+ name: value.name,
15
+ className: IMAGE_CLASS
16
+ });
17
+ return /*#__PURE__*/ react.createElement("div", {
6
18
  className: cn("flex justify-center items-center py-sm rounded-md relative", previewVariants({
7
19
  variant
8
20
  }), className),
@@ -11,11 +23,7 @@ const DecoratableImagePreview = ({ value, className, variant, disabled, onRemove
11
23
  className: "cursor-pointer size-[128px] flex justify-center items-center",
12
24
  "data-role": "select-image",
13
25
  onClick: onReplaceItem
14
- }, /*#__PURE__*/ react.createElement("img", {
15
- src: value.url,
16
- alt: value.name,
17
- className: "object-contain size-full"
18
- })), /*#__PURE__*/ react.createElement("div", {
26
+ }, image), /*#__PURE__*/ react.createElement("div", {
19
27
  className: "absolute top-1 right-1.5"
20
28
  }, /*#__PURE__*/ react.createElement(ItemActions, {
21
29
  onRemoveItem: onRemoveItem,
@@ -23,6 +31,7 @@ const DecoratableImagePreview = ({ value, className, variant, disabled, onRemove
23
31
  disabled: disabled,
24
32
  className: "flex-col"
25
33
  })));
34
+ };
26
35
  const ImagePreview = makeDecoratable("FileImagePreview", DecoratableImagePreview);
27
36
  export { ImagePreview };
28
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/ImagePreview/ImagePreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\n\ntype ImagePreviewProps = FilePreviewDefaultProps;\n\nconst DecoratableImagePreview = ({\n value,\n className,\n variant,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem\n}: ImagePreviewProps) => {\n return (\n <div\n className={cn(\n \"flex justify-center items-center py-sm rounded-md relative\",\n previewVariants({ variant }),\n className\n )}\n data-testid={\"image-preview\"}\n >\n <div\n className={\"cursor-pointer size-[128px] flex justify-center items-center\"}\n data-role={\"select-image\"}\n onClick={onReplaceItem}\n >\n <img src={value.url} alt={value.name} className={\"object-contain size-full\"} />\n </div>\n <div className={\"absolute top-1 right-1.5\"}>\n <ItemActions\n onRemoveItem={onRemoveItem}\n onEditItem={onEditItem}\n disabled={disabled}\n className={\"flex-col\"}\n />\n </div>\n </div>\n );\n};\n\nconst ImagePreview = makeDecoratable(\"FileImagePreview\", DecoratableImagePreview);\n\nexport { ImagePreview, type ImagePreviewProps };\n"],"names":["DecoratableImagePreview","value","className","variant","disabled","onRemoveItem","onReplaceItem","onEditItem","cn","previewVariants","ItemActions","ImagePreview","makeDecoratable"],"mappings":";;;;AAQA,MAAMA,0BAA0B,CAAC,EAC7BC,KAAK,EACLC,SAAS,EACTC,OAAO,EACPC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,UAAU,EACM,GACT,WAAP,GACI,oBAAC;QACG,WAAWC,GACP,8DACAC,gBAAgB;YAAEN;QAAQ,IAC1BD;QAEJ,eAAa;qBAEb,oBAAC;QACG,WAAW;QACX,aAAW;QACX,SAASI;qBAET,oBAAC;QAAI,KAAKL,MAAM,GAAG;QAAE,KAAKA,MAAM,IAAI;QAAE,WAAW;uBAErD,oBAAC;QAAI,WAAW;qBACZ,oBAACS,aAAWA;QACR,cAAcL;QACd,YAAYE;QACZ,UAAUH;QACV,WAAW;;AAO/B,MAAMO,eAAeC,gBAAgB,oBAAoBZ"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/ImagePreview/ImagePreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/ImagePreview/ImagePreview.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\n\ntype ImagePreviewProps = FilePreviewDefaultProps & {\n /**\n * Optional custom image renderer. Lets a consumer render, e.g., a cropped /\n * focal-point-aware thumbnail while keeping all of the preview chrome. When\n * omitted (or it returns a falsy value) a plain `<img>` is rendered.\n */\n renderImage?: (args: { url: string; name: string; className: string }) => React.ReactNode;\n};\n\nconst IMAGE_CLASS = \"object-contain size-full\";\n\nconst DecoratableImagePreview = ({\n value,\n className,\n variant,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem,\n renderImage\n}: ImagePreviewProps) => {\n let image: React.ReactElement | React.ReactNode = (\n <img src={value.url} alt={value.name} className={IMAGE_CLASS} />\n );\n\n if (typeof renderImage === \"function\") {\n image = renderImage({ url: value.url, name: value.name, className: IMAGE_CLASS });\n }\n\n return (\n <div\n className={cn(\n \"flex justify-center items-center py-sm rounded-md relative\",\n previewVariants({ variant }),\n className\n )}\n data-testid={\"image-preview\"}\n >\n <div\n className={\"cursor-pointer size-[128px] flex justify-center items-center\"}\n data-role={\"select-image\"}\n onClick={onReplaceItem}\n >\n {image}\n </div>\n <div className={\"absolute top-1 right-1.5\"}>\n <ItemActions\n onRemoveItem={onRemoveItem}\n onEditItem={onEditItem}\n disabled={disabled}\n className={\"flex-col\"}\n />\n </div>\n </div>\n );\n};\n\nconst ImagePreview = makeDecoratable(\"FileImagePreview\", DecoratableImagePreview);\n\nexport { ImagePreview, type ImagePreviewProps };\n"],"names":["IMAGE_CLASS","DecoratableImagePreview","value","className","variant","disabled","onRemoveItem","onReplaceItem","onEditItem","renderImage","image","cn","previewVariants","ItemActions","ImagePreview","makeDecoratable"],"mappings":";;;;AAeA,MAAMA,cAAc;AAEpB,MAAMC,0BAA0B,CAAC,EAC7BC,KAAK,EACLC,SAAS,EACTC,OAAO,EACPC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,WAAW,EACK;IAChB,IAAIC,QAAAA,WAAAA,GACA,oBAAC;QAAI,KAAKR,MAAM,GAAG;QAAE,KAAKA,MAAM,IAAI;QAAE,WAAWF;;IAGrD,IAAI,AAAuB,cAAvB,OAAOS,aACPC,QAAQD,YAAY;QAAE,KAAKP,MAAM,GAAG;QAAE,MAAMA,MAAM,IAAI;QAAE,WAAWF;IAAY;IAGnF,OAAO,WAAP,GACI,oBAAC;QACG,WAAWW,GACP,8DACAC,gBAAgB;YAAER;QAAQ,IAC1BD;QAEJ,eAAa;qBAEb,oBAAC;QACG,WAAW;QACX,aAAW;QACX,SAASI;OAERG,QAAAA,WAAAA,GAEL,oBAAC;QAAI,WAAW;qBACZ,oBAACG,aAAWA;QACR,cAAcP;QACd,YAAYE;QACZ,UAAUH;QACV,WAAW;;AAK/B;AAEA,MAAMS,eAAeC,gBAAgB,oBAAoBd"}
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/ItemActions.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemActions.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ItemActionsProps extends React.HTMLAttributes<HTMLDivElement> {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemActions = ({\n disabled,\n onRemoveItem,\n onEditItem,\n onReplaceItem,\n small,\n className,\n ...props\n}: ItemActionsProps) => {\n const iconSize = small ? \"default\" : \"lg\";\n const buttonSize = small ? \"xs\" : \"sm\";\n\n return (\n <div {...props} className={cn(\"flex justify-center items-center gap-xs\", className)}>\n {/* Replace is the action a populated picker mainly exists for, and it was only ever\n shown in the `small` layout - elsewhere it hid behind clicking the thumbnail. */}\n {onReplaceItem && (\n <IconButton\n icon={\n <Icon\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onReplaceItem}\n disabled={disabled}\n />\n )}\n\n {onEditItem && (\n <IconButton\n icon={\n <Icon\n icon={<EditIcon />}\n label={\"Edit\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onEditItem}\n disabled={disabled}\n />\n )}\n\n {onRemoveItem && (\n <IconButton\n icon={\n <Icon\n icon={<TrashIcon />}\n label={\"Remove\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ItemActions, type ItemActionsProps };\n"],"names":["ItemActions","disabled","onRemoveItem","onEditItem","onReplaceItem","small","className","props","iconSize","buttonSize","cn","IconButton","Icon","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAgBA,MAAMA,cAAc,CAAC,EACjBC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,aAAa,EACbC,KAAK,EACLC,SAAS,EACT,GAAGC,OACY;IACf,MAAMC,WAAWH,QAAQ,YAAY;IACrC,MAAMI,aAAaJ,QAAQ,OAAO;IAElC,OAAO,WAAP,GACI,oBAAC;QAAK,GAAGE,KAAK;QAAE,WAAWG,GAAG,2CAA2CJ;OAGpEF,iBAAiB,WAAjBA,GACG,oBAACO,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACC,gBAAWA;YAClB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMJ;QACN,UAAUD;QACV,SAASJ;QACT,UAAUH;QAIjBE,cAAc,WAAdA,GACG,oBAACQ,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACE,yBAAQA;YACf,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAML;QACN,UAAUD;QACV,SAASL;QACT,UAAUF;QAIjBC,gBAAgB,WAAhBA,GACG,oBAACS,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACG,2BAASA;YAChB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMN;QACN,UAAUD;QACV,SAASN;QACT,UAAUD;;AAK9B"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/ItemActions.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemActions.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ItemActionsProps extends React.HTMLAttributes<HTMLDivElement> {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemActions = ({\n disabled,\n onRemoveItem,\n onEditItem,\n onReplaceItem,\n small,\n className,\n ...props\n}: ItemActionsProps) => {\n const iconSize = small ? \"default\" : \"lg\";\n const buttonSize = small ? \"xs\" : \"sm\";\n\n return (\n <div {...props} className={cn(\"flex justify-center items-center gap-xs\", className)}>\n {onReplaceItem && (\n <IconButton\n icon={\n <Icon\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onReplaceItem}\n disabled={disabled}\n />\n )}\n\n {onEditItem && (\n <IconButton\n icon={\n <Icon\n icon={<EditIcon />}\n label={\"Edit\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onEditItem}\n disabled={disabled}\n />\n )}\n\n {onRemoveItem && (\n <IconButton\n icon={\n <Icon\n icon={<TrashIcon />}\n label={\"Remove\"}\n size={\"md\"}\n color={\"neutral-light\"}\n />\n }\n variant={\"ghost\"}\n size={buttonSize}\n iconSize={iconSize}\n onClick={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ItemActions, type ItemActionsProps };\n"],"names":["ItemActions","disabled","onRemoveItem","onEditItem","onReplaceItem","small","className","props","iconSize","buttonSize","cn","IconButton","Icon","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAgBA,MAAMA,cAAc,CAAC,EACjBC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,aAAa,EACbC,KAAK,EACLC,SAAS,EACT,GAAGC,OACY;IACf,MAAMC,WAAWH,QAAQ,YAAY;IACrC,MAAMI,aAAaJ,QAAQ,OAAO;IAElC,OAAO,WAAP,GACI,oBAAC;QAAK,GAAGE,KAAK;QAAE,WAAWG,GAAG,2CAA2CJ;OACpEF,iBAAiB,WAAjBA,GACG,oBAACO,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACC,gBAAWA;YAClB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMJ;QACN,UAAUD;QACV,SAASJ;QACT,UAAUH;QAIjBE,cAAc,WAAdA,GACG,oBAACQ,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACE,yBAAQA;YACf,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAML;QACN,UAAUD;QACV,SAASL;QACT,UAAUF;QAIjBC,gBAAgB,WAAhBA,GACG,oBAACS,YAAUA;QACP,oBACI,oBAACC,MAAIA;YACD,oBAAM,oBAACG,2BAASA;YAChB,OAAO;YACP,MAAM;YACN,OAAO;;QAGf,SAAS;QACT,MAAMN;QACN,UAAUD;QACV,SAASN;QACT,UAAUD;;AAK9B"}
@@ -7,7 +7,7 @@ const ItemDescription = ({ className, disabled, item, small, ...props })=>{
7
7
  unitSeparator: " "
8
8
  });
9
9
  return /*#__PURE__*/ react.createElement("div", {
10
- className: cn("flex flex-col gap-xxs overflow-hidden min-w-0", className),
10
+ className: cn("flex flex-col gap-xxs overflow-hidden flex-1 min-w-0", className),
11
11
  ...props
12
12
  }, /*#__PURE__*/ react.createElement(Text, {
13
13
  size: "sm",
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/ItemDescription.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemDescription.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { Text } from \"~/Text/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\ninterface ItemDescriptionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n item: FileItemFormatted;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemDescription = ({ className, disabled, item, small, ...props }: ItemDescriptionProps) => {\n const formattedSize = item.size && bytes.format(item.size, { unitSeparator: \" \" });\n\n return (\n <div className={cn(\"flex flex-col gap-xxs overflow-hidden min-w-0\", className)} {...props}>\n <Text\n size=\"sm\"\n as=\"div\"\n className={cn(\n \"truncate overflow-hidden whitespace-nowrap w-full\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-primary\"\n )}\n >\n {item.name}\n </Text>\n {!small && (formattedSize || item.mimeType) && (\n <Text\n size=\"sm\"\n className={cn(\n \"truncate overflow-hidden whitespace-nowrap w-full\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-muted\"\n )}\n >\n {[formattedSize, item.mimeType].filter(Boolean).join(\" - \")}\n </Text>\n )}\n </div>\n );\n};\n\nexport { ItemDescription, type ItemDescriptionProps };\n"],"names":["ItemDescription","className","disabled","item","small","props","formattedSize","bytes","cn","Text","Boolean"],"mappings":";;;;AAYA,MAAMA,kBAAkB,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGC,OAA6B;IACzF,MAAMC,gBAAgBH,KAAK,IAAI,IAAII,MAAM,MAAM,CAACJ,KAAK,IAAI,EAAE;QAAE,eAAe;IAAI;IAEhF,OAAO,WAAP,GACI,oBAAC;QAAI,WAAWK,GAAG,iDAAiDP;QAAa,GAAGI,KAAK;qBACrF,oBAACI,MAAIA;QACD,MAAK;QACL,IAAG;QACH,WAAWD,GACP,qDACAN,WAAW,0BAA0B;OAGxCC,KAAK,IAAI,GAEb,CAACC,SAAUE,CAAAA,iBAAiBH,KAAK,QAAO,mBACrC,oBAACM,MAAIA;QACD,MAAK;QACL,WAAWD,GACP,qDACAN,WAAW,0BAA0B;OAGxC;QAACI;QAAeH,KAAK,QAAQ;KAAC,CAAC,MAAM,CAACO,SAAS,IAAI,CAAC;AAKzE"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/ItemDescription.js","sources":["../../../../../src/FilePicker/primitives/components/previews/ItemDescription.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { Text } from \"~/Text/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\ninterface ItemDescriptionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n item: FileItemFormatted;\n disabled?: boolean;\n small?: boolean;\n}\n\nconst ItemDescription = ({ className, disabled, item, small, ...props }: ItemDescriptionProps) => {\n const formattedSize = item.size && bytes.format(item.size, { unitSeparator: \" \" });\n\n return (\n <div\n className={cn(\"flex flex-col gap-xxs overflow-hidden flex-1 min-w-0\", className)}\n {...props}\n >\n <Text\n size=\"sm\"\n as=\"div\"\n className={cn(\n \"truncate overflow-hidden whitespace-nowrap w-full\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-primary\"\n )}\n >\n {item.name}\n </Text>\n {!small && (formattedSize || item.mimeType) && (\n <Text\n size=\"sm\"\n className={cn(\n \"truncate overflow-hidden whitespace-nowrap w-full\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-muted\"\n )}\n >\n {[formattedSize, item.mimeType].filter(Boolean).join(\" - \")}\n </Text>\n )}\n </div>\n );\n};\n\nexport { ItemDescription, type ItemDescriptionProps };\n"],"names":["ItemDescription","className","disabled","item","small","props","formattedSize","bytes","cn","Text","Boolean"],"mappings":";;;;AAYA,MAAMA,kBAAkB,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGC,OAA6B;IACzF,MAAMC,gBAAgBH,KAAK,IAAI,IAAII,MAAM,MAAM,CAACJ,KAAK,IAAI,EAAE;QAAE,eAAe;IAAI;IAEhF,OAAO,WAAP,GACI,oBAAC;QACG,WAAWK,GAAG,wDAAwDP;QACrE,GAAGI,KAAK;qBAET,oBAACI,MAAIA;QACD,MAAK;QACL,IAAG;QACH,WAAWD,GACP,qDACAN,WAAW,0BAA0B;OAGxCC,KAAK,IAAI,GAEb,CAACC,SAAUE,CAAAA,iBAAiBH,KAAK,QAAO,mBACrC,oBAACM,MAAIA;QACD,MAAK;QACL,WAAWD,GACP,qDACAN,WAAW,0BAA0B;OAGxC;QAACI;QAAeH,KAAK,QAAQ;KAAC,CAAC,MAAM,CAACO,SAAS,IAAI,CAAC;AAKzE"}
@@ -1,9 +1,5 @@
1
1
  import React from "react";
2
2
  import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
3
3
  type FileTypeProps = Pick<FileItemFormatted, "mimeType" | "name">;
4
- /**
5
- * The stand-in for a file that cannot be shown as a picture: an icon of its format, falling back
6
- * to a generic one for anything unrecognised.
7
- */
8
4
  declare const FileType: ({ mimeType, name }: FileTypeProps) => React.JSX.Element;
9
5
  export { FileType, type FileTypeProps };
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/FileType.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/FileType.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\nimport csvThumb from \"../assets/csv.svg\";\nimport docThumb from \"../assets/doc.svg\";\nimport docxThumb from \"../assets/docx.svg\";\nimport fileThumb from \"../assets/file.svg\";\nimport pdfThumb from \"../assets/pdf.svg\";\nimport pptThumb from \"../assets/ppt.svg\";\nimport pptxThumb from \"../assets/pptx.svg\";\nimport txtThumb from \"../assets/txt.svg\";\nimport xlsThumb from \"../assets/xls.svg\";\nimport xlsxThumb from \"../assets/xlsx.svg\";\n\ntype FileTypeProps = Pick<FileItemFormatted, \"mimeType\" | \"name\">;\n\n/**\n * The stand-in for a file that cannot be shown as a picture: an icon of its format, falling back\n * to a generic one for anything unrecognised.\n */\nconst FileType = ({ mimeType = \"\", name }: FileTypeProps) => {\n const getMimeTypeSrc = (mimeType: string) => {\n switch (mimeType) {\n case \"text/csv\": // .csv\n return csvThumb;\n case \"application/msword\": // .doc\n return docThumb;\n case \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": // .docx\n return docxThumb;\n case \"application/pdf\": // .pdf\n return pdfThumb;\n case \"application/vnd.ms-powerpoint\": // .ppt\n return pptThumb;\n case \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": // .pptx\n return pptxThumb;\n case \"text/plain\": // .txt\n return txtThumb;\n case \"application/vnd.ms-excel\": // .xls\n return xlsThumb;\n case \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": // .xlsx\n return xlsxThumb;\n default:\n return fileThumb;\n }\n };\n\n return (\n <img\n src={getMimeTypeSrc(mimeType)}\n alt={name}\n className=\"size-full object-contain p-sm-extra\"\n />\n );\n};\n\nexport { FileType, type FileTypeProps };\n"],"names":["FileType","mimeType","name","getMimeTypeSrc","csvThumb","docThumb","docxThumb","pdfThumb","pptThumb","pptxThumb","txtThumb","xlsThumb","xlsxThumb","fileThumb"],"mappings":";;;;;;;;;;;AAoBA,MAAMA,WAAW,CAAC,EAAEC,WAAW,EAAE,EAAEC,IAAI,EAAiB;IACpD,MAAMC,iBAAiB,CAACF;QACpB,OAAQA;YACJ,KAAK;gBACD,OAAOG;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX;gBACI,OAAOC;QACf;IACJ;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,KAAKV,eAAeF;QACpB,KAAKC;QACL,WAAU;;AAGtB"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/FileType.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/FileType.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\nimport csvThumb from \"../assets/csv.svg\";\nimport docThumb from \"../assets/doc.svg\";\nimport docxThumb from \"../assets/docx.svg\";\nimport fileThumb from \"../assets/file.svg\";\nimport pdfThumb from \"../assets/pdf.svg\";\nimport pptThumb from \"../assets/ppt.svg\";\nimport pptxThumb from \"../assets/pptx.svg\";\nimport txtThumb from \"../assets/txt.svg\";\nimport xlsThumb from \"../assets/xls.svg\";\nimport xlsxThumb from \"../assets/xlsx.svg\";\n\ntype FileTypeProps = Pick<FileItemFormatted, \"mimeType\" | \"name\">;\n\nconst FileType = ({ mimeType = \"\", name }: FileTypeProps) => {\n const getMimeTypeSrc = (mimeType: string) => {\n switch (mimeType) {\n case \"text/csv\": // .csv\n return csvThumb;\n case \"application/msword\": // .doc\n return docThumb;\n case \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\": // .docx\n return docxThumb;\n case \"application/pdf\": // .pdf\n return pdfThumb;\n case \"application/vnd.ms-powerpoint\": // .ppt\n return pptThumb;\n case \"application/vnd.openxmlformats-officedocument.presentationml.presentation\": // .pptx\n return pptxThumb;\n case \"text/plain\": // .txt\n return txtThumb;\n case \"application/vnd.ms-excel\": // .xls\n return xlsThumb;\n case \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": // .xlsx\n return xlsxThumb;\n default:\n return fileThumb;\n }\n };\n\n return (\n <img\n src={getMimeTypeSrc(mimeType)}\n alt={name}\n className=\"size-full object-contain p-sm-extra\"\n />\n );\n};\n\nexport { FileType, type FileTypeProps };\n"],"names":["FileType","mimeType","name","getMimeTypeSrc","csvThumb","docThumb","docxThumb","pdfThumb","pptThumb","pptxThumb","txtThumb","xlsThumb","xlsxThumb","fileThumb"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,WAAW,CAAC,EAAEC,WAAW,EAAE,EAAEC,IAAI,EAAiB;IACpD,MAAMC,iBAAiB,CAACF;QACpB,OAAQA;YACJ,KAAK;gBACD,OAAOG;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX,KAAK;gBACD,OAAOC;YACX;gBACI,OAAOC;QACf;IACJ;IAEA,OAAO,WAAP,GACI,oBAAC;QACG,KAAKV,eAAeF;QACpB,KAAKC;QACL,WAAU;;AAGtB"}
@@ -1,8 +1,5 @@
1
1
  import React from "react";
2
2
  import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
3
3
  type PlaceholderProps = Pick<FileItemFormatted, "name">;
4
- /**
5
- * Shown when the caller asks for a placeholder rather than the file's own preview.
6
- */
7
4
  declare const Placeholder: ({ name }: PlaceholderProps) => React.JSX.Element;
8
5
  export { Placeholder, type PlaceholderProps };
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as PlaceholderIcon } from \"@webiny/icons/image.svg\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\n\ntype PlaceholderProps = Pick<FileItemFormatted, \"name\">;\n\n/**\n * Shown when the caller asks for a placeholder rather than the file's own preview.\n */\nconst Placeholder = ({ name }: PlaceholderProps) => {\n return (\n <div className={\"size-full flex justify-center items-center bg-transparent\"}>\n <Icon icon={<PlaceholderIcon />} label={name} size={\"lg\"} color={\"neutral-light\"} />\n </div>\n );\n};\n\nexport { Placeholder, type PlaceholderProps };\n"],"names":["Placeholder","name","Icon","PlaceholderIcon"],"mappings":";;;AAUA,MAAMA,cAAc,CAAC,EAAEC,IAAI,EAAoB,GACpC,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACC,MAAIA;QAAC,oBAAM,oBAACC,gBAAeA;QAAK,OAAOF;QAAM,MAAM;QAAM,OAAO"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Placeholder.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Placeholder.tsx"],"sourcesContent":["import React from \"react\";\nimport { ReactComponent as PlaceholderIcon } from \"@webiny/icons/image.svg\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { Icon } from \"~/Icon/index.js\";\n\ntype PlaceholderProps = Pick<FileItemFormatted, \"name\">;\n\nconst Placeholder = ({ name }: PlaceholderProps) => {\n return (\n <div className={\"size-full flex justify-center items-center bg-transparent\"}>\n <Icon icon={<PlaceholderIcon />} label={name} size={\"lg\"} color={\"neutral-light\"} />\n </div>\n );\n};\n\nexport { Placeholder, type PlaceholderProps };\n"],"names":["Placeholder","name","Icon","PlaceholderIcon"],"mappings":";;;AAOA,MAAMA,cAAc,CAAC,EAAEC,IAAI,EAAoB,GACpC,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACC,MAAIA;QAAC,oBAAM,oBAACC,gBAAeA;QAAK,OAAOF;QAAM,MAAM;QAAM,OAAO"}
@@ -2,22 +2,28 @@ import React from "react";
2
2
  import type { FilePreviewDefaultProps } from "../../types.js";
3
3
  type RichItemPreviewProps = FilePreviewDefaultProps & {
4
4
  preview?: "thumbnail" | "file-type" | "placeholder";
5
+ /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */
6
+ renderImage?: (args: {
7
+ url: string;
8
+ name: string;
9
+ }) => React.ReactNode;
5
10
  };
6
- declare const RichItemPreview: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element) & {
7
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element;
11
+ declare const DecoratableRichItemPreview: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props }: RichItemPreviewProps) => React.JSX.Element;
12
+ declare const RichItemPreview: typeof DecoratableRichItemPreview & {
13
+ original: typeof DecoratableRichItemPreview;
8
14
  originalName: string;
9
15
  displayName: string;
10
16
  } & {
11
- original: (({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element) & {
12
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element;
17
+ original: typeof DecoratableRichItemPreview & {
18
+ original: typeof DecoratableRichItemPreview;
13
19
  originalName: string;
14
20
  displayName: string;
15
21
  };
16
22
  originalName: string;
17
23
  displayName: string;
18
24
  } & {
19
- createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<(({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element) & {
20
- original: ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props }: RichItemPreviewProps) => React.JSX.Element;
25
+ createDecorator: (decorator: import("@webiny/react-composition/types.js").ComponentDecorator<typeof DecoratableRichItemPreview & {
26
+ original: typeof DecoratableRichItemPreview;
21
27
  originalName: string;
22
28
  displayName: string;
23
29
  }>) => (props: unknown) => React.JSX.Element;
@@ -8,7 +8,7 @@ import { ItemDescription } from "../ItemDescription.js";
8
8
  import { ItemActions } from "../ItemActions.js";
9
9
  import { TruncatedFileName } from "../TruncatedFileName.js";
10
10
  import { previewVariants } from "../variants.js";
11
- const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, ...props })=>{
11
+ const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onReplaceItem, onEditItem, value, variant, preview, renderImage, ...props })=>{
12
12
  const actions = {
13
13
  onRemoveItem,
14
14
  onReplaceItem,
@@ -25,7 +25,7 @@ const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onRepla
25
25
  ].filter(Boolean).join(" - ");
26
26
  return /*#__PURE__*/ react.createElement("div", {
27
27
  "data-testid": "image-preview",
28
- className: cn("@container w-full rounded-md", previewVariants({
28
+ className: cn("w-full rounded-md @container", previewVariants({
29
29
  variant,
30
30
  disabled
31
31
  }), className),
@@ -42,7 +42,8 @@ const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onRepla
42
42
  ...value,
43
43
  variant: "banner",
44
44
  disabled: disabled,
45
- preview: preview
45
+ preview: preview,
46
+ renderImage: renderImage
46
47
  }), /*#__PURE__*/ react.createElement(ThumbnailActions, actions)), /*#__PURE__*/ react.createElement("div", {
47
48
  className: "flex flex-col gap-xxs min-w-0 px-xxs pb-xxs"
48
49
  }, /*#__PURE__*/ react.createElement(TruncatedFileName, {
@@ -60,7 +61,8 @@ const DecoratableRichItemPreview = ({ className, disabled, onRemoveItem, onRepla
60
61
  }, /*#__PURE__*/ react.createElement(RichItemThumbnail, {
61
62
  ...value,
62
63
  disabled: disabled,
63
- preview: preview
64
+ preview: preview,
65
+ renderImage: renderImage
64
66
  })), /*#__PURE__*/ react.createElement(ItemDescription, {
65
67
  item: value,
66
68
  disabled: disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { Text } from \"~/Text/index.js\";\nimport { RichItemThumbnail } from \"./RichItemThumbnail.js\";\nimport { ThumbnailActions } from \"./ThumbnailActions.js\";\nimport { ItemDescription } from \"../ItemDescription.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\nimport { TruncatedFileName } from \"../TruncatedFileName.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\n\ntype RichItemPreviewProps = FilePreviewDefaultProps & {\n preview?: \"thumbnail\" | \"file-type\" | \"placeholder\";\n};\n\nconst DecoratableRichItemPreview = ({\n className,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem,\n value,\n variant,\n preview,\n ...props\n}: RichItemPreviewProps) => {\n const actions = { onRemoveItem, onReplaceItem, onEditItem, disabled };\n\n // Type and size share a line of their own beneath the name, so the name gets the full width\n // and the two secondary facts read as one group rather than crowding it.\n const formattedSize = value.size\n ? bytes.format(value.size, { unitSeparator: \" \", decimalPlaces: 0 })\n : \"\";\n const details = [value.mimeType, formattedSize].filter(Boolean).join(\" - \");\n\n return (\n <div\n data-testid=\"image-preview\"\n className={cn(\n \"@container w-full rounded-md\",\n previewVariants({ variant, disabled }),\n className\n )}\n {...props}\n >\n {/* Two layouts, chosen by the preview's own width rather than the viewport's, because\n the same component renders in a ~200px sidebar and in a wide form field. Below\n 280px a side-by-side row cannot give the file name a readable share of the width,\n so the thumbnail goes full width with the name and details beneath it, and the\n actions move onto the thumbnail rather than costing a row of their own. */}\n <div data-role=\"select-image\" className={\"@min-[280px]:hidden\"}>\n <div className={\"flex flex-col gap-xs p-xs\"}>\n <div className={\"group relative cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail\n {...value}\n variant={\"banner\"}\n disabled={disabled}\n preview={preview}\n />\n <ThumbnailActions {...actions} />\n </div>\n\n <div className={\"flex flex-col gap-xxs min-w-0 px-xxs pb-xxs\"}>\n <TruncatedFileName\n name={value.name}\n className={disabled ? \"text-neutral-disabled\" : \"text-neutral-primary\"}\n />\n {details ? (\n <Text\n size=\"sm\"\n className={cn(\n \"truncate\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-muted\"\n )}\n >\n {details}\n </Text>\n ) : null}\n </div>\n </div>\n </div>\n\n <div\n data-role=\"select-image\"\n className={\"hidden @min-[280px]:flex items-center gap-sm-extra min-w-0\"}\n >\n <div className={\"shrink-0 cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail {...value} disabled={disabled} preview={preview} />\n </div>\n\n <ItemDescription\n item={value}\n disabled={disabled}\n onClick={onReplaceItem}\n className={\"grow basis-0 cursor-pointer\"}\n />\n\n <ItemActions {...actions} className={\"ml-auto pr-sm-extra\"} />\n </div>\n </div>\n );\n};\n\nconst RichItemPreview = makeDecoratable(\"RichItemPreview\", DecoratableRichItemPreview);\n\nexport { RichItemPreview, type RichItemPreviewProps };\n"],"names":["DecoratableRichItemPreview","className","disabled","onRemoveItem","onReplaceItem","onEditItem","value","variant","preview","props","actions","formattedSize","bytes","details","Boolean","cn","previewVariants","RichItemThumbnail","ThumbnailActions","TruncatedFileName","Text","ItemDescription","ItemActions","RichItemPreview","makeDecoratable"],"mappings":";;;;;;;;;;AAgBA,MAAMA,6BAA6B,CAAC,EAChCC,SAAS,EACTC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,OAAO,EACP,GAAGC,OACgB;IACnB,MAAMC,UAAU;QAAEP;QAAcC;QAAeC;QAAYH;IAAS;IAIpE,MAAMS,gBAAgBL,MAAM,IAAI,GAC1BM,MAAM,MAAM,CAACN,MAAM,IAAI,EAAE;QAAE,eAAe;QAAK,eAAe;IAAE,KAChE;IACN,MAAMO,UAAU;QAACP,MAAM,QAAQ;QAAEK;KAAc,CAAC,MAAM,CAACG,SAAS,IAAI,CAAC;IAErE,OAAO,WAAP,GACI,oBAAC;QACG,eAAY;QACZ,WAAWC,GACP,gCACAC,gBAAgB;YAAET;YAASL;QAAS,IACpCD;QAEH,GAAGQ,KAAK;qBAOT,oBAAC;QAAI,aAAU;QAAe,WAAW;qBACrC,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;QAAiC,SAASL;qBACtD,oBAACa,mBAAiBA;QACb,GAAGX,KAAK;QACT,SAAS;QACT,UAAUJ;QACV,SAASM;sBAEb,oBAACU,kBAAqBR,WAAAA,WAAAA,GAG1B,oBAAC;QAAI,WAAW;qBACZ,oBAACS,mBAAiBA;QACd,MAAMb,MAAM,IAAI;QAChB,WAAWJ,WAAW,0BAA0B;QAEnDW,UAAU,WAAVA,GACG,oBAACO,MAAIA;QACD,MAAK;QACL,WAAWL,GACP,YACAb,WAAW,0BAA0B;OAGxCW,WAEL,uBAKhB,oBAAC;QACG,aAAU;QACV,WAAW;qBAEX,oBAAC;QAAI,WAAW;QAA2B,SAAST;qBAChD,oBAACa,mBAAiBA;QAAE,GAAGX,KAAK;QAAE,UAAUJ;QAAU,SAASM;uBAG/D,oBAACa,iBAAeA;QACZ,MAAMf;QACN,UAAUJ;QACV,SAASE;QACT,WAAW;sBAGf,oBAACkB,aAAWA;QAAE,GAAGZ,OAAO;QAAE,WAAW;;AAIrD;AAEA,MAAMa,kBAAkBC,gBAAgB,mBAAmBxB"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemPreview.tsx"],"sourcesContent":["import React from \"react\";\nimport bytes from \"bytes\";\nimport { cn, makeDecoratable } from \"~/utils.js\";\nimport { Text } from \"~/Text/index.js\";\nimport { RichItemThumbnail } from \"./RichItemThumbnail.js\";\nimport { ThumbnailActions } from \"./ThumbnailActions.js\";\nimport { ItemDescription } from \"../ItemDescription.js\";\nimport { ItemActions } from \"~/FilePicker/primitives/components/previews/ItemActions.js\";\nimport { TruncatedFileName } from \"../TruncatedFileName.js\";\nimport { previewVariants } from \"../variants.js\";\nimport type { FilePreviewDefaultProps } from \"../../types.js\";\n\ntype RichItemPreviewProps = FilePreviewDefaultProps & {\n preview?: \"thumbnail\" | \"file-type\" | \"placeholder\";\n /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n};\n\nconst DecoratableRichItemPreview = ({\n className,\n disabled,\n onRemoveItem,\n onReplaceItem,\n onEditItem,\n value,\n variant,\n preview,\n renderImage,\n ...props\n}: RichItemPreviewProps) => {\n const actions = { onRemoveItem, onReplaceItem, onEditItem, disabled };\n\n const formattedSize = value.size\n ? bytes.format(value.size, { unitSeparator: \" \", decimalPlaces: 0 })\n : \"\";\n const details = [value.mimeType, formattedSize].filter(Boolean).join(\" - \");\n\n return (\n <div\n data-testid=\"image-preview\"\n className={cn(\n \"w-full rounded-md @container\",\n previewVariants({ variant, disabled }),\n className\n )}\n {...props}\n >\n {/* Stacked layout for narrow containers (below 280px). */}\n <div data-role=\"select-image\" className={\"@min-[280px]:hidden\"}>\n <div className={\"flex flex-col gap-xs p-xs\"}>\n <div className={\"group relative cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail\n {...value}\n variant={\"banner\"}\n disabled={disabled}\n preview={preview}\n renderImage={renderImage}\n />\n <ThumbnailActions {...actions} />\n </div>\n\n <div className={\"flex flex-col gap-xxs min-w-0 px-xxs pb-xxs\"}>\n <TruncatedFileName\n name={value.name}\n className={disabled ? \"text-neutral-disabled\" : \"text-neutral-primary\"}\n />\n {details ? (\n <Text\n size=\"sm\"\n className={cn(\n \"truncate\",\n disabled ? \"text-neutral-disabled\" : \"text-neutral-muted\"\n )}\n >\n {details}\n </Text>\n ) : null}\n </div>\n </div>\n </div>\n\n {/* Side-by-side layout for wider containers (280px+). */}\n <div\n data-role=\"select-image\"\n className={\"hidden @min-[280px]:flex items-center gap-sm-extra min-w-0\"}\n >\n <div className={\"shrink-0 cursor-pointer\"} onClick={onReplaceItem}>\n <RichItemThumbnail\n {...value}\n disabled={disabled}\n preview={preview}\n renderImage={renderImage}\n />\n </div>\n\n <ItemDescription\n item={value}\n disabled={disabled}\n onClick={onReplaceItem}\n className={\"grow basis-0 cursor-pointer\"}\n />\n\n <ItemActions {...actions} className={\"ml-auto pr-sm-extra\"} />\n </div>\n </div>\n );\n};\n\nconst RichItemPreview = makeDecoratable(\"RichItemPreview\", DecoratableRichItemPreview);\n\nexport { RichItemPreview, type RichItemPreviewProps };\n"],"names":["DecoratableRichItemPreview","className","disabled","onRemoveItem","onReplaceItem","onEditItem","value","variant","preview","renderImage","props","actions","formattedSize","bytes","details","Boolean","cn","previewVariants","RichItemThumbnail","ThumbnailActions","TruncatedFileName","Text","ItemDescription","ItemActions","RichItemPreview","makeDecoratable"],"mappings":";;;;;;;;;;AAkBA,MAAMA,6BAA6B,CAAC,EAChCC,SAAS,EACTC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,WAAW,EACX,GAAGC,OACgB;IACnB,MAAMC,UAAU;QAAER;QAAcC;QAAeC;QAAYH;IAAS;IAEpE,MAAMU,gBAAgBN,MAAM,IAAI,GAC1BO,MAAM,MAAM,CAACP,MAAM,IAAI,EAAE;QAAE,eAAe;QAAK,eAAe;IAAE,KAChE;IACN,MAAMQ,UAAU;QAACR,MAAM,QAAQ;QAAEM;KAAc,CAAC,MAAM,CAACG,SAAS,IAAI,CAAC;IAErE,OAAO,WAAP,GACI,oBAAC;QACG,eAAY;QACZ,WAAWC,GACP,gCACAC,gBAAgB;YAAEV;YAASL;QAAS,IACpCD;QAEH,GAAGS,KAAK;qBAGT,oBAAC;QAAI,aAAU;QAAe,WAAW;qBACrC,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,WAAW;QAAiC,SAASN;qBACtD,oBAACc,mBAAiBA;QACb,GAAGZ,KAAK;QACT,SAAS;QACT,UAAUJ;QACV,SAASM;QACT,aAAaC;sBAEjB,oBAACU,kBAAqBR,WAAAA,WAAAA,GAG1B,oBAAC;QAAI,WAAW;qBACZ,oBAACS,mBAAiBA;QACd,MAAMd,MAAM,IAAI;QAChB,WAAWJ,WAAW,0BAA0B;QAEnDY,UAAU,WAAVA,GACG,oBAACO,MAAIA;QACD,MAAK;QACL,WAAWL,GACP,YACAd,WAAW,0BAA0B;OAGxCY,WAEL,uBAMhB,oBAAC;QACG,aAAU;QACV,WAAW;qBAEX,oBAAC;QAAI,WAAW;QAA2B,SAASV;qBAChD,oBAACc,mBAAiBA;QACb,GAAGZ,KAAK;QACT,UAAUJ;QACV,SAASM;QACT,aAAaC;uBAIrB,oBAACa,iBAAeA;QACZ,MAAMhB;QACN,UAAUJ;QACV,SAASE;QACT,WAAW;sBAGf,oBAACmB,aAAWA;QAAE,GAAGZ,OAAO;QAAE,WAAW;;AAIrD;AAEA,MAAMa,kBAAkBC,gBAAgB,mBAAmBzB"}
@@ -9,6 +9,11 @@ type RichItemThumbnailProps = Omit<React.HTMLAttributes<HTMLDivElement>, "childr
9
9
  * width of a stacked layout, where the panel is too narrow to afford a column for it.
10
10
  */
11
11
  variant?: "tile" | "banner";
12
+ /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */
13
+ renderImage?: (args: {
14
+ url: string;
15
+ name: string;
16
+ }) => React.ReactNode;
12
17
  };
13
- declare const RichItemThumbnail: ({ url, name, className, mimeType, preview, disabled, variant }: RichItemThumbnailProps) => React.JSX.Element;
18
+ declare const RichItemThumbnail: ({ url, name, className, mimeType, preview, disabled, variant, renderImage }: RichItemThumbnailProps) => React.JSX.Element;
14
19
  export { RichItemThumbnail, type RichItemThumbnailProps };
@@ -3,14 +3,15 @@ import { cn } from "../../../../../utils.js";
3
3
  import { FileType } from "./FileType.js";
4
4
  import { Placeholder } from "./Placeholder.js";
5
5
  import { Thumbnail } from "./Thumbnail.js";
6
- const RichItemThumbnail = ({ url, name, className, mimeType, preview, disabled, variant = "tile" })=>{
6
+ const RichItemThumbnail = ({ url, name, className, mimeType, preview, disabled, variant = "tile", renderImage })=>{
7
7
  const isImage = mimeType?.startsWith("image/");
8
8
  return /*#__PURE__*/ react.createElement("div", {
9
9
  className: cn("rounded-sm overflow-hidden relative", "banner" === variant ? "w-full h-[96px]" : "size-[56px] m-xs", disabled && "[&_img]:filter [&_img]:grayscale [&_img]:opacity-50", className)
10
10
  }, "thumbnail" === preview || isImage ? /*#__PURE__*/ react.createElement(Thumbnail, {
11
11
  url: url,
12
12
  name: name,
13
- fit: "banner" === variant ? "contain" : "cover"
13
+ fit: "banner" === variant ? "contain" : "cover",
14
+ renderImage: renderImage
14
15
  }) : "placeholder" === preview ? /*#__PURE__*/ react.createElement(Placeholder, {
15
16
  name: name
16
17
  }) : /*#__PURE__*/ react.createElement(FileType, {
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { RichItemPreviewProps } from \"~/FilePicker/primitives/components/index.js\";\nimport { FileType } from \"./FileType.js\";\nimport { Placeholder } from \"./Placeholder.js\";\nimport { Thumbnail } from \"./Thumbnail.js\";\n\ntype RichItemThumbnailProps = Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> &\n FileItemFormatted & {\n preview?: RichItemPreviewProps[\"preview\"];\n disabled?: boolean;\n /**\n * `tile` is the fixed square that sits beside the file details; `banner` spans the full\n * width of a stacked layout, where the panel is too narrow to afford a column for it.\n */\n variant?: \"tile\" | \"banner\";\n };\n\nconst RichItemThumbnail = ({\n url,\n name,\n className,\n mimeType,\n preview,\n disabled,\n variant = \"tile\"\n}: RichItemThumbnailProps) => {\n const isImage = mimeType?.startsWith(\"image/\");\n\n return (\n <div\n className={cn(\n \"rounded-sm overflow-hidden relative\",\n variant === \"banner\" ? \"w-full h-[96px]\" : \"size-[56px] m-xs\",\n disabled && \"[&_img]:filter [&_img]:grayscale [&_img]:opacity-50\",\n className\n )}\n >\n {preview === \"thumbnail\" || isImage ? (\n <Thumbnail url={url} name={name} fit={variant === \"banner\" ? \"contain\" : \"cover\"} />\n ) : preview === \"placeholder\" ? (\n <Placeholder name={name} />\n ) : (\n <FileType mimeType={mimeType} name={name} />\n )}\n </div>\n );\n};\n\nexport { RichItemThumbnail, type RichItemThumbnailProps };\n"],"names":["RichItemThumbnail","url","name","className","mimeType","preview","disabled","variant","isImage","cn","Thumbnail","Placeholder","FileType"],"mappings":";;;;;AAmBA,MAAMA,oBAAoB,CAAC,EACvBC,GAAG,EACHC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRC,UAAU,MAAM,EACK;IACrB,MAAMC,UAAUJ,UAAU,WAAW;IAErC,OAAO,WAAP,GACI,oBAAC;QACG,WAAWK,GACP,uCACAF,AAAY,aAAZA,UAAuB,oBAAoB,oBAC3CD,YAAY,uDACZH;OAGHE,AAAY,gBAAZA,WAA2BG,UAAU,WAAVA,GACxB,oBAACE,WAASA;QAAC,KAAKT;QAAK,MAAMC;QAAM,KAAKK,AAAY,aAAZA,UAAuB,YAAY;SACzEF,AAAY,kBAAZA,UAA4B,WAAhB,GACZ,oBAACM,aAAWA;QAAC,MAAMT;uBAEnB,oBAACU,UAAQA;QAAC,UAAUR;QAAU,MAAMF;;AAIpD"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/RichItemThumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\nimport { cn } from \"~/utils.js\";\nimport type { RichItemPreviewProps } from \"~/FilePicker/primitives/components/index.js\";\nimport { FileType } from \"./FileType.js\";\nimport { Placeholder } from \"./Placeholder.js\";\nimport { Thumbnail } from \"./Thumbnail.js\";\n\ntype RichItemThumbnailProps = Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> &\n FileItemFormatted & {\n preview?: RichItemPreviewProps[\"preview\"];\n disabled?: boolean;\n /**\n * `tile` is the fixed square that sits beside the file details; `banner` spans the full\n * width of a stacked layout, where the panel is too narrow to afford a column for it.\n */\n variant?: \"tile\" | \"banner\";\n /** Optional custom image renderer for the thumbnail (e.g. a cropped preview). */\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n };\n\nconst RichItemThumbnail = ({\n url,\n name,\n className,\n mimeType,\n preview,\n disabled,\n variant = \"tile\",\n renderImage\n}: RichItemThumbnailProps) => {\n const isImage = mimeType?.startsWith(\"image/\");\n\n return (\n <div\n className={cn(\n \"rounded-sm overflow-hidden relative\",\n variant === \"banner\" ? \"w-full h-[96px]\" : \"size-[56px] m-xs\",\n disabled && \"[&_img]:filter [&_img]:grayscale [&_img]:opacity-50\",\n className\n )}\n >\n {preview === \"thumbnail\" || isImage ? (\n <Thumbnail\n url={url}\n name={name}\n fit={variant === \"banner\" ? \"contain\" : \"cover\"}\n renderImage={renderImage}\n />\n ) : preview === \"placeholder\" ? (\n <Placeholder name={name} />\n ) : (\n <FileType mimeType={mimeType} name={name} />\n )}\n </div>\n );\n};\n\nexport { RichItemThumbnail, type RichItemThumbnailProps };\n"],"names":["RichItemThumbnail","url","name","className","mimeType","preview","disabled","variant","renderImage","isImage","cn","Thumbnail","Placeholder","FileType"],"mappings":";;;;;AAqBA,MAAMA,oBAAoB,CAAC,EACvBC,GAAG,EACHC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRC,UAAU,MAAM,EAChBC,WAAW,EACU;IACrB,MAAMC,UAAUL,UAAU,WAAW;IAErC,OAAO,WAAP,GACI,oBAAC;QACG,WAAWM,GACP,uCACAH,AAAY,aAAZA,UAAuB,oBAAoB,oBAC3CD,YAAY,uDACZH;OAGHE,AAAY,gBAAZA,WAA2BI,UAAU,WAAVA,GACxB,oBAACE,WAASA;QACN,KAAKV;QACL,MAAMC;QACN,KAAKK,AAAY,aAAZA,UAAuB,YAAY;QACxC,aAAaC;SAEjBH,AAAY,kBAAZA,UAA4B,WAAhB,GACZ,oBAACO,aAAWA;QAAC,MAAMV;uBAEnB,oBAACW,UAAQA;QAAC,UAAUT;QAAU,MAAMF;;AAIpD"}
@@ -2,10 +2,10 @@ import React from "react";
2
2
  import type { FileItemFormatted } from "../../../../../FilePicker/index.js";
3
3
  type ThumbnailProps = Pick<FileItemFormatted, "url" | "name"> & {
4
4
  fit: "cover" | "contain";
5
+ renderImage?: (args: {
6
+ url: string;
7
+ name: string;
8
+ }) => React.ReactNode;
5
9
  };
6
- /**
7
- * The file's own image. `cover` fills its box and crops what does not fit, which suits the small
8
- * square tile; `contain` shows the whole picture, which suits the banner.
9
- */
10
- declare const Thumbnail: ({ url, name, fit }: ThumbnailProps) => React.JSX.Element;
10
+ declare const Thumbnail: ({ url, name, fit, renderImage }: ThumbnailProps) => React.JSX.Element;
11
11
  export { Thumbnail, type ThumbnailProps };
@@ -1,15 +1,19 @@
1
1
  import react from "react";
2
- const Thumbnail = ({ url, name, fit })=>{
2
+ const Thumbnail = ({ url, name, fit, renderImage })=>{
3
+ const customImage = "function" == typeof renderImage ? renderImage({
4
+ url,
5
+ name
6
+ }) : false;
3
7
  if ("contain" === fit) return /*#__PURE__*/ react.createElement("div", {
4
8
  className: "size-full p-xs bg-neutral-muted flex items-center justify-center"
5
- }, /*#__PURE__*/ react.createElement("img", {
9
+ }, customImage || /*#__PURE__*/ react.createElement("img", {
6
10
  src: url,
7
11
  alt: name,
8
12
  className: "max-h-full max-w-full rounded-xs"
9
13
  }));
10
14
  return /*#__PURE__*/ react.createElement("div", {
11
15
  className: "size-full bg-neutral-muted"
12
- }, /*#__PURE__*/ react.createElement("img", {
16
+ }, customImage || /*#__PURE__*/ react.createElement("img", {
13
17
  src: url,
14
18
  alt: name,
15
19
  className: "size-full object-cover"
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\ntype ThumbnailProps = Pick<FileItemFormatted, \"url\" | \"name\"> & {\n fit: \"cover\" | \"contain\";\n};\n\n/**\n * The file's own image. `cover` fills its box and crops what does not fit, which suits the small\n * square tile; `contain` shows the whole picture, which suits the banner.\n */\nconst Thumbnail = ({ url, name, fit }: ThumbnailProps) => {\n if (fit === \"contain\") {\n return (\n <div className={\"size-full p-xs bg-neutral-muted flex items-center justify-center\"}>\n {/*\n Capping the element with max-width/max-height, rather than stretching it and\n letting `object-contain` letterbox the picture inside it, keeps the element box\n and the visible picture the same rectangle. That is what lets the corners round\n at all: `border-radius` clips the element, so on a letterboxed image it would\n trim empty space and leave the picture square.\n */}\n <img src={url} alt={name} className={\"max-h-full max-w-full rounded-xs\"} />\n </div>\n );\n }\n\n return (\n <div className={\"size-full bg-neutral-muted\"}>\n <img src={url} alt={name} className={\"size-full object-cover\"} />\n </div>\n );\n};\n\nexport { Thumbnail, type ThumbnailProps };\n"],"names":["Thumbnail","url","name","fit"],"mappings":";AAWA,MAAMA,YAAY,CAAC,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAkB;IACjD,IAAIA,AAAQ,cAARA,KACA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBAQZ,oBAAC;QAAI,KAAKF;QAAK,KAAKC;QAAM,WAAW;;IAKjD,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAAC;QAAI,KAAKD;QAAK,KAAKC;QAAM,WAAW;;AAGjD"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/Thumbnail.tsx"],"sourcesContent":["import React from \"react\";\nimport type { FileItemFormatted } from \"~/FilePicker/index.js\";\n\ntype ThumbnailProps = Pick<FileItemFormatted, \"url\" | \"name\"> & {\n fit: \"cover\" | \"contain\";\n renderImage?: (args: { url: string; name: string }) => React.ReactNode;\n};\n\nconst Thumbnail = ({ url, name, fit, renderImage }: ThumbnailProps) => {\n const customImage = typeof renderImage === \"function\" ? renderImage({ url, name }) : false;\n\n if (fit === \"contain\") {\n return (\n <div className={\"size-full p-xs bg-neutral-muted flex items-center justify-center\"}>\n {customImage || (\n <img src={url} alt={name} className={\"max-h-full max-w-full rounded-xs\"} />\n )}\n </div>\n );\n }\n\n return (\n <div className={\"size-full bg-neutral-muted\"}>\n {customImage || <img src={url} alt={name} className={\"size-full object-cover\"} />}\n </div>\n );\n};\n\nexport { Thumbnail, type ThumbnailProps };\n"],"names":["Thumbnail","url","name","fit","renderImage","customImage"],"mappings":";AAQA,MAAMA,YAAY,CAAC,EAAEC,GAAG,EAAEC,IAAI,EAAEC,GAAG,EAAEC,WAAW,EAAkB;IAC9D,MAAMC,cAAc,AAAuB,cAAvB,OAAOD,cAA6BA,YAAY;QAAEH;QAAKC;IAAK,KAAK;IAErF,IAAIC,AAAQ,cAARA,KACA,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXE,eAAe,WAAfA,GACG,oBAAC;QAAI,KAAKJ;QAAK,KAAKC;QAAM,WAAW;;IAMrD,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXG,eAAe,WAAfA,GAAe,oBAAC;QAAI,KAAKJ;QAAK,KAAKC;QAAM,WAAW;;AAGjE"}
@@ -6,10 +6,5 @@ interface ThumbnailActionsProps {
6
6
  disabled?: boolean;
7
7
  className?: string;
8
8
  }
9
- /**
10
- * The file's actions laid over its thumbnail and revealed on hover, mirroring the File Manager's
11
- * grid so a file offers the same affordances wherever it is shown. Requires `group` and
12
- * `relative` on the element wrapping the thumbnail.
13
- */
14
9
  declare const ThumbnailActions: ({ className, disabled, onEditItem, onRemoveItem, onReplaceItem }: ThumbnailActionsProps) => React.JSX.Element;
15
10
  export { ThumbnailActions, type ThumbnailActionsProps };
@@ -1 +1 @@
1
- {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ActionProps {\n icon: React.JSX.Element;\n label: string;\n onAction: () => void;\n disabled?: boolean;\n}\n\nconst Action = ({ icon, label, onAction, disabled }: ActionProps) => {\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n // The thumbnail behind these opens the file manager when clicked, so without this a\n // click on Remove would replace the file as well as remove it.\n event.stopPropagation();\n onAction();\n },\n [onAction]\n );\n\n return (\n <Tooltip\n content={label}\n trigger={\n <IconButton\n variant={\"tertiary\"}\n size={\"sm\"}\n icon={icon}\n onClick={onClick}\n disabled={disabled}\n />\n }\n />\n );\n};\n\ninterface ThumbnailActionsProps {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * The file's actions laid over its thumbnail and revealed on hover, mirroring the File Manager's\n * grid so a file offers the same affordances wherever it is shown. Requires `group` and\n * `relative` on the element wrapping the thumbnail.\n */\nconst ThumbnailActions = ({\n className,\n disabled,\n onEditItem,\n onRemoveItem,\n onReplaceItem\n}: ThumbnailActionsProps) => {\n return (\n <div\n className={cn(\n \"invisible group-hover:visible\",\n \"flex items-center gap-xxs\",\n \"absolute top-xs-plus right-xs-plus\",\n className\n )}\n >\n {onReplaceItem && (\n <Action\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n onAction={onReplaceItem}\n disabled={disabled}\n />\n )}\n {onEditItem && (\n <Action\n icon={<EditIcon />}\n label={\"Edit\"}\n onAction={onEditItem}\n disabled={disabled}\n />\n )}\n {onRemoveItem && (\n <Action\n icon={<TrashIcon />}\n label={\"Remove\"}\n onAction={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ThumbnailActions, type ThumbnailActionsProps };\n"],"names":["Action","icon","label","onAction","disabled","onClick","useCallback","event","Tooltip","IconButton","ThumbnailActions","className","onEditItem","onRemoveItem","onReplaceItem","cn","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAeA,MAAMA,SAAS,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAe;IAC5D,MAAMC,UAAUC,YACZ,CAACC;QAGGA,MAAM,eAAe;QACrBJ;IACJ,GACA;QAACA;KAAS;IAGd,OAAO,WAAP,GACI,oBAACK,SAAOA;QACJ,SAASN;QACT,uBACI,oBAACO,YAAUA;YACP,SAAS;YACT,MAAM;YACN,MAAMR;YACN,SAASI;YACT,UAAUD;;;AAK9B;AAeA,MAAMM,mBAAmB,CAAC,EACtBC,SAAS,EACTP,QAAQ,EACRQ,UAAU,EACVC,YAAY,EACZC,aAAa,EACO,GACb,WAAP,GACI,oBAAC;QACG,WAAWC,GACP,iCACA,6BACA,sCACAJ;OAGHG,iBAAiB,WAAjBA,GACG,oBAACd,QAAMA;QACH,oBAAM,oBAACgB,gBAAWA;QAClB,OAAO;QACP,UAAUF;QACV,UAAUV;QAGjBQ,cAAc,WAAdA,GACG,oBAACZ,QAAMA;QACH,oBAAM,oBAACiB,yBAAQA;QACf,OAAO;QACP,UAAUL;QACV,UAAUR;QAGjBS,gBAAgB,WAAhBA,GACG,oBAACb,QAAMA;QACH,oBAAM,oBAACkB,2BAASA;QAChB,OAAO;QACP,UAAUL;QACV,UAAUT"}
1
+ {"version":3,"file":"FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.js","sources":["../../../../../../src/FilePicker/primitives/components/previews/RichItemPreview/ThumbnailActions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { ReactComponent as ReplaceIcon } from \"@webiny/icons/file_upload.svg\";\nimport { ReactComponent as EditIcon } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as TrashIcon } from \"@webiny/icons/delete.svg\";\nimport { IconButton } from \"~/Button/index.js\";\nimport { Tooltip } from \"~/Tooltip/index.js\";\nimport { cn } from \"~/utils.js\";\n\ninterface ActionProps {\n icon: React.JSX.Element;\n label: string;\n onAction: () => void;\n disabled?: boolean;\n}\n\nconst Action = ({ icon, label, onAction, disabled }: ActionProps) => {\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n onAction();\n },\n [onAction]\n );\n\n return (\n <Tooltip\n content={label}\n trigger={\n <IconButton\n variant={\"tertiary\"}\n size={\"sm\"}\n icon={icon}\n onClick={onClick}\n disabled={disabled}\n />\n }\n />\n );\n};\n\ninterface ThumbnailActionsProps {\n onRemoveItem?: () => void;\n onEditItem?: () => void;\n onReplaceItem?: () => void;\n disabled?: boolean;\n className?: string;\n}\n\nconst ThumbnailActions = ({\n className,\n disabled,\n onEditItem,\n onRemoveItem,\n onReplaceItem\n}: ThumbnailActionsProps) => {\n return (\n <div\n className={cn(\n \"invisible group-hover:visible\",\n \"flex items-center gap-xxs\",\n \"absolute top-xs-plus right-xs-plus\",\n className\n )}\n >\n {onReplaceItem && (\n <Action\n icon={<ReplaceIcon />}\n label={\"Replace\"}\n onAction={onReplaceItem}\n disabled={disabled}\n />\n )}\n {onEditItem && (\n <Action\n icon={<EditIcon />}\n label={\"Edit\"}\n onAction={onEditItem}\n disabled={disabled}\n />\n )}\n {onRemoveItem && (\n <Action\n icon={<TrashIcon />}\n label={\"Remove\"}\n onAction={onRemoveItem}\n disabled={disabled}\n />\n )}\n </div>\n );\n};\n\nexport { ThumbnailActions, type ThumbnailActionsProps };\n"],"names":["Action","icon","label","onAction","disabled","onClick","useCallback","event","Tooltip","IconButton","ThumbnailActions","className","onEditItem","onRemoveItem","onReplaceItem","cn","ReplaceIcon","EditIcon","TrashIcon"],"mappings":";;;;;;;AAeA,MAAMA,SAAS,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAe;IAC5D,MAAMC,UAAUC,YACZ,CAACC;QACGA,MAAM,eAAe;QACrBJ;IACJ,GACA;QAACA;KAAS;IAGd,OAAO,WAAP,GACI,oBAACK,SAAOA;QACJ,SAASN;QACT,uBACI,oBAACO,YAAUA;YACP,SAAS;YACT,MAAM;YACN,MAAMR;YACN,SAASI;YACT,UAAUD;;;AAK9B;AAUA,MAAMM,mBAAmB,CAAC,EACtBC,SAAS,EACTP,QAAQ,EACRQ,UAAU,EACVC,YAAY,EACZC,aAAa,EACO,GACb,WAAP,GACI,oBAAC;QACG,WAAWC,GACP,iCACA,6BACA,sCACAJ;OAGHG,iBAAiB,WAAjBA,GACG,oBAACd,QAAMA;QACH,oBAAM,oBAACgB,gBAAWA;QAClB,OAAO;QACP,UAAUF;QACV,UAAUV;QAGjBQ,cAAc,WAAdA,GACG,oBAACZ,QAAMA;QACH,oBAAM,oBAACiB,yBAAQA;QACf,OAAO;QACP,UAAUL;QACV,UAAUR;QAGjBS,gBAAgB,WAAhBA,GACG,oBAACb,QAAMA;QACH,oBAAM,oBAACkB,2BAASA;QAChB,OAAO;QACP,UAAUL;QACV,UAAUT"}