datocms-react-ui 3.1.0-next.0 → 3.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/Actions.d.ts +1 -0
  2. package/dist/Actions.js +4 -0
  3. package/dist/IconAvatar.d.ts +2 -0
  4. package/dist/IconAvatar.js +2 -0
  5. package/dist/ListDetail.js +2 -2
  6. package/dist/Pane.js +2 -1
  7. package/dist/SplitPane.js +2 -2
  8. package/dist/react-ui/src/Canvas.d.ts +2 -1
  9. package/dist/react-ui/src/Canvas.js +8 -6
  10. package/dist/react-ui/src/ContextInspector.js +2 -2
  11. package/dist/react-ui/src/messageText.js +1 -1
  12. package/dist/styles.css +330 -195
  13. package/dist/ui/icons/brands/gitlab.js +15 -0
  14. package/dist/ui/icons/custom/netlify.js +7 -29
  15. package/dist/ui/icons/custom/vercel.js +1 -4
  16. package/dist/ui/icons/index.js +206 -195
  17. package/dist/ui/icons/regular/command.js +16 -0
  18. package/dist/ui/icons/regular/keyboard.js +16 -0
  19. package/dist/ui/icons/regular/list-tree.js +2 -1
  20. package/dist/ui/icons/regular/list.js +2 -1
  21. package/dist/ui/icons/regular/memo.js +2 -1
  22. package/dist/ui/locales/en.js +10 -3
  23. package/dist/ui/src/BundledTexts.js +2 -2
  24. package/dist/ui/src/UiTextKey.d.ts +1 -1
  25. package/dist/ui/src/actions/Actions/ActionTooltip.js +24 -0
  26. package/dist/ui/src/actions/Actions/Shortcut.d.ts +23 -0
  27. package/dist/ui/src/actions/Actions/Shortcut.js +45 -0
  28. package/dist/ui/src/actions/Actions/index.d.ts +3 -0
  29. package/dist/ui/src/actions/Actions/index.js +3 -0
  30. package/dist/ui/src/actions/Actions/registry.d.ts +211 -0
  31. package/dist/ui/src/actions/Actions/registry.js +580 -0
  32. package/dist/ui/src/actions/Actions/shortcuts.d.ts +85 -0
  33. package/dist/ui/src/actions/Actions/shortcuts.js +284 -0
  34. package/dist/ui/src/actions/Button.d.ts +13 -12
  35. package/dist/ui/src/actions/Button.js +8 -7
  36. package/dist/ui/src/actions/Dropdown/DropdownContext.js +2 -1
  37. package/dist/ui/src/actions/Dropdown/Footer.js +1 -1
  38. package/dist/ui/src/actions/Dropdown/Menu.d.ts +2 -1
  39. package/dist/ui/src/actions/Dropdown/Menu.js +43 -37
  40. package/dist/ui/src/actions/Dropdown/MenuContent.js +22 -12
  41. package/dist/ui/src/actions/Dropdown/MenuParts.js +3 -3
  42. package/dist/ui/src/actions/Dropdown/Option.d.ts +20 -3
  43. package/dist/ui/src/actions/Dropdown/Option.js +48 -9
  44. package/dist/ui/src/actions/Dropdown/OptionAction.js +1 -1
  45. package/dist/ui/src/actions/Dropdown/Submenu.js +2 -2
  46. package/dist/ui/src/actions/Dropdown/index.d.ts +4 -1
  47. package/dist/ui/src/actions/Dropdown/index.js +6 -4
  48. package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +4 -4
  49. package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.js +7 -6
  50. package/dist/ui/src/actions/Dropdown/triggers/PillTrigger.js +1 -1
  51. package/dist/ui/src/actions/Dropdown/triggers/TextualTrigger.js +1 -1
  52. package/dist/ui/src/actions/EditorToolbar/Button.js +2 -2
  53. package/dist/ui/src/actions/EditorToolbar/Buttons.js +2 -2
  54. package/dist/ui/src/actions/EditorToolbar/index.js +1 -1
  55. package/dist/ui/src/actions/MultipleSelectionActionBar.d.ts +20 -3
  56. package/dist/ui/src/actions/MultipleSelectionActionBar.js +25 -7
  57. package/dist/ui/src/actions/SplitButton/Caret.js +1 -1
  58. package/dist/ui/src/actions/SplitButton/index.js +1 -1
  59. package/dist/ui/src/actions/disabledReason.js +1 -1
  60. package/dist/ui/src/content/Avatar.d.ts +5 -3
  61. package/dist/ui/src/content/Avatar.js +4 -3
  62. package/dist/ui/src/content/CodeSnippet.js +1 -1
  63. package/dist/ui/src/content/CopyButton.js +1 -1
  64. package/dist/ui/src/content/CopyableId.d.ts +6 -1
  65. package/dist/ui/src/content/CopyableId.js +5 -2
  66. package/dist/ui/src/content/CopyableValue.js +2 -2
  67. package/dist/ui/src/content/FeedbackDot.js +1 -1
  68. package/dist/ui/src/content/IconAvatar.d.ts +42 -0
  69. package/dist/ui/src/content/IconAvatar.js +36 -0
  70. package/dist/ui/src/content/InitialsAvatar.js +1 -2
  71. package/dist/ui/src/content/Pill.js +3 -3
  72. package/dist/ui/src/content/SmartDate.js +1 -1
  73. package/dist/ui/src/content/UploadThreatTriangle.js +1 -1
  74. package/dist/ui/src/content/UsageMeter.d.ts +2 -1
  75. package/dist/ui/src/content/UsageMeter.js +3 -2
  76. package/dist/ui/src/content/ValidityTriangles.js +3 -3
  77. package/dist/ui/src/feedback/BlankSlate.js +2 -2
  78. package/dist/ui/src/feedback/Callout.js +2 -2
  79. package/dist/ui/src/feedback/ProgressBar.js +1 -1
  80. package/dist/ui/src/form/AutosizeInput.js +1 -1
  81. package/dist/ui/src/form/FieldHint.js +1 -1
  82. package/dist/ui/src/form/FieldWrapper.js +1 -1
  83. package/dist/ui/src/form/InputGroup.js +1 -1
  84. package/dist/ui/src/form/Label.js +2 -2
  85. package/dist/ui/src/form/PasswordInput.js +1 -1
  86. package/dist/ui/src/form/RadioGroupInput.js +1 -1
  87. package/dist/ui/src/form/SelectInput/SelectMenu.js +3 -3
  88. package/dist/ui/src/form/SelectInput/SelectMultiValueRemove.js +7 -0
  89. package/dist/ui/src/form/SelectInput/SelectOption.js +1 -1
  90. package/dist/ui/src/form/SelectInput/SortableMultiValue.js +1 -1
  91. package/dist/ui/src/form/StringInput.js +1 -1
  92. package/dist/ui/src/form/SwitchInput.d.ts +2 -0
  93. package/dist/ui/src/form/SwitchInput.js +4 -3
  94. package/dist/ui/src/form/SwitchList.js +1 -1
  95. package/dist/ui/src/form/TableList.js +2 -2
  96. package/dist/ui/src/form/TextareaInput.js +1 -1
  97. package/dist/ui/src/i18n.js +6 -6
  98. package/dist/ui/src/layout/ListOrOverview.js +3 -3
  99. package/dist/ui/src/layout/Page/Page.js +1 -1
  100. package/dist/ui/src/layout/Page/PageContent.js +1 -1
  101. package/dist/ui/src/layout/Page/PageGroup.js +2 -2
  102. package/dist/ui/src/layout/Page/PageSection.js +1 -1
  103. package/dist/ui/src/layout/Pane/ListFilter.js +6 -12
  104. package/dist/ui/src/layout/Pane/PaneHeader.js +3 -3
  105. package/dist/ui/src/layout/Pane/PaneRegion.d.ts +14 -0
  106. package/dist/ui/src/layout/Pane/PaneRegion.js +23 -0
  107. package/dist/ui/src/layout/Pane/index.d.ts +1 -0
  108. package/dist/ui/src/layout/Pane/index.js +36 -32
  109. package/dist/ui/src/layout/SidebarPanel.js +1 -1
  110. package/dist/ui/src/layout/SplitPane.d.ts +2 -0
  111. package/dist/ui/src/layout/SplitPane.js +79 -37
  112. package/dist/ui/src/layout/SplitView/SashActionButton.js +17 -9
  113. package/dist/ui/src/layout/SplitView/SplitView.js +1 -1
  114. package/dist/ui/src/layout/SplitView/SplitViewSash.js +2 -1
  115. package/dist/ui/src/layout/Toolbar/AddNewButton.d.ts +10 -6
  116. package/dist/ui/src/layout/Toolbar/AddNewButton.js +10 -23
  117. package/dist/ui/src/layout/Toolbar/Divider.d.ts +8 -0
  118. package/dist/ui/src/layout/Toolbar/Divider.js +16 -0
  119. package/dist/ui/src/layout/Toolbar/DotsDropdown.d.ts +8 -1
  120. package/dist/ui/src/layout/Toolbar/DotsDropdown.js +3 -2
  121. package/dist/ui/src/layout/Toolbar/Fill.js +1 -1
  122. package/dist/ui/src/layout/Toolbar/FilterInput.d.ts +7 -3
  123. package/dist/ui/src/layout/Toolbar/FilterInput.js +62 -49
  124. package/dist/ui/src/layout/Toolbar/FilterToggle.d.ts +6 -4
  125. package/dist/ui/src/layout/Toolbar/FilterToggle.js +42 -7
  126. package/dist/ui/src/layout/Toolbar/GoBack.d.ts +6 -1
  127. package/dist/ui/src/layout/Toolbar/GoBack.js +12 -5
  128. package/dist/ui/src/layout/Toolbar/Group.js +1 -1
  129. package/dist/ui/src/layout/Toolbar/Help.js +3 -3
  130. package/dist/ui/src/layout/Toolbar/Pagination.js +2 -2
  131. package/dist/ui/src/layout/Toolbar/PresetsTitle.js +3 -3
  132. package/dist/ui/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
  133. package/dist/ui/src/layout/Toolbar/PrimaryButton.js +2 -2
  134. package/dist/ui/src/layout/Toolbar/Root.d.ts +6 -1
  135. package/dist/ui/src/layout/Toolbar/Root.js +13 -2
  136. package/dist/ui/src/layout/Toolbar/Search.d.ts +2 -1
  137. package/dist/ui/src/layout/Toolbar/Search.js +8 -3
  138. package/dist/ui/src/layout/Toolbar/context.js +2 -1
  139. package/dist/ui/src/layout/Toolbar/index.d.ts +5 -3
  140. package/dist/ui/src/layout/Toolbar/index.js +2 -0
  141. package/dist/ui/src/lists/CardList.d.ts +7 -2
  142. package/dist/ui/src/lists/CardList.js +7 -6
  143. package/dist/ui/src/lists/EmptySlot.js +2 -2
  144. package/dist/ui/src/lists/EntityRow.js +1 -1
  145. package/dist/ui/src/lists/InfoList.js +8 -3
  146. package/dist/ui/src/lists/InsertGap.js +4 -4
  147. package/dist/ui/src/lists/MediaCard.d.ts +10 -0
  148. package/dist/ui/src/lists/MediaCard.js +9 -4
  149. package/dist/ui/src/lists/RowList.js +2 -2
  150. package/dist/ui/src/lists/SettingsList.js +1 -1
  151. package/dist/ui/src/lists/Table/Body.js +1 -1
  152. package/dist/ui/src/lists/Table/Cell.js +1 -1
  153. package/dist/ui/src/lists/Table/ColumnsMenu.js +1 -1
  154. package/dist/ui/src/lists/Table/Header.js +8 -10
  155. package/dist/ui/src/lists/Table/HeaderCell.js +2 -2
  156. package/dist/ui/src/lists/Table/Row.d.ts +7 -1
  157. package/dist/ui/src/lists/Table/Row.js +6 -2
  158. package/dist/ui/src/lists/Table/Table.js +1 -1
  159. package/dist/ui/src/lists/Table/TreeToggle.js +1 -1
  160. package/dist/ui/src/lists/Table/index.d.ts +1 -1
  161. package/dist/ui/src/lists/Table/layout.d.ts +3 -2
  162. package/dist/ui/src/lists/Table/layout.js +26 -13
  163. package/dist/ui/src/lists/dnd/DragHandle.js +1 -1
  164. package/dist/ui/src/lists/dnd/DropIndicator.js +1 -1
  165. package/dist/ui/src/lists/dnd/SortableList.js +2 -2
  166. package/dist/ui/src/lists/dnd/tree/SortableTree.js +1 -1
  167. package/dist/ui/src/navigation/Chevron.js +2 -2
  168. package/dist/ui/src/navigation/SegmentedControl.d.ts +23 -4
  169. package/dist/ui/src/navigation/SegmentedControl.js +23 -5
  170. package/dist/ui/src/navigation/SettingsMenu.js +3 -3
  171. package/dist/ui/src/navigation/SidebarTree/SidebarTreeNode.js +3 -3
  172. package/dist/ui/src/navigation/SidebarTree/SidebarTreeNodeActions.js +1 -1
  173. package/dist/ui/src/navigation/Tabs.js +1 -1
  174. package/dist/ui/src/overlays/FullscreenModal.js +48 -53
  175. package/dist/ui/src/overlays/HoverCard.js +4 -4
  176. package/dist/ui/src/overlays/Modal.d.ts +7 -0
  177. package/dist/ui/src/overlays/Modal.js +53 -55
  178. package/dist/ui/src/overlays/Popover.d.ts +6 -3
  179. package/dist/ui/src/overlays/Popover.js +13 -8
  180. package/dist/ui/src/overlays/Portal.js +1 -1
  181. package/dist/ui/src/overlays/Tooltip.d.ts +6 -3
  182. package/dist/ui/src/overlays/Tooltip.js +29 -13
  183. package/dist/ui/src/overlays/useModalClose.js +17 -12
  184. package/dist/ui/src/patterns/ListDetail/Page.d.ts +9 -0
  185. package/dist/ui/src/patterns/ListDetail/Page.js +33 -26
  186. package/dist/ui/src/patterns/ListDetail/Panel.js +4 -2
  187. package/dist/ui/src/patterns/ListDetail/Split.d.ts +5 -0
  188. package/dist/ui/src/patterns/ListDetail/Split.js +75 -56
  189. package/dist/ui/src/patterns/ListDetail/index.d.ts +2 -2
  190. package/dist/ui/src/patterns/ListDetail/index.js +2 -2
  191. package/dist/ui/src/patterns/ListFormPage.js +2 -2
  192. package/dist/ui/src/semantic/Main.d.ts +4 -1
  193. package/dist/ui/src/semantic/Main.js +53 -3
  194. package/dist/ui/src/semantic/NavigationFocusProvider.js +9 -0
  195. package/package.json +1 -1
  196. package/dist/HotKey.d.ts +0 -1
  197. package/dist/HotKey.js +0 -2
  198. package/dist/ui/src/actions/HotKey.d.ts +0 -98
  199. package/dist/ui/src/actions/HotKey.js +0 -270
  200. package/dist/ui/src/actions/hotKeyContext.d.ts +0 -32
  201. package/dist/ui/src/actions/hotKeyContext.js +0 -15
