datocms-react-ui 3.1.0-next.6 → 4.0.0-next.7

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 (222) hide show
  1. package/README.md +2 -1
  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/FilterBuilder.d.ts +2 -0
  9. package/dist/FilterBuilder.js +2 -0
  10. package/dist/RecordRow.d.ts +2 -0
  11. package/dist/RecordRow.js +2 -0
  12. package/dist/UploadCard.js +2 -2
  13. package/dist/UploadPreview.d.ts +2 -2
  14. package/dist/UploadPreview.js +1 -1
  15. package/dist/UserRow.d.ts +2 -0
  16. package/dist/UserRow.js +2 -0
  17. package/dist/react-ui/src/Canvas.d.ts +7 -1
  18. package/dist/react-ui/src/Canvas.js +26 -4
  19. package/dist/react-ui/src/ctxAnswer.js +21 -0
  20. package/dist/react-ui/src/ctxDateSettings.js +7 -5
  21. package/dist/react-ui/src/ctxRecordPresentation.js +34 -0
  22. package/dist/react-ui/src/ctxUploads.js +23 -0
  23. package/dist/styles.css +592 -11
  24. package/dist/ui-public/icons/index.js +79 -81
  25. package/dist/ui-public/locales/en.js +43 -5
  26. package/dist/ui-public/src/Message.d.ts +3 -4
  27. package/dist/ui-public/src/UiTextKey.d.ts +1 -1
  28. package/dist/ui-public/src/actions/Actions/ActionTooltip.js +1 -1
  29. package/dist/ui-public/src/actions/Actions/registry.d.ts +2 -2
  30. package/dist/ui-public/src/actions/Actions/registry.js +2 -2
  31. package/dist/ui-public/src/actions/Button.d.ts +10 -10
  32. package/dist/ui-public/src/actions/Button.js +1 -1
  33. package/dist/ui-public/src/actions/Dropdown/Menu.d.ts +2 -2
  34. package/dist/ui-public/src/actions/Dropdown/Option.d.ts +7 -7
  35. package/dist/ui-public/src/actions/Dropdown/index.d.ts +1 -1
  36. package/dist/ui-public/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +5 -5
  37. package/dist/ui-public/src/actions/Dropdown/triggers/DropdownTriggerButton.d.ts +2 -2
  38. package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.d.ts +6 -6
  39. package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.js +1 -1
  40. package/dist/ui-public/src/actions/EditorToolbar/Button.d.ts +1 -1
  41. package/dist/ui-public/src/actions/MultipleSelectionActionBar.d.ts +1 -1
  42. package/dist/ui-public/src/actions/SplitButton/Caret.js +2 -2
  43. package/dist/ui-public/src/actions/SplitButton/Halves.js +1 -1
  44. package/dist/ui-public/src/actions/SplitButton/index.d.ts +3 -3
  45. package/dist/ui-public/src/actions/disabledReason.d.ts +4 -4
  46. package/dist/ui-public/src/content/Avatar.d.ts +3 -3
  47. package/dist/ui-public/src/content/Avatar.js +2 -2
  48. package/dist/ui-public/src/content/CodeSnippet.d.ts +1 -1
  49. package/dist/ui-public/src/content/CopyableValue.d.ts +1 -1
  50. package/dist/ui-public/src/content/EnvironmentPill.d.ts +1 -1
  51. package/dist/ui-public/src/content/EnvironmentPill.js +1 -1
  52. package/dist/ui-public/src/content/IconAvatar.d.ts +1 -1
  53. package/dist/ui-public/src/content/ItemStatus.d.ts +1 -1
  54. package/dist/ui-public/src/content/Pill.d.ts +1 -1
  55. package/dist/ui-public/src/content/SmartDate.d.ts +1 -1
  56. package/dist/ui-public/src/content/UploadPreview/asset.js +200 -0
  57. package/dist/ui-public/src/content/UploadPreview/audio.js +120 -0
  58. package/dist/ui-public/src/content/{UploadPreview.d.ts → UploadPreview/box.d.ts} +10 -10
  59. package/dist/ui-public/src/content/{UploadPreview.js → UploadPreview/box.js} +7 -7
  60. package/dist/ui-public/src/content/{uploadPreviewFit.d.ts → UploadPreview/fit.d.ts} +2 -2
  61. package/dist/ui-public/src/content/{uploadPreviewFit.js → UploadPreview/fit.js} +3 -3
  62. package/dist/ui-public/src/content/UploadPreview/index.d.ts +61 -0
  63. package/dist/ui-public/src/content/UploadPreview/index.js +36 -0
  64. package/dist/ui-public/src/content/UploadPreview/presentation.js +63 -0
  65. package/dist/ui-public/src/content/UploadPreview/thumbhash.js +91 -0
  66. package/dist/ui-public/src/content/UploadPreview/upload.d.ts +104 -0
  67. package/dist/ui-public/src/content/UploadPreview/upload.js +112 -0
  68. package/dist/ui-public/src/content/UsageMeter.d.ts +1 -1
  69. package/dist/ui-public/src/content/ValidityTriangles.d.ts +1 -1
  70. package/dist/ui-public/src/feedback/BlankSlate.d.ts +5 -5
  71. package/dist/ui-public/src/feedback/Callout.d.ts +5 -5
  72. package/dist/ui-public/src/feedback/Callout.js +1 -1
  73. package/dist/ui-public/src/feedback/ProgressBar.d.ts +4 -4
  74. package/dist/ui-public/src/feedback/Spinner.d.ts +6 -6
  75. package/dist/ui-public/src/feedback/Spinner.js +1 -1
  76. package/dist/ui-public/src/form/DateInput.d.ts +13 -0
  77. package/dist/ui-public/src/form/DateInput.js +16 -0
  78. package/dist/ui-public/src/form/DateTimeInput/Base.d.ts +89 -0
  79. package/dist/ui-public/src/form/DateTimeInput/Base.js +330 -0
  80. package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.d.ts +29 -0
  81. package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.js +195 -0
  82. package/dist/ui-public/src/form/DateTimeInput/dateText.js +38 -0
  83. package/dist/ui-public/src/form/DateTimeInput/index.d.ts +10 -0
  84. package/dist/ui-public/src/form/DateTimeInput/index.js +18 -0
  85. package/dist/ui-public/src/form/DateTimeInput/value.js +31 -0
  86. package/dist/ui-public/src/form/DateTimeRangeInput/Panel.js +167 -0
  87. package/dist/ui-public/src/form/DateTimeRangeInput/index.d.ts +123 -0
  88. package/dist/ui-public/src/form/DateTimeRangeInput/index.js +186 -0
  89. package/dist/ui-public/src/form/DateTimeRangeInput/rangeLabel.js +46 -0
  90. package/dist/ui-public/src/form/FieldHint.d.ts +2 -2
  91. package/dist/ui-public/src/form/FieldWrapper.d.ts +9 -9
  92. package/dist/ui-public/src/form/FieldWrapper.js +3 -3
  93. package/dist/ui-public/src/form/FilterBuilder/Editor.js +123 -0
  94. package/dist/ui-public/src/form/FilterBuilder/index.d.ts +9 -0
  95. package/dist/ui-public/src/form/FilterBuilder/index.js +294 -0
  96. package/dist/ui-public/src/form/FilterBuilder/types.d.ts +188 -0
  97. package/dist/ui-public/src/form/FilterBuilder/values.js +86 -0
  98. package/dist/ui-public/src/form/InputGroup.d.ts +2 -2
  99. package/dist/ui-public/src/form/InputGroup.js +1 -1
  100. package/dist/ui-public/src/form/KeyValueList.d.ts +1 -1
  101. package/dist/ui-public/src/form/Label.d.ts +2 -2
  102. package/dist/ui-public/src/form/RadioGroupInput.d.ts +2 -2
  103. package/dist/ui-public/src/form/RadioGroupInput.js +1 -1
  104. package/dist/ui-public/src/form/SelectInput/SelectMenu.d.ts +2 -2
  105. package/dist/ui-public/src/form/SelectInput/index.d.ts +3 -3
  106. package/dist/ui-public/src/form/SwitchInput.d.ts +2 -2
  107. package/dist/ui-public/src/form/SwitchList.d.ts +1 -1
  108. package/dist/ui-public/src/form/SwitchList.js +1 -1
  109. package/dist/ui-public/src/form/TableList.d.ts +2 -2
  110. package/dist/ui-public/src/form/TextareaInput.js +1 -1
  111. package/dist/ui-public/src/form/inputProps.d.ts +6 -6
  112. package/dist/ui-public/src/hooks/useAsyncSelectOptions.d.ts +1 -1
  113. package/dist/ui-public/src/hooks/useSmartRowClick.d.ts +1 -1
  114. package/dist/ui-public/src/hooks/useSmartRowClick.js +1 -1
  115. package/dist/ui-public/src/layout/Page/PageGroup.d.ts +2 -2
  116. package/dist/ui-public/src/layout/Page/PageGroup.js +1 -1
  117. package/dist/ui-public/src/layout/Pane/FormHeader.d.ts +1 -1
  118. package/dist/ui-public/src/layout/Pane/FormHeader.js +1 -1
  119. package/dist/ui-public/src/layout/Pane/ListFilter.d.ts +1 -1
  120. package/dist/ui-public/src/layout/Pane/ListPresets.d.ts +1 -1
  121. package/dist/ui-public/src/layout/Pane/PaneHeader.d.ts +1 -1
  122. package/dist/ui-public/src/layout/Pane/index.d.ts +2 -2
  123. package/dist/ui-public/src/layout/SidebarPanel.d.ts +1 -1
  124. package/dist/ui-public/src/layout/SplitPane/Rail.js +1 -1
  125. package/dist/ui-public/src/layout/SplitPane/index.d.ts +6 -6
  126. package/dist/ui-public/src/layout/Toolbar/AddNewButton.d.ts +2 -2
  127. package/dist/ui-public/src/layout/Toolbar/Help.d.ts +3 -3
  128. package/dist/ui-public/src/layout/Toolbar/Help.js +2 -2
  129. package/dist/ui-public/src/layout/Toolbar/Note.d.ts +1 -1
  130. package/dist/ui-public/src/layout/Toolbar/Note.js +1 -1
  131. package/dist/ui-public/src/layout/Toolbar/Pagination.d.ts +1 -1
  132. package/dist/ui-public/src/layout/Toolbar/Pagination.js +1 -1
  133. package/dist/ui-public/src/layout/Toolbar/PresetsTitle.d.ts +3 -3
  134. package/dist/ui-public/src/layout/Toolbar/PresetsTitle.js +2 -2
  135. package/dist/ui-public/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
  136. package/dist/ui-public/src/layout/Toolbar/Root.d.ts +1 -1
  137. package/dist/ui-public/src/layout/Toolbar/Root.js +4 -1
  138. package/dist/ui-public/src/layout/Toolbar/ToolbarTitleTrigger.js +1 -1
  139. package/dist/ui-public/src/lists/CardList.d.ts +3 -3
  140. package/dist/ui-public/src/lists/EmptySlot.d.ts +1 -1
  141. package/dist/ui-public/src/lists/InfoList/User.d.ts +1 -1
  142. package/dist/ui-public/src/lists/InfoList/Value.d.ts +1 -1
  143. package/dist/ui-public/src/lists/InfoList/Value.js +1 -1
  144. package/dist/ui-public/src/lists/InfoList/index.d.ts +3 -3
  145. package/dist/ui-public/src/lists/InfoList/index.js +1 -1
  146. package/dist/ui-public/src/lists/MediaCard.d.ts +7 -7
  147. package/dist/ui-public/src/lists/RecordRow/Image.d.ts +24 -0
  148. package/dist/ui-public/src/lists/RecordRow/Image.js +22 -0
  149. package/dist/ui-public/src/lists/RecordRow/List.d.ts +26 -0
  150. package/dist/ui-public/src/lists/RecordRow/List.js +30 -0
  151. package/dist/ui-public/src/lists/RecordRow/context.js +31 -0
  152. package/dist/ui-public/src/lists/RecordRow/index.d.ts +94 -0
  153. package/dist/ui-public/src/lists/RecordRow/index.js +122 -0
  154. package/dist/ui-public/src/lists/RecordRow/presentation.js +73 -0
  155. package/dist/ui-public/src/lists/RecordRow/types.d.ts +58 -0
  156. package/dist/ui-public/src/lists/RowList.d.ts +5 -5
  157. package/dist/ui-public/src/lists/SettingsList.d.ts +3 -3
  158. package/dist/ui-public/src/lists/SettingsList.js +2 -2
  159. package/dist/ui-public/src/lists/Table/Row.d.ts +5 -5
  160. package/dist/ui-public/src/lists/Table/Table.d.ts +3 -3
  161. package/dist/ui-public/src/lists/Table/TreeToggle.d.ts +2 -2
  162. package/dist/ui-public/src/lists/Table/TreeToggle.js +1 -1
  163. package/dist/ui-public/src/lists/Table/cells/LinkCell.d.ts +1 -1
  164. package/dist/ui-public/src/lists/TreeRow/Action.d.ts +1 -1
  165. package/dist/ui-public/src/lists/TreeRow/Action.js +1 -1
  166. package/dist/ui-public/src/lists/TreeRow/Link.d.ts +1 -1
  167. package/dist/ui-public/src/lists/TreeRow/Link.js +1 -1
  168. package/dist/ui-public/src/lists/UploadCard.d.ts +66 -3
  169. package/dist/ui-public/src/lists/UploadCard.js +116 -7
  170. package/dist/ui-public/src/lists/UserRow.d.ts +122 -0
  171. package/dist/ui-public/src/lists/UserRow.js +104 -0
  172. package/dist/ui-public/src/lists/dnd/DragHandle.d.ts +2 -2
  173. package/dist/ui-public/src/lists/dnd/SortableList.d.ts +1 -1
  174. package/dist/ui-public/src/lists/dnd/dropTargetClassName.d.ts +1 -1
  175. package/dist/ui-public/src/lists/dnd/tree/SortableTree.d.ts +2 -2
  176. package/dist/ui-public/src/navigation/Chevron.d.ts +4 -4
  177. package/dist/ui-public/src/navigation/Chevron.js +1 -1
  178. package/dist/ui-public/src/navigation/Link.d.ts +5 -5
  179. package/dist/ui-public/src/navigation/Link.js +1 -1
  180. package/dist/ui-public/src/navigation/NavList.d.ts +1 -1
  181. package/dist/ui-public/src/navigation/NavList.js +1 -1
  182. package/dist/ui-public/src/navigation/NavigationProvider.d.ts +1 -1
  183. package/dist/ui-public/src/navigation/SegmentedControl.d.ts +2 -2
  184. package/dist/ui-public/src/navigation/SettingsMenu.d.ts +8 -8
  185. package/dist/ui-public/src/navigation/SettingsMenu.js +1 -1
  186. package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNode.d.ts +4 -4
  187. package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.d.ts +1 -1
  188. package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.js +1 -1
  189. package/dist/ui-public/src/overlays/NewZIndex.d.ts +1 -1
  190. package/dist/ui-public/src/overlays/NewZIndex.js +1 -1
  191. package/dist/ui-public/src/overlays/Popover.d.ts +1 -1
  192. package/dist/ui-public/src/overlays/PortalWrapper.js +1 -1
  193. package/dist/ui-public/src/overlays/useModalClose.js +3 -3
  194. package/dist/ui-public/src/patterns/ListDetail/FloatingDetail.js +2 -2
  195. package/dist/ui-public/src/patterns/ListDetail/Page.d.ts +8 -9
  196. package/dist/ui-public/src/patterns/ListDetail/Page.js +4 -5
  197. package/dist/ui-public/src/patterns/ListDetail/Panel.d.ts +2 -2
  198. package/dist/ui-public/src/patterns/ListDetail/Panel.js +1 -1
  199. package/dist/ui-public/src/patterns/ListDetail/Split.d.ts +9 -10
  200. package/dist/ui-public/src/patterns/ListDetail/Split.js +5 -5
  201. package/dist/ui-public/src/patterns/ListFormPage.d.ts +3 -3
  202. package/dist/ui-public/src/patterns/ListFormPage.js +1 -1
  203. package/dist/ui-public/src/semantic/Heading.d.ts +1 -1
  204. package/dist/ui-public/src/semantic/Heading.js +1 -1
  205. package/dist/ui-public/src/semantic/Image.js +1 -1
  206. package/dist/ui-public/src/semantic/Nav.d.ts +3 -3
  207. package/dist/ui-public/src/semantic/Nav.js +3 -3
  208. package/dist/ui-public/src/semantic/RawButton.d.ts +3 -3
  209. package/dist/ui-public/src/semantic/RawButton.js +1 -1
  210. package/dist/ui-public/src/semantic/Search.d.ts +1 -1
  211. package/dist/ui-public/src/semantic/Search.js +1 -1
  212. package/dist/ui-public/src/utils/format.d.ts +21 -0
  213. package/dist/ui-public/src/utils/format.js +20 -0
  214. package/dist/ui-public/src/utils/formatDate.d.ts +10 -2
  215. package/dist/ui-public/src/utils/formatDate.js +4 -4
  216. package/dist/ui-public/src/utils/tickBatcher.js +44 -0
  217. package/dist/ui-public/src/utils/timezones.js +277 -0
  218. package/dist/ui-public/src/utils/weekStartForLocale.js +25 -0
  219. package/dist/utils/format.d.ts +1 -0
  220. package/dist/utils/format.js +2 -0
  221. package/package.json +2 -2
  222. package/dist/ui-public/icons/lucide/receipt.js +0 -26
