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
@@ -5,7 +5,7 @@ import classNames from "classnames";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region ../ui-public/src/feedback/Callout.tsx
7
7
  /**
8
- * A message about the current data. For the text that tells what a page is
8
+ * A message about the current data. For the text that says what a page is
9
9
  * for, use Toolbar.Help. A callout has no buttons: a next step is a link in
10
10
  * the text, and a link only opens a page. An action that fixes the problem
11
11
  * goes in the row of the value, or in a Page.Group with a tone (a callout in
@@ -14,14 +14,14 @@ export type ProgressBarProps = {
14
14
  ariaLabel: TextMessage;
15
15
  /**
16
16
  * "inline" is a 4px bar as wide as its parent. "edge" is a 2px bar on the
17
- * bottom edge of the nearest positioned parent, thus it does not cover the
18
- * content: use it on a card or a row.
17
+ * bottom edge of the nearest positioned parent, so it does not cover the
18
+ * content. Use it on a card or a row.
19
19
  * @default "inline"
20
20
  */
21
21
  placement?: 'inline' | 'edge';
22
22
  /**
23
- * Only for the place of the bar (width, margin), not for its look. The bar
24
- * is as wide as its parent: the caller knows the width that fits its
23
+ * Only for the position of the bar (width, margin), not for its look. The bar
24
+ * is as wide as its parent. You know the width that fits your
25
25
  * layout, for example a maximum width in a table column.
26
26
  */
27
27
  className?: string;
@@ -9,17 +9,17 @@ export type SpinnerProps = {
9
9
  */
10
10
  inline?: boolean;
11
11
  /**
12
- * The text that a screen reader tells: the spinner is a status. Give
13
- * `false` when a visible text or `aria-busy` already tells that the
14
- * content loads: then the spinner is only a decoration.
12
+ * The text that a screen reader says. The spinner is a status. Give
13
+ * `false` when a visible text or `aria-busy` already says that the
14
+ * content loads. Then the spinner is only a decoration.
15
15
  * @default "Loading"
16
16
  */
17
17
  label?: TextMessage | false;
18
- /** Only for the place of the spinner (margin, z-index), not for its look */
18
+ /** Only for the position of the spinner (margin, z-index), not for its look */
19
19
  className?: string;
20
20
  };
21
21
  /**
22
- * A spinner that tells that something loads. It has two sizes: 32px to load
22
+ * A spinner that shows that something loads. It has two sizes: 32px to load
23
23
  * an area, 16px (an icon) in a line of text or in a control. The box is the
24
24
  * size of the spinner.
25
25
  */
@@ -50,7 +50,7 @@ export type SpinnerOverlayProps = {
50
50
  veil?: boolean;
51
51
  /** See the label of Spinner */
52
52
  label?: TextMessage | false;
53
- /** Only for the place of the overlay (z-index), not for its look */
53
+ /** Only for the position of the overlay (z-index), not for its look */
54
54
  className?: string;
55
55
  };
