@gopherium/godmin 0.23.0 → 0.24.0
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/README.md +1 -1
- package/dist/base.css +43 -0
- package/dist/confirm-dialog.d.ts +1 -1
- package/dist/form-dialog.d.ts +1 -1
- package/dist/frame.d.ts +5 -3
- package/dist/frame.js +25 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/menu-count.d.ts +12 -0
- package/dist/menu-count.js +14 -0
- package/dist/run-confirm.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ two lines do for you.
|
|
|
52
52
|
|
|
53
53
|
| Entry point | Contents |
|
|
54
54
|
| --- | --- |
|
|
55
|
-
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `RAIL_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
|
|
55
|
+
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `RAIL_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
|
|
56
56
|
| `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
|
|
57
57
|
| `@gopherium/godmin/dates` | `startListDates`, `listDate`, the only entry that loads `@wordpress/date` |
|
|
58
58
|
| `@gopherium/godmin/dialogs` | `ConfirmDialog`, `FormDialog`, the only entry that loads `@wordpress/components`. Load `@wordpress/components/build-style/style.css` once in your app, as DataViews asks |
|
package/dist/base.css
CHANGED
|
@@ -163,6 +163,24 @@ body {
|
|
|
163
163
|
overflow-y: auto;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
.godmin-menu-count__badge {
|
|
167
|
+
--godmin-menu-count-size: 18px;
|
|
168
|
+
display: inline-block;
|
|
169
|
+
vertical-align: top;
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
min-inline-size: var(--godmin-menu-count-size);
|
|
172
|
+
block-size: var(--godmin-menu-count-size);
|
|
173
|
+
margin-block: 1px -1px;
|
|
174
|
+
margin-inline-start: 2px;
|
|
175
|
+
padding-block: 0;
|
|
176
|
+
padding-inline: 5px;
|
|
177
|
+
border-radius: calc(var(--godmin-menu-count-size) / 2);
|
|
178
|
+
font-size: var(--wpds-typography-font-size-xs);
|
|
179
|
+
font-weight: inherit;
|
|
180
|
+
line-height: 1.6;
|
|
181
|
+
text-align: center;
|
|
182
|
+
}
|
|
183
|
+
|
|
166
184
|
.godmin-layout__canvas {
|
|
167
185
|
--godmin-canvas-gutter: 24px;
|
|
168
186
|
--godmin-canvas-gutter-block: var(--wpds-dimension-padding-lg);
|
|
@@ -192,6 +210,31 @@ body {
|
|
|
192
210
|
margin-inline-start: 0;
|
|
193
211
|
}
|
|
194
212
|
|
|
213
|
+
.godmin-layout__notices {
|
|
214
|
+
display: flex;
|
|
215
|
+
flex: none;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: var(--wpds-dimension-gap-md);
|
|
218
|
+
margin-block-end: var(--godmin-canvas-gutter-block);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.godmin-layout__notices:empty {
|
|
222
|
+
display: none;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.godmin-layout__canvas:not(.godmin-layout__canvas--bleed):has(.godmin-page > .godmin-page__list) > .godmin-layout__notices {
|
|
226
|
+
padding-inline: calc(var(--wpds-dimension-padding-2xl) - var(--godmin-canvas-gutter));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.godmin-layout__canvas--bleed .godmin-layout__notices {
|
|
230
|
+
gap: 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.godmin-layout__canvas--bleed .godmin-layout__notices > * {
|
|
234
|
+
border-block-start-width: 0;
|
|
235
|
+
border-inline-width: 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
195
238
|
.godmin-toasts {
|
|
196
239
|
position: fixed;
|
|
197
240
|
inset-inline: 0;
|
package/dist/confirm-dialog.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface ConfirmDialogProps {
|
|
|
12
12
|
/** The label of the button that closes the dialog. */
|
|
13
13
|
cancelLabel: string;
|
|
14
14
|
/** Carries the action out. Return nothing to close at once, or the write's promise to stay busy until it ends. */
|
|
15
|
-
onConfirm: () => void | Promise<
|
|
15
|
+
onConfirm: () => void | Promise<unknown>;
|
|
16
16
|
/** Takes the dialog away after Cancel, Escape, a click outside it, its close button or a confirm that finished. */
|
|
17
17
|
onClose: () => void;
|
|
18
18
|
}
|
package/dist/form-dialog.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface FormDialogProps {
|
|
|
17
17
|
/** What the form does: 16px above the buttons for a create, the default, 20px for an edit, 12px for a copy. */
|
|
18
18
|
kind?: FormKind;
|
|
19
19
|
/** Sends the form. Return the write's promise to keep the button busy until it ends. */
|
|
20
|
-
onSubmit: () => void | Promise<
|
|
20
|
+
onSubmit: () => void | Promise<unknown>;
|
|
21
21
|
/** Takes the dialog away after Cancel, Escape, a click on the dimmed page or the close button. */
|
|
22
22
|
onClose: () => void;
|
|
23
23
|
}
|
package/dist/frame.d.ts
CHANGED
|
@@ -34,13 +34,15 @@ export type CanvasMode = 'padded' | 'bleed';
|
|
|
34
34
|
export interface FrameCanvasProps {
|
|
35
35
|
children: ReactNode;
|
|
36
36
|
canvas?: CanvasMode;
|
|
37
|
+
/** The notices drawn in a band above the screen, such as a notice that an update is available. */
|
|
38
|
+
notices?: ReactNode;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
|
-
* Renders the region showing the active screen.
|
|
40
|
-
* @param props - The screen,
|
|
41
|
+
* Renders the region showing the active screen, under a band of notices when the app gives some.
|
|
42
|
+
* @param props - The screen, whether it fills the canvas edge to edge, and the notices.
|
|
41
43
|
* @returns The canvas element.
|
|
42
44
|
*/
|
|
43
|
-
declare function Canvas({ children, canvas }: FrameCanvasProps): import("react").JSX.Element;
|
|
45
|
+
declare function Canvas({ children, canvas, notices }: FrameCanvasProps): import("react").JSX.Element;
|
|
44
46
|
/**
|
|
45
47
|
* The admin frame, whose regions are present when their element is rendered.
|
|
46
48
|
*/
|
package/dist/frame.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
object export standing beside the parts it is built from. */
|
|
4
4
|
import { ThemeProvider } from '@wordpress/theme';
|
|
5
5
|
import { Drawer, VisuallyHidden } from '@wordpress/ui';
|
|
6
|
-
import { createContext, useContext, useEffect, useState } from 'react';
|
|
6
|
+
import { Children, createContext, useContext, useEffect, useState } from 'react';
|
|
7
7
|
import { SMALL_VIEWPORT } from './breakpoints.js';
|
|
8
8
|
import { useMediaQuery } from './use-media-query.js';
|
|
9
9
|
/**
|
|
@@ -59,16 +59,36 @@ function TopBar({ children, brand, menuLabel, }) {
|
|
|
59
59
|
return (_jsxs("div", { className: "godmin-layout__topbar", children: [_jsxs(Drawer.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Drawer.Trigger, { render: _jsx("button", { type: "button", className: "godmin-layout__menu", "aria-label": menuLabel }), children: menuIcon }), _jsxs(Drawer.Popup, { className: "godmin-layout__drawer", portal: _jsx(Drawer.Portal, { container: layout }), children: [_jsx(VisuallyHidden, { render: _jsx(Drawer.Title, {}), children: menuLabel }), children] })] }), brand] }));
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @param
|
|
62
|
+
* Tells whether notices hold anything React draws.
|
|
63
|
+
* @param notices - The notices the app gives.
|
|
64
|
+
* @returns Whether any of them is something other than nothing or an empty string.
|
|
65
|
+
*/
|
|
66
|
+
function hasNotices(notices) {
|
|
67
|
+
return Children.toArray(notices).some((notice) => notice !== '');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Renders the notices in a band of their own, with square corners on a bleed canvas, or nothing when there are none.
|
|
71
|
+
* @param props - The notices and how the screen fills the canvas.
|
|
72
|
+
* @returns The band element, or null.
|
|
73
|
+
*/
|
|
74
|
+
function Notices({ notices, canvas }) {
|
|
75
|
+
if (!hasNotices(notices)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const band = _jsx("div", { className: "godmin-layout__notices", children: notices });
|
|
79
|
+
return canvas === 'bleed' ? _jsx(ThemeProvider, { cornerRadius: "none", children: band }) : band;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Renders the region showing the active screen, under a band of notices when the app gives some.
|
|
83
|
+
* @param props - The screen, whether it fills the canvas edge to edge, and the notices.
|
|
64
84
|
* @returns The canvas element.
|
|
65
85
|
*/
|
|
66
|
-
function Canvas({ children, canvas = 'padded' }) {
|
|
86
|
+
function Canvas({ children, canvas = 'padded', notices }) {
|
|
67
87
|
const color = useContext(CanvasColorContext);
|
|
68
88
|
const classes = canvas === 'bleed'
|
|
69
89
|
? 'godmin-layout__canvas godmin-layout__canvas--bleed'
|
|
70
90
|
: 'godmin-layout__canvas';
|
|
71
|
-
return (_jsx(ThemeProvider, { color: color, children:
|
|
91
|
+
return (_jsx(ThemeProvider, { color: color, children: _jsxs("main", { className: classes, style: { isolation: 'isolate' }, children: [_jsx(Notices, { notices: notices, canvas: canvas }), children] }) }));
|
|
72
92
|
}
|
|
73
93
|
/**
|
|
74
94
|
* The admin frame, whose regions are present when their element is rendered.
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export type { ListRun, ListRunState, RunSettled } from './list-run.js';
|
|
|
26
26
|
export { LoadingRows, LoadingScreen } from './loading.js';
|
|
27
27
|
export { LogItem, LogList, LogTime } from './log-list.js';
|
|
28
28
|
export type { LogItemProps, LogListProps, LogTimeProps } from './log-list.js';
|
|
29
|
+
export { MenuCount } from './menu-count.js';
|
|
30
|
+
export type { MenuCountProps } from './menu-count.js';
|
|
29
31
|
export { NavScreen } from './nav-screen.js';
|
|
30
32
|
export type { NavScreenProps } from './nav-screen.js';
|
|
31
33
|
export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { ListEmpty } from './list-empty.js';
|
|
|
14
14
|
export { useListRun } from './list-run.js';
|
|
15
15
|
export { LoadingRows, LoadingScreen } from './loading.js';
|
|
16
16
|
export { LogItem, LogList, LogTime } from './log-list.js';
|
|
17
|
+
export { MenuCount } from './menu-count.js';
|
|
17
18
|
export { NavScreen } from './nav-screen.js';
|
|
18
19
|
export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
|
|
19
20
|
export { PageTab, PageTabs } from './page-tabs.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MenuCountProps {
|
|
2
|
+
/** The number the count shows, nothing drawn at zero or below. */
|
|
3
|
+
count: number;
|
|
4
|
+
/** The sentence a screen reader reads in place of the number, such as "1 update available". */
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Renders the small count beside a menu label, such as the number of pending updates.
|
|
9
|
+
* @param props - The number and the sentence a screen reader reads for it.
|
|
10
|
+
* @returns The count element, or null when there is nothing to count.
|
|
11
|
+
*/
|
|
12
|
+
export declare function MenuCount({ count, label }: MenuCountProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Badge, VisuallyHidden } from '@wordpress/ui';
|
|
4
|
+
/**
|
|
5
|
+
* Renders the small count beside a menu label, such as the number of pending updates.
|
|
6
|
+
* @param props - The number and the sentence a screen reader reads for it.
|
|
7
|
+
* @returns The count element, or null when there is nothing to count.
|
|
8
|
+
*/
|
|
9
|
+
export function MenuCount({ count, label }) {
|
|
10
|
+
if (!(count > 0)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (_jsxs("span", { className: "godmin-menu-count", children: [_jsx(Badge, { intent: "high", className: "godmin-menu-count__badge", "aria-hidden": "true", children: count.toLocaleString() }), _jsx(VisuallyHidden, { render: _jsx("span", {}), children: label })] }));
|
|
14
|
+
}
|
package/dist/run-confirm.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface RunConfirmProps<Item> {
|
|
|
12
12
|
/** The label of the button that closes the modal. */
|
|
13
13
|
cancelLabel: string;
|
|
14
14
|
/** Runs the action over the items, settling once the list shows how it went. */
|
|
15
|
-
run: (items: Item[]) => Promise<
|
|
15
|
+
run: (items: Item[]) => Promise<unknown>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Renders a confirmation that runs the action, keeps Cancel inert while it runs and closes once it settles.
|
package/package.json
CHANGED