@gopherium/godmin 0.11.0 → 0.13.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 {
@@ -176,6 +203,19 @@ body {
176
203
  white-space: nowrap;
177
204
  }
178
205
 
206
+ .godmin-table__actions * {
207
+ white-space: nowrap;
208
+ }
209
+
210
+ .godmin-table tbody tr:is(:hover, :has(:focus-visible)) > * {
211
+ background: var(--wpds-color-background-surface-neutral-weak);
212
+ }
213
+
214
+ .godmin-table-scroll:focus-visible {
215
+ outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
216
+ outline-offset: 2px;
217
+ }
218
+
179
219
  .godmin-loading-screen,
180
220
  .godmin-loading-rows {
181
221
  opacity: 0;
@@ -248,6 +288,31 @@ body {
248
288
  outline-offset: 2px;
249
289
  }
250
290
 
291
+ .godmin-rows__line {
292
+ display: flex;
293
+ flex-wrap: wrap;
294
+ align-items: flex-end;
295
+ gap: var(--wpds-dimension-gap-md);
296
+ }
297
+
298
+ .godmin-rows__inputs {
299
+ flex: 1 1 var(--wpds-dimension-surface-width-sm);
300
+ min-inline-size: 0;
301
+ }
302
+
303
+ .godmin-rows__controls {
304
+ flex: none;
305
+ margin-inline-start: auto;
306
+ }
307
+
308
+ .godmin-rows__remove {
309
+ margin-inline-start: calc(var(--wpds-dimension-gap-md) - var(--wpds-dimension-gap-xs));
310
+ }
311
+
312
+ .godmin-table__actions .godmin-rows__controls {
313
+ justify-content: flex-end;
314
+ }
315
+
251
316
  .godmin-log-list {
252
317
  margin: 0;
253
318
  padding: 0;
@@ -324,9 +389,15 @@ body {
324
389
  overflow-x: auto;
325
390
  }
326
391
 
327
- .godmin-table-scroll:focus-visible {
328
- outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
329
- outline-offset: 2px;
392
+ .godmin-table-scroll .godmin-table__actions {
393
+ position: sticky;
394
+ inset-inline-end: 0;
395
+ background: var(--wpds-color-background-surface-neutral);
396
+ box-shadow: inset var(--wpds-border-width-xs) 0 0 var(--wpds-color-stroke-surface-neutral);
397
+ }
398
+
399
+ .godmin-table-scroll .godmin-table__actions:dir(rtl) {
400
+ box-shadow: inset calc(-1 * var(--wpds-border-width-xs)) 0 0 var(--wpds-color-stroke-surface-neutral);
330
401
  }
331
402
  }
332
403
  }
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
@@ -1,17 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { Button, IconButton, Stack, Text } from '@wordpress/ui';
3
+ import { chevronDown, chevronUp, trash } from '@wordpress/icons';
4
+ import { Button, IconButton, Stack, Text, Tooltip } from '@wordpress/ui';
4
5
  import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';
5
6
  import { useRowKeys } from './row-keys.js';
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
- 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
7
  /**
9
8
  * Renders the buttons that move a row among its siblings and take it away.
10
9
  * @param props - The row's place, the list's length, the words and what to call on a change.
11
10
  * @returns The controls element.
12
11
  */
13
12
  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 })] }));
13
+ return (_jsxs(Stack, { direction: "row", gap: "xs", align: "center", className: "godmin-rows__controls", children: [_jsx(IconButton, { icon: chevronUp, label: labels.moveUp, size: "compact", variant: "minimal", tone: "neutral", disabled: at === 0, onClick: () => onMove(-1) }), _jsx(IconButton, { icon: chevronDown, label: labels.moveDown, size: "compact", variant: "minimal", tone: "neutral", disabled: at === count - 1, onClick: () => onMove(1) }), _jsx(IconButton, { icon: trash, label: labels.remove, className: "godmin-rows__remove", positioner: _jsx(Tooltip.Positioner, { align: "end" }), size: "compact", variant: "minimal", tone: "neutral", disabled: !removable, onClick: onRemove })] }));
15
14
  }
16
15
  /**
17
16
  * Returns where focus goes after the rows shown change.
@@ -120,7 +119,7 @@ function useRowFocus(keys) {
120
119
  function RowGroup({ rowKey, row, at, count, removable, labels, renderRow, rowLabel, update, move, remove, register, entered, }) {
121
120
  const changed = useCallback((next) => update(rowKey, next), [update, rowKey]);
122
121
  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) })] }) }));
122
+ 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
123
  }
125
124
  /** The group of one row, rendered again only when its own props change. */
126
125
  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.13.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",
@@ -58,6 +58,7 @@
58
58
  "peerDependencies": {
59
59
  "@tanstack/react-router": "^1.170.0",
60
60
  "@testing-library/react": "^16.3.2",
61
+ "@wordpress/icons": ">=16.0.0 <17.0.0",
61
62
  "@wordpress/style-runtime": ">=0.11.0 <0.12.0",
62
63
  "@wordpress/theme": ">=2.1.0 <3.0.0",
63
64
  "@wordpress/ui": ">=0.22.0 <0.23.0",
@@ -88,6 +89,7 @@
88
89
  "@vitest/coverage-v8": "^4.1.10",
89
90
  "@wordpress/a11y": "4.55.0",
90
91
  "@wordpress/element": "8.7.0",
92
+ "@wordpress/icons": "16.0.0",
91
93
  "@wordpress/style-runtime": "0.11.0",
92
94
  "@wordpress/theme": "2.1.0",
93
95
  "@wordpress/ui": "0.22.0",