@gopherium/godmin 0.9.0 → 0.11.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 CHANGED
@@ -47,7 +47,7 @@ two lines do for you.
47
47
 
48
48
  | Entry point | Contents |
49
49
  | --- | --- |
50
- | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
50
+ | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
51
51
  | `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
52
52
  | `@gopherium/godmin/router` | `useCanvas`, `useFrameLocation`, the `canvas` route static data |
53
53
  | `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport`, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR` |
package/dist/base.css CHANGED
@@ -118,6 +118,29 @@ body {
118
118
  color: var(--wpds-color-foreground-content-neutral-weak);
119
119
  }
120
120
 
121
+ .godmin-page__split {
122
+ display: flex;
123
+ flex-wrap: wrap;
124
+ align-items: flex-start;
125
+ gap: var(--wpds-dimension-gap-xl);
126
+ }
127
+
128
+ .godmin-page__main {
129
+ flex: 999 1 0;
130
+ min-inline-size: min(50%, var(--wpds-dimension-surface-width-xl));
131
+ max-inline-size: var(--wpds-dimension-surface-width-xl);
132
+ }
133
+
134
+ .godmin-page__aside {
135
+ flex: 0 1 var(--wpds-dimension-surface-width-sm);
136
+ min-inline-size: 0;
137
+ overflow-wrap: anywhere;
138
+ }
139
+
140
+ .godmin-page__aside:empty {
141
+ display: none;
142
+ }
143
+
121
144
  .godmin-form {
122
145
  display: flex;
123
146
  flex-direction: column;
@@ -225,6 +248,61 @@ body {
225
248
  outline-offset: 2px;
226
249
  }
227
250
 
251
+ .godmin-log-list {
252
+ margin: 0;
253
+ padding: 0;
254
+ list-style: none;
255
+ overflow-wrap: anywhere;
256
+ background: var(--wpds-color-background-surface-neutral-strong);
257
+ border: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral);
258
+ border-radius: var(--wpds-border-radius-lg);
259
+ }
260
+
261
+ .godmin-log-list:empty {
262
+ display: none;
263
+ }
264
+
265
+ .godmin-log-list__item {
266
+ display: flex;
267
+ flex-direction: column;
268
+ gap: var(--wpds-dimension-gap-xs);
269
+ padding: var(--wpds-dimension-padding-sm) var(--wpds-dimension-padding-md);
270
+ }
271
+
272
+ .godmin-log-list__item + .godmin-log-list__item {
273
+ border-block-start: var(--wpds-border-width-xs) solid
274
+ var(--wpds-color-stroke-surface-neutral-weak);
275
+ }
276
+
277
+ .godmin-log-list__header {
278
+ display: flex;
279
+ flex-wrap: wrap;
280
+ align-items: center;
281
+ gap: var(--wpds-dimension-gap-xs) var(--wpds-dimension-gap-sm);
282
+ }
283
+
284
+ .godmin-log-list__label {
285
+ flex: 1 1 auto;
286
+ min-inline-size: 0;
287
+ }
288
+
289
+ .godmin-log-list__actions {
290
+ display: flex;
291
+ flex-wrap: wrap;
292
+ align-items: center;
293
+ justify-content: flex-end;
294
+ gap: var(--wpds-dimension-gap-xs);
295
+ margin-inline-start: auto;
296
+ }
297
+
298
+ .godmin-log-list__body {
299
+ white-space: pre-line;
300
+ }
301
+
302
+ .godmin-log-list__time {
303
+ color: var(--wpds-color-foreground-content-neutral-weak);
304
+ }
305
+
228
306
  /* Small viewport overrides live together at the end of the sheet, so they
229
307
  always win over the rules above them without extra specificity. */
