@gopherium/godmin 0.25.0 → 0.26.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 +3 -2
- package/dist/drilldown-item.d.ts +5 -3
- package/dist/drilldown-item.js +6 -6
- package/dist/menu-item.d.ts +7 -0
- package/dist/navigation-item.d.ts +8 -0
- package/dist/navigation-item.js +9 -1
- package/dist/navigation-list.js +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ two lines do for you.
|
|
|
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 |
|
|
59
|
-
| `@gopherium/godmin/router` | `Navigation`, `NavigationList`, `NavigationItem`, `DrilldownItem`, `useCanAccess` and the `MenuItem` type
|
|
59
|
+
| `@gopherium/godmin/router` | `Navigation`, `NavigationList`, `NavigationItem`, `DrilldownItem`, `useCanAccess` and the `MenuItem` type with its optional `count`, `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, `routerDefaults`, the `canvas`, `Sidebar` and `capability` route static data |
|
|
60
60
|
| `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport` and its `TestViewport` type, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR`, `textClasses`, `badgeClasses`, `buttonClasses`, `stubLayout` |
|
|
61
61
|
| `@gopherium/godmin/vite` | `godminDedupe`, `godminSingleCopy`, `godminStylesheetFirst`, `duplicateCopies`, `hoistStylesheet` |
|
|
62
62
|
| `@gopherium/godmin/stylelint` | The design system stylelint rules |
|
package/dist/base.css
CHANGED
|
@@ -206,15 +206,16 @@ body {
|
|
|
206
206
|
.godmin-menu-count__badge {
|
|
207
207
|
--godmin-menu-count-size: 18px;
|
|
208
208
|
display: inline-block;
|
|
209
|
-
vertical-align:
|
|
209
|
+
vertical-align: middle;
|
|
210
210
|
box-sizing: border-box;
|
|
211
211
|
min-inline-size: var(--godmin-menu-count-size);
|
|
212
212
|
block-size: var(--godmin-menu-count-size);
|
|
213
|
-
margin-block: 1px -1px;
|
|
214
213
|
margin-inline-start: 2px;
|
|
215
214
|
padding-block: 0;
|
|
216
215
|
padding-inline: 5px;
|
|
217
216
|
border-radius: calc(var(--godmin-menu-count-size) / 2);
|
|
217
|
+
background-color: var(--wpds-color-background-thumb-brand);
|
|
218
|
+
color: var(--wpds-color-foreground-interactive-neutral-strong);
|
|
218
219
|
font-size: var(--wpds-typography-font-size-xs);
|
|
219
220
|
font-weight: inherit;
|
|
220
221
|
line-height: 1.6;
|
package/dist/drilldown-item.d.ts
CHANGED
|
@@ -6,12 +6,14 @@ export type DrilldownItemProps<TRouter extends AnyRouter = RegisteredRouter, TFr
|
|
|
6
6
|
id?: never;
|
|
7
7
|
/** A glyph from `@wordpress/icons`, drawn at 24px. */
|
|
8
8
|
icon?: ReactElement;
|
|
9
|
+
/** Drawn before the chevron, such as a MenuCount. */
|
|
10
|
+
suffix?: ReactNode;
|
|
9
11
|
children: ReactNode;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
|
-
* Renders a sidebar row that opens a sub menu: its icon,
|
|
14
|
+
* Renders a sidebar row that opens a sub menu: its icon, label, suffix and chevron, with an id taken from its address.
|
|
13
15
|
* A plain click inside a frame records a forward move from this row to its address.
|
|
14
|
-
* @param props - The TanStack Link props, the icon and the label.
|
|
16
|
+
* @param props - The TanStack Link props, the icon, the suffix and the label.
|
|
15
17
|
* @returns The row element, or null when its address opens a route the reader may not open.
|
|
16
18
|
*/
|
|
17
|
-
export declare function DrilldownItem<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>({ icon, children, ...link }: DrilldownItemProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): import("react").JSX.Element;
|
|
19
|
+
export declare function DrilldownItem<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>({ icon, suffix, children, ...link }: DrilldownItemProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): import("react").JSX.Element;
|
package/dist/drilldown-item.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useRouter } from '@tanstack/react-router';
|
|
4
4
|
import { isRTL } from '@wordpress/i18n';
|
|
5
5
|
import { Icon, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
|
|
6
6
|
import { useContext } from 'react';
|
|
7
|
-
import { ROW_CLASS, Row } from './navigation-item.js';
|
|
7
|
+
import { ROW_CLASS, Row, RowSuffix } from './navigation-item.js';
|
|
8
8
|
import { NavigationStateContext, isPlainClick, recordDrilldown } from './navigation-state.js';
|
|
9
9
|
import { findMoveTarget, findRowRoutes } from './path-matching.js';
|
|
10
10
|
/** The start of the id a drilldown row takes from its address. */
|
|
11
11
|
const ID_PREFIX = 'godmin-drilldown-item-';
|
|
12
12
|
/**
|
|
13
|
-
* Renders a sidebar row that opens a sub menu: its icon,
|
|
13
|
+
* Renders a sidebar row that opens a sub menu: its icon, label, suffix and chevron, with an id taken from its address.
|
|
14
14
|
* A plain click inside a frame records a forward move from this row to its address.
|
|
15
|
-
* @param props - The TanStack Link props, the icon and the label.
|
|
15
|
+
* @param props - The TanStack Link props, the icon, the suffix and the label.
|
|
16
16
|
* @returns The row element, or null when its address opens a route the reader may not open.
|
|
17
17
|
*/
|
|
18
|
-
export function DrilldownItem({ icon, children, ...link }) {
|
|
18
|
+
export function DrilldownItem({ icon, suffix, children, ...link }) {
|
|
19
19
|
const router = useRouter();
|
|
20
20
|
const state = useContext(NavigationStateContext);
|
|
21
21
|
const address = link;
|
|
@@ -27,5 +27,5 @@ export function DrilldownItem({ icon, children, ...link }) {
|
|
|
27
27
|
recordDrilldown(state, id, findMoveTarget(router, address));
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
return (_jsx(Row, { link: { ...address, onClick }, routes: routes, icon: icon, className: ROW_CLASS, id: id, end: _jsx(Icon, { icon: isRTL() ? chevronLeftSmall : chevronRightSmall, size: 24, className: "godmin-navigation-item__drilldown-indicator" }), children: children }));
|
|
30
|
+
return (_jsx(Row, { link: { ...address, onClick }, routes: routes, icon: icon, className: ROW_CLASS, id: id, end: _jsxs(_Fragment, { children: [suffix === undefined ? null : _jsx(RowSuffix, { children: suffix }), _jsx(Icon, { icon: isRTL() ? chevronLeftSmall : chevronRightSmall, size: 24, className: "godmin-navigation-item__drilldown-indicator" })] }), children: children }));
|
|
31
31
|
}
|
package/dist/menu-item.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export interface MenuItem {
|
|
|
12
12
|
capability?: string;
|
|
13
13
|
/** The row shown in this one's place when the reader cannot open it. */
|
|
14
14
|
fallback?: MenuItem;
|
|
15
|
+
/** The count drawn after the label and before the chevron of a row that opens a sub menu, none at zero or below. */
|
|
16
|
+
count?: {
|
|
17
|
+
/** The number the row shows. */
|
|
18
|
+
value: number;
|
|
19
|
+
/** The sentence a screen reader reads in place of the number, such as "1 update available". */
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
15
22
|
}
|
|
16
23
|
/**
|
|
17
24
|
* Tells whether a reader may open every route an address opens, parents and params included.
|
|
@@ -30,6 +30,14 @@ interface RowProps {
|
|
|
30
30
|
end?: ReactNode;
|
|
31
31
|
children: ReactNode;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders what a row draws after its label, such as a MenuCount.
|
|
35
|
+
* @param props - What the row draws.
|
|
36
|
+
* @returns The suffix element.
|
|
37
|
+
*/
|
|
38
|
+
export declare function RowSuffix({ children }: {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
}): import("react").JSX.Element;
|
|
33
41
|
/**
|
|
34
42
|
* Renders a sidebar row as a list item holding its link, or nothing when the reader may not open its routes.
|
|
35
43
|
* @param props - The link props, where the row goes, the icon, the classes, the id, the end of the row and its label.
|
package/dist/navigation-item.js
CHANGED
|
@@ -22,6 +22,14 @@ function RowIcon({ icon }) {
|
|
|
22
22
|
}
|
|
23
23
|
return placeholder ? _jsx("span", { className: ICON_CLASS, "aria-hidden": "true" }) : null;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders what a row draws after its label, such as a MenuCount.
|
|
27
|
+
* @param props - What the row draws.
|
|
28
|
+
* @returns The suffix element.
|
|
29
|
+
*/
|
|
30
|
+
export function RowSuffix({ children }) {
|
|
31
|
+
return _jsx("span", { className: "godmin-navigation-item__suffix", children: children });
|
|
32
|
+
}
|
|
25
33
|
/**
|
|
26
34
|
* Renders a sidebar row as a list item holding its link, or nothing when the reader may not open its routes.
|
|
27
35
|
* @param props - The link props, where the row goes, the icon, the classes, the id, the end of the row and its label.
|
|
@@ -46,5 +54,5 @@ export function NavigationItem({ icon, suffix, children, ...link }) {
|
|
|
46
54
|
if (suffix === undefined) {
|
|
47
55
|
return (_jsx(Row, { link: address, routes: routes, icon: icon, className: ROW_CLASS, children: children }));
|
|
48
56
|
}
|
|
49
|
-
return (_jsx(Row, { link: address, routes: routes, icon: icon, className: `${ROW_CLASS} ${ROW_CLASS}--with-suffix`, end: _jsx(
|
|
57
|
+
return (_jsx(Row, { link: address, routes: routes, icon: icon, className: `${ROW_CLASS} ${ROW_CLASS}--with-suffix`, end: _jsx(RowSuffix, { children: suffix }), children: children }));
|
|
50
58
|
}
|
package/dist/navigation-list.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRouter, useRouterState } from '@tanstack/react-router';
|
|
4
4
|
import { Children, isValidElement, useContext } from 'react';
|
|
5
5
|
import { DrilldownItem } from './drilldown-item.js';
|
|
6
|
+
import { MenuCount } from './menu-count.js';
|
|
6
7
|
import { canOpenRoutes, useCanAccess } from './menu-item.js';
|
|
7
8
|
import { NavigationItem } from './navigation-item.js';
|
|
8
9
|
import { IconPlaceholderContext, ScreenContext } from './navigation-state.js';
|
|
@@ -32,6 +33,14 @@ function showsIcon(child, router, can) {
|
|
|
32
33
|
}
|
|
33
34
|
return canOpenRoutes(findRouteCapabilities(router, child.props), can);
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the MenuCount a row of data draws after its label, none when its count is absent or not above zero.
|
|
38
|
+
* @param count - The count of the row.
|
|
39
|
+
* @returns The count element, or undefined.
|
|
40
|
+
*/
|
|
41
|
+
function countSuffix(count) {
|
|
42
|
+
return count !== undefined && count.value > 0 ? _jsx(MenuCount, { count: count.value, label: count.label }) : undefined;
|
|
43
|
+
}
|
|
35
44
|
/**
|
|
36
45
|
* Renders a row of data as a DrilldownItem when it opens a sub menu other than the one shown, else a NavigationItem.
|
|
37
46
|
* @param props - The row, and the id of the sub menu route shown now, undefined on the root screen.
|
|
@@ -40,10 +49,11 @@ function showsIcon(child, router, can) {
|
|
|
40
49
|
function DataRow({ item, shown }) {
|
|
41
50
|
const router = useRouter();
|
|
42
51
|
const target = findDrilldownParent(router, { to: item.to });
|
|
52
|
+
const suffix = countSuffix(item.count);
|
|
43
53
|
if (target !== undefined && target !== shown) {
|
|
44
|
-
return (_jsx(DrilldownItem, { to: item.to, icon: item.icon, children: item.label }));
|
|
54
|
+
return (_jsx(DrilldownItem, { to: item.to, icon: item.icon, suffix: suffix, children: item.label }));
|
|
45
55
|
}
|
|
46
|
-
return (_jsx(NavigationItem, { to: item.to, icon: item.icon, children: item.label }));
|
|
56
|
+
return (_jsx(NavigationItem, { to: item.to, icon: item.icon, suffix: suffix, children: item.label }));
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
59
|
* Renders the rows of a sidebar screen as a list: the rows of items the reader may access, then the rows the app draws.
|
package/package.json
CHANGED