datocms-react-ui 3.1.0-next.6 → 3.1.0-next.9

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 (252) hide show
  1. package/README.md +3 -2
  2. package/dist/DateInput.d.ts +2 -0
  3. package/dist/DateInput.js +2 -0
  4. package/dist/DateTimeInput.d.ts +2 -0
  5. package/dist/DateTimeInput.js +2 -0
  6. package/dist/DateTimeRangeInput.d.ts +2 -0
  7. package/dist/DateTimeRangeInput.js +2 -0
  8. package/dist/FieldTypeAvatar.d.ts +2 -0
  9. package/dist/FieldTypeAvatar.js +2 -0
  10. package/dist/FieldTypeName.d.ts +2 -0
  11. package/dist/FieldTypeName.js +2 -0
  12. package/dist/FilterBuilder.d.ts +2 -0
  13. package/dist/FilterBuilder.js +2 -0
  14. package/dist/RecordRow.d.ts +2 -0
  15. package/dist/RecordRow.js +2 -0
  16. package/dist/UploadCard.js +2 -2
  17. package/dist/UploadPreview.d.ts +2 -2
  18. package/dist/UploadPreview.js +1 -1
  19. package/dist/UserRow.d.ts +2 -0
  20. package/dist/UserRow.js +2 -0
  21. package/dist/react-ui/src/Canvas.d.ts +7 -1
  22. package/dist/react-ui/src/Canvas.js +26 -4
  23. package/dist/react-ui/src/ctxAnswer.js +21 -0
  24. package/dist/react-ui/src/ctxDateSettings.js +7 -5
  25. package/dist/react-ui/src/ctxRecordPresentation.js +34 -0
  26. package/dist/react-ui/src/ctxUploads.js +23 -0
  27. package/dist/styles.css +634 -45
  28. package/dist/ui-public/icons/index.js +285 -280
  29. package/dist/ui-public/icons/lucide/braces.js +22 -0
  30. package/dist/ui-public/icons/lucide/hash.js +47 -0
  31. package/dist/ui-public/icons/lucide/letter-text.js +28 -0
  32. package/dist/ui-public/icons/lucide/rows-3.js +32 -0
  33. package/dist/ui-public/icons/lucide/toggle-right.js +32 -0
  34. package/dist/ui-public/locales/en.js +74 -5
  35. package/dist/ui-public/src/Message.d.ts +3 -4
  36. package/dist/ui-public/src/UiTextKey.d.ts +1 -1
  37. package/dist/ui-public/src/actions/Actions/ActionTooltip.js +1 -1
  38. package/dist/ui-public/src/actions/Actions/registry.d.ts +2 -2
  39. package/dist/ui-public/src/actions/Actions/registry.js +2 -2
  40. package/dist/ui-public/src/actions/Button.d.ts +10 -10
  41. package/dist/ui-public/src/actions/Button.js +1 -1
  42. package/dist/ui-public/src/actions/Dropdown/Menu.d.ts +2 -2
  43. package/dist/ui-public/src/actions/Dropdown/Option.d.ts +7 -7
  44. package/dist/ui-public/src/actions/Dropdown/index.d.ts +1 -1
  45. package/dist/ui-public/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +5 -5
  46. package/dist/ui-public/src/actions/Dropdown/triggers/DropdownTriggerButton.d.ts +2 -2
  47. package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.d.ts +6 -6
  48. package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.js +1 -1
  49. package/dist/ui-public/src/actions/EditorToolbar/Button.d.ts +1 -1
  50. package/dist/ui-public/src/actions/MultipleSelectionActionBar.d.ts +1 -1
  51. package/dist/ui-public/src/actions/SplitButton/Caret.js +2 -2
  52. package/dist/ui-public/src/actions/SplitButton/Halves.js +1 -1
  53. package/dist/ui-public/src/actions/SplitButton/index.d.ts +3 -3
  54. package/dist/ui-public/src/actions/disabledReason.d.ts +4 -4
  55. package/dist/ui-public/src/content/Avatar.d.ts +3 -3
  56. package/dist/ui-public/src/content/Avatar.js +2 -2
  57. package/dist/ui-public/src/content/CodeSnippet.d.ts +1 -1
  58. package/dist/ui-public/src/content/CopyableValue.d.ts +1 -1
  59. package/dist/ui-public/src/content/EnvironmentPill.d.ts +1 -1
  60. package/dist/ui-public/src/content/EnvironmentPill.js +1 -1
  61. package/dist/ui-public/src/content/FieldTypeAvatar.d.ts +22 -0
  62. package/dist/ui-public/src/content/FieldTypeAvatar.js +35 -0
  63. package/dist/ui-public/src/content/FieldTypeName.d.ts +19 -0
  64. package/dist/ui-public/src/content/FieldTypeName.js +25 -0
  65. package/dist/ui-public/src/content/IconAvatar.d.ts +3 -2
  66. package/dist/ui-public/src/content/ItemStatus.d.ts +1 -1
  67. package/dist/ui-public/src/content/Pill.d.ts +1 -1
  68. package/dist/ui-public/src/content/SmartDate.d.ts +1 -1
  69. package/dist/ui-public/src/content/UploadPreview/asset.js +200 -0
  70. package/dist/ui-public/src/content/UploadPreview/audio.js +120 -0
  71. package/dist/ui-public/src/content/{UploadPreview.d.ts → UploadPreview/box.d.ts} +10 -10
  72. package/dist/ui-public/src/content/{UploadPreview.js → UploadPreview/box.js} +7 -7
  73. package/dist/ui-public/src/content/{uploadPreviewFit.d.ts → UploadPreview/fit.d.ts} +2 -2
  74. package/dist/ui-public/src/content/{uploadPreviewFit.js → UploadPreview/fit.js} +3 -3
  75. package/dist/ui-public/src/content/UploadPreview/index.d.ts +61 -0
  76. package/dist/ui-public/src/content/UploadPreview/index.js +36 -0
  77. package/dist/ui-public/src/content/UploadPreview/presentation.js +63 -0
  78. package/dist/ui-public/src/content/UploadPreview/thumbhash.js +91 -0
  79. package/dist/ui-public/src/content/UploadPreview/upload.d.ts +104 -0
  80. package/dist/ui-public/src/content/UploadPreview/upload.js +112 -0
  81. package/dist/ui-public/src/content/UsageMeter.d.ts +1 -1
  82. package/dist/ui-public/src/content/ValidityTriangles.d.ts +1 -1
  83. package/dist/ui-public/src/feedback/BlankSlate.d.ts +5 -5
  84. package/dist/ui-public/src/feedback/Callout.d.ts +5 -5
  85. package/dist/ui-public/src/feedback/Callout.js +1 -1
  86. package/dist/ui-public/src/feedback/ProgressBar.d.ts +4 -4
  87. package/dist/ui-public/src/feedback/Spinner.d.ts +6 -6
  88. package/dist/ui-public/src/feedback/Spinner.js +1 -1
  89. package/dist/ui-public/src/form/DateInput.d.ts +13 -0
  90. package/dist/ui-public/src/form/DateInput.js +16 -0
  91. package/dist/ui-public/src/form/DateTimeInput/Base.d.ts +89 -0
  92. package/dist/ui-public/src/form/DateTimeInput/Base.js +330 -0
  93. package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.d.ts +29 -0
  94. package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.js +195 -0
  95. package/dist/ui-public/src/form/DateTimeInput/dateText.js +38 -0
  96. package/dist/ui-public/src/form/DateTimeInput/index.d.ts +10 -0
  97. package/dist/ui-public/src/form/DateTimeInput/index.js +18 -0
  98. package/dist/ui-public/src/form/DateTimeInput/value.js +31 -0
  99. package/dist/ui-public/src/form/DateTimeRangeInput/Panel.js +167 -0
  100. package/dist/ui-public/src/form/DateTimeRangeInput/index.d.ts +123 -0
  101. package/dist/ui-public/src/form/DateTimeRangeInput/index.js +186 -0
  102. package/dist/ui-public/src/form/DateTimeRangeInput/rangeLabel.js +46 -0
  103. package/dist/ui-public/src/form/FieldHint.d.ts +2 -2
  104. package/dist/ui-public/src/form/FieldWrapper.d.ts +9 -9
  105. package/dist/ui-public/src/form/FieldWrapper.js +3 -3
  106. package/dist/ui-public/src/form/FilterBuilder/Editor.js +123 -0
  107. package/dist/ui-public/src/form/FilterBuilder/index.d.ts +9 -0
  108. package/dist/ui-public/src/form/FilterBuilder/index.js +294 -0
  109. package/dist/ui-public/src/form/FilterBuilder/types.d.ts +188 -0
  110. package/dist/ui-public/src/form/FilterBuilder/values.js +86 -0
  111. package/dist/ui-public/src/form/InputGroup.d.ts +2 -2
  112. package/dist/ui-public/src/form/InputGroup.js +1 -1
  113. package/dist/ui-public/src/form/KeyValueList.d.ts +1 -1
  114. package/dist/ui-public/src/form/Label.d.ts +2 -2
  115. package/dist/ui-public/src/form/RadioGroupInput.d.ts +2 -2
  116. package/dist/ui-public/src/form/RadioGroupInput.js +1 -1
  117. package/dist/ui-public/src/form/SelectInput/SelectMenu.d.ts +2 -2
  118. package/dist/ui-public/src/form/SelectInput/index.d.ts +3 -3
  119. package/dist/ui-public/src/form/SwitchInput.d.ts +2 -2
  120. package/dist/ui-public/src/form/SwitchList.d.ts +1 -1
  121. package/dist/ui-public/src/form/SwitchList.js +1 -1
  122. package/dist/ui-public/src/form/TableList.d.ts +2 -2
  123. package/dist/ui-public/src/form/TextareaInput.js +1 -1
  124. package/dist/ui-public/src/form/inputProps.d.ts +6 -6
  125. package/dist/ui-public/src/hooks/useAsyncSelectOptions.d.ts +1 -1
  126. package/dist/ui-public/src/hooks/useSmartRowClick.d.ts +1 -1
  127. package/dist/ui-public/src/hooks/useSmartRowClick.js +1 -1
  128. package/dist/ui-public/src/layout/Page/PageGroup.d.ts +2 -2
  129. package/dist/ui-public/src/layout/Page/PageGroup.js +1 -1
  130. package/dist/ui-public/src/layout/Pane/FormHeader.d.ts +1 -1
  131. package/dist/ui-public/src/layout/Pane/FormHeader.js +1 -1
  132. package/dist/ui-public/src/layout/Pane/ListFilter.d.ts +1 -1
  133. package/dist/ui-public/src/layout/Pane/ListPresets.d.ts +1 -1
  134. package/dist/ui-public/src/layout/Pane/PaneHeader.d.ts +1 -1
  135. package/dist/ui-public/src/layout/Pane/index.d.ts +8 -8
  136. package/dist/ui-public/src/layout/Pane/index.js +17 -8
  137. package/dist/ui-public/src/layout/SidebarPanel.d.ts +1 -1
  138. package/dist/ui-public/src/layout/SplitPane/Rail.js +1 -1
  139. package/dist/ui-public/src/layout/SplitPane/index.d.ts +6 -6
  140. package/dist/ui-public/src/layout/SplitPane/index.js +16 -2
  141. package/dist/ui-public/src/layout/Toolbar/AddNewButton.d.ts +2 -2
  142. package/dist/ui-public/src/layout/Toolbar/Help.d.ts +3 -3
  143. package/dist/ui-public/src/layout/Toolbar/Help.js +2 -2
  144. package/dist/ui-public/src/layout/Toolbar/Note.d.ts +1 -1
  145. package/dist/ui-public/src/layout/Toolbar/Note.js +1 -1
  146. package/dist/ui-public/src/layout/Toolbar/Pagination.d.ts +1 -1
  147. package/dist/ui-public/src/layout/Toolbar/Pagination.js +1 -1
  148. package/dist/ui-public/src/layout/Toolbar/PresetsTitle.d.ts +3 -3
  149. package/dist/ui-public/src/layout/Toolbar/PresetsTitle.js +2 -2
  150. package/dist/ui-public/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
  151. package/dist/ui-public/src/layout/Toolbar/Root.d.ts +1 -1
  152. package/dist/ui-public/src/layout/Toolbar/Root.js +4 -1
  153. package/dist/ui-public/src/layout/Toolbar/ToolbarTitleTrigger.js +1 -1
  154. package/dist/ui-public/src/lists/CardList.d.ts +3 -3
  155. package/dist/ui-public/src/lists/EmptySlot.d.ts +1 -1
  156. package/dist/ui-public/src/lists/InfoList/User.d.ts +1 -1
  157. package/dist/ui-public/src/lists/InfoList/Value.d.ts +1 -1
  158. package/dist/ui-public/src/lists/InfoList/Value.js +1 -1
  159. package/dist/ui-public/src/lists/InfoList/index.d.ts +3 -3
  160. package/dist/ui-public/src/lists/InfoList/index.js +1 -1
  161. package/dist/ui-public/src/lists/MediaCard.d.ts +7 -7
  162. package/dist/ui-public/src/lists/RecordRow/Image.d.ts +24 -0
  163. package/dist/ui-public/src/lists/RecordRow/Image.js +22 -0
  164. package/dist/ui-public/src/lists/RecordRow/List.d.ts +26 -0
  165. package/dist/ui-public/src/lists/RecordRow/List.js +30 -0
  166. package/dist/ui-public/src/lists/RecordRow/context.js +31 -0
  167. package/dist/ui-public/src/lists/RecordRow/index.d.ts +94 -0
  168. package/dist/ui-public/src/lists/RecordRow/index.js +122 -0
  169. package/dist/ui-public/src/lists/RecordRow/presentation.js +73 -0
  170. package/dist/ui-public/src/lists/RecordRow/types.d.ts +58 -0
  171. package/dist/ui-public/src/lists/RowList.d.ts +5 -5
  172. package/dist/ui-public/src/lists/SettingsList.d.ts +3 -3
  173. package/dist/ui-public/src/lists/SettingsList.js +2 -2
  174. package/dist/ui-public/src/lists/Table/Row.d.ts +5 -5
  175. package/dist/ui-public/src/lists/Table/Table.d.ts +3 -3
  176. package/dist/ui-public/src/lists/Table/TreeToggle.d.ts +2 -2
  177. package/dist/ui-public/src/lists/Table/TreeToggle.js +5 -4
  178. package/dist/ui-public/src/lists/Table/cells/LinkCell.d.ts +1 -1
  179. package/dist/ui-public/src/lists/TreeRow/Action.d.ts +1 -1
  180. package/dist/ui-public/src/lists/TreeRow/Action.js +1 -1
  181. package/dist/ui-public/src/lists/TreeRow/Link.d.ts +1 -1
  182. package/dist/ui-public/src/lists/TreeRow/Link.js +1 -1
  183. package/dist/ui-public/src/lists/UploadCard.d.ts +66 -3
  184. package/dist/ui-public/src/lists/UploadCard.js +116 -7
  185. package/dist/ui-public/src/lists/UserRow.d.ts +122 -0
  186. package/dist/ui-public/src/lists/UserRow.js +104 -0
  187. package/dist/ui-public/src/lists/dnd/DragHandle.d.ts +2 -2
  188. package/dist/ui-public/src/lists/dnd/SortableList.d.ts +1 -1
  189. package/dist/ui-public/src/lists/dnd/dropTargetClassName.d.ts +1 -1
  190. package/dist/ui-public/src/lists/dnd/tree/SortableTree.d.ts +2 -2
  191. package/dist/ui-public/src/navigation/Chevron.d.ts +4 -4
  192. package/dist/ui-public/src/navigation/Chevron.js +1 -1
  193. package/dist/ui-public/src/navigation/Link.d.ts +5 -5
  194. package/dist/ui-public/src/navigation/Link.js +1 -1
  195. package/dist/ui-public/src/navigation/NavList.d.ts +1 -1
  196. package/dist/ui-public/src/navigation/NavList.js +1 -1
  197. package/dist/ui-public/src/navigation/NavigationProvider.d.ts +1 -1
  198. package/dist/ui-public/src/navigation/SegmentedControl.d.ts +2 -2
  199. package/dist/ui-public/src/navigation/SettingsMenu.d.ts +8 -8
  200. package/dist/ui-public/src/navigation/SettingsMenu.js +1 -1
  201. package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNode.d.ts +4 -4
  202. package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.d.ts +1 -1
  203. package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.js +1 -1
  204. package/dist/ui-public/src/overlays/NewZIndex.d.ts +1 -1
  205. package/dist/ui-public/src/overlays/NewZIndex.js +1 -1
  206. package/dist/ui-public/src/overlays/Popover.d.ts +1 -1
  207. package/dist/ui-public/src/overlays/PortalWrapper.js +1 -1
  208. package/dist/ui-public/src/overlays/useModalClose.js +3 -3
  209. package/dist/ui-public/src/patterns/ListDetail/FloatingDetail.js +2 -2
  210. package/dist/ui-public/src/patterns/ListDetail/Page.d.ts +8 -9
  211. package/dist/ui-public/src/patterns/ListDetail/Page.js +4 -5
  212. package/dist/ui-public/src/patterns/ListDetail/Panel.d.ts +2 -2
  213. package/dist/ui-public/src/patterns/ListDetail/Panel.js +1 -1
  214. package/dist/ui-public/src/patterns/ListDetail/Split.d.ts +9 -10
  215. package/dist/ui-public/src/patterns/ListDetail/Split.js +5 -5
  216. package/dist/ui-public/src/patterns/ListFormPage.d.ts +3 -3
  217. package/dist/ui-public/src/patterns/ListFormPage.js +1 -1
  218. package/dist/ui-public/src/semantic/Heading.d.ts +1 -1
  219. package/dist/ui-public/src/semantic/Heading.js +1 -1
  220. package/dist/ui-public/src/semantic/Image.js +1 -1
  221. package/dist/ui-public/src/semantic/Nav.d.ts +3 -3
  222. package/dist/ui-public/src/semantic/Nav.js +3 -3
  223. package/dist/ui-public/src/semantic/RawButton.d.ts +3 -3
  224. package/dist/ui-public/src/semantic/RawButton.js +1 -1
  225. package/dist/ui-public/src/semantic/Search.d.ts +1 -1
  226. package/dist/ui-public/src/semantic/Search.js +1 -1
  227. package/dist/ui-public/src/utils/fieldTypes.d.ts +29 -0
  228. package/dist/ui-public/src/utils/fieldTypes.js +94 -0
  229. package/dist/ui-public/src/utils/format.d.ts +21 -0
  230. package/dist/ui-public/src/utils/format.js +20 -0
  231. package/dist/ui-public/src/utils/formatDate.d.ts +10 -2
  232. package/dist/ui-public/src/utils/formatDate.js +4 -4
  233. package/dist/ui-public/src/utils/tickBatcher.js +44 -0
  234. package/dist/ui-public/src/utils/timezones.js +277 -0
  235. package/dist/ui-public/src/utils/weekStartForLocale.js +25 -0
  236. package/dist/utils/fieldTypes.d.ts +1 -0
  237. package/dist/utils/fieldTypes.js +2 -0
  238. package/dist/utils/format.d.ts +1 -0
  239. package/dist/utils/format.js +2 -0
  240. package/package.json +2 -2
  241. package/dist/ui-public/icons/custom/fieldgroup-boolean.js +0 -18
  242. package/dist/ui-public/icons/custom/fieldgroup-color.js +0 -18
  243. package/dist/ui-public/icons/custom/fieldgroup-datetime.js +0 -49
  244. package/dist/ui-public/icons/custom/fieldgroup-json.js +0 -18
  245. package/dist/ui-public/icons/custom/fieldgroup-location.js +0 -19
  246. package/dist/ui-public/icons/custom/fieldgroup-media.js +0 -18
  247. package/dist/ui-public/icons/custom/fieldgroup-number.js +0 -18
  248. package/dist/ui-public/icons/custom/fieldgroup-reference.js +0 -18
  249. package/dist/ui-public/icons/custom/fieldgroup-rich_text.js +0 -18
  250. package/dist/ui-public/icons/custom/fieldgroup-seo.js +0 -22
  251. package/dist/ui-public/icons/custom/fieldgroup-structured_text.js +0 -61
  252. package/dist/ui-public/icons/lucide/receipt.js +0 -26