@@ -4,14 +4,14 @@ import { DropdownTriggerBaseProps } from './types.js';
4
4
  export type DropdownTriggerButtonProps = DropdownTriggerBaseProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'id' | 'onMouseDown' | 'onClick' | 'onKeyDown' | 'aria-haspopup' | 'aria-expanded' | 'aria-controls' | 'disabled'> & {
5
5
  /**
6
6
  * The menu cannot open. With a reason, the button keeps the focus and
7
- * its tooltip tells why.
7
+ * its tooltip says why.
8
8
  */
9
9
  disabled?: Disabled;
10
10
  };
11
11
  declare const _default: React.NamedExoticComponent<DropdownTriggerBaseProps & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "id" | "type" | "aria-controls" | "aria-expanded" | "aria-haspopup" | "onKeyDown" | "onClick" | "onMouseDown" | "disabled"> & {
12
12
  /**
13
13
  * The menu cannot open. With a reason, the button keeps the focus and
14
- * its tooltip tells why.
14
+ * its tooltip says why.
15
15
  */
16
16
  disabled?: Disabled;
17
17
  } & React.RefAttributes<HTMLButtonElement>>;
@@ -10,25 +10,25 @@ export type IconTriggerProps = DropdownTriggerBaseProps & {
10
10
  /**
11
11
  * The accessible name of the button and the text of its tooltip. If you
12
12
  * do not give a label, the button gets the generic name "Actions" and no
13
- * tooltip: "Actions" tells nothing that the "⋮" does not tell.
13
+ * tooltip, because "Actions" says nothing that the "⋮" does not say.
14
14
  */
15
15
  label?: TextMessage;
16
- /** The size of the place in a toolbar, "micro" in other places */
16
+ /** The default size in a toolbar, "micro" outside a toolbar */
17
17
  size?: ButtonSize;
18
18
  /**
19
- * The menu cannot open. Give a reason when the user must know why: it
20
- * takes the place of the tooltip.
19
+ * The menu cannot open. Give a reason when the user must know why. It
20
+ * replaces the tooltip.
21
21
  */
22
22
  disabled?: Disabled;
23
23
  /**
24
- * Only for the place or the surface of the button (for example on a
24
+ * Only for the position or the surface of the button (for example on a
25
25
  * media card)
26
26
  */
27
27
  className?: string;
28
28
  };
