@gopherium/godmin 0.11.0 → 0.12.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`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
50
+ | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `SectionTitle`, `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
@@ -126,14 +126,12 @@ body {
126
126
  }
127
127
 
128
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);
129
+ flex: 1 1 var(--wpds-dimension-surface-width-lg);
132
130
  }
133
131
 
134
132
  .godmin-page__aside {
135
- flex: 0 1 var(--wpds-dimension-surface-width-sm);
136
- min-inline-size: 0;
133
+ flex: 999 1 0;
134
+ min-inline-size: min(100%, var(--wpds-dimension-surface-width-xs));
137
135
  overflow-wrap: anywhere;
138
136
  }
139
137
 
@@ -145,7 +143,36 @@ body {
145
143
  display: flex;
146
144
  flex-direction: column;
147
145
  gap: var(--wpds-dimension-gap-md);
148
- max-width: var(--wpds-dimension-surface-width-sm);
146
+ max-width: var(--wpds-dimension-surface-width-lg);
147
+ }
148
+
149
+ .godmin-form--inline {
150
+ max-width: none;
151
+ }
152
+
153
+ .godmin-form > button {
154
+ align-self: flex-start;
155
+ }
156
+
157
+ .godmin-form__row {
158
+ display: flex;
159
+ flex-wrap: wrap;
160
+ align-items: flex-end;
161
+ gap: var(--wpds-dimension-gap-md);
162
+ }
163
+
164
+ .godmin-form__row > * {
165
+ flex: 1 1 calc(var(--wpds-dimension-surface-width-xs) * 2 / 3);
166
+ min-inline-size: 0;
167
+ }
168
+
169
+ .godmin-form__row > .godmin-form__grow {
170
+ flex-grow: 3;
171
+ }
172
+
173
+ .godmin-form__row > button {
174
+ flex: none;
175
+ margin-inline-start: auto;
149
176
  }
150
177
 
