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.
- package/dist/Actions.d.ts +1 -0
- package/dist/Actions.js +4 -0
- package/dist/IconAvatar.d.ts +2 -0
- package/dist/IconAvatar.js +2 -0
- package/dist/ListDetail.js +2 -2
- package/dist/Pane.js +2 -1
- package/dist/SplitPane.js +2 -2
- package/dist/react-ui/src/Canvas.d.ts +2 -1
- package/dist/react-ui/src/Canvas.js +8 -6
- package/dist/react-ui/src/ContextInspector.js +2 -2
- package/dist/react-ui/src/messageText.js +1 -1
- package/dist/styles.css +330 -195
- package/dist/ui/icons/brands/gitlab.js +15 -0
- package/dist/ui/icons/custom/netlify.js +7 -29
- package/dist/ui/icons/custom/vercel.js +1 -4
- package/dist/ui/icons/index.js +206 -195
- package/dist/ui/icons/regular/command.js +16 -0
- package/dist/ui/icons/regular/keyboard.js +16 -0
- package/dist/ui/icons/regular/list-tree.js +2 -1
- package/dist/ui/icons/regular/list.js +2 -1
- package/dist/ui/icons/regular/memo.js +2 -1
- package/dist/ui/locales/en.js +10 -3
- package/dist/ui/src/BundledTexts.js +2 -2
- package/dist/ui/src/UiTextKey.d.ts +1 -1
- package/dist/ui/src/actions/Actions/ActionTooltip.js +24 -0
- package/dist/ui/src/actions/Actions/Shortcut.d.ts +23 -0
- package/dist/ui/src/actions/Actions/Shortcut.js +45 -0
- package/dist/ui/src/actions/Actions/index.d.ts +3 -0
- package/dist/ui/src/actions/Actions/index.js +3 -0
- package/dist/ui/src/actions/Actions/registry.d.ts +211 -0
- package/dist/ui/src/actions/Actions/registry.js +580 -0
- package/dist/ui/src/actions/Actions/shortcuts.d.ts +85 -0
- package/dist/ui/src/actions/Actions/shortcuts.js +284 -0
- package/dist/ui/src/actions/Button.d.ts +13 -12
- package/dist/ui/src/actions/Button.js +8 -7
- package/dist/ui/src/actions/Dropdown/DropdownContext.js +2 -1
- package/dist/ui/src/actions/Dropdown/Footer.js +1 -1
- package/dist/ui/src/actions/Dropdown/Menu.d.ts +2 -1
- package/dist/ui/src/actions/Dropdown/Menu.js +43 -37
- package/dist/ui/src/actions/Dropdown/MenuContent.js +22 -12
- package/dist/ui/src/actions/Dropdown/MenuParts.js +3 -3
- package/dist/ui/src/actions/Dropdown/Option.d.ts +20 -3
- package/dist/ui/src/actions/Dropdown/Option.js +48 -9
- package/dist/ui/src/actions/Dropdown/OptionAction.js +1 -1
- package/dist/ui/src/actions/Dropdown/Submenu.js +2 -2
- package/dist/ui/src/actions/Dropdown/index.d.ts +4 -1
- package/dist/ui/src/actions/Dropdown/index.js +6 -4
- package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +4 -4
- package/dist/ui/src/actions/Dropdown/triggers/ButtonTrigger.js +7 -6
- package/dist/ui/src/actions/Dropdown/triggers/PillTrigger.js +1 -1
- package/dist/ui/src/actions/Dropdown/triggers/TextualTrigger.js +1 -1
- package/dist/ui/src/actions/EditorToolbar/Button.js +2 -2
- package/dist/ui/src/actions/EditorToolbar/Buttons.js +2 -2
- package/dist/ui/src/actions/EditorToolbar/index.js +1 -1
- package/dist/ui/src/actions/MultipleSelectionActionBar.d.ts +20 -3
- package/dist/ui/src/actions/MultipleSelectionActionBar.js +25 -7
- package/dist/ui/src/actions/SplitButton/Caret.js +1 -1
- package/dist/ui/src/actions/SplitButton/index.js +1 -1
- package/dist/ui/src/actions/disabledReason.js +1 -1
- package/dist/ui/src/content/Avatar.d.ts +5 -3
- package/dist/ui/src/content/Avatar.js +4 -3
- package/dist/ui/src/content/CodeSnippet.js +1 -1
- package/dist/ui/src/content/CopyButton.js +1 -1
- package/dist/ui/src/content/CopyableId.d.ts +6 -1
- package/dist/ui/src/content/CopyableId.js +5 -2
- package/dist/ui/src/content/CopyableValue.js +2 -2
- package/dist/ui/src/content/FeedbackDot.js +1 -1
- package/dist/ui/src/content/IconAvatar.d.ts +42 -0
- package/dist/ui/src/content/IconAvatar.js +36 -0
- package/dist/ui/src/content/InitialsAvatar.js +1 -2
- package/dist/ui/src/content/Pill.js +3 -3
- package/dist/ui/src/content/SmartDate.js +1 -1
- package/dist/ui/src/content/UploadThreatTriangle.js +1 -1
- package/dist/ui/src/content/UsageMeter.d.ts +2 -1
- package/dist/ui/src/content/UsageMeter.js +3 -2
- package/dist/ui/src/content/ValidityTriangles.js +3 -3
- package/dist/ui/src/feedback/BlankSlate.js +2 -2
- package/dist/ui/src/feedback/Callout.js +2 -2
- package/dist/ui/src/feedback/ProgressBar.js +1 -1
- package/dist/ui/src/form/AutosizeInput.js +1 -1
- package/dist/ui/src/form/FieldHint.js +1 -1
- package/dist/ui/src/form/FieldWrapper.js +1 -1
- package/dist/ui/src/form/InputGroup.js +1 -1
- package/dist/ui/src/form/Label.js +2 -2
- package/dist/ui/src/form/PasswordInput.js +1 -1
- package/dist/ui/src/form/RadioGroupInput.js +1 -1
- package/dist/ui/src/form/SelectInput/SelectMenu.js +3 -3
- package/dist/ui/src/form/SelectInput/SelectMultiValueRemove.js +7 -0
- package/dist/ui/src/form/SelectInput/SelectOption.js +1 -1
- package/dist/ui/src/form/SelectInput/SortableMultiValue.js +1 -1
- package/dist/ui/src/form/StringInput.js +1 -1
- package/dist/ui/src/form/SwitchInput.d.ts +2 -0
- package/dist/ui/src/form/SwitchInput.js +4 -3
- package/dist/ui/src/form/SwitchList.js +1 -1
- package/dist/ui/src/form/TableList.js +2 -2
- package/dist/ui/src/form/TextareaInput.js +1 -1
- package/dist/ui/src/i18n.js +6 -6
- package/dist/ui/src/layout/ListOrOverview.js +3 -3
- package/dist/ui/src/layout/Page/Page.js +1 -1
- package/dist/ui/src/layout/Page/PageContent.js +1 -1
- package/dist/ui/src/layout/Page/PageGroup.js +2 -2
- package/dist/ui/src/layout/Page/PageSection.js +1 -1
- package/dist/ui/src/layout/Pane/ListFilter.js +6 -12
- package/dist/ui/src/layout/Pane/PaneHeader.js +3 -3
- package/dist/ui/src/layout/Pane/PaneRegion.d.ts +14 -0
- package/dist/ui/src/layout/Pane/PaneRegion.js +23 -0
- package/dist/ui/src/layout/Pane/index.d.ts +1 -0
- package/dist/ui/src/layout/Pane/index.js +36 -32
- package/dist/ui/src/layout/SidebarPanel.js +1 -1
- package/dist/ui/src/layout/SplitPane.d.ts +2 -0
- package/dist/ui/src/layout/SplitPane.js +79 -37
- package/dist/ui/src/layout/SplitView/SashActionButton.js +17 -9
- package/dist/ui/src/layout/SplitView/SplitView.js +1 -1
- package/dist/ui/src/layout/SplitView/SplitViewSash.js +2 -1
- package/dist/ui/src/layout/Toolbar/AddNewButton.d.ts +10 -6
- package/dist/ui/src/layout/Toolbar/AddNewButton.js +10 -23
- package/dist/ui/src/layout/Toolbar/Divider.d.ts +8 -0
- package/dist/ui/src/layout/Toolbar/Divider.js +16 -0
- package/dist/ui/src/layout/Toolbar/DotsDropdown.d.ts +8 -1
- package/dist/ui/src/layout/Toolbar/DotsDropdown.js +3 -2
- package/dist/ui/src/layout/Toolbar/Fill.js +1 -1
- package/dist/ui/src/layout/Toolbar/FilterInput.d.ts +7 -3
- package/dist/ui/src/layout/Toolbar/FilterInput.js +62 -49
- package/dist/ui/src/layout/Toolbar/FilterToggle.d.ts +6 -4
- package/dist/ui/src/layout/Toolbar/FilterToggle.js +42 -7
- package/dist/ui/src/layout/Toolbar/GoBack.d.ts +6 -1
- package/dist/ui/src/layout/Toolbar/GoBack.js +12 -5
- package/dist/ui/src/layout/Toolbar/Group.js +1 -1
- package/dist/ui/src/layout/Toolbar/Help.js +3 -3
- package/dist/ui/src/layout/Toolbar/Pagination.js +2 -2
- package/dist/ui/src/layout/Toolbar/PresetsTitle.js +3 -3
- package/dist/ui/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
- package/dist/ui/src/layout/Toolbar/PrimaryButton.js +2 -2
- package/dist/ui/src/layout/Toolbar/Root.d.ts +6 -1
- package/dist/ui/src/layout/Toolbar/Root.js +13 -2
- package/dist/ui/src/layout/Toolbar/Search.d.ts +2 -1
- package/dist/ui/src/layout/Toolbar/Search.js +8 -3
- package/dist/ui/src/layout/Toolbar/context.js +2 -1
- package/dist/ui/src/layout/Toolbar/index.d.ts +5 -3
- package/dist/ui/src/layout/Toolbar/index.js +2 -0
- package/dist/ui/src/lists/CardList.d.ts +7 -2
- package/dist/ui/src/lists/CardList.js +7 -6
- package/dist/ui/src/lists/EmptySlot.js +2 -2
- package/dist/ui/src/lists/EntityRow.js +1 -1
- package/dist/ui/src/lists/InfoList.js +8 -3
- package/dist/ui/src/lists/InsertGap.js +4 -4
- package/dist/ui/src/lists/MediaCard.d.ts +10 -0
- package/dist/ui/src/lists/MediaCard.js +9 -4
- package/dist/ui/src/lists/RowList.js +2 -2
- package/dist/ui/src/lists/SettingsList.js +1 -1
- package/dist/ui/src/lists/Table/Body.js +1 -1
- package/dist/ui/src/lists/Table/Cell.js +1 -1
- package/dist/ui/src/lists/Table/ColumnsMenu.js +1 -1
- package/dist/ui/src/lists/Table/Header.js +8 -10
- package/dist/ui/src/lists/Table/HeaderCell.js +2 -2
- package/dist/ui/src/lists/Table/Row.d.ts +7 -1
- package/dist/ui/src/lists/Table/Row.js +6 -2
- package/dist/ui/src/lists/Table/Table.js +1 -1
- package/dist/ui/src/lists/Table/TreeToggle.js +1 -1
- package/dist/ui/src/lists/Table/index.d.ts +1 -1
- package/dist/ui/src/lists/Table/layout.d.ts +3 -2
- package/dist/ui/src/lists/Table/layout.js +26 -13
- package/dist/ui/src/lists/dnd/DragHandle.js +1 -1
- package/dist/ui/src/lists/dnd/DropIndicator.js +1 -1
- package/dist/ui/src/lists/dnd/SortableList.js +2 -2
- package/dist/ui/src/lists/dnd/tree/SortableTree.js +1 -1
- package/dist/ui/src/navigation/Chevron.js +2 -2
- package/dist/ui/src/navigation/SegmentedControl.d.ts +23 -4
- package/dist/ui/src/navigation/SegmentedControl.js +23 -5
- package/dist/ui/src/navigation/SettingsMenu.js +3 -3
- package/dist/ui/src/navigation/SidebarTree/SidebarTreeNode.js +3 -3
- package/dist/ui/src/navigation/SidebarTree/SidebarTreeNodeActions.js +1 -1
- package/dist/ui/src/navigation/Tabs.js +1 -1
- package/dist/ui/src/overlays/FullscreenModal.js +48 -53
- package/dist/ui/src/overlays/HoverCard.js +4 -4
- package/dist/ui/src/overlays/Modal.d.ts +7 -0
- package/dist/ui/src/overlays/Modal.js +53 -55
- package/dist/ui/src/overlays/Popover.d.ts +6 -3
- package/dist/ui/src/overlays/Popover.js +13 -8
- package/dist/ui/src/overlays/Portal.js +1 -1
- package/dist/ui/src/overlays/Tooltip.d.ts +6 -3
- package/dist/ui/src/overlays/Tooltip.js +29 -13
- package/dist/ui/src/overlays/useModalClose.js +17 -12
- package/dist/ui/src/patterns/ListDetail/Page.d.ts +9 -0
- package/dist/ui/src/patterns/ListDetail/Page.js +33 -26
- package/dist/ui/src/patterns/ListDetail/Panel.js +4 -2
- package/dist/ui/src/patterns/ListDetail/Split.d.ts +5 -0
- package/dist/ui/src/patterns/ListDetail/Split.js +75 -56
- package/dist/ui/src/patterns/ListDetail/index.d.ts +2 -2
- package/dist/ui/src/patterns/ListDetail/index.js +2 -2
- package/dist/ui/src/patterns/ListFormPage.js +2 -2
- package/dist/ui/src/semantic/Main.d.ts +4 -1
- package/dist/ui/src/semantic/Main.js +53 -3
- package/dist/ui/src/semantic/NavigationFocusProvider.js +9 -0
- package/package.json +1 -1
- package/dist/HotKey.d.ts +0 -1
- package/dist/HotKey.js +0 -2
- package/dist/ui/src/actions/HotKey.d.ts +0 -98
- package/dist/ui/src/actions/HotKey.js +0 -270
- package/dist/ui/src/actions/hotKeyContext.d.ts +0 -32
- 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(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
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 {
|
|
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 {
|
|
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(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
className:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
160
|
+
style: { width: detailWidth },
|
|
114
161
|
children: [/* @__PURE__ */ jsx(SplitView_default.Sash, {
|
|
115
162
|
split: "vertical",
|
|
116
|
-
allowResize:
|
|
117
|
-
style:
|
|
118
|
-
onMouseDown:
|
|
119
|
-
onMouseMove:
|
|
120
|
-
onMouseUp:
|
|
121
|
-
|
|
122
|
-
|
|
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
|
|
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
package/dist/HotKey.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ui/src/actions/HotKey.js";
|
package/dist/HotKey.js
DELETED
|
@@ -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;
|