29
29
  /**
30
30
  * A ghost icon-only ButtonTrigger (the "⋮" of a row, a card or a toolbar).
31
- * It has the size of the place in a toolbar, and "micro" in other places
31
+ * It has the default size in a toolbar, and "micro" outside a toolbar
32
32
  * (the actions of a row or a card).
33
33
  */
34
34
  declare const IconTrigger: ({ icon, label, size, disabled, className, open, onTrigger, }: IconTriggerProps) => React.JSX.Element;
@@ -5,7 +5,7 @@ import { jsx } from "react/jsx-runtime";
5
5
  //#region ../ui-public/src/actions/Dropdown/triggers/IconTrigger.tsx
6
6
  /**
7
7
  * A ghost icon-only ButtonTrigger (the "⋮" of a row, a card or a toolbar).
8
- * It has the size of the place in a toolbar, and "micro" in other places
8
+ * It has the default size in a toolbar, and "micro" outside a toolbar
9
9
  * (the actions of a row or a card).
10
10
  */
11
11
  var IconTrigger = ({ icon, label, size, disabled, className, open, onTrigger }) => {
@@ -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;
@@ -28,7 +28,7 @@ export type IconAvatarProps = {
28
28
  surface?: IconAvatarSurface;
29
29
  /**
30
30
  * 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
31
+ * avatar says what the icon shows. Without it, the screen readers do not
32
32
  * read the avatar.
33
33
  */
34
34
  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 };
@@ -1,11 +1,11 @@
1
1
  import React, { ReactNode } from 'react';
2
- import type { TextMessage } from '../Message.js';
3
- import { type BoxSize, type UploadPreviewPadding } from './uploadPreviewFit.js';
4
- export type { BoxSize, UploadPreviewPadding } from './uploadPreviewFit.js';
5
- export type UploadPreviewProps = {
2
+ import type { TextMessage } from '../../Message.js';
3
+ import { type BoxSize, type UploadPreviewPadding } from './fit.js';
4
+ export type { BoxSize, UploadPreviewPadding } from './fit.js';
5
+ export type UploadPreviewBoxProps = {
6
6
  /**
7
7
  * The size of the box in px, for the fit of the asset. A live host
8
- * measures the box. A static host gives a constant. `null` tells that the
8
+ * measures the box. A static host gives a constant. `null` says that the
9
9
  * size is not known yet: `UploadPreview.Image` then renders nothing.
10
10
  */
11
11
  box: BoxSize | null;
@@ -20,7 +20,7 @@ export type UploadPreviewProps = {
20
20
  * @default [10, 10]
21
21
  */
22
22
  padding?: UploadPreviewPadding;
23
- /** The box has no background, thus it shows the background of the parent. */
23
+ /** The box has no background, so it shows the background of the parent. */
24
24
  transparent?: boolean;
25
25
  /** The box is a link to the file. */
26
26
  link?: {
@@ -43,8 +43,8 @@ export type UploadPreviewImageProps = {
43
43
  */
44
44
  upscale?: boolean;
45
45
  /**
46
- * The image shows in the place of an icon (for example the poster of a
47
- * video), thus it always gets space around it, also when the
46
+ * The image shows instead of an icon (for example the poster of a
47
+ * video), so it always gets space around it, even when the
48
48
  * `UploadPreview` has zero padding.
49
49
  */
50
50
  icon?: boolean;
@@ -65,13 +65,13 @@ export type UploadPreviewProgressProps = {
65
65
  percent: number;
66
66
  /**
67
67
  * The text above the bar, and the name of the bar. Without it, the name
68
- * of the bar tells the percent or the analysis.
68
+ * of the bar says the percent or the analysis.
69
69
  */
70
70
  label?: TextMessage;
71
71
  };
72
72
  /** The progress of the upload, on the bottom edge of the box. */
73
73
  declare function UploadPreviewProgress({ percent, label }: UploadPreviewProgressProps): React.JSX.Element;
74
- declare const _default: React.ForwardRefExoticComponent<UploadPreviewProps & React.RefAttributes<HTMLElement>> & {
74
+ declare const _default: React.ForwardRefExoticComponent<UploadPreviewBoxProps & React.RefAttributes<HTMLElement>> & {
75
75
  Image: typeof UploadPreviewImage;
76
76
  Progress: typeof UploadPreviewProgress;
77
77
  };
@@ -1,11 +1,11 @@
1
- import { useTranslation } from "../i18n.js";
2
- import ProgressBar_default from "../feedback/ProgressBar.js";
3
- import Image from "../semantic/Image.js";
4
- import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./uploadPreviewFit.js";
1
+ import { useTranslation } from "../../i18n.js";
2
+ import ProgressBar_default from "../../feedback/ProgressBar.js";
3
+ import Image from "../../semantic/Image.js";
4
+ import { DEFAULT_PADDING, fitInBox, nonImagePadding } from "./fit.js";
5
5
  import { createContext, forwardRef, useContext, useMemo } from "react";
6
6
  import classNames from "classnames";
7
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
- //#region ../ui-public/src/content/UploadPreview.tsx
8
+ //#region ../ui-public/src/content/UploadPreview/box.tsx
9
9
  var UploadPreviewContext = createContext({
10
10
  box: null,
11
11
  padding: DEFAULT_PADDING
@@ -87,9 +87,9 @@ function UploadPreviewProgress({ percent, label }) {
87
87
  })
88
88
  })] });
89
89
  }
90
- var UploadPreview_default = Object.assign(UploadPreview, {
90
+ var box_default = Object.assign(UploadPreview, {
91
91
  Image: UploadPreviewImage,
92
92
  Progress: UploadPreviewProgress
93
93
  });
94
94
  //#endregion
95
- export { UploadPreview_default as default };
95
+ export { box_default as default };