@@ -1,8 +1,6 @@
1
+ import { Generic } from "../../../icons/index.js";
1
2
  import { useTranslation } from "../../i18n.js";
2
3
  import { useNavigation } from "../../navigation/NavigationProvider.js";
3
- import { HotKeyListener } from "../../actions/HotKey.js";
4
- import { Generic } from "../../../icons/index.js";
5
- import "../../layout/Toolbar/FilterToggle.js";
6
4
  import Toolbar from "../../layout/Toolbar/index.js";
7
5
  import BlankSlate_default from "../../feedback/BlankSlate.js";
8
6
  import Pane_default from "../../layout/Pane/index.js";
@@ -10,9 +8,9 @@ import ListOrOverview_default from "../../layout/ListOrOverview.js";
10
8
  import ListArea_default from "../../lists/ListArea.js";
11
9
  import Split_default from "./Split.js";
12
10
  import Overview_default from "./Overview.js";
13
- import React, { useCallback } from "react";
14
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ import React, { useCallback, useState } from "react";
15
12
  import { escapeRegExp } from "lodash-es";
13
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
14
  //#region ../ui/src/patterns/ListDetail/Page.tsx
17
15
  /**
18
16
  * The state of a list that the server filters and paginates. `isEmpty` is
@@ -43,7 +41,7 @@ function ListDetailPage({ detail, title, help, subtitle, menu, busy, filter, con
43
41
  detail,
44
42
  children: /* @__PURE__ */ jsx(Pane_default, {
45
43
  ariaLabel: titleText,
46
- header: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Pane_default.Header, { children: [
44
+ header: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Pane_default.Header, { children: [
47
45
  /* @__PURE__ */ jsx(Pane_default.Header.Title, {
48
46
  level: 1,
49
47
  help,
@@ -54,20 +52,16 @@ function ListDetailPage({ detail, title, help, subtitle, menu, busy, filter, con
54
52
  busy && /* @__PURE__ */ jsx(Pane_default.Header.Spinner, {}),
55
53
  /* @__PURE__ */ jsxs(Pane_default.Header.Button, { children: [
56
54
  controls,
57
- filter && /* @__PURE__ */ jsx(HotKeyListener, {
58
- hotKey: "mod+shift+f",
59
- description: { id: "hotkeys.filterList" },
60
- trigger: filter.toolbar.onOpen,
61
- children: /* @__PURE__ */ jsx(Toolbar.FilterToggle, {
62
- pressed: filter.toolbar.open,
63
- onClick: filter.toolbar.onToggle,
64
- hotKey: true
65
- })
55
+ filter && /* @__PURE__ */ jsx(Toolbar.FilterToggle, {
56
+ pressed: filter.toolbar.open,
57
+ onClick: filter.toolbar.onToggle,
58
+ onOpen: filter.toolbar.onOpen
66
59
  }),
67
60
  button
68
61
  ] })
69
62
  ] }), filter?.toolbar.open && /* @__PURE__ */ jsx(Toolbar, {
70
63
  fields: true,
64
+ onClose: filter.toolbar.onClose,
71
65
  children: filter.form
72
66
  })] }),
73
67
  footer,
@@ -96,30 +90,43 @@ function matchOpenRowId(pathname, baseUrl, idPattern) {
96
90
  * of the id, for example "\\d+") when other routes are under the base URL:
97
91
  * then a route under the open row (for example "<baseUrl>/12/delete") keeps
98
92
  * the row open. It needs a host with a location (see NavigationProvider).
93
+ * `reopen` opens the last open row again, while no row is open: give it to
94
+ * `onReopen` of the detail.
99
95
  */
100
96
  function useOpenRowRoute(baseUrl, idPattern) {
101
97
  const { location, navigate } = useNavigation();
102
98
  const search = location?.search ?? "";
103
99
  const id = location ? matchOpenRowId(location.pathname, baseUrl, idPattern) : void 0;
100
+ const open = useCallback((rowOrId) => {
101
+ const rowId = typeof rowOrId === "string" ? rowOrId : rowOrId.id;
102
+ navigate(`${baseUrl}/${rowId}${search}`, { replace: Boolean(id) });
103
+ }, [
104
+ navigate,
105
+ baseUrl,
106
+ search,
107
+ id
108
+ ]);
104
109
  return {
105
110
  id,
106
- open: useCallback((rowOrId) => {
107
- const rowId = typeof rowOrId === "string" ? rowOrId : rowOrId.id;
108
- navigate(`${baseUrl}/${rowId}${search}`, { replace: Boolean(id) });
109
- }, [
110
- navigate,
111
- baseUrl,
112
- search,
113
- id
114
- ]),
111
+ open,
115
112
  close: useCallback(() => {
116
113
  navigate(`${baseUrl}${search}`);
117
114
  }, [
118
115
  navigate,
119
116
  baseUrl,
120
117
  search
121
- ])
118
+ ]),
119
+ reopen: useReopenLastRow(id, open)
122
120
  };
123
121
  }
122
+ /**
123
+ * Opens the last open row again, for `onReopen` of the detail. It gives
124
+ * `undefined` while a row is open or before the first row opens.
125
+ */
126
+ function useReopenLastRow(openId, open) {
127
+ const [lastId, setLastId] = useState(openId);
128
+ if (openId !== void 0 && openId !== lastId) setLastId(openId);
129
+ return openId === void 0 && lastId !== void 0 ? () => open(lastId) : void 0;
130
+ }
124
131
  //#endregion
125
- export { Page_default as default, getPaginatedListState, useOpenRowRoute };
132
+ export { Page_default as default, getPaginatedListState, useOpenRowRoute, useReopenLastRow };
@@ -1,5 +1,6 @@
1
- import { useTranslation } from "../../i18n.js";
2
1
  import { Status } from "../../../icons/index.js";
2
+ import { useTranslation } from "../../i18n.js";
3
+ import "../../layout/SplitPane.js";
3
4
  import Toolbar from "../../layout/Toolbar/index.js";
4
5
  import BlankSlate_default from "../../feedback/BlankSlate.js";
5
6
  import Pane_default from "../../layout/Pane/index.js";
@@ -19,7 +20,8 @@ function ListDetailPanel({ title, state = "ready", fetching, actions, toolbarAct
19
20
  header: /* @__PURE__ */ jsxs(Toolbar, { children: [
20
21
  closeOverlay && /* @__PURE__ */ jsx(Toolbar.GoBack, {
21
22
  onClick: closeOverlay,
22
- ariaLabel: { id: "admin.listDetail.panel.close" }
23
+ ariaLabel: { id: "admin.listDetail.panel.close" },
24
+ action: "sidebar.toggleRight"
23
25
  }),
24
26
  /* @__PURE__ */ jsx(Toolbar.Title, {
25
27
  level: 2,
@@ -11,6 +11,11 @@ export type ListDetailSplitDetail = {
11
11
  * goes over the list, the back button of the panel run it.
12
12
  */
13
13
  onClose: () => void;
14
+ /**
15
+ * Opens the last open row again, while no row is open. Without it, `]`
16
+ * only closes the open row.
17
+ */
18
+ onReopen?: () => void;
14
19
  };
15
20
  export type ListDetailSplitProps = {
16
21
  /** The rows open a detail at the right. Without it, the list is alone. */
@@ -1,13 +1,14 @@
1
- import { HotKeyListener } from "../../actions/HotKey.js";
1
+ import { Misc, Navigation } from "../../../icons/index.js";
2
+ import { useRegisterActions } from "../../actions/Actions/registry.js";
2
3
  import { useMediaQuery } from "../../hooks/useMediaQuery.js";
3
- import { Navigation } from "../../../icons/index.js";
4
+ import { CollectionRegionProvider } from "../../layout/Pane/PaneRegion.js";
4
5
  import { useSashActionReveal } from "../../layout/SplitView/SashActionButton.js";
5
6
  import SplitView_default from "../../layout/SplitView/SplitView.js";
6
- import SplitPane from "../../layout/SplitPane.js";
7
+ import SplitPane, { TOGGLE_RIGHT_SIDEBAR_ACTION_ID } from "../../layout/SplitPane.js";
7
8
  import { useListDetailWidths } from "./Widths.js";
8
9
  import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  import classNames from "classnames";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
12
  //#region ../ui/src/patterns/ListDetail/Split.tsx
12
13
  var MIN_LIST_WIDTH = 360;
13
14
  var DEFAULT_DETAIL_WIDTH = 500;
@@ -53,6 +54,11 @@ function ListDetailSplit({ detail, children }) {
53
54
  const { matches: isOverlay } = useMediaQuery(OVERLAY_MEDIA_QUERY);
54
55
  const isOpen = Boolean(panel);
55
56
  const [container, setContainer] = useState(null);
57
+ const containerRef = useRef(null);
58
+ const setContainerElement = useCallback((element) => {
59
+ containerRef.current = element;
60
+ setContainer(element);
61
+ }, []);
56
62
  const [containerWidth, setContainerWidth] = useState();
57
63
  useEffect(() => {
58
64
  if (!container) return void 0;
@@ -90,64 +96,77 @@ function ListDetailSplit({ detail, children }) {
90
96
  const firstListWidth = containerWidth === void 0 ? MAX_FIRST_LIST_WIDTH : Math.max(MIN_LIST_WIDTH, Math.min(MAX_FIRST_LIST_WIDTH, containerWidth - DEFAULT_DETAIL_WIDTH));
91
97
  const size = Math.min(listWidth ?? firstListWidth, maxListWidth ?? Number.POSITIVE_INFINITY);
92
98
  const hideButton = useSashActionReveal(isOpen && isOverlay);
99
+ useRegisterActions([{
100
+ id: "listDetail.close",
101
+ name: { id: "admin.listDetail.panel.close" },
102
+ shortcut: { key: "escape" },
103
+ palette: "hidden",
104
+ applicable: () => isOpen,
105
+ run: onCloseDetail
106
+ }, {
107
+ id: TOGGLE_RIGHT_SIDEBAR_ACTION_ID,
108
+ name: { id: "sidebar.toggleRight" },
109
+ icon: Misc.SidebarFlipIcon,
110
+ shortcut: { key: "]" },
111
+ applicable: () => isOpen || Boolean(detail?.onReopen),
112
+ run: () => isOpen ? onCloseDetail() : detail?.onReopen?.()
113
+ }]);
93
114
  const list = /* @__PURE__ */ jsx(DetailOpenContext.Provider, {
94
115
  value: isOpen,
95
- children
116
+ children: /* @__PURE__ */ jsx(CollectionRegionProvider, {
117
+ value: containerRef,
118
+ children
119
+ })
96
120
  });
97
- return /* @__PURE__ */ jsx(HotKeyListener, {
98
- hotKey: "escape",
99
- description: { id: "hotkeys.closeModal" },
100
- trigger: onCloseDetail,
101
- enabled: isOpen,
102
- children: /* @__PURE__ */ jsx("div", {
103
- ref: setContainer,
104
- className: classNames("ListDetailSplit", {
105
- "ListDetailSplit--open": isOpen,
106
- "ListDetailSplit--overlay": isOverlay
107
- }),
108
- children: isOverlay ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
109
- className: "ListDetailSplit__list",
110
- children: list
111
- }), isOpen && /* @__PURE__ */ jsxs("div", {
121
+ return /* @__PURE__ */ jsx("div", {
122
+ ref: setContainerElement,
123
+ className: classNames("ListDetailSplit", {
124
+ "ListDetailSplit--open": isOpen,
125
+ "ListDetailSplit--overlay": isOverlay
126
+ }),
127
+ children: isOverlay ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
128
+ className: "ListDetailSplit__list",
129
+ children: list
130
+ }), isOpen && /* @__PURE__ */ jsxs("div", {
131
+ className: "ListDetailSplit__detail",
132
+ ...hideButton.paneHoverProps,
133
+ children: [/* @__PURE__ */ jsx(SplitView_default.Sash, {
134
+ split: "vertical",
135
+ allowResize: false,
136
+ style: SASH_STYLE,
137
+ onMouseDown: noop,
138
+ onMouseMove: noop,
139
+ onMouseUp: noop,
140
+ action: {
141
+ icon: Navigation.ChevronsRightIcon,
142
+ label: { id: "admin.listDetail.panel.close" },
143
+ action: "sidebar.toggleRight",
144
+ onClick: onCloseDetail,
145
+ revealFrom: "right",
146
+ hidden: !hideButton.isVisible
147
+ }
148
+ }), /* @__PURE__ */ jsx(OverlayCloseContext.Provider, {
149
+ value: onCloseDetail,
150
+ children: panel
151
+ })]
152
+ })] }) : /* @__PURE__ */ jsxs(SplitPane, {
153
+ primaryPane: "right",
154
+ size,
155
+ minSize: MIN_LIST_WIDTH,
156
+ maxSize: maxListWidth,
157
+ onDragFinished: onListWidthChange,
158
+ children: [list, isOpen ? /* @__PURE__ */ jsxs("div", {
112
159
  className: "ListDetailSplit__detail",
113
- ...hideButton.paneHoverProps,
160
+ style: { width: detailWidth },
114
161
  children: [/* @__PURE__ */ jsx(SplitView_default.Sash, {
115
162
  split: "vertical",
116
- allowResize: false,
117
- style: SASH_STYLE,
118
- onMouseDown: noop,
119
- onMouseMove: noop,
120
- onMouseUp: noop,
121
- action: {
122
- icon: Navigation.ChevronsRightIcon,
123
- label: { id: "admin.listDetail.panel.close" },
124
- onClick: onCloseDetail,
125
- revealFrom: "right",
126
- hidden: !hideButton.isVisible
127
- }
128
- }), /* @__PURE__ */ jsx(OverlayCloseContext.Provider, {
129
- value: onCloseDetail,
130
- children: panel
131
- })]
132
- })] }) : /* @__PURE__ */ jsxs(SplitPane, {
133
- primaryPane: "right",
134
- size,
135
- minSize: MIN_LIST_WIDTH,
136
- maxSize: maxListWidth,
137
- onDragFinished: onListWidthChange,
138
- children: [list, isOpen ? /* @__PURE__ */ jsxs("div", {
139
- className: "ListDetailSplit__detail",
140
- style: { width: detailWidth },
141
- children: [/* @__PURE__ */ jsx(SplitView_default.Sash, {
142
- split: "vertical",
143
- allowResize: true,
144
- style: DETAIL_SASH_STYLE,
145
- onMouseDown: handleDetailDragStart,
146
- onMouseMove: handleDetailDragMove,
147
- onMouseUp: handleDetailDragEnd
148
- }), panel]
149
- }) : null]
150
- })
163
+ allowResize: true,
164
+ style: DETAIL_SASH_STYLE,
165
+ onMouseDown: handleDetailDragStart,
166
+ onMouseMove: handleDetailDragMove,
167
+ onMouseUp: handleDetailDragEnd
168
+ }), panel]
169
+ }) : null]
151
170
  })
152
171
  });
153
172
  }
@@ -1,4 +1,4 @@
1
- import { getPaginatedListState, type ListDetailPageState, useOpenRowRoute } from './Page.js';
1
+ import { getPaginatedListState, type ListDetailPageState, useOpenRowRoute, useReopenLastRow } from './Page.js';
2
2
  import { getListDetailMaxWidth, useIsListDetailOpen } from './Split.js';
3
3
  import { ListDetailWidthsProvider } from './Widths.js';
4
4
  export declare const ListDetail: {
@@ -9,4 +9,4 @@ export declare const ListDetail: {
9
9
  children: React.ReactNode;
10
10
  }) => import("react").JSX.Element>;
11
11
  };
12
- export { getListDetailMaxWidth, getPaginatedListState, type ListDetailPageState, ListDetailWidthsProvider, useIsListDetailOpen, useOpenRowRoute, };
12
+ export { getListDetailMaxWidth, getPaginatedListState, type ListDetailPageState, ListDetailWidthsProvider, useIsListDetailOpen, useOpenRowRoute, useReopenLastRow, };
@@ -1,7 +1,7 @@
1
1
  import { ListDetailWidthsProvider } from "./Widths.js";
2
2
  import Split_default, { getListDetailMaxWidth, useIsListDetailOpen } from "./Split.js";
3
3
  import Overview_default from "./Overview.js";
4
- import Page_default, { getPaginatedListState, useOpenRowRoute } from "./Page.js";
4
+ import Page_default, { getPaginatedListState, useOpenRowRoute, useReopenLastRow } from "./Page.js";
5
5
  import Panel_default from "./Panel.js";
6
6
  //#region ../ui/src/patterns/ListDetail/index.ts
7
7
  var ListDetail = {
@@ -11,4 +11,4 @@ var ListDetail = {
11
11
  Overview: Overview_default
12
12
  };
13
13
  //#endregion
14
- export { ListDetail, ListDetailWidthsProvider, getListDetailMaxWidth, getPaginatedListState, useIsListDetailOpen, useOpenRowRoute };
14
+ export { ListDetail, ListDetailWidthsProvider, getListDetailMaxWidth, getPaginatedListState, useIsListDetailOpen, useOpenRowRoute, useReopenLastRow };
@@ -2,7 +2,7 @@ import { isActivePath, useNavigation } from "../navigation/NavigationProvider.js
2
2
  import SplitPane from "../layout/SplitPane.js";
3
3
  import ListOrOverview_default from "../layout/ListOrOverview.js";
4
4
  import React from "react";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region ../ui/src/patterns/ListFormPage.tsx
7
7
  /**
8
8
  * The content of a settings section whose elements are forms (for a list
@@ -13,7 +13,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  */
14
14
  function ListFormPage({ baseUrl, state, overview, list, children }) {
15
15
  const { location } = useNavigation();
16
- if (!(location ? isActivePath(location.pathname, baseUrl, true) : false) && (state === "empty" || state === "loading" && list === void 0)) return /* @__PURE__ */ jsx(Fragment, { children });
16
+ if (!(location ? isActivePath(location.pathname, baseUrl, true) : false) && (state === "empty" || state === "loading" && list === void 0)) return /* @__PURE__ */ jsx(Fragment$1, { children });
17
17
  return /* @__PURE__ */ jsx(ListOrOverview_default, {
18
18
  state,
19
19
  overview,
@@ -3,7 +3,10 @@ export type MainProps = Omit<React.HTMLAttributes<HTMLElement>, 'id'>;
3
3
  /**
4
4
  * The main content of the page: a landmark. A page has only one. It always
5
5
  * has the id "main-content", because the skip link of the authenticated
6
- * layout points to it. A heading of level 1 goes inside it.
6
+ * layout points to it. A heading of level 1 goes inside it. In a dialog, it
7
+ * replaces the main content of the page: the dialog covers the page, and the
8
+ * host can make the page inert (see `useIsPageCovered`). In a
9
+ * `NavigationFocusProvider`, it takes the focus when the pathname changes.
7
10
  */
8
11
  declare const Main: React.ForwardRefExoticComponent<MainProps & React.RefAttributes<HTMLElement>>;
9
12
  export default Main;
@@ -1,16 +1,66 @@
1
- import React from "react";
1
+ import { useLayerCoversPage } from "../actions/Actions/registry.js";
2
+ import { useNavigationFocus } from "./NavigationFocusProvider.js";
3
+ import React, { useEffect, useRef } from "react";
2
4
  import { jsx } from "react/jsx-runtime";
5
+ import mergeRefs from "@react-hook/merged-ref";
3
6
  //#region ../ui/src/semantic/Main.tsx
7
+ var SECONDARY_PANE = ".SplitPane__secondary-host, .SplitPaneOverlay";
8
+ /**
9
+ * The content of the first `Pane` of `main` that is not in the secondary
10
+ * pane of a `SplitPane`: the side list of a page is not its content.
11
+ */
12
+ function primaryPaneContent(main) {
13
+ for (const content of Array.from(main.querySelectorAll(".Pane__content"))) {
14
+ const secondary = content.closest(SECONDARY_PANE);
15
+ if (!secondary || !main.contains(secondary)) return content;
16
+ }
17
+ return null;
18
+ }
19
+ function focusMain(main) {
20
+ main.setAttribute("tabindex", "-1");
21
+ main.focus({ preventScroll: true });
22
+ if (document.activeElement !== main) {
23
+ main.removeAttribute("tabindex");
24
+ return;
25
+ }
26
+ main.addEventListener("blur", () => main.removeAttribute("tabindex"), { once: true });
27
+ }
28
+ /** Moves the focus into the page when the pathname of the host changes */
29
+ function useFocusOnNavigation(mainRef) {
30
+ const navigation = useNavigationFocus();
31
+ useEffect(() => {
32
+ const main = mainRef.current;
33
+ if (!navigation || !main) return;
34
+ const { pathname, consumed } = navigation;
35
+ if (pathname === consumed.current) return;
36
+ if (main.closest("[inert]")) return;
37
+ if (main.contains(document.activeElement)) {
38
+ consumed.current = pathname;
39
+ return;
40
+ }
41
+ const content = primaryPaneContent(main);
42
+ if (content) content.focus({ preventScroll: true });
43
+ else focusMain(main);
44
+ if (main.contains(document.activeElement)) consumed.current = pathname;
45
+ }, [navigation, mainRef]);
46
+ }
4
47
  /**
5
48
  * The main content of the page: a landmark. A page has only one. It always
6
49
  * has the id "main-content", because the skip link of the authenticated
7
- * layout points to it. A heading of level 1 goes inside it.
50
+ * layout points to it. A heading of level 1 goes inside it. In a dialog, it
51
+ * replaces the main content of the page: the dialog covers the page, and the
52
+ * host can make the page inert (see `useIsPageCovered`). In a
53
+ * `NavigationFocusProvider`, it takes the focus when the pathname changes.
8
54
  */
9
55
  var Main = React.forwardRef(function Main(props, ref) {
56
+ const mainRef = useRef(null);
57
+ const mergedRef = mergeRefs(ref, mainRef);
58
+ useLayerCoversPage();
59
+ useFocusOnNavigation(mainRef);
10
60
  return /* @__PURE__ */ jsx("main", {
11
61
  ...props,
12
62
  id: "main-content",
13
- ref
63
+ ref: mergedRef
14
64
  });
15
65
  });
16
66
  //#endregion
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from "react";
2
+ import "react/jsx-runtime";
3
+ //#region ../ui/src/semantic/NavigationFocusProvider.tsx
4
+ var NavigationFocusContext = createContext(null);
5
+ function useNavigationFocus() {
6
+ return useContext(NavigationFocusContext);
7
+ }
8
+ //#endregion
9
+ export { useNavigationFocus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-react-ui",
3
- "version": "3.1.0-next.0",
3
+ "version": "3.1.0-next.1",
4
4
  "description": "React components to use inside DatoCMS plugins",
5
5
  "keywords": [
6
6
  "datocms",
package/dist/HotKey.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./ui/src/actions/HotKey.js";
package/dist/HotKey.js DELETED
@@ -1,2 +0,0 @@
1
- import { HotKey, HotKeyListener, HotKeyManager, HotKeyManagerInfo, HotKeyStack, HotKeyTooltip, useIsRootCovered } from "./ui/src/actions/HotKey.js";
2
- export { HotKey, HotKeyListener, HotKeyManager, HotKeyManagerInfo, HotKeyStack, HotKeyTooltip, useIsRootCovered };
@@ -1,98 +0,0 @@
1
- import React from 'react';
2
- import { type Message, type TextMessage } from '../Message.js';
3
- import { type TooltipProps } from '../overlays/Tooltip.js';
4
- import { type Callback } from './hotKeyContext.js';
5
- export declare const useIsRootCovered: () => boolean;
6
- export type HotKeyStackProps = {
7
- /** The part of the page that has its own keys, for example a dialog. */
8
- children: React.ReactNode;
9
- /**
10
- * The priority of the stack. By default it is one more than the priority
11
- * of the stack around it. Modal, FullscreenModal and Confirm set the
12
- * priority of their dialog layer: a dialog that opens later is above the
13
- * others, also when it is not inside them in the tree.
14
- */
15
- forceStackPriority?: number;
16
- };
17
- /**
18
- * A layer of keys. While it is mounted, only its own HotKeyListener
19
- * elements work, and the ones of the layers below do not. A dialog is a
20
- * stack.
21
- */
22
- export declare function HotKeyStack({ children, forceStackPriority, }: HotKeyStackProps): React.JSX.Element;
23
- /**
24
- * Listens to the keys of the whole page. Put it once near the root of the
25
- * app, above every HotKeyListener.
26
- */
27
- export declare function HotKeyManager({ children }: {
28
- children: React.ReactNode;
29
- }): React.JSX.Element;
30
- export type HotKeyListenerProps = {
31
- /**
32
- * The keys, in the format of `is-hotkey`, for example "mod+s" or
33
- * "mod+shift+s". "mod" is Cmd on a Mac and Ctrl on other systems.
34
- */
35
- hotKey: string;
36
- /**
37
- * The text that tells what the keys do, for example
38
- * `{ id: 'hotkeys.saveRecord' }`. The tooltip and the list of the active
39
- * keys show it.
40
- */
41
- description: TextMessage;
42
- /**
43
- * The function that runs when the user presses the keys. When it returns a
44
- * promise, `children` gets `true` until the promise ends.
45
- */
46
- trigger: Callback;
47
- /**
48
- * The elements that the keys belong to. A HotKeyTooltip inside shows the
49
- * keys. Use a function to get `isTriggerPending`, for example to show a
50
- * spinner on a button.
51
- */
52
- children: React.ReactNode | ((isTriggerPending: boolean) => React.ReactNode) | undefined;
53
- /**
54
- * When it is `false`, the keys do nothing and the tooltip does not show
55
- * them.
56
- * @default true
57
- */
58
- enabled?: boolean;
59
- };
60
- /**
61
- * Runs `trigger` when the user presses `hotKey`. Of two listeners with the
62
- * same keys, the one that is nested deeper in the tree wins.
63
- */
64
- export declare function HotKeyListener({ children, hotKey, enabled, trigger, description: descriptionProp, }: HotKeyListenerProps): React.JSX.Element;
65
- export type HotKeyProps = {
66
- /**
67
- * The keys, joined with "+", for example "mod+enter" or "esc". "mod" is
68
- * Cmd on a Mac and Ctrl on other systems. Enter, Esc and the arrows show
69
- * as symbols.
70
- */
71
- hotkey: string;
72
- };
73
- /** The keys of a shortcut, drawn as small keycaps. */
74
- export declare function HotKey({ hotkey }: HotKeyProps): React.JSX.Element;
75
- export type HotKeyTooltipProps = Omit<TooltipProps, 'label' | 'shortcut' | 'long'> & {
76
- /**
77
- * The text of the tooltip, for example the label of an icon-only button.
78
- * By default it is the description of the HotKeyListener around it.
79
- */
80
- label?: Message;
81
- /**
82
- * The tooltip does not show, for example while the menu of a trigger is
83
- * open. The trigger stays in the same place in the tree.
84
- * @default false
85
- */
86
- hidden?: boolean;
87
- };
88
- /**
89
- * A tooltip with the keys of the HotKeyListener of the trigger. Put the
90
- * HotKeyListener around it. When there is no listener, or the listener is
91
- * disabled, the tooltip has no keys, and without `label` it does not show.
92
- */
93
- export declare function HotKeyTooltip({ label, hidden, ...props }: HotKeyTooltipProps): React.JSX.Element;
94
- /**
95
- * A panel at the top of the page with the active keys. Cmd or Ctrl + \\
96
- * opens and closes it. Put it once, inside HotKeyManager.
97
- */
98
- export declare function HotKeyManagerInfo(): React.JSX.Element;