56
56
  /**
@@ -3,7 +3,7 @@ import "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region ../ui-public/src/feedback/Spinner.tsx
5
5
  /**
6
- * A spinner that tells that something loads. It has two sizes: 32px to load
6
+ * A spinner that shows that something loads. It has two sizes: 32px to load
7
7
  * an area, 16px (an icon) in a line of text or in a control. The box is the
8
8
  * size of the spinner.
9
9
  */
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { type DateInputCommonProps } from './DateTimeInput/Base.js';
3
+ /**
4
+ * The props of `DateInput`. The value is a date as `"yyyy-MM-dd"`, for
5
+ * example `"2026-11-17"`, or `null`.
6
+ */
7
+ export type DateInputProps = DateInputCommonProps;
8
+ export type { DateInputVariant, SelectableDays } from './DateTimeInput/Base.js';
9
+ /**
10
+ * An input for a date, with a calendar. The user types the date in the
11
+ * format of their settings, or picks the day in the calendar.
12
+ */
13
+ export default function DateInput(props: DateInputProps): React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ import DateTimeInputBase from "./DateTimeInput/Base.js";
2
+ import "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region ../ui-public/src/form/DateInput.tsx
5
+ /**
6
+ * An input for a date, with a calendar. The user types the date in the
7
+ * format of their settings, or picks the day in the calendar.
8
+ */
9
+ function DateInput(props) {
10
+ return /* @__PURE__ */ jsx(DateTimeInputBase, {
11
+ ...props,
12
+ withTime: false
13
+ });
14
+ }
15
+ //#endregion
16
+ export { DateInput as default };
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import { type TextMessage } from '../../Message.js';
3
+ import { type PopoverProps } from '../../overlays/Popover.js';
4
+ import { type FieldInputProps } from '../FieldWrapper.js';
5
+ import { BaseInputComponentPropsFieldWithReadOnly } from '../inputProps.js';
6
+ import { type SelectableDays } from './CalendarGrid.js';
7
+ export type { SelectableDays } from './CalendarGrid.js';
8
+ /** The look of the input, and the props that only one look has */
9
+ export type DateInputVariant =
10
+ /** A field with a border, a calendar button and a clear button */
11
+ {
12
+ /**
13
+ * The look of the input. "default" is a field with a border and a
14
+ * calendar button. "filter" has no border, no buttons and a small
15
+ * text, for the value of a filter: the calendar opens when the user
16
+ * clicks the date.
17
+ * @default 'default'
18
+ */
19
+ variant?: 'default';
20
+ /**
21
+ * Shows a button that clears the value, when the input has a value.
22
+ * @default true
23
+ */
24
+ clearable?: boolean;
25
+ /**
26
+ * The field is as wide as its content, not as wide as its container.
27
+ * @default false
28
+ */
29
+ autosize?: boolean;
30
+ }
31
+ /**
32
+ * The value of a filter: no border, no buttons, a small text. It is as
33
+ * wide as its content.
34
+ */
35
+ | {
36
+ variant: 'filter';
37
+ clearable?: never;
38
+ autosize?: never;
39
+ };
40
+ /** The props that `DateInput` and `DateTimeInput` share */
41
+ export type DateInputCommonProps = BaseInputComponentPropsFieldWithReadOnly<string | null> & Omit<FieldInputProps, 'id'> & DateInputVariant & {
42
+ /**
43
+ * The accessible name of the date text. Give it when the input is not in
44
+ * a `FieldWrapper` with a `label`.
45
+ */
46
+ ariaLabel?: TextMessage;
47
+ /**
48
+ * The side of the field where the calendar opens. It moves to the other
49
+ * side when there is no space.
50
+ * @default 'bottom-start'
51
+ */
52
+ calendarPlacement?: PopoverProps['placement'];
53
+ /**
54
+ * The days that the user can pick in the calendar. "future" is today and
55
+ * the days after it, "past" is today and the days before it. The
56
+ * calendar disables the other days. The user can still type a date out
57
+ * of the limit: check the value in your code.
58
+ * @default 'all'
59
+ */
60
+ selectableDays?: SelectableDays;
61
+ };
62
+ /**
63
+ * The props of `DateTimeInput`. The value is an ISO 8601 date and time with
64
+ * an offset, for example `"2026-11-17T09:30:00+01:00"`, or `null`.
65
+ */
66
+ export type DateTimeInputProps = DateInputCommonProps & {
67
+ /**
68
+ * The time has the seconds. Without them, the user types the hours and
69
+ * the minutes, and the seconds of the value are 0.
70
+ * @default true
71
+ */
72
+ seconds?: boolean;
73
+ /**
74
+ * When the field shows the time zone menu. "always" shows it. "whenDifferent"
75
+ * shows it only when the time zone of the user is not the time zone of the
76
+ * project, so the user sees which time zone the time is in.
77
+ * @default 'always'
78
+ */
79
+ timezoneSelect?: 'always' | 'whenDifferent';
80
+ };
81
+ type DateTimeInputBaseProps = DateTimeInputProps & {
82
+ withTime: boolean;
83
+ };
84
+ /**
85
+ * The input of `DateInput` and of `DateTimeInput`. A date has no time zone:
86
+ * it uses the time zone of the project for the instant of its midnight, and
87
+ * shows the same day.
88
+ */
89
+ export default function DateTimeInputBase({ value, onChange, onBlur, disabled: disabledProp, readOnly, withTime, seconds, timezoneSelect, variant, clearable, calendarPlacement, selectableDays, autosize, ariaLabel, id, name, ...ariaProps }: DateTimeInputBaseProps): React.JSX.Element;
@@ -0,0 +1,330 @@
1
+ import { Generic, UI } from "../../../icons/index.js";
2
+ import { useTranslation } from "../../i18n.js";
3
+ import { useDateSettings } from "../../content/DateSettings.js";
4
+ import Popover from "../../overlays/Popover.js";
5
+ import Button from "../../actions/Button.js";
6
+ import AutosizeInput_default from "../AutosizeInput.js";
7
+ import FieldWrapper_default, { useFieldInput } from "../FieldWrapper.js";
8
+ import { timezoneOptions } from "../../utils/timezones.js";
9
+ import { getEditState } from "../getEditState.js";
10
+ import SelectInput from "../SelectInput/index.js";
11
+ import { parseDateText, timeInputFormats } from "./dateText.js";
12
+ import CalendarGrid, { CALENDAR_FOCUS_TARGET } from "./CalendarGrid.js";
13
+ import { DATE_TIME_VALUE_FORMAT, DATE_VALUE_FORMAT, formatInstantInTimezone } from "./value.js";
14
+ import { useCallback, useEffect, useRef, useState } from "react";
15
+ import classNames from "classnames";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ import { TZDate, tzOffset } from "@date-fns/tz";
18
+ import { format } from "date-fns";
19
+ //#region ../ui-public/src/form/DateTimeInput/Base.tsx
20
+ /**
21
+ * Creates a TZDate for midnight (00:00) of a 'yyyy-MM-dd' date in an IANA
22
+ * time zone.
23
+ *
24
+ * Example:
25
+ * createTzMidnight("2025-11-01", "America/Manaus")
26
+ * → TZDate for 2025-11-01T00:00:00-04:00 (2025-11-01T04:00:00Z)
27
+ */
28
+ function createTzMidnight(dateString, timeZone) {
29
+ const [year, month, day] = dateString.split("-").map(Number);
30
+ if (!year || Number.isNaN(month) || Number.isNaN(day) || month < 1 || month > 12 || day < 1 || day > 31) throw new Error(`Invalid date string: ${dateString}`);
31
+ return new TZDate(year, month - 1, day, timeZone);
32
+ }
33
+ /**
34
+ * Returns a TZDate for 00:00:00 of today in the time zone.
35
+ *
36
+ * Example: at 15:34 of 2025-10-25 in "America/Los_Angeles", it returns
37
+ * 2025-10-25T00:00:00 in "America/Los_Angeles". Its getTime() is the UTC
38
+ * instant of that wall clock.
39
+ */
40
+ function tzStartOfDay(timezone) {
41
+ const currentTimeInTz = TZDate.tz(timezone);
42
+ return TZDate.tz(timezone, currentTimeInTz.getFullYear(), currentTimeInTz.getMonth(), currentTimeInTz.getDate());
43
+ }
44
+ /**
45
+ * Parses the text of the user with the first format that matches. Then
46
+ * `copyFn` copies the parsed parts (the day, or the time) as the wall clock
47
+ * of `inputTimezone` onto the base instant. Without a base instant, the base
48
+ * is 00:00 of today in `inputTimezone`. It returns null when no format
49
+ * matches.
50
+ *
51
+ * Example (a time):
52
+ * base = "2025-10-25T09:00:00.000Z", text = "11:00:00",
53
+ * inputTimezone = "America/Los_Angeles"
54
+ * 1) "11:00:00" gives a Date with the hours 11 and the minutes 0.
55
+ * 2) The base becomes a TZDate in Los Angeles.
56
+ * 3) copyFn sets 11:00:00 on it: the instant is now 11:00 in Los Angeles.
57
+ */
58
+ function applyInputAsWallClock(baseInstantISOString, copyFn, { inputText, inputFormats, inputTimezone }) {
59
+ const parsedUserInput = parseDateText(inputText, inputFormats);
60
+ if (!parsedUserInput) return null;
61
+ const modifiableInstanceInInputTz = baseInstantISOString ? TZDate.tz(inputTimezone, baseInstantISOString) : tzStartOfDay(inputTimezone);
62
+ copyFn(parsedUserInput, modifiableInstanceInInputTz);
63
+ return modifiableInstanceInInputTz;
64
+ }
65
+ /**
66
+ * The offset of the time zone at the instant, in a short form: "UTC",
67
+ * "UTC+2", "UTC-3:30". The instant is necessary, because the offset changes
68
+ * with daylight saving time.
69
+ */
70
+ function shortTimezoneLabel(timezone, instant) {
71
+ const minutes = tzOffset(timezone, instant);
72
+ if (minutes === 0) return "UTC";
73
+ const sign = minutes > 0 ? "+" : "-";
74
+ const hours = Math.floor(Math.abs(minutes) / 60);
75
+ const rest = Math.abs(minutes) % 60;
76
+ return `UTC${sign}${hours}${rest ? `:${String(rest).padStart(2, "0")}` : ""}`;
77
+ }
78
+ /**
79
+ * The text that sets the width of a date or time input (see AutosizeInput).
80
+ * It has one line for each of these: a sample with the widest digits
81
+ * ("28/12/2026", "08:58:58 PM"), the placeholder (the format), and the text
82
+ * of the user. The width is the width of the longest line. So the input
83
+ * keeps its width when the user sets or clears the value, and the text never
84
+ * gets cut.
85
+ */
86
+ var widestSample = new Date(2026, 11, 28, 20, 58, 58);
87
+ function sizerText(inputFormat, input) {
88
+ return [
89
+ format(widestSample, inputFormat),
90
+ inputFormat,
91
+ input
92
+ ].join("\n");
93
+ }
94
+ /**
95
+ * The input of `DateInput` and of `DateTimeInput`. A date has no time zone:
96
+ * it uses the time zone of the project for the instant of its midnight, and
97
+ * shows the same day.
98
+ */
99
+ function DateTimeInputBase({ value, onChange, onBlur, disabled: disabledProp, readOnly, withTime, seconds = true, timezoneSelect = "always", variant = "default", clearable = true, calendarPlacement = "bottom-start", selectableDays = "all", autosize = false, ariaLabel, id, name, ...ariaProps }) {
100
+ const { t, tm } = useTranslation();
101
+ const fieldProps = useFieldInput({
102
+ id,
103
+ ...ariaProps
104
+ });
105
+ const { locked, disabled, showsReadOnly, stateClass } = getEditState({
106
+ disabled: disabledProp,
107
+ readOnly
108
+ });
109
+ const { dateFormat, twentyFourHour, timezone: userTimezone, projectTimezone } = useDateSettings();
110
+ const apiTimezone = projectTimezone ?? userTimezone;
111
+ const filter = variant === "filter";
112
+ const commit = (newValue) => {
113
+ onChange?.(newValue);
114
+ onBlur?.(newValue);
115
+ };
116
+ const timeFormats = timeInputFormats(twentyFourHour, seconds);
117
+ const serializationFormat = withTime ? DATE_TIME_VALUE_FORMAT : DATE_VALUE_FORMAT;
118
+ const timeFormat = timeFormats[0];
119
+ const [selectedTimezone, setSelectedTimezone] = useState(withTime ? userTimezone : apiTimezone);
120
+ const canonicalInstantISO = value ? withTime ? new Date(value).toISOString() : createTzMidnight(value, apiTimezone).toISOString() : null;
121
+ const formattedDateDisplay = canonicalInstantISO ? format(TZDate.tz(selectedTimezone, canonicalInstantISO), dateFormat) : "";
122
+ const formattedTimeDisplay = canonicalInstantISO ? format(TZDate.tz(selectedTimezone, canonicalInstantISO), timeFormat) : "";
123
+ const [calendarOpener, setCalendarOpener] = useState(null);
124
+ const calendarVisible = calendarOpener !== null;
125
+ const [userDateInput, setUserDateInput] = useState(formattedDateDisplay);
126
+ const [userTimeInput, setUserTimeInput] = useState(formattedTimeDisplay);
127
+ useEffect(() => {
128
+ setUserDateInput(formattedDateDisplay);
129
+ setUserTimeInput(formattedTimeDisplay);
130
+ }, [
131
+ value,
132
+ formattedDateDisplay,
133
+ formattedTimeDisplay
134
+ ]);
135
+ const dateInputRef = useRef(null);
136
+ const calendarRef = useRef(null);
137
+ const skipOpenOnFocus = useRef(false);
138
+ const closeCalendar = useCallback(() => {
139
+ const focusInCalendar = Boolean(calendarRef.current?.contains(document.activeElement));
140
+ setCalendarOpener(null);
141
+ if (calendarOpener === "field" && focusInCalendar) {
142
+ skipOpenOnFocus.current = true;
143
+ dateInputRef.current?.focus();
144
+ }
145
+ }, [calendarOpener]);
146
+ const handleChangeDay = (date) => {
147
+ const dateTimeInSelectedTz = canonicalInstantISO ? TZDate.tz(selectedTimezone, canonicalInstantISO) : tzStartOfDay(selectedTimezone);
148
+ dateTimeInSelectedTz.setFullYear(date.getFullYear());
149
+ dateTimeInSelectedTz.setMonth(date.getMonth(), date.getDate());
150
+ commit(formatInstantInTimezone(dateTimeInSelectedTz, apiTimezone, serializationFormat));
151
+ closeCalendar();
152
+ };
153
+ const transformedDate = applyInputAsWallClock(canonicalInstantISO, (src, dest) => {
154
+ dest.setFullYear(src.getFullYear());
155
+ dest.setMonth(src.getMonth(), src.getDate());
156
+ }, {
157
+ inputText: userDateInput,
158
+ inputFormats: [dateFormat],
159
+ inputTimezone: selectedTimezone
160
+ });
161
+ const serializedDateValue = transformedDate ? formatInstantInTimezone(transformedDate, apiTimezone, serializationFormat) : null;
162
+ const selectedDay = transformedDate ? format(transformedDate, "yyyy-MM-dd") : null;
163
+ const handleDateTextBlur = () => {
164
+ if (!serializedDateValue) {
165
+ setUserDateInput(formattedDateDisplay);
166
+ return;
167
+ }
168
+ commit(serializedDateValue);
169
+ };
170
+ const handleTimeTextBlur = () => {
171
+ const transformedTime = applyInputAsWallClock(canonicalInstantISO, (src, dest) => {
172
+ dest.setHours(src.getHours());
173
+ dest.setMinutes(src.getMinutes());
174
+ dest.setSeconds(seconds ? src.getSeconds() : 0);
175
+ }, {
176
+ inputText: userTimeInput,
177
+ inputFormats: timeFormats,
178
+ inputTimezone: selectedTimezone
179
+ });
180
+ if (!transformedTime) {
181
+ setUserTimeInput(formattedTimeDisplay);
182
+ return;
183
+ }
184
+ commit(formatInstantInTimezone(transformedTime, apiTimezone, serializationFormat));
185
+ };
186
+ const handleDateTextFocus = () => {
187
+ if (skipOpenOnFocus.current) {
188
+ skipOpenOnFocus.current = false;
189
+ return;
190
+ }
191
+ if (!locked) setCalendarOpener("field");
192
+ };
193
+ const handleDateTextKeyDown = (event) => {
194
+ if (event.key !== "ArrowDown" || !calendarVisible) return;
195
+ const target = calendarRef.current?.querySelector(CALENDAR_FOCUS_TARGET);
196
+ if (target) {
197
+ event.preventDefault();
198
+ target.focus();
199
+ }
200
+ };
201
+ const handleCalendarButtonClick = () => {
202
+ setCalendarOpener(calendarVisible ? null : "button");
203
+ };
204
+ const handleTimezoneChange = (newTimezone) => {
205
+ if (newTimezone === null) return;
206
+ if (!canonicalInstantISO) {
207
+ setSelectedTimezone(newTimezone);
208
+ return;
209
+ }
210
+ const instantInOldTz = TZDate.tz(selectedTimezone, canonicalInstantISO);
211
+ const instantInNewTz = new TZDate(instantInOldTz.getTime(), newTimezone);
212
+ commit(formatInstantInTimezone(instantInNewTz, apiTimezone, serializationFormat));
213
+ setSelectedTimezone(newTimezone);
214
+ };
215
+ const [fieldElement, setFieldElement] = useState(null);
216
+ const handleBlur = (event) => {
217
+ const next = event.relatedTarget;
218
+ if (calendarOpener === "field" && next && !event.currentTarget.contains(next) && !calendarRef.current?.contains(next)) setCalendarOpener(null);
219
+ };
220
+ const formatTimezoneLabel = useCallback((option, { context }) => context === "value" ? shortTimezoneLabel(option.value, canonicalInstantISO ? new Date(canonicalInstantISO) : /* @__PURE__ */ new Date()) : option.label, [canonicalInstantISO]);
221
+ const showTimezone = withTime && (timezoneSelect === "always" || apiTimezone !== userTimezone);
222
+ const showClear = Boolean(value) && !filter && clearable && Boolean(onChange) && !locked;
223
+ return /* @__PURE__ */ jsxs("div", {
224
+ onBlur: handleBlur,
225
+ className: classNames("DateTimeInput", stateClass, {
226
+ "DateTimeInput--smaller": filter,
227
+ "DateTimeInput--with-time": withTime,
228
+ "DateTimeInput--autosize": autosize || filter,
229
+ "is-open": calendarVisible
230
+ }),
231
+ children: [/* @__PURE__ */ jsxs("div", {
232
+ className: classNames("InputFrame DateTimeInput__field", stateClass, { "is-open": calendarVisible }),
233
+ ref: setFieldElement,
234
+ children: [
235
+ !filter && /* @__PURE__ */ jsx(Button, {
236
+ tone: "ghost",
237
+ size: "micro",
238
+ iconOnly: true,
239
+ icon: UI.CalendarIcon,
240
+ label: t("dateTimeInput.openCalendar"),
241
+ className: "InputFrame__control DateTimeInput__calendar-button",
242
+ onClick: handleCalendarButtonClick,
243
+ disabled: locked,
244
+ "aria-expanded": calendarVisible
245
+ }),
246
+ /* @__PURE__ */ jsx(AutosizeInput_default, {
247
+ text: sizerText(dateFormat, userDateInput),
248
+ className: "DateTimeInput__sizer DateTimeInput__sizer--date",
249
+ children: /* @__PURE__ */ jsx("input", {
250
+ ...fieldProps,
251
+ ref: dateInputRef,
252
+ name,
253
+ "aria-label": ariaLabel ? tm(ariaLabel) : void 0,
254
+ type: "text",
255
+ placeholder: dateFormat,
256
+ value: userDateInput,
257
+ onChange: (event) => setUserDateInput(event.target.value),
258
+ onFocus: handleDateTextFocus,
259
+ onBlur: handleDateTextBlur,
260
+ onKeyDown: handleDateTextKeyDown,
261
+ className: "InputFrame__input DateTimeInput__date",
262
+ disabled,
263
+ readOnly: showsReadOnly,
264
+ spellCheck: false,
265
+ autoComplete: "off"
266
+ })
267
+ }),
268
+ /* @__PURE__ */ jsxs(FieldWrapper_default.Boundary, { children: [withTime && /* @__PURE__ */ jsx(AutosizeInput_default, {
269
+ text: sizerText(timeFormat, userTimeInput),
270
+ className: "DateTimeInput__sizer DateTimeInput__sizer--time",
271
+ children: /* @__PURE__ */ jsx("input", {
272
+ "aria-label": t("dateTimeInput.time"),
273
+ type: "text",
274
+ placeholder: timeFormat,
275
+ value: userTimeInput,
276
+ onChange: (event) => setUserTimeInput(event.target.value),
277
+ onBlur: handleTimeTextBlur,
278
+ className: "InputFrame__input DateTimeInput__time",
279
+ disabled,
280
+ readOnly: showsReadOnly,
281
+ spellCheck: false,
282
+ autoComplete: "off"
283
+ })
284
+ }), showTimezone && /* @__PURE__ */ jsx(SelectInput, {
285
+ "aria-label": t("dateTimeInput.timezone"),
286
+ options: timezoneOptions,
287
+ value: selectedTimezone,
288
+ onChange: handleTimezoneChange,
289
+ onBlur: handleTimezoneChange,
290
+ className: "DateTimeInput__timezone",
291
+ classNamePrefix: "DateTimeInput__timezone",
292
+ formatOptionLabel: formatTimezoneLabel,
293
+ autosize: true,
294
+ variant: "embedded",
295
+ disabled: locked
296
+ })] }),
297
+ showClear && /* @__PURE__ */ jsx(Button, {
298
+ tone: "ghost",
299
+ size: "micro",
300
+ iconOnly: true,
301
+ icon: Generic.CloseIcon,
302
+ label: t("field.clearValue"),
303
+ className: "InputFrame__control DateTimeInput__clear",
304
+ onClick: () => commit(null)
305
+ })
306
+ ]
307
+ }), calendarVisible && fieldElement && /* @__PURE__ */ jsx(Popover, {
308
+ anchorElement: fieldElement,
309
+ placement: calendarPlacement,
310
+ offset: 4,
311
+ onClose: closeCalendar,
312
+ ariaLabel: { id: "dateTimeInput.calendar" },
313
+ autoFocus: calendarOpener === "button" ? ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]" : void 0,
314
+ children: /* @__PURE__ */ jsx("div", {
315
+ ref: calendarRef,
316
+ className: "DateTimeInput__date-popper",
317
+ children: /* @__PURE__ */ jsx(CalendarGrid, {
318
+ selection: {
319
+ start: selectedDay,
320
+ end: selectedDay
321
+ },
322
+ onChange: handleChangeDay,
323
+ selectableDays
324
+ })
325
+ })
326
+ })]
327
+ });
328
+ }
329
+ //#endregion
330
+ export { DateTimeInputBase as default };
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ /** The selector of the day that has the focus, or that gets it with Tab */
3
+ export declare const CALENDAR_FOCUS_TARGET = ".DateTimeInput__CalendarDayCell[tabindex=\"0\"]";
4
+ /**
5
+ * The selected days, as 'yyyy-MM-dd'. One date has the same day in `start`
6
+ * and `end`. A range that has only one end has null in the other.
7
+ */
8
+ export type CalendarSelection = {
9
+ start: string | null;
10
+ end: string | null;
11
+ };
12
+ /**
13
+ * The days that the user can pick in the calendar. "future" is today and the
14
+ * days after it. "past" is today and the days before it.
15
+ */
16
+ export type SelectableDays = 'all' | 'future' | 'past';
17
+ type CalendarGridProps = {
18
+ selection: CalendarSelection;
19
+ selectableDays: SelectableDays;
20
+ onChange: (day: Date) => void;
21
+ };
22
+ /**
23
+ * The days of a month in a grid, for one date or for a range. The arrows,
24
+ * Home, End, Page Up and Page Down move the focus between the days, as in
25
+ * the date picker of the WAI-ARIA Authoring Practices. Only one day is in
26
+ * the Tab order.
27
+ */
28
+ export default function CalendarGrid({ selection, selectableDays, onChange, }: CalendarGridProps): React.JSX.Element;
29
+ export {};