230
308
  @media (max-width: 639px) {
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export type { CanvasMode, FrameCanvasProps, FrameRailProps, FrameRootProps, } fr
6
6
  export { keyFromLabel } from './keys.js';
7
7
  export type { KeyOptions, KeyStyle } from './keys.js';
8
8
  export { LoadingRows, LoadingScreen } from './loading.js';
9
+ export { LogItem, LogList, LogTime } from './log-list.js';
10
+ export type { LogItemProps, LogListProps, LogTimeProps } from './log-list.js';
9
11
  export { NavScreen } from './nav-screen.js';
10
12
  export type { NavScreenProps } from './nav-screen.js';
11
13
  export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { DENSE_BREAKPOINT, RAIL_BREAKPOINT, SMALL_VIEWPORT } from './breakpoints
4
4
  export { Frame } from './frame.js';
5
5
  export { keyFromLabel } from './keys.js';
6
6
  export { LoadingRows, LoadingScreen } from './loading.js';
7
+ export { LogItem, LogList, LogTime } from './log-list.js';
7
8
  export { NavScreen } from './nav-screen.js';
8
9
  export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
9
10
  export { useRowKeys } from './row-keys.js';
@@ -0,0 +1,46 @@
1
+ import type { ReactNode } from 'react';
2
+ /** What a log list needs. */
3
+ export interface LogListProps {
4
+ /** The items, each a LogItem the caller keys by its own id, in the order they read. */
5
+ children: ReactNode;
6
+ /** The id of the visible heading that names the list. */
7
+ 'aria-labelledby'?: string;
8
+ }
9
+ /** What one item of a log list needs. */
10
+ export interface LogItemProps {
11
+ /** The start of the header line, such as a LogTime. */
12
+ label?: ReactNode;
13
+ /** The controls at the end of the header line. */
14
+ actions?: ReactNode;
15
+ /** The item's text, shown with its line breaks kept. */
16
+ body?: string;
17
+ /** Any other content, shown under the body. */
18
+ children?: ReactNode;
19
+ /** The name the item is announced by. */
20
+ 'aria-label'?: string;
21
+ }
22
+ /** What a log time needs. */
23
+ export interface LogTimeProps {
24
+ /** The date or time in machine readable form, such as 2026-01-01. */
25
+ dateTime: string;
26
+ /** The date or time as the reader sees it. */
27
+ children: ReactNode;
28
+ }
29
+ /**
30
+ * Renders items one under the other in the order given.
31
+ * @param props - The items and the id of the heading that names the list.
32
+ * @returns The log list element.
33
+ */
34
+ export declare function LogList({ children, 'aria-labelledby': labelledBy }: LogListProps): import("react").JSX.Element;
35
+ /**
36
+ * Renders one log item, its header line over its text and any other content.
37
+ * @param props - The label, the actions, the text, the other content and the item's name.
38
+ * @returns The log item element.
39
+ */
40
+ export declare function LogItem({ label, actions, body, children, 'aria-label': name }: LogItemProps): import("react").JSX.Element;
41
+ /**
42
+ * Renders a date or time as small muted text inside a time element.
43
+ * @param props - The machine readable value and the text the reader sees.
44
+ * @returns The time element.
45
+ */
46
+ export declare function LogTime({ dateTime, children }: LogTimeProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Text } from '@wordpress/ui';
4
+ /**
5
+ * Renders items one under the other in the order given.
6
+ * @param props - The items and the id of the heading that names the list.
7
+ * @returns The log list element.
8
+ */
9
+ export function LogList({ children, 'aria-labelledby': labelledBy }) {
10
+ return (_jsx("ul", { role: "list", className: "godmin-log-list", "aria-labelledby": labelledBy, children: children }));
11
+ }
12
+ /**
13
+ * Renders one log item, its header line over its text and any other content.
14
+ * @param props - The label, the actions, the text, the other content and the item's name.
15
+ * @returns The log item element.
16
+ */
17
+ export function LogItem({ label, actions, body, children, 'aria-label': name }) {
18
+ return (_jsxs("li", { className: "godmin-log-list__item", "aria-label": name, children: [_jsx(LogHeader, { label: label, actions: actions }), body !== undefined && (_jsx(Text, { render: _jsx("p", {}), className: "godmin-log-list__body", children: body })), children] }));
19
+ }
20
+ /**
21
+ * Renders the header line of a log item, or nothing without a label or actions.
22
+ * @param props - The label and the actions.
23
+ * @returns The header line element, or null.
24
+ */
25
+ function LogHeader({ label, actions }) {
26
+ const labelled = rendersSomething(label);
27
+ const acting = rendersSomething(actions);
28
+ if (!labelled && !acting) {
29
+ return null;
30
+ }
31
+ return (_jsxs("div", { className: "godmin-log-list__header", children: [labelled && _jsx("div", { className: "godmin-log-list__label", children: label }), acting && _jsx("div", { className: "godmin-log-list__actions", children: actions })] }));
32
+ }
33
+ /**
34
+ * Reports whether React renders anything for a node.
35
+ * @param node - The node to check.
36
+ * @returns False for undefined, null, booleans, an empty string and a list of those, true otherwise.
37
+ */
38
+ function rendersSomething(node) {
39
+ if (Array.isArray(node)) {
40
+ return node.some(rendersSomething);
41
+ }
42
+ return node !== undefined && node !== null && node !== '' && typeof node !== 'boolean';
43
+ }
44
+ /**
45
+ * Renders a date or time as small muted text inside a time element.
46
+ * @param props - The machine readable value and the text the reader sees.
47
+ * @returns The time element.
48
+ */
49
+ export function LogTime({ dateTime, children }) {
50
+ return (_jsx(Text, { variant: "body-sm", render: _jsx("time", { dateTime: dateTime }), className: "godmin-log-list__time", children: children }));
51
+ }
package/dist/page.d.ts CHANGED
@@ -14,16 +14,17 @@ export interface PageProps {
14
14
  title: string;
15
15
  subtitle?: string;
16
16
  actions?: ReactNode;
17
+ aside?: ReactNode;
17
18
  className?: string;
18
19
  children: ReactNode;
19
20
  }
20
21
  /**
21
22
  * Renders a screen: its title top left, an optional subtitle under it,
22
- * optional actions top right, and the content below.
23
- * @param props - The title, subtitle, actions, extra class and content.
23
+ * optional actions top right, and the content below, beside an optional aside.
24
+ * @param props - The title, subtitle, actions, aside, extra class and content.
24
25
  * @returns The page element.
25
26
  */
26
- export declare function Page({ title, subtitle, actions, className, children }: PageProps): import("react").JSX.Element;
27
+ export declare function Page({ title, subtitle, actions, aside, className, children }: PageProps): import("react").JSX.Element;
27
28
  /**
28
29
  * Renders a failure message that a screen reader announces.
29
30
  * @param props - The message to announce.
package/dist/page.js CHANGED
@@ -12,13 +12,24 @@ export function PageTitle({ children, variant = 'heading-xl', }) {
12
12
  }
13
13
  /**
14
14
  * Renders a screen: its title top left, an optional subtitle under it,
15
- * optional actions top right, and the content below.
16
- * @param props - The title, subtitle, actions, extra class and content.
15
+ * optional actions top right, and the content below, beside an optional aside.
16
+ * @param props - The title, subtitle, actions, aside, extra class and content.
17
17
  * @returns The page element.
18
18
  */
19
- export function Page({ title, subtitle, actions, className, children }) {
19
+ export function Page({ title, subtitle, actions, aside, className, children }) {
20
20
  const classes = className === undefined ? 'godmin-page' : `godmin-page ${className}`;
21
- return (_jsxs(Stack, { direction: "column", gap: "lg", className: classes, children: [_jsxs(Stack, { direction: "row", gap: "md", align: "center", justify: "space-between", children: [_jsxs(Stack, { direction: "column", gap: "xs", children: [_jsx(PageTitle, { children: title }), subtitle !== undefined && (_jsx(Text, { variant: "body-sm", className: "godmin-page__subtitle", children: subtitle }))] }), actions !== undefined && (_jsx(Stack, { direction: "row", gap: "sm", align: "center", children: actions }))] }), children] }));
21
+ return (_jsxs(Stack, { direction: "column", gap: "lg", className: classes, children: [_jsxs(Stack, { direction: "row", gap: "md", align: "center", justify: "space-between", children: [_jsxs(Stack, { direction: "column", gap: "xs", children: [_jsx(PageTitle, { children: title }), subtitle !== undefined && (_jsx(Text, { variant: "body-sm", className: "godmin-page__subtitle", children: subtitle }))] }), actions !== undefined && (_jsx(Stack, { direction: "row", gap: "sm", align: "center", children: actions }))] }), _jsx(PageBody, { aside: aside, children: children })] }));
22
+ }
23
+ /**
24
+ * Renders a page's content, beside its aside when it has one.
25
+ * @param props - The content and the optional aside.
26
+ * @returns The content alone, or a main column followed by the aside.
27
+ */
28
+ function PageBody({ aside, children }) {
29
+ if (aside === undefined) {
30
+ return children;
31
+ }
32
+ return (_jsxs("div", { className: "godmin-page__split", children: [_jsx(Stack, { direction: "column", gap: "lg", className: "godmin-page__main", children: children }), _jsx(Stack, { direction: "column", gap: "lg", className: "godmin-page__aside", children: aside })] }));
22
33
  }
23
34
  /**
24
35
  * Renders a failure message that a screen reader announces.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "The admin kit for Gopherium projects: host layer for React admin applications on the WordPress Design System.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",