@@ -10,7 +10,7 @@ export type RowListProps = {
10
10
  * @default "default"
11
11
  */
12
12
  density?: 'default' | 'compact';
13
- /** Only for the place of the list in its container (a margin), not for its look */
13
+ /** Only for the position of the list in its container (a margin), not for its look */
14
14
  className?: string;
15
15
  /** The rows (RowList.Item) */
16
16
  children: ReactNode;
@@ -21,9 +21,9 @@ export type RowListProps = {
21
21
  * of a section, use NavList: it adds the navigation landmark.
22
22
  */
23
23
  declare function BaseRowList({ density, className, children, }: RowListProps): React.JSX.Element;
24
- /** The row opens a page of the app. It is selected while the page is open. */
24
+ /** The row opens a page of DatoCMS. It is selected while the page is open. */
25
25
  type LinkRow = {
26
- /** The page of the app: the path with its query */
26
+ /** The page of DatoCMS: the path with its query */
27
27
  to: string;
28
28
  /** Runs on a click, before the page opens */
29
29
  onClick?: () => void;
@@ -53,13 +53,13 @@ export type RowListItemProps = RowListItemAction & {
53
53
  /**
54
54
  * The text of the row is subtle and its images fade, but the user can
55
55
  * still open it. Use it for an element that is off (for example a
56
- * disabled plugin), with a Pill that tells it.
56
+ * disabled plugin), with a Pill that says it.
57
57
  * @default false
58
58
  */
59
59
  muted?: boolean;
60
60
  /**
61
61
  * The user can drag the row to a new position. Give the argument of the
62
- * children of SortableItem (ui-public/dnd), with `handle` on the SortableItem:
62
+ * children of SortableItem , with `handle` on the SortableItem:
63
63
  * the row shows a grip at its left.
64
64
  */
65
65
  sortable?: SortableItemApi;
@@ -14,7 +14,7 @@ export type SettingsListRowProps = {
14
14
  /**
15
15
  * The current value. A long value gets an ellipsis (in a narrow list, it
16
16
  * goes on more lines), and a value on more lines (an address) has each
17
- * line at the right. An action without a value (for example "Log out
17
+ * line on the right. An action without a value (for example "Log out
18
18
  * everywhere") has no value.
19
19
  */
20
20
  value?: ReactNode;
@@ -25,11 +25,11 @@ export type SettingsListRowProps = {
25
25
  */
26
26
  action?: ReactNode;
27
27
  };
28
- /** A setting or an action: the text at the left, the value and the control at the right */
28
+ /** A setting or an action: the text on the left, the value and the control on the right */
29
29
  declare function Row({ title, description, value, action }: SettingsListRowProps): React.JSX.Element;
30
30
  /**
31
31
  * The settings of a wide page: one row for each value that the user changes
32
- * or for each action, with the control always visible at the right. Put it
32
+ * or for each action, with the control always visible on the right. Put it
33
33
  * in a Page.Group. For facts to read, use InfoList. For a list of items,
34
34
  * use CardList.
35
35
  */
@@ -9,7 +9,7 @@ function BaseSettingsList({ className, children }) {
9
9
  children
10
10
  });
11
11
  }
12
- /** A setting or an action: the text at the left, the value and the control at the right */
12
+ /** A setting or an action: the text on the left, the value and the control on the right */
13
13
  function Row({ title, description, value, action }) {
14
14
  const { tc } = useTranslation();
15
15
  return /* @__PURE__ */ jsxs("li", {
@@ -38,7 +38,7 @@ function Row({ title, description, value, action }) {
38
38
  }
39
39
  /**
40
40
  * The settings of a wide page: one row for each value that the user changes
41
- * or for each action, with the control always visible at the right. Put it
41
+ * or for each action, with the control always visible on the right. Put it
42
42
  * in a Page.Group. For facts to read, use InfoList. For a list of items,
43
43
  * use CardList.
44
44
  */
@@ -45,7 +45,7 @@ export type RowAction = {
45
45
  openWithArrows?: never;
46
46
  };
47
47
  /**
48
- * The drag handle at the left of the row: the handle that the library listens
48
+ * The drag handle on the left of the row: the handle that the library listens
49
49
  * to, or a disabled handle with the reason in a tooltip
50
50
  */
51
51
  export type RowDragHandle =
@@ -61,7 +61,7 @@ export type RowDragHandle =
61
61
  };
62
62
  export type RowDrag = {
63
63
  /**
64
- * The element that the library moves. It has a position, thus the drop
64
+ * The element that the library moves. It has a position, so the drop
65
65
  * indicator can be in it.
66
66
  */
67
67
  wrapperRef?: Ref<HTMLDivElement>;
@@ -91,7 +91,7 @@ type RowBaseProps<R> = {
91
91
  /**
92
92
  * The text of the row is subtle and its images fade, but the user can
93
93
  * still open it. Use it for an element that is off (for example a
94
- * deactivated user), with a Pill that tells it.
94
+ * deactivated user), with a Pill that says it.
95
95
  * @default false
96
96
  */
97
97
  muted?: boolean;
@@ -99,7 +99,7 @@ type RowBaseProps<R> = {
99
99
  /** The element of the row, without the handle */
100
100
  rowRef?: Ref<HTMLDivElement>;
101
101
  /**
102
- * The actions of the row (see `ui-public/Actions`): their keys work while the
102
+ * The actions of the row (see `Actions`): their keys work while the
103
103
  * pointer or the focus is in the row, and a menu in the row runs them.
104
104
  */
105
105
  actions?: readonly Action[];
@@ -117,7 +117,7 @@ type RowBaseProps<R> = {
117
117
  * device with no hover. A click in them never opens the row.
118
118
  */
119
119
  trailing?: ReactNode;
120
- /** Cells in place of the cells of the columns. Use <Table.Cell>. */
120
+ /** Cells instead of the cells of the columns. Use <Table.Cell>. */
121
121
  children?: ReactNode;
122
122
  };
123
123
  export type RowProps<R = any> = RowBaseProps<R> & RowAction;
@@ -18,7 +18,7 @@ export type TableProps<R = any> = {
18
18
  layout: TableLayout;
19
19
  onLayoutChange: (layout: TableLayout) => void;
20
20
  /**
21
- * The order of the rows: `useClientSort` or a hook of the app gives it.
21
+ * The order of the rows: `useClientSort` or a hook of yours gives it.
22
22
  * Without it, the user cannot sort from the header.
23
23
  */
24
24
  sort?: TableSortState;
@@ -30,13 +30,13 @@ export type TableProps<R = any> = {
30
30
  /**
31
31
  * The width in pixels of a column at the end of each row, outside the columns
32
32
  * of the layout and with no label: the controls of the row (see `trailing` of
33
- * <Table.Row>). The header keeps the same space empty, thus the button of the
33
+ * <Table.Row>). The header keeps the same space empty, so the button of the
34
34
  * columns menu sits over it.
35
35
  */
36
36
  trailingWidth?: number;
37
37
  /**
38
38
  * The rows have a drag handle at their left. Set it with the `reorder` of
39
- * <Table.Body>, or for rows that a library of the caller moves (a tree).
39
+ * <Table.Body>, or for rows that a library of yours moves (a tree).
40
40
  */
41
41
  reorderable?: boolean;
42
42
  /**
@@ -7,7 +7,7 @@ export type TableRowExpandable = {
7
7
  /** Runs when the user clicks the toggle */
8
8
  onToggle: () => void;
9
9
  /**
10
- * The child rows load: a spinner takes the place of the chevron, and the
10
+ * The child rows load: a spinner replaces the chevron, and the
11
11
  * toggle does nothing
12
12
  */
13
13
  busy?: boolean;
@@ -19,7 +19,7 @@ export type TableRowExpandable = {
19
19
  };
20
20
  /**
21
21
  * The toggle column of a tree row. A row without child rows keeps the space
22
- * of the toggle, thus the contents of the rows align.
22
+ * of the toggle, so the contents of the rows align.
23
23
  */
24
24
  export declare function TreeToggle({ expandable, nested, labelledBy, }: {
25
25
  expandable: TableRowExpandable | undefined;
@@ -6,12 +6,13 @@ import { DisclosureChevron, DisclosureChevronPlaceholder } from "../../navigatio
6
6
  import "react";
7
7
  import { jsx } from "react/jsx-runtime";
8
8
  //#region ../ui-public/src/lists/Table/TreeToggle.tsx
9
- function stopPropagation(event) {
9
+ function stopRowClick(event) {
10
10
  event.stopPropagation();
11
+ event.preventDefault();
11
12
  }
12
13
  /**
13
14
  * The toggle column of a tree row. A row without child rows keeps the space
14
- * of the toggle, thus the contents of the rows align.
15
+ * of the toggle, so the contents of the rows align.
15
16
  */
16
17
  function TreeToggle({ expandable, nested, labelledBy }) {
17
18
  if (!expandable) return /* @__PURE__ */ jsx(TreeToggleSlot, { children: nested ? /* @__PURE__ */ jsx(Generic.DashIcon, { className: "Table__toggle__dash" }) : /* @__PURE__ */ jsx(DisclosureChevronPlaceholder, {}) });
@@ -25,9 +26,9 @@ function TreeToggle({ expandable, nested, labelledBy }) {
25
26
  expandable: { open },
26
27
  disabled: hasReason ? "focusable" : Boolean(disabled),
27
28
  "aria-busy": busy || void 0,
28
- onClickCapture: disabled ? stopPropagation : void 0,
29
+ onClickCapture: disabled ? stopRowClick : void 0,
29
30
  onClick: (event) => {
30
- stopPropagation(event);
31
+ stopRowClick(event);
31
32
  if (!busy) onToggle();
32
33
  },
33
34
  children: busy ? /* @__PURE__ */ jsx(Spinner_default, {
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export type LinkCellProps = {
3
3
  /** The path of the link */
4
4
  to: string;
5
- /** The text of the link: a string, thus the title can show it */
5
+ /** The text of the link: a string, so the title can show it */
6
6
  children: string;
7
7
  };
8
8
  /** A link in a cell. The title shows the full text when the column cuts it. */
@@ -13,7 +13,7 @@ export type TreeRowActionProps = {
13
13
  };
14
14
  /**
15
15
  * The content of a `TreeRow` as a button, for example "Load more". The
16
- * button starts in the column of the handle, thus a click there also runs
16
+ * button starts in the column of the handle, so a click there also runs
17
17
  * it. Give it to a row with no `expandable` and no `drag.handle`. In a
18
18
  * SortableTree, the button is a tree item: the arrow keys move the focus to
19
19
  * it, and Enter or Space runs it.
@@ -6,7 +6,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region ../ui-public/src/lists/TreeRow/Action.tsx
7
7
  /**
8
8
  * The content of a `TreeRow` as a button, for example "Load more". The
9
- * button starts in the column of the handle, thus a click there also runs
9
+ * button starts in the column of the handle, so a click there also runs
10
10
  * it. Give it to a row with no `expandable` and no `drag.handle`. In a
11
11
  * SortableTree, the button is a tree item: the arrow keys move the focus to
12
12
  * it, and Enter or Space runs it.
@@ -6,7 +6,7 @@ export type TreeRowLinkProps = Omit<LinkProps, 'className' | 'children'> & {
6
6
  };
7
7
  /**
8
8
  * The content of a `TreeRow` as a link, for example the link that opens a
9
- * record. Give it the `provided.treeItemProps` of SortableTree, thus the
9
+ * record. Give it the `provided.treeItemProps` of SortableTree, so the
10
10
  * arrow keys move the focus between the rows.
11
11
  */
12
12
  export default function TreeRowLink({ children, ...props }: TreeRowLinkProps): React.JSX.Element;
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
4
4
  //#region ../ui-public/src/lists/TreeRow/Link.tsx
5
5
  /**
6
6
  * The content of a `TreeRow` as a link, for example the link that opens a
7
- * record. Give it the `provided.treeItemProps` of SortableTree, thus the
7
+ * record. Give it the `provided.treeItemProps` of SortableTree, so the
8
8
  * arrow keys move the focus between the rows.
9
9
  */
10
10
  function TreeRowLink({ children, ...props }) {
@@ -1,4 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
+ import type { BoxSize, UploadPreviewPadding } from '../content/UploadPreview/fit.js';
3
+ import { type UploadFieldValue, type UploadPreviewUpload } from '../content/UploadPreview/upload.js';
2
4
  import { type MediaCardCaption, type MediaCardProps } from './MediaCard.js';
3
5
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
4
6
  /** The upload of the asset, while it is in progress */
@@ -15,7 +17,10 @@ export type UploadCardProgress = {
15
17
  */
16
18
  onCancel?: (event: React.MouseEvent) => void;
17
19
  };
18
- export type UploadCardProps = DistributiveOmit<MediaCardProps, 'caption' | 'captionAction' | 'children'> & {
20
+ type CardProps = DistributiveOmit<MediaCardProps, 'caption' | 'captionAction' | 'children'>;
21
+ /** Mode "preview": you give the preview and the caption of the asset. */
22
+ export type UploadCardPreviewModeProps = CardProps & {
23
+ upload?: never;
19
24
  /** The preview of the asset, an `UploadPreview` */
20
25
  children: ReactNode;
21
26
  /**
@@ -25,12 +30,56 @@ export type UploadCardProps = DistributiveOmit<MediaCardProps, 'caption' | 'capt
25
30
  caption?: MediaCardCaption;
26
31
  /**
27
32
  * The asset uploads. The caption shows in the subtle ink. Without a
28
- * caption, the caption tells the percent or the analysis.
33
+ * caption, the caption shows the percent or the analysis.
29
34
  */
30
35
  progress?: UploadCardProgress;
31
36
  /** The antivirus found a threat in the file: the card shows a badge. */
32
37
  threatDetected?: boolean;
33
38
  };
39
+ export type { UploadFieldValue } from '../content/UploadPreview/upload.js';
40
+ /**
41
+ * Mode "upload": the card shows an asset of the Media Area, as DatoCMS
42
+ * shows it, with its preview, its caption and the antivirus badge. A sound
43
+ * file gets a play action.
44
+ */
45
+ export type UploadCardUploadModeProps = CardProps & {
46
+ /**
47
+ * The asset as `ctx` gives it, or its ID. An ID loads through the
48
+ * provider of the host: `Canvas` mounts it. `null` is an asset that does
49
+ * not exist: the preview shows a blank file icon.
50
+ */
51
+ upload: string | UploadPreviewUpload | null;
52
+ /**
53
+ * The locale of the default metadata of the asset, for the caption, for
54
+ * example the locale of the field. When it has no value, the caption uses
55
+ * the main locale of the project, which the provider of the host gives.
56
+ */
57
+ preferredLocale?: string;
58
+ /**
59
+ * The value of the field that holds the asset. Its title and alternate
60
+ * text come before the default metadata of the asset, and its
61
+ * `poster_time` gives the frame of a video.
62
+ */
63
+ fieldValue?: UploadFieldValue;
64
+ /**
65
+ * The text below the preview. Without it, the card computes it with
66
+ * `uploadCardCaption`. `null` shows no caption.
67
+ */
68
+ caption?: MediaCardCaption | null;
69
+ /** The size of the preview, in px. Without it, the CSS gives the size. */
70
+ box?: BoxSize;
71
+ /** The space around the asset in the preview, as in `UploadPreview`. */
72
+ padding?: UploadPreviewPadding;
73
+ /** The preview is a link. */
74
+ link?: {
75
+ href: string;
76
+ target?: string;
77
+ };
78
+ children?: never;
79
+ progress?: never;
80
+ threatDetected?: never;
81
+ };
82
+ export type UploadCardProps = UploadCardPreviewModeProps | UploadCardUploadModeProps;
34
83
  /** The metadata of an asset that give its caption */
35
84
  export type UploadCaptionMetadata = {
36
85
  /** The title of the asset in the record */
@@ -51,9 +100,23 @@ export type UploadCaptionMetadata = {
51
100
  * or no `defaultTitle`.
52
101
  */
53
102
  export declare function uploadCaption({ title, alt, defaultTitle, defaultAlt, filename, }: UploadCaptionMetadata): MediaCardCaption;
103
+ /**
104
+ * The caption of an asset in a card, as the gallery field of DatoCMS shows
105
+ * it: the metadata of the value of the field, then the default metadata of
106
+ * the asset in `preferredLocale`, then in `mainLocale`. A sound file falls
107
+ * back to its file name. `UploadCard` takes `mainLocale` from the provider
108
+ * of the host. Give it when you call this function outside a `Canvas`.
109
+ */
110
+ export declare function uploadCardCaption(upload: UploadPreviewUpload, { preferredLocale, mainLocale, fieldValue, }?: {
111
+ preferredLocale?: string;
112
+ /** The main locale of the project: the first of `ctx.site.attributes.locales` */
113
+ mainLocale?: string;
114
+ fieldValue?: UploadFieldValue;
115
+ }): MediaCardCaption;
54
116
  /**
55
117
  * The card of an asset: a `MediaCard` with the preview of the asset, its
56
- * caption, the progress of its upload and the antivirus badge.
118
+ * caption, the progress of its upload and the antivirus badge. With
119
+ * `upload`, the card gets them from an asset of the Media Area.
57
120
  */
58
121
  declare const UploadCard: React.ForwardRefExoticComponent<UploadCardProps & React.RefAttributes<HTMLDivElement>>;
59
122
  export default UploadCard;
@@ -1,8 +1,12 @@
1
1
  import { Generic, Status } from "../../icons/index.js";
2
2
  import { useTranslation } from "../i18n.js";
3
+ import { useLoadedUpload, useUploadMainLocale } from "../content/UploadPreview/presentation.js";
3
4
  import Button from "../actions/Button.js";
4
5
  import MediaCard from "./MediaCard.js";
5
- import { forwardRef } from "react";
6
+ import { useAudioPlayback } from "../content/UploadPreview/audio.js";
7
+ import { uploadDefaultMetadata } from "../content/UploadPreview/upload.js";
8
+ import { UploadAssetPreview } from "../content/UploadPreview/asset.js";
9
+ import { forwardRef, useMemo } from "react";
6
10
  import { jsx, jsxs } from "react/jsx-runtime";
7
11
  //#region ../ui-public/src/lists/UploadCard.tsx
8
12
  /**
@@ -20,11 +24,7 @@ function uploadCaption({ title, alt, defaultTitle, defaultAlt, filename }) {
20
24
  function hasCheckbox(props) {
21
25
  return !!props.selection?.checkbox;
22
26
  }
23
- /**
24
- * The card of an asset: a `MediaCard` with the preview of the asset, its
25
- * caption, the progress of its upload and the antivirus badge.
26
- */
27
- var UploadCard = forwardRef(function UploadCard({ children, caption, progress, threatDetected, ...mediaCardProps }, ref) {
27
+ var PreviewModeCard = forwardRef(function PreviewModeCard({ children, caption, progress, threatDetected, upload: _, ...mediaCardProps }, ref) {
28
28
  const { tm } = useTranslation();
29
29
  const progressText = progress ? progress.percent < 100 ? {
30
30
  id: "imageMetadata.uploadInProgress",
@@ -62,5 +62,114 @@ var UploadCard = forwardRef(function UploadCard({ children, caption, progress, t
62
62
  }), children]
63
63
  });
64
64
  });
65
+ /**
66
+ * The caption of an asset in a card, as the gallery field of DatoCMS shows
67
+ * it: the metadata of the value of the field, then the default metadata of
68
+ * the asset in `preferredLocale`, then in `mainLocale`. A sound file falls
69
+ * back to its file name. `UploadCard` takes `mainLocale` from the provider
70
+ * of the host. Give it when you call this function outside a `Canvas`.
71
+ */
72
+ function uploadCardCaption(upload, { preferredLocale, mainLocale, fieldValue } = {}) {
73
+ const locales = [preferredLocale, mainLocale].filter((locale) => !!locale);
74
+ const defaults = uploadDefaultMetadata(upload, locales);
75
+ return uploadCaption({
76
+ title: fieldValue?.title,
77
+ alt: fieldValue?.alt,
78
+ defaultTitle: defaults.title,
79
+ defaultAlt: defaults.alt,
80
+ filename: upload.attributes.mime_type?.startsWith("audio/") ? upload.attributes.filename : null
81
+ });
82
+ }
83
+ function useActionsWithPlay(url, { actions, options, compact }) {
84
+ const playback = useAudioPlayback(url);
85
+ const { isPlaying, toggle } = playback;
86
+ return useMemo(() => {
87
+ if (!url) return {
88
+ playback: void 0,
89
+ actions,
90
+ options
91
+ };
92
+ const play = {
93
+ id: "play",
94
+ icon: isPlaying ? Status.PauseIcon : Status.PlayIcon,
95
+ label: { id: isPlaying ? "audioPlayer.pause" : "audioPlayer.play" },
96
+ onClick: (e) => {
97
+ e?.stopPropagation();
98
+ toggle();
99
+ }
100
+ };
101
+ return compact ? {
102
+ playback,
103
+ actions,
104
+ options: [play, ...options ?? []]
105
+ } : {
106
+ playback,
107
+ actions: [play, ...actions ?? []],
108
+ options
109
+ };
110
+ }, [
111
+ url,
112
+ playback,
113
+ isPlaying,
114
+ toggle,
115
+ actions,
116
+ options,
117
+ compact
118
+ ]);
119
+ }
120
+ var UploadModeCard = forwardRef(function UploadModeCard({ upload: uploadOrId, preferredLocale, fieldValue, caption, box, padding, link, ...mediaCardProps }, ref) {
121
+ const upload = useLoadedUpload(uploadOrId);
122
+ const mainLocale = useUploadMainLocale();
123
+ const attributes = upload?.attributes;
124
+ const { playback, actions, options } = useActionsWithPlay(attributes?.mime_type?.startsWith("audio/") && attributes.url ? attributes.url : null, mediaCardProps);
125
+ const cardCaption = caption === null ? void 0 : caption ?? (upload ? uploadCardCaption(upload, {
126
+ preferredLocale,
127
+ mainLocale,
128
+ fieldValue
129
+ }) : upload === null && typeof uploadOrId === "string" ? {
130
+ text: {
131
+ id: "uploadCard.fallbackTitle",
132
+ values: { id: uploadOrId }
133
+ },
134
+ muted: true
135
+ } : upload === void 0 ? {
136
+ text: { id: "uploadCard.loading" },
137
+ muted: true
138
+ } : void 0);
139
+ const cardProps = {
140
+ ...mediaCardProps,
141
+ actions,
142
+ options
143
+ };
144
+ return /* @__PURE__ */ jsx(PreviewModeCard, {
145
+ ...cardProps,
146
+ ref,
147
+ caption: cardCaption,
148
+ threatDetected: upload?.meta?.antivirus?.status === "infected",
149
+ children: /* @__PURE__ */ jsx(UploadAssetPreview, {
150
+ upload,
151
+ box,
152
+ padding,
153
+ link,
154
+ posterTime: fieldValue?.poster_time ?? void 0,
155
+ audioPlayback: playback
156
+ })
157
+ });
158
+ });
159
+ /**
160
+ * The card of an asset: a `MediaCard` with the preview of the asset, its
161
+ * caption, the progress of its upload and the antivirus badge. With
162
+ * `upload`, the card gets them from an asset of the Media Area.
163
+ */
164
+ var UploadCard = forwardRef(function UploadCard(props, ref) {
165
+ if (props.upload !== void 0) return /* @__PURE__ */ jsx(UploadModeCard, {
166
+ ...props,
167
+ ref
168
+ });
169
+ return /* @__PURE__ */ jsx(PreviewModeCard, {
170
+ ...props,
171
+ ref
172
+ });
173
+ });
65
174
  //#endregion
66
- export { UploadCard as default, uploadCaption };
175
+ export { UploadCard as default, uploadCaption, uploadCardCaption };
@@ -0,0 +1,122 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type Message, type TextMessage } from '../Message.js';
3
+ /**
4
+ * A person as the API gives it, and as `ctx` gives it to a plugin (for
5
+ * example `ctx.currentUser`, `ctx.loadUsers()`): a collaborator, an account,
6
+ * an organization, an SSO user, an API token or an invitation. The row reads
7
+ * only these fields.
8
+ */
9
+ export type UserRowEntity = {
10
+ type: 'user';
11
+ attributes: {
12
+ full_name?: string | null;
13
+ email: string;
14
+ };
15
+ } | {
16
+ type: 'account';
17
+ attributes: {
18
+ first_name?: string | null;
19
+ last_name?: string | null;
20
+ email: string;
21
+ };
22
+ } | {
23
+ type: 'organization';
24
+ attributes: {
25
+ name: string;
26
+ };
27
+ } | {
28
+ type: 'sso_user';
29
+ attributes: {
30
+ first_name?: string | null;
31
+ last_name?: string | null;
32
+ username: string;
33
+ };
34
+ } | {
35
+ type: 'access_token';
36
+ attributes: {
37
+ name?: string | null;
38
+ };
39
+ } | {
40
+ type: 'site_invitation';
41
+ attributes: {
42
+ email: string;
43
+ };
44
+ };
45
+ /** The data of a person that the row shows */
46
+ export type UserRowPresentation = {
47
+ /** The name. Without it, the email is the title. */
48
+ name: string | null | undefined;
49
+ /** The email. It gives the Gravatar image and the color of the initials. */
50
+ email: string | null | undefined;
51
+ /**
52
+ * The URL of the image of the avatar. Without it, the avatar is the
53
+ * Gravatar image of the email, and the initials of the name when the
54
+ * email has no Gravatar image.
55
+ */
56
+ imageUrl?: string | null;
57
+ };
58
+ /**
59
+ * The name and the email of a person, as DatoCMS shows them. The name falls
60
+ * back to the email. It is null only for an API token without a name: show
61
+ * the kind (`userKindLabel`) in its place.
62
+ */
63
+ export declare function userPresentation(user: UserRowEntity): {
64
+ name: string | null;
65
+ email: string | null;
66
+ };
67
+ /** The name of the kind of a person, for example "SSO user" */
68
+ export declare function userKindLabel(type: UserRowEntity['type']): TextMessage;
69
+ type Content =
70
+ /** The person as the API gives it */
71
+ {
72
+ /** The person. The row reads its name and its email. */
73
+ user: UserRowEntity;
74
+ /**
75
+ * Shows the kind of the person after the name, for example "SSO
76
+ * user". Use it when the list or the menu mixes people of different
77
+ * kinds.
78
+ * @default false
79
+ */
80
+ showKind?: boolean;
81
+ presentation?: never;
82
+ kind?: never;
83
+ }
84
+ /** The data of the person, already resolved */
85
+ | {
86
+ /** The name, the email and the image of the person */
87
+ presentation: UserRowPresentation;
88
+ /**
89
+ * The kind of person, after the name in the subtle ink. For example
90
+ * "SSO user", "API token" or "Invitation".
91
+ */
92
+ kind?: Message;
93
+ user?: never;
94
+ showKind?: never;
95
+ };
96
+ type Layout = {
97
+ /**
98
+ * "row" shows the email below the name, with an avatar of 32px: a row
99
+ * of a list, an option of a menu.
100
+ */
101
+ layout: 'row';
102
+ /**
103
+ * The line below the name, in place of the email. Write the email in
104
+ * it when the row needs it.
105
+ */
106
+ children?: ReactNode;
107
+ } | {
108
+ /**
109
+ * "inline" shows the name on one line, with an avatar of 20px: a
110
+ * chip, the value of a select, a cell of a table, a person in a text.
111
+ */
112
+ layout: 'inline';
113
+ children?: never;
114
+ };
115
+ export type UserRowProps = Content & Layout;
116
+ /**
117
+ * A person in a row: the avatar, the name, the email and the kind. It
118
+ * shows only the content: the container gives the surface, the hover and
119
+ * the click.
120
+ */
121
+ declare function UserRow(props: UserRowProps): React.JSX.Element;
122
+ export default UserRow;