151
178
  .godmin-empty {
@@ -248,6 +275,23 @@ body {
248
275
  outline-offset: 2px;
249
276
  }
250
277
 
278
+ .godmin-rows__line {
279
+ display: flex;
280
+ flex-wrap: wrap;
281
+ align-items: flex-end;
282
+ gap: var(--wpds-dimension-gap-md);
283
+ }
284
+
285
+ .godmin-rows__inputs {
286
+ flex: 1 1 var(--wpds-dimension-surface-width-sm);
287
+ min-inline-size: 0;
288
+ }
289
+
290
+ .godmin-rows__controls {
291
+ flex: none;
292
+ margin-inline-start: auto;
293
+ }
294
+
251
295
  .godmin-log-list {
252
296
  margin: 0;
253
297
  padding: 0;
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { LogItem, LogList, LogTime } from './log-list.js';
10
10
  export type { LogItemProps, LogListProps, LogTimeProps } from './log-list.js';
11
11
  export { NavScreen } from './nav-screen.js';
12
12
  export type { NavScreenProps } from './nav-screen.js';
13
- export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
13
+ export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
14
14
  export type { LoadMoreQuery, PageProps } from './page.js';
15
15
  export { useRowKeys } from './row-keys.js';
16
16
  export type { RowBounds, RowKeys } from './row-keys.js';
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ export { keyFromLabel } from './keys.js';
6
6
  export { LoadingRows, LoadingScreen } from './loading.js';
7
7
  export { LogItem, LogList, LogTime } from './log-list.js';
8
8
  export { NavScreen } from './nav-screen.js';
9
- export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
9
+ export { ErrorNotice, LoadMore, Page, PageTitle, SectionTitle } from './page.js';
10
10
  export { useRowKeys } from './row-keys.js';
11
11
  export { RepeatRows, RowControls } from './rows.js';
12
12
  export { Toaster, useToaster } from './toaster.js';
package/dist/page.d.ts CHANGED
@@ -10,6 +10,17 @@ export declare function PageTitle({ children, variant, }: {
10
10
  children: ReactNode;
11
11
  variant?: TextVariant;
12
12
  }): import("react").JSX.Element;
13
+ /**
14
+ * Renders a section heading one size step above the field labels.
15
+ * @param props - The heading text, its level, and the id and tab index a screen moves focus with.
16
+ * @returns The section heading element.
17
+ */
18
+ export declare function SectionTitle({ children, level, id, tabIndex, }: {
19
+ children: ReactNode;
20
+ level?: 2 | 3;
21
+ id?: string;
22
+ tabIndex?: number;
23
+ }): import("react").JSX.Element;
13
24
  export interface PageProps {
14
25
  title: string;
15
26
  subtitle?: string;
package/dist/page.js CHANGED
@@ -10,6 +10,15 @@ import { Button, Notice, Stack, Text } from '@wordpress/ui';
10
10
  export function PageTitle({ children, variant = 'heading-xl', }) {
11
11
  return (_jsx(Text, { variant: variant, render: _jsx("h1", {}), children: children }));
12
12
  }
13
+ /**
14
+ * Renders a section heading one size step above the field labels.
15
+ * @param props - The heading text, its level, and the id and tab index a screen moves focus with.
16
+ * @returns The section heading element.
17
+ */
18
+ export function SectionTitle({ children, level = 2, id, tabIndex, }) {
19
+ const second = level === 2;
20
+ return (_jsx(Text, { variant: second ? 'heading-lg' : 'heading-md', render: second ? _jsx("h2", {}) : _jsx("h3", {}), id: id, tabIndex: tabIndex, children: children }));
21
+ }
13
22
  /**
14
23
  * Renders a screen: its title top left, an optional subtitle under it,
15
24
  * optional actions top right, and the content below, beside an optional aside.
package/dist/rows.js CHANGED
@@ -5,13 +5,14 @@ import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';
5
5
  import { useRowKeys } from './row-keys.js';
6
6
  const upIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: _jsx("path", { d: "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" }) }));
7
7
  const downIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: _jsx("path", { d: "M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z" }) }));
8
+ const removeIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: _jsx("path", { d: "M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" }) }));
8
9
  /**
9
10
  * Renders the buttons that move a row among its siblings and take it away.
10
11
  * @param props - The row's place, the list's length, the words and what to call on a change.
11
12
  * @returns The controls element.
12
13
  */
13
14
  export function RowControls({ at, count, removable = true, labels, onMove, onRemove }) {
14
- return (_jsxs(Stack, { direction: "row", gap: "xs", align: "center", children: [_jsx(IconButton, { icon: upIcon, label: labels.moveUp, size: "compact", variant: "minimal", tone: "neutral", disabled: at === 0, onClick: () => onMove(-1) }), _jsx(IconButton, { icon: downIcon, label: labels.moveDown, size: "compact", variant: "minimal", tone: "neutral", disabled: at === count - 1, onClick: () => onMove(1) }), _jsx(Button, { variant: "outline", size: "compact", disabled: !removable, onClick: onRemove, children: labels.remove })] }));
15
+ return (_jsxs(Stack, { direction: "row", gap: "xs", align: "center", className: "godmin-rows__controls", children: [_jsx(IconButton, { icon: upIcon, label: labels.moveUp, size: "compact", variant: "minimal", tone: "neutral", disabled: at === 0, onClick: () => onMove(-1) }), _jsx(IconButton, { icon: downIcon, label: labels.moveDown, size: "compact", variant: "minimal", tone: "neutral", disabled: at === count - 1, onClick: () => onMove(1) }), _jsx(IconButton, { icon: removeIcon, label: labels.remove, size: "compact", variant: "minimal", tone: "neutral", disabled: !removable, onClick: onRemove })] }));
15
16
  }
16
17
  /**
17
18
  * Returns where focus goes after the rows shown change.
@@ -120,7 +121,7 @@ function useRowFocus(keys) {
120
121
  function RowGroup({ rowKey, row, at, count, removable, labels, renderRow, rowLabel, update, move, remove, register, entered, }) {
121
122
  const changed = useCallback((next) => update(rowKey, next), [update, rowKey]);
122
123
  const ref = useCallback((element) => register(rowKey, element), [register, rowKey]);
123
- return (_jsx("div", { ref: ref, role: "group", "aria-label": rowLabel(at), tabIndex: -1, className: "godmin-rows__row", onFocus: (event) => entered(rowKey, event.target), children: _jsxs(Stack, { direction: "column", gap: "xs", children: [renderRow(row, changed, at), _jsx(RowControls, { at: at, count: count, removable: removable, labels: labels, onMove: (offset) => move(rowKey, offset), onRemove: () => remove(rowKey) })] }) }));
124
+ return (_jsx("div", { ref: ref, role: "group", "aria-label": rowLabel(at), tabIndex: -1, className: "godmin-rows__row", onFocus: (event) => entered(rowKey, event.target), children: _jsxs("div", { className: "godmin-rows__line", children: [_jsx("div", { className: "godmin-rows__inputs", children: renderRow(row, changed, at) }), _jsx(RowControls, { at: at, count: count, removable: removable, labels: labels, onMove: (offset) => move(rowKey, offset), onRemove: () => remove(rowKey) })] }) }));
124
125
  }
125
126
  /** The group of one row, rendered again only when its own props change. */
126
127
  const Row = memo(RowGroup);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",