@gopherium/godmin 0.10.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
@@ -248,6 +248,61 @@ body {
248
248
  outline-offset: 2px;
249
249
  }
250
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
+
251
306
  /* Small viewport overrides live together at the end of the sheet, so they
252
307
  always win over the rules above them without extra specificity. */
253
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.10.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",