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 @@ interface ButtonBaseProps {
10
10
  shortcut?: string;
11
11
  /**
12
12
  * Runs the command of the button. The button keeps the focus and the
13
- * selection in the editor, thus do not call `preventDefault()`.
13
+ * selection in the editor, so do not call `preventDefault()`.
14
14
  */
15
15
  onClick?: (event: React.MouseEvent) => void;
16
16
  }
@@ -14,7 +14,7 @@ type ActionBehavior =
14
14
  action?: never;
15
15
  }
16
16
  /**
17
- * Runs an action of the registry (`ui-public/Actions`). The tooltip of the
17
+ * Runs an action of the registry (`Actions`). The tooltip of the
18
18
  * button and the option of the ⋮ menu show its keys.
19
19
  */
20
20
  | {
@@ -6,11 +6,11 @@ import React from "react";
6
6
  import classNames from "classnames";
7
7
  import { jsx } from "react/jsx-runtime";
8
8
  //#region ../ui-public/src/actions/SplitButton/Caret.tsx
9
- /** The accessible name of the caret when the caller gives none */
9
+ /** The accessible name of the caret when you give none */
10
10
  var defaultCaretLabel = { id: "splitButton.moreActions" };
11
11
  /**
12
12
  * The caret half of a SplitButton. It has the tone and the size of the main
13
- * half, thus the two halves read as one button.
13
+ * half, so the two halves read as one button.
14
14
  */
15
15
  var Caret = React.memo(function Caret({ open, onTrigger, tone, size, ariaLabel, disabled }) {
16
16
  const { tm } = useTranslation();
@@ -4,7 +4,7 @@ import classNames from "classnames";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region ../ui-public/src/actions/SplitButton/Halves.tsx
6
6
  /**
7
- * The main half and the place of the caret. `SplitButton` and its picture
7
+ * The main half and the caret. `SplitButton` and its picture
8
8
  * at rest (`Static.tsx`) render it.
9
9
  */
10
10
  var SplitButtonHalves = React.forwardRef(function SplitButtonHalves({ main, className, children }, ref) {
@@ -29,8 +29,8 @@ export type SplitButtonProps = {
29
29
  */
30
30
  tone?: Extract<ButtonTone, 'primary' | 'soft'>;
31
31
  /**
32
- * The size of the two halves. The size of the place by default: "milli"
33
- * in a toolbar, "small" out of a toolbar (see useButtonSize).
32
+ * The size of the two halves. The default size is "milli" in a toolbar
33
+ * and "small" out of a toolbar (see useButtonSize).
34
34
  */
35
35
  size?: ButtonSize;
36
36
  /**
@@ -38,7 +38,7 @@ export type SplitButtonProps = {
38
38
  * to disable it too. Give a reason when the user must know why.
39
39
  */
40
40
  disabled?: ButtonProps['disabled'];
41
- /** Only for the place of the split button, not for its look */
41
+ /** Only for the position of the split button, not for its look */
42
42
  className?: string;
43
43
  /** The caret and its menu */
44
44
  menu?: SplitButtonMenu;
@@ -3,10 +3,10 @@ import React from 'react';
3
3
  import { type Message } from '../Message.js';
4
4
  import type { FloatingTrigger } from '../overlays/floatingTrigger.js';
5
5
  /**
6
- * A disabled control that tells why. It keeps the focus and the hover
7
- * ("aria-disabled" in place of "disabled"), thus its tooltip shows the
8
- * reason, also to the keyboard and screen reader users.
9
- * With "interactive", the reason has links: it shows in a HoverCard, thus
6
+ * A disabled control that says why. It keeps the focus and the hover
7
+ * ("aria-disabled" instead of "disabled"), so its tooltip shows the
8
+ * reason, even to the keyboard and screen reader users.
9
+ * With "interactive", the reason has links. It shows in a HoverCard, so
10
10
  * the pointer can move into it.
11
11
  */
12
12
  export type DisabledWithReason = {
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  * "small" is 20px, "regular" is 30px, "large" is 40px, "xlarge" is 48px.
4
4
  * The regular and the large avatars have a ring, so avatars in a stack stay
5
5
  * apart. The xlarge avatar is for a single person, for example the header of
6
- * a profile, thus it has no ring.
6
+ * a profile, so it has no ring.
7
7
  */
8
8
  export type AvatarSize = 'small' | 'regular' | 'large' | 'xlarge';
9
9
  /** The side of each size in pixels, for example to ask an image of that size */
@@ -53,8 +53,8 @@ export type AvatarProps = AvatarIdentity & {
53
53
  labelled?: boolean;
54
54
  };
55
55
  /**
56
- * The avatar of a person. It does not know where the person comes from: the
57
- * app reads the name, the email and the image URL and gives them.
56
+ * The avatar of a person. It does not know where the person comes from. You
57
+ * read the name, the email and the image URL and give them.
58
58
  */
59
59
  declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLDivElement>>;
60
60
  export default Avatar;
@@ -20,8 +20,8 @@ function gravatarUrl(email, pixels) {
20
20
  })}`;
21
21
  }
22
22
  /**
23
- * The avatar of a person. It does not know where the person comes from: the
24
- * app reads the name, the email and the image URL and gives them.
23
+ * The avatar of a person. It does not know where the person comes from. You
24
+ * read the name, the email and the image URL and give them.
25
25
  */
26
26
  var Avatar = forwardRef(({ size = "regular", active = false, name, email, imageUrl, gravatar, labelled = false }, ref) => {
27
27
  const url = gravatar ? email ? gravatarUrl(email, AVATAR_SIZE_IN_PIXELS[size] * 2) : null : imageUrl;
@@ -5,7 +5,7 @@ export type CodeSnippetProps = {
5
5
  code: string;
6
6
  /**
7
7
  * The name of the box for screen readers, for example "Request body". The
8
- * box is a region that the keyboard can focus, thus the arrow keys
8
+ * box is a region that the keyboard can focus, so the arrow keys
9
9
  * scroll it.
10
10
  */
11
11
  ariaLabel: TextMessage;
@@ -10,7 +10,7 @@ type CopyableValueName =
10
10
  hint?: Message;
11
11
  ariaLabel?: never;
12
12
  }
13
- /** No visible label, for example a link under a text that tells it */
13
+ /** No visible label, for example a link under a text that says it */
14
14
  | {
15
15
  /** The name of the field for screen readers */
16
16
  ariaLabel: TextMessage;
@@ -9,7 +9,7 @@ export type EnvironmentPillProps = {
9
9
  */
10
10
  label?: Message;
11
11
  };
12
- /** A pill that tells the type of an environment, with its icon */
12
+ /** A pill that shows the type of an environment, with its icon */
13
13
  declare function EnvironmentPill({ primary, label }: EnvironmentPillProps): React.JSX.Element;
14
14
  declare const _default: React.MemoExoticComponent<typeof EnvironmentPill>;
15
15
  export default _default;
@@ -4,7 +4,7 @@ import Pill_default from "./Pill.js";
4
4
  import React from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region ../ui-public/src/content/EnvironmentPill.tsx
7
- /** A pill that tells the type of an environment, with its icon */
7
+ /** A pill that shows the type of an environment, with its icon */
8
8
  function EnvironmentPill({ primary, label }) {
9
9
  const { tc } = useTranslation();
10
10
  const Icon = primary ? Environments.PrimaryEnvironmentIcon : Environments.SandboxEnvironmentIcon;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { type TextMessage } from '../Message.js';
3
+ import { type FieldType } from '../utils/fieldTypes.js';
4
+ export type FieldTypeAvatarProps = {
5
+ /** The `field_type` of the field, as the CMA gives it, for example `"rich_text"` */
6
+ fieldType: FieldType | (string & {});
7
+ /** The side of the square in pixels, for example 32 in the image of an EntityRow */
8
+ size: number;
9
+ /**
10
+ * The name for the screen readers. Use it only when no text near the
11
+ * avatar says the type of the field. Without it, the screen readers do
12
+ * not read the avatar.
13
+ */
14
+ ariaLabel?: TextMessage;
15
+ };
16
+ /**
17
+ * The icon of the group of a field type, on the colors of the group, as
18
+ * DatoCMS shows a field type. A type that the component does not know
19
+ * gets a generic icon on the neutral surface.
20
+ */
21
+ declare function FieldTypeAvatar({ fieldType, size, ariaLabel }: FieldTypeAvatarProps): React.JSX.Element;
22
+ export default FieldTypeAvatar;
@@ -0,0 +1,35 @@
1
+ import { FieldGroup, Generic } from "../../icons/index.js";
2
+ import IconAvatar from "./IconAvatar.js";
3
+ import { fieldGroupOf, fieldTypeSurface } from "../utils/fieldTypes.js";
4
+ import "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region ../ui-public/src/content/FieldTypeAvatar.tsx
7
+ var groupIcons = {
8
+ boolean: FieldGroup.BooleanGroupIcon,
9
+ color: FieldGroup.ColorGroupIcon,
10
+ datetime: FieldGroup.DatetimeGroupIcon,
11
+ json: FieldGroup.JsonGroupIcon,
12
+ location: FieldGroup.LocationGroupIcon,
13
+ media: FieldGroup.MediaGroupIcon,
14
+ number: FieldGroup.NumberGroupIcon,
15
+ reference: FieldGroup.ReferenceGroupIcon,
16
+ rich_text: FieldGroup.RichTextGroupIcon,
17
+ seo: FieldGroup.SeoGroupIcon,
18
+ text: FieldGroup.StructuredTextGroupIcon
19
+ };
20
+ /**
21
+ * The icon of the group of a field type, on the colors of the group, as
22
+ * DatoCMS shows a field type. A type that the component does not know
23
+ * gets a generic icon on the neutral surface.
24
+ */
25
+ function FieldTypeAvatar({ fieldType, size, ariaLabel }) {
26
+ const group = fieldGroupOf(fieldType);
27
+ return /* @__PURE__ */ jsx(IconAvatar, {
28
+ icon: group ? groupIcons[group] : Generic.CircleQuestionIcon,
29
+ size,
30
+ surface: fieldTypeSurface(fieldType),
31
+ ariaLabel
32
+ });
33
+ }
34
+ //#endregion
35
+ export { FieldTypeAvatar as default };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { type FieldType } from '../utils/fieldTypes.js';
3
+ export type FieldTypeNameProps = {
4
+ /** The `field_type` of the field, as the CMA gives it, for example `"rich_text"` */
5
+ fieldType: FieldType | (string & {});
6
+ };
7
+ /**
8
+ * Gives a function that returns the name of a field type as a string, in
9
+ * the language of the user. Use it when the name is a part of a string, for
10
+ * example the text of a tooltip. In JSX, use `FieldTypeName`. A type that
11
+ * the function does not know gives its `field_type` string.
12
+ */
13
+ export declare function useFieldTypeName(): (fieldType: FieldType | (string & {})) => string;
14
+ /**
15
+ * The name of a field type as text, in the language of the user. A type
16
+ * that the component does not know shows its `field_type` string.
17
+ */
18
+ declare function FieldTypeName({ fieldType }: FieldTypeNameProps): React.JSX.Element;
19
+ export default FieldTypeName;
@@ -0,0 +1,25 @@
1
+ import { useTranslation } from "../i18n.js";
2
+ import { fieldTypeMessage } from "../utils/fieldTypes.js";
3
+ import { useCallback } from "react";
4
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
5
+ //#region ../ui-public/src/content/FieldTypeName.tsx
6
+ /**
7
+ * Gives a function that returns the name of a field type as a string, in
8
+ * the language of the user. Use it when the name is a part of a string, for
9
+ * example the text of a tooltip. In JSX, use `FieldTypeName`. A type that
10
+ * the function does not know gives its `field_type` string.
11
+ */
12
+ function useFieldTypeName() {
13
+ const { tm } = useTranslation();
14
+ return useCallback((fieldType) => tm(fieldTypeMessage(fieldType)), [tm]);
15
+ }
16
+ /**
17
+ * The name of a field type as text, in the language of the user. A type
18
+ * that the component does not know shows its `field_type` string.
19
+ */
20
+ function FieldTypeName({ fieldType }) {
21
+ const fieldTypeName = useFieldTypeName();
22
+ return /* @__PURE__ */ jsx(Fragment$1, { children: fieldTypeName(fieldType) });
23
+ }
24
+ //#endregion
25
+ export { FieldTypeName as default, useFieldTypeName };
@@ -13,7 +13,8 @@ export type IconAvatarSurface =
13
13
  /**
14
14
  * A surface and an ink from the data or from a context of tokens, for
15
15
  * example `{ color: 'var(--color--field-group-media--surface)', ink:
16
- * 'var(--color--field-group-media--ink)' }`
16
+ * 'var(--color--field-group-media--ink)' }`. `fieldTypeSurface` gives
17
+ * this pair for the group of a field type.
17
18
  */
18
19
  | {
19
20
  color: string;
@@ -28,7 +29,7 @@ export type IconAvatarProps = {
28
29
  surface?: IconAvatarSurface;
29
30
  /**
30
31
  * The name for the screen readers. Use it only when no text near the
31
- * avatar tells what the icon shows. Without it, the screen readers do not
32
+ * avatar says what the icon shows. Without it, the screen readers do not
32
33
  * read the avatar.
33
34
  */
34
35
  ariaLabel?: TextMessage;
@@ -9,7 +9,7 @@ type Display =
9
9
  display?: 'dot';
10
10
  /**
11
11
  * The name of the status, for example "Published". It goes in the
12
- * tooltip and in `aria-label`, thus it is a text.
12
+ * tooltip and in `aria-label`, so it is a text.
13
13
  * @default the name of the status: "Published", "Unpublished changes", "Draft" or "New"
14
14
  */
15
15
  label?: TextMessage;
@@ -36,7 +36,7 @@ export type PillProps = {
36
36
  icon?: React.ReactNode;
37
37
  /**
38
38
  * A hint in a tooltip, on hover and on keyboard focus. A static pill with a
39
- * tooltip takes the focus, thus the keyboard can reach the hint.
39
+ * tooltip takes the focus, so the keyboard can reach the hint.
40
40
  */
41
41
  tooltip?: Message;
42
42
  /** The text of the pill. Keep it short: a long text gets an ellipsis. */
@@ -19,7 +19,7 @@ export type SmartDateProps = {
19
19
  */
20
20
  withSeconds?: boolean;
21
21
  /**
22
- * Show "Today, 09:30" in place of the date and the time when the date is
22
+ * Show "Today, 09:30" instead of the date and the time when the date is
23
23
  * today. It has an effect only with `show="dateTime"`.
24
24
  * @default true
25
25
  */
@@ -0,0 +1,200 @@
1
+ import Image from "../../semantic/Image.js";
2
+ import FileTypeIcon from "../FileTypeIcon.js";
3
+ import { useElementLayout } from "../../hooks/useElementLayout.js";
4
+ import { AudioPlayPause } from "./audio.js";
5
+ import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./fit.js";
6
+ import box_default from "./box.js";
7
+ import { ThumbhashCanvas } from "./thumbhash.js";
8
+ import { uploadDefaultPosterTime, uploadFileUrl, uploadPreviewKind, videoFrameUrl } from "./upload.js";
9
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ //#region ../ui-public/src/content/UploadPreview/asset.tsx
12
+ var MAX_DOCUMENT_ICON_HEIGHT = 100;
13
+ var DOCUMENT_ICON_SIZE = {
14
+ width: 448 / 512 * MAX_DOCUMENT_ICON_HEIGHT,
15
+ height: MAX_DOCUMENT_ICON_HEIGHT
16
+ };
17
+ var FadeInImage = ({ style, src, ...props }) => {
18
+ const [loadedSrc, setLoadedSrc] = useState(void 0);
19
+ useEffect(() => {
20
+ if (!src) return;
21
+ const image = new window.Image();
22
+ image.onload = () => {
23
+ setLoadedSrc(src);
24
+ };
25
+ image.src = src;
26
+ return () => {
27
+ image.onload = null;
28
+ image.src = "";
29
+ };
30
+ }, [src]);
31
+ return /* @__PURE__ */ jsx(Image, {
32
+ ...props,
33
+ src: loadedSrc,
34
+ style: {
35
+ ...style,
36
+ transition: "opacity 0.2s ease-in-out",
37
+ opacity: loadedSrc ? 1 : 0
38
+ }
39
+ });
40
+ };
41
+ var ThumbhashImage = React.memo(function ThumbhashImage({ thumbhash, src, style }) {
42
+ const [isLoaded, setLoaded] = useState(false);
43
+ return /* @__PURE__ */ jsxs("div", {
44
+ style: {
45
+ ...style,
46
+ position: "relative"
47
+ },
48
+ className: "checkboard-bg",
49
+ children: [/* @__PURE__ */ jsx(ThumbhashCanvas, {
50
+ thumbhash,
51
+ style: {
52
+ position: "absolute",
53
+ left: 0,
54
+ top: 0,
55
+ width: "100%",
56
+ height: "100%",
57
+ opacity: isLoaded ? 0 : 1,
58
+ transition: "opacity 0.2s ease-in-out"
59
+ }
60
+ }), /* @__PURE__ */ jsx(FadeInImage, {
61
+ src,
62
+ style: {
63
+ ...style,
64
+ position: "relative",
65
+ display: "block",
66
+ zIndex: "1"
67
+ },
68
+ onLoad: () => setLoaded(true),
69
+ alt: "",
70
+ draggable: "false"
71
+ })]
72
+ });
73
+ });
74
+ function useHasBeenVisible(ref) {
75
+ const [visible, setVisible] = useState(false);
76
+ useEffect(() => {
77
+ const element = ref.current;
78
+ if (visible || !element) return;
79
+ if (typeof IntersectionObserver === "undefined") {
80
+ setVisible(true);
81
+ return;
82
+ }
83
+ const observer = new IntersectionObserver((entries) => {
84
+ if (entries.some((entry) => entry.isIntersecting)) {
85
+ observer.disconnect();
86
+ setVisible(true);
87
+ }
88
+ });
89
+ observer.observe(element);
90
+ return () => observer.disconnect();
91
+ }, [ref, visible]);
92
+ return visible;
93
+ }
94
+ function pixelRatio() {
95
+ return typeof window === "undefined" ? 1 : window.devicePixelRatio || 1;
96
+ }
97
+ function renderAsset({ upload, box, padding, posterTime, wrapImage, audioPlayback }) {
98
+ const iconPadding = nonImagePadding(padding);
99
+ if (!upload) {
100
+ const fit = fitInBox(box, iconPadding, DOCUMENT_ICON_SIZE, false);
101
+ return /* @__PURE__ */ jsx(FileTypeIcon, {
102
+ style: fit.style,
103
+ extension: ""
104
+ });
105
+ }
106
+ const { attributes } = upload;
107
+ const kind = uploadPreviewKind(attributes);
108
+ if (kind === "audio") return /* @__PURE__ */ jsx(AudioPlayPause, {
109
+ url: attributes.url,
110
+ playback: audioPlayback,
111
+ width: box.width,
112
+ height: box.height
113
+ });
114
+ if (kind === "video-encoding") return /* @__PURE__ */ jsx(box_default.Progress, {
115
+ percent: 0,
116
+ label: { id: "uploadPreview.encodingVideo" }
117
+ });
118
+ if (kind === "file" || !attributes.width || !attributes.height) {
119
+ const fit = fitInBox(box, iconPadding, DOCUMENT_ICON_SIZE, false);
120
+ return /* @__PURE__ */ jsx(FileTypeIcon, {
121
+ style: fit.style,
122
+ extension: attributes.format ?? ""
123
+ });
124
+ }
125
+ const content = {
126
+ width: attributes.width,
127
+ height: attributes.height
128
+ };
129
+ const upscale = attributes.format?.toLowerCase() === "svg";
130
+ const fit = fitInBox(box, padding, content, upscale);
131
+ const downloadWidth = Math.round(pixelRatio() * fit.width);
132
+ if (kind === "video" && attributes.mux_playback_id) {
133
+ const src = videoFrameUrl(attributes.mux_playback_id, downloadWidth, posterTime !== void 0 ? posterTime : uploadDefaultPosterTime(upload));
134
+ if (attributes.thumbhash) return /* @__PURE__ */ jsx(ThumbhashImage, {
135
+ thumbhash: attributes.thumbhash,
136
+ src,
137
+ style: fit.style
138
+ }, attributes.mux_playback_id);
139
+ return /* @__PURE__ */ jsx(box_default.Image, {
140
+ src,
141
+ ...content,
142
+ alt: ""
143
+ });
144
+ }
145
+ if (kind === "image") {
146
+ const src = uploadFileUrl(attributes, {
147
+ auto: "format",
148
+ w: downloadWidth
149
+ });
150
+ const image = attributes.thumbhash ? /* @__PURE__ */ jsx(ThumbhashImage, {
151
+ thumbhash: attributes.thumbhash,
152
+ src,
153
+ style: fit.style
154
+ }, attributes.thumbhash) : /* @__PURE__ */ jsx(FadeInImage, {
155
+ style: fit.style,
156
+ src,
157
+ alt: ""
158
+ }, attributes.url);
159
+ return wrapImage ? wrapImage(image, fit.style) : image;
160
+ }
161
+ return /* @__PURE__ */ jsx(box_default.Image, {
162
+ src: uploadFileUrl(attributes),
163
+ ...content,
164
+ upscale,
165
+ alt: ""
166
+ });
167
+ }
168
+ /**
169
+ * The preview of an asset entity: the image, the frame of a video, the
170
+ * waveform of a sound, or the icon of the format. The `UploadPreview` and
171
+ * the `UploadCard` with `upload` render it.
172
+ */
173
+ var UploadAssetPreview = forwardRef(function UploadAssetPreview({ upload, box: fixedBox, padding = DEFAULT_PADDING, transparent, link, posterTime, children, wrapImage, audioPlayback }, ref) {
174
+ const elementRef = useRef(null);
175
+ useImperativeHandle(ref, () => elementRef.current);
176
+ const rect = useElementLayout(elementRef);
177
+ const visible = useHasBeenVisible(elementRef);
178
+ const box = fixedBox ?? (rect.width && rect.height ? {
179
+ width: rect.width,
180
+ height: rect.height
181
+ } : null);
182
+ return /* @__PURE__ */ jsxs(box_default, {
183
+ ref: elementRef,
184
+ box,
185
+ fixedSize: !!fixedBox,
186
+ padding,
187
+ transparent,
188
+ link,
189
+ children: [visible && box && upload !== void 0 && renderAsset({
190
+ upload,
191
+ box,
192
+ padding,
193
+ posterTime,
194
+ wrapImage,
195
+ audioPlayback
196
+ }), children]
197
+ });
198
+ });
199
+ //#endregion
200
+ export { UploadAssetPreview };
@@ -0,0 +1,120 @@
1
+ import { Status } from "../../../icons/index.js";
2
+ import { useTranslation } from "../../i18n.js";
3
+ import RawButton from "../../semantic/RawButton.js";
4
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
+ import classNames from "classnames";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ //#region ../ui-public/src/content/UploadPreview/audio.tsx
8
+ var pauseListeners = /* @__PURE__ */ new Set();
9
+ /** Stops all the players of the page */
10
+ function pauseAllPlayers() {
11
+ for (const pause of pauseListeners) pause();
12
+ }
13
+ /**
14
+ * Calls `pause` when another player starts. Call `pauseAllPlayers` before
15
+ * a player starts. Returns the function that removes the listener.
16
+ */
17
+ function addPauseListener(pause) {
18
+ pauseListeners.add(pause);
19
+ return () => {
20
+ pauseListeners.delete(pause);
21
+ };
22
+ }
23
+ /**
24
+ * Plays a sound file. The waveform of a preview and the play action of a
25
+ * card use this hook. The hook makes the audio element at the first play,
26
+ * thus a page with many cards does not load the files. Give `null` for no
27
+ * file.
28
+ */
29
+ function useAudioPlayback(url) {
30
+ const audioRef = useRef(null);
31
+ const listenersRef = useRef(null);
32
+ const [isPlaying, setIsPlaying] = useState(false);
33
+ const [progress, setProgress] = useState(0);
34
+ useEffect(() => {
35
+ setIsPlaying(false);
36
+ setProgress(0);
37
+ return () => {
38
+ listenersRef.current?.abort();
39
+ listenersRef.current = null;
40
+ audioRef.current?.pause();
41
+ audioRef.current = null;
42
+ };
43
+ }, [url]);
44
+ useEffect(() => addPauseListener(() => {
45
+ audioRef.current?.pause();
46
+ }), []);
47
+ const toggle = useCallback(() => {
48
+ if (!url) return;
49
+ if (!audioRef.current) {
50
+ const audio = new Audio(url);
51
+ const listeners = new AbortController();
52
+ const { signal } = listeners;
53
+ audio.addEventListener("play", () => setIsPlaying(true), { signal });
54
+ audio.addEventListener("pause", () => setIsPlaying(false), { signal });
55
+ audio.addEventListener("ended", () => setProgress(0), { signal });
56
+ audio.addEventListener("timeupdate", () => {
57
+ if (Number.isFinite(audio.duration) && audio.duration > 0) setProgress(audio.currentTime / audio.duration * 100);
58
+ }, { signal });
59
+ audioRef.current = audio;
60
+ listenersRef.current = listeners;
61
+ }
62
+ const audio = audioRef.current;
63
+ if (!audio.paused) {
64
+ audio.pause();
65
+ return;
66
+ }
67
+ pauseAllPlayers();
68
+ audio.play().catch(() => {});
69
+ }, [url]);
70
+ return useMemo(() => ({
71
+ isPlaying,
72
+ progress,
73
+ toggle
74
+ }), [
75
+ isPlaying,
76
+ progress,
77
+ toggle
78
+ ]);
79
+ }
80
+ /** The waveform of a sound file, with a play button */
81
+ var AudioPlayPause = React.memo(function AudioPlayPause({ url, width, height, playback }) {
82
+ const { t } = useTranslation();
83
+ const ownPlayback = useAudioPlayback(playback ? null : url);
84
+ const { isPlaying, progress, toggle } = playback ?? ownPlayback;
85
+ const handleClick = useCallback((e) => {
86
+ e.stopPropagation();
87
+ e.preventDefault();
88
+ toggle();
89
+ }, [toggle]);
90
+ const waveStyle = useMemo(() => ({ "--AudioPlayPause-progress": `${progress}%` }), [progress]);
91
+ let style;
92
+ if (width > 110) {
93
+ const scale = Math.min(width / 300, height / 200);
94
+ style = {
95
+ width: `${300 * scale}px`,
96
+ height: `${200 * scale}px`
97
+ };
98
+ } else style = {
99
+ width,
100
+ height
101
+ };
102
+ return /* @__PURE__ */ jsxs("div", {
103
+ className: classNames("AudioPlayPause", {
104
+ big: width >= 100,
105
+ small: width < 100
106
+ }),
107
+ style,
108
+ children: [/* @__PURE__ */ jsx("div", {
109
+ className: "AudioPlayPause__wave",
110
+ style: waveStyle
111
+ }), !playback && /* @__PURE__ */ jsx(RawButton, {
112
+ className: classNames("AudioPlayPause__button", { "button button--icon-only button--primary": width >= 100 }),
113
+ ariaLabel: t(isPlaying ? "audioPlayer.pause" : "audioPlayer.play"),
114
+ onClick: handleClick,
115
+ children: isPlaying ? /* @__PURE__ */ jsx(Status.PauseIcon, {}) : /* @__PURE__ */ jsx(Status.PlayIcon, {})
116
+ })]
117
+ });
118
+ });
119
+ //#endregion
120
+ export { AudioPlayPause, addPauseListener, pauseAllPlayers, useAudioPlayback };